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(bool runtime_cpu_detection) | 16 VideoDenoiser::VideoDenoiser(bool runtime_cpu_detection) |
17 : width_(0), | 17 : width_(0), |
18 height_(0), | 18 height_(0), |
19 filter_(DenoiserFilter::Create(runtime_cpu_detection)) {} | 19 filter_(DenoiserFilter::Create(runtime_cpu_detection, &cpu_type_)), |
| 20 ne_(new NoiseEstimation()) {} |
20 | 21 |
21 void VideoDenoiser::TrailingReduction(int mb_rows, | 22 #if EXPERIMENTAL |
22 int mb_cols, | 23 // Check the mb position(1: close to the center, 3: close to the border). |
23 const uint8_t* y_src, | 24 static int PositionCheck(int mb_row, int mb_col, int mb_rows, int mb_cols) { |
24 int stride_y, | 25 if ((mb_row >= (mb_rows >> 3)) && (mb_row <= (7 * mb_rows >> 3)) && |
25 uint8_t* y_dst) { | 26 (mb_col >= (mb_cols >> 3)) && (mb_col <= (7 * mb_cols >> 3))) |
26 for (int mb_row = 1; mb_row < mb_rows - 1; ++mb_row) { | 27 return 1; |
27 for (int mb_col = 1; mb_col < mb_cols - 1; ++mb_col) { | 28 else if ((mb_row >= (mb_rows >> 4)) && (mb_row <= (15 * mb_rows >> 4)) && |
| 29 (mb_col >= (mb_cols >> 4)) && (mb_col <= (15 * mb_cols >> 4))) |
| 30 return 2; |
| 31 else |
| 32 return 3; |
| 33 } |
| 34 |
| 35 static void ReduceFalseDetection(const std::unique_ptr<uint8_t[]>& d_status, |
| 36 std::unique_ptr<uint8_t[]>* d_status_tmp1, |
| 37 std::unique_ptr<uint8_t[]>* d_status_tmp2, |
| 38 int noise_level, |
| 39 int mb_rows, |
| 40 int mb_cols) { |
| 41 // Draft. This can be optimized. This code block is to reduce false detection |
| 42 // in moving object detection. |
| 43 int mb_row_min = noise_level ? mb_rows >> 3 : 1; |
| 44 int mb_col_min = noise_level ? mb_cols >> 3 : 1; |
| 45 int mb_row_max = noise_level ? (7 * mb_rows >> 3) : mb_rows - 2; |
| 46 int mb_col_max = noise_level ? (7 * mb_cols >> 3) : mb_cols - 2; |
| 47 memcpy((*d_status_tmp1).get(), d_status.get(), mb_rows * mb_cols); |
| 48 // Up left. |
| 49 for (int mb_row = mb_row_min; mb_row <= mb_row_max; ++mb_row) { |
| 50 for (int mb_col = mb_col_min; mb_col <= mb_col_max; ++mb_col) { |
| 51 (*d_status_tmp1)[mb_row * mb_cols + mb_col] |= |
| 52 ((*d_status_tmp1)[(mb_row - 1) * mb_cols + mb_col] | |
| 53 (*d_status_tmp1)[mb_row * mb_cols + mb_col - 1]); |
| 54 } |
| 55 } |
| 56 memcpy((*d_status_tmp2).get(), (*d_status_tmp1).get(), mb_rows * mb_cols); |
| 57 memcpy((*d_status_tmp1).get(), d_status.get(), mb_rows * mb_cols); |
| 58 // Bottom left. |
| 59 for (int mb_row = mb_row_max; mb_row >= mb_row_min; --mb_row) { |
| 60 for (int mb_col = mb_col_min; mb_col <= mb_col_max; ++mb_col) { |
| 61 (*d_status_tmp1)[mb_row * mb_cols + mb_col] |= |
| 62 ((*d_status_tmp1)[(mb_row + 1) * mb_cols + mb_col] | |
| 63 (*d_status_tmp1)[mb_row * mb_cols + mb_col - 1]); |
| 64 (*d_status_tmp2)[mb_row * mb_cols + mb_col] &= |
| 65 (*d_status_tmp1)[mb_row * mb_cols + mb_col]; |
| 66 } |
| 67 } |
| 68 memcpy((*d_status_tmp1).get(), d_status.get(), mb_rows * mb_cols); |
| 69 // Up right. |
| 70 for (int mb_row = mb_row_min; mb_row <= mb_row_max; ++mb_row) { |
| 71 for (int mb_col = mb_col_max; mb_col >= mb_col_min; --mb_col) { |
| 72 (*d_status_tmp1)[mb_row * mb_cols + mb_col] |= |
| 73 ((*d_status_tmp1)[(mb_row - 1) * mb_cols + mb_col] | |
| 74 (*d_status_tmp1)[mb_row * mb_cols + mb_col + 1]); |
| 75 (*d_status_tmp2)[mb_row * mb_cols + mb_col] &= |
| 76 (*d_status_tmp1)[mb_row * mb_cols + mb_col]; |
| 77 } |
| 78 } |
| 79 memcpy((*d_status_tmp1).get(), d_status.get(), mb_rows * mb_cols); |
| 80 // Bottom right. |
| 81 for (int mb_row = mb_row_max; mb_row >= mb_row_min; --mb_row) { |
| 82 for (int mb_col = mb_col_max; mb_col >= mb_col_min; --mb_col) { |
| 83 (*d_status_tmp1)[mb_row * mb_cols + mb_col] |= |
| 84 ((*d_status_tmp1)[(mb_row + 1) * mb_cols + mb_col] | |
| 85 (*d_status_tmp1)[mb_row * mb_cols + mb_col + 1]); |
| 86 (*d_status_tmp2)[mb_row * mb_cols + mb_col] &= |
| 87 (*d_status_tmp1)[mb_row * mb_cols + mb_col]; |
| 88 } |
| 89 } |
| 90 } |
| 91 |
| 92 static bool TrailingBlock(const std::unique_ptr<uint8_t[]>& d_status, |
| 93 int mb_row, |
| 94 int mb_col, |
| 95 int mb_rows, |
| 96 int mb_cols) { |
| 97 int mb_index = mb_row * mb_cols + mb_col; |
| 98 if (!mb_row || !mb_col || mb_row == mb_rows - 1 || mb_col == mb_cols - 1) |
| 99 return false; |
| 100 return d_status[mb_index + 1] || d_status[mb_index - 1] || |
| 101 d_status[mb_index + mb_cols] || d_status[mb_index - mb_cols]; |
| 102 } |
| 103 #endif |
| 104 |
| 105 #if DISPLAY |
| 106 void ShowRect(const std::unique_ptr<DenoiserFilter>& filter, |
| 107 const std::unique_ptr<uint8_t[]>& d_status, |
| 108 const std::unique_ptr<uint8_t[]>& d_status_tmp2, |
| 109 const std::unique_ptr<uint8_t[]>& x_density, |
| 110 const std::unique_ptr<uint8_t[]>& y_density, |
| 111 const uint8_t* u_src, |
| 112 const uint8_t* v_src, |
| 113 uint8_t* u_dst, |
| 114 uint8_t* v_dst, |
| 115 int mb_rows, |
| 116 int mb_cols, |
| 117 int stride_u, |
| 118 int stride_v) { |
| 119 for (int mb_row = 0; mb_row < mb_rows; ++mb_row) { |
| 120 for (int mb_col = 0; mb_col < mb_cols; ++mb_col) { |
28 int mb_index = mb_row * mb_cols + mb_col; | 121 int mb_index = mb_row * mb_cols + mb_col; |
29 uint8_t* mb_dst = y_dst + (mb_row << 4) * stride_y + (mb_col << 4); | 122 const uint8_t* mb_src_u = |
30 const uint8_t* mb_src = y_src + (mb_row << 4) * stride_y + (mb_col << 4); | 123 u_src + (mb_row << 3) * stride_u + (mb_col << 3); |
31 // If the number of denoised neighbors is less than a threshold, | 124 const uint8_t* mb_src_v = |
32 // do NOT denoise for the block. Set different threshold for skin MB. | 125 v_src + (mb_row << 3) * stride_v + (mb_col << 3); |
33 // The change of denoising status will not propagate. | 126 uint8_t* mb_dst_u = u_dst + (mb_row << 3) * stride_u + (mb_col << 3); |
34 if (metrics_[mb_index].is_skin) { | 127 uint8_t* mb_dst_v = v_dst + (mb_row << 3) * stride_v + (mb_col << 3); |
35 // The threshold is high (more strict) for non-skin MB where the | 128 uint8_t y_tmp_255[8 * 8]; |
36 // trailing usually happen. | 129 memset(y_tmp_255, 200, 8 * 8); |
37 if (metrics_[mb_index].denoise && | 130 // x_density_[mb_col] * y_density_[mb_row] |
38 metrics_[mb_index + 1].denoise + metrics_[mb_index - 1].denoise + | 131 if (d_status[mb_index] == 1) { |
39 metrics_[mb_index + mb_cols].denoise + | 132 // Paint to red. |
40 metrics_[mb_index - mb_cols].denoise <= | 133 filter->CopyMem8x8(mb_src_u, stride_u, mb_dst_u, stride_u); |
41 2) { | 134 filter->CopyMem8x8(y_tmp_255, 8, mb_dst_v, stride_v); |
42 metrics_[mb_index].denoise = 0; | 135 #if EXPERIMENTAL |
43 filter_->CopyMem16x16(mb_src, stride_y, mb_dst, stride_y); | 136 } else if (d_status_tmp2[mb_row * mb_cols + mb_col] && |
44 } | 137 x_density[mb_col] * y_density[mb_row]) { |
45 } else if (metrics_[mb_index].denoise && | 138 #else |
46 metrics_[mb_index + 1].denoise + | 139 } else if (x_density[mb_col] * y_density[mb_row]) { |
47 metrics_[mb_index - 1].denoise + | 140 #endif |
48 metrics_[mb_index + mb_cols + 1].denoise + | 141 // Paint to blue. |
49 metrics_[mb_index + mb_cols - 1].denoise + | 142 filter->CopyMem8x8(y_tmp_255, 8, mb_dst_u, stride_u); |
50 metrics_[mb_index - mb_cols + 1].denoise + | 143 filter->CopyMem8x8(mb_src_v, stride_v, mb_dst_v, stride_v); |
51 metrics_[mb_index - mb_cols - 1].denoise + | 144 } else { |
52 metrics_[mb_index + mb_cols].denoise + | 145 filter->CopyMem8x8(mb_src_u, stride_u, mb_dst_u, stride_u); |
53 metrics_[mb_index - mb_cols].denoise <= | 146 filter->CopyMem8x8(mb_src_v, stride_v, mb_dst_v, stride_v); |
54 7) { | |
55 filter_->CopyMem16x16(mb_src, stride_y, mb_dst, stride_y); | |
56 } | 147 } |
57 } | 148 } |
58 } | 149 } |
59 } | 150 } |
| 151 #endif |
60 | 152 |
61 void VideoDenoiser::DenoiseFrame(const VideoFrame& frame, | 153 void VideoDenoiser::DenoiseFrame(const VideoFrame& frame, |
62 VideoFrame* denoised_frame) { | 154 VideoFrame* denoised_frame, |
| 155 VideoFrame* denoised_frame_prev, |
| 156 int noise_level_prev) { |
63 int stride_y = frame.stride(kYPlane); | 157 int stride_y = frame.stride(kYPlane); |
64 int stride_u = frame.stride(kUPlane); | 158 int stride_u = frame.stride(kUPlane); |
65 int stride_v = frame.stride(kVPlane); | 159 int stride_v = frame.stride(kVPlane); |
66 // If previous width and height are different from current frame's, then no | 160 // If previous width and height are different from current frame's, then no |
67 // denoising for the current frame. | 161 // denoising for the current frame. |
68 if (width_ != frame.width() || height_ != frame.height()) { | 162 if (width_ != frame.width() || height_ != frame.height()) { |
69 width_ = frame.width(); | 163 width_ = frame.width(); |
70 height_ = frame.height(); | 164 height_ = frame.height(); |
71 denoised_frame->CreateFrame(frame.buffer(kYPlane), frame.buffer(kUPlane), | 165 denoised_frame->CreateFrame(frame.buffer(kYPlane), frame.buffer(kUPlane), |
72 frame.buffer(kVPlane), width_, height_, | 166 frame.buffer(kVPlane), width_, height_, |
73 stride_y, stride_u, stride_v, kVideoRotation_0); | 167 stride_y, stride_u, stride_v, kVideoRotation_0); |
| 168 denoised_frame_prev->CreateFrame( |
| 169 frame.buffer(kYPlane), frame.buffer(kUPlane), frame.buffer(kVPlane), |
| 170 width_, height_, stride_y, stride_u, stride_v, kVideoRotation_0); |
74 // Setting time parameters to the output frame. | 171 // Setting time parameters to the output frame. |
75 denoised_frame->set_timestamp(frame.timestamp()); | 172 denoised_frame->set_timestamp(frame.timestamp()); |
76 denoised_frame->set_render_time_ms(frame.render_time_ms()); | 173 denoised_frame->set_render_time_ms(frame.render_time_ms()); |
| 174 ne_->Init(width_, height_, cpu_type_); |
77 return; | 175 return; |
78 } | 176 } |
79 // For 16x16 block. | 177 // For 16x16 block. |
80 int mb_cols = width_ >> 4; | 178 int mb_cols = width_ >> 4; |
81 int mb_rows = height_ >> 4; | 179 int mb_rows = height_ >> 4; |
82 if (metrics_.get() == nullptr) | 180 if (metrics_.get() == nullptr) |
83 metrics_.reset(new DenoiseMetrics[mb_cols * mb_rows]()); | 181 metrics_.reset(new DenoiseMetrics[mb_cols * mb_rows]()); |
| 182 if (d_status_.get() == nullptr) { |
| 183 d_status_.reset(new uint8_t[mb_cols * mb_rows]()); |
| 184 #if EXPERIMENTAL |
| 185 d_status_tmp1_.reset(new uint8_t[mb_cols * mb_rows]()); |
| 186 d_status_tmp2_.reset(new uint8_t[mb_cols * mb_rows]()); |
| 187 #endif |
| 188 x_density_.reset(new uint8_t[mb_cols]()); |
| 189 y_density_.reset(new uint8_t[mb_rows]()); |
| 190 } |
| 191 |
84 // Denoise on Y plane. | 192 // Denoise on Y plane. |
85 uint8_t* y_dst = denoised_frame->buffer(kYPlane); | 193 uint8_t* y_dst = denoised_frame->buffer(kYPlane); |
86 uint8_t* u_dst = denoised_frame->buffer(kUPlane); | 194 uint8_t* u_dst = denoised_frame->buffer(kUPlane); |
87 uint8_t* v_dst = denoised_frame->buffer(kVPlane); | 195 uint8_t* v_dst = denoised_frame->buffer(kVPlane); |
| 196 uint8_t* y_dst_prev = denoised_frame_prev->buffer(kYPlane); |
88 const uint8_t* y_src = frame.buffer(kYPlane); | 197 const uint8_t* y_src = frame.buffer(kYPlane); |
89 const uint8_t* u_src = frame.buffer(kUPlane); | 198 const uint8_t* u_src = frame.buffer(kUPlane); |
90 const uint8_t* v_src = frame.buffer(kVPlane); | 199 const uint8_t* v_src = frame.buffer(kVPlane); |
| 200 uint8_t noise_level = noise_level_prev == -1 ? 0 : ne_->GetNoiseLevel(); |
91 // Temporary buffer to store denoising result. | 201 // Temporary buffer to store denoising result. |
92 uint8_t y_tmp[16 * 16] = {0}; | 202 uint8_t y_tmp[16 * 16] = {0}; |
| 203 memset(x_density_.get(), 0, mb_cols); |
| 204 memset(y_density_.get(), 0, mb_rows); |
| 205 |
| 206 // Loop over blocks to accumulate/extract noise level and update x/y_density |
| 207 // factors for moving object detection. |
| 208 for (int mb_row = 0; mb_row < mb_rows; ++mb_row) { |
| 209 for (int mb_col = 0; mb_col < mb_cols; ++mb_col) { |
| 210 const uint8_t* mb_src = y_src + (mb_row << 4) * stride_y + (mb_col << 4); |
| 211 uint8_t* mb_dst_prev = |
| 212 y_dst_prev + (mb_row << 4) * stride_y + (mb_col << 4); |
| 213 int mb_index = mb_row * mb_cols + mb_col; |
| 214 #if EXPERIMENTAL |
| 215 int pos_factor = PositionCheck(mb_row, mb_col, mb_rows, mb_cols); |
| 216 uint32_t thr_var_adp = 16 * 16 * 5 * (noise_level ? pos_factor : 1); |
| 217 #else |
| 218 uint32_t thr_var_adp = 16 * 16 * 5; |
| 219 #endif |
| 220 int brightness = 0; |
| 221 for (int i = 0; i < 16; ++i) { |
| 222 for (int j = 0; j < 16; ++j) { |
| 223 brightness += mb_src[i * stride_y + j]; |
| 224 } |
| 225 } |
| 226 |
| 227 // Get the denoised block. |
| 228 filter_->MbDenoise(mb_dst_prev, stride_y, y_tmp, 16, mb_src, stride_y, 0, |
| 229 1, true); |
| 230 // The variance is based on the denoised blocks in time T and T-1. |
| 231 metrics_[mb_index].var = filter_->Variance16x8( |
| 232 mb_dst_prev, stride_y, y_tmp, 16, &metrics_[mb_index].sad); |
| 233 |
| 234 if (metrics_[mb_index].var > thr_var_adp) { |
| 235 ne_->ResetConsecLowVar(mb_index); |
| 236 d_status_[mb_index] = 1; |
| 237 #if EXPERIMENTAL |
| 238 if (noise_level == 0 || pos_factor < 3) { |
| 239 x_density_[mb_col] += 1; |
| 240 y_density_[mb_row] += 1; |
| 241 } |
| 242 #else |
| 243 x_density_[mb_col] += 1; |
| 244 y_density_[mb_row] += 1; |
| 245 #endif |
| 246 } else { |
| 247 uint32_t sse_t = 0; |
| 248 // The variance is based on the src blocks in time T and denoised block |
| 249 // in time T-1. |
| 250 uint32_t noise_var = filter_->Variance16x8(mb_dst_prev, stride_y, |
| 251 mb_src, stride_y, &sse_t); |
| 252 ne_->GetNoise(mb_index, noise_var, brightness); |
| 253 d_status_[mb_index] = 0; |
| 254 } |
| 255 // Track denoised frame. |
| 256 filter_->CopyMem16x16(y_tmp, 16, mb_dst_prev, stride_y); |
| 257 } |
| 258 } |
| 259 |
| 260 #if EXPERIMENTAL |
| 261 ReduceFalseDetection(d_status_, &d_status_tmp1_, &d_status_tmp2_, noise_level, |
| 262 mb_rows, mb_cols); |
| 263 #endif |
| 264 |
| 265 // Denoise each MB based on the results of moving objects detection. |
93 for (int mb_row = 0; mb_row < mb_rows; ++mb_row) { | 266 for (int mb_row = 0; mb_row < mb_rows; ++mb_row) { |
94 for (int mb_col = 0; mb_col < mb_cols; ++mb_col) { | 267 for (int mb_col = 0; mb_col < mb_cols; ++mb_col) { |
95 const uint8_t* mb_src = y_src + (mb_row << 4) * stride_y + (mb_col << 4); | 268 const uint8_t* mb_src = y_src + (mb_row << 4) * stride_y + (mb_col << 4); |
96 uint8_t* mb_dst = y_dst + (mb_row << 4) * stride_y + (mb_col << 4); | 269 uint8_t* mb_dst = y_dst + (mb_row << 4) * stride_y + (mb_col << 4); |
97 int mb_index = mb_row * mb_cols + mb_col; | |
98 // Denoise each MB at the very start and save the result to a temporary | |
99 // buffer. | |
100 if (filter_->MbDenoise(mb_dst, stride_y, y_tmp, 16, mb_src, stride_y, 0, | |
101 1) == FILTER_BLOCK) { | |
102 uint32_t thr_var = 0; | |
103 // Save var and sad to the buffer. | |
104 metrics_[mb_index].var = filter_->Variance16x8( | |
105 mb_dst, stride_y, y_tmp, 16, &metrics_[mb_index].sad); | |
106 // Get skin map. | |
107 metrics_[mb_index].is_skin = MbHasSkinColor( | |
108 y_src, u_src, v_src, stride_y, stride_u, stride_v, mb_row, mb_col); | |
109 // Variance threshold for skin/non-skin MB is different. | |
110 // Skin MB use a small threshold to reduce blockiness. | |
111 thr_var = metrics_[mb_index].is_skin ? 128 : 12 * 128; | |
112 if (metrics_[mb_index].var > thr_var) { | |
113 metrics_[mb_index].denoise = 0; | |
114 // Use the source MB. | |
115 filter_->CopyMem16x16(mb_src, stride_y, mb_dst, stride_y); | |
116 } else { | |
117 metrics_[mb_index].denoise = 1; | |
118 // Use the denoised MB. | |
119 filter_->CopyMem16x16(y_tmp, 16, mb_dst, stride_y); | |
120 } | |
121 } else { | |
122 metrics_[mb_index].denoise = 0; | |
123 filter_->CopyMem16x16(mb_src, stride_y, mb_dst, stride_y); | |
124 } | |
125 // Copy source U/V plane. | |
126 const uint8_t* mb_src_u = | 270 const uint8_t* mb_src_u = |
127 u_src + (mb_row << 3) * stride_u + (mb_col << 3); | 271 u_src + (mb_row << 3) * stride_u + (mb_col << 3); |
128 const uint8_t* mb_src_v = | 272 const uint8_t* mb_src_v = |
129 v_src + (mb_row << 3) * stride_v + (mb_col << 3); | 273 v_src + (mb_row << 3) * stride_v + (mb_col << 3); |
130 uint8_t* mb_dst_u = u_dst + (mb_row << 3) * stride_u + (mb_col << 3); | 274 uint8_t* mb_dst_u = u_dst + (mb_row << 3) * stride_u + (mb_col << 3); |
131 uint8_t* mb_dst_v = v_dst + (mb_row << 3) * stride_v + (mb_col << 3); | 275 uint8_t* mb_dst_v = v_dst + (mb_row << 3) * stride_v + (mb_col << 3); |
| 276 #if EXPERIMENTAL |
| 277 if ((!d_status_tmp2_[mb_row * mb_cols + mb_col] || |
| 278 x_density_[mb_col] * y_density_[mb_row] == 0) && |
| 279 !TrailingBlock(d_status_, mb_row, mb_col, mb_rows, mb_cols)) { |
| 280 #else |
| 281 if (x_density_[mb_col] * y_density_[mb_row] == 0) { |
| 282 #endif |
| 283 if (filter_->MbDenoise(mb_dst, stride_y, y_tmp, 16, mb_src, stride_y, 0, |
| 284 noise_level, false) == FILTER_BLOCK) { |
| 285 filter_->CopyMem16x16(y_tmp, 16, mb_dst, stride_y); |
| 286 } else { |
| 287 // Copy y source. |
| 288 filter_->CopyMem16x16(mb_src, stride_y, mb_dst, stride_y); |
| 289 } |
| 290 } else { |
| 291 // Copy y source. |
| 292 filter_->CopyMem16x16(mb_src, stride_y, mb_dst, stride_y); |
| 293 } |
132 filter_->CopyMem8x8(mb_src_u, stride_u, mb_dst_u, stride_u); | 294 filter_->CopyMem8x8(mb_src_u, stride_u, mb_dst_u, stride_u); |
133 filter_->CopyMem8x8(mb_src_v, stride_v, mb_dst_v, stride_v); | 295 filter_->CopyMem8x8(mb_src_v, stride_v, mb_dst_v, stride_v); |
134 } | 296 } |
135 } | 297 } |
136 // Second round. | 298 |
137 // This is to reduce the trailing artifact and blockiness by referring | 299 #if DISPLAY // Rectangle diagnostics |
138 // neighbors' denoising status. | 300 // Show rectangular region |
139 TrailingReduction(mb_rows, mb_cols, y_src, stride_y, y_dst); | 301 ShowRect(filter_, d_status_, d_status_tmp2_, x_density_, y_density_, u_src, |
| 302 v_src, u_dst, v_dst, mb_rows, mb_cols, stride_u, stride_v); |
| 303 #endif |
140 | 304 |
141 // Setting time parameters to the output frame. | 305 // Setting time parameters to the output frame. |
142 denoised_frame->set_timestamp(frame.timestamp()); | 306 denoised_frame->set_timestamp(frame.timestamp()); |
143 denoised_frame->set_render_time_ms(frame.render_time_ms()); | 307 denoised_frame->set_render_time_ms(frame.render_time_ms()); |
144 return; | 308 return; |
145 } | 309 } |
146 | 310 |
147 } // namespace webrtc | 311 } // namespace webrtc |
OLD | NEW |