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" |
| 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.org | 6f3d8fc | 2013-05-27 14:12:16 +0000 | [diff] [blame] | 20 | #include "webrtc/typedefs.h" |
jackychen | 8f9902a | 2015-11-26 02:59:48 -0800 | [diff] [blame] | 21 | #include "webrtc/video_frame.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 22 | |
| 23 | namespace webrtc { |
| 24 | |
mflodman | a856542 | 2015-12-07 01:09:52 -0800 | [diff] [blame] | 25 | class VideoDenoiser; |
| 26 | |
| 27 | // All pointers/members in this class are assumed to be protected by the class |
| 28 | // owner. |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 29 | class VPMFramePreprocessor { |
| 30 | public: |
| 31 | VPMFramePreprocessor(); |
| 32 | ~VPMFramePreprocessor(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 33 | |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 34 | void Reset(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 35 | |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 36 | // Enable temporal decimation. |
| 37 | void EnableTemporalDecimation(bool enable); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 38 | |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 39 | void SetInputFrameResampleMode(VideoFrameResampling resampling_mode); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 40 | |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 41 | // Enable content analysis. |
| 42 | void EnableContentAnalysis(bool enable); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 43 | |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 44 | // Set target resolution: frame rate and dimension. |
mflodman | 99ab944 | 2015-12-07 22:54:50 -0800 | [diff] [blame] | 45 | int32_t SetTargetResolution(uint32_t width, |
| 46 | uint32_t height, |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 47 | uint32_t frame_rate); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 48 | |
jackychen | 6e2ce6e | 2015-07-13 16:26:33 -0700 | [diff] [blame] | 49 | // Set target frame rate. |
| 50 | void SetTargetFramerate(int frame_rate); |
| 51 | |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 52 | // Update incoming frame rate/dimension. |
| 53 | void UpdateIncomingframe_rate(); |
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 | int32_t updateIncomingFrameSize(uint32_t width, uint32_t height); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 56 | |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 57 | // Set decimated values: frame rate/dimension. |
mflodman | a856542 | 2015-12-07 01:09:52 -0800 | [diff] [blame] | 58 | uint32_t GetDecimatedFrameRate(); |
| 59 | uint32_t GetDecimatedWidth() const; |
| 60 | uint32_t GetDecimatedHeight() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 61 | |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 62 | // Preprocess output: |
mflodman | a856542 | 2015-12-07 01:09:52 -0800 | [diff] [blame] | 63 | void EnableDenosing(bool enable); |
| 64 | const VideoFrame* PreprocessFrame(const VideoFrame& frame); |
| 65 | VideoContentMetrics* GetContentMetrics() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 66 | |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 67 | 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 71 | |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 72 | VideoContentMetrics* content_metrics_; |
jackychen | 8f9902a | 2015-11-26 02:59:48 -0800 | [diff] [blame] | 73 | VideoFrame denoised_frame_; |
Miguel Casas-Sanchez | 4765070 | 2015-05-29 17:21:40 -0700 | [diff] [blame] | 74 | VideoFrame resampled_frame_; |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 75 | VPMSpatialResampler* spatial_resampler_; |
| 76 | VPMContentAnalysis* ca_; |
| 77 | VPMVideoDecimator* vd_; |
kwiberg | e065fcf | 2016-03-02 01:01:11 -0800 | [diff] [blame^] | 78 | std::unique_ptr<VideoDenoiser> denoiser_; |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 79 | bool enable_ca_; |
mflodman | a856542 | 2015-12-07 01:09:52 -0800 | [diff] [blame] | 80 | uint32_t frame_cnt_; |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 81 | }; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 82 | |
mikhal@webrtc.org | b43d807 | 2013-10-03 16:42:41 +0000 | [diff] [blame] | 83 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 84 | |
mflodman | a856542 | 2015-12-07 01:09:52 -0800 | [diff] [blame] | 85 | #endif // WEBRTC_MODULES_VIDEO_PROCESSING_FRAME_PREPROCESSOR_H_ |