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 #include "webrtc/modules/video_processing/frame_preprocessor.h" | 11 #include "webrtc/modules/video_processing/frame_preprocessor.h" |
12 | 12 |
13 #include "webrtc/modules/video_processing/video_denoiser.h" | 13 #include "webrtc/modules/video_processing/video_denoiser.h" |
14 | 14 |
15 namespace webrtc { | 15 namespace webrtc { |
16 | 16 |
17 VPMFramePreprocessor::VPMFramePreprocessor() | 17 VPMFramePreprocessor::VPMFramePreprocessor() |
18 : content_metrics_(nullptr), | 18 : content_metrics_(nullptr), |
19 resampled_frame_(), | 19 resampled_frame_(), |
20 enable_ca_(false), | 20 enable_ca_(false), |
21 frame_cnt_(0) { | 21 frame_cnt_(0) { |
22 spatial_resampler_ = new VPMSimpleSpatialResampler(); | 22 spatial_resampler_ = new VPMSimpleSpatialResampler(); |
23 ca_ = new VPMContentAnalysis(true); | 23 ca_ = new VPMContentAnalysis(true); |
24 vd_ = new VPMVideoDecimator(); | 24 vd_ = new VPMVideoDecimator(); |
| 25 EnableDenosing(false); |
25 } | 26 } |
26 | 27 |
27 VPMFramePreprocessor::~VPMFramePreprocessor() { | 28 VPMFramePreprocessor::~VPMFramePreprocessor() { |
28 Reset(); | 29 Reset(); |
29 delete ca_; | 30 delete ca_; |
30 delete vd_; | 31 delete vd_; |
31 delete spatial_resampler_; | 32 delete spatial_resampler_; |
32 } | 33 } |
33 | 34 |
34 void VPMFramePreprocessor::Reset() { | 35 void VPMFramePreprocessor::Reset() { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 return nullptr; | 109 return nullptr; |
109 } | 110 } |
110 | 111 |
111 vd_->UpdateIncomingframe_rate(); | 112 vd_->UpdateIncomingframe_rate(); |
112 if (vd_->DropFrame()) { | 113 if (vd_->DropFrame()) { |
113 return nullptr; | 114 return nullptr; |
114 } | 115 } |
115 | 116 |
116 const VideoFrame* current_frame = &frame; | 117 const VideoFrame* current_frame = &frame; |
117 if (denoiser_) { | 118 if (denoiser_) { |
118 denoiser_->DenoiseFrame(*current_frame, &denoised_frame_); | 119 denoiser_->DenoiseFrame(*current_frame, &denoised_frame_, |
| 120 &denoised_frame_prev_, 0); |
119 current_frame = &denoised_frame_; | 121 current_frame = &denoised_frame_; |
120 } | 122 } |
121 | 123 |
122 if (spatial_resampler_->ApplyResample(current_frame->width(), | 124 if (spatial_resampler_->ApplyResample(current_frame->width(), |
123 current_frame->height())) { | 125 current_frame->height())) { |
124 if (spatial_resampler_->ResampleFrame(*current_frame, &resampled_frame_) != | 126 if (spatial_resampler_->ResampleFrame(*current_frame, &resampled_frame_) != |
125 VPM_OK) { | 127 VPM_OK) { |
126 return nullptr; | 128 return nullptr; |
127 } | 129 } |
128 current_frame = &resampled_frame_; | 130 current_frame = &resampled_frame_; |
129 } | 131 } |
130 | 132 |
131 // Perform content analysis on the frame to be encoded. | 133 // Perform content analysis on the frame to be encoded. |
132 if (enable_ca_ && frame_cnt_ % kSkipFrameCA == 0) { | 134 if (enable_ca_ && frame_cnt_ % kSkipFrameCA == 0) { |
133 // Compute new metrics every |kSkipFramesCA| frames, starting with | 135 // Compute new metrics every |kSkipFramesCA| frames, starting with |
134 // the first frame. | 136 // the first frame. |
135 content_metrics_ = ca_->ComputeContentMetrics(*current_frame); | 137 content_metrics_ = ca_->ComputeContentMetrics(*current_frame); |
136 } | 138 } |
137 ++frame_cnt_; | 139 ++frame_cnt_; |
138 return current_frame; | 140 return current_frame; |
139 } | 141 } |
140 | 142 |
141 VideoContentMetrics* VPMFramePreprocessor::GetContentMetrics() const { | 143 VideoContentMetrics* VPMFramePreprocessor::GetContentMetrics() const { |
142 return content_metrics_; | 144 return content_metrics_; |
143 } | 145 } |
144 | 146 |
145 } // namespace webrtc | 147 } // namespace webrtc |
OLD | NEW |