Commit 78291b27 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

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.
parent 207a2e86
......@@ -219,7 +219,7 @@ int opus_encoder_init(OpusEncoder* st, opus_int32 Fs, int channels, int applicat
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 @@ static unsigned char gen_toc(int mode, int framerate, int bandwidth, int silk_ba
}
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 opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_size,
int ret=0;
int nBytes;
ec_enc enc;
int silk_internal_bandwidth=-1;
int bytes_target;
int prefill=0;
int start_band = 0;
......@@ -803,18 +802,18 @@ int opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_size,
}
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;
}
/* 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 @@ int opus_encode_float(OpusEncoder *st, const opus_val16 *pcm, int frame_size,
/* 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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment