From a81e6dc2bc337c25156e6e908e45cbf7a5e0f104 Mon Sep 17 00:00:00 2001
From: Koen Vos <koen.vos@skype.net>
Date: Thu, 3 Feb 2011 09:08:25 -0500
Subject: [PATCH] Minor bugfix

---
 src_common/SKP_Silk_create_init_destroy.c |  4 ----
 src_common/SKP_Silk_decoder_set_fs.c      | 10 ++++++----
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/src_common/SKP_Silk_create_init_destroy.c b/src_common/SKP_Silk_create_init_destroy.c
index 657759570..93cdaf730 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 41f7f7e57..b8df6811f 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;
-- 
GitLab