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

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

Issue 1917323002: Remove remaining quality-analysis (QM). (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 4 years, 7 months 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 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 : resampled_frame_(), frame_cnt_(0) {
19 resampled_frame_(),
20 enable_ca_(false),
21 frame_cnt_(0) {
22 spatial_resampler_ = new VPMSimpleSpatialResampler(); 19 spatial_resampler_ = new VPMSimpleSpatialResampler();
23 ca_ = new VPMContentAnalysis(true);
24 vd_ = new VPMVideoDecimator(); 20 vd_ = new VPMVideoDecimator();
25 EnableDenoising(false); 21 EnableDenoising(false);
26 denoised_frame_toggle_ = 0; 22 denoised_frame_toggle_ = 0;
27 } 23 }
28 24
29 VPMFramePreprocessor::~VPMFramePreprocessor() { 25 VPMFramePreprocessor::~VPMFramePreprocessor() {
30 Reset(); 26 Reset();
31 delete ca_;
32 delete vd_; 27 delete vd_;
33 delete spatial_resampler_; 28 delete spatial_resampler_;
34 } 29 }
35 30
36 void VPMFramePreprocessor::Reset() { 31 void VPMFramePreprocessor::Reset() {
37 ca_->Release();
38 vd_->Reset(); 32 vd_->Reset();
39 content_metrics_ = nullptr;
40 spatial_resampler_->Reset(); 33 spatial_resampler_->Reset();
41 enable_ca_ = false;
42 frame_cnt_ = 0; 34 frame_cnt_ = 0;
43 } 35 }
44 36
45 void VPMFramePreprocessor::EnableTemporalDecimation(bool enable) { 37 void VPMFramePreprocessor::EnableTemporalDecimation(bool enable) {
46 vd_->EnableTemporalDecimation(enable); 38 vd_->EnableTemporalDecimation(enable);
47 } 39 }
48 40
49 void VPMFramePreprocessor::EnableContentAnalysis(bool enable) {
50 enable_ca_ = enable;
51 }
52
53 void VPMFramePreprocessor::SetInputFrameResampleMode( 41 void VPMFramePreprocessor::SetInputFrameResampleMode(
54 VideoFrameResampling resampling_mode) { 42 VideoFrameResampling resampling_mode) {
55 spatial_resampler_->SetInputFrameResampleMode(resampling_mode); 43 spatial_resampler_->SetInputFrameResampleMode(resampling_mode);
56 } 44 }
57 45
58 int32_t VPMFramePreprocessor::SetTargetResolution(uint32_t width, 46 int32_t VPMFramePreprocessor::SetTargetResolution(uint32_t width,
59 uint32_t height, 47 uint32_t height,
60 uint32_t frame_rate) { 48 uint32_t frame_rate) {
61 if ((width == 0) || (height == 0) || (frame_rate == 0)) { 49 if ((width == 0) || (height == 0) || (frame_rate == 0)) {
62 return VPM_PARAMETER_ERROR; 50 return VPM_PARAMETER_ERROR;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 112
125 if (spatial_resampler_->ApplyResample(current_frame->width(), 113 if (spatial_resampler_->ApplyResample(current_frame->width(),
126 current_frame->height())) { 114 current_frame->height())) {
127 if (spatial_resampler_->ResampleFrame(*current_frame, &resampled_frame_) != 115 if (spatial_resampler_->ResampleFrame(*current_frame, &resampled_frame_) !=
128 VPM_OK) { 116 VPM_OK) {
129 return nullptr; 117 return nullptr;
130 } 118 }
131 current_frame = &resampled_frame_; 119 current_frame = &resampled_frame_;
132 } 120 }
133 121
134 // Perform content analysis on the frame to be encoded.
135 if (enable_ca_ && frame_cnt_ % kSkipFrameCA == 0) {
136 // Compute new metrics every |kSkipFramesCA| frames, starting with
137 // the first frame.
138 content_metrics_ = ca_->ComputeContentMetrics(*current_frame);
139 }
140 ++frame_cnt_; 122 ++frame_cnt_;
141 return current_frame; 123 return current_frame;
142 } 124 }
143 125
144 VideoContentMetrics* VPMFramePreprocessor::GetContentMetrics() const {
145 return content_metrics_;
146 }
147
148 } // namespace webrtc 126 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_processing/frame_preprocessor.h ('k') | webrtc/modules/video_processing/include/video_processing.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698