diff options
author | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2018-05-23 16:59:23 -0400 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2018-05-24 02:29:11 -0400 |
commit | cd78f3976ea44797a10486592880511227d31594 (patch) | |
tree | aad956862b87d31e34b39bfe83a73b549af88a7c /src | |
parent | 85ce87ffbe8b30247f62bf2868d28ef75468aec9 (diff) | |
download | libopus-cd78f3976ea44797a10486592880511227d31594.tar.gz |
Fixes a SILK bandwidth switching regression
The bug was triggered because f982b84d started using prefill for
SILK bandwidth changes, which reinitialized the encoder state and
prevented the variable lowpass from working properly. To fix the problem,
we preserve the sampling rate and variable low-pass when prefilling.
Diffstat (limited to 'src')
-rw-r--r-- | src/opus_encoder.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/opus_encoder.c b/src/opus_encoder.c index 0be65a3d..e6cca901 100644 --- a/src/opus_encoder.c +++ b/src/opus_encoder.c @@ -1599,7 +1599,8 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ redundancy = 1; celt_to_silk = 1; st->silk_bw_switch = 0; - prefill=1; + /* Do a prefill without reseting the sampling rate control. */ + prefill=2; } /* If we decided to go with CELT, make sure redundancy is off, no matter what @@ -1825,7 +1826,9 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_ for (i=0;i<st->encoder_buffer*st->channels;i++) pcm_silk[i] = FLOAT2INT16(st->delay_buffer[i]); #endif - silk_Encode( silk_enc, &st->silk_mode, pcm_silk, st->encoder_buffer, NULL, &zero, 1, activity ); + silk_Encode( silk_enc, &st->silk_mode, pcm_silk, st->encoder_buffer, NULL, &zero, prefill, activity ); + /* Prevent a second switch in the real encode call. */ + st->silk_mode.opusCanSwitch = 0; } #ifdef FIXED_POINT |