Skip to content
Snippets Groups Projects
Commit b88a3ad3 authored by Mark Harris's avatar Mark Harris Committed by Jean-Marc Valin
Browse files

Fix 40/60ms zero-length frame decode failure


Decoding failed with OPUS_BAD_ARG on a packet containing a 40ms or
60ms zero-length frame when it followed a hybrid or MDCT frame.
It now invokes the PLC for the duration of the packet as expected.

Signed-off-by: default avatarJean-Marc Valin <jmvalin@jmvalin.ca>
parent dbc83d31
No related branches found
No related tags found
No related merge requests found
......@@ -257,23 +257,33 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data,
ec_dec_init(&dec,(unsigned char*)data,len);
} else {
audiosize = frame_size;
mode = st->prev_mode;
if (st->prev_mode == 0)
if (mode == 0)
{
/* If we haven't got any packet yet, all we can do is return zeros */
for (i=0;i<audiosize*st->channels;i++)
pcm[i] = 0;
RESTORE_STACK;
return audiosize;
} else {
mode = st->prev_mode;
}
}
/* For CELT/hybrid PLC of more than 20 ms, opus_decode_native() will do
multiple calls */
if (data==NULL && mode != MODE_SILK_ONLY)
frame_size = IMIN(frame_size, F20);
if (mode != MODE_SILK_ONLY && audiosize > F20)
{
do {
int ret = opus_decode_frame(st, NULL, 0, pcm, IMIN(audiosize, F20), 0);
if (ret<0)
{
RESTORE_STACK;
return ret;
}
pcm += ret*st->channels;
audiosize -= ret;
} while (audiosize > 0);
RESTORE_STACK;
return frame_size;
}
}
pcm_transition_silk_size = 0;
pcm_transition_celt_size = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment