shithub: opus

Download patch

ref: a93f501cfa9848ac37dcbf9618c5e6ee039d1059
parent: e2a09db92b5e9de9375100fe639d032b1edced54
author: Jean-Marc Valin <[email protected]>
date: Thu Mar 3 10:50:08 EST 2011

Fix PLC-based mode transition code.

--- a/src/opus_decoder.c
+++ b/src/opus_decoder.c
@@ -84,7 +84,7 @@
     int mode;
     int transition=0;
     int start_band;
-    int redundancy;
+    int redundancy=0;
 
     /* Payloads of 1 (2 including ToC) or 0 trigger the PLC/DTX */
     if (len<=2)
@@ -189,7 +189,7 @@
     }
 
     start_band = 0;
-    if (mode == MODE_HYBRID)
+    if (mode == MODE_HYBRID && data != NULL)
     {
         /* Check if we have a redundant 0-8 kHz band */
         redundancy = ec_dec_bit_logp(&dec, 12);
@@ -196,13 +196,15 @@
         if (!redundancy)
             start_band = 17;
     }
-    celt_decoder_ctl(st->celt_dec, CELT_SET_START_BAND(start_band));
-
     if (redundancy)
         transition = 0;
 
     if (transition && mode != MODE_CELT_ONLY)
         opus_decode(st, NULL, 0, pcm_transition, IMAX(480, audiosize), 0);
+
+    /* MUST be after PLC */
+    celt_decoder_ctl(st->celt_dec, CELT_SET_START_BAND(start_band));
+
 
     if (mode != MODE_SILK_ONLY)
     {
--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -157,7 +157,10 @@
         /* Call SILK encoder for the low band */
         nBytes = max_data_bytes-1;
         if (prefill)
-        	SKP_Silk_SDK_Encode( st->silk_enc, &st->silk_mode, st->delay_buffer, ENCODER_BUFFER, NULL, 0, 1 );
+        {
+            int zero=0;
+        	SKP_Silk_SDK_Encode( st->silk_enc, &st->silk_mode, st->delay_buffer, ENCODER_BUFFER, NULL, &zero, 1 );
+        }
 
         ret = SKP_Silk_SDK_Encode( st->silk_enc, &st->silk_mode, pcm, frame_size, &enc, &nBytes, 0 );
         if( ret ) {