blob: 8e6bb9b3d0ec17a5b1487cf111312742ee50e476 [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.
44 int32_t SetTargetResolution(uint32_t width, uint32_t height,
45 uint32_t frame_rate);
niklase@google.com470e71d2011-07-07 08:21:25 +000046
jackychen6e2ce6e2015-07-13 16:26:33 -070047 // Set target frame rate.
48 void SetTargetFramerate(int frame_rate);
49
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000050 // Update incoming frame rate/dimension.
51 void UpdateIncomingframe_rate();
niklase@google.com470e71d2011-07-07 08:21:25 +000052
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000053 int32_t updateIncomingFrameSize(uint32_t width, uint32_t height);
niklase@google.com470e71d2011-07-07 08:21:25 +000054
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000055 // Set decimated values: frame rate/dimension.
mflodmana8565422015-12-07 01:09:52 -080056 uint32_t GetDecimatedFrameRate();
57 uint32_t GetDecimatedWidth() const;
58 uint32_t GetDecimatedHeight() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000059
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000060 // Preprocess output:
mflodmana8565422015-12-07 01:09:52 -080061 void EnableDenosing(bool enable);
62 const VideoFrame* PreprocessFrame(const VideoFrame& frame);
63 VideoContentMetrics* GetContentMetrics() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000064
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000065 private:
66 // The content does not change so much every frame, so to reduce complexity
67 // we can compute new content metrics every |kSkipFrameCA| frames.
68 enum { kSkipFrameCA = 2 };
niklase@google.com470e71d2011-07-07 08:21:25 +000069
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000070 VideoContentMetrics* content_metrics_;
jackychen8f9902a2015-11-26 02:59:48 -080071 VideoFrame denoised_frame_;
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -070072 VideoFrame resampled_frame_;
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000073 VPMSpatialResampler* spatial_resampler_;
74 VPMContentAnalysis* ca_;
75 VPMVideoDecimator* vd_;
mflodmana8565422015-12-07 01:09:52 -080076 rtc::scoped_ptr<VideoDenoiser> denoiser_;
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000077 bool enable_ca_;
mflodmana8565422015-12-07 01:09:52 -080078 uint32_t frame_cnt_;
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000079};
niklase@google.com470e71d2011-07-07 08:21:25 +000080
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000081} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000082
mflodmana8565422015-12-07 01:09:52 -080083#endif // WEBRTC_MODULES_VIDEO_PROCESSING_FRAME_PREPROCESSOR_H_