shithub: libvpx

Download patch

ref: f73b21439d05e71451d51222f557a59fad0256db
parent: a9deec43895c75be16d685f1a69f92f0c4670f94
parent: cf3d2c8d5a8438fd63ed739f11f1116e0f21d3a0
author: Deb Mukherjee <[email protected]>
date: Mon Jan 6 07:01:30 EST 2014

Merge "Corerctly sets frame type in the 2 pass case"

--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -2114,6 +2114,8 @@
     // Define next KF group and assign bits to it
     this_frame_copy = this_frame;
     find_next_key_frame(cpi, &this_frame_copy);
+  } else {
+    cpi->common.frame_type = INTER_FRAME;
   }
 
   // Is this a GF / ARF (Note that a KF is always also a GF)
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -2913,19 +2913,6 @@
   // Current default encoder behavior for the altref sign bias.
   cpi->common.ref_frame_sign_bias[ALTREF_FRAME] = cpi->rc.source_alt_ref_active;
 
-  // Check to see if a key frame is signaled.
-  // For two pass with auto key frame enabled cm->frame_type may already be
-  // set, but not for one pass.
-  if ((cm->current_video_frame == 0) ||
-      (cm->frame_flags & FRAMEFLAGS_KEY) ||
-      (cpi->oxcf.auto_key && (cpi->rc.frames_since_key %
-                              cpi->key_frame_frequency == 0))) {
-    // Set frame type to key frame for the force key frame, if we exceed the
-    // maximum distance in an automatic keyframe selection or for the first
-    // frame.
-    cm->frame_type = KEY_FRAME;
-  }
-
   // Set default state for segment based loop filter update flags.
   cm->lf.mode_ref_delta_update = 0;
 
@@ -3165,7 +3152,6 @@
 #endif
 
     // As this frame is a key frame the next defaults to an inter frame.
-    cm->frame_type = INTER_FRAME;
     vp9_clear_system_state();
     cpi->rc.frames_since_key = 0;
   } else {
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -750,7 +750,6 @@
   // Limit Q range for the adaptive loop.
   if (cm->frame_type == KEY_FRAME && !cpi->rc.this_key_frame_forced) {
     if (!(cpi->pass == 0 && cpi->common.current_video_frame == 0)) {
-      *top_index = active_worst_quality;
       *top_index =
           (active_worst_quality + active_best_quality * 3) / 4;
     }
@@ -790,6 +789,12 @@
     printf("frame:%d q:%d\n", cm->current_video_frame, q);
   }
 #endif
+  assert(*top_index <= cpi->rc.worst_quality &&
+         *top_index >= cpi->rc.best_quality);
+  assert(*bottom_index <= cpi->rc.worst_quality &&
+         *bottom_index >= cpi->rc.best_quality);
+  assert(q <= cpi->rc.worst_quality &&
+         q >= cpi->rc.best_quality);
   return q;
 }