blob: 5bdc576f3712f7f71bdffb5f22ed0942fbd5f05d [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
Henrik Kjellander0f59a882015-11-18 22:31:24 +010011#ifndef WEBRTC_MODULES_VIDEO_PROCESSING_FRAME_PREPROCESSOR_H_
12#define WEBRTC_MODULES_VIDEO_PROCESSING_FRAME_PREPROCESSOR_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
mflodmana8565422015-12-07 01:09:52 -080014#include "webrtc/base/scoped_ptr.h"
Henrik Kjellander0f59a882015-11-18 22:31:24 +010015#include "webrtc/modules/video_processing/include/video_processing.h"
16#include "webrtc/modules/video_processing/content_analysis.h"
17#include "webrtc/modules/video_processing/spatial_resampler.h"
18#include "webrtc/modules/video_processing/video_decimator.h"
pbos@webrtc.org6f3d8fc2013-05-27 14:12:16 +000019#include "webrtc/typedefs.h"
jackychen8f9902a2015-11-26 02:59:48 -080020#include "webrtc/video_frame.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000021
22namespace webrtc {
23
mflodmana8565422015-12-07 01:09:52 -080024class VideoDenoiser;
25
26// All pointers/members in this class are assumed to be protected by the class
27// owner.
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000028class VPMFramePreprocessor {
29 public:
30 VPMFramePreprocessor();
31 ~VPMFramePreprocessor();
niklase@google.com470e71d2011-07-07 08:21:25 +000032
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000033 void Reset();
niklase@google.com470e71d2011-07-07 08:21:25 +000034
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000035 // Enable temporal decimation.
36 void EnableTemporalDecimation(bool enable);
niklase@google.com470e71d2011-07-07 08:21:25 +000037
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000038 void SetInputFrameResampleMode(VideoFrameResampling resampling_mode);
niklase@google.com470e71d2011-07-07 08:21:25 +000039
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000040 // Enable content analysis.
41 void EnableContentAnalysis(bool enable);
niklase@google.com470e71d2011-07-07 08:21:25 +000042
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000043 // Set target resolution: frame rate and dimension.
mflodman99ab9442015-12-07 22:54:50 -080044 int32_t SetTargetResolution(uint32_t width,
45 uint32_t height,
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000046 uint32_t frame_rate);
niklase@google.com470e71d2011-07-07 08:21:25 +000047
jackychen6e2ce6e2015-07-13 16:26:33 -070048 // Set target frame rate.
49 void SetTargetFramerate(int frame_rate);
50
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000051 // Update incoming frame rate/dimension.
52 void UpdateIncomingframe_rate();
niklase@google.com470e71d2011-07-07 08:21:25 +000053
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000054 int32_t updateIncomingFrameSize(uint32_t width, uint32_t height);
niklase@google.com470e71d2011-07-07 08:21:25 +000055
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000056 // Set decimated values: frame rate/dimension.
mflodmana8565422015-12-07 01:09:52 -080057 uint32_t GetDecimatedFrameRate();
58 uint32_t GetDecimatedWidth() const;
59 uint32_t GetDecimatedHeight() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000060
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000061 // Preprocess output:
mflodmana8565422015-12-07 01:09:52 -080062 void EnableDenosing(bool enable);
63 const VideoFrame* PreprocessFrame(const VideoFrame& frame);
64 VideoContentMetrics* GetContentMetrics() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000065
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000066 private:
67 // The content does not change so much every frame, so to reduce complexity
68 // we can compute new content metrics every |kSkipFrameCA| frames.
69 enum { kSkipFrameCA = 2 };
niklase@google.com470e71d2011-07-07 08:21:25 +000070
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000071 VideoContentMetrics* content_metrics_;
jackychen8f9902a2015-11-26 02:59:48 -080072 VideoFrame denoised_frame_;
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -070073 VideoFrame resampled_frame_;
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000074 VPMSpatialResampler* spatial_resampler_;
75 VPMContentAnalysis* ca_;
76 VPMVideoDecimator* vd_;
mflodmana8565422015-12-07 01:09:52 -080077 rtc::scoped_ptr<VideoDenoiser> denoiser_;
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000078 bool enable_ca_;
mflodmana8565422015-12-07 01:09:52 -080079 uint32_t frame_cnt_;
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
mflodmana8565422015-12-07 01:09:52 -080084#endif // WEBRTC_MODULES_VIDEO_PROCESSING_FRAME_PREPROCESSOR_H_