Fixed use of motion percentage in KF/GF group calc
In both vp8_find_next_key_frame and define_gf_group,
motion_pct was initialised at the top of the loop before
next_frame stats had been read in.
This fix sets motion_pct after next_frame stats have
been read.
Change-Id: I8c0bebf372ef8aa97b97fd35b42973d1d831ee73
diff --git a/vp8/encoder/firstpass.c b/vp8/encoder/firstpass.c
index e5a22d9..7102d1c 100644
--- a/vp8/encoder/firstpass.c
+++ b/vp8/encoder/firstpass.c
@@ -1381,7 +1381,7 @@
double this_frame_mvr_ratio;
double this_frame_mvc_ratio;
double motion_decay;
- double motion_pct = next_frame.pcnt_motion;
+ double motion_pct;
i++; // Increment the loop counter
@@ -1396,13 +1396,14 @@
break;
// Accumulate motion stats.
+ motion_pct = next_frame.pcnt_motion;
mv_accumulator_rabs += fabs(next_frame.mvr_abs * motion_pct);
mv_accumulator_cabs += fabs(next_frame.mvc_abs * motion_pct);
//Accumulate Motion In/Out of frame stats
- this_frame_mv_in_out = next_frame.mv_in_out_count * next_frame.pcnt_motion;
- mv_in_out_accumulator += next_frame.mv_in_out_count * next_frame.pcnt_motion;
- abs_mv_in_out_accumulator += fabs(next_frame.mv_in_out_count * next_frame.pcnt_motion);
+ this_frame_mv_in_out = next_frame.mv_in_out_count * motion_pct;
+ mv_in_out_accumulator += next_frame.mv_in_out_count * motion_pct;
+ abs_mv_in_out_accumulator += fabs(next_frame.mv_in_out_count * motion_pct);
// If there is a significant amount of motion
if (motion_pct > 0.05)
@@ -2451,7 +2452,7 @@
{
double r;
double motion_decay;
- double motion_pct = next_frame.pcnt_motion;
+ double motion_pct;
if (EOF == vp8_input_stats(cpi, &next_frame))
break;
@@ -2471,6 +2472,7 @@
loop_decay_rate = next_frame.pcnt_inter;
// High % motion -> somewhat higher decay rate
+ motion_pct = next_frame.pcnt_motion;
motion_decay = (1.0 - (motion_pct / 20.0));
if (motion_decay < loop_decay_rate)
loop_decay_rate = motion_decay;