mirror of
https://github.com/xiph/opus.git
synced 2025-05-17 17:08:29 +00:00
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.
This commit is contained in:
parent
207a2e8627
commit
78291b270a
1 changed files with 7 additions and 8 deletions
|
@ -219,7 +219,7 @@ int opus_encoder_init(OpusEncoder* st, opus_int32 Fs, int channels, int applicat
|
||||||
return OPUS_OK;
|
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;
|
int period;
|
||||||
unsigned char toc;
|
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)
|
if (mode == MODE_SILK_ONLY)
|
||||||
{
|
{
|
||||||
toc = (silk_bandwidth-OPUS_BANDWIDTH_NARROWBAND)<<5;
|
toc = (bandwidth-OPUS_BANDWIDTH_NARROWBAND)<<5;
|
||||||
toc |= (period-2)<<3;
|
toc |= (period-2)<<3;
|
||||||
} else if (mode == MODE_CELT_ONLY)
|
} 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 ret=0;
|
||||||
int nBytes;
|
int nBytes;
|
||||||
ec_enc enc;
|
ec_enc enc;
|
||||||
int silk_internal_bandwidth=-1;
|
|
||||||
int bytes_target;
|
int bytes_target;
|
||||||
int prefill=0;
|
int prefill=0;
|
||||||
int start_band = 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)
|
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;
|
RESTORE_STACK;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/* Extract SILK internal bandwidth for signaling in first byte */
|
/* Extract SILK internal bandwidth for signaling in first byte */
|
||||||
if( st->mode == MODE_SILK_ONLY ) {
|
if( st->mode == MODE_SILK_ONLY ) {
|
||||||
if( st->silk_mode.internalSampleRate == 8000 ) {
|
if( st->silk_mode.internalSampleRate == 8000 ) {
|
||||||
silk_internal_bandwidth = OPUS_BANDWIDTH_NARROWBAND;
|
st->bandwidth = OPUS_BANDWIDTH_NARROWBAND;
|
||||||
} else if( st->silk_mode.internalSampleRate == 12000 ) {
|
} 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 ) {
|
} else if( st->silk_mode.internalSampleRate == 16000 ) {
|
||||||
silk_internal_bandwidth = OPUS_BANDWIDTH_WIDEBAND;
|
st->bandwidth = OPUS_BANDWIDTH_WIDEBAND;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
silk_assert( st->silk_mode.internalSampleRate == 16000 );
|
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 */
|
/* Signalling the mode in the first byte */
|
||||||
data--;
|
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;
|
st->rangeFinal = enc.rng ^ redundant_rng;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue