OLD | NEW |
---|---|
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), height_(0), filter_(DenoiserFilter::Create()) {} | 17 : width_(0), |
18 height_(0), | |
19 filter_(DenoiserFilter::Create(runtime_cpu_detection)) {} | |
18 | 20 |
19 void VideoDenoiser::TrailingReduction(int mb_rows, | 21 void VideoDenoiser::TrailingReduction(int mb_rows, |
20 int mb_cols, | 22 int mb_cols, |
21 const uint8_t* y_src, | 23 const uint8_t* y_src, |
22 int stride_y, | 24 int stride_y, |
23 uint8_t* y_dst) { | 25 uint8_t* y_dst) { |
24 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) { |
25 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) { |
26 int mb_index = mb_row * mb_cols + mb_col; | 28 int mb_index = mb_row * mb_cols + mb_col; |
27 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 stride_y, stride_u, stride_v); | 73 stride_y, stride_u, stride_v); |
72 // Setting time parameters to the output frame. | 74 // Setting time parameters to the output frame. |
73 denoised_frame->set_timestamp(frame.timestamp()); | 75 denoised_frame->set_timestamp(frame.timestamp()); |
74 denoised_frame->set_render_time_ms(frame.render_time_ms()); | 76 denoised_frame->set_render_time_ms(frame.render_time_ms()); |
75 return; | 77 return; |
76 } | 78 } |
77 // For 16x16 block. | 79 // For 16x16 block. |
78 int mb_cols = width_ >> 4; | 80 int mb_cols = width_ >> 4; |
79 int mb_rows = height_ >> 4; | 81 int mb_rows = height_ >> 4; |
80 if (metrics_.get() == nullptr) | 82 if (metrics_.get() == nullptr) |
81 metrics_.reset(new DenoiseMetrics[mb_cols * mb_rows]); | 83 metrics_.reset(new DenoiseMetrics[mb_cols * mb_rows]()); |
tommi (sloooow) - chröme
2016/01/12 12:01:21
I'm curious about what this change does?
jackychen_
2016/01/13 03:07:50
This is to initialize the array, since the msan te
| |
82 // Denoise on Y plane. | 84 // Denoise on Y plane. |
83 uint8_t* y_dst = denoised_frame->buffer(kYPlane); | 85 uint8_t* y_dst = denoised_frame->buffer(kYPlane); |
84 uint8_t* u_dst = denoised_frame->buffer(kUPlane); | 86 uint8_t* u_dst = denoised_frame->buffer(kUPlane); |
85 uint8_t* v_dst = denoised_frame->buffer(kVPlane); | 87 uint8_t* v_dst = denoised_frame->buffer(kVPlane); |
86 const uint8_t* y_src = frame.buffer(kYPlane); | 88 const uint8_t* y_src = frame.buffer(kYPlane); |
87 const uint8_t* u_src = frame.buffer(kUPlane); | 89 const uint8_t* u_src = frame.buffer(kUPlane); |
88 const uint8_t* v_src = frame.buffer(kVPlane); | 90 const uint8_t* v_src = frame.buffer(kVPlane); |
89 // Temporary buffer to store denoising result. | 91 // Temporary buffer to store denoising result. |
90 uint8_t y_tmp[16 * 16] = {0}; | 92 uint8_t y_tmp[16 * 16] = {0}; |
91 for (int mb_row = 0; mb_row < mb_rows; ++mb_row) { | 93 for (int mb_row = 0; mb_row < mb_rows; ++mb_row) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 // neighbors' denoising status. | 138 // neighbors' denoising status. |
137 TrailingReduction(mb_rows, mb_cols, y_src, stride_y, y_dst); | 139 TrailingReduction(mb_rows, mb_cols, y_src, stride_y, y_dst); |
138 | 140 |
139 // Setting time parameters to the output frame. | 141 // Setting time parameters to the output frame. |
140 denoised_frame->set_timestamp(frame.timestamp()); | 142 denoised_frame->set_timestamp(frame.timestamp()); |
141 denoised_frame->set_render_time_ms(frame.render_time_ms()); | 143 denoised_frame->set_render_time_ms(frame.render_time_ms()); |
142 return; | 144 return; |
143 } | 145 } |
144 | 146 |
145 } // namespace webrtc | 147 } // namespace webrtc |
OLD | NEW |