]> granicus.if.org Git - libvpx/commitdiff
Adjust alt-ref selection in define_gf_group()
authorhui su <huisu@google.com>
Thu, 20 Apr 2017 22:49:52 +0000 (15:49 -0700)
committerhui su <huisu@google.com>
Wed, 26 Apr 2017 01:03:47 +0000 (18:03 -0700)
107de19698 changes the encoder alt-ref selection behavior. Assuming
min_gf_interval = max_gf_interval = 4, the frame order would be
frm_1  arf_1  frm_2  frm_3  frm_4  frm_5  arf_2 before 107de19698;
frm_1  arf_1  frm_2  frm_3  frm_4  arf_2  frm_5 after 107de19698.

This patch reverts such alt-ref placement change.

Change-Id: I93a4a65036575151286f004d455d4fcea88a1550

vp9/encoder/vp9_firstpass.c

index e7639a7c570c12093b200dc228f55c31e7b3ed15..43b87df33d40130eb7b5c3fa5e59ed51d345c658 100644 (file)
@@ -2370,8 +2370,8 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
                                                 cpi->common.bit_depth));
     active_min_gf_interval =
         rc->min_gf_interval + arf_active_or_kf + VPXMIN(2, int_max_q / 200);
-    if (active_min_gf_interval > rc->max_gf_interval)
-      active_min_gf_interval = rc->max_gf_interval;
+    active_min_gf_interval =
+        VPXMIN(active_min_gf_interval, rc->max_gf_interval + arf_active_or_kf);
 
     if (cpi->multi_arf_allowed) {
       active_max_gf_interval = rc->max_gf_interval;
@@ -2382,11 +2382,14 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
       // interval to spread the cost of the GF.
       active_max_gf_interval = 12 + arf_active_or_kf + VPXMIN(4, (int_lbq / 6));
 
-      // We have: active_min_gf_interval <= rc->max_gf_interval
-      if (active_max_gf_interval < active_min_gf_interval)
+      // We have: active_min_gf_interval <=
+      // rc->max_gf_interval + arf_active_or_kf.
+      if (active_max_gf_interval < active_min_gf_interval) {
         active_max_gf_interval = active_min_gf_interval;
-      else if (active_max_gf_interval > rc->max_gf_interval)
-        active_max_gf_interval = rc->max_gf_interval;
+      } else {
+        active_max_gf_interval = VPXMIN(active_max_gf_interval,
+                                        rc->max_gf_interval + arf_active_or_kf);
+      }
 
       // Would the active max drop us out just before the near the next kf?
       if ((active_max_gf_interval <= rc->frames_to_key) &&