[xiph-commits] r10399 - trunk/speex/libspeex

jm at svn.xiph.org jm at svn.xiph.org
Fri Nov 18 01:15:30 PST 2005


Author: jm
Date: 2005-11-18 01:15:27 -0800 (Fri, 18 Nov 2005)
New Revision: 10399

Modified:
   trunk/speex/libspeex/bits.c
Log:
Fixed a brown-paper-bag bug in speex_bits_insert_terminator() that sometime had
the last bit wrong or inserted a useless bit at the end.


Modified: trunk/speex/libspeex/bits.c
===================================================================
--- trunk/speex/libspeex/bits.c	2005-11-18 08:49:50 UTC (rev 10398)
+++ trunk/speex/libspeex/bits.c	2005-11-18 09:15:27 UTC (rev 10399)
@@ -170,7 +170,8 @@
    int i;
    int max_nchars = max_nbytes/BYTES_PER_CHAR;
    int charPtr, bitPtr, nbBits;
-   
+   printf ("%d %d %d\n", bits->bitPtr, bits->charPtr, bits->nbBits);
+
    /* Insert terminator, but save the data so we can put it back after */
    bitPtr=bits->bitPtr;
    charPtr=bits->charPtr;
@@ -187,6 +188,7 @@
 #else
 #define HTOLS(A) ((((A) >> 8)&0xff)|(((A) & 0xff)<<8))
 #endif
+   printf ("%d %d %d %d\n", bits->bitPtr, bits->charPtr, bits->nbBits, max_nchars);
    for (i=0;i<max_nchars;i++)
       chars[i]=HTOLS(bits->chars[i]);
    return max_nchars*BYTES_PER_CHAR;
@@ -352,8 +354,8 @@
 
 void speex_bits_insert_terminator(SpeexBits *bits)
 {
-   if (bits->bitPtr<BITS_PER_CHAR-1)
+   if (bits->bitPtr)
       speex_bits_pack(bits, 0, 1);
-   while (bits->bitPtr<BITS_PER_CHAR-1)
+   while (bits->bitPtr)
       speex_bits_pack(bits, 1, 1);
 }



More information about the commits mailing list