[opus] WAVE PCM to OPUS and back

Ralph Giles giles at thaumas.net
Thu Oct 25 10:10:58 PDT 2012

On 12-10-25 6:41 AM, Stepan Melnichuk wrote:

>                 opus_int32 dataLength = opus_encode(m_opusEncoder, (short*)Hdr->lpData, 80, data, BUFSIZE);
>                 dataLength = opus_decode(m_opusDecoder, (unsigned char*)data, dataLength, (short*)WaveHdrOut.lpData, BUFSIZE, 0);

What does dataLength end up being here? It looks like you're only
encoding 80 samples, which should be an error. You need to pass in one
of the allowed packet durations' worth of data: e.g. 960 (20ms) would be
a better value.

Also, it looks like you're only encoding those 80 samples and then
leaking the encoder and decoder contexts. You need to loop over all
available audio data and code it, one packet duration at a time, using
the same encoder and decoder for each call.

Hope that helps,

More information about the opus mailing list