niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 3 | * |
| 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 Kjellander | 0f59a88 | 2015-11-18 22:31:24 +0100 | [diff] [blame] | 11 | #ifndef WEBRTC_MODULES_VIDEO_PROCESSING_FRAME_PREPROCESSOR_H_ |
| 12 | #define WEBRTC_MODULES_VIDEO_PROCESSING_FRAME_PREPROCESSOR_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
kwiberg | e065fcf | 2016-03-02 01:01:11 -0800 | [diff] [blame] | 14 | #include <memory> |
| 15 | |
Henrik Kjellander | 0f59a88 | 2015-11-18 22:31:24 +0100 | [diff] [blame] | 16 | #include "webrtc/modules/video_processing/include/video_processing.h" |
Henrik Kjellander | 0f59a88 | 2015-11-18 22:31:24 +0100 | [diff] [blame] | 17 | #include "webrtc/modules/video_processing/spatial_resampler.h" |
| 18 | #include "webrtc/modules/video_processing/video_decimator.h" |
pbos@webrtc.org | 6f3d8fc | 2013-05-27 14:12:16 +0000 | [diff] [blame] | 19 | #include "webrtc/typedefs.h" |
jackychen | 8f9902a | 2015-11-26 02:59:48 -0800 | [diff] [blame] | 20 | #include "webrtc/video_frame.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 21 | |
| 22 | namespace webrtc { |
| 23 | |
mflodman | a856542 | 2015-12-07 01:09:52 -0800 | [diff] [blame] | 24 | class VideoDenoiser; |
| 25 | |
| 26 | // All pointers/members in this class are assumed to be protected by the class |
| 27 | // owner. |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 28 | class VPMFramePreprocessor { |
| 29 | public: |
| 30 | VPMFramePreprocessor(); |
| 31 | ~VPMFramePreprocessor(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 32 | |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 33 | void Reset(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 34 | |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 35 | // Enable temporal decimation. |
| 36 | void EnableTemporalDecimation(bool enable); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 37 | |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 38 | void SetInputFrameResampleMode(VideoFrameResampling resampling_mode); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 39 | |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 40 | // Set target resolution: frame rate and dimension. |
mflodman | 99ab944 | 2015-12-07 22:54:50 -0800 | [diff] [blame] | 41 | int32_t SetTargetResolution(uint32_t width, |
| 42 | uint32_t height, |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 43 | uint32_t frame_rate); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 44 | |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 45 | // Update incoming frame rate/dimension. |
| 46 | void UpdateIncomingframe_rate(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 47 | |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 48 | int32_t updateIncomingFrameSize(uint32_t width, uint32_t height); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 49 | |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 50 | // Set decimated values: frame rate/dimension. |
mflodman | a856542 | 2015-12-07 01:09:52 -0800 | [diff] [blame] | 51 | uint32_t GetDecimatedFrameRate(); |
| 52 | uint32_t GetDecimatedWidth() const; |
| 53 | uint32_t GetDecimatedHeight() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 54 | |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 55 | // Preprocess output: |
nisse | 90c335a | 2016-04-27 00:59:22 -0700 | [diff] [blame] | 56 | void EnableDenoising(bool enable); |
mflodman | a856542 | 2015-12-07 01:09:52 -0800 | [diff] [blame] | 57 | const VideoFrame* PreprocessFrame(const VideoFrame& frame); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 58 | |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 59 | private: |
| 60 | // The content does not change so much every frame, so to reduce complexity |
| 61 | // we can compute new content metrics every |kSkipFrameCA| frames. |
| 62 | enum { kSkipFrameCA = 2 }; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 63 | |
Niels Möller | 6af2e86 | 2016-06-17 09:12:44 +0200 | [diff] [blame^] | 64 | rtc::scoped_refptr<I420Buffer> denoised_buffer_[2]; |
| 65 | VideoFrame denoised_frame_; |
Miguel Casas-Sanchez | 4765070 | 2015-05-29 17:21:40 -0700 | [diff] [blame] | 66 | VideoFrame resampled_frame_; |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 67 | VPMSpatialResampler* spatial_resampler_; |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 68 | VPMVideoDecimator* vd_; |
kwiberg | e065fcf | 2016-03-02 01:01:11 -0800 | [diff] [blame] | 69 | std::unique_ptr<VideoDenoiser> denoiser_; |
jackychen | afaae0d | 2016-04-12 23:02:55 -0700 | [diff] [blame] | 70 | uint8_t denoised_frame_toggle_; |
mflodman | a856542 | 2015-12-07 01:09:52 -0800 | [diff] [blame] | 71 | uint32_t frame_cnt_; |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 72 | }; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 73 | |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 74 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 75 | |
mflodman | a856542 | 2015-12-07 01:09:52 -0800 | [diff] [blame] | 76 | #endif // WEBRTC_MODULES_VIDEO_PROCESSING_FRAME_PREPROCESSOR_H_ |