Commit 599da3ce authored by jm's avatar jm
Browse files

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.

git-svn-id: 0101bb08-14d6-0310-b084-bc0e0c8e3800
parent db7b2437
......@@ -170,7 +170,8 @@ int speex_bits_write(SpeexBits *bits, char *chars, int max_nbytes)
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 */
......@@ -187,6 +188,7 @@ int speex_bits_write(SpeexBits *bits, char *chars, int max_nbytes)
#define HTOLS(A) ((((A) >> 8)&0xff)|(((A) & 0xff)<<8))
printf ("%d %d %d %d\n", bits->bitPtr, bits->charPtr, bits->nbBits, max_nchars);
for (i=0;i<max_nchars;i++)
return max_nchars*BYTES_PER_CHAR;
......@@ -352,8 +354,8 @@ int speex_bits_nbytes(SpeexBits *bits)
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);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment