External VNR speed improvement.
Improved visual quality with 3x times speed-up.
Change list:
1. Remove second chance filter in temporal denoising filter to mitigate trailing artifact.
2. Add swap buffer to save one whole-frame memcpy.
3. Do noise estimation on every N blocks.
4. Adopt a faster moving object detection algorithm (change the structure).
5. Refactor the for loops and PositionCheck().
6. Refactor the function ReduceFalseDetection (RFD).
7. Fix a bug in TrailingBlock() which causes a mismatch.
8. Change unit test to support swap buffer test.
9. Remove CopyMem8x8, use memcpy to copy U/V plane which can be optimized future.
10. Remove DenoiseMetrics.
Review URL: https://codereview.webrtc.org/1871853003
Cr-Commit-Position: refs/heads/master@{#12340}
diff --git a/webrtc/modules/video_processing/video_denoiser.h b/webrtc/modules/video_processing/video_denoiser.h
index 03b30d9..319845b 100644
--- a/webrtc/modules/video_processing/video_denoiser.h
+++ b/webrtc/modules/video_processing/video_denoiser.h
@@ -22,25 +22,55 @@
class VideoDenoiser {
public:
explicit VideoDenoiser(bool runtime_cpu_detection);
+
void DenoiseFrame(const VideoFrame& frame,
VideoFrame* denoised_frame,
- VideoFrame* denoised_frame_track,
- int noise_level_prev);
+ VideoFrame* denoised_frame_prev,
+ bool noise_estimation_enabled);
private:
+ void DenoiserReset(const VideoFrame& frame,
+ VideoFrame* denoised_frame,
+ VideoFrame* denoised_frame_prev);
+
+ // Check the mb position, return 1: close to the frame center (between 1/8
+ // and 7/8 of width/height), 3: close to the border (out of 1/16 and 15/16
+ // of width/height), 2: in between.
+ int PositionCheck(int mb_row, int mb_col, int noise_level);
+
+ // To reduce false detection in moving object detection (MOD).
+ void ReduceFalseDetection(const std::unique_ptr<uint8_t[]>& d_status,
+ std::unique_ptr<uint8_t[]>* d_status_red,
+ int noise_level);
+
+ // Return whether a block might cause trailing artifact by checking if one of
+ // its neighbor blocks is a moving edge block.
+ bool IsTrailingBlock(const std::unique_ptr<uint8_t[]>& d_status,
+ int mb_row,
+ int mb_col);
+
+ // Copy input blocks to dst buffer on moving object blocks (MOB).
+ void CopySrcOnMOB(const uint8_t* y_src, uint8_t* y_dst);
+
int width_;
int height_;
+ int mb_rows_;
+ int mb_cols_;
+ int stride_y_;
+ int stride_u_;
+ int stride_v_;
CpuType cpu_type_;
- std::unique_ptr<DenoiseMetrics[]> metrics_;
std::unique_ptr<DenoiserFilter> filter_;
std::unique_ptr<NoiseEstimation> ne_;
- std::unique_ptr<uint8_t[]> d_status_;
-#if EXPERIMENTAL
- std::unique_ptr<uint8_t[]> d_status_tmp1_;
- std::unique_ptr<uint8_t[]> d_status_tmp2_;
-#endif
+ // 1 for moving edge block, 0 for static block.
+ std::unique_ptr<uint8_t[]> moving_edge_;
+ // 1 for moving object block, 0 for static block.
+ std::unique_ptr<uint8_t[]> moving_object_;
+ // x_density_ and y_density_ are used in MOD process.
std::unique_ptr<uint8_t[]> x_density_;
std::unique_ptr<uint8_t[]> y_density_;
+ // Save the return values by MbDenoise for each block.
+ std::unique_ptr<DenoiserDecision[]> mb_filter_decision_;
};
} // namespace webrtc