ref: b88a3ad39672ffa8ccf5ea73a0bffa1dd76a93aa
parent: dbc83d316c2c221f9790e6162c9942082db8362a
author: Mark Harris <[email protected]>
date: Mon Oct 7 14:50:59 EDT 2013
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: Jean-Marc Valin <[email protected]>
--- a/src/opus_decoder.c
+++ b/src/opus_decoder.c
@@ -257,8 +257,9 @@
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++)
@@ -265,15 +266,24 @@
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;