From d1124adef036af484d4fe75b131f7724cbad53fb Mon Sep 17 00:00:00 2001 From: angiebird Date: Wed, 16 Oct 2019 13:50:02 -0700 Subject: [PATCH] Localize zero_motion_accumulator Change-Id: Ib4d37667c217cb06e6941de7b3204ba71b880396 --- vp9/encoder/vp9_firstpass.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index 76c45b81c..7e8129b78 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -2496,8 +2496,6 @@ static void define_gf_group(VP9_COMP *cpi, int gf_start_show_idx) { 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 @@ static void define_gf_group(VP9_COMP *cpi, int gf_start_show_idx) { // 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,14 +2669,14 @@ static void define_gf_group(VP9_COMP *cpi, int gf_start_show_idx) { break; } } + allow_alt_ref &= zero_motion_accumulator < 0.995; } // Was the group length constrained by the requirement for a new KF? 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 -- 2.49.0