shithub: opus

Download patch

ref: ee8adbe7015c9dfaa2f66279efdbd63e8e935ce8
parent: a51ebd6831e839551255999f501dbf635c0f1943
author: Jean-Marc Valin <[email protected]>
date: Tue Jan 24 09:45:08 EST 2012

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)

--- a/doc/draft-ietf-codec-opus.xml
+++ b/doc/draft-ietf-codec-opus.xml
@@ -7175,6 +7175,14 @@
 </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>
--- a/silk/dec_API.c
+++ b/silk/dec_API.c
@@ -315,7 +315,12 @@
         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;
--- a/silk/decode_core.c
+++ b/silk/decode_core.c
@@ -72,7 +72,8 @@
             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 ] );
     }
--- a/src/opus_decoder.c
+++ b/src/opus_decoder.c
@@ -923,6 +923,10 @@
 {
    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)