Index: webrtc/modules/video_processing/video_denoiser.cc |
diff --git a/webrtc/modules/video_processing/video_denoiser.cc b/webrtc/modules/video_processing/video_denoiser.cc |
index e48bf5b8cd2ef181c80329b92249501723eac5bf..c1cab8187d28c4b3ad2c3c58b882818979931600 100644 |
--- a/webrtc/modules/video_processing/video_denoiser.cc |
+++ b/webrtc/modules/video_processing/video_denoiser.cc |
@@ -207,6 +207,23 @@ void VideoDenoiser::CopySrcOnMOB(const uint8_t* y_src, uint8_t* y_dst) { |
} |
} |
+void VideoDenoiser::CopyLumaOnMargin(const uint8_t* y_src, uint8_t* y_dst) { |
+ if ((mb_rows_ << 4) != height_) { |
+ const uint8_t* margin_y_src = y_src + (mb_rows_ << 4) * stride_y_; |
+ uint8_t* margin_y_dst = y_dst + (mb_rows_ << 4) * stride_y_; |
+ memcpy(margin_y_dst, margin_y_src, (height_ - (mb_rows_ << 4)) * stride_y_); |
+ } |
+ if ((mb_cols_ << 4) != width_) { |
+ const uint8_t* margin_y_src = y_src + (mb_cols_ << 4); |
+ uint8_t* margin_y_dst = y_dst + (mb_cols_ << 4); |
+ for (int i = 0; i < height_; ++i) { |
+ for (int j = mb_cols_ << 4; j < width_; ++j) { |
+ margin_y_dst[i * stride_y_ + j] = margin_y_src[i * stride_y_ + j]; |
+ } |
+ } |
+ } |
+} |
+ |
void VideoDenoiser::DenoiseFrame(const VideoFrame& frame, |
VideoFrame* denoised_frame, |
VideoFrame* denoised_frame_prev, |
@@ -309,6 +326,11 @@ void VideoDenoiser::DenoiseFrame(const VideoFrame& frame, |
CopySrcOnMOB(y_src, y_dst); |
+ // When frame width/height not divisible by 16, copy the margin to |
+ // denoised_frame. |
+ if ((mb_rows_ << 4) != height_ || (mb_cols_ << 4) != width_) |
+ CopyLumaOnMargin(y_src, y_dst); |
+ |
// TODO(jackychen): Need SSE2/NEON opt. |
// Copy u/v planes. |
memcpy(u_dst, u_src, (height_ >> 1) * stride_u_); |