shithub: opus

Download patch

ref: 78291b270ab9d253049018c6e280b68ab6f50b85
parent: 207a2e8627ad371b4d1e7bc4d3a39fe97ef2999c
author: Jean-Marc Valin <[email protected]>
date: Sat Oct 8 18:12:31 EDT 2011

Fixes a redundancy mismatch bug

When SILK decided not to use the desired bandwidth, the redundancy
could be encoded at the desired bandwidth rather than at the actual
bandwidth used.

--- a/src/opus_encoder.c
+++ b/src/opus_encoder.c
@@ -219,7 +219,7 @@
     return OPUS_OK;
 }
 
-static unsigned char gen_toc(int mode, int framerate, int bandwidth, int silk_bandwidth, int channels)
+static unsigned char gen_toc(int mode, int framerate, int bandwidth, int channels)
 {
    int period;
    unsigned char toc;
@@ -231,7 +231,7 @@
    }
    if (mode == MODE_SILK_ONLY)
    {
-       toc = (silk_bandwidth-OPUS_BANDWIDTH_NARROWBAND)<<5;
+       toc = (bandwidth-OPUS_BANDWIDTH_NARROWBAND)<<5;
        toc |= (period-2)<<3;
    } else if (mode == MODE_CELT_ONLY)
    {
@@ -412,7 +412,6 @@
     int ret=0;
     int nBytes;
     ec_enc enc;
-    int silk_internal_bandwidth=-1;
     int bytes_target;
     int prefill=0;
     int start_band = 0;
@@ -803,7 +802,7 @@
         }
         if (nBytes==0)
         {
-           data[-1] = gen_toc(st->mode, st->Fs/frame_size, st->bandwidth, silk_internal_bandwidth, st->stream_channels);
+           data[-1] = gen_toc(st->mode, st->Fs/frame_size, st->bandwidth, st->stream_channels);
            RESTORE_STACK;
            return 1;
         }
@@ -810,11 +809,11 @@
         /* Extract SILK internal bandwidth for signaling in first byte */
         if( st->mode == MODE_SILK_ONLY ) {
             if( st->silk_mode.internalSampleRate == 8000 ) {
-                silk_internal_bandwidth = OPUS_BANDWIDTH_NARROWBAND;
+               st->bandwidth = OPUS_BANDWIDTH_NARROWBAND;
             } else if( st->silk_mode.internalSampleRate == 12000 ) {
-                silk_internal_bandwidth = OPUS_BANDWIDTH_MEDIUMBAND;
+               st->bandwidth = OPUS_BANDWIDTH_MEDIUMBAND;
             } else if( st->silk_mode.internalSampleRate == 16000 ) {
-                silk_internal_bandwidth = OPUS_BANDWIDTH_WIDEBAND;
+               st->bandwidth = OPUS_BANDWIDTH_WIDEBAND;
             }
         } else {
             silk_assert( st->silk_mode.internalSampleRate == 16000 );
@@ -1003,7 +1002,7 @@
 
     /* Signalling the mode in the first byte */
     data--;
-    data[0] = gen_toc(st->mode, st->Fs/frame_size, st->bandwidth, silk_internal_bandwidth, st->stream_channels);
+    data[0] = gen_toc(st->mode, st->Fs/frame_size, st->bandwidth, st->stream_channels);
 
     st->rangeFinal = enc.rng ^ redundant_rng;