diff --git a/src_common/SKP_Silk_create_init_destroy.c b/src_common/SKP_Silk_create_init_destroy.c index 657759570fa27cfb5fabdcf91c7f55af548e2f57..93cdaf73059018fb76c8008cd56626bf4fd15775 100644 --- a/src_common/SKP_Silk_create_init_destroy.c +++ b/src_common/SKP_Silk_create_init_destroy.c @@ -38,10 +38,6 @@ SKP_int SKP_Silk_init_decoder( /* Clear the entire encoder state, except anything copied */ SKP_memset( psDec, 0, sizeof( SKP_Silk_decoder_state ) ); - /* Set sampling rate to 16 kHz, and init non-zero values */ - psDec->nb_subfr = MAX_NB_SUBFR; - SKP_Silk_decoder_set_fs( psDec, 16 ); - /* Used to deactivate e.g. LSF interpolation and fluctuation reduction */ psDec->first_frame_after_reset = 1; psDec->prev_inv_gain_Q16 = 65536; diff --git a/src_common/SKP_Silk_decoder_set_fs.c b/src_common/SKP_Silk_decoder_set_fs.c index 41f7f7e5720e4902e3744aea584f51d210373bd4..b8df6811fc16e3830d4bdb6c08163725c9700401 100644 --- a/src_common/SKP_Silk_decoder_set_fs.c +++ b/src_common/SKP_Silk_decoder_set_fs.c @@ -33,11 +33,13 @@ void SKP_Silk_decoder_set_fs( SKP_int fs_kHz /* I Sampling frequency (kHz) */ ) { - psDec->frame_length = SKP_SMULBB( psDec->nb_subfr, psDec->subfr_length ); - if( psDec->fs_kHz != fs_kHz ) { + SKP_int frame_length; + + psDec->subfr_length = SKP_SMULBB( SUB_FRAME_LENGTH_MS, fs_kHz ); + frame_length = SKP_SMULBB( psDec->nb_subfr, psDec->subfr_length ); + if( psDec->fs_kHz != fs_kHz || frame_length != psDec->frame_length ) { psDec->fs_kHz = fs_kHz; - psDec->subfr_length = SKP_SMULBB( SUB_FRAME_LENGTH_MS, fs_kHz ); - psDec->frame_length = SKP_SMULBB( psDec->nb_subfr, psDec->subfr_length ); + psDec->frame_length = frame_length; psDec->ltp_mem_length = SKP_SMULBB( LTP_MEM_LENGTH_MS, fs_kHz ); if( psDec->fs_kHz == 8 ) { psDec->LPC_order = MIN_LPC_ORDER;