diff options
author | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2012-11-23 22:50:31 +0400 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2012-11-23 22:50:31 +0400 |
commit | 5bf5b6e7c7d8bee155ae5856aafa57f961c37fa2 (patch) | |
tree | 2716aa7014cc82ad1da3330d709d028e4488f2ff | |
parent | b66697247791c35d731c49473c8dc3a6fb998d48 (diff) |
PLC fixes
We now report an error if the PLC frame size is not a multiple of 2.5 ms
and currectly handles the case of CELT PLC when the size isn't a multiple
of 20 ms.
-rw-r--r-- | src/opus_decoder.c | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/src/opus_decoder.c b/src/opus_decoder.c index 1a828652..02b475ee 100644 --- a/src/opus_decoder.c +++ b/src/opus_decoder.c @@ -263,23 +263,10 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data, } } - /* For CELT/hybrid PLC of more than 20 ms, do multiple calls */ - if (data==NULL && frame_size > F20 && mode != MODE_SILK_ONLY) - { - int nb_samples = 0; - do { - int ret = opus_decode_frame(st, NULL, 0, pcm, F20, 0); - if (ret != F20) - { - RESTORE_STACK; - return OPUS_INTERNAL_ERROR; - } - pcm += F20*st->channels; - nb_samples += F20; - } while (nb_samples < frame_size); - RESTORE_STACK; - return frame_size; - } + /* 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); pcm_transition_silk_size = 0; pcm_transition_celt_size = 0; @@ -748,6 +735,9 @@ int opus_decode_native(OpusDecoder *st, const unsigned char *data, short size[48]; if (decode_fec<0 || decode_fec>1) return OPUS_BAD_ARG; + /* For FEC/PLC, frame_size has to be a multiple of 2.5 ms */ + if ((decode_fec || len==0 || data==NULL) && frame_size%(st->Fs/400)!=0) + return OPUS_BAD_ARG; if (len==0 || data==NULL) { int pcm_count=0; |