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

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

Issue 1983583002: Revert of Delete webrtc::VideoFrame methods buffer and stride. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 filter_(DenoiserFilter::Create(runtime_cpu_detection, &cpu_type_)), 74 filter_(DenoiserFilter::Create(runtime_cpu_detection, &cpu_type_)),
75 ne_(new NoiseEstimation()) {} 75 ne_(new NoiseEstimation()) {}
76 76
77 void VideoDenoiser::DenoiserReset(const VideoFrame& frame, 77 void VideoDenoiser::DenoiserReset(const VideoFrame& frame,
78 VideoFrame* denoised_frame, 78 VideoFrame* denoised_frame,
79 VideoFrame* denoised_frame_prev) { 79 VideoFrame* denoised_frame_prev) {
80 width_ = frame.width(); 80 width_ = frame.width();
81 height_ = frame.height(); 81 height_ = frame.height();
82 mb_cols_ = width_ >> 4; 82 mb_cols_ = width_ >> 4;
83 mb_rows_ = height_ >> 4; 83 mb_rows_ = height_ >> 4;
84 stride_y_ = frame.video_frame_buffer()->StrideY(); 84 stride_y_ = frame.stride(kYPlane);
85 stride_u_ = frame.video_frame_buffer()->StrideU(); 85 stride_u_ = frame.stride(kUPlane);
86 stride_v_ = frame.video_frame_buffer()->StrideV(); 86 stride_v_ = frame.stride(kVPlane);
87 87
88 // Allocate an empty buffer for denoised_frame_prev. 88 // Allocate an empty buffer for denoised_frame_prev.
89 denoised_frame_prev->CreateEmptyFrame(width_, height_, stride_y_, stride_u_, 89 denoised_frame_prev->CreateEmptyFrame(width_, height_, stride_y_, stride_u_,
90 stride_v_); 90 stride_v_);
91 // Allocate and initialize denoised_frame with key frame. 91 // Allocate and initialize denoised_frame with key frame.
92 denoised_frame->CreateFrame( 92 denoised_frame->CreateFrame(frame.buffer(kYPlane), frame.buffer(kUPlane),
93 frame.video_frame_buffer()->DataY(), 93 frame.buffer(kVPlane), width_, height_, stride_y_,
94 frame.video_frame_buffer()->DataU(), 94 stride_u_, stride_v_, kVideoRotation_0);
95 frame.video_frame_buffer()->DataV(),
96 width_, height_, stride_y_, stride_u_, stride_v_, kVideoRotation_0);
97 // Set time parameters to the output frame. 95 // Set time parameters to the output frame.
98 denoised_frame->set_timestamp(frame.timestamp()); 96 denoised_frame->set_timestamp(frame.timestamp());
99 denoised_frame->set_render_time_ms(frame.render_time_ms()); 97 denoised_frame->set_render_time_ms(frame.render_time_ms());
100 98
101 // Init noise estimator and allocate buffers. 99 // Init noise estimator and allocate buffers.
102 ne_->Init(width_, height_, cpu_type_); 100 ne_->Init(width_, height_, cpu_type_);
103 moving_edge_.reset(new uint8_t[mb_cols_ * mb_rows_]); 101 moving_edge_.reset(new uint8_t[mb_cols_ * mb_rows_]);
104 mb_filter_decision_.reset(new DenoiserDecision[mb_cols_ * mb_rows_]); 102 mb_filter_decision_.reset(new DenoiserDecision[mb_cols_ * mb_rows_]);
105 x_density_.reset(new uint8_t[mb_cols_]); 103 x_density_.reset(new uint8_t[mb_cols_]);
106 y_density_.reset(new uint8_t[mb_rows_]); 104 y_density_.reset(new uint8_t[mb_rows_]);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 VideoFrame* denoised_frame_prev, 229 VideoFrame* denoised_frame_prev,
232 bool noise_estimation_enabled) { 230 bool noise_estimation_enabled) {
233 // If previous width and height are different from current frame's, need to 231 // If previous width and height are different from current frame's, need to
234 // reallocate the buffers and no denoising for the current frame. 232 // reallocate the buffers and no denoising for the current frame.
235 if (width_ != frame.width() || height_ != frame.height()) { 233 if (width_ != frame.width() || height_ != frame.height()) {
236 DenoiserReset(frame, denoised_frame, denoised_frame_prev); 234 DenoiserReset(frame, denoised_frame, denoised_frame_prev);
237 return; 235 return;
238 } 236 }
239 237
240 // Set buffer pointers. 238 // Set buffer pointers.
241 const uint8_t* y_src = frame.video_frame_buffer()->DataY(); 239 const uint8_t* y_src = frame.buffer(kYPlane);
242 const uint8_t* u_src = frame.video_frame_buffer()->DataU(); 240 const uint8_t* u_src = frame.buffer(kUPlane);
243 const uint8_t* v_src = frame.video_frame_buffer()->DataV(); 241 const uint8_t* v_src = frame.buffer(kVPlane);
244 uint8_t* y_dst = denoised_frame->video_frame_buffer()->MutableDataY(); 242 uint8_t* y_dst = denoised_frame->buffer(kYPlane);
245 uint8_t* u_dst = denoised_frame->video_frame_buffer()->MutableDataU(); 243 uint8_t* u_dst = denoised_frame->buffer(kUPlane);
246 uint8_t* v_dst = denoised_frame->video_frame_buffer()->MutableDataV(); 244 uint8_t* v_dst = denoised_frame->buffer(kVPlane);
247 uint8_t* y_dst_prev = 245 uint8_t* y_dst_prev = denoised_frame_prev->buffer(kYPlane);
248 denoised_frame_prev->video_frame_buffer()->MutableDataY();
249 memset(x_density_.get(), 0, mb_cols_); 246 memset(x_density_.get(), 0, mb_cols_);
250 memset(y_density_.get(), 0, mb_rows_); 247 memset(y_density_.get(), 0, mb_rows_);
251 memset(moving_object_.get(), 1, mb_cols_ * mb_rows_); 248 memset(moving_object_.get(), 1, mb_cols_ * mb_rows_);
252 249
253 uint8_t noise_level = noise_estimation_enabled ? ne_->GetNoiseLevel() : 0; 250 uint8_t noise_level = noise_estimation_enabled ? ne_->GetNoiseLevel() : 0;
254 int thr_var_base = 16 * 16 * 2; 251 int thr_var_base = 16 * 16 * 2;
255 // Loop over blocks to accumulate/extract noise level and update x/y_density 252 // Loop over blocks to accumulate/extract noise level and update x/y_density
256 // factors for moving object detection. 253 // factors for moving object detection.
257 for (int mb_row = 0; mb_row < mb_rows_; ++mb_row) { 254 for (int mb_row = 0; mb_row < mb_rows_; ++mb_row) {
258 const int mb_index_base = mb_row * mb_cols_; 255 const int mb_index_base = mb_row * mb_cols_;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 denoised_frame->set_render_time_ms(frame.render_time_ms()); 341 denoised_frame->set_render_time_ms(frame.render_time_ms());
345 342
346 #if DISPLAY || DISPLAYNEON 343 #if DISPLAY || DISPLAYNEON
347 // Show rectangular region 344 // Show rectangular region
348 ShowRect(filter_, moving_edge_, moving_object_, x_density_, y_density_, u_src, 345 ShowRect(filter_, moving_edge_, moving_object_, x_density_, y_density_, u_src,
349 v_src, u_dst, v_dst, mb_rows_, mb_cols_, stride_u_, stride_v_); 346 v_src, u_dst, v_dst, mb_rows_, mb_cols_, stride_u_, stride_v_);
350 #endif 347 #endif
351 } 348 }
352 349
353 } // namespace webrtc 350 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_processing/test/video_processing_unittest.cc ('k') | webrtc/test/frame_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698