From: Paul Wilkins Date: Tue, 2 Oct 2018 15:11:14 +0000 (+0100) Subject: Force even arf group length where possible. X-Git-Tag: v1.8.0~268^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6804737ef5f18e2e5ade9608b2e34090bb030ef2;p=libvpx Force even arf group length where possible. This patch tweaks the calculation of the active maximum GF interval and also the break out clause for the GF interval loop. The changes force the maximum and where possible the break out value to be odd which in turn will result in an even length ARF group if ARF coding is selected (vs GF only coding). The primary aim was to improve coding with multi layer arf groups. For the single layer case there are small net gains in 3 out of 4 sets (low,md, hd) and a small net drop for the NF2K set. For multi-layer the gains (opsnr, ssim, psnr-hvs : -ve = better) were:- Low res: -0.109, -0.038, -0.036 Mid res: -0.204, -0.171, -0.242 Hd res: -0.330, -0.471, -0.496 NF 2k: -0.165, -0.149, -0.157 Change-Id: I245f8561f5d1bd34312a0133c670c2154a0da23f --- diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index 0bf1a728b..58c3a435d 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -2513,7 +2513,10 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { // bits to spare and are better with a smaller interval and smaller boost. // At high Q when there are few bits to spare we are better with a longer // interval to spread the cost of the GF. - active_max_gf_interval = 12 + arf_active_or_kf + VPXMIN(4, q_term); + active_max_gf_interval = 11 + arf_active_or_kf + VPXMIN(5, q_term); + + // Force max GF interval to be odd. + active_max_gf_interval = active_max_gf_interval | 0x01; // We have: active_min_gf_interval <= // rc->max_gf_interval + arf_active_or_kf. @@ -2613,7 +2616,7 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { // Don't break out with a very short interval. (i >= active_min_gf_interval) && // If possible dont break very close to a kf - ((rc->frames_to_key - i) >= rc->min_gf_interval) && + ((rc->frames_to_key - i) >= rc->min_gf_interval) && (i & 0x01) && (!flash_detected) && ((mv_ratio_accumulator > mv_ratio_accumulator_thresh) || (abs_mv_in_out_accumulator > abs_mv_in_out_thresh) ||