diff options
author | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2018-05-23 23:59:23 +0300 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2018-05-24 09:29:11 +0300 |
commit | cd78f3976ea44797a10486592880511227d31594 (patch) | |
tree | aad956862b87d31e34b39bfe83a73b549af88a7c /silk/enc_API.c | |
parent | 85ce87ffbe8b30247f62bf2868d28ef75468aec9 (diff) |
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 'silk/enc_API.c')
-rw-r--r-- | silk/enc_API.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/silk/enc_API.c b/silk/enc_API.c index 7ae31a9e..55a33f37 100644 --- a/silk/enc_API.c +++ b/silk/enc_API.c @@ -200,15 +200,25 @@ opus_int silk_Encode( /* O Returns error co tot_blocks = ( nBlocksOf10ms > 1 ) ? nBlocksOf10ms >> 1 : 1; curr_block = 0; if( prefillFlag ) { + silk_LP_state save_LP; /* Only accept input length of 10 ms */ if( nBlocksOf10ms != 1 ) { celt_assert( 0 ); RESTORE_STACK; return SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES; } + if ( prefillFlag == 2 ) { + save_LP = psEnc->state_Fxx[ 0 ].sCmn.sLP; + /* Save the sampling rate so the bandwidth switching code can keep handling transitions. */ + save_LP.saved_fs_kHz = psEnc->state_Fxx[ 0 ].sCmn.fs_kHz; + } /* Reset Encoder */ for( n = 0; n < encControl->nChannelsInternal; n++ ) { ret = silk_init_encoder( &psEnc->state_Fxx[ n ], psEnc->state_Fxx[ n ].sCmn.arch ); + /* Restore the variable LP state. */ + if ( prefillFlag == 2 ) { + psEnc->state_Fxx[ n ].sCmn.sLP = save_LP; + } celt_assert( !ret ); } tmp_payloadSize_ms = encControl->payloadSize_ms; |