[xiph-cvs] cvs commit: vorbis/lib bitrate.c

Monty xiphmont at xiph.org
Tue Dec 30 05:17:25 PST 2003



xiphmont    03/12/30 08:17:24

  Modified:    lib      bitrate.c
  Log:
  Kill off small padding bug for super-small bitreservoir sizes.  It's
  now accurate to the byte.
  
  Monty

Revision  Changes    Path
1.23      +16 -16    vorbis/lib/bitrate.c

Index: bitrate.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/bitrate.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- bitrate.c	30 Dec 2003 11:02:22 -0000	1.22
+++ bitrate.c	30 Dec 2003 13:17:20 -0000	1.23
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: bitrate tracking and management
- last mod: $Id: bitrate.c,v 1.22 2003/12/30 11:02:22 xiphmont Exp $
+ last mod: $Id: bitrate.c,v 1.23 2003/12/30 13:17:20 xiphmont Exp $
 
  ********************************************************************/
 
@@ -157,31 +157,31 @@
   /* Choice of packetblobs now made based on floater, and min/max
      requirements. Now boundary check extreme choices */
 
-  if(choice>=PACKETBLOBS){
-    /* choosing a larger packetblob is insufficient to prop up bitrate.
-       pad this frame out with zeroes */
-    long minsize=(min_target_bits-bm->minmax_reservoir+7)/8;
-    bm->choice=choice=PACKETBLOBS-1;
-
-    minsize-=oggpack_bytes(vbi->packetblob[choice]);
-
-    while(minsize--)oggpack_write(vbi->packetblob[choice],0,8);
-    this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
-
-  }else if(choice<0){
+  if(choice<0){
     /* choosing a smaller packetblob is insufficient to trim bitrate.
        frame will need to be truncated */
     long maxsize=(max_target_bits+(bi->reservoir_bits-bm->minmax_reservoir))/8;
     bm->choice=choice=0;
-
+    
     if(oggpack_bytes(vbi->packetblob[choice])>maxsize){
-
+      
       oggpack_writetrunc(vbi->packetblob[choice],maxsize*8);
       this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
     }
-  }else
+  }else{
+    long minsize=(min_target_bits-bm->minmax_reservoir+7)/8;
+    if(choice>=PACKETBLOBS)
+      choice=PACKETBLOBS-1;
+
     bm->choice=choice;
 
+    /* prop up bitrate according to demand. pad this frame out with zeroes */
+    minsize-=oggpack_bytes(vbi->packetblob[choice]);
+    while(minsize-->0)oggpack_write(vbi->packetblob[choice],0,8);
+    this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
+
+  }
+
   /* now we have the final packet and the final packet size.  Update statistics */
   /* min and max reservoir */
   if(bm->min_bitsper>0 || bm->max_bitsper>0){

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list