shithub: libvpx

Download patch

ref: 5f914dd902b8414d7d4d8c21d0be96059f2c5103
parent: d22b1d69575bb4852555e3636dedb0ee6e635250
author: Marco Paniconi <marpan@google.com>
date: Thu Aug 2 16:48:17 EDT 2018

vp9: Add zero_temp_sad count to scene detection.

For real-time screen-content mode: makes the
scene/slide change detection more robust.

Change-Id: I28d8d28b42bb92d527811f814bf14bbbbb53ab25

--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -2640,6 +2640,7 @@
     int frames_to_buffer = 1;
     int frame = 0;
     int scene_cut_force_key_frame = 0;
+    int num_zero_temp_sad = 0;
     uint64_t avg_sad_current = 0;
     uint32_t min_thresh = 10000;
     float thresh = 8.0f;
@@ -2703,6 +2704,7 @@
           last_src_y = frames[frame + 1]->y_buffer;
           last_src_ystride = frames[frame + 1]->y_stride;
         }
+        num_zero_temp_sad = 0;
         for (sbi_row = 0; sbi_row < sb_rows; ++sbi_row) {
           for (sbi_col = 0; sbi_col < sb_cols; ++sbi_col) {
             // Checker-board pattern, ignore boundary.
@@ -2714,6 +2716,7 @@
                                                last_src_ystride);
               avg_sad += tmp_sad;
               num_samples++;
+              if (tmp_sad == 0) num_zero_temp_sad++;
             }
             src_y += 64;
             last_src_y += 64;
@@ -2730,7 +2733,8 @@
           if (avg_sad >
                   VPXMAX(min_thresh,
                          (unsigned int)(rc->avg_source_sad[0] * thresh)) &&
-              rc->frames_since_key > 1)
+              rc->frames_since_key > 1 &&
+              num_zero_temp_sad < 3 * (num_samples >> 2))
             rc->high_source_sad = 1;
           else
             rc->high_source_sad = 0;