shithub: libvpx

Download patch

ref: 086ae992356b091f555479d41fe23ec34307620f
parent: dddc3c6906f0d840935214ab0b26ea9a6e06cc27
author: Adrian Grange <agrange@google.com>
date: Wed Apr 23 06:08:31 EDT 2014

Fixed handling of regularly placed keyframes

The encoder was not handling requests to place keyframes at
fixed intervals, i.e. kf_min_dist == kf_max_dist, correctly.

In this case when looking to place the next keyframe it was
accumulating stats all the way up to the end of the firstpass
file. This patch corrects this behavior.

Change-Id: I948ad9f1d7faa0c05861df588136cce3bb61d7e7

--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -1935,7 +1935,8 @@
 
   // Find the next keyframe.
   i = 0;
-  while (twopass->stats_in < twopass->stats_in_end) {
+  while (twopass->stats_in < twopass->stats_in_end &&
+         rc->frames_to_key < cpi->key_frame_frequency) {
     // Accumulate kf group error.
     kf_group_err += calculate_modified_err(cpi, this_frame);
 
@@ -2003,7 +2004,8 @@
       input_stats(twopass, &tmp_frame);
     }
     rc->next_key_frame_forced = 1;
-  } else if (twopass->stats_in == twopass->stats_in_end) {
+  } else if (twopass->stats_in == twopass->stats_in_end ||
+             rc->frames_to_key >= cpi->key_frame_frequency) {
     rc->next_key_frame_forced = 1;
   } else {
     rc->next_key_frame_forced = 0;
--- a/vp9/vp9_cx_iface.c
+++ b/vp9/vp9_cx_iface.c
@@ -185,7 +185,7 @@
         ERROR("ts_rate_decimator factors are not powers of 2");
   }
 
-  // VP8 does not support a lower bound on the keyframe interval in
+  // VP9 does not support a lower bound on the keyframe interval in
   // automatic keyframe placement mode.
   if (cfg->kf_mode != VPX_KF_DISABLED &&
       cfg->kf_min_dist != cfg->kf_max_dist &&