From cd78f3976ea44797a10486592880511227d31594 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Wed, 23 May 2018 16:59:23 -0400 Subject: 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. --- src/opus_encoder.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') 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;iencoder_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 -- cgit v1.2.3