shithub: libvpx

Download patch

ref: 8097b49997e839863cf0e48a54ea29f757bb34a2
parent: 6b3f4bc794bc5bc58a583b3925bd2e05f4eec4a1
author: Marco <[email protected]>
date: Tue Apr 4 05:53:13 EDT 2017

vp9: Adjust condition of golden update with cyclic refresh.

Base the low_content_frame metric on the motion vectors,
and adjust the logic for preventing golden update.

Small change in behavior: small positive gain (~0.2-1%) on clips
with high activity.

Change-Id: I0b861c8e9666cd82b45cde5ee57ee8a1e5ab453c

--- a/vp9/encoder/vp9_aq_cyclicrefresh.c
+++ b/vp9/encoder/vp9_aq_cyclicrefresh.c
@@ -258,6 +258,7 @@
   cr->actual_num_seg2_blocks = 0;
   for (mi_row = 0; mi_row < cm->mi_rows; mi_row++) {
     for (mi_col = 0; mi_col < cm->mi_cols; mi_col++) {
+      MV mv = mi[0]->mv[0].as_mv;
       int map_index = mi_row * cm->mi_cols + mi_col;
       if (cyclic_refresh_segment_id(seg_map[map_index]) == CR_SEGMENT_ID_BOOST1)
         cr->actual_num_seg1_blocks++;
@@ -265,7 +266,8 @@
                CR_SEGMENT_ID_BOOST2)
         cr->actual_num_seg2_blocks++;
       // Accumulate low_content_frame.
-      if (cr->map[map_index] < 1) low_content_frame++;
+      if (is_inter_block(mi[0]) && abs(mv.row) < 16 && abs(mv.col) < 16)
+        low_content_frame++;
       mi++;
     }
     mi += 8;
@@ -288,12 +290,14 @@
     // Update average of low content/motion in the frame.
     fraction_low = (double)low_content_frame / (cm->mi_rows * cm->mi_cols);
     cr->low_content_avg = (fraction_low + 3 * cr->low_content_avg) / 4;
-    if (!force_gf_refresh && cpi->refresh_golden_frame == 1) {
+    if (!force_gf_refresh && cpi->refresh_golden_frame == 1 &&
+        rc->frames_since_key > rc->frames_since_golden + 1) {
       // Don't update golden reference if the amount of low_content for the
       // current encoded frame is small, or if the recursive average of the
       // low_content over the update interval window falls below threshold.
-      if (fraction_low < 0.8 || cr->low_content_avg < 0.7)
+      if (fraction_low < 0.65 || cr->low_content_avg < 0.6) {
         cpi->refresh_golden_frame = 0;
+      }
       // Reset for next internal.
       cr->low_content_avg = fraction_low;
     }