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

giles at svn.xiph.org giles at svn.xiph.org
Fri May 26 13:59:40 PDT 2006


Author: giles
Date: 2006-05-26 13:59:40 -0700 (Fri, 26 May 2006)
New Revision: 11434

Modified:
   trunk/theora/lib/encoder_toplevel.c
Log:
Clamp the target_bitrate field to the range of the unsigned 24 bit 
integer field in the info header. Fixes #808.


Modified: trunk/theora/lib/encoder_toplevel.c
===================================================================
--- trunk/theora/lib/encoder_toplevel.c	2006-05-26 20:45:26 UTC (rev 11433)
+++ trunk/theora/lib/encoder_toplevel.c	2006-05-26 20:59:40 UTC (rev 11434)
@@ -792,6 +792,9 @@
   /* Initialise Configuration structure to legal values */
   if(c->quality>63)c->quality=63;
   if(c->quality<0)c->quality=32;
+  if(c->target_bitrate<0)c->target_bitrate=0;
+  /* we clamp target_bitrate to 24 bits after setting up the encoder */
+
   cpi->Configuration.BaseQ = c->quality;
   cpi->Configuration.FirstFrameQ = c->quality;
   cpi->Configuration.MaxQ = c->quality;
@@ -833,6 +836,10 @@
     c->keyframe_mindistance=c->keyframe_frequency_force;
   cpi->pb.keyframe_granule_shift=_ilog(c->keyframe_frequency_force-1);
 
+  /* clamp the target_bitrate to a maximum of 24 bits so we get a
+     more meaningful value when we write this out in the header. */
+  if(c->target_bitrate>(1<<24)-1)c->target_bitrate=(1<<24)-1;
+
   /* copy in config */
   memcpy(&cpi->pb.info,c,sizeof(*c));
   th->i=&cpi->pb.info;



More information about the commits mailing list