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

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

Issue 1492053003: Add unit test for stand-alone denoiser and fixed some bugs. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix asan test failure. 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) 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 #include "webrtc/common_video/libyuv/include/scaler.h" 10 #include "webrtc/common_video/libyuv/include/scaler.h"
11 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" 11 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
12 #include "webrtc/modules/video_processing/video_denoiser.h" 12 #include "webrtc/modules/video_processing/video_denoiser.h"
13 13
14 namespace webrtc { 14 namespace webrtc {
15 15
16 VideoDenoiser::VideoDenoiser() 16 VideoDenoiser::VideoDenoiser(bool runtime_cpu_detection)
17 : width_(0), 17 : width_(0),
18 height_(0), 18 height_(0),
19 filter_(DenoiserFilter::Create()) {} 19 filter_(DenoiserFilter::Create(runtime_cpu_detection)) {}
20 20
21 void VideoDenoiser::TrailingReduction(int mb_rows, 21 void VideoDenoiser::TrailingReduction(int mb_rows,
22 int mb_cols, 22 int mb_cols,
23 const uint8_t* y_src, 23 const uint8_t* y_src,
24 int stride_y, 24 int stride_y,
25 uint8_t* y_dst) { 25 uint8_t* y_dst) {
26 for (int mb_row = 1; mb_row < mb_rows - 1; ++mb_row) { 26 for (int mb_row = 1; mb_row < mb_rows - 1; ++mb_row) {
27 for (int mb_col = 1; mb_col < mb_cols - 1; ++mb_col) { 27 for (int mb_col = 1; mb_col < mb_cols - 1; ++mb_col) {
28 int mb_index = mb_row * mb_cols + mb_col; 28 int mb_index = mb_row * mb_cols + mb_col;
29 uint8_t* mb_dst = y_dst + (mb_row << 4) * stride_y + (mb_col << 4); 29 uint8_t* mb_dst = y_dst + (mb_row << 4) * stride_y + (mb_col << 4);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 stride_y, stride_u, stride_v); 72 stride_y, stride_u, stride_v);
73 // Setting time parameters to the output frame. 73 // Setting time parameters to the output frame.
74 denoised_frame->set_timestamp(frame.timestamp()); 74 denoised_frame->set_timestamp(frame.timestamp());
75 denoised_frame->set_render_time_ms(frame.render_time_ms()); 75 denoised_frame->set_render_time_ms(frame.render_time_ms());
76 return; 76 return;
77 } 77 }
78 // For 16x16 block. 78 // For 16x16 block.
79 int mb_cols = width_ >> 4; 79 int mb_cols = width_ >> 4;
80 int mb_rows = height_ >> 4; 80 int mb_rows = height_ >> 4;
81 if (metrics_.get() == nullptr) 81 if (metrics_.get() == nullptr)
82 metrics_.reset(new DenoiseMetrics[mb_cols * mb_rows]); 82 metrics_.reset(new DenoiseMetrics[mb_cols * mb_rows]());
stefan-webrtc 2015/12/10 08:53:25 Why was () added?
jackychen 2015/12/11 19:57:57 To memset the buffer to 0 to pass msan checking, t
83 // Denoise on Y plane. 83 // Denoise on Y plane.
84 uint8_t* y_dst = denoised_frame->buffer(kYPlane); 84 uint8_t* y_dst = denoised_frame->buffer(kYPlane);
85 uint8_t* u_dst = denoised_frame->buffer(kUPlane); 85 uint8_t* u_dst = denoised_frame->buffer(kUPlane);
86 uint8_t* v_dst = denoised_frame->buffer(kVPlane); 86 uint8_t* v_dst = denoised_frame->buffer(kVPlane);
87 const uint8_t* y_src = frame.buffer(kYPlane); 87 const uint8_t* y_src = frame.buffer(kYPlane);
88 const uint8_t* u_src = frame.buffer(kUPlane); 88 const uint8_t* u_src = frame.buffer(kUPlane);
89 const uint8_t* v_src = frame.buffer(kVPlane); 89 const uint8_t* v_src = frame.buffer(kVPlane);
90 // Temporary buffer to store denoising result. 90 // Temporary buffer to store denoising result.
91 uint8_t y_tmp[16 * 16] = {0}; 91 uint8_t y_tmp[16 * 16] = {0};
92 for (int mb_row = 0; mb_row < mb_rows; ++mb_row) { 92 for (int mb_row = 0; mb_row < mb_rows; ++mb_row) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // neighbors' denoising status. 140 // neighbors' denoising status.
141 TrailingReduction(mb_rows, mb_cols, y_src, stride_y, y_dst); 141 TrailingReduction(mb_rows, mb_cols, y_src, stride_y, y_dst);
142 142
143 // Setting time parameters to the output frame. 143 // Setting time parameters to the output frame.
144 denoised_frame->set_timestamp(frame.timestamp()); 144 denoised_frame->set_timestamp(frame.timestamp());
145 denoised_frame->set_render_time_ms(frame.render_time_ms()); 145 denoised_frame->set_render_time_ms(frame.render_time_ms());
146 return; 146 return;
147 } 147 }
148 148
149 } // namespace webrtc 149 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698