[Speex-dev] More frames in one packet

Steve Checkoway s at pahtak.org
Tue Jul 26 17:35:56 PDT 2011


On Tue, Jul 26, 2011 at 11:39:34PM +0200, Peter Soxberger wrote:
> 1) The documentation has a mistake: The bit terminator is NOT set
> automatically! (I'm using the latest speex version!) It has to be
> set manually using speex_bits_insert_terminator(&bits);

The documentation is old and incomplete. However, the implementation
of speex_bits_write() inserts the terminator, but does not update the
pointers or the number of bits:

/* Insert terminator, but save the data so we can put it back after */
bitPtr=bits->bitPtr;
charPtr=bits->charPtr;
nbBits=bits->nbBits;
speex_bits_insert_terminator(bits);
bits->bitPtr=bitPtr;
bits->charPtr=charPtr;
bits->nbBits=nbBits;

> 2) speex_decoder_int() has to be called as long, as it returns -1.
> After that, all frames should be decoded. This should be added to
> the docu!

There was code that was posted to the list that computed the number of
in a SpeexBits. It was never included into the main code for some
reason, but it's easy enough to modify it to work outside. Or you can
just call speex_decoder_int() _until_ it returns -1, not as long as it
returns -1.

> Bugreport: I tried using speex_bits_remaining() instead of checking
> the return value of speex_decoder_int() but this leads to an endless
> loop! Or can't this function be used in this case?

Were there fewer than 5 bits left? It looks like the terminator should
be 01111 and it should be removed by the two calls
speex_bits_unpack_unsigned(bits, 1) 
speex_bits_unpack_unsigned(bits, 4)
in speex_decode_int().

However, if there are fewer than 5 bits remaining, it will just return
-1.

-- 
Steve Checkoway




More information about the Speex-dev mailing list