shithub: libvpx

Download patch

ref: 9f002bee53b5372f97b6dbc01f97c598ff585fcf
parent: 34ba18760fa1e14c6679aa4e423f030e3166b981
author: Ronald S. Bultje <rbultje@google.com>
date: Thu Jun 2 05:14:51 EDT 2011

Don't allow very short GF groups even when the GF is predicted from an ARF.

This is basically a slightly modified version of the previous patch,
and it has a moderately positive effect (SSIM/PSNR both +0.08% avg
on derf-set). Most clips show no change, except waterfall/coastguard,
each ~ +0.8% SSIM/PSNR. You can see similar effects in other clips
by shortening their length to terminate at a very short last group
of frames.

Change-Id: I7a70de99ca1f9fe6a8b6ca7a6e30e8a4b64383e4

--- a/vp8/encoder/firstpass.c
+++ b/vp8/encoder/firstpass.c
@@ -1553,6 +1553,24 @@
 
     cpi->gfu_boost = (int)(boost_score * 100.0) >> 4;
 
+    // Dont allow conventional gf too near the next kf
+    if ((cpi->twopass.frames_to_key - i) < MIN_GF_INTERVAL)
+    {
+        while (i < cpi->twopass.frames_to_key)
+        {
+            i++;
+
+            if (EOF == input_stats(cpi, this_frame))
+                break;
+
+            if (i < cpi->twopass.frames_to_key)
+            {
+                mod_frame_err = calculate_modified_err(cpi, this_frame);
+                gf_group_err += mod_frame_err;
+            }
+        }
+    }
+
     // Should we use the alternate refernce frame
     if (allow_alt_ref &&
         (i >= MIN_GF_INTERVAL) &&
@@ -1673,25 +1691,6 @@
     {
         cpi->source_alt_ref_pending = FALSE;
         cpi->baseline_gf_interval = i;
-    }
-
-    // Conventional GF
-    if (!cpi->source_alt_ref_pending)
-    {
-        // Dont allow conventional gf too near the next kf
-        if ((cpi->twopass.frames_to_key - cpi->baseline_gf_interval) < MIN_GF_INTERVAL)
-        {
-            while (cpi->baseline_gf_interval < cpi->twopass.frames_to_key)
-            {
-                if (EOF == input_stats(cpi, this_frame))
-                    break;
-
-                cpi->baseline_gf_interval++;
-
-                if (cpi->baseline_gf_interval < cpi->twopass.frames_to_key)
-                    gf_group_err += calculate_modified_err(cpi, this_frame);
-            }
-        }
     }
 
     // Now decide how many bits should be allocated to the GF group as  a proportion of those remaining in the kf group.