Index: webrtc/modules/video_processing/frame_preprocessor.cc |
diff --git a/webrtc/modules/video_processing/frame_preprocessor.cc b/webrtc/modules/video_processing/frame_preprocessor.cc |
index a3ec3c8c1c617d57c41d5ff3a40952857e4445a4..887586e754d3e12b3a1f421c2db0d51e9d5fe91a 100644 |
--- a/webrtc/modules/video_processing/frame_preprocessor.cc |
+++ b/webrtc/modules/video_processing/frame_preprocessor.cc |
@@ -9,6 +9,7 @@ |
*/ |
#include "webrtc/modules/video_processing/frame_preprocessor.h" |
+#include "webrtc/modules/video_processing/video_denoiser.h" |
namespace webrtc { |
@@ -16,17 +17,20 @@ VPMFramePreprocessor::VPMFramePreprocessor() |
: content_metrics_(NULL), |
resampled_frame_(), |
enable_ca_(false), |
+ enable_denoising_(false), |
frame_cnt_(0) { |
spatial_resampler_ = new VPMSimpleSpatialResampler(); |
ca_ = new VPMContentAnalysis(true); |
vd_ = new VPMVideoDecimator(); |
+ video_denoiser_ = new VideoDenoiser(); |
} |
VPMFramePreprocessor::~VPMFramePreprocessor() { |
Reset(); |
- delete spatial_resampler_; |
delete ca_; |
delete vd_; |
+ delete video_denoiser_; |
+ delete spatial_resampler_; |
} |
void VPMFramePreprocessor::Reset() { |
@@ -107,8 +111,19 @@ int32_t VPMFramePreprocessor::PreprocessFrame(const VideoFrame& frame, |
// Resizing incoming frame if needed. Otherwise, remains NULL. |
// We are not allowed to resample the input frame (must make a copy of it). |
*processed_frame = NULL; |
+ if (enable_denoising_) { |
mflodman
2015/11/25 12:15:19
I'd prefer to skip this bool and instead check if
jackychen
2015/11/25 20:29:05
Done.
|
+ video_denoiser_->DenoiseFrame(frame, &denoised_frame_); |
+ *processed_frame = &denoised_frame_; |
+ } |
+ |
if (spatial_resampler_->ApplyResample(frame.width(), frame.height())) { |
- int32_t ret = spatial_resampler_->ResampleFrame(frame, &resampled_frame_); |
+ int32_t ret; |
+ if (enable_denoising_) { |
mflodman
2015/11/25 12:15:19
I think we can avoid this check by refactor this m
jackychen
2015/11/25 20:29:05
OK. Will do in a follow up cl.
mflodman
2015/11/26 10:50:00
I filed a bug to keep track of the coming clean-up
|
+ ret = spatial_resampler_->ResampleFrame(denoised_frame_, |
+ &resampled_frame_); |
+ } else { |
+ ret = spatial_resampler_->ResampleFrame(frame, &resampled_frame_); |
+ } |
if (ret != VPM_OK) return ret; |
*processed_frame = &resampled_frame_; |
} |
@@ -121,11 +136,11 @@ int32_t VPMFramePreprocessor::PreprocessFrame(const VideoFrame& frame, |
if (*processed_frame == NULL) { |
content_metrics_ = ca_->ComputeContentMetrics(frame); |
} else { |
- content_metrics_ = ca_->ComputeContentMetrics(resampled_frame_); |
+ content_metrics_ = ca_->ComputeContentMetrics(**processed_frame); |
} |
} |
- ++frame_cnt_; |
} |
+ ++frame_cnt_; |
return VPM_OK; |
} |