blob: 270fbc2fc9e9a713ab39f8bfebda8137f3da8ecc [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
kwiberge065fcf2016-03-02 01:01:11 -080014#include <memory>
15
Henrik Kjellander0f59a882015-11-18 22:31:24 +010016#include "webrtc/modules/video_processing/include/video_processing.h"
17#include "webrtc/modules/video_processing/content_analysis.h"
18#include "webrtc/modules/video_processing/spatial_resampler.h"
19#include "webrtc/modules/video_processing/video_decimator.h"
pbos@webrtc.org6f3d8fc2013-05-27 14:12:16 +000020#include "webrtc/typedefs.h"
jackychen8f9902a2015-11-26 02:59:48 -080021#include "webrtc/video_frame.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000022
23namespace webrtc {
24
mflodmana8565422015-12-07 01:09:52 -080025class VideoDenoiser;
26
27// All pointers/members in this class are assumed to be protected by the class
28// owner.
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000029class VPMFramePreprocessor {
30 public:
31 VPMFramePreprocessor();
32 ~VPMFramePreprocessor();
niklase@google.com470e71d2011-07-07 08:21:25 +000033
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000034 void Reset();
niklase@google.com470e71d2011-07-07 08:21:25 +000035
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000036 // Enable temporal decimation.
37 void EnableTemporalDecimation(bool enable);
niklase@google.com470e71d2011-07-07 08:21:25 +000038
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000039 void SetInputFrameResampleMode(VideoFrameResampling resampling_mode);
niklase@google.com470e71d2011-07-07 08:21:25 +000040
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000041 // Enable content analysis.
42 void EnableContentAnalysis(bool enable);
niklase@google.com470e71d2011-07-07 08:21:25 +000043
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000044 // Set target resolution: frame rate and dimension.
mflodman99ab9442015-12-07 22:54:50 -080045 int32_t SetTargetResolution(uint32_t width,
46 uint32_t height,
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000047 uint32_t frame_rate);
niklase@google.com470e71d2011-07-07 08:21:25 +000048
jackychen6e2ce6e2015-07-13 16:26:33 -070049 // Set target frame rate.
50 void SetTargetFramerate(int frame_rate);
51
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000052 // Update incoming frame rate/dimension.
53 void UpdateIncomingframe_rate();
niklase@google.com470e71d2011-07-07 08:21:25 +000054
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000055 int32_t updateIncomingFrameSize(uint32_t width, uint32_t height);
niklase@google.com470e71d2011-07-07 08:21:25 +000056
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000057 // Set decimated values: frame rate/dimension.
mflodmana8565422015-12-07 01:09:52 -080058 uint32_t GetDecimatedFrameRate();
59 uint32_t GetDecimatedWidth() const;
60 uint32_t GetDecimatedHeight() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000061
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000062 // Preprocess output:
mflodmana8565422015-12-07 01:09:52 -080063 void EnableDenosing(bool enable);
64 const VideoFrame* PreprocessFrame(const VideoFrame& frame);
65 VideoContentMetrics* GetContentMetrics() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000066
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000067 private:
68 // The content does not change so much every frame, so to reduce complexity
69 // we can compute new content metrics every |kSkipFrameCA| frames.
70 enum { kSkipFrameCA = 2 };
niklase@google.com470e71d2011-07-07 08:21:25 +000071
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000072 VideoContentMetrics* content_metrics_;
jackychenafaae0d2016-04-12 23:02:55 -070073 VideoFrame denoised_frame_[2];
Miguel Casas-Sanchez47650702015-05-29 17:21:40 -070074 VideoFrame resampled_frame_;
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000075 VPMSpatialResampler* spatial_resampler_;
76 VPMContentAnalysis* ca_;
77 VPMVideoDecimator* vd_;
kwiberge065fcf2016-03-02 01:01:11 -080078 std::unique_ptr<VideoDenoiser> denoiser_;
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000079 bool enable_ca_;
jackychenafaae0d2016-04-12 23:02:55 -070080 uint8_t denoised_frame_toggle_;
mflodmana8565422015-12-07 01:09:52 -080081 uint32_t frame_cnt_;
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000082};
niklase@google.com470e71d2011-07-07 08:21:25 +000083
mikhal@webrtc.orgb43d8072013-10-03 16:42:41 +000084} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000085
mflodmana8565422015-12-07 01:09:52 -080086#endif // WEBRTC_MODULES_VIDEO_PROCESSING_FRAME_PREPROCESSOR_H_