Commit 815e1e9f authored by Adrian Grange's avatar Adrian Grange
Browse files

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
parent 06e7320c
......@@ -1381,7 +1381,7 @@ static void define_gf_group(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
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 @@ static void define_gf_group(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
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 @@ void vp8_find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
{
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 @@ void vp8_find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment