[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."

Hi,
reading more careful the speex_decode() help (
http://www.speex.org/docs/api/speex-api-reference/group__Codec.html#g0ac60440b73e560fcfbca4f9e497d993
), 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_reset(&spx_bits_);
  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 )
      break;
    nbBytes = speex_bits_remaining(&spx_bits_);
    // Save the speex frame into the buffer
    DecOutBuffer_.Write(spx_dec_frame_, spx_frame_size_);
  }
}

Daniele.


More information about the Speex-dev mailing list