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

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

Issue 2005733003: Refactor VideoDenoiser to work with I420Buffer, not VideoFrame. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Trivial rebase. Created 4 years, 6 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
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 return nullptr; 89 return nullptr;
90 } 90 }
91 91
92 vd_->UpdateIncomingframe_rate(); 92 vd_->UpdateIncomingframe_rate();
93 if (vd_->DropFrame()) { 93 if (vd_->DropFrame()) {
94 return nullptr; 94 return nullptr;
95 } 95 }
96 96
97 const VideoFrame* current_frame = &frame; 97 const VideoFrame* current_frame = &frame;
98 if (denoiser_) { 98 if (denoiser_) {
99 VideoFrame* denoised_frame = &denoised_frame_[0]; 99 rtc::scoped_refptr<I420Buffer>* denoised_frame = &denoised_buffer_[0];
100 VideoFrame* denoised_frame_prev = &denoised_frame_[1]; 100 rtc::scoped_refptr<I420Buffer>* denoised_frame_prev = &denoised_buffer_[1];
101 // Swap the buffer to save one memcpy in DenoiseFrame. 101 // Swap the buffer to save one memcpy in DenoiseFrame.
102 if (denoised_frame_toggle_) { 102 if (denoised_frame_toggle_) {
103 denoised_frame = &denoised_frame_[1]; 103 denoised_frame = &denoised_buffer_[1];
104 denoised_frame_prev = &denoised_frame_[0]; 104 denoised_frame_prev = &denoised_buffer_[0];
105 } 105 }
106 // Invert the flag. 106 // Invert the flag.
107 denoised_frame_toggle_ ^= 1; 107 denoised_frame_toggle_ ^= 1;
108 denoiser_->DenoiseFrame(*current_frame, denoised_frame, denoised_frame_prev, 108 denoiser_->DenoiseFrame(current_frame->video_frame_buffer(), denoised_frame,
109 true); 109 denoised_frame_prev, true);
110 current_frame = denoised_frame; 110 denoised_frame_.ShallowCopy(*current_frame);
111 denoised_frame_.set_video_frame_buffer(*denoised_frame);
112 current_frame = &denoised_frame_;
111 } 113 }
112 114
113 if (spatial_resampler_->ApplyResample(current_frame->width(), 115 if (spatial_resampler_->ApplyResample(current_frame->width(),
114 current_frame->height())) { 116 current_frame->height())) {
115 if (spatial_resampler_->ResampleFrame(*current_frame, &resampled_frame_) != 117 if (spatial_resampler_->ResampleFrame(*current_frame, &resampled_frame_) !=
116 VPM_OK) { 118 VPM_OK) {
117 return nullptr; 119 return nullptr;
118 } 120 }
119 current_frame = &resampled_frame_; 121 current_frame = &resampled_frame_;
120 } 122 }
121 123
122 ++frame_cnt_; 124 ++frame_cnt_;
123 return current_frame; 125 return current_frame;
124 } 126 }
125 127
126 } // namespace webrtc 128 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698