[Speex-dev] Decoded output buffer size

Daniele Barzotti daniele.barzotti at eurocomtel.com
Thu Apr 15 02:35:07 PDT 2010

Il 15/04/2010 11:17, Conrad Parker wrote:
> but the number of frames in a packet is up to your application. 
>   "The Speex decoder [SPEEX] can detect the bit-rate from the payload
>    and is responsible for detecting the 20 msec boundaries between each
>    frame."

reading more careful the speex_decode() help (
), it should be enough to test the return value: 0 for no error, -1 for
end of stream, -2 corrupt stream.

UINT DecodePayload( char* payload, UINT payload_len )
  speex_bits_read_from(&spx_bits_, payload, payload_len);
  UINT nbBytes = speex_bits_remaining(&spx_bits_);

  while (nbBytes>0)
    if ( speex_decode(spx_state_, &spx_bits_, spx_dec_frame_) != 0 )
    nbBytes = speex_bits_remaining(&spx_bits_);
    // Save the speex frame into the buffer
    DecOutBuffer_.Write(spx_dec_frame_, spx_frame_size_);


More information about the Speex-dev mailing list