Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1477)

Side by Side Diff: webrtc/modules/video_processing/frame_preprocessor.cc

Issue 1466763002: Standalone denoiser (off by default). (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "webrtc/modules/video_processing/video_denoiser.h"
12 13
13 namespace webrtc { 14 namespace webrtc {
14 15
15 VPMFramePreprocessor::VPMFramePreprocessor() 16 VPMFramePreprocessor::VPMFramePreprocessor()
16 : content_metrics_(NULL), 17 : content_metrics_(NULL),
17 resampled_frame_(), 18 resampled_frame_(),
18 enable_ca_(false), 19 enable_ca_(false),
20 enable_denoising_(false),
19 frame_cnt_(0) { 21 frame_cnt_(0) {
20 spatial_resampler_ = new VPMSimpleSpatialResampler(); 22 spatial_resampler_ = new VPMSimpleSpatialResampler();
21 ca_ = new VPMContentAnalysis(true); 23 ca_ = new VPMContentAnalysis(true);
22 vd_ = new VPMVideoDecimator(); 24 vd_ = new VPMVideoDecimator();
25 video_denoiser_ = new VideoDenoiser();
23 } 26 }
24 27
25 VPMFramePreprocessor::~VPMFramePreprocessor() { 28 VPMFramePreprocessor::~VPMFramePreprocessor() {
26 Reset(); 29 Reset();
27 delete spatial_resampler_;
28 delete ca_; 30 delete ca_;
29 delete vd_; 31 delete vd_;
32 delete video_denoiser_;
33 delete spatial_resampler_;
30 } 34 }
31 35
32 void VPMFramePreprocessor::Reset() { 36 void VPMFramePreprocessor::Reset() {
33 ca_->Release(); 37 ca_->Release();
34 vd_->Reset(); 38 vd_->Reset();
35 content_metrics_ = NULL; 39 content_metrics_ = NULL;
36 spatial_resampler_->Reset(); 40 spatial_resampler_->Reset();
37 enable_ca_ = false; 41 enable_ca_ = false;
38 frame_cnt_ = 0; 42 frame_cnt_ = 0;
39 } 43 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 104
101 vd_->UpdateIncomingframe_rate(); 105 vd_->UpdateIncomingframe_rate();
102 106
103 if (vd_->DropFrame()) { 107 if (vd_->DropFrame()) {
104 return 1; // drop 1 frame 108 return 1; // drop 1 frame
105 } 109 }
106 110
107 // Resizing incoming frame if needed. Otherwise, remains NULL. 111 // Resizing incoming frame if needed. Otherwise, remains NULL.
108 // We are not allowed to resample the input frame (must make a copy of it). 112 // We are not allowed to resample the input frame (must make a copy of it).
109 *processed_frame = NULL; 113 *processed_frame = NULL;
114 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.
115 video_denoiser_->DenoiseFrame(frame, &denoised_frame_);
116 *processed_frame = &denoised_frame_;
117 }
118
110 if (spatial_resampler_->ApplyResample(frame.width(), frame.height())) { 119 if (spatial_resampler_->ApplyResample(frame.width(), frame.height())) {
111 int32_t ret = spatial_resampler_->ResampleFrame(frame, &resampled_frame_); 120 int32_t ret;
121 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
122 ret = spatial_resampler_->ResampleFrame(denoised_frame_,
123 &resampled_frame_);
124 } else {
125 ret = spatial_resampler_->ResampleFrame(frame, &resampled_frame_);
126 }
112 if (ret != VPM_OK) return ret; 127 if (ret != VPM_OK) return ret;
113 *processed_frame = &resampled_frame_; 128 *processed_frame = &resampled_frame_;
114 } 129 }
115 130
116 // Perform content analysis on the frame to be encoded. 131 // Perform content analysis on the frame to be encoded.
117 if (enable_ca_) { 132 if (enable_ca_) {
118 // Compute new metrics every |kSkipFramesCA| frames, starting with 133 // Compute new metrics every |kSkipFramesCA| frames, starting with
119 // the first frame. 134 // the first frame.
120 if (frame_cnt_ % kSkipFrameCA == 0) { 135 if (frame_cnt_ % kSkipFrameCA == 0) {
121 if (*processed_frame == NULL) { 136 if (*processed_frame == NULL) {
122 content_metrics_ = ca_->ComputeContentMetrics(frame); 137 content_metrics_ = ca_->ComputeContentMetrics(frame);
123 } else { 138 } else {
124 content_metrics_ = ca_->ComputeContentMetrics(resampled_frame_); 139 content_metrics_ = ca_->ComputeContentMetrics(**processed_frame);
125 } 140 }
126 } 141 }
127 ++frame_cnt_;
128 } 142 }
143 ++frame_cnt_;
129 return VPM_OK; 144 return VPM_OK;
130 } 145 }
131 146
132 VideoContentMetrics* VPMFramePreprocessor::ContentMetrics() const { 147 VideoContentMetrics* VPMFramePreprocessor::ContentMetrics() const {
133 return content_metrics_; 148 return content_metrics_;
134 } 149 }
135 150
136 } // namespace 151 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698