diff options
author | Adrian Grange <agrange@google.com> | 2011-01-20 13:13:33 +0000 |
---|---|---|
committer | Adrian Grange <agrange@google.com> | 2011-01-20 13:13:33 +0000 |
commit | 815e1e9fe4ede2bc8e0e9b58cc58f84822a02f89 (patch) | |
tree | 9ae563828f3f88220d34a023ca32cbe07e258945 | |
parent | 06e7320c3e909c33e248b9910dc182b13451d1c8 (diff) | |
download | libvpx-815e1e9fe4ede2bc8e0e9b58cc58f84822a02f89.tar libvpx-815e1e9fe4ede2bc8e0e9b58cc58f84822a02f89.tar.gz libvpx-815e1e9fe4ede2bc8e0e9b58cc58f84822a02f89.tar.bz2 libvpx-815e1e9fe4ede2bc8e0e9b58cc58f84822a02f89.zip |
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
-rw-r--r-- | vp8/encoder/firstpass.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/vp8/encoder/firstpass.c b/vp8/encoder/firstpass.c index e5a22d957..7102d1cd0 100644 --- a/vp8/encoder/firstpass.c +++ b/vp8/encoder/firstpass.c @@ -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; |