Fixes another minor bug introduced in 43a0de4af15
authorKoen Vos <koen.vos@skype.net>
Wed, 26 Oct 2011 12:03:31 +0000 (08:03 -0400)
committerJean-Marc Valin <jmvalin@jmvalin.ca>
Wed, 26 Oct 2011 12:03:31 +0000 (08:03 -0400)
silk/fixed/encode_frame_FIX.c
silk/float/encode_frame_FLP.c

index 34a480c..1f27131 100644 (file)
@@ -199,6 +199,15 @@ TOC(NSQ)
             } else if( gainsID == gainsID_upper ) {
                 nBits = nBits_upper;
             } else {
+                /* Restore part of the input state */
+                if( iter > 0 ) {
+                    silk_memcpy( psRangeEnc, &sRangeEnc_copy, sizeof( ec_enc ) );
+                    silk_memcpy( &psEnc->sCmn.sNSQ, &sNSQ_copy, sizeof( silk_nsq_state ) );
+                    psEnc->sCmn.indices.Seed = seed_copy;
+                    psEnc->sCmn.ec_prevLagIndex = ec_prevLagIndex_copy;
+                    psEnc->sCmn.ec_prevSignalType = ec_prevSignalType_copy;
+                }
+
                 /*****************************************/
                 /* Noise shaping quantization            */
                 /*****************************************/
@@ -310,13 +319,6 @@ TOC(ENCODE_PULSES)
 
             /* Unique identifier of gains vector */
             gainsID = silk_gains_ID( psEnc->sCmn.indices.GainsIndices, psEnc->sCmn.nb_subfr );
-
-            /* Restore part of the input state */
-            silk_memcpy( psRangeEnc, &sRangeEnc_copy, sizeof( ec_enc ) );
-            silk_memcpy( &psEnc->sCmn.sNSQ, &sNSQ_copy, sizeof( silk_nsq_state ) );
-            psEnc->sCmn.indices.Seed = seed_copy;
-            psEnc->sCmn.ec_prevLagIndex = ec_prevLagIndex_copy;
-            psEnc->sCmn.ec_prevSignalType = ec_prevSignalType_copy;
         }
     }
 
index 635b964..717b1e0 100644 (file)
@@ -201,6 +201,15 @@ TOC(NSQ)
             } else if( gainsID == gainsID_upper ) {
                 nBits = nBits_upper;
             } else {
+                /* Restore part of the input state */
+                if( iter > 0 ) {
+                    silk_memcpy( psRangeEnc, &sRangeEnc_copy, sizeof( ec_enc ) );
+                    silk_memcpy( &psEnc->sCmn.sNSQ, &sNSQ_copy, sizeof( silk_nsq_state ) );
+                    psEnc->sCmn.indices.Seed = seed_copy;
+                    psEnc->sCmn.ec_prevLagIndex = ec_prevLagIndex_copy;
+                    psEnc->sCmn.ec_prevSignalType = ec_prevSignalType_copy;
+                }
+
                 /*****************************************/
                 /* Noise shaping quantization            */
                 /*****************************************/
@@ -309,13 +318,6 @@ TOC(ENCODE_PULSES)
             for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) {
                 sEncCtrl.Gains[ i ] = pGains_Q16[ i ] / 65536.0f;
             }
-
-            /* Restore part of the input state */
-            silk_memcpy( psRangeEnc, &sRangeEnc_copy, sizeof( ec_enc ) );
-            silk_memcpy( &psEnc->sCmn.sNSQ, &sNSQ_copy, sizeof( silk_nsq_state ) );
-            psEnc->sCmn.indices.Seed = seed_copy;
-            psEnc->sCmn.ec_prevLagIndex = ec_prevLagIndex_copy;
-            psEnc->sCmn.ec_prevSignalType = ec_prevSignalType_copy;
         }
     }