Interface for bandwidth switching
[opus.git] / src_common / SKP_Silk_control_audio_bandwidth.c
index 0e454c3..b2d0e04 100644 (file)
@@ -50,7 +50,11 @@ SKP_int SKP_Silk_control_audio_bandwidth(
         fs_kHz = SKP_DIV32_16( fs_Hz, 1000 );\r
     } else {\r
         /* State machine for the internal sampling rate switching */\r
-        if( psEncC->API_fs_Hz > 8000 && psEncC->prevSignalType == TYPE_NO_VOICE_ACTIVITY ) {\r
+        if( psEncC->sLP.transition_frame_no >= TRANSITION_FRAMES ) {\r
+            /* Stop transition phase */\r
+            psEncC->sLP.mode = 0;\r
+        }\r
+        if( psEncC->allow_bandwidth_switch ) {\r
             /* Check if we should switch down */\r
             if( SKP_SMULBB( psEncC->fs_kHz, 1000 ) > psEncC->desiredInternal_fs_Hz ) \r
             {\r
@@ -84,14 +88,12 @@ SKP_int SKP_Silk_control_audio_bandwidth(
 \r
                     /* New transition */\r
                     psEncC->sLP.transition_frame_no = 0;\r
+\r
+                    /* Reset transition filter state */\r
+                    SKP_memset( psEncC->sLP.In_LP_State, 0, sizeof( psEncC->sLP.In_LP_State ) );\r
                 } \r
-                if( psEncC->sLP.transition_frame_no >= TRANSITION_FRAMES ) {\r
-                    /* Stop transition phase */\r
-                    psEncC->sLP.mode = 0;\r
-                } else {\r
-                    /* Direction: up */\r
-                    psEncC->sLP.mode = 1;\r
-                }\r
+                /* Direction: up */\r
+                psEncC->sLP.mode = 1;\r
             }\r
         }\r
     }\r