[xiph-commits] r10839 - trunk/theora/lib

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Mon Feb 20 09:26:34 PST 2006


Author: xiphmont
Date: 2006-02-20 09:26:32 -0800 (Mon, 20 Feb 2006)
New Revision: 10839

Modified:
   trunk/theora/lib/encoder_toplevel.c
Log:
Correct bug in keyframe decision logic; if keyframe_autop was unset,
the encoder would hapily generate files that disobeyed keyframe
spacing, overflowing the p-frame shift in granulepos.



Modified: trunk/theora/lib/encoder_toplevel.c
===================================================================
--- trunk/theora/lib/encoder_toplevel.c	2006-02-20 13:34:21 UTC (rev 10838)
+++ trunk/theora/lib/encoder_toplevel.c	2006-02-20 17:26:32 UTC (rev 10839)
@@ -720,16 +720,13 @@
                &InterError, &IntraError );
 
     /* decide whether we really should have made this frame a key frame */
-
+    /* forcing out a keyframe if the max interval is up is done at a higher level */
     if( cpi->pb.info.keyframe_auto_p){
-      if( ( ( 2* IntraError < 5 * InterError )
-            && ( KFIndicator >= (ogg_uint32_t)
-                 cpi->pb.info.keyframe_auto_threshold)
-            && ( cpi->LastKeyFrame > cpi->pb.info.keyframe_mindistance)
-            ) ||
-          (cpi->LastKeyFrame >= (ogg_uint32_t)
-           cpi->pb.info.keyframe_frequency_force) ){
-
+      if( ( 2* IntraError < 5 * InterError )
+	  && ( KFIndicator >= (ogg_uint32_t)
+	       cpi->pb.info.keyframe_auto_threshold)
+	  && ( cpi->LastKeyFrame > cpi->pb.info.keyframe_mindistance)
+	  ){
         CompressKeyFrame(cpi);  /* Code a key frame */
         return;
       }
@@ -968,12 +965,22 @@
     CompressFirstFrame(cpi);
     cpi->ThisIsFirstFrame = 0;
     cpi->ThisIsKeyFrame = 0;
-  } else if ( cpi->ThisIsKeyFrame ) {
-    CompressKeyFrame(cpi);
-    cpi->ThisIsKeyFrame = 0;
-  } else  {
-    /* Compress the frame. */
-    CompressFrame( cpi );
+  } else {
+
+    // don't allow generating invalid files that overflow the p-frame
+    // shift, even if keyframe autop is turned off
+    if(cpi->LastKeyFrame >= (ogg_uint32_t)
+       cpi->pb.info.keyframe_frequency_force)
+      cpi->ThisIsKeyFrame = 1;
+    
+    if ( cpi->ThisIsKeyFrame ) {
+      CompressKeyFrame(cpi);
+      cpi->ThisIsKeyFrame = 0;
+    } else  {
+      /* Compress the frame. */
+      CompressFrame( cpi );
+    }
+
   }
 
   /* Update stats variables. */



More information about the commits mailing list