diff --git a/doc/draft-ietf-codec-opus.xml b/doc/draft-ietf-codec-opus.xml
index 4524c3e5..a6739a1b 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.
+
+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.
+
+
diff --git a/silk/dec_API.c b/silk/dec_API.c
index c456a6d4..a0b841ce 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 7f90e03b..9854ccc7 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 97e3e968..ab79f427 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)