Fixes a glitch on SILK frame size switching
authorJean-Marc Valin <jmvalin@jmvalin.ca>
Tue, 27 Sep 2011 21:12:23 +0000 (17:12 -0400)
committerJean-Marc Valin <jmvalin@jmvalin.ca>
Tue, 27 Sep 2011 21:12:23 +0000 (17:12 -0400)
We no longer reset the decoder predictors when switching only the
frame size and not the sampling rate. The encoder already doesn't reset.

silk/decoder_set_fs.c

index 02cdff0..be29a97 100644 (file)
@@ -69,15 +69,18 @@ void silk_decoder_set_fs(
             psDec->psNLSF_CB = &silk_NLSF_CB_WB;
         }
 
-        /* Reset part of the decoder state */
-        silk_memset( psDec->sLPC_Q14,     0,                    sizeof( psDec->sLPC_Q14 ) );
-        silk_memset( psDec->outBuf,       0, MAX_FRAME_LENGTH * sizeof( opus_int16 ) );
-        silk_memset( psDec->prevNLSF_Q15, 0,                    sizeof( psDec->prevNLSF_Q15 ) );
-
+        if( psDec->fs_kHz != fs_kHz)
+        {
+           /* Reset part of the decoder state */
+           silk_memset( psDec->sLPC_Q14,     0,                    sizeof( psDec->sLPC_Q14 ) );
+           silk_memset( psDec->outBuf,       0, MAX_FRAME_LENGTH * sizeof( opus_int16 ) );
+           silk_memset( psDec->prevNLSF_Q15, 0,                    sizeof( psDec->prevNLSF_Q15 ) );
+        }
         psDec->lagPrev                 = 100;
         psDec->LastGainIndex           = 10;
         psDec->prevSignalType          = TYPE_NO_VOICE_ACTIVITY;
-        psDec->first_frame_after_reset = 1;
+        if( psDec->fs_kHz != fs_kHz)
+           psDec->first_frame_after_reset = 1;
 
         if( fs_kHz == 16 ) {
             psDec->pitch_lag_low_bits_iCDF = silk_uniform8_iCDF;