OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_VIDEO_PROCESSING_FRAME_PREPROCESSOR_H_ | 11 #ifndef WEBRTC_MODULES_VIDEO_PROCESSING_FRAME_PREPROCESSOR_H_ |
12 #define WEBRTC_MODULES_VIDEO_PROCESSING_FRAME_PREPROCESSOR_H_ | 12 #define WEBRTC_MODULES_VIDEO_PROCESSING_FRAME_PREPROCESSOR_H_ |
13 | 13 |
14 #include <memory> | 14 #include <memory> |
15 | 15 |
16 #include "webrtc/modules/video_processing/include/video_processing.h" | 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" | 17 #include "webrtc/modules/video_processing/spatial_resampler.h" |
19 #include "webrtc/modules/video_processing/video_decimator.h" | 18 #include "webrtc/modules/video_processing/video_decimator.h" |
20 #include "webrtc/typedefs.h" | 19 #include "webrtc/typedefs.h" |
21 #include "webrtc/video_frame.h" | 20 #include "webrtc/video_frame.h" |
22 | 21 |
23 namespace webrtc { | 22 namespace webrtc { |
24 | 23 |
25 class VideoDenoiser; | 24 class VideoDenoiser; |
26 | 25 |
27 // All pointers/members in this class are assumed to be protected by the class | 26 // All pointers/members in this class are assumed to be protected by the class |
28 // owner. | 27 // owner. |
29 class VPMFramePreprocessor { | 28 class VPMFramePreprocessor { |
30 public: | 29 public: |
31 VPMFramePreprocessor(); | 30 VPMFramePreprocessor(); |
32 ~VPMFramePreprocessor(); | 31 ~VPMFramePreprocessor(); |
33 | 32 |
34 void Reset(); | 33 void Reset(); |
35 | 34 |
36 // Enable temporal decimation. | 35 // Enable temporal decimation. |
37 void EnableTemporalDecimation(bool enable); | 36 void EnableTemporalDecimation(bool enable); |
38 | 37 |
39 void SetInputFrameResampleMode(VideoFrameResampling resampling_mode); | 38 void SetInputFrameResampleMode(VideoFrameResampling resampling_mode); |
40 | 39 |
41 // Enable content analysis. | |
42 void EnableContentAnalysis(bool enable); | |
43 | |
44 // Set target resolution: frame rate and dimension. | 40 // Set target resolution: frame rate and dimension. |
45 int32_t SetTargetResolution(uint32_t width, | 41 int32_t SetTargetResolution(uint32_t width, |
46 uint32_t height, | 42 uint32_t height, |
47 uint32_t frame_rate); | 43 uint32_t frame_rate); |
48 | 44 |
49 // Update incoming frame rate/dimension. | 45 // Update incoming frame rate/dimension. |
50 void UpdateIncomingframe_rate(); | 46 void UpdateIncomingframe_rate(); |
51 | 47 |
52 int32_t updateIncomingFrameSize(uint32_t width, uint32_t height); | 48 int32_t updateIncomingFrameSize(uint32_t width, uint32_t height); |
53 | 49 |
54 // Set decimated values: frame rate/dimension. | 50 // Set decimated values: frame rate/dimension. |
55 uint32_t GetDecimatedFrameRate(); | 51 uint32_t GetDecimatedFrameRate(); |
56 uint32_t GetDecimatedWidth() const; | 52 uint32_t GetDecimatedWidth() const; |
57 uint32_t GetDecimatedHeight() const; | 53 uint32_t GetDecimatedHeight() const; |
58 | 54 |
59 // Preprocess output: | 55 // Preprocess output: |
60 void EnableDenoising(bool enable); | 56 void EnableDenoising(bool enable); |
61 const VideoFrame* PreprocessFrame(const VideoFrame& frame); | 57 const VideoFrame* PreprocessFrame(const VideoFrame& frame); |
62 VideoContentMetrics* GetContentMetrics() const; | |
63 | 58 |
64 private: | 59 private: |
65 // The content does not change so much every frame, so to reduce complexity | 60 // The content does not change so much every frame, so to reduce complexity |
66 // we can compute new content metrics every |kSkipFrameCA| frames. | 61 // we can compute new content metrics every |kSkipFrameCA| frames. |
67 enum { kSkipFrameCA = 2 }; | 62 enum { kSkipFrameCA = 2 }; |
68 | 63 |
69 VideoContentMetrics* content_metrics_; | |
70 VideoFrame denoised_frame_[2]; | 64 VideoFrame denoised_frame_[2]; |
71 VideoFrame resampled_frame_; | 65 VideoFrame resampled_frame_; |
72 VPMSpatialResampler* spatial_resampler_; | 66 VPMSpatialResampler* spatial_resampler_; |
73 VPMContentAnalysis* ca_; | |
74 VPMVideoDecimator* vd_; | 67 VPMVideoDecimator* vd_; |
75 std::unique_ptr<VideoDenoiser> denoiser_; | 68 std::unique_ptr<VideoDenoiser> denoiser_; |
76 bool enable_ca_; | |
77 uint8_t denoised_frame_toggle_; | 69 uint8_t denoised_frame_toggle_; |
78 uint32_t frame_cnt_; | 70 uint32_t frame_cnt_; |
79 }; | 71 }; |
80 | 72 |
81 } // namespace webrtc | 73 } // namespace webrtc |
82 | 74 |
83 #endif // WEBRTC_MODULES_VIDEO_PROCESSING_FRAME_PREPROCESSOR_H_ | 75 #endif // WEBRTC_MODULES_VIDEO_PROCESSING_FRAME_PREPROCESSOR_H_ |
OLD | NEW |