shithub: libvpx

Download patch

ref: ce9e52b13c9f1d1e356d3061877e661b5ab1f4da
parent: 1c0857d648c1e2eb13de3d2e717b1848bbc602d9
author: Marco Paniconi <marpan@google.com>
date: Mon Apr 1 10:18:54 EDT 2019

vp9-rtc: Move noise estimation to after scene change detection

This allows to use result from scene chage detection to exclude
the current frame from noise estimation analysis if the frame has
scene/ big content change (i.e., high_source_sad flag is set).

The behavior change for noise estimation may be small in practice,
since in the current code, a scene change would have blocks excluded
due to thresh_sum_diff, and the subsequent frames would also be mostly
excluded due to (past) non-zero motion vectors (until the
consec_zeromv > thresh_consec_zeromv is satisfied again).
But its better to completely exclude current frame if its a scene change.

Change-Id: Icd08bab7a8e1b994c7accced89697e0b2d7f50c5

--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -3839,7 +3839,6 @@
   if (cpi->oxcf.noise_sensitivity > 0 && cpi->use_svc)
     vp9_denoiser_reset_on_first_frame(cpi);
 #endif
-  vp9_update_noise_estimate(cpi);
 
   // Scene detection is always used for VBR mode or screen-content case.
   // For other cases (e.g., CBR mode) use it for 5 <= speed < 8 for now
@@ -3870,6 +3869,8 @@
       cpi->rc.high_source_sad = tmp_high_source_sad;
     }
   }
+
+  vp9_update_noise_estimate(cpi);
 
   // For 1 pass CBR, check if we are dropping this frame.
   // Never drop on key frame, if base layer is key for svc,
--- a/vp9/encoder/vp9_noise_estimate.c
+++ b/vp9/encoder/vp9_noise_estimate.c
@@ -209,8 +209,11 @@
           // Only consider blocks that are likely steady background. i.e, have
           // been encoded as zero/low motion x (= thresh_consec_zeromv) frames
           // in a row. consec_zero_mv[] defined for 8x8 blocks, so consider all
-          // 4 sub-blocks for 16x16 block. Also, avoid skin blocks.
-          if (frame_low_motion && consec_zeromv > thresh_consec_zeromv) {
+          // 4 sub-blocks for 16x16 block. And exclude this frame if
+          // high_source_sad is true (i.e., scene/content change).
+          if (frame_low_motion && consec_zeromv > thresh_consec_zeromv &&
+              !cpi->rc.high_source_sad &&
+              !cpi->svc.high_source_sad_superframe) {
             int is_skin = 0;
             if (cpi->use_skin_detection) {
               is_skin =