[Theora-dev] Patch that fixes distortions during static scenes

Aaron Colwell acolwell at real.com
Wed Mar 2 09:19:07 PST 2005


Here is a patch that fixes distortions that appear during scenes with no 
motion. Tbe problem was that UpdateFrame() was not being called when a 
MotionScore of 0 was computed. Since UpdateFrame() was not called the buffer
returned by theora_encode_packetout() would be the same buffer that was output
for the last frame that had a non-zero MotionScore. This is obviously incorrect
behavior. I've just moved the UpdateFrame() out of the (MotionScore > 0) 
conditional block. 

I've also included my change that prevents the encoder from spending WAY to
many bits on keyframes. This helps prevent the artifact where the video 
suddenly gets very clear when keyframes occur but gets progressively blurry
for interframes. This change helps minimize some of the drastic Q changes
that cause this artifact.

Aaron

Index: encoder_toplevel.c
===================================================================
--- encoder_toplevel.c	(revision 9007)
+++ encoder_toplevel.c	(working copy)
@@ -739,12 +739,12 @@
     /* Increment the frames since last key frame count */
     cpi->LastKeyFrame++;
 
+    /* Proceed with the frame update. */
+    UpdateFrame(cpi);
+    
     if ( cpi->MotionScore > 0 ){
       cpi->DropCount = 0;
 
-      /* Proceed with the frame update. */
-      UpdateFrame(cpi);
-
       /* Note the Quantizer used for each block coded. */
       for ( i = 0; i < cpi->pb.UnitFragments; i++ ){
         if ( cpi->pb.display_fragments[i] ){
@@ -862,8 +862,8 @@
 
   /* Set key frame data rate target; this is nominal keyframe size */
   cpi->Configuration.KeyFrameDataTarget = (c->keyframe_data_target_bitrate *
-                                           c->fps_numerator /
-                                           c->fps_denominator ) / 8;
+                                           c->fps_denominator /
+                                           c->fps_numerator ) / 8;
 
   /* Note the height and width in the pre-processor control structure. */
   cpi->ScanConfig.VideoFrameHeight = cpi->pb.info.height;


More information about the Theora-dev mailing list