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

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

Issue 1917703002: Fix an issue in external VNR when width or height not divisible by 16. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « webrtc/modules/video_processing/video_denoiser.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 IsTrailingBlock(moving_edge_, mb_row, mb_col) || 200 IsTrailingBlock(moving_edge_, mb_row, mb_col) ||
201 (x_density_[mb_col] * y_density_[mb_row] && 201 (x_density_[mb_col] * y_density_[mb_row] &&
202 moving_object_[mb_row * mb_cols_ + mb_col])) { 202 moving_object_[mb_row * mb_cols_ + mb_col])) {
203 // Copy y source. 203 // Copy y source.
204 filter_->CopyMem16x16(mb_src, stride_y_, mb_dst, stride_y_); 204 filter_->CopyMem16x16(mb_src, stride_y_, mb_dst, stride_y_);
205 } 205 }
206 } 206 }
207 } 207 }
208 } 208 }
209 209
210 void VideoDenoiser::CopyLumaOnMargin(const uint8_t* y_src, uint8_t* y_dst) {
211 if ((mb_rows_ << 4) != height_) {
212 const uint8_t* margin_y_src = y_src + (mb_rows_ << 4) * stride_y_;
213 uint8_t* margin_y_dst = y_dst + (mb_rows_ << 4) * stride_y_;
214 memcpy(margin_y_dst, margin_y_src, (height_ - (mb_rows_ << 4)) * stride_y_);
215 }
216 if ((mb_cols_ << 4) != width_) {
217 const uint8_t* margin_y_src = y_src + (mb_cols_ << 4);
218 uint8_t* margin_y_dst = y_dst + (mb_cols_ << 4);
219 for (int i = 0; i < height_; ++i) {
220 for (int j = mb_cols_ << 4; j < width_; ++j) {
221 margin_y_dst[i * stride_y_ + j] = margin_y_src[i * stride_y_ + j];
222 }
223 }
224 }
225 }
226
210 void VideoDenoiser::DenoiseFrame(const VideoFrame& frame, 227 void VideoDenoiser::DenoiseFrame(const VideoFrame& frame,
211 VideoFrame* denoised_frame, 228 VideoFrame* denoised_frame,
212 VideoFrame* denoised_frame_prev, 229 VideoFrame* denoised_frame_prev,
213 bool noise_estimation_enabled) { 230 bool noise_estimation_enabled) {
214 // 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
215 // reallocate the buffers and no denoising for the current frame. 232 // reallocate the buffers and no denoising for the current frame.
216 if (width_ != frame.width() || height_ != frame.height()) { 233 if (width_ != frame.width() || height_ != frame.height()) {
217 DenoiserReset(frame, denoised_frame, denoised_frame_prev); 234 DenoiserReset(frame, denoised_frame, denoised_frame_prev);
218 return; 235 return;
219 } 236 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 } 319 }
303 } 320 }
304 } 321 }
305 } // End of for loop 322 } // End of for loop
306 } // End of for loop 323 } // End of for loop
307 324
308 ReduceFalseDetection(moving_edge_, &moving_object_, noise_level); 325 ReduceFalseDetection(moving_edge_, &moving_object_, noise_level);
309 326
310 CopySrcOnMOB(y_src, y_dst); 327 CopySrcOnMOB(y_src, y_dst);
311 328
329 // When frame width/height not divisible by 16, copy the margin to
330 // denoised_frame.
331 if ((mb_rows_ << 4) != height_ || (mb_cols_ << 4) != width_)
332 CopyLumaOnMargin(y_src, y_dst);
333
312 // TODO(jackychen): Need SSE2/NEON opt. 334 // TODO(jackychen): Need SSE2/NEON opt.
313 // Copy u/v planes. 335 // Copy u/v planes.
314 memcpy(u_dst, u_src, (height_ >> 1) * stride_u_); 336 memcpy(u_dst, u_src, (height_ >> 1) * stride_u_);
315 memcpy(v_dst, v_src, (height_ >> 1) * stride_v_); 337 memcpy(v_dst, v_src, (height_ >> 1) * stride_v_);
316 338
317 // Set time parameters to the output frame. 339 // Set time parameters to the output frame.
318 denoised_frame->set_timestamp(frame.timestamp()); 340 denoised_frame->set_timestamp(frame.timestamp());
319 denoised_frame->set_render_time_ms(frame.render_time_ms()); 341 denoised_frame->set_render_time_ms(frame.render_time_ms());
320 342
321 #if DISPLAY || DISPLAYNEON 343 #if DISPLAY || DISPLAYNEON
322 // Show rectangular region 344 // Show rectangular region
323 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,
324 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_);
325 #endif 347 #endif
326 } 348 }
327 349
328 } // namespace webrtc 350 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_processing/video_denoiser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698