From ee8adbe7015c9dfaa2f66279efdbd63e8e935ce8 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin <jmvalin@jmvalin.ca> Date: Tue, 24 Jan 2012 14:45:08 +1300 Subject: [PATCH] Fixes a few minor issues (no bit-stream change) - Safer gain clamping for PLC - Makes opus_decoder_get_nb_samples() report an error on invalid ToC - Giving a free license to the text ofthe draft (not just the code) --- doc/draft-ietf-codec-opus.xml | 8 ++++++++ silk/dec_API.c | 7 ++++++- silk/decode_core.c | 3 ++- src/opus_decoder.c | 4 ++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/doc/draft-ietf-codec-opus.xml b/doc/draft-ietf-codec-opus.xml index 4524c3e5e..a6739a1bd 100644 --- a/doc/draft-ietf-codec-opus.xml +++ b/doc/draft-ietf-codec-opus.xml @@ -7175,6 +7175,14 @@ for their bug reports and feedback. </t> </section> +<section title="Copying Conditions"> +<t>The authors agree to grant third parties the irrevocable right to copy, use and distribute +the work (excluding Code Components available under the simplified BSD license), with or +without modification, in any medium, without royalty, provided that, unless separate +permission is granted, redistributed modified works do not contain misleading author, version, +name of work, or endorsement information.</t> +</section> + </middle> <back> diff --git a/silk/dec_API.c b/silk/dec_API.c index c456a6d49..a0b841ce6 100644 --- a/silk/dec_API.c +++ b/silk/dec_API.c @@ -315,7 +315,12 @@ opus_int silk_Decode( /* O Returns error co decControl->prevPitchLag = 0; } - if( lostFlag != FLAG_PACKET_LOST ) { + if( lostFlag == FLAG_PACKET_LOST ) { + /* On packet loss, remove the gain clamping to prevent having the energy "bounce back" + if we lose packets when the energy is going down */ + for ( i = 0; i < psDec->nChannelsInternal; i++ ) + psDec->channel_state[ i ].LastGainIndex = 10; + } else { psDec->prev_decode_only_middle = decode_only_middle; } return ret; diff --git a/silk/decode_core.c b/silk/decode_core.c index 7f90e03be..9854ccc78 100644 --- a/silk/decode_core.c +++ b/silk/decode_core.c @@ -72,7 +72,8 @@ void silk_decode_core( psDec->exc_Q14[ i ] += QUANT_LEVEL_ADJUST_Q10 << 4; } psDec->exc_Q14[ i ] += offset_Q10 << 4; - psDec->exc_Q14[ i ] ^= silk_RSHIFT( rand_seed, 31 ); + if ( rand_seed < 0 ) + psDec->exc_Q14[ i ] = -psDec->exc_Q14[ i ]; rand_seed = silk_ADD32_ovflw( rand_seed, pulses[ i ] ); } diff --git a/src/opus_decoder.c b/src/opus_decoder.c index 97e3e9689..ab79f4277 100644 --- a/src/opus_decoder.c +++ b/src/opus_decoder.c @@ -923,6 +923,10 @@ int opus_decoder_get_nb_samples(const OpusDecoder *dec, { int samples; int count = opus_packet_get_nb_frames(packet, len); + + if (count<0) + return count; + samples = count*opus_packet_get_samples_per_frame(packet, dec->Fs); /* Can't have more than 120 ms */ if (samples*25 > dec->Fs*3) -- GitLab