blob: 27592603c7095d4ae8a224689bfabfeceed71992 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
marpan@webrtc.org9d76b4e2012-02-28 23:39:31 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11/*
12 * frame_preprocessor.h
13 */
Henrik Kjellander0f59a882015-11-18 22:31:24 +010014#ifndef WEBRTC_MODULES_VIDEO_PROCESSING_FRAME_PREPROCESSOR_H_
15#define WEBRTC_MODULES_VIDEO_PROCESSING_FRAME_PREPROCESSOR_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000016
Henrik Kjellander0f59a882015-11-18 22:31:24 +010017#include "webrtc/modules/video_processing/include/video_processing.h"
18#include "webrtc/modules/video_processing/content_analysis.h"
19#include "webrtc/modules/video_processing/spatial_resampler.h"
20#include "webrtc/modules/video_processing/video_decimator.h"
jackychen8f9902a2015-11-26 02:59:48 -080021#include "webrtc/modules/video_processing/video_denoiser.h"
pbos@webrtc.org6f3d8fc2013-05-27 14:12:16 +000022#include "webrtc/typedefs.h"
jackychen8f9902a2015-11-26 02:59:48 -080023#include "webrtc/video_frame.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000024
25namespace webrtc {
26
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000027class VPMFramePreprocessor {
28 public:
29 VPMFramePreprocessor();
30 ~VPMFramePreprocessor();
niklase@google.com470e71d2011-07-07 08:21:25 +000031
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000032 void Reset();
niklase@google.com470e71d2011-07-07 08:21:25 +000033
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000034 // Enable temporal decimation.
35 void EnableTemporalDecimation(bool enable);
niklase@google.com470e71d2011-07-07 08:21:25 +000036
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000037 void SetInputFrameResampleMode(VideoFrameResampling resampling_mode);
niklase@google.com470e71d2011-07-07 08:21:25 +000038
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000039 // Enable content analysis.
40 void EnableContentAnalysis(bool enable);
niklase@google.com470e71d2011-07-07 08:21:25 +000041
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000042 // Set target resolution: frame rate and dimension.
43 int32_t SetTargetResolution(uint32_t width, uint32_t height,
44 uint32_t frame_rate);
niklase@google.com470e71d2011-07-07 08:21:25 +000045
jackychen6e2ce6e2015-07-13 16:26:33 -070046 // Set target frame rate.
47 void SetTargetFramerate(int frame_rate);
48
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000049 // Update incoming frame rate/dimension.
50 void UpdateIncomingframe_rate();
niklase@google.com470e71d2011-07-07 08:21:25 +000051
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000052 int32_t updateIncomingFrameSize(uint32_t width, uint32_t height);
niklase@google.com470e71d2011-07-07 08:21:25 +000053
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000054 // Set decimated values: frame rate/dimension.
55 uint32_t Decimatedframe_rate();
56 uint32_t DecimatedWidth() const;
57 uint32_t DecimatedHeight() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000058
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000059 // Preprocess output:
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -070060 int32_t PreprocessFrame(const VideoFrame& frame,
61 VideoFrame** processed_frame);
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000062 VideoContentMetrics* ContentMetrics() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000063
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000064 private:
65 // The content does not change so much every frame, so to reduce complexity
66 // we can compute new content metrics every |kSkipFrameCA| frames.
67 enum { kSkipFrameCA = 2 };
niklase@google.com470e71d2011-07-07 08:21:25 +000068
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000069 VideoContentMetrics* content_metrics_;
jackychen8f9902a2015-11-26 02:59:48 -080070 VideoFrame denoised_frame_;
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -070071 VideoFrame resampled_frame_;
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000072 VPMSpatialResampler* spatial_resampler_;
73 VPMContentAnalysis* ca_;
74 VPMVideoDecimator* vd_;
jackychen8f9902a2015-11-26 02:59:48 -080075 VideoDenoiser* denoiser_;
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000076 bool enable_ca_;
jackychen8f9902a2015-11-26 02:59:48 -080077 bool enable_denoising_;
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000078 int frame_cnt_;
niklase@google.com470e71d2011-07-07 08:21:25 +000079
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000080};
niklase@google.com470e71d2011-07-07 08:21:25 +000081
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000082} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000083
Henrik Kjellander0f59a882015-11-18 22:31:24 +010084#endif // WEBRTC_MODULES_VIDEO_PROCESSING_FRAME_PREPROCESSOR_H_