shithub: libvpx

Download patch

ref: 6804737ef5f18e2e5ade9608b2e34090bb030ef2
parent: 6b7848d4c9016efbfbc9529df008ffde0e15b7cc
author: Paul Wilkins <paulwilkins@google.com>
date: Tue Oct 2 12:11:14 EDT 2018

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

--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -2513,8 +2513,11 @@
     // 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.
     if (active_max_gf_interval < active_min_gf_interval) {
@@ -2613,7 +2616,7 @@
             // 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) ||