shithub: libvpx

Download patch

ref: d1124adef036af484d4fe75b131f7724cbad53fb
parent: ab7974d36df5c548c8f3549545d12f42e2b274ce
author: angiebird <angiebird@google.com>
date: Wed Oct 16 09:50:02 EDT 2019

Localize zero_motion_accumulator

Change-Id: Ib4d37667c217cb06e6941de7b3204ba71b880396

--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -2496,8 +2496,6 @@
   double gf_group_inter = 0.0;
   double gf_group_motion = 0.0;
 
-  double zero_motion_accumulator = 1.0;
-
   unsigned int allow_alt_ref = is_altref_enabled(cpi);
 
   int active_max_gf_interval;
@@ -2584,6 +2582,7 @@
     // Motion breakout threshold for loop below depends on image size.
     double mv_ratio_accumulator_thresh =
         (cpi->initial_height + cpi->initial_width) / 4.0;
+    double zero_motion_accumulator = 1.0;
 
     while (i < rc->static_scene_max_gf_interval && i < rc->frames_to_key) {
       const FIRSTPASS_STATS *next_next_frame;
@@ -2670,6 +2669,7 @@
         break;
       }
     }
+    allow_alt_ref &= zero_motion_accumulator < 0.995;
   }
 
   // Was the group length constrained by the requirement for a new KF?
@@ -2676,8 +2676,7 @@
   rc->constrained_gf_group = (i >= rc->frames_to_key) ? 1 : 0;
 
   // Should we use the alternate reference frame.
-  if ((zero_motion_accumulator < 0.995) && allow_alt_ref &&
-      (twopass->kf_zeromotion_pct < STATIC_KF_GROUP_THRESH) &&
+  if (allow_alt_ref && (twopass->kf_zeromotion_pct < STATIC_KF_GROUP_THRESH) &&
       (i < cpi->oxcf.lag_in_frames) && (i >= rc->min_gf_interval)) {
     const int f_frames = (rc->frames_to_key - i >= i - 1)
                              ? i - 1