shithub: opus

Download patch

ref: fcf95bac9330e8e6db1184496ae33007a7c7a9cf
parent: 0d73d676d76f9bc9eae4d3863e0c43d2c73f943e
author: Koen Vos <[email protected]>
date: Tue Apr 26 20:49:40 EDT 2011

Squashed commit of the following:

commit c44b37355295df2963daa724649ff1876b690488
Author: Jean-Marc Valin <[email protected]>
Date:   Wed Apr 27 00:33:12 2011 -0400

    decoder size fix

commit 78f864e9ddacd94d03d717d79a6e606712e25edd
Author: Jean-Marc Valin <[email protected]>
Date:   Tue Apr 26 23:26:14 2011 -0400

    Makefile fix

commit a0e884e463af88bcaa2f410ea8cc85e5bebd2c3b
Author: Jean-Marc Valin <[email protected]>
Date:   Tue Apr 26 22:53:27 2011 -0400

    Making some progress

commit 9e30457f2199bba7b5e37bb577ff75dc85ba9306
Author: Koen Vos <[email protected]>
Date:   Tue Apr 26 22:29:42 2011 -0400

    SILK update with stereo support

--- a/Makefile.am
+++ b/Makefile.am
@@ -10,9 +10,6 @@
 src_FLP/src_FLP.vcxproj.filters \
 src_common/src_common.vcxproj \
 src_common/src_common.vcxproj.filters \
-test/Encoder.c \
-test/Decoder.c \
-test/signalCompare.c \
 src_SigProc_FLP/src_SigProc_FLP.vcxproj \
 src_SigProc_FLP/src_SigProc_FLP.vcxproj.filters \
 src_SigProc_FIX/src_SigProc_FIX.vcxproj \
@@ -39,7 +36,6 @@
 src_common/SKP_Silk_encode_pulses.c \
 src_common/SKP_Silk_gain_quant.c \
 src_common/SKP_Silk_interpolate.c \
-src_common/SKP_Silk_LBRR_embed.c \
 src_common/SKP_Silk_LP_variable_cutoff.c \
 src_common/SKP_Silk_NLSF2A_stable.c \
 src_common/SKP_Silk_NLSF_decode.c \
@@ -64,6 +60,12 @@
 src_common/SKP_Silk_NLSF_unpack.c \
 src_common/SKP_Silk_NLSF_del_dec_quant.c \
 src_common/SKP_Silk_process_NLSFs.c \
+src_common/SKP_Silk_stereo_LR_to_MS.c \
+src_common/SKP_Silk_stereo_MS_to_LR.c \
+src_common/SKP_Silk_control_SNR.c \
+src_common/SKP_Silk_init_encoder.c \
+src_common/SKP_Silk_control_codec.c \
+src_common/SKP_Silk_check_control_input.c \
 src_SigProc_FIX/SKP_Silk_A2NLSF.c \
 src_SigProc_FIX/SKP_Silk_ana_filt_bank_1.c \
 src_SigProc_FIX/SKP_Silk_apply_sine_window.c \
@@ -149,7 +151,6 @@
 else
 libSKP_SILK_SDK_la_SOURCES += \
 src_FLP/SKP_Silk_apply_sine_window_FLP.c \
-src_FLP/SKP_Silk_control_codec_FLP.c \
 src_FLP/SKP_Silk_corrMatrix_FLP.c \
 src_FLP/SKP_Silk_encode_frame_FLP.c \
 src_FLP/SKP_Silk_find_LPC_FLP.c \
@@ -156,7 +157,6 @@
 src_FLP/SKP_Silk_find_LTP_FLP.c \
 src_FLP/SKP_Silk_find_pitch_lags_FLP.c \
 src_FLP/SKP_Silk_find_pred_coefs_FLP.c \
-src_FLP/SKP_Silk_init_encoder_FLP.c \
 src_FLP/SKP_Silk_LPC_analysis_filter_FLP.c \
 src_FLP/SKP_Silk_LTP_analysis_filter_FLP.c \
 src_FLP/SKP_Silk_LTP_scale_ctrl_FLP.c \
@@ -185,7 +185,6 @@
 src_common/SKP_Silk_structs.h \
 src_common/SKP_Silk_tables.h \
 src_common/SKP_Silk_tuning_parameters.h \
-src_common/SKP_Silk_setup.h \
 src_FIX/SKP_Silk_main_FIX.h \
 src_FIX/SKP_Silk_structs_FIX.h \
 src_FLP/SKP_Silk_assembler_FLP.h \
@@ -201,18 +200,5 @@
 src_SigProc_FIX/SKP_Silk_resampler_structs.h \
 src_SigProc_FIX/SKP_Silk_SigProc_FIX.h \
 src_SigProc_FLP/SKP_Silk_SigProc_FLP.h
-
-bin_PROGRAMS = Encoder Decoder signalCompare
-Encoder_SOURCES = test/Encoder.c $(top_builddir)/interface/SKP_Silk_SDK_API.h
-Encoder_LDADD = $(lib_LTLIBRARIES) 
-Encoder_LDFLAGS = $(LIBS)
-
-Decoder_SOURCES = test/Decoder.c $(top_builddir)/interface/SKP_Silk_SDK_API.h
-Decoder_LDADD = $(lib_LTLIBRARIES) 
-Decoder_LDFLAGS = $(LIBS)
-
-signalCompare_SOURCES = test/signalCompare.c $(top_builddir)/interface/SKP_Silk_SDK_API.h
-signalCompare_LDADD = $(lib_LTLIBRARIES) 
-signalCompare_LDFLAGS = $(LIBS)
 
 LIBS = ../celt/libcelt/libcelt0.la
--- a/interface/SKP_Silk_SDK_API.h
+++ b/interface/SKP_Silk_SDK_API.h
@@ -108,16 +108,6 @@
     void                                *decState       /* I/O: State                                           */
 );
 
-/************************************************************************************************/
-/* Prefill LPC synthesis buffer, HP filter and upsampler. Input must be exactly 10 ms of audio. */
-/************************************************************************************************/
-SKP_int SKP_Silk_SDK_Decoder_prefill_buffers(           /* O:   Returns error code                              */
-    void*                               decState,       /* I/O: State                                           */
-    SKP_SILK_SDK_DecControlStruct*      decControl,     /* I/O: Control Structure                               */
-    const SKP_int16                     *samplesIn,     /* I:   Speech sample input vector  (10 ms)             */
-    SKP_int                             nSamplesIn      /* I:   Number of samples in input vector               */
-);
-
 /******************/
 /* Decode a frame */
 /******************/
@@ -127,7 +117,6 @@
     SKP_int                             lostFlag,       /* I:   0: no loss, 1 loss, 2 decode fec                */
     SKP_int                             newPacketFlag,  /* I:   Indicates first decoder call for this packet    */
     ec_dec                              *psRangeDec,    /* I/O  Compressor data structure                       */
-    const SKP_int                       nBytesIn,       /* I:   Number of input bytes                           */
     SKP_int16                           *samplesOut,    /* O:   Decoded output speech vector                    */
     SKP_int32                           *nSamplesOut    /* O:   Number of samples decoded                       */
 );
--- a/interface/SKP_Silk_control.h
+++ b/interface/SKP_Silk_control.h
@@ -35,10 +35,18 @@
 {
 #endif
 
+/* Decoder API flags */
+#define FLAG_DECODE_NORMAL                      0
+#define FLAG_PACKET_LOST                        1
+#define FLAG_DECODE_LBRR                        2
+
 /***********************************************/
 /* Structure for controlling encoder operation */
 /***********************************************/
 typedef struct {
+    /* I:   Number of channels; 1/2                                                         */
+    SKP_int32 nChannels;
+
     /* I:   Input signal sampling rate in Hertz; 8000/12000/16000/24000/32000/44100/48000   */
     SKP_int32 API_sampleRate;
 
@@ -77,6 +85,9 @@
 /* Structure for controlling decoder operation and reading decoder status */
 /**************************************************************************/
 typedef struct {
+    /* I:   Number of channels; 1/2                                                         */
+    SKP_int32 nChannels;
+
     /* I:   Output signal sampling rate in Hertz; 8000/12000/16000/24000/32000/44100/48000  */
     SKP_int32 API_sampleRate;
 
--- a/interface/SKP_Silk_errors.h
+++ b/interface/SKP_Silk_errors.h
@@ -72,6 +72,9 @@
 /* Internal encoder error */
 #define SKP_SILK_ENC_INTERNAL_ERROR                     -110
 
+/* Internal encoder error */
+#define SKP_SILK_ENC_INVALID_NUMBER_OF_CHANNELS_ERROR   -111
+
 /**************************/
 /* Decoder error messages */
 /**************************/
--- a/src_FIX/SKP_Silk_LTP_scale_ctrl_FIX.c
+++ b/src_FIX/SKP_Silk_LTP_scale_ctrl_FIX.c
@@ -27,15 +27,6 @@
 
 #include "SKP_Silk_main_FIX.h"
 
-#define NB_THRESHOLDS           11
-
-/* Table containing trained thresholds for LTP scaling */
-static const SKP_int16 LTPScaleThresholds_Q15[ NB_THRESHOLDS ] = 
-{
-    31129, 26214, 16384, 13107, 9830, 6554,
-     4915,  3276,  2621,  2458,    0
-};
-
 void SKP_Silk_LTP_scale_ctrl_FIX(
     SKP_Silk_encoder_state_FIX      *psEnc,     /* I/O  encoder state FIX                           */
     SKP_Silk_encoder_control_FIX    *psEncCtrl  /* I/O  encoder control FIX                         */
@@ -42,38 +33,20 @@
 )
 {
     SKP_int round_loss;
-    SKP_int g_out_Q5, g_limit_Q15, thrld1_Q15, thrld2_Q15;
 
     /* 1st order high-pass filter */
-    psEnc->HPLTPredCodGain_Q7 = SKP_max_int( psEncCtrl->LTPredCodGain_Q7 - psEnc->prevLTPredCodGain_Q7, 0 ) 
-        + SKP_RSHIFT_ROUND( psEnc->HPLTPredCodGain_Q7, 1 );
-    
+    psEnc->HPLTPredCodGain_Q7 = SKP_max_int( psEncCtrl->LTPredCodGain_Q7 - SKP_RSHIFT( psEnc->prevLTPredCodGain_Q7, 1 ), 0 ) 
+        + SKP_RSHIFT( psEnc->HPLTPredCodGain_Q7, 1 );
     psEnc->prevLTPredCodGain_Q7 = psEncCtrl->LTPredCodGain_Q7;
 
-    /* combine input and filtered input */
-    g_out_Q5    = SKP_RSHIFT_ROUND( SKP_RSHIFT( psEncCtrl->LTPredCodGain_Q7, 1 ) + SKP_RSHIFT( psEnc->HPLTPredCodGain_Q7, 1 ), 3 );
-    g_limit_Q15 = SKP_Silk_sigm_Q15( g_out_Q5 - ( 3 << 5 ) );
-            
-    /* Default is minimum scaling */
-    psEnc->sCmn.indices.LTP_scaleIndex = 0;
-
-    /* Round the loss measure to whole pct */
-    round_loss = ( SKP_int )psEnc->sCmn.PacketLoss_perc;
-
     /* Only scale if first frame in packet */
     if( psEnc->sCmn.nFramesAnalyzed == 0 ) {
-        
-        round_loss += psEnc->sCmn.nFramesPerPacket - 1;
-        thrld1_Q15 = LTPScaleThresholds_Q15[ SKP_min_int( round_loss,     NB_THRESHOLDS - 1 ) ];
-        thrld2_Q15 = LTPScaleThresholds_Q15[ SKP_min_int( round_loss + 1, NB_THRESHOLDS - 1 ) ];
-    
-        if( g_limit_Q15 > thrld1_Q15 ) {
-            /* Maximum scaling */
-            psEnc->sCmn.indices.LTP_scaleIndex = 2;
-        } else if( g_limit_Q15 > thrld2_Q15 ) {
-            /* Medium scaling */
-            psEnc->sCmn.indices.LTP_scaleIndex = 1;
-        }
+        round_loss = psEnc->sCmn.PacketLoss_perc + psEnc->sCmn.nFramesPerPacket - 1;
+        psEnc->sCmn.indices.LTP_scaleIndex = (SKP_int8)SKP_LIMIT( 
+            SKP_SMULWB( SKP_SMULBB( round_loss, psEnc->HPLTPredCodGain_Q7 ), SKP_FIX_CONST( 0.1, 9 ) ), 0, 2 );
+    } else {
+        /* Default is minimum scaling */
+        psEnc->sCmn.indices.LTP_scaleIndex = 0;
     }
     psEncCtrl->LTP_scale_Q14 = SKP_Silk_LTPScales_table_Q14[ psEnc->sCmn.indices.LTP_scaleIndex ];
 }
--- a/src_FIX/SKP_Silk_control_codec_FIX.c
+++ /dev/null
@@ -1,313 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. 
-Redistribution and use in source and binary forms, with or without 
-modification, (subject to the limitations in the disclaimer below) 
-are permitted provided that the following conditions are met:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright 
-notice, this list of conditions and the following disclaimer in the 
-documentation and/or other materials provided with the distribution.
-- Neither the name of Skype Limited, nor the names of specific 
-contributors, may be used to endorse or promote products derived from 
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-***********************************************************************/
-
-#include "SKP_Silk_main_FIX.h"
-#include "SKP_Silk_setup.h"
-
-SKP_INLINE SKP_int SKP_Silk_setup_resamplers(
-    SKP_Silk_encoder_state_FIX      *psEnc,             /* I/O                      */
-    SKP_int                         fs_kHz              /* I                        */
-);
-
-SKP_INLINE SKP_int SKP_Silk_setup_fs(
-    SKP_Silk_encoder_state_FIX      *psEnc,             /* I/O                      */
-    SKP_int                         fs_kHz,             /* I                        */
-    SKP_int                         PacketSize_ms       /* I                        */
-);
-
-SKP_INLINE SKP_int SKP_Silk_setup_rate(
-    SKP_Silk_encoder_state_FIX      *psEnc,             /* I/O                      */
-    SKP_int32                       TargetRate_bps      /* I                        */
-);
-
-/* Control encoder SNR */
-SKP_int SKP_Silk_control_encoder_FIX( 
-    SKP_Silk_encoder_state_FIX  *psEnc,                 /* I/O  Pointer to Silk encoder state           */
-    const SKP_int               PacketSize_ms,          /* I    Packet length (ms)                      */
-    const SKP_int32             TargetRate_bps,         /* I    Target max bitrate (bps)                */
-    const SKP_int               PacketLoss_perc,        /* I    Packet loss rate (in percent)           */
-    const SKP_int               Complexity              /* I    Complexity (0-10)                       */
-)
-{
-    SKP_int   fs_kHz, ret = 0;
-
-    if( psEnc->sCmn.controlled_since_last_payload != 0 && psEnc->sCmn.prefillFlag == 0 ) {
-        if( psEnc->sCmn.API_fs_Hz != psEnc->sCmn.prev_API_fs_Hz && psEnc->sCmn.fs_kHz > 0 ) {
-            /* Change in API sampling rate in the middle of encoding a packet */
-            ret += SKP_Silk_setup_resamplers( psEnc, psEnc->sCmn.fs_kHz );
-        }
-        return ret;
-    }
-
-    /* Beyond this point we know that there are no previously coded frames in the payload buffer */
-
-    /********************************************/
-    /* Determine internal sampling rate         */
-    /********************************************/
-    fs_kHz = SKP_Silk_control_audio_bandwidth( &psEnc->sCmn, TargetRate_bps );
-
-    /********************************************/
-    /* Prepare resampler and buffered data      */
-    /********************************************/
-    ret += SKP_Silk_setup_resamplers( psEnc, fs_kHz );
-
-    /********************************************/
-    /* Set internal sampling frequency          */
-    /********************************************/
-    ret += SKP_Silk_setup_fs( psEnc, fs_kHz, PacketSize_ms );
-
-    /********************************************/
-    /* Set encoding complexity                  */
-    /********************************************/
-    ret += SKP_Silk_setup_complexity( &psEnc->sCmn, Complexity );
-
-    /********************************************/
-    /* Set bitrate/coding quality               */
-    /********************************************/
-    ret += SKP_Silk_setup_rate( psEnc, TargetRate_bps );
-
-    /********************************************/
-    /* Set packet loss rate measured by farend  */
-    /********************************************/
-    if( ( PacketLoss_perc < 0 ) || ( PacketLoss_perc > 100 ) ) {
-        ret = SKP_SILK_ENC_INVALID_LOSS_RATE;
-    }
-    psEnc->sCmn.PacketLoss_perc = PacketLoss_perc;
-
-    /********************************************/
-    /* Set LBRR usage                           */
-    /********************************************/
-    ret += SKP_Silk_setup_LBRR( &psEnc->sCmn );
-
-    psEnc->sCmn.controlled_since_last_payload = 1;
-
-    return ret;
-}
-
-SKP_INLINE SKP_int SKP_Silk_setup_resamplers(
-    SKP_Silk_encoder_state_FIX      *psEnc,             /* I/O                      */
-    SKP_int                         fs_kHz              /* I                        */
-)
-{
-    SKP_int ret = SKP_SILK_NO_ERROR;
-    
-    if( psEnc->sCmn.fs_kHz != fs_kHz || psEnc->sCmn.prev_API_fs_Hz != psEnc->sCmn.API_fs_Hz ) {
-
-        if( psEnc->sCmn.fs_kHz == 0 ) {
-            /* Initialize the resampler for enc_API.c preparing resampling from API_fs_Hz to fs_kHz */
-            ret += SKP_Silk_resampler_init( &psEnc->sCmn.resampler_state, psEnc->sCmn.API_fs_Hz, fs_kHz * 1000 );
-        } else {
-            /* Allocate space for worst case temporary upsampling, 8 to 48 kHz, so a factor 6 */
-            SKP_int16 x_buf_API_fs_Hz[ ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) * ( MAX_API_FS_KHZ / 8 ) ];
-
-            SKP_int32 nSamples_temp = SKP_LSHIFT( psEnc->sCmn.frame_length, 1 ) + LA_SHAPE_MS * psEnc->sCmn.fs_kHz;
-
-            if( SKP_SMULBB( fs_kHz, 1000 ) < psEnc->sCmn.API_fs_Hz && psEnc->sCmn.fs_kHz != 0 ) {
-                /* Resample buffered data in x_buf to API_fs_Hz */
-
-                SKP_Silk_resampler_state_struct  temp_resampler_state;
-
-                /* Initialize resampler for temporary resampling of x_buf data to API_fs_Hz */
-                ret += SKP_Silk_resampler_init( &temp_resampler_state, SKP_SMULBB( psEnc->sCmn.fs_kHz, 1000 ), psEnc->sCmn.API_fs_Hz );
-
-                /* Temporary resampling of x_buf data to API_fs_Hz */
-                ret += SKP_Silk_resampler( &temp_resampler_state, x_buf_API_fs_Hz, psEnc->x_buf, nSamples_temp );
-
-                /* Calculate number of samples that has been temporarily upsampled */
-                nSamples_temp = SKP_DIV32_16( nSamples_temp * psEnc->sCmn.API_fs_Hz, SKP_SMULBB( psEnc->sCmn.fs_kHz, 1000 ) );
-
-                /* Initialize the resampler for enc_API.c preparing resampling from API_fs_Hz to fs_kHz */
-                ret += SKP_Silk_resampler_init( &psEnc->sCmn.resampler_state, psEnc->sCmn.API_fs_Hz, SKP_SMULBB( fs_kHz, 1000 ) );
-
-            } else {
-                /* Copy data */
-                SKP_memcpy( x_buf_API_fs_Hz, psEnc->x_buf, nSamples_temp * sizeof( SKP_int16 ) );
-            }
-
-            if( 1000 * fs_kHz != psEnc->sCmn.API_fs_Hz ) {
-                /* Correct resampler state (unless resampling by a factor 1) by resampling buffered data from API_fs_Hz to fs_kHz */
-                ret += SKP_Silk_resampler( &psEnc->sCmn.resampler_state, psEnc->x_buf, x_buf_API_fs_Hz, nSamples_temp );
-            }
-        }
-    }
-
-    psEnc->sCmn.prev_API_fs_Hz = psEnc->sCmn.API_fs_Hz;
-
-    return(ret);
-}
-
-SKP_INLINE SKP_int SKP_Silk_setup_fs(
-    SKP_Silk_encoder_state_FIX      *psEnc,             /* I/O                      */
-    SKP_int                         fs_kHz,             /* I                        */
-    SKP_int                         PacketSize_ms       /* I                        */
-)
-{
-    SKP_int ret = SKP_SILK_NO_ERROR;
-
-    /* Set packet size */
-    if( PacketSize_ms != psEnc->sCmn.PacketSize_ms ) {
-        if( ( PacketSize_ms !=  10 ) &&
-            ( PacketSize_ms !=  20 ) &&
-            ( PacketSize_ms !=  40 ) && 
-            ( PacketSize_ms !=  60 ) ) {
-            ret = SKP_SILK_ENC_PACKET_SIZE_NOT_SUPPORTED;
-        }
-        if( PacketSize_ms <= 10 ) {
-            psEnc->sCmn.nFramesPerPacket = 1;
-            psEnc->sCmn.nb_subfr = PacketSize_ms == 10 ? 2 : 1;
-            psEnc->sCmn.frame_length = SKP_SMULBB( PacketSize_ms, fs_kHz );
-            psEnc->sCmn.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS_2_SF, fs_kHz );
-            if( psEnc->sCmn.fs_kHz == 8 ) {
-                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_NB_iCDF;
-            } else {
-                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_iCDF;
-            }
-        } else {
-            psEnc->sCmn.nFramesPerPacket = SKP_DIV32_16( PacketSize_ms, MAX_FRAME_LENGTH_MS );
-            psEnc->sCmn.nb_subfr = MAX_NB_SUBFR;
-            psEnc->sCmn.frame_length = SKP_SMULBB( 20, fs_kHz );
-            psEnc->sCmn.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS, fs_kHz );
-            if( psEnc->sCmn.fs_kHz == 8 ) {
-                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_NB_iCDF;
-            } else {
-                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_iCDF; 
-            }
-        }
-        psEnc->sCmn.PacketSize_ms  = PacketSize_ms;
-        psEnc->sCmn.TargetRate_bps = 0;         /* trigger new SNR computation */
-    }
-
-    /* Set internal sampling frequency */
-    SKP_assert( fs_kHz == 8 || fs_kHz == 12 || fs_kHz == 16 );
-    SKP_assert( psEnc->sCmn.nb_subfr == 2 || psEnc->sCmn.nb_subfr == 4 );
-    if( psEnc->sCmn.fs_kHz != fs_kHz ) {
-        /* reset part of the state */
-        SKP_memset( &psEnc->sShape,               0, sizeof( SKP_Silk_shape_state_FIX ) );
-        SKP_memset( &psEnc->sPrefilt,             0, sizeof( SKP_Silk_prefilter_state_FIX ) );
-        SKP_memset( &psEnc->sCmn.sNSQ,            0, sizeof( SKP_Silk_nsq_state ) );
-        SKP_memset( psEnc->sCmn.prev_NLSFq_Q15,   0, sizeof( psEnc->sCmn.prev_NLSFq_Q15 ) );
-        SKP_memset( &psEnc->sCmn.sLP.In_LP_State, 0, sizeof( psEnc->sCmn.sLP.In_LP_State ) );
-        psEnc->sCmn.inputBufIx                  = 0;
-        psEnc->sCmn.nFramesAnalyzed             = 0;
-        psEnc->sCmn.TargetRate_bps              = 0; /* Ensures that psEnc->SNR_dB is recomputed */
-
-        /* Initialize non-zero parameters */
-        psEnc->sCmn.prevLag                     = 100;
-        psEnc->sCmn.first_frame_after_reset     = 1;
-        psEnc->sPrefilt.lagPrev                 = 100;
-        psEnc->sShape.LastGainIndex             = 10;
-        psEnc->sCmn.sNSQ.lagPrev                = 100;
-        psEnc->sCmn.sNSQ.prev_inv_gain_Q16      = 65536;
-
-        psEnc->sCmn.fs_kHz = fs_kHz;
-        if( psEnc->sCmn.fs_kHz == 8 ) {
-            if( psEnc->sCmn.nb_subfr == MAX_NB_SUBFR ) {
-                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_NB_iCDF; 
-            } else {
-                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_NB_iCDF;
-            }
-        } else {
-            if( psEnc->sCmn.nb_subfr == MAX_NB_SUBFR ) {
-                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_iCDF; 
-            } else {
-                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_iCDF;
-            }
-        }
-        if( psEnc->sCmn.fs_kHz == 8 || psEnc->sCmn.fs_kHz == 12 ) {
-            psEnc->sCmn.predictLPCOrder = MIN_LPC_ORDER;
-            psEnc->sCmn.psNLSF_CB  = &SKP_Silk_NLSF_CB_NB_MB;
-        } else {
-            psEnc->sCmn.predictLPCOrder = MAX_LPC_ORDER;
-            psEnc->sCmn.psNLSF_CB  = &SKP_Silk_NLSF_CB_WB;
-        }
-        psEnc->sCmn.subfr_length   = SUB_FRAME_LENGTH_MS * fs_kHz;
-        psEnc->sCmn.frame_length   = SKP_SMULBB( psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr );
-        psEnc->sCmn.ltp_mem_length = SKP_SMULBB( LTP_MEM_LENGTH_MS, fs_kHz ); 
-        psEnc->sCmn.la_pitch       = SKP_SMULBB( LA_PITCH_MS, fs_kHz );
-        psEnc->sCmn.max_pitch_lag  = SKP_SMULBB( 18, fs_kHz );
-        if( psEnc->sCmn.nb_subfr == MAX_NB_SUBFR ) {
-            psEnc->sCmn.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS, fs_kHz );
-        } else {
-            psEnc->sCmn.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS_2_SF, fs_kHz );
-        }
-        if( psEnc->sCmn.fs_kHz == 16 ) {
-            psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_WB, 9 );
-            psEnc->sCmn.pitch_lag_low_bits_iCDF = SKP_Silk_uniform8_iCDF;
-        } else if( psEnc->sCmn.fs_kHz == 12 ) {
-            psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_MB, 9 );
-            psEnc->sCmn.pitch_lag_low_bits_iCDF = SKP_Silk_uniform6_iCDF;
-        } else {
-            psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_NB, 9 );
-            psEnc->sCmn.pitch_lag_low_bits_iCDF = SKP_Silk_uniform4_iCDF;
-        }
-    }
-
-    /* Check that settings are valid */
-    SKP_assert( ( psEnc->sCmn.subfr_length * psEnc->sCmn.nb_subfr ) == psEnc->sCmn.frame_length );
- 
-    return( ret );
-}
-
-SKP_INLINE SKP_int SKP_Silk_setup_rate(
-    SKP_Silk_encoder_state_FIX      *psEnc,             /* I/O                      */
-    SKP_int32                       TargetRate_bps      /* I                        */
-)
-{
-    SKP_int k, ret = SKP_SILK_NO_ERROR;
-    SKP_int32 frac_Q6;
-    const SKP_int32 *rateTable;
-
-    /* Set bitrate/coding quality */
-    if( TargetRate_bps != psEnc->sCmn.TargetRate_bps ) {
-        psEnc->sCmn.TargetRate_bps = TargetRate_bps;
-
-        /* If new TargetRate_bps, translate to SNR_dB value */
-        if( psEnc->sCmn.fs_kHz == 8 ) {
-            rateTable = TargetRate_table_NB;
-        } else if( psEnc->sCmn.fs_kHz == 12 ) {
-            rateTable = TargetRate_table_MB;
-        } else if( psEnc->sCmn.fs_kHz == 16 ) {
-            rateTable = TargetRate_table_WB;
-        } else {
-            SKP_assert( 0 );
-        }
-        /* Reduce bitrate for 10 ms modes in these calculations */
-        if( psEnc->sCmn.nb_subfr == 2 ) {
-            TargetRate_bps -= REDUCE_BITRATE_10_MS_BPS;
-        }
-        for( k = 1; k < TARGET_RATE_TAB_SZ; k++ ) {
-            /* Find bitrate interval in table and interpolate */
-            if( TargetRate_bps <= rateTable[ k ] ) {
-                frac_Q6 = SKP_DIV32( SKP_LSHIFT( TargetRate_bps - rateTable[ k - 1 ], 6 ), 
-                                                 rateTable[ k ] - rateTable[ k - 1 ] );
-                psEnc->SNR_dB_Q7 = SKP_LSHIFT( SNR_table_Q1[ k - 1 ], 6 ) + SKP_MUL( frac_Q6, SNR_table_Q1[ k ] - SNR_table_Q1[ k - 1 ] );
-                break;
-            }
-        }
-    }
-    return( ret );
-}
--- a/src_FIX/SKP_Silk_encode_frame_FIX.c
+++ b/src_FIX/SKP_Silk_encode_frame_FIX.c
@@ -38,8 +38,7 @@
 )
 {
     SKP_Silk_encoder_control_FIX sEncCtrl;
-    SKP_int     i, nBits, ret = 0;
-    SKP_uint8   flags;
+    SKP_int     ret = 0;
     SKP_int16   *x_frame, *res_pitch_frame;
     SKP_int16   xfw[ MAX_FRAME_LENGTH ];
     SKP_int16   res_pitch[ 2 * MAX_FRAME_LENGTH + LA_PITCH_MAX ];
@@ -65,14 +64,16 @@
     /**************************************************/
     /* Convert speech activity into VAD and DTX flags */
     /**************************************************/
+    if( psEnc->sCmn.nFramesAnalyzed == 0 ) {
+        psEnc->sCmn.inDTX = psEnc->sCmn.useDTX;
+    }
     if( psEnc->sCmn.speech_activity_Q8 < SKP_FIX_CONST( SPEECH_ACTIVITY_DTX_THRES, 8 ) ) {
         psEnc->sCmn.indices.signalType = TYPE_NO_VOICE_ACTIVITY;
         psEnc->sCmn.noSpeechCounter++;
-        if( psEnc->sCmn.noSpeechCounter > NO_SPEECH_FRAMES_BEFORE_DTX ) {
-            psEnc->sCmn.inDTX = 1;
-        }
-        if( psEnc->sCmn.noSpeechCounter > MAX_CONSECUTIVE_DTX ) {
-            psEnc->sCmn.noSpeechCounter = 0;
+        if( psEnc->sCmn.noSpeechCounter < NB_SPEECH_FRAMES_BEFORE_DTX ) {
+            psEnc->sCmn.inDTX = 0;
+        } else if( psEnc->sCmn.noSpeechCounter > MAX_CONSECUTIVE_DTX + NB_SPEECH_FRAMES_BEFORE_DTX ) {
+            psEnc->sCmn.noSpeechCounter = NB_SPEECH_FRAMES_BEFORE_DTX;
             psEnc->sCmn.inDTX           = 0;
         }
         psEnc->sCmn.VAD_flags[ psEnc->sCmn.nFramesAnalyzed ] = 0;
@@ -83,24 +84,6 @@
         psEnc->sCmn.VAD_flags[ psEnc->sCmn.nFramesAnalyzed ] = 1;
     }
 
-    if( psEnc->sCmn.nFramesAnalyzed == 0 && !psEnc->sCmn.prefillFlag && !( psEnc->sCmn.useDTX && psEnc->sCmn.inDTX ) ) {
-        /* Create space at start of payload for VAD and FEC flags */
-        SKP_uint8 iCDF[ 2 ] = { 0, 0 };
-        iCDF[ 0 ] = 256 - SKP_RSHIFT( 256, psEnc->sCmn.nFramesPerPacket + 1 );
-        ec_enc_icdf( psRangeEnc, 0, iCDF, 8 );
-
-        /* Encode any LBRR data from previous packet */
-        SKP_Silk_LBRR_embed( &psEnc->sCmn, psRangeEnc );
-
-        /* Reduce coding SNR depending on how many bits used by LBRR */
-        nBits = ec_tell( psRangeEnc );
-        psEnc->inBandFEC_SNR_comp_Q7 = SKP_DIV32_16( SKP_SMULBB( SKP_FIX_CONST( 6.0f, 7 ), nBits ), 
-            SKP_SMULBB( psEnc->sCmn.nFramesPerPacket, psEnc->sCmn.frame_length ) );
-
-        /* Reset LBRR flags */
-        SKP_memset( psEnc->sCmn.LBRR_flags, 0, sizeof( psEnc->sCmn.LBRR_flags ) );
-    }
-
     /*******************************************/
     /* High-pass filtering of the input signal */
     /*******************************************/
@@ -108,10 +91,8 @@
     SKP_Silk_HP_variable_cutoff( &psEnc->sCmn, x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, psEnc->sCmn.inputBuf, psEnc->sCmn.frame_length );
 TOC(HP_IN)
 
-#if SWITCH_TRANSITION_FILTERING
     /* Ensure smooth bandwidth transitions */
     SKP_Silk_LP_variable_cutoff( &psEnc->sCmn.sLP, x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, psEnc->sCmn.frame_length );
-#endif
     
     /*****************************************/
     /* Find pitch lags, initial LPC analysis */
@@ -179,7 +160,7 @@
     psEnc->sCmn.prevSignalType = psEnc->sCmn.indices.signalType;
 
     /* Exit without entropy coding */
-    if( psEnc->sCmn.prefillFlag || ( psEnc->sCmn.useDTX && psEnc->sCmn.inDTX ) ) {
+    if( psEnc->sCmn.prefillFlag ) {
         /* No payload */
         *pnBytesOut = 0;
         return ret;
@@ -201,36 +182,15 @@
 TOC(ENCODE_PULSES)
 
     /****************************************/
-    /* Simulate network buffer delay caused */
-    /* by exceeding TargetRate              */
-    /****************************************/
-    nBits = ec_tell( psRangeEnc );
-    psEnc->BufferedInChannel_ms += SKP_DIV32( SKP_SMULBB( 1000, nBits - psEnc->sCmn.prev_nBits ), psEnc->sCmn.TargetRate_bps );
-    psEnc->BufferedInChannel_ms -= psEnc->sCmn.PacketSize_ms;
-    psEnc->BufferedInChannel_ms  = SKP_LIMIT_int( psEnc->BufferedInChannel_ms, 0, 100 );
-    psEnc->sCmn.prev_nBits = nBits;
-    psEnc->sCmn.first_frame_after_reset = 0;
-
-    /****************************************/
     /* Finalize payload                     */
     /****************************************/
+    psEnc->sCmn.first_frame_after_reset = 0;
     if( ++psEnc->sCmn.nFramesAnalyzed >= psEnc->sCmn.nFramesPerPacket ) {
-        /* Insert VAD flags and FEC flag at beginning of bitstream */
-        flags = 0;
-        for( i = 0; i < psEnc->sCmn.nFramesPerPacket; i++ ) {
-            flags |= psEnc->sCmn.VAD_flags[i];
-            flags  = SKP_LSHIFT( flags, 1 );
-        }
-        flags |= psEnc->sCmn.LBRR_flag;
-        ec_enc_patch_initial_bits( psRangeEnc, flags, psEnc->sCmn.nFramesPerPacket + 1 );
-
         /* Payload size */
-        nBits = ec_tell( psRangeEnc );
-        *pnBytesOut = SKP_RSHIFT( nBits + 7, 3 );
+        *pnBytesOut = SKP_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
 
         /* Reset the number of frames in payload buffer */
         psEnc->sCmn.nFramesAnalyzed = 0;
-        psEnc->sCmn.prev_nBits = 0;
     } else {
         /* No payload this time */
         *pnBytesOut = 0;
@@ -241,9 +201,9 @@
     {
         SKP_float tmp[ MAX_NB_SUBFR * LTP_ORDER ];
         int i;
-        DEBUG_STORE_DATA( xf.dat,                   x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, psEnc->sCmn.frame_length    * sizeof( SKP_int16 ) );
+        DEBUG_STORE_DATA( xf.dat,                   x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, psEnc->sCmn.frame_length * sizeof( SKP_int16 ) );
         DEBUG_STORE_DATA( xfw.dat,                  xfw,                            psEnc->sCmn.frame_length    * sizeof( SKP_int16 ) );
-        DEBUG_STORE_DATA( pitchL.dat,               sEncCtrl.pitchL,                psEnc->sCmn.nb_subfr            * sizeof( SKP_int ) );
+        DEBUG_STORE_DATA( pitchL.dat,               sEncCtrl.pitchL,                psEnc->sCmn.nb_subfr        * sizeof( SKP_int ) );
         for( i = 0; i < psEnc->sCmn.nb_subfr * LTP_ORDER; i++ ) {
             tmp[ i ] = (SKP_float)sEncCtrl.LTPCoef_Q14[ i ] / 16384.0f;
         }
@@ -263,17 +223,16 @@
             tmp[ i ] = (SKP_float)sEncCtrl.Gains_Q16[ i ] / 65536.0f;
         }
         DEBUG_STORE_DATA( gains.dat,                tmp,                            psEnc->sCmn.nb_subfr * sizeof( SKP_float ) );
-        DEBUG_STORE_DATA( gains_indices.dat,        &psEnc->sCmn.indices.GainsIndices,       psEnc->sCmn.nb_subfr * sizeof( SKP_int ) );
-        DEBUG_STORE_DATA( nBits.dat,                &nBits,                         sizeof( SKP_int ) );
+        DEBUG_STORE_DATA( gains_indices.dat,        &psEnc->sCmn.indices.GainsIndices, psEnc->sCmn.nb_subfr * sizeof( SKP_int ) );
         tmp[ 0 ] = (SKP_float)sEncCtrl.current_SNR_dB_Q7 / 128.0f;
         DEBUG_STORE_DATA( current_SNR_db.dat,       tmp,                            sizeof( SKP_float ) );
-        DEBUG_STORE_DATA( quantOffsetType.dat,      &psEnc->sCmn.indices.quantOffsetType,    sizeof( SKP_int ) );
+        DEBUG_STORE_DATA( quantOffsetType.dat,      &psEnc->sCmn.indices.quantOffsetType, sizeof( SKP_int ) );
         tmp[ 0 ] = (SKP_float)psEnc->sCmn.speech_activity_Q8 / 256.0f;
         DEBUG_STORE_DATA( speech_activity.dat,      tmp,                            sizeof( SKP_float ) );
         for( i = 0; i < VAD_N_BANDS; i++ ) {
             tmp[ i ] = (SKP_float)psEnc->sCmn.input_quality_bands_Q15[ i ] / 32768.0f;
         }
-        DEBUG_STORE_DATA( input_quality_bands.dat,  tmp,                            VAD_N_BANDS * sizeof( SKP_float ) );
+        DEBUG_STORE_DATA( input_quality_bands.dat,  tmp,                       VAD_N_BANDS * sizeof( SKP_float ) );
         DEBUG_STORE_DATA( signalType.dat,           &psEnc->sCmn.indices.signalType,         sizeof( SKP_int8) ); 
         DEBUG_STORE_DATA( lag_index.dat,            &psEnc->sCmn.indices.lagIndex,           sizeof( SKP_int16 ) ); 
         DEBUG_STORE_DATA( contour_index.dat,        &psEnc->sCmn.indices.contourIndex,       sizeof( SKP_int8 ) ); 
@@ -336,7 +295,7 @@
                 psEncCtrl->Gains_Q16, psEncCtrl->pitchL, psEncCtrl->Lambda_Q10, psEncCtrl->LTP_scale_Q14 );
         }
 
-        /* Restore original Gains */
+        /* Restore original gains */
         SKP_memcpy( psEncCtrl->Gains_Q16, TempGains_Q16, psEnc->sCmn.nb_subfr * sizeof( SKP_int32 ) );
     }
 }
--- a/src_FIX/SKP_Silk_init_encoder_FIX.c
+++ /dev/null
@@ -1,50 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. 
-Redistribution and use in source and binary forms, with or without 
-modification, (subject to the limitations in the disclaimer below) 
-are permitted provided that the following conditions are met:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright 
-notice, this list of conditions and the following disclaimer in the 
-documentation and/or other materials provided with the distribution.
-- Neither the name of Skype Limited, nor the names of specific 
-contributors, may be used to endorse or promote products derived from 
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-***********************************************************************/
-
-#include "SKP_Silk_main_FIX.h"
-
-/*********************************/
-/* Initialize Silk Encoder state */
-/*********************************/
-SKP_int SKP_Silk_init_encoder_FIX(
-    SKP_Silk_encoder_state_FIX  *psEnc          /* I/O  Pointer to Silk encoder state               */
-) {
-    SKP_int ret = 0;
-    /* Clear the entire encoder state */
-    SKP_memset( psEnc, 0, sizeof( SKP_Silk_encoder_state_FIX ) );
-
-    psEnc->sCmn.variable_HP_smth1_Q15 = 200844; /* = SKP_Silk_log2(70)_Q0; */
-    psEnc->sCmn.variable_HP_smth2_Q15 = 200844; /* = SKP_Silk_log2(70)_Q0; */
-
-    /* Used to deactivate LSF interpolation, fluctuation reduction, pitch prediction */
-    psEnc->sCmn.first_frame_after_reset = 1;
-
-    /* Initialize Silk VAD */
-    ret += SKP_Silk_VAD_Init( &psEnc->sCmn.sVAD );
-
-    return( ret );
-}
--- a/src_FIX/SKP_Silk_main_FIX.h
+++ b/src_FIX/SKP_Silk_main_FIX.h
@@ -30,6 +30,7 @@
 
 #include "SKP_Silk_SigProc_FIX.h"
 #include "SKP_Silk_structs_FIX.h"
+#include "SKP_Silk_control.h"
 #include "SKP_Silk_main.h"
 #include "SKP_Silk_PLC.h"
 #include "SKP_debug.h"
@@ -55,23 +56,21 @@
 
 /* Low Bitrate Redundancy (LBRR) encoding. Reuse all parameters but encode with lower bitrate           */
 void SKP_Silk_LBRR_encode_FIX(
-    SKP_Silk_encoder_state_FIX      *psEnc,         /* I/O  Pointer to Silk FIX encoder state           */
-    SKP_Silk_encoder_control_FIX    *psEncCtrl,     /* I/O  Pointer to Silk FIX encoder control struct  */
-    const SKP_int16                 xfw[]           /* I    Input signal                                */
+    SKP_Silk_encoder_state_FIX      *psEnc,             /* I/O  Pointer to Silk FIX encoder state           */
+    SKP_Silk_encoder_control_FIX    *psEncCtrl,         /* I/O  Pointer to Silk FIX encoder control struct  */
+    const SKP_int16                 xfw[]               /* I    Input signal                                */
 );
 
 /* Initializes the Silk encoder state */
-SKP_int SKP_Silk_init_encoder_FIX(
-    SKP_Silk_encoder_state_FIX  *psEnc              /* I/O  Pointer to Silk FIX encoder state           */
+SKP_int SKP_Silk_init_encoder(
+    SKP_Silk_encoder_state_FIX      *psEnc              /* I/O  Pointer to Silk FIX encoder state           */
 );
 
 /* Control the Silk encoder */
-SKP_int SKP_Silk_control_encoder_FIX( 
-    SKP_Silk_encoder_state_FIX  *psEnc,                 /* I/O  Pointer to Silk encoder state           */
-    const SKP_int               PacketSize_ms,          /* I    Packet length (ms)                      */
-    const SKP_int32             TargetRate_bps,         /* I    Target max bitrate (bps)                */
-    const SKP_int               PacketLoss_perc,        /* I    Packet loss rate (in percent)           */
-    const SKP_int               Complexity              /* I    Complexity (0-10)                       */
+SKP_int SKP_Silk_control_encoder( 
+    SKP_Silk_encoder_state_FIX      *psEnc,             /* I/O  Pointer to Silk encoder state           */
+    SKP_SILK_SDK_EncControlStruct   *encControl,        /* I:   Control structure                       */
+    const SKP_int32                 TargetRate_bps      /* I    Target max bitrate (bps)                */
 );
 
 /****************/
--- a/src_FIX/SKP_Silk_noise_shape_analysis_FIX.c
+++ b/src_FIX/SKP_Silk_noise_shape_analysis_FIX.c
@@ -158,27 +158,19 @@
     x_ptr = x - psEnc->sCmn.la_shape;
 
     /****************/
-    /* CONTROL SNR  */
-    /****************/
-    /* Reduce SNR_dB values if recent bitstream has exceeded TargetRate */
-    psEncCtrl->current_SNR_dB_Q7 = psEnc->SNR_dB_Q7 - SKP_SMULBB( psEnc->BufferedInChannel_ms, SKP_FIX_CONST( 0.1, 7 ) );
-
-    /* Reduce SNR_dB because of any inband FEC used */
-    psEncCtrl->current_SNR_dB_Q7 -= psEnc->inBandFEC_SNR_comp_Q7;
-
-    /****************/
     /* GAIN CONTROL */
     /****************/
+    SNR_adj_dB_Q7 = psEnc->sCmn.SNR_dB_Q7;
+
     /* Input quality is the average of the quality in the lowest two VAD bands */
     psEncCtrl->input_quality_Q14 = ( SKP_int )SKP_RSHIFT( ( SKP_int32 )psEnc->sCmn.input_quality_bands_Q15[ 0 ] 
         + psEnc->sCmn.input_quality_bands_Q15[ 1 ], 2 );
 
     /* Coding quality level, between 0.0_Q0 and 1.0_Q0, but in Q14 */
-    psEncCtrl->coding_quality_Q14 = SKP_RSHIFT( SKP_Silk_sigm_Q15( SKP_RSHIFT_ROUND( psEncCtrl->current_SNR_dB_Q7 - 
+    psEncCtrl->coding_quality_Q14 = SKP_RSHIFT( SKP_Silk_sigm_Q15( SKP_RSHIFT_ROUND( SNR_adj_dB_Q7 - 
         SKP_FIX_CONST( 18.0, 7 ), 4 ) ), 1 );
 
     /* Reduce coding SNR during low speech activity */
-    SNR_adj_dB_Q7 = psEncCtrl->current_SNR_dB_Q7;
     if( psEnc->sCmn.useCBR == 0 ) {
         b_Q8 = SKP_FIX_CONST( 1.0, 8 ) - psEnc->sCmn.speech_activity_Q8;
         b_Q8 = SKP_SMULWB( SKP_LSHIFT( b_Q8, 8 ), b_Q8 );
@@ -193,7 +185,7 @@
     } else { 
         /* For unvoiced signals and low-quality input, adjust the quality slower than SNR_dB setting */
         SNR_adj_dB_Q7 = SKP_SMLAWB( SNR_adj_dB_Q7, 
-            SKP_SMLAWB( SKP_FIX_CONST( 6.0, 9 ), -SKP_FIX_CONST( 0.4, 18 ), psEncCtrl->current_SNR_dB_Q7 ),
+            SKP_SMLAWB( SKP_FIX_CONST( 6.0, 9 ), -SKP_FIX_CONST( 0.4, 18 ), psEnc->sCmn.SNR_dB_Q7 ),
             SKP_FIX_CONST( 1.0, 14 ) - psEncCtrl->input_quality_Q14 );
     }
 
--- a/src_FIX/SKP_Silk_process_gains_FIX.c
+++ b/src_FIX/SKP_Silk_process_gains_FIX.c
@@ -48,8 +48,9 @@
     }
 
     /* Limit the quantized signal */
+    /* InvMaxSqrVal = pow( 2.0f, 0.33f * ( 21.0f - SNR_dB ) ) / subfr_length; */
     InvMaxSqrVal_Q16 = SKP_DIV32_16( SKP_Silk_log2lin( 
-        SKP_SMULWB( SKP_FIX_CONST( 70.0, 7 ) - psEncCtrl->current_SNR_dB_Q7, SKP_FIX_CONST( 0.33, 16 ) ) ), psEnc->sCmn.subfr_length );
+        SKP_SMULWB( SKP_FIX_CONST( 21 + 16 / 0.33, 7 ) - psEnc->sCmn.SNR_dB_Q7, SKP_FIX_CONST( 0.33, 16 ) ) ), psEnc->sCmn.subfr_length );
 
     for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) {
         /* Soft limit on ratio residual energy and squared gains */
@@ -56,13 +57,9 @@
         ResNrg     = psEncCtrl->ResNrg[ k ];
         ResNrgPart = SKP_SMULWW( ResNrg, InvMaxSqrVal_Q16 );
         if( psEncCtrl->ResNrgQ[ k ] > 0 ) {
-            if( psEncCtrl->ResNrgQ[ k ] < 32 ) {
-                ResNrgPart = SKP_RSHIFT_ROUND( ResNrgPart, psEncCtrl->ResNrgQ[ k ] );
-            } else {
-                ResNrgPart = 0;
-            }
-        } else if( psEncCtrl->ResNrgQ[k] != 0 ) {
-            if( ResNrgPart > SKP_RSHIFT( SKP_int32_MAX, -psEncCtrl->ResNrgQ[ k ] ) ) {
+            ResNrgPart = SKP_RSHIFT_ROUND( ResNrgPart, psEncCtrl->ResNrgQ[ k ] );
+        } else {
+            if( ResNrgPart >= SKP_RSHIFT( SKP_int32_MAX, -psEncCtrl->ResNrgQ[ k ] ) ) {
                 ResNrgPart = SKP_int32_MAX;
             } else {
                 ResNrgPart = SKP_LSHIFT( ResNrgPart, -psEncCtrl->ResNrgQ[ k ] );
@@ -75,9 +72,11 @@
             gain_squared = SKP_SMLAWW( SKP_LSHIFT( ResNrgPart, 16 ), gain, gain );
             SKP_assert( gain_squared > 0 );
             gain = SKP_Silk_SQRT_APPROX( gain_squared );                    /* Q8   */
+            gain = SKP_min( gain, SKP_int32_MAX >> 8 );
             psEncCtrl->Gains_Q16[ k ] = SKP_LSHIFT_SAT32( gain, 8 );        /* Q16  */
         } else {
             gain = SKP_Silk_SQRT_APPROX( gain_squared );                    /* Q0   */
+            gain = SKP_min( gain, SKP_int32_MAX >> 16 );
             psEncCtrl->Gains_Q16[ k ] = SKP_LSHIFT_SAT32( gain, 16 );       /* Q16  */
         }
     }
@@ -85,6 +84,7 @@
     /* Noise shaping quantization */
     SKP_Silk_gains_quant( psEnc->sCmn.indices.GainsIndices, psEncCtrl->Gains_Q16, 
         &psShapeSt->LastGainIndex, psEnc->sCmn.nFramesAnalyzed, psEnc->sCmn.nb_subfr );
+
     /* Set quantizer offset for voiced signals. Larger offset when LTP coding gain is low or tilt is high (ie low-pass) */
     if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) {
         if( psEncCtrl->LTPredCodGain_Q7 + SKP_RSHIFT( psEnc->sCmn.input_tilt_Q15, 8 ) > SKP_FIX_CONST( 1.0, 7 ) ) {
--- a/src_FIX/SKP_Silk_structs_FIX.h
+++ b/src_FIX/SKP_Silk_structs_FIX.h
@@ -72,15 +72,10 @@
     /* Buffer for find pitch and noise shape analysis */
     SKP_DWORD_ALIGN SKP_int16 x_buf[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ];
     SKP_int                         LTPCorr_Q15;                    /* Normalized correlation from pitch lag estimator                      */
-    SKP_int32                       SNR_dB_Q7;                      /* Quality setting                                                      */
-    SKP_int                         BufferedInChannel_ms;           /* Simulated number of ms buffer because of exceeded TargetRate_bps     */
 
     /* Parameters For LTP scaling Control */
     SKP_int                         prevLTPredCodGain_Q7;
     SKP_int                         HPLTPredCodGain_Q7;
-
-    SKP_int32                       inBandFEC_SNR_comp_Q7;          /* Compensation to SNR_dB when using inband FEC Voiced                  */
-
 } SKP_Silk_encoder_state_FIX;
 
 /************************/
@@ -106,7 +101,6 @@
     SKP_int     Lambda_Q10;
     SKP_int     input_quality_Q14;
     SKP_int     coding_quality_Q14;
-    SKP_int     current_SNR_dB_Q7;
 
     /* measures */
     SKP_int     sparseness_Q8;
--- a/src_FIX/src_FIX.vcxproj
+++ b/src_FIX/src_FIX.vcxproj
@@ -78,7 +78,6 @@
     <ClInclude Include="SKP_Silk_structs_FIX.h" />
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="SKP_Silk_control_codec_FIX.c" />
     <ClCompile Include="SKP_Silk_corrMatrix_FIX.c" />
     <ClCompile Include="SKP_Silk_encode_frame_FIX.c" />
     <ClCompile Include="SKP_Silk_find_LPC_FIX.c" />
@@ -85,7 +84,6 @@
     <ClCompile Include="SKP_Silk_find_LTP_FIX.c" />
     <ClCompile Include="SKP_Silk_find_pitch_lags_FIX.c" />
     <ClCompile Include="SKP_Silk_find_pred_coefs_FIX.c" />
-    <ClCompile Include="SKP_Silk_init_encoder_FIX.c" />
     <ClCompile Include="SKP_Silk_LTP_analysis_filter_FIX.c" />
     <ClCompile Include="SKP_Silk_LTP_scale_ctrl_FIX.c" />
     <ClCompile Include="SKP_Silk_noise_shape_analysis_FIX.c" />
--- a/src_FIX/src_FIX.vcxproj.filters
+++ b/src_FIX/src_FIX.vcxproj.filters
@@ -26,9 +26,6 @@
     </ClInclude>
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="SKP_Silk_control_codec_FIX.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="SKP_Silk_corrMatrix_FIX.c">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -45,9 +42,6 @@
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="SKP_Silk_find_pred_coefs_FIX.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="SKP_Silk_init_encoder_FIX.c">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="SKP_Silk_LTP_analysis_filter_FIX.c">
--- a/src_FLP/SKP_Silk_LTP_scale_ctrl_FLP.c
+++ b/src_FLP/SKP_Silk_LTP_scale_ctrl_FLP.c
@@ -27,57 +27,26 @@
 
 #include "SKP_Silk_main_FLP.h"
 
-#define NB_THRESHOLDS           11
-
-/* Table containing trained thresholds for LTP scaling */
-static const SKP_float LTPScaleThresholds[ NB_THRESHOLDS ] = 
-{
-    0.95f, 0.8f, 0.50f, 0.400f, 0.3f, 0.2f,
-    0.15f, 0.1f, 0.08f, 0.075f, 0.0f
-};
-
-
 void SKP_Silk_LTP_scale_ctrl_FLP(
     SKP_Silk_encoder_state_FLP      *psEnc,             /* I/O  Encoder state FLP                       */
     SKP_Silk_encoder_control_FLP    *psEncCtrl          /* I/O  Encoder control FLP                     */
 )
 {
-    SKP_int round_loss;
-    SKP_float g_out, g_limit, thrld1, thrld2;
+    SKP_int   round_loss;
 
     /* 1st order high-pass filter */
-    //g_HP(n) = g(n) - g(n-1) + 0.5 * g_HP(n-1);       // tune the 0.5: higher means longer impact of jump
-    psEnc->HPLTPredCodGain = SKP_max_float( psEncCtrl->LTPredCodGain - psEnc->prevLTPredCodGain, 0.0f ) 
+    //g_HP(n) = g(n) - 0.5 * g(n-1) + 0.5 * g_HP(n-1);
+    psEnc->HPLTPredCodGain = SKP_max_float( psEncCtrl->LTPredCodGain - 0.5 * psEnc->prevLTPredCodGain, 0.0f ) 
                             + 0.5f * psEnc->HPLTPredCodGain;
-    
     psEnc->prevLTPredCodGain = psEncCtrl->LTPredCodGain;
 
-    /* Combine input and filtered input */
-    g_out = 0.5f * psEncCtrl->LTPredCodGain + ( 1.0f - 0.5f ) * psEnc->HPLTPredCodGain;
-    g_limit = SKP_sigmoid( 0.5f * ( g_out - 6 ) );
-    
-    
-    /* Default is minimum scaling */
-    psEnc->sCmn.indices.LTP_scaleIndex = 0;
-
-    /* Round the loss measure to whole pct */
-    round_loss = ( SKP_int )( psEnc->sCmn.PacketLoss_perc );
-    round_loss = SKP_max( 0, round_loss );
-
     /* Only scale if first frame in packet */
-    if( psEnc->sCmn.nFramesAnalyzed == 0 ){
-        
-        round_loss += psEnc->sCmn.nFramesPerPacket - 1;
-        thrld1 = LTPScaleThresholds[ SKP_min_int( round_loss,     NB_THRESHOLDS - 1 ) ];
-        thrld2 = LTPScaleThresholds[ SKP_min_int( round_loss + 1, NB_THRESHOLDS - 1 ) ];
-    
-        if( g_limit > thrld1 ) {
-            /* High Scaling */
-            psEnc->sCmn.indices.LTP_scaleIndex = 2;
-        } else if( g_limit > thrld2 ) {
-            /* Middle Scaling */
-            psEnc->sCmn.indices.LTP_scaleIndex = 1;
-        }
+    if( psEnc->sCmn.nFramesAnalyzed == 0 ) {
+        round_loss = psEnc->sCmn.PacketLoss_perc + psEnc->sCmn.nFramesPerPacket;
+        psEnc->sCmn.indices.LTP_scaleIndex = (SKP_int8)SKP_LIMIT( round_loss * psEnc->HPLTPredCodGain * 0.1f, 0.0f, 2.0f );
+    } else {
+        /* Default is minimum scaling */
+        psEnc->sCmn.indices.LTP_scaleIndex = 0;
     }
-    psEncCtrl->LTP_scale = ( SKP_float)SKP_Silk_LTPScales_table_Q14[ psEnc->sCmn.indices.LTP_scaleIndex ] / 16384.0f;
+    psEncCtrl->LTP_scale = (SKP_float)SKP_Silk_LTPScales_table_Q14[ psEnc->sCmn.indices.LTP_scaleIndex ] / 16384.0f;
 }
--- a/src_FLP/SKP_Silk_control_codec_FLP.c
+++ /dev/null
@@ -1,317 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. 
-Redistribution and use in source and binary forms, with or without 
-modification, (subject to the limitations in the disclaimer below) 
-are permitted provided that the following conditions are met:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright 
-notice, this list of conditions and the following disclaimer in the 
-documentation and/or other materials provided with the distribution.
-- Neither the name of Skype Limited, nor the names of specific 
-contributors, may be used to endorse or promote products derived from 
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-***********************************************************************/
-
-#include "SKP_Silk_main_FLP.h"
-#include "SKP_Silk_setup.h"
-
-SKP_INLINE SKP_int SKP_Silk_setup_resamplers(
-    SKP_Silk_encoder_state_FLP      *psEnc,             /* I/O  Pointer to Silk encoder state FLP       */
-    SKP_int                         fs_kHz              /* I    Internal sampling rate (kHz)            */
-);
-
-SKP_INLINE SKP_int SKP_Silk_setup_fs(
-    SKP_Silk_encoder_state_FLP      *psEnc,             /* I/O                      */
-    SKP_int                         fs_kHz,             /* I                        */
-    SKP_int                         PacketSize_ms       /* I                        */
-);
-
-SKP_INLINE SKP_int SKP_Silk_setup_rate(
-    SKP_Silk_encoder_state_FLP      *psEnc,             /* I/O  Pointer to Silk encoder state FLP       */
-    SKP_int32                       TargetRate_bps      /* I    Target max bitrate                      */
-);
-
-/* Control encoder */
-SKP_int SKP_Silk_control_encoder_FLP( 
-    SKP_Silk_encoder_state_FLP  *psEnc,                 /* I/O  Pointer to Silk encoder state FLP       */
-    const SKP_int               PacketSize_ms,          /* I    Packet length (ms)                      */
-    const SKP_int32             TargetRate_bps,         /* I    Target max bitrate (bps)                */
-    const SKP_int               PacketLoss_perc,        /* I    Packet loss rate (in percent)           */
-    const SKP_int               Complexity              /* I    Complexity (0-10)                       */
-)
-{
-    SKP_int   fs_kHz, ret = 0;
-
-    if( psEnc->sCmn.controlled_since_last_payload != 0 && psEnc->sCmn.prefillFlag == 0 ) {
-        if( psEnc->sCmn.API_fs_Hz != psEnc->sCmn.prev_API_fs_Hz && psEnc->sCmn.fs_kHz > 0 ) {
-            /* Change in API sampling rate in the middle of encoding a packet */
-            ret += SKP_Silk_setup_resamplers( psEnc, psEnc->sCmn.fs_kHz );
-        }
-        return ret;
-    }
-
-    /* Beyond this point we know that there are no previously coded frames in the payload buffer */
-
-    /********************************************/
-    /* Determine internal sampling rate         */
-    /********************************************/
-    fs_kHz = SKP_Silk_control_audio_bandwidth( &psEnc->sCmn, TargetRate_bps );
-
-    /********************************************/
-    /* Prepare resampler and buffered data      */
-    /********************************************/
-    ret += SKP_Silk_setup_resamplers( psEnc, fs_kHz );
-
-    /********************************************/
-    /* Set internal sampling frequency          */
-    /********************************************/
-    ret += SKP_Silk_setup_fs( psEnc, fs_kHz, PacketSize_ms );
-
-    /********************************************/
-    /* Set encoding complexity                  */
-    /********************************************/
-    ret += SKP_Silk_setup_complexity( &psEnc->sCmn, Complexity );
-
-    /********************************************/
-    /* Set bitrate/coding quality               */
-    /********************************************/
-    ret += SKP_Silk_setup_rate( psEnc, TargetRate_bps );
-
-    /********************************************/
-    /* Set packet loss rate measured by farend  */
-    /********************************************/
-    if( ( PacketLoss_perc < 0 ) || ( PacketLoss_perc > 100 ) ) {
-        ret = SKP_SILK_ENC_INVALID_LOSS_RATE;
-    }
-    psEnc->sCmn.PacketLoss_perc = PacketLoss_perc;
-
-    /********************************************/
-    /* Set LBRR usage                           */
-    /********************************************/
-    ret += SKP_Silk_setup_LBRR( &psEnc->sCmn );
-
-    psEnc->sCmn.controlled_since_last_payload = 1;
-
-    return ret;
-}
-
-SKP_INLINE SKP_int SKP_Silk_setup_resamplers(
-    SKP_Silk_encoder_state_FLP      *psEnc,             /* I/O  Pointer to Silk encoder state FLP       */
-    SKP_int                         fs_kHz              /* I    External (API) sampling rate (Hz)       */
-)
-{
-    SKP_int ret = SKP_SILK_NO_ERROR;
-    
-    if( psEnc->sCmn.fs_kHz != fs_kHz || psEnc->sCmn.prev_API_fs_Hz != psEnc->sCmn.API_fs_Hz ) {
-
-        if( psEnc->sCmn.fs_kHz == 0 ) {
-            /* Initialize the resampler for enc_API.c preparing resampling from API_fs_Hz to fs_kHz */
-            ret += SKP_Silk_resampler_init( &psEnc->sCmn.resampler_state, psEnc->sCmn.API_fs_Hz, fs_kHz * 1000 );
-        } else {
-            /* Allocate space for worst case temporary upsampling, 8 to 48 kHz, so a factor 6 */
-            SKP_int16 x_buf_API_fs_Hz[ ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) * ( MAX_API_FS_KHZ / 8 ) ];
-            SKP_int16 x_bufFIX[          2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ]; 
-
-            SKP_int32 nSamples_temp = 2 * psEnc->sCmn.frame_length + LA_SHAPE_MS * psEnc->sCmn.fs_kHz;
-
-            SKP_float2short_array( x_bufFIX, psEnc->x_buf, nSamples_temp );
-
-            if( fs_kHz * 1000 < psEnc->sCmn.API_fs_Hz && psEnc->sCmn.fs_kHz != 0 ) {
-                /* Resample buffered data in x_buf to API_fs_Hz */
-
-                SKP_Silk_resampler_state_struct  temp_resampler_state;
-
-                /* Initialize resampler for temporary resampling of x_buf data to API_fs_Hz */
-                ret += SKP_Silk_resampler_init( &temp_resampler_state, psEnc->sCmn.fs_kHz * 1000, psEnc->sCmn.API_fs_Hz );
-
-                /* Temporary resampling of x_buf data to API_fs_Hz */
-                ret += SKP_Silk_resampler( &temp_resampler_state, x_buf_API_fs_Hz, x_bufFIX, nSamples_temp );
-
-                /* Calculate number of samples that has been temporarily upsampled */
-                nSamples_temp = SKP_DIV32_16( nSamples_temp * psEnc->sCmn.API_fs_Hz, psEnc->sCmn.fs_kHz * 1000 );
-
-                /* Initialize the resampler for enc_API.c preparing resampling from API_fs_Hz to fs_kHz */
-                ret += SKP_Silk_resampler_init( &psEnc->sCmn.resampler_state, psEnc->sCmn.API_fs_Hz, fs_kHz * 1000 );
-
-            } else {
-                /* Copy data */
-                SKP_memcpy( x_buf_API_fs_Hz, x_bufFIX, nSamples_temp * sizeof( SKP_int16 ) );
-            }
-
-            if( 1000 * fs_kHz != psEnc->sCmn.API_fs_Hz ) {
-                /* Correct resampler state (unless resampling by a factor 1) by resampling buffered data from API_fs_Hz to fs_kHz */
-                ret += SKP_Silk_resampler( &psEnc->sCmn.resampler_state, x_bufFIX, x_buf_API_fs_Hz, nSamples_temp );
-            }
-            SKP_short2float_array( psEnc->x_buf, x_bufFIX, ( 2 * MAX_FRAME_LENGTH_MS + LA_SHAPE_MS ) * fs_kHz );
-        }
-    }
-
-    psEnc->sCmn.prev_API_fs_Hz = psEnc->sCmn.API_fs_Hz;
-
-    return(ret);
-}
-
-SKP_INLINE SKP_int SKP_Silk_setup_fs(
-    SKP_Silk_encoder_state_FLP      *psEnc,             /* I/O                      */
-    SKP_int                         fs_kHz,             /* I                        */
-    SKP_int                         PacketSize_ms       /* I                        */
-)
-{
-    SKP_int ret = SKP_SILK_NO_ERROR;
-
-    /* Set packet size */
-    if( PacketSize_ms != psEnc->sCmn.PacketSize_ms ) {
-        if( ( PacketSize_ms !=  10 ) &&
-            ( PacketSize_ms !=  20 ) &&
-            ( PacketSize_ms !=  40 ) && 
-            ( PacketSize_ms !=  60 ) ) {
-            ret = SKP_SILK_ENC_PACKET_SIZE_NOT_SUPPORTED;
-        }
-        if( PacketSize_ms <= 10 ) {
-            psEnc->sCmn.nFramesPerPacket = 1;
-            psEnc->sCmn.nb_subfr = PacketSize_ms == 10 ? 2 : 1;
-            psEnc->sCmn.frame_length = PacketSize_ms * fs_kHz;
-            psEnc->sCmn.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS_2_SF, fs_kHz );
-            if( psEnc->sCmn.fs_kHz == 8 ) {
-                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_NB_iCDF;
-            } else {
-                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_iCDF;
-            }
-        } else {
-            psEnc->sCmn.nFramesPerPacket = SKP_DIV32_16( PacketSize_ms, MAX_FRAME_LENGTH_MS );
-            psEnc->sCmn.nb_subfr = MAX_NB_SUBFR;
-            psEnc->sCmn.frame_length = 20 * fs_kHz;
-            psEnc->sCmn.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS, fs_kHz );
-            if( psEnc->sCmn.fs_kHz == 8 ) {
-                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_NB_iCDF;
-            } else {
-                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_iCDF; 
-            }
-        }
-        psEnc->sCmn.PacketSize_ms  = PacketSize_ms;
-        psEnc->sCmn.TargetRate_bps = 0;         /* trigger new SNR computation */
-    }
-
-    /* Set internal sampling frequency */
-    SKP_assert( fs_kHz == 8 || fs_kHz == 12 || fs_kHz == 16 );
-    SKP_assert( psEnc->sCmn.nb_subfr == 2 || psEnc->sCmn.nb_subfr == 4 );
-    if( psEnc->sCmn.fs_kHz != fs_kHz ) {
-        /* reset part of the state */
-        SKP_memset( &psEnc->sShape,               0, sizeof( SKP_Silk_shape_state_FLP ) );
-        SKP_memset( &psEnc->sPrefilt,             0, sizeof( SKP_Silk_prefilter_state_FLP ) );
-        SKP_memset( &psEnc->sCmn.sNSQ,            0, sizeof( SKP_Silk_nsq_state ) );
-        SKP_memset( psEnc->sCmn.prev_NLSFq_Q15,   0, sizeof( psEnc->sCmn.prev_NLSFq_Q15 ) );
-        SKP_memset( &psEnc->sCmn.sLP.In_LP_State, 0, sizeof( psEnc->sCmn.sLP.In_LP_State ) );
-        psEnc->sCmn.inputBufIx                  = 0;
-        psEnc->sCmn.nFramesAnalyzed             = 0;
-        psEnc->sCmn.TargetRate_bps              = 0; /* Ensures that psEnc->SNR_dB is recomputed */
-
-        /* Initialize non-zero parameters */
-        psEnc->sCmn.prevLag                     = 100;
-        psEnc->sCmn.first_frame_after_reset     = 1;
-        psEnc->sPrefilt.lagPrev                 = 100;
-        psEnc->sShape.LastGainIndex             = 10;
-        psEnc->sCmn.sNSQ.lagPrev                = 100;
-        psEnc->sCmn.sNSQ.prev_inv_gain_Q16      = 65536;
-
-        psEnc->sCmn.fs_kHz = fs_kHz;
-        if( psEnc->sCmn.fs_kHz == 8 ) {
-            if( psEnc->sCmn.nb_subfr == MAX_NB_SUBFR ) {
-                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_NB_iCDF; 
-            } else {
-                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_NB_iCDF;
-            }
-        } else {
-            if( psEnc->sCmn.nb_subfr == MAX_NB_SUBFR ) {
-                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_iCDF; 
-            } else {
-                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_iCDF;
-            }
-        }
-        if( psEnc->sCmn.fs_kHz == 8 || psEnc->sCmn.fs_kHz == 12 ) {
-            psEnc->sCmn.predictLPCOrder = MIN_LPC_ORDER;
-            psEnc->sCmn.psNLSF_CB  = &SKP_Silk_NLSF_CB_NB_MB;
-        } else {
-            psEnc->sCmn.predictLPCOrder = MAX_LPC_ORDER;
-            psEnc->sCmn.psNLSF_CB  = &SKP_Silk_NLSF_CB_WB;
-        }
-        psEnc->sCmn.subfr_length   = SUB_FRAME_LENGTH_MS * fs_kHz;
-        psEnc->sCmn.frame_length   = psEnc->sCmn.subfr_length * psEnc->sCmn.nb_subfr;
-        psEnc->sCmn.ltp_mem_length = LTP_MEM_LENGTH_MS * fs_kHz; 
-        psEnc->sCmn.la_pitch       = LA_PITCH_MS * fs_kHz;
-        psEnc->sCmn.max_pitch_lag = 18 * fs_kHz;
-        if( psEnc->sCmn.nb_subfr == MAX_NB_SUBFR ) {
-            psEnc->sCmn.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS, fs_kHz );
-        } else {
-            psEnc->sCmn.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS_2_SF, fs_kHz );
-        }
-        if( psEnc->sCmn.fs_kHz == 16 ) {
-            psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_WB, 9 );
-            psEnc->sCmn.pitch_lag_low_bits_iCDF = SKP_Silk_uniform8_iCDF;
-        } else if( psEnc->sCmn.fs_kHz == 12 ) {
-            psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_MB, 9 );
-            psEnc->sCmn.pitch_lag_low_bits_iCDF = SKP_Silk_uniform6_iCDF;
-        } else {
-            psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_NB, 9 );
-            psEnc->sCmn.pitch_lag_low_bits_iCDF = SKP_Silk_uniform4_iCDF;
-        }
-    }
-
-    /* Check that settings are valid */
-    SKP_assert( ( psEnc->sCmn.subfr_length * psEnc->sCmn.nb_subfr ) == psEnc->sCmn.frame_length );
- 
-    return( ret );
-}
-
-SKP_INLINE SKP_int SKP_Silk_setup_rate(
-    SKP_Silk_encoder_state_FLP      *psEnc,             /* I/O  Pointer to Silk encoder state FLP       */
-    SKP_int32                       TargetRate_bps      /* I    Target max bitrate                      */
-)
-{
-    SKP_int k, ret = SKP_SILK_NO_ERROR;
-    SKP_float frac;
-    const SKP_int32 *rateTable;
-
-    /* Set bitrate/coding quality */
-    if( TargetRate_bps != psEnc->sCmn.TargetRate_bps ) {
-        psEnc->sCmn.TargetRate_bps = TargetRate_bps;
-
-        /* If new TargetRate_bps, translate to SNR_dB value */
-        if( psEnc->sCmn.fs_kHz == 8 ) {
-            rateTable = TargetRate_table_NB;
-        } else if( psEnc->sCmn.fs_kHz == 12 ) {
-            rateTable = TargetRate_table_MB;
-        } else if( psEnc->sCmn.fs_kHz == 16 ) {
-            rateTable = TargetRate_table_WB;
-        } else {
-            SKP_assert( 0 );
-        }
-        /* Reduce bitrate for 10 ms modes in these calculations */
-        if( psEnc->sCmn.nb_subfr == 2 ) {
-            TargetRate_bps -= REDUCE_BITRATE_10_MS_BPS;
-        }
-        for( k = 1; k < TARGET_RATE_TAB_SZ; k++ ) {
-            /* Find bitrate interval in table and interpolate */
-            if( TargetRate_bps <= rateTable[ k ] ) {
-                frac = (SKP_float)( TargetRate_bps - rateTable[ k - 1 ] ) / 
-                       (SKP_float)( rateTable[ k ] - rateTable[ k - 1 ] );
-                psEnc->SNR_dB = 0.5f * ( SNR_table_Q1[ k - 1 ] + frac * ( SNR_table_Q1[ k ] - SNR_table_Q1[ k - 1 ] ) );
-                break;
-            }
-        }
-    }
-    return( ret );
-}
--- a/src_FLP/SKP_Silk_encode_frame_FLP.c
+++ b/src_FLP/SKP_Silk_encode_frame_FLP.c
@@ -38,8 +38,7 @@
 )
 {
     SKP_Silk_encoder_control_FLP sEncCtrl;
-    SKP_int     i, nBits, ret = 0;
-    SKP_uint8   flags;
+    SKP_int     i, ret = 0;
     SKP_float   *x_frame, *res_pitch_frame;
     SKP_int16   pIn_HP[ MAX_FRAME_LENGTH ];
     SKP_float   xfw[ MAX_FRAME_LENGTH ];
@@ -66,42 +65,26 @@
     /**************************************************/
     /* Convert speech activity into VAD and DTX flags */
     /**************************************************/
+    if( psEnc->sCmn.nFramesAnalyzed == 0 ) {
+        psEnc->sCmn.inDTX = psEnc->sCmn.useDTX;
+    }
     if( psEnc->sCmn.speech_activity_Q8 < SKP_FIX_CONST( SPEECH_ACTIVITY_DTX_THRES, 8 ) ) {
         psEnc->sCmn.indices.signalType = TYPE_NO_VOICE_ACTIVITY;
         psEnc->sCmn.noSpeechCounter++;
-        if( psEnc->sCmn.noSpeechCounter > NO_SPEECH_FRAMES_BEFORE_DTX ) {
-            psEnc->sCmn.inDTX = 1;
-        }
-        if( psEnc->sCmn.noSpeechCounter > MAX_CONSECUTIVE_DTX ) {
-            psEnc->sCmn.noSpeechCounter = 0;
+        if( psEnc->sCmn.noSpeechCounter < NB_SPEECH_FRAMES_BEFORE_DTX ) {
+            psEnc->sCmn.inDTX = 0;
+        } else if( psEnc->sCmn.noSpeechCounter > MAX_CONSECUTIVE_DTX + NB_SPEECH_FRAMES_BEFORE_DTX ) {
+            psEnc->sCmn.noSpeechCounter = NB_SPEECH_FRAMES_BEFORE_DTX;
             psEnc->sCmn.inDTX           = 0;
         }
         psEnc->sCmn.VAD_flags[ psEnc->sCmn.nFramesAnalyzed ] = 0;
     } else {
-        psEnc->sCmn.noSpeechCounter = 0;
-        psEnc->sCmn.inDTX           = 0;
+        psEnc->sCmn.noSpeechCounter    = 0;
+        psEnc->sCmn.inDTX              = 0;
         psEnc->sCmn.indices.signalType = TYPE_UNVOICED;
         psEnc->sCmn.VAD_flags[ psEnc->sCmn.nFramesAnalyzed ] = 1;
     }
 
-    if( psEnc->sCmn.nFramesAnalyzed == 0 && !psEnc->sCmn.prefillFlag && !( psEnc->sCmn.useDTX && psEnc->sCmn.inDTX ) ) {
-        /* Create space at start of payload for VAD and FEC flags */
-        SKP_uint8 iCDF[ 2 ] = { 0, 0 };
-        iCDF[ 0 ] = 256 - SKP_RSHIFT( 256, psEnc->sCmn.nFramesPerPacket + 1 );
-        ec_enc_icdf( psRangeEnc, 0, iCDF, 8 );
-
-        /* Encode any LBRR data from previous packet */
-        SKP_Silk_LBRR_embed( &psEnc->sCmn, psRangeEnc );
-
-        /* Reduce coding SNR depending on how many bits used by LBRR */
-        nBits = ec_tell( psRangeEnc );
-        psEnc->inBandFEC_SNR_comp = ( 6.0f * nBits ) / 
-            ( psEnc->sCmn.nFramesPerPacket * psEnc->sCmn.frame_length );
-
-        /* Reset LBRR flags */
-        SKP_memset( psEnc->sCmn.LBRR_flags, 0, sizeof( psEnc->sCmn.LBRR_flags ) );
-    }
-
     /*******************************************/
     /* High-pass filtering of the input signal */
     /*******************************************/
@@ -109,10 +92,8 @@
     SKP_Silk_HP_variable_cutoff( &psEnc->sCmn, pIn_HP, psEnc->sCmn.inputBuf, psEnc->sCmn.frame_length );
 TOC(HP_IN)
 
-#if SWITCH_TRANSITION_FILTERING
     /* Ensure smooth bandwidth transitions */
     SKP_Silk_LP_variable_cutoff( &psEnc->sCmn.sLP, pIn_HP, psEnc->sCmn.frame_length );
-#endif
 
     /*******************************************/
     /* Copy new frame to front of input buffer */
@@ -182,7 +163,7 @@
     psEnc->sCmn.prevSignalType = psEnc->sCmn.indices.signalType;
 
     /* Exit without entropy coding */
-    if( psEnc->sCmn.prefillFlag || ( psEnc->sCmn.useDTX && psEnc->sCmn.inDTX ) ) {
+    if( psEnc->sCmn.prefillFlag ) {
         /* No payload */
         *pnBytesOut = 0;
         return ret;
@@ -204,36 +185,15 @@
 TOC(ENCODE_PULSES)
 
     /****************************************/
-    /* Simulate network buffer delay caused */
-    /* by exceeding TargetRate              */
-    /****************************************/
-    nBits = ec_tell( psRangeEnc );
-    psEnc->BufferedInChannel_ms += 1000.0f * ( nBits - psEnc->sCmn.prev_nBits ) / psEnc->sCmn.TargetRate_bps;
-    psEnc->BufferedInChannel_ms -= psEnc->sCmn.nb_subfr * SUB_FRAME_LENGTH_MS;
-    psEnc->BufferedInChannel_ms  = SKP_LIMIT_float( psEnc->BufferedInChannel_ms, 0.0f, 100.0f );
-    psEnc->sCmn.prev_nBits = nBits;
-    psEnc->sCmn.first_frame_after_reset = 0;
-
-    /****************************************/
     /* Finalize payload                     */
     /****************************************/
+    psEnc->sCmn.first_frame_after_reset = 0;
     if( ++psEnc->sCmn.nFramesAnalyzed >= psEnc->sCmn.nFramesPerPacket ) {
-        /* Insert VAD flags and FEC flag at beginning of bitstream */
-        flags = 0;
-        for( i = 0; i < psEnc->sCmn.nFramesPerPacket; i++ ) {
-            flags |= psEnc->sCmn.VAD_flags[i];
-            flags  = SKP_LSHIFT( flags, 1 );
-        }
-        flags |= psEnc->sCmn.LBRR_flag;
-        ec_enc_patch_initial_bits( psRangeEnc, flags, psEnc->sCmn.nFramesPerPacket + 1 );
-
         /* Payload size */
-        nBits = ec_tell( psRangeEnc );
-        *pnBytesOut = SKP_RSHIFT( nBits + 7, 3 );
+        *pnBytesOut = SKP_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 );
 
         /* Reset the number of frames in payload buffer */
         psEnc->sCmn.nFramesAnalyzed = 0;
-        psEnc->sCmn.prev_nBits = 0;
     } else {
         /* No payload this time */
         *pnBytesOut = 0;
@@ -248,8 +208,6 @@
     DEBUG_STORE_DATA( LTPcorr.dat,              &psEnc->LTPCorr,                                                sizeof( SKP_float ) );
     DEBUG_STORE_DATA( gains.dat,                sEncCtrl.Gains,                          psEnc->sCmn.nb_subfr * sizeof( SKP_float ) );
     DEBUG_STORE_DATA( gains_indices.dat,        &psEnc->sCmn.indices.GainsIndices,       psEnc->sCmn.nb_subfr * sizeof( SKP_int8  ) );
-    DEBUG_STORE_DATA( nBits.dat,                &nBits,                                                         sizeof( SKP_int   ) );
-    DEBUG_STORE_DATA( current_SNR_db.dat,       &sEncCtrl.current_SNR_dB,                                       sizeof( SKP_float ) );
     DEBUG_STORE_DATA( quantOffsetType.dat,      &psEnc->sCmn.indices.quantOffsetType,                           sizeof( SKP_int8  ) );
     DEBUG_STORE_DATA( speech_activity_q8.dat,   &psEnc->sCmn.speech_activity_Q8,                                sizeof( SKP_int   ) );
     DEBUG_STORE_DATA( signalType.dat,           &psEnc->sCmn.indices.signalType,                                sizeof( SKP_int8  ) ); 
@@ -289,7 +247,6 @@
         /* Save original gains */
         SKP_memcpy( TempGains, psEncCtrl->Gains, psEnc->sCmn.nb_subfr * sizeof( SKP_float ) );
 
-
         if( psEnc->sCmn.nFramesAnalyzed == 0 || psEnc->sCmn.LBRR_flags[ psEnc->sCmn.nFramesAnalyzed - 1 ] == 0 ) {
             /* First frame in packet or previous frame not LBRR coded */
             psEnc->sCmn.LBRRprevLastGainIndex = psEnc->sShape.LastGainIndex;
@@ -314,7 +271,7 @@
         SKP_Silk_NSQ_wrapper_FLP( psEnc, psEncCtrl, psIndices_LBRR, &sNSQ_LBRR, 
             psEnc->sCmn.pulses_LBRR[ psEnc->sCmn.nFramesAnalyzed ], xfw );
 
-        /* Restore original Gains */
+        /* Restore original gains */
         SKP_memcpy( psEncCtrl->Gains, TempGains, psEnc->sCmn.nb_subfr * sizeof( SKP_float ) );
     }
 }
--- a/src_FLP/SKP_Silk_init_encoder_FLP.c
+++ /dev/null
@@ -1,52 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. 
-Redistribution and use in source and binary forms, with or without 
-modification, (subject to the limitations in the disclaimer below) 
-are permitted provided that the following conditions are met:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright 
-notice, this list of conditions and the following disclaimer in the 
-documentation and/or other materials provided with the distribution.
-- Neither the name of Skype Limited, nor the names of specific 
-contributors, may be used to endorse or promote products derived from 
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-***********************************************************************/
-
-#include <stdlib.h>
-#include "SKP_Silk_main_FLP.h"
-
-/*********************************/
-/* Initialize Silk Encoder state */
-/*********************************/
-SKP_int SKP_Silk_init_encoder_FLP(
-    SKP_Silk_encoder_state_FLP      *psEnc              /* I/O  Encoder state FLP                       */
-) {
-    SKP_int ret = 0;
-
-    /* Clear the entire encoder state */
-    SKP_memset( psEnc, 0, sizeof( SKP_Silk_encoder_state_FLP ) );
-
-    psEnc->sCmn.variable_HP_smth1_Q15 = 200844; /* = SKP_Silk_log2(70)_Q0; */
-    psEnc->sCmn.variable_HP_smth2_Q15 = 200844; /* = SKP_Silk_log2(70)_Q0; */
-
-    /* Used to deactivate e.g. LSF interpolation and fluctuation reduction */
-    psEnc->sCmn.first_frame_after_reset = 1;
-
-    /* Initialize Silk VAD */
-    ret += SKP_Silk_VAD_Init( &psEnc->sCmn.sVAD );
-
-    return( ret );
-}
--- a/src_FLP/SKP_Silk_main_FLP.h
+++ b/src_FLP/SKP_Silk_main_FLP.h
@@ -36,9 +36,6 @@
 #include "SKP_debug.h"
 #include "entenc.h"
 
-/* uncomment to compile without SSE optimizations */
-//#undef SKP_USE_SSE
-
 #ifdef __cplusplus
 extern "C"
 {
@@ -63,17 +60,15 @@
 );
 
 /* Initializes the Silk encoder state */
-SKP_int SKP_Silk_init_encoder_FLP(
+SKP_int SKP_Silk_init_encoder(
     SKP_Silk_encoder_state_FLP      *psEnc              /* I/O  Encoder state FLP                       */
 );
 
 /* Control the Silk encoder */
-SKP_int SKP_Silk_control_encoder_FLP( 
-    SKP_Silk_encoder_state_FLP  *psEnc,                 /* I/O  Pointer to Silk encoder state FLP       */
-    const SKP_int               PacketSize_ms,          /* I    Packet length (ms)                      */
-    const SKP_int32             TargetRate_bps,         /* I    Target max bitrate (bps)                */
-    const SKP_int               PacketLoss_perc,        /* I    Packet loss rate (in percent)           */
-    const SKP_int               Complexity              /* I    Complexity (0-10)                       */
+SKP_int SKP_Silk_control_encoder( 
+    SKP_Silk_encoder_state_FLP      *psEnc,             /* I/O  Pointer to Silk encoder state FLP       */
+    SKP_SILK_SDK_EncControlStruct   *encControl,        /* I:   Control structure                       */
+    const SKP_int32                 TargetRate_bps      /* I    Target max bitrate (bps)                */
 );
 
 /****************/
--- a/src_FLP/SKP_Silk_noise_shape_analysis_FLP.c
+++ b/src_FLP/SKP_Silk_noise_shape_analysis_FLP.c
@@ -139,24 +139,16 @@
     x_ptr = x - psEnc->sCmn.la_shape;
 
     /****************/
-    /* CONTROL SNR  */
-    /****************/
-    /* Reduce SNR_dB values if recent bitstream has exceeded TargetRate */
-    psEncCtrl->current_SNR_dB = psEnc->SNR_dB - 0.1f * psEnc->BufferedInChannel_ms;
-
-    /* Reduce SNR_dB because of any inband FEC used */
-    psEncCtrl->current_SNR_dB -= psEnc->inBandFEC_SNR_comp;
-
-    /****************/
     /* GAIN CONTROL */
     /****************/
+    SNR_adj_dB = psEnc->sCmn.SNR_dB_Q7 * ( 1 / 128.0f );
+
     /* Input quality is the average of the quality in the lowest two VAD bands */
     psEncCtrl->input_quality = 0.5f * ( psEnc->sCmn.input_quality_bands_Q15[ 0 ] + psEnc->sCmn.input_quality_bands_Q15[ 1 ] ) * ( 1.0f / 32768.0f );
 
     /* Coding quality level, between 0.0 and 1.0 */
-    psEncCtrl->coding_quality = SKP_sigmoid( 0.25f * ( psEncCtrl->current_SNR_dB - 18.0f ) );
+    psEncCtrl->coding_quality = SKP_sigmoid( 0.25f * ( SNR_adj_dB - 18.0f ) );
 
-    SNR_adj_dB = psEncCtrl->current_SNR_dB;
     if( psEnc->sCmn.useCBR == 0 ) {
         /* Reduce coding SNR during low speech activity */
         b = 1.0f - psEnc->sCmn.speech_activity_Q8 * ( 1.0f /  256.0f );
@@ -168,7 +160,7 @@
         SNR_adj_dB += HARM_SNR_INCR_dB * psEnc->LTPCorr;
     } else { 
         /* For unvoiced signals and low-quality input, adjust the quality slower than SNR_dB setting */
-        SNR_adj_dB += ( -0.4f * psEncCtrl->current_SNR_dB + 6.0f ) * ( 1.0f - psEncCtrl->input_quality );
+        SNR_adj_dB += ( -0.4f * psEnc->sCmn.SNR_dB_Q7 * ( 1 / 128.0f ) + 6.0f ) * ( 1.0f - psEncCtrl->input_quality );
     }
 
     /*************************/
--- a/src_FLP/SKP_Silk_process_gains_FLP.c
+++ b/src_FLP/SKP_Silk_process_gains_FLP.c
@@ -48,7 +48,7 @@
     }
 
     /* Limit the quantized signal */
-    InvMaxSqrVal = ( SKP_float )( pow( 2.0f, 0.33f * ( 21.0f - psEncCtrl->current_SNR_dB ) ) / psEnc->sCmn.subfr_length );
+    InvMaxSqrVal = ( SKP_float )( pow( 2.0f, 0.33f * ( 21.0f - psEnc->sCmn.SNR_dB_Q7 * ( 1 / 128.0f ) ) ) / psEnc->sCmn.subfr_length );
 
     for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) {
         /* Soft limit on ratio residual energy and squared gains */
--- a/src_FLP/SKP_Silk_structs_FLP.h
+++ b/src_FLP/SKP_Silk_structs_FLP.h
@@ -30,6 +30,7 @@
 
 #include "SKP_Silk_typedef.h"
 #include "SKP_Silk_main.h"
+#include "SKP_Silk_structs.h"
 
 #ifdef __cplusplus
 extern "C"
@@ -71,17 +72,12 @@
     /* Buffer for find pitch and noise shape analysis */
     SKP_float                           x_buf[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ];/* Buffer for find pitch and noise shape analysis */
     SKP_float                           LTPCorr;                    /* Normalized correlation from pitch lag estimator */
-    SKP_float                           SNR_dB;                     /* Quality setting */
-    SKP_float                           BufferedInChannel_ms;       /* Simulated number of ms buffer in channel because of exceeded TargetRate_bps */
 
     /* Parameters for LTP scaling control */
     SKP_float                           prevLTPredCodGain;
     SKP_float                           HPLTPredCodGain;
-
-    SKP_float                           inBandFEC_SNR_comp;         /* Compensation to SNR_DB when using inband FEC Voiced */
 } SKP_Silk_encoder_state_FLP;
 
-
 /************************/
 /* Encoder control FLP  */
 /************************/
@@ -105,7 +101,6 @@
 	SKP_float					Lambda;
 	SKP_float					input_quality;
 	SKP_float					coding_quality;
-	SKP_float					current_SNR_dB;
 
 	/* Measures */
 	SKP_float					sparseness;
--- a/src_FLP/src_FLP.vcxproj
+++ b/src_FLP/src_FLP.vcxproj
@@ -80,7 +80,6 @@
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="SKP_Silk_apply_sine_window_FLP.c" />
-    <ClCompile Include="SKP_Silk_control_codec_FLP.c" />
     <ClCompile Include="SKP_Silk_corrMatrix_FLP.c" />
     <ClCompile Include="SKP_Silk_encode_frame_FLP.c" />
     <ClCompile Include="SKP_Silk_find_LPC_FLP.c" />
@@ -87,7 +86,6 @@
     <ClCompile Include="SKP_Silk_find_LTP_FLP.c" />
     <ClCompile Include="SKP_Silk_find_pitch_lags_FLP.c" />
     <ClCompile Include="SKP_Silk_find_pred_coefs_FLP.c" />
-    <ClCompile Include="SKP_Silk_init_encoder_FLP.c" />
     <ClCompile Include="SKP_Silk_LPC_analysis_filter_FLP.c" />
     <ClCompile Include="SKP_Silk_LTP_analysis_filter_FLP.c" />
     <ClCompile Include="SKP_Silk_LTP_scale_ctrl_FLP.c" />
--- a/src_FLP/src_FLP.vcxproj.filters
+++ b/src_FLP/src_FLP.vcxproj.filters
@@ -32,9 +32,6 @@
     <ClCompile Include="SKP_Silk_apply_sine_window_FLP.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="SKP_Silk_control_codec_FLP.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="SKP_Silk_corrMatrix_FLP.c">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -51,9 +48,6 @@
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="SKP_Silk_find_pred_coefs_FLP.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="SKP_Silk_init_encoder_FLP.c">
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="SKP_Silk_LPC_analysis_filter_FLP.c">
--- a/src_SigProc_FIX/SKP_Silk_SigProc_FIX.h
+++ b/src_SigProc_FIX/SKP_Silk_SigProc_FIX.h
@@ -399,13 +399,6 @@
     const SKP_int        D                   /* I   order                                                           */
 );
 
-/* Multiply a vector by a constant */
-void SKP_Silk_scale_vector16_Q14( 
-    SKP_int16            *data1, 
-    SKP_int              gain_Q14,           /* Gain in Q14 */ 
-    SKP_int              dataSize
-);
-
 /* Copy and multiply a vector by a constant */
 void SKP_Silk_scale_copy_vector16( 
     SKP_int16            *data_out, 
@@ -414,19 +407,6 @@
     const SKP_int        dataSize            /* I:   length        */
 );
 
-void SKP_Silk_scale_vector32_16_Q14( 
-    SKP_int32            *data1,             /* I/O: Q0/Q0         */
-    SKP_int              gain_Q14,           /* I:   Q14           */
-    SKP_int              dataSize            /* I:   length        */
-);
-
-/* Multiply a vector by a constant, does not saturate output data */
-void SKP_Silk_scale_vector32_Q16( 
-    SKP_int32            *data1,             /* I/O: Q0/Q0         */
-    SKP_int32            gain_Q16,           /* I:   gain in Q16 ( SKP_int16_MIN <= gain_Q16 <= SKP_int16_MAX + 65536 ) */
-    const SKP_int        dataSize            /* I:   length        */
-);
-
 /* Some for the LTP related function requires Q26 to work.*/
 void SKP_Silk_scale_vector32_Q26_lshift_18( 
     SKP_int32            *data1,             /* I/O: Q0/Q18        */
@@ -439,30 +419,25 @@
 /********************************************************************/
 
 /*    return sum(inVec1[i]*inVec2[i])    */
-/*    inVec1 and inVec2 should be increasing ordered, and starting address should be 4 byte aligned. (a factor of 4)*/
 SKP_int32 SKP_Silk_inner_prod_aligned(
-    const SKP_int16* const inVec1,           /* I   input vector 1    */ 
-    const SKP_int16* const inVec2,           /* I   input vector 2    */
-    const SKP_int          len               /* I   vector lengths    */
+    const SKP_int16 *const  inVec1,     /*    I input vector 1    */
+    const SKP_int16 *const  inVec2,     /*    I input vector 2    */
+    const SKP_int           len         /*    I vector lengths    */
 );
 
-SKP_int32 SKP_Silk_inner_prod16_aligned_sat(
-    const SKP_int16* const inVec1,           /* I   input vector 1  */
-    const SKP_int16* const inVec2,           /* I   input vector 2  */
-    const SKP_int          len               /* I   vector lengths  */
+SKP_int32 SKP_Silk_inner_prod_aligned_scale(
+    const SKP_int16 *const  inVec1,     /*    I input vector 1          */
+    const SKP_int16 *const  inVec2,     /*    I input vector 2          */
+    const SKP_int           scale,      /*    I number of bits to shift */
+    const SKP_int           len         /*    I vector lengths          */
 );
 
-SKP_int64 SKP_Silk_inner_prod_aligned_64(
-    const SKP_int32        *inVec1,          /* I   input vector 1    */
-    const SKP_int32        *inVec2,          /* I   input vector 2    */
-    const SKP_int          len               /* I   vector lengths    */
-);
-
 SKP_int64 SKP_Silk_inner_prod16_aligned_64(
-    const SKP_int16        *inVec1,          /* I   input vector 1    */
-    const SKP_int16        *inVec2,          /* I   input vector 2    */
-    const SKP_int          len               /* I   vector lengths    */
+    const SKP_int16         *inVec1,    /*    I input vector 1    */ 
+    const SKP_int16         *inVec2,    /*    I input vector 2    */
+    const SKP_int           len         /*    I vector lengths    */
 );
+
 /********************************************************************/
 /*                                MACROS                            */
 /********************************************************************/
--- a/src_SigProc_FIX/SKP_Silk_allpass_int.c
+++ /dev/null
@@ -1,69 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. 
-Redistribution and use in source and binary forms, with or without 
-modification, (subject to the limitations in the disclaimer below) 
-are permitted provided that the following conditions are met:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright 
-notice, this list of conditions and the following disclaimer in the 
-documentation and/or other materials provided with the distribution.
-- Neither the name of Skype Limited, nor the names of specific 
-contributors, may be used to endorse or promote products derived from 
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-***********************************************************************/
-
-/*                                                                        *
- * SKP_Silk_allpass_int.c                                               *
- *                                                                        *
- * First-order allpass filter with                                        *
- * transfer function:                                                     *
- *                                                                        *
- *         A + Z^(-1)                                                     *
- * H(z) = ------------                                                    *
- *        1 + A*Z^(-1)                                                    *
- *                                                                        *
- * Implemented using minimum multiplier filter design.                    *
- *                                                                        *
- * Reference: http://www.univ.trieste.it/~ramponi/teaching/               *
- * DSP/materiale/Ch6(2).pdf                                               *
- *                                                                        *
- * Copyright 2007 (c), Skype Limited                                      *
- * Date: 070525                                                           *
- *                                                                        */
-#include "SKP_Silk_SigProc_FIX.h"
-
-
-/* First-order allpass filter */
-void SKP_Silk_allpass_int(
-    const SKP_int32      *in,    /* I:    Q25 input signal [len]               */
-    SKP_int32            *S,     /* I/O:  Q25 state [1]                         */
-    SKP_int              A,      /* I:    Q15 coefficient    (0 <= A < 32768)  */
-    SKP_int32            *out,   /* O:    Q25 output signal [len]              */
-    const SKP_int32      len     /* I:    Number of samples                    */
-)
-{
-    SKP_int32    Y2, X2, S0;
-    SKP_int        k;
-
-    S0 = S[ 0 ];
-    for( k = len - 1; k >= 0; k-- ) {
-        Y2         = *in - S0;
-        X2         = ( Y2 >> 15 ) * A + ( ( ( Y2 & 0x00007FFF ) * A ) >> 15 );
-        ( *out++ ) = S0 + X2;
-        S0         = ( *in++ ) + X2;
-    }
-    S[ 0 ] = S0;
-}
--- a/src_SigProc_FIX/SKP_Silk_autocorr.c
+++ b/src_SigProc_FIX/SKP_Silk_autocorr.c
@@ -25,15 +25,6 @@
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***********************************************************************/
 
-/*                                                                      *
- * SKP_Silk_autocorr.c                                                *
- *                                                                      *
- * Calculates the autocorrelation                                       *
- * The result has 29 non-zero bits for the first correlation, to leave  *
- * some    room for adding white noise fractions etc.                   *
- *                                                                      *
- * Copyright 2008 (c), Skype Limited                                    *
- *                                                                      */
 #include "SKP_Silk_SigProc_FIX.h"
 
 /* Compute autocorrelation */
--- a/src_SigProc_FIX/SKP_Silk_debug.c
+++ b/src_SigProc_FIX/SKP_Silk_debug.c
@@ -37,6 +37,8 @@
 #include "SKP_debug.h"
 #include "../src_SigProc_FIX/SKP_Silk_SigProc_FIX.h"
 
+#if SKP_TIC_TOC
+
 #ifdef _WIN32
 
 #if (defined(_WIN32) || defined(_WINCE)) 
@@ -64,8 +66,6 @@
     return((tv.tv_sec*1000000)+(tv.tv_usec));
 }
 #endif
-
-#if SKP_TIC_TOC
 
 int           SKP_Timer_nTimers = 0;
 int           SKP_Timer_depth_ctr = 0;
--- a/src_SigProc_FIX/SKP_Silk_inner_prod_aligned.c
+++ b/src_SigProc_FIX/SKP_Silk_inner_prod_aligned.c
@@ -34,9 +34,9 @@
 /*        * only when len>6, memory access can be reduced by half.              */
 
 SKP_int32 SKP_Silk_inner_prod_aligned(
-    const SKP_int16* const inVec1,  /*    I input vector 1    */
-    const SKP_int16* const inVec2,  /*    I input vector 2    */
-    const SKP_int             len   /*    I vector lengths    */
+    const SKP_int16 *const  inVec1,     /*    I input vector 1    */
+    const SKP_int16 *const  inVec2,     /*    I input vector 2    */
+    const SKP_int           len         /*    I vector lengths    */
 )
 {
     SKP_int   i; 
@@ -47,23 +47,25 @@
     return sum;
 }
 
-SKP_int64 SKP_Silk_inner_prod_aligned_64(
-    const SKP_int32 *inVec1,        /*    I input vector 1    */ 
-    const SKP_int32 *inVec2,        /*    I input vector 2    */
-    const SKP_int   len             /*    I vector lengths    */
+SKP_int32 SKP_Silk_inner_prod_aligned_scale(
+    const SKP_int16 *const  inVec1,     /*    I input vector 1          */
+    const SKP_int16 *const  inVec2,     /*    I input vector 2          */
+    const SKP_int           scale,      /*    I number of bits to shift */
+    const SKP_int           len         /*    I vector lengths          */
 )
 {
     SKP_int   i; 
-    SKP_int64 sum = 0;
+    SKP_int32 sum = 0;
     for( i = 0; i < len; i++ ) {
-        sum = SKP_SMLAL( sum, inVec1[ i ], inVec2[ i ] );
+        sum = SKP_ADD_RSHIFT32( sum, SKP_SMULBB( inVec1[ i ], inVec2[ i ] ), scale );
     }
     return sum;
 }
+
 SKP_int64 SKP_Silk_inner_prod16_aligned_64(
-    const SKP_int16 *inVec1,        /*    I input vector 1    */ 
-    const SKP_int16 *inVec2,        /*    I input vector 2    */
-    const SKP_int   len             /*    I vector lengths    */
+    const SKP_int16         *inVec1,    /*    I input vector 1    */ 
+    const SKP_int16         *inVec2,    /*    I input vector 2    */
+    const SKP_int           len         /*    I vector lengths    */
 )
 {
     SKP_int   i; 
@@ -70,20 +72,6 @@
     SKP_int64 sum = 0;
     for( i = 0; i < len; i++ ) {
         sum = SKP_SMLALBB( sum, inVec1[ i ], inVec2[ i ] );
-    }
-    return sum;
-}
-
-SKP_int32 SKP_Silk_inner_prod16_aligned_sat(
-    const SKP_int16* const inVec1,  /*    I input vector 1  */ 
-    const SKP_int16* const inVec2,  /*    I input vector 2  */
-    const SKP_int    len            /*    I vector lengths  */ 
-)
-{
-    SKP_int   i; 
-    SKP_int32 sum = 0;
-    for( i = 0; i < len; i++ ) {
-        sum = SKP_ADD_SAT32( sum, SKP_SMULBB( inVec1[ i ], inVec2[ i ] ) );
     }
     return sum;
 }
--- a/src_SigProc_FIX/SKP_Silk_lowpass_int.c
+++ /dev/null
@@ -1,61 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. 
-Redistribution and use in source and binary forms, with or without 
-modification, (subject to the limitations in the disclaimer below) 
-are permitted provided that the following conditions are met:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright 
-notice, this list of conditions and the following disclaimer in the 
-documentation and/or other materials provided with the distribution.
-- Neither the name of Skype Limited, nor the names of specific 
-contributors, may be used to endorse or promote products derived from 
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-***********************************************************************/
-
-/*                                                                      *
- * SKP_Silk_lowpass_int.c                                             *
- *                                                                      *
- * First order low-pass filter, with input as SKP_int32, running at     *
- * 48 kHz                                                               *
- *                                                                      *
- * Copyright 2006 (c), Skype Limited                                    *
- * Date: 060221                                                         *
- *                                                                      */
-#include "SKP_Silk_SigProc_FIX.h"
-
-/* First order low-pass filter, with input as SKP_int32, running at 48 kHz        */
-void SKP_Silk_lowpass_int(
-    const SKP_int32      *in,            /* I:    Q25 48 kHz signal; length = len */
-    SKP_int32            *S,             /* I/O: Q25 state; length = 1            */
-    SKP_int32            *out,           /* O:    Q25 48 kHz signal; length = len */
-    const SKP_int32      len             /* I:    Number of samples               */
-)
-{
-    SKP_int        k;
-    SKP_int32    in_tmp, out_tmp, state;
-    
-    state = S[ 0 ];
-    for( k = len; k > 0; k-- ) {    
-        in_tmp  = *in++;
-        in_tmp -= SKP_RSHIFT( in_tmp, 2 );              /* multiply by 0.75 */
-        out_tmp = state + in_tmp;                       /* zero at nyquist  */
-        state   = in_tmp - SKP_RSHIFT( out_tmp, 1 );    /* pole             */
-        *out++  = out_tmp;
-    }
-    S[ 0 ] = state;
-}
-
-
--- a/src_SigProc_FIX/SKP_Silk_lowpass_short.c
+++ /dev/null
@@ -1,61 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. 
-Redistribution and use in source and binary forms, with or without 
-modification, (subject to the limitations in the disclaimer below) 
-are permitted provided that the following conditions are met:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright 
-notice, this list of conditions and the following disclaimer in the 
-documentation and/or other materials provided with the distribution.
-- Neither the name of Skype Limited, nor the names of specific 
-contributors, may be used to endorse or promote products derived from 
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-***********************************************************************/
-
-/*                                                                      *
- * SKP_Silk_lowpass_short.c                                           *
- *                                                                      *
- * First order low-pass filter, with input as SKP_int16, running at     *
- * 48 kHz                                                               *
- *                                                                      *
- * Copyright 2006 (c), Skype Limited                                    *
- * Date: 060221                                                         *
- *                                                                      */
-#include "SKP_Silk_SigProc_FIX.h"
-
-
-/* First order low-pass filter, with input as SKP_int16, running at 48 kHz   */
-void SKP_Silk_lowpass_short(
-    const SKP_int16          *in,        /* I:   Q15 48 kHz signal; [len]    */
-    SKP_int32                *S,         /* I/O: Q25 state; length = 1       */
-    SKP_int32                *out,       /* O:   Q25 48 kHz signal; [len]    */
-    const SKP_int32          len         /* O:   Signal length               */
-)
-{
-    SKP_int        k;
-    SKP_int32    in_tmp, out_tmp, state;
-    
-    state = S[ 0 ];
-    for( k = 0; k < len; k++ ) {    
-        in_tmp   = SKP_MUL( 768, (SKP_int32)in[k] );    /* multiply by 0.75, going from Q15 to Q25 */
-        out_tmp  = state + in_tmp;                      /* zero at nyquist                         */
-        state    = in_tmp - SKP_RSHIFT( out_tmp, 1 );   /* pole                                    */
-        out[ k ] = out_tmp;
-    }
-    S[ 0 ] = state;
-}
-
-
--- a/src_SigProc_FIX/SKP_Silk_resampler_private_up2_HQ.c
+++ b/src_SigProc_FIX/SKP_Silk_resampler_private_up2_HQ.c
@@ -25,14 +25,6 @@
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***********************************************************************/
 
-/*                                                                      *
- * SKP_Silk_resampler_private_up2_HQ.c                                *
- *                                                                      *
- * Upsample by a factor 2, high quality                                 *
- *                                                                      *
- * Copyright 2010 (c), Skype Limited                                    *
- *                                                                      */
-
 #include "SKP_Silk_SigProc_FIX.h"
 #include "SKP_Silk_resampler_private.h"
 
--- a/src_SigProc_FIX/SKP_Silk_resampler_private_up4.c
+++ b/src_SigProc_FIX/SKP_Silk_resampler_private_up4.c
@@ -25,18 +25,10 @@
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***********************************************************************/
 
-/*                                                                      *
- * SKP_Silk_resampler_private_up4.c                                   *
- *                                                                      *
- * Upsample by a factor 4, low quality                                  *
- *                                                                      *
- * Copyright 2010 (c), Skype Limited                                    *
- *                                                                      */
-
 #include "SKP_Silk_SigProc_FIX.h"
 #include "SKP_Silk_resampler_private.h"
 
-/* Upsample by a factor 4, Note: very low quality, only use with output sampling rates above 96 kHz. */
+/* Upsample by a factor 4, Note: low quality, only use with output sampling rates above 96 kHz. */
 void SKP_Silk_resampler_private_up4(
     SKP_int32                       *S,             /* I/O: State vector [ 2 ]                      */
     SKP_int16                       *out,           /* O:   Output signal [ 4 * len ]               */
--- a/src_SigProc_FIX/SKP_Silk_resampler_rom.h
+++ b/src_SigProc_FIX/SKP_Silk_resampler_rom.h
@@ -25,18 +25,6 @@
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***********************************************************************/
 
-/*                                                                      *
- * File Name:    SKP_Silk_resample_rom.h                              *
- *                                                                      *
- * Description: Header file for FIR resampling of                       *
- *                32 and 44 kHz input                                   *
- *                                                                      *
- * Copyright 2007 (c), Skype Limited                                    *
- * All rights reserved.                                                 *
- *                                                                      *
- * Date: 070807                                                         *
- *                                                                      */
-
 #ifndef _SKP_SILK_FIX_RESAMPLER_ROM_H_
 #define _SKP_SILK_FIX_RESAMPLER_ROM_H_
 
--- a/src_SigProc_FIX/SKP_Silk_resampler_structs.h
+++ b/src_SigProc_FIX/SKP_Silk_resampler_structs.h
@@ -43,7 +43,7 @@
 #endif
 
 /* Flag to enable support for input/output sampling rates above 48 kHz. Turn off for embedded devices */
-#define RESAMPLER_SUPPORT_ABOVE_48KHZ                   1
+#define RESAMPLER_SUPPORT_ABOVE_48KHZ                    1
 
 #define SKP_Silk_RESAMPLER_MAX_FIR_ORDER                 16
 #define SKP_Silk_RESAMPLER_MAX_IIR_ORDER                 6
--- a/src_SigProc_FIX/SKP_Silk_scale_vector.c
+++ b/src_SigProc_FIX/SKP_Silk_scale_vector.c
@@ -28,25 +28,6 @@
 #include "SKP_Silk_SigProc_FIX.h"
 
 /* Multiply a vector by a constant */
-void SKP_Silk_scale_vector16_Q14( 
-    SKP_int16           *data1, 
-    SKP_int             gain_Q14,       /* Gain in Q14 */ 
-    SKP_int             dataSize
-)
-{
-    SKP_int   i;
-    SKP_int32 gain_Q16;
-
-    SKP_assert( gain_Q14 <   32768 );
-    SKP_assert( gain_Q14 >= -32768 );
-
-    gain_Q16 = SKP_LSHIFT( gain_Q14, 2 );
-    for( i = 0; i < dataSize; i ++ ) {
-        data1[ i ] = SKP_SMULWB( gain_Q16, data1[ i ] );
-    }
-}
-
-/* Multiply a vector by a constant */
 void SKP_Silk_scale_vector32_Q26_lshift_18( 
     SKP_int32           *data1,                     /* (I/O): Q0/Q18        */
     SKP_int32           gain_Q26,                   /* (I):   Q26           */
@@ -57,51 +38,5 @@
 
     for( i = 0; i < dataSize; i++ ) {
         data1[ i ] = (SKP_int32)SKP_CHECK_FIT32( SKP_RSHIFT64( SKP_SMULL( data1[ i ], gain_Q26 ), 8 ) );// OUTPUT: Q18
-    }
-}
-
-/* Multiply a vector by a constant */
-void SKP_Silk_scale_vector32_16_Q14( 
-    SKP_int32           *data1,                     /* (I/O): Q0/Q0         */
-    SKP_int             gain_Q14,                   /* (I):   Q14           */
-    SKP_int             dataSize                    /* (I):   length        */
-)
-{
-    SKP_int  i, gain_Q16;
-
-    if( gain_Q14 < ( SKP_int16_MAX >> 2 ) ) {
-        gain_Q16 = SKP_LSHIFT( gain_Q14, 2 );
-        for( i = 0; i < dataSize; i++ ) {
-            data1[ i ] = SKP_SMULWB( data1[ i ], gain_Q16 );
-        }
-    } else {
-        SKP_assert( gain_Q14 >= SKP_int16_MIN );
-        for( i = 0; i < dataSize; i++ ) {
-            data1[ i ] = SKP_LSHIFT( SKP_SMULWB( data1[ i ], gain_Q14 ), 2 );
-        }
-    }
-}
-
-/* Multiply a vector by a constant, does not saturate output data */
-void SKP_Silk_scale_vector32_Q16( 
-    SKP_int32           *data1,                     /* (I/O): Q0/Q0         */
-    SKP_int32           gain_Q16,                   /* (I):   gain in Q16 ( SKP_int16_MIN <= gain_Q16 <= SKP_int16_MAX + 65536 ) */
-    const SKP_int       dataSize                    /* (I):   length        */
-)
-{
-    SKP_int     i;
-
-    SKP_assert( gain_Q16 <= SKP_int16_MAX + 65536 );
-    SKP_assert( gain_Q16 >= SKP_int16_MIN );
-
-    if( gain_Q16 > SKP_int16_MAX ) {
-        gain_Q16 -= 65536;
-        for( i = 0; i < dataSize; i++ ) {
-            data1[ i ] = SKP_SMLAWB( data1[ i ], data1[ i ], gain_Q16 );
-        }
-    } else {
-        for( i = 0; i < dataSize; i++ ) {
-            data1[ i ] = SKP_SMULWB( data1[ i ], gain_Q16 );
-        }
     }
 }
--- a/src_SigProc_FIX/SKP_Silk_schur64.c
+++ b/src_SigProc_FIX/SKP_Silk_schur64.c
@@ -25,20 +25,11 @@
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***********************************************************************/
 
-/*                                                                      *
- * SKP_Silk_schur64.c                                                 *
- *                                                                      *
- * Calculates the reflection coefficients from the correlation sequence *
- * using extra precision                                                *
- *                                                                      *
- * Copyright 2008 (c), Skype Limited                                    *
- * Date: 080103                                                         *
- *                                                                      */
 #include "SKP_Silk_SigProc_FIX.h"
 
 /* Slower than schur(), but more accurate.                              */
 /* Uses SMULL(), available on armv4                                     */ 
-SKP_int32 SKP_Silk_schur64(                    /* O:    Returns residual energy                     */
+SKP_int32 SKP_Silk_schur64(                      /* O:    Returns residual energy                     */
     SKP_int32            rc_Q16[],               /* O:    Reflection coefficients [order] Q16         */
     const SKP_int32      c[],                    /* I:    Correlations [order+1]                      */
     SKP_int32            order                   /* I:    Prediction order                            */
--- a/src_SigProc_FIX/SKP_Silk_sum_sqr_shift.c
+++ b/src_SigProc_FIX/SKP_Silk_sum_sqr_shift.c
@@ -25,15 +25,8 @@
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***********************************************************************/
 
-/*                                                                      *
- * SKP_Silk_sum_sqr_shift.c                                           *
- *                                                                      *
- * compute number of bits to right shift the sum of squares of a vector *
- * of int16s to make it fit in an int32                                 *
- *                                                                      *
- * Copyright 2006-2008 (c), Skype Limited                               *
- *                                                                      */
 #include "SKP_Silk_SigProc_FIX.h"
+
 /* Compute number of bits to right shift the sum of squares of a vector */
 /* of int16s to make it fit in an int32                                 */
 void SKP_Silk_sum_sqr_shift(
@@ -44,24 +37,14 @@
 )
 {
     SKP_int   i, shft;
-    SKP_int32 in32, nrg_tmp, nrg;
+    SKP_int32 nrg_tmp, nrg;
 
-    if( (SKP_int32)( (SKP_int_ptr_size)x & 2 ) != 0 ) {
-        /* Input is not 4-byte aligned */
-        nrg = SKP_SMULBB( x[ 0 ], x[ 0 ] );
-        i = 1;
-    } else {
-        nrg = 0;
-        i   = 0;
-    }
+    nrg  = 0;
     shft = 0;
     len--;
-    while( i < len ) {
-        /* Load two values at once */
-        in32 = *( (SKP_int32 *)&x[ i ] );
-        nrg = SKP_SMLABB_ovflw( nrg, in32, in32 );
-        nrg = SKP_SMLATT_ovflw( nrg, in32, in32 );
-        i += 2;
+    for( i = 0; i < len; i += 2 ) {
+        nrg = SKP_SMLABB_ovflw( nrg, x[ i ], x[ i ] );
+        nrg = SKP_SMLABB_ovflw( nrg, x[ i + 1 ], x[ i + 1 ] );
         if( nrg < 0 ) {
             /* Scale down */
             nrg = (SKP_int32)SKP_RSHIFT_uint( (SKP_uint32)nrg, 2 );
@@ -70,10 +53,8 @@
         }
     }
     for( ; i < len; i += 2 ) {
-        /* Load two values at once */
-        in32 = *( (SKP_int32 *)&x[ i ] );
-        nrg_tmp = SKP_SMULBB( in32, in32 );
-        nrg_tmp = SKP_SMLATT_ovflw( nrg_tmp, in32, in32 );
+        nrg_tmp = SKP_SMULBB( x[ i ], x[ i ] );
+        nrg_tmp = SKP_SMLABB_ovflw( nrg_tmp, x[ i + 1 ], x[ i + 1 ] );
         nrg = (SKP_int32)SKP_ADD_RSHIFT_uint( nrg, (SKP_uint32)nrg_tmp, shft );
         if( nrg < 0 ) {
             /* Scale down */
--- a/src_SigProc_FLP/SKP_Silk_SigProc_FLP.h
+++ b/src_SigProc_FLP/SKP_Silk_SigProc_FLP.h
@@ -113,13 +113,6 @@
     const SKP_int        K              /* I:    Number of correctly sorted positions    */
 );
 
-void SKP_Silk_insertion_sort_increasing_FLP(
-    SKP_float            *a,            /* I/O:  Unsorted / Sorted vector                */
-    SKP_int              *index,        /* O:    Index vector for the sorted elements    */
-    const SKP_int        L,             /* I:    Vector length                           */
-    const SKP_int        K              /* I:    Number of correctly sorted positions    */
-);
-
 /* Compute reflection coefficients from input signal */
 SKP_float SKP_Silk_burg_modified_FLP(       /* O    returns residual energy                                         */
     SKP_float           A[],                /* O    prediction coefficients (length order)                          */
--- a/src_SigProc_FLP/SKP_Silk_sort_FLP.c
+++ b/src_SigProc_FLP/SKP_Silk_sort_FLP.c
@@ -32,52 +32,6 @@
 #include "SKP_Silk_typedef.h"
 #include "SKP_Silk_SigProc_FLP.h"
 
-void SKP_Silk_insertion_sort_increasing_FLP(
-    SKP_float            *a,          /* I/O:  Unsorted / Sorted vector                */
-    SKP_int              *index,      /* O:    Index vector for the sorted elements    */
-    const SKP_int        L,           /* I:    Vector length                           */
-    const SKP_int        K            /* I:    Number of correctly sorted positions    */
-)
-{
-    SKP_float value;
-    SKP_int   i, j;
-
-    /* Safety checks */
-    SKP_assert( K >  0 );
-    SKP_assert( L >  0 );
-    SKP_assert( L >= K );
-
-    /* Write start indices in index vector */
-    for( i = 0; i < K; i++ ) {
-        index[ i ] = i;
-    }
-
-    /* Sort vector elements by value, increasing order */
-    for( i = 1; i < K; i++ ) {
-        value = a[ i ];
-        for( j = i - 1; ( j >= 0 ) && ( value < a[ j ] ); j-- ) {
-            a[ j + 1 ]     = a[ j ];     /* Shift value */
-            index[ j + 1 ] = index[ j ]; /* Shift index */
-        }
-        a[ j + 1 ]     = value; /* Write value */
-        index[ j + 1 ] = i;     /* Write index */
-    }
-
-    /* If less than L values are asked check the remaining values,      */
-    /* but only spend CPU to ensure that the K first values are correct */
-    for( i = K; i < L; i++ ) {
-        value = a[ i ];
-        if( value < a[ K - 1 ] ) {
-            for( j = K - 2; ( j >= 0 ) && ( value < a[ j ] ); j-- ) {
-                a[ j + 1 ]     = a[ j ];     /* Shift value */
-                index[ j + 1 ] = index[ j ]; /* Shift index */
-            }
-            a[ j + 1 ]     = value; /* Write value */
-            index[ j + 1 ] = i;        /* Write index */
-        }
-    }
-}
-
 void SKP_Silk_insertion_sort_decreasing_FLP(
     SKP_float            *a,          /* I/O:  Unsorted / Sorted vector                */
     SKP_int              *index,      /* O:    Index vector for the sorted elements    */
@@ -123,25 +77,3 @@
         }
     }
 }
-
-void SKP_Silk_insertion_sort_increasing_all_values_FLP(
-    SKP_float            *a,          /* I/O:  Unsorted / Sorted vector                */
-    const SKP_int        L            /* I:    Vector length                           */
-)
-{
-    SKP_float value;
-    SKP_int   i, j;
-
-    /* Safety checks */
-    SKP_assert( L >  0 );
-
-    /* Sort vector elements by value, increasing order */
-    for( i = 1; i < L; i++ ) {
-        value = a[ i ];
-        for( j = i - 1; ( j >= 0 ) && ( value < a[ j ] ); j-- ) {    
-            a[ j + 1 ] = a[ j ]; /* Shift value */
-        }
-        a[ j + 1 ] = value; /* Write value */
-    }
-}
-
--- a/src_common/SKP_Silk_LBRR_embed.c
+++ /dev/null
@@ -1,59 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. 
-Redistribution and use in source and binary forms, with or without 
-modification, (subject to the limitations in the disclaimer below) 
-are permitted provided that the following conditions are met:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright 
-notice, this list of conditions and the following disclaimer in the 
-documentation and/or other materials provided with the distribution.
-- Neither the name of Skype Limited, nor the names of specific 
-contributors, may be used to endorse or promote products derived from 
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-
-/*******************************************/
-/* Encode LBRR side info and excitation    */
-/*******************************************/
-void SKP_Silk_LBRR_embed(
-    SKP_Silk_encoder_state      *psEncC,            /* I/O  Encoder state                               */
-    ec_enc                      *psRangeEnc         /* I/O  Compressor data structure                   */
-)
-{
-    SKP_int   i;
-    SKP_int32 LBRR_symbol;
-
-    /* Encode LBRR flags */
-    LBRR_symbol = 0;
-    for( i = 0; i < psEncC->nFramesPerPacket; i++ ) {
-        LBRR_symbol |= SKP_LSHIFT( psEncC->LBRR_flags[ i ], i );
-    }
-    psEncC->LBRR_flag = LBRR_symbol > 0 ? 1 : 0;
-    if( LBRR_symbol && psEncC->nFramesPerPacket > 1 ) {
-        ec_enc_icdf( psRangeEnc, LBRR_symbol - 1, SKP_Silk_LBRR_flags_iCDF_ptr[ psEncC->nFramesPerPacket - 2 ], 8 );
-    }
-
-    /* Code indices and excitation signals */
-    for( i = 0; i < psEncC->nFramesPerPacket; i++ ) {
-        if( psEncC->LBRR_flags[ i ] ) {
-            SKP_Silk_encode_indices( psEncC, psRangeEnc, i, 1 );
-            SKP_Silk_encode_pulses( psRangeEnc, psEncC->indices_LBRR[i].signalType, 
-                psEncC->indices_LBRR[i].quantOffsetType, psEncC->pulses_LBRR[ i ], psEncC->frame_length );
-        }
-    }
-}
--- a/src_common/SKP_Silk_LP_variable_cutoff.c
+++ b/src_common/SKP_Silk_LP_variable_cutoff.c
@@ -34,9 +34,7 @@
 */
 #include "SKP_Silk_main.h"
 
-#if SWITCH_TRANSITION_FILTERING
-
-/* Helper function, that interpolates the filter taps */
+/* Helper function, interpolates the filter taps */
 SKP_INLINE void SKP_Silk_LP_interpolate_filter_taps( 
     SKP_int32           B_Q28[ TRANSITION_NB ], 
     SKP_int32           A_Q28[ TRANSITION_NA ],
@@ -133,4 +131,3 @@
         SKP_Silk_biquad_alt( signal, B_Q28, A_Q28, psLP->In_LP_State, signal, frame_length );
     }
 }
-#endif
--- a/src_common/SKP_Silk_NLSF_MSVQ_decode.c
+++ /dev/null
@@ -1,106 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. 
-Redistribution and use in source and binary forms, with or without 
-modification, (subject to the limitations in the disclaimer below) 
-are permitted provided that the following conditions are met:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright 
-notice, this list of conditions and the following disclaimer in the 
-documentation and/or other materials provided with the distribution.
-- Neither the name of Skype Limited, nor the names of specific 
-contributors, may be used to endorse or promote products derived from 
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-
-/* NLSF vector decoder */
-void SKP_Silk_NLSF_MSVQ_decode(
-    SKP_int                         *pNLSF_Q15,     /* O    Pointer to decoded output vector [LPC_ORDER x 1]    */
-    const SKP_Silk_NLSF_CB_struct   *psNLSF_CB,     /* I    Pointer to NLSF codebook struct                     */
-    const SKP_int8                  *NLSFIndices,   /* I    Pointer to NLSF indices          [nStages x 1]      */
-    const SKP_int                   LPC_order       /* I    LPC order used                                      */
-) 
-{
-    const SKP_int8 *pCB_element;
-          SKP_int   i, s;
-          SKP_int   pNLSF_Q8[ MAX_LPC_ORDER ];
-
-    /* Check that index is within valid range */
-    SKP_assert( 0 <= NLSFIndices[ 0 ] && NLSFIndices[ 0 ] < psNLSF_CB->CBStages[ 0 ].nVectors );
-
-    /* Point to the first vector element */
-    pCB_element = &psNLSF_CB->CBStages[ 0 ].CB_NLSF_Q8[ SKP_SMULBB( (SKP_int16)NLSFIndices[ 0 ], LPC_order ) ];
-
-    /* Initialize with the codebook vector from stage 0 */
-    for( i = 0; i < LPC_order; i++ ) {
-        pNLSF_Q8[ i ] = SKP_LSHIFT( ( SKP_int )pCB_element[ i ], NLSF_Q_DOMAIN_STAGE_2_TO_LAST - NLSF_Q_DOMAIN_STAGE_0 );
-    }
-          
-    if( LPC_order == 16 ) {
-        for( s = 1; s < psNLSF_CB->nStages; s++ ) {
-            /* Check that each index is within valid range */
-            SKP_assert( 0 <= NLSFIndices[ s ] && NLSFIndices[ s ] < psNLSF_CB->CBStages[ s ].nVectors );
-
-            /* Point to the first vector element */
-            pCB_element = &psNLSF_CB->CBStages[ s ].CB_NLSF_Q8[ 16 * (SKP_int16)NLSFIndices[ s ] ];
-
-            /* Add the codebook vector from the current stage */
-            pNLSF_Q8[  0 ] += ( SKP_int )pCB_element[  0 ];
-            pNLSF_Q8[  1 ] += ( SKP_int )pCB_element[  1 ];
-            pNLSF_Q8[  2 ] += ( SKP_int )pCB_element[  2 ];
-            pNLSF_Q8[  3 ] += ( SKP_int )pCB_element[  3 ];
-            pNLSF_Q8[  4 ] += ( SKP_int )pCB_element[  4 ];
-            pNLSF_Q8[  5 ] += ( SKP_int )pCB_element[  5 ];
-            pNLSF_Q8[  6 ] += ( SKP_int )pCB_element[  6 ];
-            pNLSF_Q8[  7 ] += ( SKP_int )pCB_element[  7 ];
-            pNLSF_Q8[  8 ] += ( SKP_int )pCB_element[  8 ];
-            pNLSF_Q8[  9 ] += ( SKP_int )pCB_element[  9 ];
-            pNLSF_Q8[ 10 ] += ( SKP_int )pCB_element[ 10 ];
-            pNLSF_Q8[ 11 ] += ( SKP_int )pCB_element[ 11 ];
-            pNLSF_Q8[ 12 ] += ( SKP_int )pCB_element[ 12 ];
-            pNLSF_Q8[ 13 ] += ( SKP_int )pCB_element[ 13 ];
-            pNLSF_Q8[ 14 ] += ( SKP_int )pCB_element[ 14 ];
-            pNLSF_Q8[ 15 ] += ( SKP_int )pCB_element[ 15 ];
-        }
-    } else {
-        SKP_assert( LPC_order == 10 );
-        for( s = 1; s < psNLSF_CB->nStages; s++ ) {
-            /* Point to the first vector element */
-            pCB_element = &psNLSF_CB->CBStages[ s ].CB_NLSF_Q8[ SKP_SMULBB( (SKP_int16)NLSFIndices[ s ], LPC_order ) ];
-
-            /* Add the codebook vector from the current stage */
-            pNLSF_Q8[  0 ] += ( SKP_int )pCB_element[  0 ];
-            pNLSF_Q8[  1 ] += ( SKP_int )pCB_element[  1 ];
-            pNLSF_Q8[  2 ] += ( SKP_int )pCB_element[  2 ];
-            pNLSF_Q8[  3 ] += ( SKP_int )pCB_element[  3 ];
-            pNLSF_Q8[  4 ] += ( SKP_int )pCB_element[  4 ];
-            pNLSF_Q8[  5 ] += ( SKP_int )pCB_element[  5 ];
-            pNLSF_Q8[  6 ] += ( SKP_int )pCB_element[  6 ];
-            pNLSF_Q8[  7 ] += ( SKP_int )pCB_element[  7 ];
-            pNLSF_Q8[  8 ] += ( SKP_int )pCB_element[  8 ];
-            pNLSF_Q8[  9 ] += ( SKP_int )pCB_element[  9 ];
-        }
-    }
-
-    /* Add 1/2 in Q15 */
-    for( i = 0; i < LPC_order; i++ ) {
-        pNLSF_Q15[ i ] = SKP_LSHIFT16( pNLSF_Q8[ i ], 15 - NLSF_Q_DOMAIN_STAGE_2_TO_LAST ) + SKP_FIX_CONST( 0.5f, 15 );
-    }
-
-    /* NLSF stabilization */
-    SKP_Silk_NLSF_stabilize( pNLSF_Q15, psNLSF_CB->NDeltaMin_Q15, LPC_order );
-}
--- a/src_common/SKP_Silk_NLSF_MSVQ_encode.c
+++ /dev/null
@@ -1,238 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. 
-Redistribution and use in source and binary forms, with or without 
-modification, (subject to the limitations in the disclaimer below) 
-are permitted provided that the following conditions are met:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright 
-notice, this list of conditions and the following disclaimer in the 
-documentation and/or other materials provided with the distribution.
-- Neither the name of Skype Limited, nor the names of specific 
-contributors, may be used to endorse or promote products derived from 
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-
-/***********************/
-/* NLSF vector encoder */
-/***********************/
-void SKP_Silk_NLSF_MSVQ_encode(
-          SKP_int8                  *NLSFIndices,           /* O    Codebook path vector [ CB_STAGES ]      */
-          SKP_int                   *pNLSF_Q15,             /* I/O  Quantized NLSF vector [ LPC_ORDER ]     */
-    const SKP_Silk_NLSF_CB_struct   *psNLSF_CB,             /* I    Codebook object                         */
-    const SKP_int                   *pNLSF_q_Q15_prev,      /* I    Prev. quantized NLSF vector [LPC_ORDER] */
-    const SKP_int                   *pW_Q5,                 /* I    NLSF weight vector [ LPC_ORDER ]        */
-    const SKP_int                   NLSF_mu_Q15,            /* I    Rate weight for the RD optimization     */
-    const SKP_int                   NLSF_mu_fluc_red_Q16,   /* I    Fluctuation reduction error weight      */
-    const SKP_int                   NLSF_MSVQ_Survivors,    /* I    Max survivors from each stage           */
-    const SKP_int                   LPC_order,              /* I    LPC order                               */
-    const SKP_int                   deactivate_fluc_red     /* I    Deactivate fluctuation reduction        */
-)
-{
-    SKP_int     i, s, k, cur_survivors = 0, prev_survivors, min_survivors, input_index, cb_index, bestIndex;
-    SKP_int32   rateDistThreshold_Q18;
-#if( NLSF_MSVQ_FLUCTUATION_REDUCTION == 1 )
-    SKP_int32   se_Q15, wsse_Q20, bestRateDist_Q20;
-#endif
-
-    SKP_int32   pRateDist_Q18[  NLSF_MSVQ_TREE_SEARCH_MAX_VECTORS_EVALUATED ];
-    SKP_int32   pRate_Q4[       MAX_NLSF_MSVQ_SURVIVORS ];
-    SKP_int32   pRate_new_Q4[   MAX_NLSF_MSVQ_SURVIVORS ];
-    SKP_int     pTempIndices[   MAX_NLSF_MSVQ_SURVIVORS ];
-    SKP_int8    pPath[          MAX_NLSF_MSVQ_SURVIVORS * NLSF_MSVQ_MAX_CB_STAGES ];
-    SKP_int8    pPath_new[      MAX_NLSF_MSVQ_SURVIVORS * NLSF_MSVQ_MAX_CB_STAGES ];
-    SKP_int16   pRes_Q15[       MAX_NLSF_MSVQ_SURVIVORS * MAX_LPC_ORDER ];
-    SKP_int16   pRes_new_Q15[   MAX_NLSF_MSVQ_SURVIVORS * MAX_LPC_ORDER ];
-
-    const SKP_int16 *pConstInt16;
-          SKP_int16 *pInt16;
-    const SKP_int8  *pConstInt8;
-          SKP_int8  *pInt8;
-    const SKP_int8  *pCB_element;
-    const SKP_Silk_NLSF_CBS *pCurrentCBStage;
-
-    SKP_assert( NLSF_MSVQ_Survivors <= MAX_NLSF_MSVQ_SURVIVORS );
-
-#ifdef SAVE_ALL_INTERNAL_DATA
-    DEBUG_STORE_DATA( NLSF.dat,    pNLSF_Q15,    LPC_order * sizeof( SKP_int   ) );
-    DEBUG_STORE_DATA( WNLSF.dat,   pW_Q5,        LPC_order * sizeof( SKP_int   ) );
-    DEBUG_STORE_DATA( NLSF_mu.dat, &NLSF_mu_Q15,             sizeof( SKP_int32 ) );
-#endif
-
-    /****************************************************/
-    /* Tree search for the multi-stage vector quantizer */
-    /****************************************************/
-
-    /* Clear accumulated rates */
-    SKP_memset( pRate_Q4, 0, NLSF_MSVQ_Survivors * sizeof( SKP_int32 ) );
-
-    /* Subtract 1/2 from NLSF input vector to create initial residual */
-    for( i = 0; i < LPC_order; i++ ) {
-        pRes_Q15[ i ] = pNLSF_Q15[ i ] - SKP_FIX_CONST( 0.5f, 15 );
-    }
-
-    /* Set first stage values */
-    prev_survivors = 1;
-
-    /* Minimum number of survivors */
-    min_survivors = NLSF_MSVQ_Survivors / 2;
-
-    /* Loop over all stages */
-    for( s = 0; s < psNLSF_CB->nStages; s++ ) {
-
-        /* Set a pointer to the current stage codebook */
-        pCurrentCBStage = &psNLSF_CB->CBStages[ s ];
-
-        /* Calculate the number of survivors in the current stage */
-        cur_survivors = SKP_min_32( NLSF_MSVQ_Survivors, SKP_SMULBB( prev_survivors, pCurrentCBStage->nVectors ) );
-
-#if( NLSF_MSVQ_FLUCTUATION_REDUCTION == 0 )
-        /* Find a single best survivor in the last stage, if we */
-        /* do not need candidates for fluctuation reduction     */
-        if( s == psNLSF_CB->nStages - 1 ) {
-            cur_survivors = 1;
-        }
-#endif
-
-        /* Nearest neighbor clustering for multiple input data vectors */
-        SKP_Silk_NLSF_VQ_rate_distortion( pRateDist_Q18, pCurrentCBStage, pRes_Q15, pW_Q5, 
-            pRate_Q4, NLSF_mu_Q15, prev_survivors, s, LPC_order );
-
-        /* Sort the rate-distortion errors */
-        SKP_Silk_insertion_sort_increasing( pRateDist_Q18, pTempIndices, 
-            prev_survivors * pCurrentCBStage->nVectors, cur_survivors );
-
-        /* Discard survivors with rate-distortion values too far above the best one */
-        if( pRateDist_Q18[ 0 ] < SKP_int32_MAX / MAX_NLSF_MSVQ_SURVIVORS ) {
-            rateDistThreshold_Q18 = SKP_SMLAWB( pRateDist_Q18[ 0 ], 
-                SKP_MUL( NLSF_MSVQ_Survivors, pRateDist_Q18[ 0 ] ), SKP_FIX_CONST( NLSF_MSVQ_SURV_MAX_REL_RD, 16 ) );
-            while( pRateDist_Q18[ cur_survivors - 1 ] > rateDistThreshold_Q18 && cur_survivors > min_survivors ) {
-                cur_survivors--;
-            }
-        }
-        /* Update accumulated codebook contributions for the 'cur_survivors' best codebook indices */
-        for( k = 0; k < cur_survivors; k++ ) { 
-            if( s > 0 ) {
-                /* Find the indices of the input and the codebook vector */
-                if( pCurrentCBStage->nVectors == 8 ) {
-                    input_index = SKP_RSHIFT( pTempIndices[ k ], 3 );
-                    cb_index    = pTempIndices[ k ] & 7;
-                } else {
-                    input_index = SKP_DIV32_16( pTempIndices[ k ], pCurrentCBStage->nVectors );  
-                    cb_index    = pTempIndices[ k ] - SKP_SMULBB( input_index, pCurrentCBStage->nVectors );
-                }
-            } else {
-                /* Find the indices of the input and the codebook vector */
-                input_index = 0;
-                cb_index    = pTempIndices[ k ];
-            }
-
-            /* Subtract new contribution from the previous residual vector for each of 'cur_survivors' */
-            pConstInt16 = &pRes_Q15[ SKP_SMULBB( input_index, LPC_order ) ];
-            pCB_element = &pCurrentCBStage->CB_NLSF_Q8[ SKP_SMULBB( cb_index, LPC_order ) ];
-            pInt16      = &pRes_new_Q15[ SKP_SMULBB( k, LPC_order ) ];
-            for( i = 0; i < LPC_order; i++ ) {
-                pInt16[ i ] = pConstInt16[ i ] - SKP_LSHIFT16( ( SKP_int16 )pCB_element[ i ], 7 );
-            }
-
-            /* Update accumulated rate for stage 1 to the current */
-            pRate_new_Q4[ k ] = pRate_Q4[ input_index ] + pCurrentCBStage->Rates_Q4[ cb_index ];
-
-            /* Copy paths from previous matrix, starting with the best path */
-            pConstInt8 = &pPath[ SKP_SMULBB( input_index, psNLSF_CB->nStages ) ];
-            pInt8      = &pPath_new[ SKP_SMULBB( k, psNLSF_CB->nStages ) ];
-            for( i = 0; i < s; i++ ) {
-                pInt8[ i ] = pConstInt8[ i ];
-            }
-            /* Write the current stage indices for the 'cur_survivors' to the best path matrix */
-            pInt8[ s ] = (SKP_int8)cb_index;
-        }
-
-        if( s < psNLSF_CB->nStages - 1 ) {
-            /* Copy NLSF residual matrix for next stage */
-            SKP_memcpy( pRes_Q15, pRes_new_Q15, SKP_SMULBB( cur_survivors, LPC_order ) * sizeof( SKP_int16 ) );
-
-            /* Copy rate vector for next stage */
-            SKP_memcpy( pRate_Q4, pRate_new_Q4, cur_survivors * sizeof( SKP_int32 ) );
-
-            /* Copy best path matrix for next stage */
-            SKP_memcpy( pPath, pPath_new, SKP_SMULBB( cur_survivors, psNLSF_CB->nStages ) * sizeof( SKP_int8) );
-        }
-
-        prev_survivors = cur_survivors;
-    }
-
-    /* (Preliminary) index of the best survivor, later to be decoded */
-    bestIndex = 0;
-
-#if( NLSF_MSVQ_FLUCTUATION_REDUCTION == 1 )
-    /******************************/
-    /* NLSF fluctuation reduction */
-    /******************************/
-    if( deactivate_fluc_red != 1 ) {
-    
-        /* Search among all survivors, now taking also weighted fluctuation errors into account */
-        bestRateDist_Q20 = SKP_int32_MAX;
-        for( s = 0; s < cur_survivors; s++ ) {
-            /* Decode survivor to compare with previous quantized NLSF vector */
-            SKP_Silk_NLSF_MSVQ_decode( pNLSF_Q15, psNLSF_CB, &pPath_new[ SKP_SMULBB( s, psNLSF_CB->nStages ) ], LPC_order );
-
-            /* Compare decoded NLSF vector with the previously quantized vector */ 
-            wsse_Q20 = 0;
-            for( i = 0; i < LPC_order; i += 2 ) {
-                /* Compute weighted squared quantization error for index i */
-                se_Q15 = pNLSF_Q15[ i ] - pNLSF_q_Q15_prev[ i ]; // range: [ -32767 : 32767 ]
-                wsse_Q20 = SKP_SMLAWB( wsse_Q20, SKP_SMULBB( se_Q15, se_Q15 ), pW_Q5[ i ] );
-
-                /* Compute weighted squared quantization error for index i + 1 */
-                se_Q15 = pNLSF_Q15[ i + 1 ] - pNLSF_q_Q15_prev[ i + 1 ]; // range: [ -32767 : 32767 ]
-                wsse_Q20 = SKP_SMLAWB( wsse_Q20, SKP_SMULBB( se_Q15, se_Q15 ), pW_Q5[ i + 1 ] );
-            }
-            SKP_assert( wsse_Q20 >= 0 );
-
-            /* Add the fluctuation reduction penalty to the rate distortion error */
-            wsse_Q20 = SKP_ADD_POS_SAT32( pRateDist_Q18[ s ], SKP_SMULWB( wsse_Q20, NLSF_mu_fluc_red_Q16 ) );
-
-            /* Keep index of best survivor */
-            if( wsse_Q20 < bestRateDist_Q20 ) {
-                bestRateDist_Q20 = wsse_Q20;
-                bestIndex = s;
-            }
-        }
-    }
-#endif
-
-    /* Copy best path to output argument */
-    SKP_memcpy( NLSFIndices, &pPath_new[ SKP_SMULBB( bestIndex, psNLSF_CB->nStages ) ], psNLSF_CB->nStages * sizeof( SKP_int8 ) );
-
-    /* Decode and stabilize the best survivor */
-    SKP_Silk_NLSF_MSVQ_decode( pNLSF_Q15, psNLSF_CB, NLSFIndices, LPC_order );
-
-#ifdef SAVE_ALL_INTERNAL_DATA
-    {
-        SKP_float rateBPF_LSF;
-        SKP_float NLSF_coef;
-
-        rateBPF_LSF = (SKP_float)pRate_new_Q5[ bestIndex ] / 32.0f; // Q5 -> Q0
-        DEBUG_STORE_DATA( rateBPF_LSF.dat, &rateBPF_LSF, sizeof( SKP_float ));
-        for( i = 0; i < LPC_order; i++ ) {
-            NLSF_coef = ( (SKP_float)pNLSF_Q15[ i ] ) * ( 1.0f / 32768.0f );
-            DEBUG_STORE_DATA( NLSFq.dat, &NLSF_coef, sizeof( SKP_float ) );
-        }
-    }
-#endif
-}
--- a/src_common/SKP_Silk_NLSF_VQ_rate_distortion.c
+++ /dev/null
@@ -1,62 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. 
-Redistribution and use in source and binary forms, with or without 
-modification, (subject to the limitations in the disclaimer below) 
-are permitted provided that the following conditions are met:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright 
-notice, this list of conditions and the following disclaimer in the 
-documentation and/or other materials provided with the distribution.
-- Neither the name of Skype Limited, nor the names of specific 
-contributors, may be used to endorse or promote products derived from 
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-
-/* Rate-Distortion calculations for multiple input data vectors */
-void SKP_Silk_NLSF_VQ_rate_distortion(
-    SKP_int32                       *pRD_Q19,           /* O    Rate-distortion values [psNLSF_CBS->nVectors*N] */
-    const SKP_Silk_NLSF_CBS         *psNLSF_CBS,        /* I    NLSF codebook stage struct                      */
-    const SKP_int16                 *in_Q15,            /* I    Input vectors to be quantized                   */
-    const SKP_int                   *w_Q5,              /* I    Weight vector                                   */
-    const SKP_int32                 *rate_acc_Q4,       /* I    Accumulated rates from previous stage           */
-    const SKP_int                   mu_Q15,             /* I    Weight between weighted error and rate          */
-    const SKP_int                   N,                  /* I    Number of input vectors to be quantized         */
-    const SKP_int                   stage,              /* I    Stage number                                */
-    const SKP_int                   LPC_order           /* I    LPC order                                       */
-)
-{
-    SKP_int   i, n;
-    SKP_int32 *pRD_vec_Q19;
-
-    /* Compute weighted quantization errors for all input vectors over one codebook stage */
-    SKP_Silk_NLSF_VQ_sum_error( pRD_Q19, in_Q15, w_Q5, psNLSF_CBS->CB_NLSF_Q8, 
-        N, psNLSF_CBS->nVectors, stage, LPC_order );
-
-    /* Loop over input vectors */
-    pRD_vec_Q19 = pRD_Q19;
-    for( n = 0; n < N; n++ ) {
-        /* Add rate cost to error for each codebook vector */
-        for( i = 0; i < psNLSF_CBS->nVectors; i++ ) {
-            SKP_assert( rate_acc_Q4[ n ] + SKP_LSHIFT32( ( SKP_int32 )psNLSF_CBS->Rates_Q4[ i ], 1 ) >= 0 );
-            SKP_assert( rate_acc_Q4[ n ] + SKP_LSHIFT32( ( SKP_int32 )psNLSF_CBS->Rates_Q4[ i ], 1 ) <= SKP_int16_MAX );
-            pRD_vec_Q19[ i ] = SKP_SMLABB( pRD_vec_Q19[ i ], rate_acc_Q4[ n ] + psNLSF_CBS->Rates_Q4[ i ], mu_Q15 );
-            SKP_assert( pRD_vec_Q19[ i ] >= 0 );
-        }
-        pRD_vec_Q19 += psNLSF_CBS->nVectors;
-    }
-}
--- a/src_common/SKP_Silk_NLSF_VQ_sum_error.c
+++ /dev/null
@@ -1,107 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. 
-Redistribution and use in source and binary forms, with or without 
-modification, (subject to the limitations in the disclaimer below) 
-are permitted provided that the following conditions are met:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright 
-notice, this list of conditions and the following disclaimer in the 
-documentation and/or other materials provided with the distribution.
-- Neither the name of Skype Limited, nor the names of specific 
-contributors, may be used to endorse or promote products derived from 
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-
-/* Compute weighted quantization errors for an LPC_order element input vector, over one codebook stage */
-void SKP_Silk_NLSF_VQ_sum_error(
-    SKP_int32                       *err_Q19,           /* O    Weighted quantization errors  [N*K]         */
-    const SKP_int16                 *in_Q15,            /* I    Input vectors to be quantized [N*LPC_order] */
-    const SKP_int                   *w_Q5,              /* I    Weighting vectors             [LPC_order]   */
-    const SKP_int8                  *pCB_Q8,            /* I    Codebook vectors              [K*LPC_order] */
-    const SKP_int                   N,                  /* I    Number of input vectors                     */
-    const SKP_int                   K,                  /* I    Number of codebook vectors                  */
-    const SKP_int                   stage,              /* I    Stage number                                */
-    const SKP_int                   LPC_order           /* I    Number of LPCs                              */
-)
-{
-    SKP_int        i, n, m;
-    SKP_int32      diff_Q15, sum_error, Wtmp_Q5;
-    SKP_int32      Wcpy_Q5[ MAX_LPC_ORDER / 2 ];
-    const SKP_int8 *cb_vec_Q8;
-
-    SKP_assert( LPC_order <= 16 );
-    SKP_assert( ( LPC_order & 1 ) == 0 );
-
-    /* Copy to local stack and pack two weights per int32 */
-    for( m = 0; m < SKP_RSHIFT( LPC_order, 1 ); m++ ) {
-        Wcpy_Q5[ m ] = w_Q5[ 2 * m ] | SKP_LSHIFT( ( SKP_int32 )w_Q5[ 2 * m + 1 ], 16 );
-    }
-
-    if( stage == 0 ) {
-        /* Loop over input vectors */
-        for( n = 0; n < N; n++ ) {
-            /* Loop over codebook */
-            cb_vec_Q8 = pCB_Q8;
-            for( i = 0; i < K; i++ ) {
-                sum_error = 0;
-                for( m = 0; m < LPC_order; m += 2 ) {
-                    /* Get two weights packed in an int32 */
-                    Wtmp_Q5 = Wcpy_Q5[ m >> 1 ];
-
-                    /* Compute weighted squared quantization error for index m */
-                    diff_Q15 = in_Q15[ m ] - SKP_LSHIFT16( ( SKP_int16 )( *cb_vec_Q8++ ), 15 - NLSF_Q_DOMAIN_STAGE_0 ); // range: [ -32767 : 32767 ]
-                    sum_error = SKP_SMLAWB( sum_error, SKP_SMULBB( diff_Q15, diff_Q15 ), Wtmp_Q5 );
-
-                    /* Compute weighted squared quantization error for index m + 1 */
-                    diff_Q15 = in_Q15[m + 1] - SKP_LSHIFT16( ( SKP_int16 )( *cb_vec_Q8++ ), 15 - NLSF_Q_DOMAIN_STAGE_0 ); // range: [ -32767 : 32767 ]
-                    sum_error = SKP_SMLAWT( sum_error, SKP_SMULBB( diff_Q15, diff_Q15 ), Wtmp_Q5 );
-                }
-                SKP_assert( sum_error >= 0 );
-                err_Q19[ i ] = sum_error;
-            }
-            err_Q19 += K;
-            in_Q15 += LPC_order;
-        }
-    } else {
-        /* Loop over input vectors */
-        for( n = 0; n < N; n++ ) {
-            /* Loop over codebook */
-            cb_vec_Q8 = pCB_Q8;
-            for( i = 0; i < K; i++ ) {
-                sum_error = 0;
-                for( m = 0; m < LPC_order; m += 2 ) {
-                    /* Get two weights packed in an int32 */
-                    Wtmp_Q5 = Wcpy_Q5[ m >> 1 ];
-
-                    /* Compute weighted squared quantization error for index m */
-                    diff_Q15 = in_Q15[ m ] - SKP_LSHIFT16( ( SKP_int16 )( *cb_vec_Q8++ ), 15 - NLSF_Q_DOMAIN_STAGE_2_TO_LAST ); // range: [ -32767 : 32767 ]
-                    sum_error = SKP_SMLAWB( sum_error, SKP_SMULBB( diff_Q15, diff_Q15 ), Wtmp_Q5 );
-
-                    /* Compute weighted squared quantization error for index m + 1 */
-                    diff_Q15 = in_Q15[m + 1] - SKP_LSHIFT16( ( SKP_int16 )( *cb_vec_Q8++ ), 15 - NLSF_Q_DOMAIN_STAGE_2_TO_LAST ); // range: [ -32767 : 32767 ]
-                    sum_error = SKP_SMLAWT( sum_error, SKP_SMULBB( diff_Q15, diff_Q15 ), Wtmp_Q5 );
-                }
-                SKP_assert( sum_error >= 0 );
-                err_Q19[ i ] = sum_error;
-            }
-            err_Q19 += K;
-            in_Q15 += LPC_order;
-        }
-    }
-}
-
--- a/src_common/SKP_Silk_PLC.c
+++ b/src_common/SKP_Silk_PLC.c
@@ -167,7 +167,7 @@
     SKP_memmove( psDec->sLTP_Q16, &psDec->sLTP_Q16[ psDec->frame_length ], psDec->ltp_mem_length * sizeof( SKP_int32 ) );
 
     /* LPC concealment. Apply BWE to previous LPC */
-    SKP_Silk_bwexpander( psPLC->prevLPC_Q12, psDec->LPC_order, BWE_COEF_Q16 );
+    SKP_Silk_bwexpander( psPLC->prevLPC_Q12, psDec->LPC_order, SKP_FIX_CONST( BWE_COEF, 16 ) );
 
     /* Find random noise component */
     /* Scale previous excitation signal */
@@ -205,7 +205,7 @@
 
     /* First Lost frame */
     if( psDec->lossCnt == 0 ) {
-        rand_scale_Q14 = (1 << 14 );
+        rand_scale_Q14 = 1 << 14;
     
         /* Reduce random noise Gain for voiced frames */
         if( psDec->prevSignalType == TYPE_VOICED ) {
@@ -220,8 +220,8 @@
             
             SKP_Silk_LPC_inverse_pred_gain( &invGain_Q30, psPLC->prevLPC_Q12, psDec->LPC_order );
             
-            down_scale_Q30 = SKP_min_32( SKP_RSHIFT( ( 1 << 30 ), LOG2_INV_LPC_GAIN_HIGH_THRES ), invGain_Q30 );
-            down_scale_Q30 = SKP_max_32( SKP_RSHIFT( ( 1 << 30 ), LOG2_INV_LPC_GAIN_LOW_THRES ), down_scale_Q30 );
+            down_scale_Q30 = SKP_min_32( SKP_RSHIFT( 1 << 30, LOG2_INV_LPC_GAIN_HIGH_THRES ), invGain_Q30 );
+            down_scale_Q30 = SKP_max_32( SKP_RSHIFT( 1 << 30, LOG2_INV_LPC_GAIN_LOW_THRES ), down_scale_Q30 );
             down_scale_Q30 = SKP_LSHIFT( down_scale_Q30, LOG2_INV_LPC_GAIN_HIGH_THRES );
             
             rand_Gain_Q15 = SKP_RSHIFT( SKP_SMULWB( down_scale_Q30, rand_Gain_Q15 ), 14 );
@@ -360,7 +360,7 @@
             /* Fade in the energy difference */
             if( energy > psPLC->conc_energy ) {
                 SKP_int32 frac_Q24, LZ;
-                SKP_int32 gain_Q12, slope_Q12;
+                SKP_int32 gain_Q16, slope_Q16;
 
                 LZ = SKP_Silk_CLZ32( psPLC->conc_energy );
                 LZ = LZ - 1;
@@ -369,13 +369,17 @@
                 
                 frac_Q24 = SKP_DIV32( psPLC->conc_energy, SKP_max( energy, 1 ) );
                 
-                gain_Q12 = SKP_Silk_SQRT_APPROX( frac_Q24 );
-                slope_Q12 = SKP_DIV32_16( ( 1 << 12 ) - gain_Q12, length );
+                gain_Q16 = SKP_LSHIFT( SKP_Silk_SQRT_APPROX( frac_Q24 ), 4 );
+                slope_Q16 = SKP_DIV32_16( ( 1 << 16 ) - gain_Q16, length );
+				/* Make slope 4x steeper to avoid missing onsets after DTX */
+                slope_Q16 = SKP_LSHIFT( slope_Q16, 2 );
 
                 for( i = 0; i < length; i++ ) {
-                    signal[ i ] = SKP_RSHIFT( SKP_MUL( gain_Q12, signal[ i ] ), 12 );
-                    gain_Q12 += slope_Q12;
-                    gain_Q12 = SKP_min( gain_Q12, ( 1 << 12 ) );
+                    signal[ i ] = SKP_SMULWB( gain_Q16, signal[ i ] );
+                    gain_Q16 += slope_Q16;
+                    if( gain_Q16 > 1 << 16 ) {
+                        break;
+                    }
                 }
             }
         }
--- a/src_common/SKP_Silk_PLC.h
+++ b/src_common/SKP_Silk_PLC.h
@@ -30,7 +30,7 @@
 
 #include "SKP_Silk_main.h"
 
-#define BWE_COEF_Q16                    64880           /* 0.99 in Q16                      */
+#define BWE_COEF                        0.99
 #define V_PITCH_GAIN_START_MIN_Q14      11469           /* 0.7 in Q14                       */
 #define V_PITCH_GAIN_START_MAX_Q14      15565           /* 0.95 in Q14                      */
 #define MAX_PITCH_LAG_MS                18
--- /dev/null
+++ b/src_common/SKP_Silk_check_control_input.c
@@ -1,0 +1,89 @@
+/***********************************************************************
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. 
+Redistribution and use in source and binary forms, with or without 
+modification, (subject to the limitations in the disclaimer below) 
+are permitted provided that the following conditions are met:
+- Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+- Redistributions in binary form must reproduce the above copyright 
+notice, this list of conditions and the following disclaimer in the 
+documentation and/or other materials provided with the distribution.
+- Neither the name of Skype Limited, nor the names of specific 
+contributors, may be used to endorse or promote products derived from 
+this software without specific prior written permission.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 
+BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
+CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
+BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+***********************************************************************/
+
+#include "SKP_Silk_main.h"
+#include "SKP_Silk_control.h"
+#include "SKP_Silk_errors.h"
+
+/* Check encoder control struct */
+SKP_int check_control_input( 
+    SKP_SILK_SDK_EncControlStruct        *encControl     /* I:   Control structure                               */
+)
+{
+    SKP_assert( encControl != NULL );
+
+    if( ( ( encControl->API_sampleRate        !=  8000 ) &&
+          ( encControl->API_sampleRate        != 12000 ) &&
+          ( encControl->API_sampleRate        != 16000 ) &&
+          ( encControl->API_sampleRate        != 24000 ) && 
+          ( encControl->API_sampleRate        != 32000 ) &&
+          ( encControl->API_sampleRate        != 44100 ) &&
+          ( encControl->API_sampleRate        != 48000 ) ) ||
+        ( ( encControl->maxInternalSampleRate !=  8000 ) &&
+          ( encControl->maxInternalSampleRate != 12000 ) &&
+          ( encControl->maxInternalSampleRate != 16000 ) ) ||
+        ( ( encControl->minInternalSampleRate !=  8000 ) &&
+          ( encControl->minInternalSampleRate != 12000 ) &&
+          ( encControl->minInternalSampleRate != 16000 ) ) ||
+          ( encControl->minInternalSampleRate > encControl->maxInternalSampleRate ) ) {
+        SKP_assert( 0 );
+        return SKP_SILK_ENC_FS_NOT_SUPPORTED;
+    }
+    if( encControl->payloadSize_ms != 10 && 
+        encControl->payloadSize_ms != 20 && 
+        encControl->payloadSize_ms != 40 && 
+        encControl->payloadSize_ms != 60 ) {
+        SKP_assert( 0 );
+        return SKP_SILK_ENC_PACKET_SIZE_NOT_SUPPORTED;
+    }
+    if( encControl->packetLossPercentage < 0 || encControl->packetLossPercentage > 100 ) {
+        SKP_assert( 0 );
+        return SKP_SILK_ENC_INVALID_LOSS_RATE;
+    }
+    if( encControl->useDTX < 0 || encControl->useDTX > 1 ) {
+        SKP_assert( 0 );
+        return SKP_SILK_ENC_INVALID_DTX_SETTING;
+    }
+	if( encControl->useCBR < 0 || encControl->useCBR > 1 ) {
+        SKP_assert( 0 );
+        return SKP_SILK_ENC_INVALID_CBR_SETTING;
+    }
+	if( encControl->useInBandFEC < 0 || encControl->useInBandFEC > 1 ) {
+        SKP_assert( 0 );
+        return SKP_SILK_ENC_INVALID_INBAND_FEC_SETTING;
+    }
+    if( encControl->nChannels < 1 || encControl->nChannels > ENCODER_NUM_CHANNELS ) {
+        SKP_assert( 0 );
+        return SKP_SILK_ENC_INVALID_NUMBER_OF_CHANNELS_ERROR;
+    }
+    if( encControl->complexity < 0 || encControl->complexity > 10 ) {
+        SKP_assert( 0 );
+        return SKP_SILK_ENC_INVALID_COMPLEXITY_SETTING;
+    }
+
+    return SKP_SILK_NO_ERROR;
+}
--- /dev/null
+++ b/src_common/SKP_Silk_control_SNR.c
@@ -1,0 +1,74 @@
+/***********************************************************************
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. 
+Redistribution and use in source and binary forms, with or without 
+modification, (subject to the limitations in the disclaimer below) 
+are permitted provided that the following conditions are met:
+- Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+- Redistributions in binary form must reproduce the above copyright 
+notice, this list of conditions and the following disclaimer in the 
+documentation and/or other materials provided with the distribution.
+- Neither the name of Skype Limited, nor the names of specific 
+contributors, may be used to endorse or promote products derived from 
+this software without specific prior written permission.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 
+BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
+CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
+BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+***********************************************************************/
+
+#include "SKP_Silk_main.h"
+#include "SKP_Silk_tuning_parameters.h"
+
+/* Control SNR of redidual quantizer */
+SKP_int SKP_Silk_control_SNR(
+    SKP_Silk_encoder_state      *psEncC,            /* I/O  Pointer to Silk encoder state               */
+    SKP_int32                   TargetRate_bps      /* I    Target max bitrate (bps)                    */
+)
+{
+    SKP_int k, ret = SKP_SILK_NO_ERROR;
+    SKP_int32 frac_Q6;
+    const SKP_int32 *rateTable;
+
+    /* Set bitrate/coding quality */
+    TargetRate_bps = SKP_LIMIT( TargetRate_bps, MIN_TARGET_RATE_BPS, MAX_TARGET_RATE_BPS );
+    if( TargetRate_bps != psEncC->TargetRate_bps ) {
+        psEncC->TargetRate_bps = TargetRate_bps;
+
+        /* If new TargetRate_bps, translate to SNR_dB value */
+        if( psEncC->fs_kHz == 8 ) {
+            rateTable = TargetRate_table_NB;
+        } else if( psEncC->fs_kHz == 12 ) {
+            rateTable = TargetRate_table_MB;
+        } else if( psEncC->fs_kHz == 16 ) {
+            rateTable = TargetRate_table_WB;
+        } else {
+            SKP_assert( 0 );
+        }
+
+        /* Reduce bitrate for 10 ms modes in these calculations */
+        if( psEncC->nb_subfr == 2 ) {
+            TargetRate_bps -= REDUCE_BITRATE_10_MS_BPS;
+        }
+
+        /* Find bitrate interval in table and interpolate */
+        for( k = 1; k < TARGET_RATE_TAB_SZ; k++ ) {
+            if( TargetRate_bps <= rateTable[ k ] ) {
+                frac_Q6 = SKP_DIV32( SKP_LSHIFT( TargetRate_bps - rateTable[ k - 1 ], 6 ), 
+                                                 rateTable[ k ] - rateTable[ k - 1 ] );
+                psEncC->SNR_dB_Q7 = SKP_LSHIFT( SNR_table_Q1[ k - 1 ], 6 ) + SKP_MUL( frac_Q6, SNR_table_Q1[ k ] - SNR_table_Q1[ k - 1 ] );
+                break;
+            }
+        }
+    }
+
+    return ret;
+}
--- a/src_common/SKP_Silk_control_audio_bandwidth.c
+++ b/src_common/SKP_Silk_control_audio_bandwidth.c
@@ -34,42 +34,45 @@
     SKP_int32                   TargetRate_bps      /* I    Target max bitrate (bps)                    */
 )
 {
-    SKP_int fs_kHz;
-
-    fs_kHz = psEncC->fs_kHz;
-
+    SKP_int   fs_kHz;
+    SKP_int32 fs_Hz;
+    
     /* Reduce bitrate for 10 ms modes in these calculations */
     if( psEncC->nb_subfr == 2 ) {
         TargetRate_bps -= REDUCE_BITRATE_10_MS_BPS;
     }
 
-    if( fs_kHz == 0 ) {
+    fs_kHz = psEncC->fs_kHz;
+    fs_Hz = SKP_SMULBB( fs_kHz, 1000 );
+    if( fs_Hz == 0 ) {
         /* Encoder has just been initialized */
         if( TargetRate_bps >= WB2MB_BITRATE_BPS ) {
-            fs_kHz = 16;
+            fs_Hz = 16000;
         } else if( TargetRate_bps >= MB2NB_BITRATE_BPS ) {
-            fs_kHz = 12;
+            fs_Hz = 12000;
         } else {
-            fs_kHz = 8;
+            fs_Hz = 8000;
         }
         /* Make sure internal rate is not higher than external rate or maximum allowed, or lower than minimum allowed */
-        fs_kHz = SKP_min( fs_kHz, SKP_DIV32_16( psEncC->API_fs_Hz, 1000 ) );
-        fs_kHz = SKP_min( fs_kHz, psEncC->maxInternal_fs_kHz );
-        fs_kHz = SKP_max( fs_kHz, psEncC->minInternal_fs_kHz );
-    } else if( SKP_SMULBB( fs_kHz, 1000 ) > psEncC->API_fs_Hz || fs_kHz > psEncC->maxInternal_fs_kHz || fs_kHz < psEncC->minInternal_fs_kHz ) {
+        fs_Hz = SKP_min( fs_Hz, psEncC->API_fs_Hz );
+        fs_Hz = SKP_min( fs_Hz, psEncC->maxInternal_fs_Hz );
+        fs_Hz = SKP_max( fs_Hz, psEncC->minInternal_fs_Hz );
+        fs_kHz = SKP_DIV32_16( fs_Hz, 1000 );
+    } else if( fs_Hz > psEncC->API_fs_Hz || fs_Hz > psEncC->maxInternal_fs_Hz || fs_Hz < psEncC->minInternal_fs_Hz ) {
         /* Make sure internal rate is not higher than external rate or maximum allowed, or lower than minimum allowed */
-        fs_kHz = SKP_DIV32_16( psEncC->API_fs_Hz, 1000 );
-        fs_kHz = SKP_min( fs_kHz, psEncC->maxInternal_fs_kHz );
-        fs_kHz = SKP_max( fs_kHz, psEncC->minInternal_fs_kHz );
+        fs_Hz = psEncC->API_fs_Hz;
+        fs_Hz = SKP_min( fs_Hz, psEncC->maxInternal_fs_Hz );
+        fs_Hz = SKP_max( fs_Hz, psEncC->minInternal_fs_Hz );
+        fs_kHz = SKP_DIV32_16( fs_Hz, 1000 );
     } else {
         /* State machine for the internal sampling rate switching */
-        if( psEncC->API_fs_Hz > 8000 && psEncC->prevSignalType == TYPE_NO_VOICE_ACTIVITY ) { /* Low speech activity */
+        if( psEncC->API_fs_Hz > 8000 && psEncC->prevSignalType == TYPE_NO_VOICE_ACTIVITY ) {
             /* Check if we should switch down */
-            if( ( psEncC->fs_kHz == 12 && TargetRate_bps < MB2NB_BITRATE_BPS && psEncC->minInternal_fs_kHz <=  8 ) ||
-                ( psEncC->fs_kHz == 16 && TargetRate_bps < WB2MB_BITRATE_BPS && psEncC->minInternal_fs_kHz <= 12 ) ) 
+            if( ( psEncC->fs_kHz == 12 && TargetRate_bps < MB2NB_BITRATE_BPS && psEncC->minInternal_fs_Hz <=  8000 ) ||
+                ( psEncC->fs_kHz == 16 && TargetRate_bps < WB2MB_BITRATE_BPS && psEncC->minInternal_fs_Hz <= 12000 ) ) 
             {
                 /* Switch down */
-                if( SWITCH_TRANSITION_FILTERING && psEncC->sLP.mode == 0 ) {
+                if( psEncC->sLP.mode == 0 ) {
                     /* New transition */
                     psEncC->sLP.transition_frame_no = TRANSITION_FRAMES;
 
@@ -88,11 +91,11 @@
                 } 
             } 
             else
-            if( ( psEncC->fs_kHz ==  8 && TargetRate_bps > NB2MB_BITRATE_BPS && psEncC->maxInternal_fs_kHz >= 12 && psEncC->API_fs_Hz >= 12000 ) ||
-                ( psEncC->fs_kHz == 12 && TargetRate_bps > MB2WB_BITRATE_BPS && psEncC->maxInternal_fs_kHz >= 16 && psEncC->API_fs_Hz >= 16000 ) ) 
+            if( ( psEncC->fs_kHz ==  8 && TargetRate_bps > NB2MB_BITRATE_BPS && psEncC->maxInternal_fs_Hz >= 12000 && psEncC->API_fs_Hz >= 12000 ) ||
+                ( psEncC->fs_kHz == 12 && TargetRate_bps > MB2WB_BITRATE_BPS && psEncC->maxInternal_fs_Hz >= 16000 && psEncC->API_fs_Hz >= 16000 ) ) 
             {
                 /* Switch up */
-                if( SWITCH_TRANSITION_FILTERING && psEncC->sLP.mode == 0 ) {
+                if( psEncC->sLP.mode == 0 ) {
                     /* Switch to a higher sample frequency */
                     fs_kHz = psEncC->fs_kHz == 8 ? 12 : 16;
 
--- /dev/null
+++ b/src_common/SKP_Silk_control_codec.c
@@ -1,0 +1,410 @@
+/***********************************************************************
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. 
+Redistribution and use in source and binary forms, with or without 
+modification, (subject to the limitations in the disclaimer below) 
+are permitted provided that the following conditions are met:
+- Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+- Redistributions in binary form must reproduce the above copyright 
+notice, this list of conditions and the following disclaimer in the 
+documentation and/or other materials provided with the distribution.
+- Neither the name of Skype Limited, nor the names of specific 
+contributors, may be used to endorse or promote products derived from 
+this software without specific prior written permission.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 
+BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
+CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
+BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+***********************************************************************/
+
+#include "SKP_Silk_tuning_parameters.h"
+#if FIXED_POINT
+#include "SKP_Silk_main_FIX.h"
+#define SKP_Silk_encoder_state_Fxx      SKP_Silk_encoder_state_FIX
+#else
+#include "SKP_Silk_main_FLP.h"
+#define SKP_Silk_encoder_state_Fxx      SKP_Silk_encoder_state_FLP
+#endif
+
+SKP_int SKP_Silk_setup_resamplers(
+    SKP_Silk_encoder_state_Fxx      *psEnc,             /* I/O                      */
+    SKP_int                         fs_kHz              /* I                        */
+);
+
+SKP_int SKP_Silk_setup_fs(
+    SKP_Silk_encoder_state_Fxx      *psEnc,             /* I/O                      */
+    SKP_int                         fs_kHz,             /* I                        */
+    SKP_int                         PacketSize_ms       /* I                        */
+);
+
+SKP_int SKP_Silk_setup_complexity(
+    SKP_Silk_encoder_state          *psEncC,            /* I/O                      */
+    SKP_int                         Complexity          /* I                        */
+);
+
+static SKP_int SKP_Silk_setup_LBRR(
+    SKP_Silk_encoder_state          *psEncC,            /* I/O                      */
+    const SKP_int32                 TargetRate_bps      /* I                        */
+);
+
+
+/* Control encoder */
+SKP_int SKP_Silk_control_encoder( 
+    SKP_Silk_encoder_state_Fxx      *psEnc,             /* I/O  Pointer to Silk encoder state           */
+    SKP_SILK_SDK_EncControlStruct   *encControl,        /* I:   Control structure                       */
+    const SKP_int32                 TargetRate_bps      /* I    Target max bitrate (bps)                */
+)
+{
+    SKP_int   fs_kHz, ret = 0;
+
+    psEnc->sCmn.useDTX            = encControl->useDTX;
+    psEnc->sCmn.useCBR            = encControl->useCBR;
+    psEnc->sCmn.API_fs_Hz         = encControl->API_sampleRate;
+    psEnc->sCmn.maxInternal_fs_Hz = encControl->maxInternalSampleRate;
+    psEnc->sCmn.minInternal_fs_Hz = encControl->minInternalSampleRate;
+    psEnc->sCmn.useInBandFEC      = encControl->useInBandFEC;
+
+    if( psEnc->sCmn.controlled_since_last_payload != 0 && psEnc->sCmn.prefillFlag == 0 ) {
+        if( psEnc->sCmn.API_fs_Hz != psEnc->sCmn.prev_API_fs_Hz && psEnc->sCmn.fs_kHz > 0 ) {
+            /* Change in API sampling rate in the middle of encoding a packet */
+            ret += SKP_Silk_setup_resamplers( psEnc, psEnc->sCmn.fs_kHz );
+        }
+        return ret;
+    }
+
+    /* Beyond this point we know that there are no previously coded frames in the payload buffer */
+
+    /********************************************/
+    /* Determine internal sampling rate         */
+    /********************************************/
+    fs_kHz = SKP_Silk_control_audio_bandwidth( &psEnc->sCmn, TargetRate_bps );
+
+    /********************************************/
+    /* Prepare resampler and buffered data      */
+    /********************************************/
+    ret += SKP_Silk_setup_resamplers( psEnc, fs_kHz );
+
+    /********************************************/
+    /* Set internal sampling frequency          */
+    /********************************************/
+    ret += SKP_Silk_setup_fs( psEnc, fs_kHz, encControl->payloadSize_ms );
+
+    /********************************************/
+    /* Set encoding complexity                  */
+    /********************************************/
+    ret += SKP_Silk_setup_complexity( &psEnc->sCmn, encControl->complexity  );
+
+    /********************************************/
+    /* Set packet loss rate measured by farend  */
+    /********************************************/
+    psEnc->sCmn.PacketLoss_perc = encControl->packetLossPercentage;
+
+    /********************************************/
+    /* Set LBRR usage                           */
+    /********************************************/
+    ret += SKP_Silk_setup_LBRR( &psEnc->sCmn, TargetRate_bps );
+
+    psEnc->sCmn.controlled_since_last_payload = 1;
+
+    return ret;
+}
+
+SKP_int SKP_Silk_setup_resamplers(
+    SKP_Silk_encoder_state_Fxx      *psEnc,             /* I/O                      */
+    SKP_int                         fs_kHz              /* I                        */
+)
+{
+    SKP_int   ret = SKP_SILK_NO_ERROR;
+    SKP_int32 nSamples_temp;
+    
+    if( psEnc->sCmn.fs_kHz != fs_kHz || psEnc->sCmn.prev_API_fs_Hz != psEnc->sCmn.API_fs_Hz ) 
+    {
+        if( psEnc->sCmn.fs_kHz == 0 ) {
+            /* Initialize the resampler for enc_API.c preparing resampling from API_fs_Hz to fs_kHz */
+            ret += SKP_Silk_resampler_init( &psEnc->sCmn.resampler_state, psEnc->sCmn.API_fs_Hz, fs_kHz * 1000 );
+        } else {
+            /* Allocate space for worst case temporary upsampling, 8 to 48 kHz, so a factor 6 */
+            SKP_int16 x_buf_API_fs_Hz[ ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) * ( MAX_API_FS_KHZ / 8 ) ];
+#if FIXED_POINT
+            SKP_int16 *x_bufFIX = psEnc->x_buf;
+#else
+            SKP_int16 x_bufFIX[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ]; 
+#endif
+
+            nSamples_temp = SKP_LSHIFT( psEnc->sCmn.frame_length, 1 ) + LA_SHAPE_MS * psEnc->sCmn.fs_kHz;
+
+#if !FIXED_POINT
+            SKP_float2short_array( x_bufFIX, psEnc->x_buf, nSamples_temp );
+#endif
+
+            if( SKP_SMULBB( fs_kHz, 1000 ) < psEnc->sCmn.API_fs_Hz && psEnc->sCmn.fs_kHz != 0 ) {
+                /* Resample buffered data in x_buf to API_fs_Hz */
+
+                SKP_Silk_resampler_state_struct  temp_resampler_state;
+
+                /* Initialize resampler for temporary resampling of x_buf data to API_fs_Hz */
+                ret += SKP_Silk_resampler_init( &temp_resampler_state, SKP_SMULBB( psEnc->sCmn.fs_kHz, 1000 ), psEnc->sCmn.API_fs_Hz );
+
+                /* Temporary resampling of x_buf data to API_fs_Hz */
+                ret += SKP_Silk_resampler( &temp_resampler_state, x_buf_API_fs_Hz, x_bufFIX, nSamples_temp );
+
+                /* Calculate number of samples that has been temporarily upsampled */
+                nSamples_temp = SKP_DIV32_16( nSamples_temp * psEnc->sCmn.API_fs_Hz, SKP_SMULBB( psEnc->sCmn.fs_kHz, 1000 ) );
+
+                /* Initialize the resampler for enc_API.c preparing resampling from API_fs_Hz to fs_kHz */
+                ret += SKP_Silk_resampler_init( &psEnc->sCmn.resampler_state, psEnc->sCmn.API_fs_Hz, SKP_SMULBB( fs_kHz, 1000 ) );
+
+            } else {
+                /* Copy data */
+                SKP_memcpy( x_buf_API_fs_Hz, x_bufFIX, nSamples_temp * sizeof( SKP_int16 ) );
+            }
+
+            if( 1000 * fs_kHz != psEnc->sCmn.API_fs_Hz ) {
+                /* Correct resampler state (unless resampling by a factor 1) by resampling buffered data from API_fs_Hz to fs_kHz */
+                ret += SKP_Silk_resampler( &psEnc->sCmn.resampler_state, x_bufFIX, x_buf_API_fs_Hz, nSamples_temp );
+            }
+#if !FIXED_POINT
+            SKP_short2float_array( psEnc->x_buf, x_bufFIX, ( 2 * MAX_FRAME_LENGTH_MS + LA_SHAPE_MS ) * fs_kHz );
+#endif
+        }
+    }
+
+    psEnc->sCmn.prev_API_fs_Hz = psEnc->sCmn.API_fs_Hz;
+
+    return ret;
+}
+
+SKP_int SKP_Silk_setup_fs(
+    SKP_Silk_encoder_state_Fxx      *psEnc,             /* I/O                      */
+    SKP_int                         fs_kHz,             /* I                        */
+    SKP_int                         PacketSize_ms       /* I                        */
+)
+{
+    SKP_int ret = SKP_SILK_NO_ERROR;
+
+    /* Set packet size */
+    if( PacketSize_ms != psEnc->sCmn.PacketSize_ms ) {
+        if( ( PacketSize_ms !=  10 ) &&
+            ( PacketSize_ms !=  20 ) &&
+            ( PacketSize_ms !=  40 ) && 
+            ( PacketSize_ms !=  60 ) ) {
+            ret = SKP_SILK_ENC_PACKET_SIZE_NOT_SUPPORTED;
+        }
+        if( PacketSize_ms <= 10 ) {
+            psEnc->sCmn.nFramesPerPacket = 1;
+            psEnc->sCmn.nb_subfr = PacketSize_ms == 10 ? 2 : 1;
+            psEnc->sCmn.frame_length = SKP_SMULBB( PacketSize_ms, fs_kHz );
+            psEnc->sCmn.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS_2_SF, fs_kHz );
+            if( psEnc->sCmn.fs_kHz == 8 ) {
+                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_NB_iCDF;
+            } else {
+                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_iCDF;
+            }
+        } else {
+            psEnc->sCmn.nFramesPerPacket = SKP_DIV32_16( PacketSize_ms, MAX_FRAME_LENGTH_MS );
+            psEnc->sCmn.nb_subfr = MAX_NB_SUBFR;
+            psEnc->sCmn.frame_length = SKP_SMULBB( 20, fs_kHz );
+            psEnc->sCmn.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS, fs_kHz );
+            if( psEnc->sCmn.fs_kHz == 8 ) {
+                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_NB_iCDF;
+            } else {
+                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_iCDF; 
+            }
+        }
+        psEnc->sCmn.PacketSize_ms  = PacketSize_ms;
+        psEnc->sCmn.TargetRate_bps = 0;         /* trigger new SNR computation */
+    }
+
+    /* Set internal sampling frequency */
+    SKP_assert( fs_kHz == 8 || fs_kHz == 12 || fs_kHz == 16 );
+    SKP_assert( psEnc->sCmn.nb_subfr == 2 || psEnc->sCmn.nb_subfr == 4 );
+    if( psEnc->sCmn.fs_kHz != fs_kHz ) {
+        /* reset part of the state */
+#if FIXED_POINT
+        SKP_memset( &psEnc->sShape,               0, sizeof( SKP_Silk_shape_state_FIX ) );
+        SKP_memset( &psEnc->sPrefilt,             0, sizeof( SKP_Silk_prefilter_state_FIX ) );
+#else
+        SKP_memset( &psEnc->sShape,               0, sizeof( SKP_Silk_shape_state_FLP ) );
+        SKP_memset( &psEnc->sPrefilt,             0, sizeof( SKP_Silk_prefilter_state_FLP ) );
+#endif
+        SKP_memset( &psEnc->sCmn.sNSQ,            0, sizeof( SKP_Silk_nsq_state ) );
+        SKP_memset( psEnc->sCmn.prev_NLSFq_Q15,   0, sizeof( psEnc->sCmn.prev_NLSFq_Q15 ) );
+        SKP_memset( &psEnc->sCmn.sLP.In_LP_State, 0, sizeof( psEnc->sCmn.sLP.In_LP_State ) );
+        psEnc->sCmn.inputBufIx                  = 0;
+        psEnc->sCmn.nFramesAnalyzed             = 0;
+        psEnc->sCmn.TargetRate_bps              = 0;     /* trigger new SNR computation */
+
+        /* Initialize non-zero parameters */
+        psEnc->sCmn.prevLag                     = 100;
+        psEnc->sCmn.first_frame_after_reset     = 1;
+        psEnc->sPrefilt.lagPrev                 = 100;
+        psEnc->sShape.LastGainIndex             = 10;
+        psEnc->sCmn.sNSQ.lagPrev                = 100;
+        psEnc->sCmn.sNSQ.prev_inv_gain_Q16      = 65536;
+
+        psEnc->sCmn.fs_kHz = fs_kHz;
+        if( psEnc->sCmn.fs_kHz == 8 ) {
+            if( psEnc->sCmn.nb_subfr == MAX_NB_SUBFR ) {
+                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_NB_iCDF; 
+            } else {
+                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_NB_iCDF;
+            }
+        } else {
+            if( psEnc->sCmn.nb_subfr == MAX_NB_SUBFR ) {
+                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_iCDF; 
+            } else {
+                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_iCDF;
+            }
+        }
+        if( psEnc->sCmn.fs_kHz == 8 || psEnc->sCmn.fs_kHz == 12 ) {
+            psEnc->sCmn.predictLPCOrder = MIN_LPC_ORDER;
+            psEnc->sCmn.psNLSF_CB  = &SKP_Silk_NLSF_CB_NB_MB;
+        } else {
+            psEnc->sCmn.predictLPCOrder = MAX_LPC_ORDER;
+            psEnc->sCmn.psNLSF_CB  = &SKP_Silk_NLSF_CB_WB;
+        }
+        psEnc->sCmn.subfr_length   = SUB_FRAME_LENGTH_MS * fs_kHz;
+        psEnc->sCmn.frame_length   = SKP_SMULBB( psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr );
+        psEnc->sCmn.ltp_mem_length = SKP_SMULBB( LTP_MEM_LENGTH_MS, fs_kHz ); 
+        psEnc->sCmn.la_pitch       = SKP_SMULBB( LA_PITCH_MS, fs_kHz );
+        psEnc->sCmn.max_pitch_lag  = SKP_SMULBB( 18, fs_kHz );
+        if( psEnc->sCmn.nb_subfr == MAX_NB_SUBFR ) {
+            psEnc->sCmn.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS, fs_kHz );
+        } else {
+            psEnc->sCmn.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS_2_SF, fs_kHz );
+        }
+        if( psEnc->sCmn.fs_kHz == 16 ) {
+            psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_WB, 9 );
+            psEnc->sCmn.pitch_lag_low_bits_iCDF = SKP_Silk_uniform8_iCDF;
+        } else if( psEnc->sCmn.fs_kHz == 12 ) {
+            psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_MB, 9 );
+            psEnc->sCmn.pitch_lag_low_bits_iCDF = SKP_Silk_uniform6_iCDF;
+        } else {
+            psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_NB, 9 );
+            psEnc->sCmn.pitch_lag_low_bits_iCDF = SKP_Silk_uniform4_iCDF;
+        }
+    }
+
+    /* Check that settings are valid */
+    SKP_assert( ( psEnc->sCmn.subfr_length * psEnc->sCmn.nb_subfr ) == psEnc->sCmn.frame_length );
+ 
+    return ret;
+}
+
+SKP_int SKP_Silk_setup_complexity(
+    SKP_Silk_encoder_state          *psEncC,            /* I/O                      */
+    SKP_int                         Complexity          /* I                        */
+)
+{
+    SKP_int ret = 0;
+
+    /* Set encoding complexity */
+    SKP_assert( Complexity >= 0 && Complexity <= 10 );
+    if( Complexity < 2 ) {
+        psEncC->pitchEstimationComplexity       = SKP_Silk_PE_MIN_COMPLEX;
+        psEncC->pitchEstimationThreshold_Q16    = SKP_FIX_CONST( 0.8, 16 );
+        psEncC->pitchEstimationLPCOrder         = 6;
+        psEncC->shapingLPCOrder                 = 8;
+        psEncC->la_shape                        = 3 * psEncC->fs_kHz;
+        psEncC->nStatesDelayedDecision          = 1;
+        psEncC->useInterpolatedNLSFs            = 0;
+        psEncC->LTPQuantLowComplexity           = 1;
+        psEncC->NLSF_MSVQ_Survivors             = 2;
+        psEncC->warping_Q16                     = 0;
+    } else if( Complexity < 4 ) {
+        psEncC->pitchEstimationComplexity       = SKP_Silk_PE_MID_COMPLEX;
+        psEncC->pitchEstimationThreshold_Q16    = SKP_FIX_CONST( 0.76, 16 );
+        psEncC->pitchEstimationLPCOrder         = 8;
+        psEncC->shapingLPCOrder                 = 10;
+        psEncC->la_shape                        = 5 * psEncC->fs_kHz;
+        psEncC->nStatesDelayedDecision          = 1;
+        psEncC->useInterpolatedNLSFs            = 1;
+        psEncC->LTPQuantLowComplexity           = 0;
+        psEncC->NLSF_MSVQ_Survivors             = 4;
+        psEncC->warping_Q16                     = 0;
+    } else if( Complexity < 6 ) {
+        psEncC->pitchEstimationComplexity       = SKP_Silk_PE_MID_COMPLEX;
+        psEncC->pitchEstimationThreshold_Q16    = SKP_FIX_CONST( 0.74, 16 );
+        psEncC->pitchEstimationLPCOrder         = 10;
+        psEncC->shapingLPCOrder                 = 12;
+        psEncC->la_shape                        = 5 * psEncC->fs_kHz;
+        psEncC->nStatesDelayedDecision          = 2;
+        psEncC->useInterpolatedNLSFs            = 0;
+        psEncC->LTPQuantLowComplexity           = 0;
+        psEncC->NLSF_MSVQ_Survivors             = 6;
+        psEncC->warping_Q16                     = psEncC->fs_kHz * SKP_FIX_CONST( WARPING_MULTIPLIER, 16 );
+    } else if( Complexity < 8 ) {
+        psEncC->pitchEstimationComplexity       = SKP_Silk_PE_MID_COMPLEX;
+        psEncC->pitchEstimationThreshold_Q16    = SKP_FIX_CONST( 0.72, 16 );
+        psEncC->pitchEstimationLPCOrder         = 12;
+        psEncC->shapingLPCOrder                 = 14;
+        psEncC->la_shape                        = 5 * psEncC->fs_kHz;
+        psEncC->nStatesDelayedDecision          = 3;
+        psEncC->useInterpolatedNLSFs            = 0;
+        psEncC->LTPQuantLowComplexity           = 0;
+        psEncC->NLSF_MSVQ_Survivors             = 8;
+        psEncC->warping_Q16                     = psEncC->fs_kHz * SKP_FIX_CONST( WARPING_MULTIPLIER, 16 );
+    } else {
+        psEncC->pitchEstimationComplexity       = SKP_Silk_PE_MAX_COMPLEX;
+        psEncC->pitchEstimationThreshold_Q16    = SKP_FIX_CONST( 0.7, 16 );
+        psEncC->pitchEstimationLPCOrder         = 16;
+        psEncC->shapingLPCOrder                 = 16;
+        psEncC->la_shape                        = 5 * psEncC->fs_kHz;
+        psEncC->nStatesDelayedDecision          = MAX_DEL_DEC_STATES;
+        psEncC->useInterpolatedNLSFs            = 1;
+        psEncC->LTPQuantLowComplexity           = 0;
+        psEncC->NLSF_MSVQ_Survivors             = 16;
+        psEncC->warping_Q16                     = psEncC->fs_kHz * SKP_FIX_CONST( WARPING_MULTIPLIER, 16 );
+    }
+
+    /* Do not allow higher pitch estimation LPC order than predict LPC order */
+    psEncC->pitchEstimationLPCOrder = SKP_min_int( psEncC->pitchEstimationLPCOrder, psEncC->predictLPCOrder );
+    psEncC->shapeWinLength          = SUB_FRAME_LENGTH_MS * psEncC->fs_kHz + 2 * psEncC->la_shape;
+
+    SKP_assert( psEncC->pitchEstimationLPCOrder <= MAX_FIND_PITCH_LPC_ORDER );
+    SKP_assert( psEncC->shapingLPCOrder         <= MAX_SHAPE_LPC_ORDER      );
+    SKP_assert( psEncC->nStatesDelayedDecision  <= MAX_DEL_DEC_STATES       );
+    SKP_assert( psEncC->warping_Q16             <= 32767                    );
+    SKP_assert( psEncC->la_shape                <= LA_SHAPE_MAX             );
+    SKP_assert( psEncC->shapeWinLength          <= SHAPE_LPC_WIN_MAX        );
+    SKP_assert( psEncC->NLSF_MSVQ_Survivors     <= NLSF_VQ_MAX_SURVIVORS    );
+
+    return ret;
+}
+
+SKP_INLINE SKP_int SKP_Silk_setup_LBRR(
+    SKP_Silk_encoder_state          *psEncC,            /* I/O                      */
+    const SKP_int32                 TargetRate_bps      /* I                        */
+)
+{
+    SKP_int   ret = SKP_SILK_NO_ERROR;
+    SKP_int32 LBRRRate_thres_bps;
+
+    SKP_assert( psEncC->fs_kHz == 8 || psEncC->fs_kHz == 12 || psEncC->fs_kHz == 16 );
+    if( psEncC->fs_kHz == 8 ) {
+        LBRRRate_thres_bps = LBRR_NB_MIN_RATE_BPS;
+    } else if( psEncC->fs_kHz == 12 ) {
+        LBRRRate_thres_bps = LBRR_MB_MIN_RATE_BPS;
+    } else {
+        LBRRRate_thres_bps = LBRR_WB_MIN_RATE_BPS;
+    }
+
+    LBRRRate_thres_bps = SKP_RSHIFT( SKP_SMULBB( LBRRRate_thres_bps, 7 - psEncC->PacketLoss_perc ), 2 );
+    if( psEncC->useInBandFEC && TargetRate_bps >= LBRRRate_thres_bps && psEncC->PacketLoss_perc > 0 ) {
+        /* Set gain increase / rate reduction for LBRR usage */
+        psEncC->LBRR_GainIncreases = SKP_max_int( 7 - SKP_SMULWB( psEncC->PacketLoss_perc, SKP_FIX_CONST( 0.4, 16 ) ), 2 );
+        psEncC->LBRR_enabled = 1;
+    } else {
+        psEncC->LBRR_enabled = 0;
+    }
+
+    return ret;
+}
--- a/src_common/SKP_Silk_dec_API.c
+++ b/src_common/SKP_Silk_dec_API.c
@@ -31,6 +31,14 @@
 #include "SKP_Silk_SDK_API.h"
 #include "SKP_Silk_main.h"
 
+/* Decoder Super Struct */
+typedef struct {
+    SKP_Silk_decoder_state          channel_state[ DECODER_NUM_CHANNELS ];
+    stereo_state                    sStereo;
+    SKP_int                         nChannels;
+} SKP_Silk_decoder;
+
+
 /*********************/
 /* Decoder functions */
 /*********************/
@@ -39,7 +47,7 @@
 {
     SKP_int ret = SKP_SILK_NO_ERROR;
 
-    *decSizeBytes = sizeof( SKP_Silk_decoder_state );
+    *decSizeBytes = sizeof( SKP_Silk_decoder );
 
     return ret;
 }
@@ -49,61 +57,13 @@
     void* decState                                      /* I/O: State                                          */
 )
 {
-    SKP_int ret = SKP_SILK_NO_ERROR;
-    SKP_Silk_decoder_state *struc;
+    SKP_int n, ret = SKP_SILK_NO_ERROR;
+    SKP_Silk_decoder_state *channel_state = ((SKP_Silk_decoder *)decState)->channel_state;
 
-    struc = (SKP_Silk_decoder_state *)decState;
-
-    ret  = SKP_Silk_init_decoder( struc );
-
-    return ret;
-}
-
-/* Prefill LPC synthesis buffer, HP filter and upsampler. Input must be exactly 10 ms of audio. */
-SKP_int SKP_Silk_SDK_Decoder_prefill_buffers(           /* O:   Returns error code                              */
-    void*                               decState,       /* I/O: State                                           */
-    SKP_SILK_SDK_DecControlStruct*      decControl,     /* I/O: Control Structure                               */
-    const SKP_int16                     *samplesIn,     /* I:   Speech sample input vector  (10 ms)             */
-    SKP_int                             nSamplesIn      /* I:   Number of samples in input vector               */
-)
-{
-    SKP_int   i, nSamples, ret = 0;
-    SKP_Silk_decoder_state *psDec = ( SKP_Silk_decoder_state *)decState;
-    SKP_Silk_resampler_state_struct resampler_state;
-    SKP_int16 buf[ 10 * MAX_FS_KHZ ];
-    SKP_int16 buf_out[ 10 * MAX_API_FS_KHZ ];
-    const SKP_int16 *in_ptr;
-
-    /* Compute some numbers at API sampling rate */
-    if( nSamplesIn != SKP_DIV32_16( decControl->API_sampleRate, 100 ) ) {
-        return -1;
+    for( n = 0; n < DECODER_NUM_CHANNELS; n++ ) {
+        ret  = SKP_Silk_init_decoder( &channel_state[ n ] );
     }
 
-    /* Resample input if necessary */
-    if( decControl->API_sampleRate != SKP_SMULBB( 1000, psDec->fs_kHz ) ) { 
-        ret += SKP_Silk_resampler_init( &resampler_state, decControl->API_sampleRate, SKP_SMULBB( 1000, psDec->fs_kHz ) );
-        ret += SKP_Silk_resampler( &resampler_state, buf, samplesIn, nSamplesIn );
-        in_ptr = buf;
-        nSamples = SKP_SMULBB( 10, psDec->fs_kHz );
-    } else {
-        in_ptr = samplesIn;
-        nSamples = nSamplesIn;
-    }
-
-    /* Set synthesis filter state */
-    for( i = 0; i < psDec->LPC_order; i++ ) {
-        psDec->sLPC_Q14[ MAX_LPC_ORDER - i ] = SKP_LSHIFT( SKP_SMULWB( psDec->prev_inv_gain_Q16, in_ptr[ nSamples - i ] ), 14 );
-    }
-
-    /* HP filter */
-    SKP_Silk_biquad_alt( in_ptr, psDec->HP_B, psDec->HP_A, psDec->HPState, buf, nSamples );
-
-    /* Output upsampler */
-    SKP_Silk_resampler( &psDec->resampler_state, buf_out, buf, nSamples );
-
-    /* Avoid using LSF interpolation or pitch prediction in first next frame */
-    psDec->first_frame_after_reset = 1;
-
     return ret;
 }
 
@@ -111,90 +71,183 @@
 SKP_int SKP_Silk_SDK_Decode(
     void*                               decState,       /* I/O: State                                           */
     SKP_SILK_SDK_DecControlStruct*      decControl,     /* I/O: Control Structure                               */
-    SKP_int                             lostFlag,       /* I:   0: no loss, 1 loss, 2 decode fec                */
+    SKP_int                             lostFlag,       /* I:   0: no loss, 1 loss, 2 decode FEC                */
     SKP_int                             newPacketFlag,  /* I:   Indicates first decoder call for this packet    */
     ec_dec                              *psRangeDec,    /* I/O  Compressor data structure                       */
-    const SKP_int                       nBytesIn,       /* I:   Number of input bytes                           */
     SKP_int16                           *samplesOut,    /* O:   Decoded output speech vector                    */
     SKP_int32                           *nSamplesOut    /* O:   Number of samples decoded                       */
 )
 {
-    SKP_int ret = SKP_SILK_NO_ERROR, prev_fs_kHz;
-    SKP_Silk_decoder_state *psDec;
+    SKP_int   i, n, prev_fs_kHz, doResample, flags, nFlags, MS_predictorIx, ret = SKP_SILK_NO_ERROR;
+    SKP_int32 nSamplesOutDec, LBRR_symbol;
+    SKP_int16 samplesOut1_tmp[ 2 * MAX_FS_KHZ * MAX_FRAME_LENGTH_MS ];
+    SKP_int16 samplesOut2_tmp[ MAX_API_FS_KHZ * MAX_FRAME_LENGTH_MS ];
+    SKP_int16 *dec_out_ptr, *resample_out_ptr;
+    SKP_Silk_decoder *psDec = ( SKP_Silk_decoder * )decState;
+    SKP_Silk_decoder_state *channel_state = psDec->channel_state;
 
-    psDec = (SKP_Silk_decoder_state *)decState;
-
     /**********************************/
     /* Test if first frame in payload */
     /**********************************/
     if( newPacketFlag ) {
-        /* First Frame in Payload */
-        psDec->nFramesDecoded = 0;  /* Used to count frames in packet */
+        for( n = 0; n < decControl->nChannels; n++ ) {
+            channel_state[ n ].nFramesDecoded = 0;  /* Used to count frames in packet */
+        }
     }
 
     /* Save previous sample frequency */
-    prev_fs_kHz = psDec->fs_kHz;
+    prev_fs_kHz = channel_state[ 0 ].fs_kHz;
 
-    if( psDec->nFramesDecoded == 0 ) {
-        SKP_int fs_kHz_dec;
-        if( decControl->payloadSize_ms == 10 ) {
-            psDec->nFramesPerPacket = 1;
-            psDec->nb_subfr = 2;
-        } else if( decControl->payloadSize_ms == 20 ) {
-            psDec->nFramesPerPacket = 1;
-            psDec->nb_subfr = 4;
-        } else if( decControl->payloadSize_ms == 40 ) {
-            psDec->nFramesPerPacket = 2;
-            psDec->nb_subfr = 4;
-        } else if( decControl->payloadSize_ms == 60 ) {
-            psDec->nFramesPerPacket = 3;
-            psDec->nb_subfr = 4;
-        } else {
-            SKP_assert( 0 );
-            return SKP_SILK_DEC_INVALID_FRAME_SIZE;
-        } 
-        fs_kHz_dec = ( decControl->internalSampleRate >> 10 ) + 1;
-        if( fs_kHz_dec != 8 && fs_kHz_dec != 12 && fs_kHz_dec != 16 ) {
-            SKP_assert( 0 );
-            return SKP_SILK_DEC_INVALID_SAMPLING_FREQUENCY;
+    if( decControl->nChannels > psDec->nChannels ) {
+        /* Mono -> Stereo transition: init state of second channel and stereo state */
+        SKP_memset( &psDec->sStereo, 0, sizeof( psDec->sStereo ) );
+        ret += SKP_Silk_init_decoder( &channel_state[ 1 ] );
+    }
+    psDec->nChannels = decControl->nChannels;
+
+    for( n = 0; n < decControl->nChannels; n++ ) {
+        if( channel_state[ n ].nFramesDecoded == 0 ) {
+            SKP_int fs_kHz_dec;
+            if( decControl->payloadSize_ms == 10 ) {
+                channel_state[ n ].nFramesPerPacket = 1;
+                channel_state[ n ].nb_subfr = 2;
+            } else if( decControl->payloadSize_ms == 20 ) {
+                channel_state[ n ].nFramesPerPacket = 1;
+                channel_state[ n ].nb_subfr = 4;
+            } else if( decControl->payloadSize_ms == 40 ) {
+                channel_state[ n ].nFramesPerPacket = 2;
+                channel_state[ n ].nb_subfr = 4;
+            } else if( decControl->payloadSize_ms == 60 ) {
+                channel_state[ n ].nFramesPerPacket = 3;
+                channel_state[ n ].nb_subfr = 4;
+            } else {
+                SKP_assert( 0 );
+                return SKP_SILK_DEC_INVALID_FRAME_SIZE;
+            } 
+            fs_kHz_dec = ( decControl->internalSampleRate >> 10 ) + 1;
+            if( fs_kHz_dec != 8 && fs_kHz_dec != 12 && fs_kHz_dec != 16 ) {
+                SKP_assert( 0 );
+                return SKP_SILK_DEC_INVALID_SAMPLING_FREQUENCY;
+            }
+            SKP_Silk_decoder_set_fs( &channel_state[ n ], fs_kHz_dec );
         }
-        SKP_Silk_decoder_set_fs( psDec, fs_kHz_dec );
     }
     
-    /* Call decoder for one frame */
-    ret += SKP_Silk_decode_frame( psDec, psRangeDec, samplesOut, nSamplesOut, nBytesIn, lostFlag );
-    
     if( decControl->API_sampleRate > MAX_API_FS_KHZ * 1000 || decControl->API_sampleRate < 8000 ) {
         ret = SKP_SILK_DEC_INVALID_SAMPLING_FREQUENCY;
         return( ret );
     }
 
-    /* Resample if needed */
-    if( SKP_SMULBB( psDec->fs_kHz, 1000 ) != decControl->API_sampleRate ) { 
-        SKP_int16 samplesOut_tmp[ MAX_API_FS_KHZ * MAX_FRAME_LENGTH_MS ];
-        SKP_assert( psDec->fs_kHz <= MAX_API_FS_KHZ );
+    doResample = SKP_SMULBB( channel_state[ 0 ].fs_kHz, 1000 ) != decControl->API_sampleRate;
 
-        /* Copy to a tmp buffer as the resampling writes to samplesOut */
-        SKP_memcpy( samplesOut_tmp, samplesOut, *nSamplesOut * sizeof( SKP_int16 ) );
+    /* Set up pointers to temp buffers */
+    if( doResample || decControl->nChannels == 2 ) { 
+        dec_out_ptr = samplesOut1_tmp;
+    } else {
+        dec_out_ptr = samplesOut;
+    }
+    if( decControl->nChannels == 2 ) {
+        resample_out_ptr = samplesOut2_tmp;
+    } else {
+        resample_out_ptr = samplesOut;
+    }
 
-        /* (Re-)initialize resampler state when switching internal sampling frequency */
-        if( prev_fs_kHz != psDec->fs_kHz || psDec->prev_API_sampleRate != decControl->API_sampleRate ) {
-            ret = SKP_Silk_resampler_init( &psDec->resampler_state, SKP_SMULBB( psDec->fs_kHz, 1000 ), decControl->API_sampleRate );
+    if( lostFlag != FLAG_PACKET_LOST && channel_state[ 0 ].nFramesDecoded == 0 ) {
+        /* First decoder call for this payload */
+        nFlags = SKP_SMULBB( decControl->nChannels, channel_state[ 0 ].nFramesPerPacket + 1 );
+        flags = SKP_RSHIFT( psRangeDec->buf[ 0 ], 8 - nFlags ) & ( SKP_LSHIFT( 1, nFlags ) - 1 );
+        for( i = 0; i < nFlags; i++ ) {
+            ec_dec_icdf( psRangeDec, SKP_Silk_uniform2_iCDF, 8 );
         }
+        /* Decode VAD flags and LBRR flag */
+        for( n = decControl->nChannels - 1; n >= 0; n-- ) {
+            channel_state[ n ].LBRR_flag = flags & 1;
+            flags = SKP_RSHIFT( flags, 1 );
+            for( i = channel_state[ n ].nFramesPerPacket - 1; i >= 0 ; i-- ) {
+                channel_state[ n ].VAD_flags[ i ] = flags & 1;
+                flags = SKP_RSHIFT( flags, 1 );
+            }
+        }       
+        /* Decode LBRR flags */
+        for( n = 0; n < decControl->nChannels; n++ ) {
+            SKP_memset( channel_state[ n ].LBRR_flags, 0, sizeof( channel_state[ n ].LBRR_flags ) );
+            if( channel_state[ n ].LBRR_flag ) {
+                if( channel_state[ n ].nFramesPerPacket == 1 ) {
+                    channel_state[ n ].LBRR_flags[ 0 ] = 1;
+                } else {
+                    LBRR_symbol = ec_dec_icdf( psRangeDec, SKP_Silk_LBRR_flags_iCDF_ptr[ channel_state[ n ].nFramesPerPacket - 2 ], 8 ) + 1;
+                    for( i = 0; i < channel_state[ n ].nFramesPerPacket; i++ ) {
+                        channel_state[ n ].LBRR_flags[ i ] = SKP_RSHIFT( LBRR_symbol, i ) & 1;
+                    }
+                }
+            }
+        }
 
-        /* Resample the output to API_sampleRate */
-        ret += SKP_Silk_resampler( &psDec->resampler_state, samplesOut, samplesOut_tmp, *nSamplesOut );
+        if( lostFlag == FLAG_DECODE_NORMAL ) {
+            /* Regular decoding: skip all LBRR data */
+            for( i = 0; i < channel_state[ 0 ].nFramesPerPacket; i++ ) {
+                for( n = 0; n < decControl->nChannels; n++ ) {
+                    if( channel_state[ n ].LBRR_flags[ i ] ) {
+                        SKP_int pulses[ MAX_FRAME_LENGTH ];
+                        SKP_Silk_decode_indices( &channel_state[ n ], psRangeDec, i, 1 );
+                        SKP_Silk_decode_pulses( psRangeDec, pulses, channel_state[ n ].indices.signalType, 
+                            channel_state[ n ].indices.quantOffsetType, channel_state[ n ].frame_length );
+                    }
+                }
+            }
+        }
+    }
 
-        /* Update the number of output samples */
-        *nSamplesOut = SKP_DIV32( ( SKP_int32 )*nSamplesOut * decControl->API_sampleRate, SKP_SMULBB( psDec->fs_kHz, 1000 ) );
+    /* Get MS predictor index */
+    if( decControl->nChannels == 2 ) {
+        MS_predictorIx = ec_dec_icdf( psRangeDec, SKP_Silk_stereo_predictor_iCDF, 8 );
     }
 
-    psDec->prev_API_sampleRate = decControl->API_sampleRate;
+    /* Call decoder for one frame */
+    for( n = 0; n < decControl->nChannels; n++ ) {
+        ret += SKP_Silk_decode_frame( &channel_state[ n ], psRangeDec, &dec_out_ptr[ n * MAX_FS_KHZ * MAX_FRAME_LENGTH_MS ], &nSamplesOutDec, lostFlag );
+    }
 
-    /* Copy all parameters that are needed out of internal structure to the control stucture */
-    decControl->frameSize                 = ( SKP_int )*nSamplesOut;
-    decControl->framesPerPayload          = ( SKP_int )psDec->nFramesPerPacket;
+    /* Convert Mid/Side to Left/Right */
+    if( decControl->nChannels == 2 ) {
+        SKP_Silk_stereo_MS_to_LR( &psDec->sStereo, dec_out_ptr, &dec_out_ptr[ MAX_FS_KHZ * MAX_FRAME_LENGTH_MS ], MS_predictorIx, channel_state[ 0 ].fs_kHz, nSamplesOutDec );
+    }
 
+    /* Number of output samples */
+    if( doResample ) {
+        *nSamplesOut = SKP_DIV32( nSamplesOutDec * decControl->API_sampleRate, SKP_SMULBB( channel_state[ 0 ].fs_kHz, 1000 ) );
+    } else {
+        *nSamplesOut = nSamplesOutDec;
+    }
+
+    for( n = 0; n < decControl->nChannels; n++ ) {
+        /* Resample if needed */
+        if( doResample ) {
+            /* Initialize resampler when switching internal or external sampling frequency */
+            if( prev_fs_kHz != channel_state[ n ].fs_kHz || channel_state[ n ].prev_API_sampleRate != decControl->API_sampleRate ) {
+                ret = SKP_Silk_resampler_init( &channel_state[ n ].resampler_state, SKP_SMULBB( channel_state[ n ].fs_kHz, 1000 ), decControl->API_sampleRate );
+            }
+
+            /* Resample the output to API_sampleRate */
+            ret += SKP_Silk_resampler( &channel_state[ n ].resampler_state, resample_out_ptr, &dec_out_ptr[ n * MAX_FS_KHZ * MAX_FRAME_LENGTH_MS ], nSamplesOutDec );
+        } else {
+            resample_out_ptr = &dec_out_ptr[ n * MAX_FS_KHZ * MAX_FRAME_LENGTH_MS ];
+        }
+
+        /* Interleave if needed */
+        if( decControl->nChannels == 2 ) {
+            for( i = 0; i < *nSamplesOut; i++ ) {
+                samplesOut[ n + 2 * i ] = resample_out_ptr[ i ];
+            }
+        }
+        
+        channel_state[ n ].prev_API_sampleRate = decControl->API_sampleRate;
+    }
+
+    /* Copy parameters to control stucture */
+    decControl->frameSize        = ( SKP_int )*nSamplesOut;
+    decControl->framesPerPayload = ( SKP_int )channel_state[ n ].nFramesPerPacket;
+
     return ret;
 }
 
@@ -217,6 +270,7 @@
 
     SKP_memset( Silk_TOC, 0, sizeof( Silk_TOC ) );
 
+    /* For stereo, extract the flags for the mid channel */
     flags = SKP_RSHIFT( payload[ 0 ], 7 - nFramesPerPayload ) & ( SKP_LSHIFT( 1, nFramesPerPayload + 1 ) - 1 );
 
     Silk_TOC->inbandFECFlag = flags & 1;
--- a/src_common/SKP_Silk_decode_frame.c
+++ b/src_common/SKP_Silk_decode_frame.c
@@ -28,10 +28,6 @@
 #include "SKP_Silk_main.h"
 #include "SKP_Silk_PLC.h"
 
-#define DECODE_NORMAL       0
-#define PACKET_LOST         1
-#define DECODE_LBRR         2
-
 /****************/
 /* Decode frame */
 /****************/
@@ -40,14 +36,11 @@
     ec_dec                      *psRangeDec,        /* I/O  Compressor data structure                   */
     SKP_int16                   pOut[],             /* O    Pointer to output speech frame              */
     SKP_int32                   *pN,                /* O    Pointer to size of output frame             */
-    const SKP_int               nBytes,             /* I    Payload length                              */
     SKP_int                     lostFlag            /* I    0: no loss, 1 loss, 2 decode fec            */
 )
 {
     SKP_Silk_decoder_control sDecCtrl;
-    SKP_int         i, L, mv_len, ret = 0;
-    SKP_int8        flags;
-    SKP_int32       LBRR_symbol;
+    SKP_int         L, mv_len, ret = 0;
     SKP_int         pulses[ MAX_FRAME_LENGTH ];
 
 TIC(DECODE_FRAME)
@@ -58,56 +51,9 @@
     /* Safety checks */
     SKP_assert( L > 0 && L <= MAX_FRAME_LENGTH );
 
-    /********************************************/
-    /* Decode Frame if packet is not lost       */
-    /********************************************/
-    if( lostFlag != PACKET_LOST && psDec->nFramesDecoded == 0 ) {
-        /* First decoder call for this payload */
-        /* Decode VAD flags and LBRR flag */
-        flags = SKP_RSHIFT( psRangeDec->buf[ 0 ], 7 - psDec->nFramesPerPacket ) & 
-            ( SKP_LSHIFT( 1, psDec->nFramesPerPacket + 1 ) - 1 );
-        psDec->LBRR_flag = flags & 1;
-        for( i = psDec->nFramesPerPacket - 1; i >= 0 ; i-- ) {
-            flags = SKP_RSHIFT( flags, 1 );
-            psDec->VAD_flags[ i ] = flags & 1;
-        }
-        for( i = 0; i < psDec->nFramesPerPacket + 1; i++ ) {
-            ec_dec_icdf( psRangeDec, SKP_Silk_uniform2_iCDF, 8 );
-        }
-       
-        /* Decode LBRR flags */
-        SKP_memset( psDec->LBRR_flags, 0, sizeof( psDec->LBRR_flags ) );
-        if( psDec->LBRR_flag ) {
-            if( psDec->nFramesPerPacket == 1 ) {
-                psDec->LBRR_flags[ 0 ] = 1;
-            } else {
-                LBRR_symbol = ec_dec_icdf( psRangeDec, SKP_Silk_LBRR_flags_iCDF_ptr[ psDec->nFramesPerPacket - 2 ], 8 ) + 1;
-                for( i = 0; i < psDec->nFramesPerPacket; i++ ) {
-                    psDec->LBRR_flags[ i ] = SKP_RSHIFT( LBRR_symbol, i ) & 1;
-                }
-            }
-        }
-
-        if( lostFlag == DECODE_NORMAL ) {
-            /* Regular decoding: skip all LBRR data */
-            for( i = 0; i < psDec->nFramesPerPacket; i++ ) {
-                if( psDec->LBRR_flags[ i ] ) {
-                    SKP_Silk_decode_indices( psDec, psRangeDec, i, 1 );
-                    SKP_Silk_decode_pulses( psRangeDec, pulses, psDec->indices.signalType, 
-                        psDec->indices.quantOffsetType, psDec->frame_length );
-                }
-            }
-        }
-
-    }
-
-    if( lostFlag == DECODE_LBRR && psDec->LBRR_flags[ psDec->nFramesDecoded ] == 0 ) {
-        /* Treat absent LBRR data as lost frame */
-        lostFlag = PACKET_LOST;
-        psDec->nFramesDecoded++;
-    }
-
-    if( lostFlag != PACKET_LOST ) {
+    if(   lostFlag == FLAG_DECODE_NORMAL || 
+        ( lostFlag == FLAG_DECODE_LBRR && psDec->LBRR_flags[ psDec->nFramesDecoded ] == 1 ) ) 
+    {
         /*********************************************/
         /* Decode quantization indices of side info  */
         /*********************************************/
@@ -151,7 +97,6 @@
 
         /* A frame has been decoded without errors */
         psDec->first_frame_after_reset = 0;
-        psDec->nFramesDecoded++;
     } else {
         /* Handle packet loss by extrapolation */
         SKP_Silk_PLC( psDec, &sDecCtrl, pOut, L, 1 );
@@ -175,20 +120,12 @@
     /************************************************/
     SKP_Silk_CNG( psDec, &sDecCtrl, pOut, L );
 
-    /********************************************/
-    /* HP filter output                            */
-    /********************************************/
-TIC(HP_out)
-    SKP_Silk_biquad_alt( pOut, psDec->HP_B, psDec->HP_A, psDec->HPState, pOut, L );
-TOC(HP_out)
-
     /* Update some decoder state variables */
     psDec->lagPrev = sDecCtrl.pitchL[ psDec->nb_subfr - 1 ];
+    psDec->nFramesDecoded++;
 
-    /********************************************/
-    /* set output frame length                    */
-    /********************************************/
-    *pN = ( SKP_int16 )L;
+    /* Set output frame length */
+    *pN = L;
 
 TOC(DECODE_FRAME)
 
--- a/src_common/SKP_Silk_decode_indices.c
+++ b/src_common/SKP_Silk_decode_indices.c
@@ -27,7 +27,7 @@
 
 #include "SKP_Silk_main.h"
 
-/* Decode indices from payload */
+/* Decode side-information parameters from payload */
 void SKP_Silk_decode_indices(
     SKP_Silk_decoder_state      *psDec,             /* I/O  State                                       */
     ec_dec                      *psRangeDec,        /* I/O  Compressor data structure                   */
@@ -40,6 +40,7 @@
     SKP_int16 ec_ix[ MAX_LPC_ORDER ];
     SKP_uint8 pred_Q8[ MAX_LPC_ORDER ];
 
+    /* Use conditional coding if previous frame available */
     if( FrameIndex > 0 && ( decode_LBRR == 0 || psDec->LBRR_flags[ FrameIndex - 1 ] == 1 ) ) {
         condCoding = 1;
     } else {
@@ -60,17 +61,17 @@
     /****************/
     /* Decode gains */
     /****************/
-    /* first subframe */    
+    /* First subframe */    
     if( condCoding ) {
-        /* conditional coding */
+        /* Conditional coding */
         psDec->indices.GainsIndices[ 0 ] = (SKP_int8)ec_dec_icdf( psRangeDec, SKP_Silk_delta_gain_iCDF, 8 );
     } else {
-        /* independent coding, in two stages: MSB bits followed by 3 LSBs */
+        /* Independent coding, in two stages: MSB bits followed by 3 LSBs */
         psDec->indices.GainsIndices[ 0 ]  = (SKP_int8)SKP_LSHIFT( ec_dec_icdf( psRangeDec, SKP_Silk_gain_iCDF[ psDec->indices.signalType ], 8 ), 3 );
         psDec->indices.GainsIndices[ 0 ] += (SKP_int8)ec_dec_icdf( psRangeDec, SKP_Silk_uniform8_iCDF, 8 );
     }
 
-    /* remaining subframes */
+    /* Remaining subframes */
     for( i = 1; i < psDec->nb_subfr; i++ ) {
         psDec->indices.GainsIndices[ i ] = (SKP_int8)ec_dec_icdf( psRangeDec, SKP_Silk_delta_gain_iCDF, 8 );
     }
--- a/src_common/SKP_Silk_decoder_set_fs.c
+++ b/src_common/SKP_Silk_decoder_set_fs.c
@@ -76,16 +76,10 @@
         psDec->first_frame_after_reset = 1;
 
         if( fs_kHz == 16 ) {
-            psDec->HP_A = SKP_Silk_Dec_A_HP_16;
-            psDec->HP_B = SKP_Silk_Dec_B_HP_16;
             psDec->pitch_lag_low_bits_iCDF = SKP_Silk_uniform8_iCDF;
         } else if( fs_kHz == 12 ) {
-            psDec->HP_A = SKP_Silk_Dec_A_HP_12;
-            psDec->HP_B = SKP_Silk_Dec_B_HP_12;
             psDec->pitch_lag_low_bits_iCDF = SKP_Silk_uniform6_iCDF;
         } else if( fs_kHz == 8 ) {
-            psDec->HP_A = SKP_Silk_Dec_A_HP_8;
-            psDec->HP_B = SKP_Silk_Dec_B_HP_8;
             psDec->pitch_lag_low_bits_iCDF = SKP_Silk_uniform4_iCDF;
         } else {
             /* unsupported sampling rate */
--- a/src_common/SKP_Silk_define.h
+++ b/src_common/SKP_Silk_define.h
@@ -40,6 +40,11 @@
 {
 #endif
 
+/* Max number of encoder channels (1/2) */
+#define ENCODER_NUM_CHANNELS                    2
+/* Number of decoder channels (1/2) */
+#define DECODER_NUM_CHANNELS                    2
+
 #define MAX_FRAMES_PER_PACKET                   3
 
 #ifndef FIXED_POINT
@@ -51,30 +56,36 @@
 #define MAX_TARGET_RATE_BPS                     80000
 #define TARGET_RATE_TAB_SZ                      8
 
+/* Decay time for bitreservoir */
+#define BITRESERVOIR_DECAY_TIME_MS              200
+
 /* LBRR thresholds */
 #define LBRR_NB_MIN_RATE_BPS                    9000
 #define LBRR_MB_MIN_RATE_BPS                    12000
 #define LBRR_WB_MIN_RATE_BPS                    15000
 
-/* DTX settings                                 */
-#define NO_SPEECH_FRAMES_BEFORE_DTX             5       /* eq 100 ms */
+/* DTX settings */
+#define NB_SPEECH_FRAMES_BEFORE_DTX             10      /* eq 200 ms */
 #define MAX_CONSECUTIVE_DTX                     20      /* eq 400 ms */
 
-/* Activate bandwidth transition filtering for mode switching */
-#define SWITCH_TRANSITION_FILTERING             1
-
-/* Decoder Parameters */
-#define DEC_HP_ORDER                            2
-
 /* Maximum sampling frequency, should be 16 for embedded */
 #define MAX_FS_KHZ                              16 
 #define MAX_API_FS_KHZ                          48
 
-/* Signal types used by silk */
+/* Signal types */
 #define TYPE_NO_VOICE_ACTIVITY                  0
 #define TYPE_UNVOICED                           1
 #define TYPE_VOICED                             2
 
+/* Setting for stereo processing */
+#define STEREO_QUANT_STEPS                      15
+#define STEREO_QUANT_HYSTERESIS                 0.25
+#define STEREO_INTERPOL_LENGTH_MS               10
+
+/* Range of pitch lag estimates */
+#define PITCH_EST_MIN_LAG_MS                    2           /* 2 ms -> 500 Hz */
+#define PITCH_EST_MAX_LAG_MS                    18          /* 18 ms -> 56 Hz */
+
 /* Number of subframes */
 #define MAX_NB_SUBFR                            4
 
@@ -147,20 +158,20 @@
 #define MAX_DEL_DEC_STATES                      4
 
 #define LTP_BUF_LENGTH                          512
-#define LTP_MASK                                (LTP_BUF_LENGTH - 1)
+#define LTP_MASK                                ( LTP_BUF_LENGTH - 1 )
 
 #define DECISION_DELAY                          32
-#define DECISION_DELAY_MASK                     (DECISION_DELAY - 1)
+#define DECISION_DELAY_MASK                     ( DECISION_DELAY - 1 )
 
-/* number of subframes for excitation entropy coding */
+/* Number of subframes for excitation entropy coding */
 #define SHELL_CODEC_FRAME_LENGTH                16
 #define LOG2_SHELL_CODEC_FRAME_LENGTH           4
-#define MAX_NB_SHELL_BLOCKS                     (MAX_FRAME_LENGTH / SHELL_CODEC_FRAME_LENGTH)
+#define MAX_NB_SHELL_BLOCKS                     ( MAX_FRAME_LENGTH / SHELL_CODEC_FRAME_LENGTH )
 
-/* number of rate levels, for entropy coding of excitation */
+/* Number of rate levels, for entropy coding of excitation */
 #define N_RATE_LEVELS                           10
 
-/* maximum sum of pulses per shell coding frame */
+/* Maximum sum of pulses per shell coding frame */
 #define MAX_PULSES                              16
 
 #define MAX_MATRIX_SIZE                         MAX_LPC_ORDER /* Max of LPC Order and LTP order */
@@ -206,7 +217,6 @@
 #define NLSF_QUANT_DEL_DEC_STATES               ( 1 << NLSF_QUANT_DEL_DEC_STATES_LOG2 )
 
 /* Transition filtering for mode switching */
-#if SWITCH_TRANSITION_FILTERING
 #  define TRANSITION_TIME_MS                    5120 // 5120 = 64 * FRAME_LENGTH_MS * ( TRANSITION_INT_NUM - 1 ) = 64*(20*4)
 #  define TRANSITION_NB                         3 /* Hardcoded in tables */
 #  define TRANSITION_NA                         2 /* Hardcoded in tables */
@@ -213,9 +223,6 @@
 #  define TRANSITION_INT_NUM                    5 /* Hardcoded in tables */
 #  define TRANSITION_FRAMES                     ( TRANSITION_TIME_MS / MAX_FRAME_LENGTH_MS ) // todo: needs to be made flexible for 10 ms frames
 #  define TRANSITION_INT_STEPS                  ( TRANSITION_FRAMES  / ( TRANSITION_INT_NUM - 1 ) )
-#else
-#  define TRANSITION_FRAMES                     0
-#endif
 
 /* BWE factors to apply after packet loss */
 #define BWE_AFTER_LOSS_Q16                      63570
--- a/src_common/SKP_Silk_enc_API.c
+++ b/src_common/SKP_Silk_enc_API.c
@@ -34,87 +34,21 @@
 #if FIXED_POINT
 #include "SKP_Silk_main_FIX.h"
 #define SKP_Silk_encoder_state_Fxx      SKP_Silk_encoder_state_FIX
-#define SKP_Silk_init_encoder_Fxx       SKP_Silk_init_encoder_FIX
-#define SKP_Silk_control_encoder_Fxx    SKP_Silk_control_encoder_FIX
 #define SKP_Silk_encode_frame_Fxx       SKP_Silk_encode_frame_FIX
 #else
 #include "SKP_Silk_main_FLP.h"
 #define SKP_Silk_encoder_state_Fxx      SKP_Silk_encoder_state_FLP
-#define SKP_Silk_init_encoder_Fxx       SKP_Silk_init_encoder_FLP
-#define SKP_Silk_control_encoder_Fxx    SKP_Silk_control_encoder_FLP
 #define SKP_Silk_encode_frame_Fxx       SKP_Silk_encode_frame_FLP
 #endif
-#define SKP_Silk_EncodeControlStruct    SKP_SILK_SDK_EncControlStruct
 
-/**************************/
-/* Encode frame with Silk */
-/**************************/
-static SKP_int process_enc_control_struct( 
-    SKP_Silk_encoder_state_Fxx          *psEnc,         /* I/O: State                                           */
-    SKP_Silk_EncodeControlStruct        *encControl     /* I:   Control structure                               */
-)
-{
-    SKP_int   max_internal_fs_kHz, min_internal_fs_kHz, Complexity, PacketSize_ms, PacketLoss_perc, UseInBandFEC, ret = SKP_SILK_NO_ERROR;
-    SKP_int32 TargetRate_bps, API_fs_Hz;
-
-    SKP_assert( encControl != NULL );
-
-    /* Check sampling frequency first, to avoid divide by zero later */
-    if( ( ( encControl->API_sampleRate        !=  8000 ) &&
-          ( encControl->API_sampleRate        != 12000 ) &&
-          ( encControl->API_sampleRate        != 16000 ) &&
-          ( encControl->API_sampleRate        != 24000 ) && 
-          ( encControl->API_sampleRate        != 32000 ) &&
-          ( encControl->API_sampleRate        != 44100 ) &&
-          ( encControl->API_sampleRate        != 48000 ) ) ||
-        ( ( encControl->maxInternalSampleRate !=  8000 ) &&
-          ( encControl->maxInternalSampleRate != 12000 ) &&
-          ( encControl->maxInternalSampleRate != 16000 ) ) ||
-        ( ( encControl->minInternalSampleRate !=  8000 ) &&
-          ( encControl->minInternalSampleRate != 12000 ) &&
-          ( encControl->minInternalSampleRate != 16000 ) ) ||
-          ( encControl->minInternalSampleRate > encControl->maxInternalSampleRate ) ) {
-        ret = SKP_SILK_ENC_FS_NOT_SUPPORTED;
-        SKP_assert( 0 );
-        return( ret );
-    }
-    if( encControl->useDTX < 0 || encControl->useDTX > 1 ) {
-        ret = SKP_SILK_ENC_INVALID_DTX_SETTING;
-    }
-	if( encControl->useCBR < 0 || encControl->useCBR > 1 ) {
-        ret = SKP_SILK_ENC_INVALID_CBR_SETTING;
-    }
-
-    /* Set encoder parameters from control structure */
-    API_fs_Hz           =            encControl->API_sampleRate;
-    max_internal_fs_kHz = (SKP_int)( encControl->maxInternalSampleRate >> 10 ) + 1;   /* convert Hz -> kHz */
-    min_internal_fs_kHz = (SKP_int)( encControl->minInternalSampleRate >> 10 ) + 1;   /* convert Hz -> kHz */
-    PacketSize_ms       =            encControl->payloadSize_ms;
-    TargetRate_bps      =            encControl->bitRate;
-    PacketLoss_perc     =            encControl->packetLossPercentage;
-    UseInBandFEC        =            encControl->useInBandFEC;
-    Complexity          =            encControl->complexity;
-    psEnc->sCmn.useDTX  =            encControl->useDTX;
-	psEnc->sCmn.useCBR  =			 encControl->useCBR;
-
-    /* Save values in state */
-    psEnc->sCmn.API_fs_Hz          = API_fs_Hz;
-    psEnc->sCmn.maxInternal_fs_kHz = max_internal_fs_kHz;
-    psEnc->sCmn.minInternal_fs_kHz = min_internal_fs_kHz;
-    psEnc->sCmn.useInBandFEC       = UseInBandFEC;
+/* Encoder Super Struct */
+typedef struct {
+    SKP_Silk_encoder_state_Fxx          state_Fxx[ ENCODER_NUM_CHANNELS ];
+    stereo_state                        sStereo;
+    SKP_int32                           nBitsExceeded;
+    SKP_int                             nChannels;
+} SKP_Silk_encoder;
 
-    TargetRate_bps = SKP_LIMIT( TargetRate_bps, MIN_TARGET_RATE_BPS, MAX_TARGET_RATE_BPS );
-    if( ( ret = SKP_Silk_control_encoder_Fxx( psEnc, PacketSize_ms, TargetRate_bps, 
-                        PacketLoss_perc, Complexity) ) != 0 ) {
-        SKP_assert( 0 );
-        return( ret );
-    }
-
-    encControl->internalSampleRate = SKP_SMULBB( psEnc->sCmn.fs_kHz, 1000 );
-    
-    return ret;
-}
-
 /****************************************/
 /* Encoder functions                    */
 /****************************************/
@@ -123,7 +57,7 @@
 {
     SKP_int ret = SKP_SILK_NO_ERROR;
     
-    *encSizeBytes = sizeof( SKP_Silk_encoder_state_Fxx );
+    *encSizeBytes = sizeof( SKP_Silk_encoder );
     
     return ret;
 }
@@ -133,26 +67,30 @@
 /*************************/
 SKP_int SKP_Silk_SDK_InitEncoder(
     void                            *encState,          /* I/O: State                                           */
-    SKP_Silk_EncodeControlStruct    *encStatus          /* O:   Control structure                               */
+    SKP_SILK_SDK_EncControlStruct   *encStatus          /* O:   Control structure                               */
 )
 {
-    SKP_Silk_encoder_state_Fxx *psEnc;
-    SKP_int ret = SKP_SILK_NO_ERROR;
+    SKP_Silk_encoder *psEnc;
+    SKP_int n, ret = SKP_SILK_NO_ERROR;
 
-        
-    psEnc = ( SKP_Silk_encoder_state_Fxx* )encState;
-
-    /* Reset Encoder */
-    if( ret += SKP_Silk_init_encoder_Fxx( psEnc ) ) {
-        SKP_assert( 0 );
+    psEnc = (SKP_Silk_encoder *)encState;
+    
+    /* Reset encoder */
+    for( n = 0; n < ENCODER_NUM_CHANNELS; n++ ) {
+        if( ret += SKP_Silk_init_encoder( &psEnc->state_Fxx[ n ] ) ) {
+            SKP_assert( 0 );
+        }
     }
+    SKP_memset( &psEnc->sStereo, 0, sizeof( psEnc->sStereo ) );
 
+    psEnc->nBitsExceeded = 0;
+    psEnc->nChannels = 1;
+
     /* Read control structure */
     if( ret += SKP_Silk_SDK_QueryEncoder( encState, encStatus ) ) {
         SKP_assert( 0 );
     }
 
-
     return ret;
 }
 
@@ -161,25 +99,26 @@
 /***************************************/
 SKP_int SKP_Silk_SDK_QueryEncoder(
     const void *encState,                       /* I:   State Vector                                    */
-    SKP_Silk_EncodeControlStruct *encStatus     /* O:   Control Structure                               */
+    SKP_SILK_SDK_EncControlStruct *encStatus    /* O:   Control Structure                               */
 )
 {
-    SKP_Silk_encoder_state_Fxx *psEnc;
+    SKP_Silk_encoder_state_Fxx *state_Fxx;
     SKP_int ret = SKP_SILK_NO_ERROR;
 
-    psEnc = ( SKP_Silk_encoder_state_Fxx* )encState;
+    state_Fxx = ((SKP_Silk_encoder *)encState)->state_Fxx;
 
-    encStatus->API_sampleRate        = psEnc->sCmn.API_fs_Hz;
-    encStatus->maxInternalSampleRate = SKP_SMULBB( psEnc->sCmn.maxInternal_fs_kHz, 1000 );
-    encStatus->minInternalSampleRate = SKP_SMULBB( psEnc->sCmn.minInternal_fs_kHz, 1000 );
-    encStatus->payloadSize_ms        = psEnc->sCmn.PacketSize_ms;
-    encStatus->bitRate               = psEnc->sCmn.TargetRate_bps;
-    encStatus->packetLossPercentage  = psEnc->sCmn.PacketLoss_perc;
-    encStatus->complexity            = psEnc->sCmn.Complexity;
-    encStatus->useInBandFEC          = psEnc->sCmn.useInBandFEC;
-    encStatus->useDTX                = psEnc->sCmn.useDTX;
-    encStatus->useCBR                = psEnc->sCmn.useCBR;
-    encStatus->internalSampleRate    = SKP_SMULBB( psEnc->sCmn.fs_kHz, 1000 );
+    encStatus->API_sampleRate        = state_Fxx->sCmn.API_fs_Hz;
+    encStatus->maxInternalSampleRate = state_Fxx->sCmn.maxInternal_fs_Hz;
+    encStatus->minInternalSampleRate = state_Fxx->sCmn.minInternal_fs_Hz;
+    encStatus->payloadSize_ms        = state_Fxx->sCmn.PacketSize_ms;
+    encStatus->bitRate               = state_Fxx->sCmn.TargetRate_bps;
+    encStatus->packetLossPercentage  = state_Fxx->sCmn.PacketLoss_perc;
+    encStatus->complexity            = state_Fxx->sCmn.Complexity;
+    encStatus->useInBandFEC          = state_Fxx->sCmn.useInBandFEC;
+    encStatus->useDTX                = state_Fxx->sCmn.useDTX;
+    encStatus->useCBR                = state_Fxx->sCmn.useCBR;
+    encStatus->internalSampleRate    = SKP_SMULBB( state_Fxx->sCmn.fs_kHz, 1000 );
+
     return ret;
 }
 
@@ -188,82 +127,220 @@
 /**************************/
 SKP_int SKP_Silk_SDK_Encode( 
     void                                *encState,      /* I/O: State                                           */
-    SKP_Silk_EncodeControlStruct        *encControl,    /* I:   Control structure                               */
+    SKP_SILK_SDK_EncControlStruct       *encControl,    /* I:   Control structure                               */
     const SKP_int16                     *samplesIn,     /* I:   Speech sample input vector                      */
     SKP_int                             nSamplesIn,     /* I:   Number of samples in input vector               */
     ec_enc                              *psRangeEnc,    /* I/O  Compressor data structure                       */
     SKP_int32                           *nBytesOut,     /* I/O: Number of bytes in payload (input: Max bytes)   */
-    const SKP_int                       prefillFlag     /* I:   Flag to indicate prefilling buffers no coding   */
+    const SKP_int                       prefillFlag     /* I:   Flag to indicate prefilling buffers; no coding  */
 )
 {
-    SKP_int   tmp_payloadSize_ms, tmp_complexity, ret = 0;
+    SKP_int   n, i, nBits, flags, tmp_payloadSize_ms, tmp_complexity, MS_predictorIx = 0, ret = 0;
     SKP_int   nSamplesToBuffer, nBlocksOf10ms, nSamplesFromInput = 0;
-    SKP_Silk_encoder_state_Fxx *psEnc = ( SKP_Silk_encoder_state_Fxx* )encState;
+    SKP_int32 TargetRate_bps, channelRate_bps, LBRR_symbol;
+    SKP_Silk_encoder *psEnc = ( SKP_Silk_encoder * )encState;
+    SKP_int16 buf[ MAX_FRAME_LENGTH_MS * MAX_API_FS_KHZ ];
 
-    ret = process_enc_control_struct( psEnc, encControl );
+    /* Check values in encoder control structure */
+    if( ( ret = check_control_input( encControl ) != 0 ) ) {
+        SKP_assert( 0 );
+        return ret;
+    }
 
-    nBlocksOf10ms = SKP_DIV32( 100 * nSamplesIn, psEnc->sCmn.API_fs_Hz );
+    if( encControl->nChannels > psEnc->nChannels ) {
+        /* Mono -> Stereo transition: init state of second channel and stereo state */
+        SKP_memset( &psEnc->sStereo, 0, sizeof( psEnc->sStereo ) );
+        ret += SKP_Silk_init_encoder( &psEnc->state_Fxx[ 1 ] );
+    }
+    psEnc->nChannels = encControl->nChannels;
+
+    nBlocksOf10ms = SKP_DIV32( 100 * nSamplesIn, encControl->API_sampleRate );
     if( prefillFlag ) {
         /* Only accept input length of 10 ms */
         if( nBlocksOf10ms != 1 ) {
             ret = SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES;
             SKP_assert( 0 );
-            return( ret );
+            return ret;
         }
         /* Reset Encoder */
-        if( ret = SKP_Silk_init_encoder_Fxx( psEnc ) ) {
-            SKP_assert( 0 );
+        for( n = 0; n < encControl->nChannels; n++ ) {
+            if( ret = SKP_Silk_init_encoder( &psEnc->state_Fxx[ n ] ) ) {
+                SKP_assert( 0 );
+            }
         }
         tmp_payloadSize_ms = encControl->payloadSize_ms;
         encControl->payloadSize_ms = 10;
         tmp_complexity = encControl->complexity;
         encControl->complexity = 0;
-        ret = process_enc_control_struct( psEnc, encControl );
-        psEnc->sCmn.prefillFlag = 1;
+        for( n = 0; n < encControl->nChannels; n++ ) {
+            psEnc->state_Fxx[ n ].sCmn.controlled_since_last_payload = 0;
+            psEnc->state_Fxx[ n ].sCmn.prefillFlag = 1;
+        }
     } else {
         /* Only accept input lengths that are a multiple of 10 ms */
-        if( nBlocksOf10ms * psEnc->sCmn.API_fs_Hz != 100 * nSamplesIn || nSamplesIn < 0 ) {
+        if( nBlocksOf10ms * encControl->API_sampleRate != 100 * nSamplesIn || nSamplesIn < 0 ) {
             ret = SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES;
             SKP_assert( 0 );
-            return( ret );
+            return ret;
         }
         /* Make sure no more than one packet can be produced */
-        if( 1000 * (SKP_int32)nSamplesIn > psEnc->sCmn.PacketSize_ms * psEnc->sCmn.API_fs_Hz ) {
+        if( 1000 * (SKP_int32)nSamplesIn > encControl->payloadSize_ms * encControl->API_sampleRate ) {
             ret = SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES;
             SKP_assert( 0 );
-            return( ret );
+            return ret;
         }
     }
 
+    TargetRate_bps = SKP_RSHIFT32( encControl->bitRate, encControl->nChannels - 1 );
+    for( n = 0; n < encControl->nChannels; n++ ) {
+        if( ( ret = SKP_Silk_control_encoder( &psEnc->state_Fxx[ n ], encControl, TargetRate_bps ) ) != 0 ) {
+            SKP_assert( 0 );
+            return ret;
+        }
+    }
+    SKP_assert( encControl->nChannels == 1 || psEnc->state_Fxx[ 0 ].sCmn.fs_kHz == psEnc->state_Fxx[ 1 ].sCmn.fs_kHz );
+
     /* Input buffering/resampling and encoding */
     while( 1 ) {
-        nSamplesToBuffer = psEnc->sCmn.frame_length - psEnc->sCmn.inputBufIx;
-        if( psEnc->sCmn.API_fs_Hz == SKP_SMULBB( 1000, psEnc->sCmn.fs_kHz ) ) { 
-            nSamplesToBuffer  = SKP_min_int( nSamplesToBuffer, nSamplesIn );
-            nSamplesFromInput = nSamplesToBuffer;
-            /* Copy to buffer */
-            SKP_memcpy( &psEnc->sCmn.inputBuf[ psEnc->sCmn.inputBufIx ], samplesIn, nSamplesFromInput * sizeof( SKP_int16 ) );
-        } else {  
-            nSamplesToBuffer  = SKP_min( nSamplesToBuffer, 10 * nBlocksOf10ms * psEnc->sCmn.fs_kHz );
-            nSamplesFromInput = SKP_DIV32_16( nSamplesToBuffer * psEnc->sCmn.API_fs_Hz, psEnc->sCmn.fs_kHz * 1000 );
-            /* Resample and write to buffer */
-            ret += SKP_Silk_resampler( &psEnc->sCmn.resampler_state, &psEnc->sCmn.inputBuf[ psEnc->sCmn.inputBufIx ], samplesIn, nSamplesFromInput );
-        } 
-        samplesIn              += nSamplesFromInput;
-        nSamplesIn             -= nSamplesFromInput;
-        psEnc->sCmn.inputBufIx += nSamplesToBuffer;
+        nSamplesToBuffer  = psEnc->state_Fxx[ 0 ].sCmn.frame_length - psEnc->state_Fxx[ 0 ].sCmn.inputBufIx;
+        nSamplesToBuffer  = SKP_min( nSamplesToBuffer, 10 * nBlocksOf10ms * psEnc->state_Fxx[ 0 ].sCmn.fs_kHz );
+        nSamplesFromInput = SKP_DIV32_16( nSamplesToBuffer * psEnc->state_Fxx[ 0 ].sCmn.API_fs_Hz, psEnc->state_Fxx[ 0 ].sCmn.fs_kHz * 1000 );
+        /* Resample and write to buffer */
+        if( encControl->nChannels == 2 ) {
+            for( n = 0; n < nSamplesFromInput; n++ ) {
+                buf[ n ] = samplesIn[ 2 * n ];
+            }
+            ret += SKP_Silk_resampler( &psEnc->state_Fxx[ 0 ].sCmn.resampler_state, 
+                &psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx ], buf, nSamplesFromInput );
+            psEnc->state_Fxx[ 0 ].sCmn.inputBufIx += nSamplesToBuffer;
 
-        /* Silk encoder */
-        if( psEnc->sCmn.inputBufIx >= psEnc->sCmn.frame_length ) {
-            SKP_assert( psEnc->sCmn.inputBufIx == psEnc->sCmn.frame_length );
+            nSamplesToBuffer  = psEnc->state_Fxx[ 1 ].sCmn.frame_length - psEnc->state_Fxx[ 1 ].sCmn.inputBufIx;
+            nSamplesToBuffer  = SKP_min( nSamplesToBuffer, 10 * nBlocksOf10ms * psEnc->state_Fxx[ 1 ].sCmn.fs_kHz );
+            for( n = 0; n < nSamplesFromInput; n++ ) {
+                buf[ n ] = samplesIn[ 2 * n + 1 ];
+            }
+            ret += SKP_Silk_resampler( &psEnc->state_Fxx[ 1 ].sCmn.resampler_state, 
+                &psEnc->state_Fxx[ 1 ].sCmn.inputBuf[ psEnc->state_Fxx[ 1 ].sCmn.inputBufIx ], buf, nSamplesFromInput );
+            psEnc->state_Fxx[ 1 ].sCmn.inputBufIx += nSamplesToBuffer;
+        } else {
+            SKP_assert( encControl->nChannels == 1 );
+            ret += SKP_Silk_resampler( &psEnc->state_Fxx[ 0 ].sCmn.resampler_state, 
+                &psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx ], samplesIn, nSamplesFromInput );
+            psEnc->state_Fxx[ 0 ].sCmn.inputBufIx += nSamplesToBuffer;
+        }
+        samplesIn  += nSamplesFromInput * encControl->nChannels;
+        nSamplesIn -= nSamplesFromInput;
 
+        /* Silk encoder */
+        if( psEnc->state_Fxx[ 0 ].sCmn.inputBufIx >= psEnc->state_Fxx[ 0 ].sCmn.frame_length ) {
             /* Enough data in input buffer, so encode */
-            if( ( ret = SKP_Silk_encode_frame_Fxx( psEnc, nBytesOut, psRangeEnc ) ) != 0 ) {
-                SKP_assert( 0 );
+            SKP_assert( psEnc->state_Fxx[ 0 ].sCmn.inputBufIx == psEnc->state_Fxx[ 0 ].sCmn.frame_length );
+            SKP_assert( encControl->nChannels == 1 || psEnc->state_Fxx[ 1 ].sCmn.inputBufIx == psEnc->state_Fxx[ 1 ].sCmn.frame_length );
+
+            /* Deal with LBRR data */
+            if( psEnc->state_Fxx[ 0 ].sCmn.nFramesAnalyzed == 0 && !prefillFlag ) {
+                /* Create space at start of payload for VAD and FEC flags */
+                SKP_uint8 iCDF[ 2 ] = { 0, 0 };
+                iCDF[ 0 ] = 256 - SKP_RSHIFT( 256, ( psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket + 1 ) * encControl->nChannels );
+                ec_enc_icdf( psRangeEnc, 0, iCDF, 8 );
+
+                /* Encode any LBRR data from previous packet */
+                /* Encode LBRR flags */
+                for( n = 0; n < encControl->nChannels; n++ ) {
+                    LBRR_symbol = 0;
+                    for( i = 0; i < psEnc->state_Fxx[ n ].sCmn.nFramesPerPacket; i++ ) {
+                        LBRR_symbol |= SKP_LSHIFT( psEnc->state_Fxx[ n ].sCmn.LBRR_flags[ i ], i );
+                    }
+                    psEnc->state_Fxx[ n ].sCmn.LBRR_flag = LBRR_symbol > 0 ? 1 : 0;
+                    if( LBRR_symbol && psEnc->state_Fxx[ n ].sCmn.nFramesPerPacket > 1 ) {
+                        ec_enc_icdf( psRangeEnc, LBRR_symbol - 1, SKP_Silk_LBRR_flags_iCDF_ptr[ psEnc->state_Fxx[ n ].sCmn.nFramesPerPacket - 2 ], 8 );
+                    }
+                }
+
+                /* Code LBRR indices and excitation signals */
+                for( i = 0; i < psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket; i++ ) {
+                    for( n = 0; n < encControl->nChannels; n++ ) {                
+                        if( psEnc->state_Fxx[ n ].sCmn.LBRR_flags[ i ] ) {
+                            SKP_Silk_encode_indices( &psEnc->state_Fxx[ n ].sCmn, psRangeEnc, i, 1 );
+                            SKP_Silk_encode_pulses( psRangeEnc, psEnc->state_Fxx[ n ].sCmn.indices_LBRR[i].signalType, psEnc->state_Fxx[ n ].sCmn.indices_LBRR[i].quantOffsetType, 
+                                psEnc->state_Fxx[ n ].sCmn.pulses_LBRR[ i ], psEnc->state_Fxx[ n ].sCmn.frame_length );
+                        }
+                    }
+                }
+
+                /* Reset LBRR flags */
+                for( n = 0; n < encControl->nChannels; n++ ) {                
+                    SKP_memset( psEnc->state_Fxx[ n ].sCmn.LBRR_flags, 0, sizeof( psEnc->state_Fxx[ n ].sCmn.LBRR_flags ) );
+                }
             }
-            psEnc->sCmn.inputBufIx = 0;
-            psEnc->sCmn.controlled_since_last_payload = 0;
 
+            /* Convert Left/Right to Mid/Side */
+            if( encControl->nChannels == 2 ) {
+                SKP_Silk_stereo_LR_to_MS( &psEnc->sStereo, psEnc->state_Fxx[ 0 ].sCmn.inputBuf, psEnc->state_Fxx[ 1 ].sCmn.inputBuf, 
+                    &MS_predictorIx, psEnc->state_Fxx[ 0 ].sCmn.fs_kHz, psEnc->state_Fxx[ 0 ].sCmn.frame_length );
+                ec_enc_icdf( psRangeEnc, MS_predictorIx, SKP_Silk_stereo_predictor_iCDF, 8 );
+            }
+
+
+            /* Total target bits for packet */
+            nBits = SKP_DIV32_16( SKP_MUL( encControl->bitRate, encControl->payloadSize_ms ), 1000 );
+            /* Subtract bits already used */
+            nBits -= ec_tell( psRangeEnc );
+            /* Divide by number of uncoded frames left in packet */
+            nBits = SKP_DIV32_16( nBits, psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket - psEnc->state_Fxx[ 0 ].sCmn.nFramesAnalyzed );
+            /* Convert to bits/second */
+            if( encControl->payloadSize_ms == 10 ) {
+                TargetRate_bps = SKP_SMULBB( nBits, 100 );
+            } else {
+                TargetRate_bps = SKP_SMULBB( nBits, 50 );
+            }
+            /* Subtract fraction of bits in excess of target in previous packets */
+            TargetRate_bps -= SKP_DIV32_16( SKP_MUL( psEnc->nBitsExceeded, 1000 ), BITRESERVOIR_DECAY_TIME_MS );
+            /* Don't exceed input bitrate */
+            TargetRate_bps = SKP_min( TargetRate_bps, encControl->bitRate );
+
+            /* Encode */
+            for( n = 0; n < encControl->nChannels; n++ ) {
+                /* For stereo coding, allocate 60% of the bitrate to mid and 40% to side */
+                if( encControl->nChannels == 1 ) {
+                    channelRate_bps = TargetRate_bps;
+                } else if( n == 0 ) {
+                    channelRate_bps = SKP_SMULWW( TargetRate_bps, SKP_FIX_CONST( 0.6, 16 ) );
+                } else {
+                    channelRate_bps = SKP_SMULWB( TargetRate_bps, SKP_FIX_CONST( 0.4, 16 ) );
+                }
+                SKP_Silk_control_SNR( &psEnc->state_Fxx[ n ].sCmn, channelRate_bps );
+                //SKP_Silk_control_SNR( &psEnc->state_Fxx[ n ].sCmn, TargetRate_bps / 2 );
+                if( ( ret = SKP_Silk_encode_frame_Fxx( &psEnc->state_Fxx[ n ], nBytesOut, psRangeEnc ) ) != 0 ) {
+                    SKP_assert( 0 );
+                }
+                psEnc->state_Fxx[ n ].sCmn.controlled_since_last_payload = 0;
+                psEnc->state_Fxx[ n ].sCmn.inputBufIx = 0;
+            }
+
+            /* Insert VAD and FEC flags at beginning of bitstream */
+            if( *nBytesOut > 0 ) {
+                flags = 0;
+                for( n = 0; n < encControl->nChannels; n++ ) {
+                    for( i = 0; i < psEnc->state_Fxx[ n ].sCmn.nFramesPerPacket; i++ ) {
+                        flags  = SKP_LSHIFT( flags, 1 );
+                        flags |= psEnc->state_Fxx[ n ].sCmn.VAD_flags[ i ];
+                    }
+                    flags  = SKP_LSHIFT( flags, 1 );
+                    flags |= psEnc->state_Fxx[ n ].sCmn.LBRR_flag;
+                }
+                ec_enc_patch_initial_bits( psRangeEnc, flags, ( psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket + 1 ) * encControl->nChannels );
+
+                /* Return zero bytes if DTXed */
+                if( psEnc->state_Fxx[ 0 ].sCmn.inDTX && ( encControl->nChannels == 1 || psEnc->state_Fxx[ 1 ].sCmn.inDTX ) ) {
+                    *nBytesOut = 0;
+                }
+
+                psEnc->nBitsExceeded += *nBytesOut * 8;
+                psEnc->nBitsExceeded -= SKP_DIV32_16( SKP_MUL( encControl->bitRate, encControl->payloadSize_ms ), 1000 );
+                psEnc->nBitsExceeded  = SKP_LIMIT( psEnc->nBitsExceeded, 0, 10000 );
+            }
+
             if( nSamplesIn == 0 ) {
                 break;
             }
@@ -272,11 +349,14 @@
         }
     }
 
+    encControl->internalSampleRate = SKP_SMULBB( psEnc->state_Fxx[ 0 ].sCmn.fs_kHz, 1000 );
     if( prefillFlag ) {
         encControl->payloadSize_ms = tmp_payloadSize_ms;
         encControl->complexity = tmp_complexity;
-        ret = process_enc_control_struct( psEnc, encControl );
-        psEnc->sCmn.prefillFlag = 0;
+        for( n = 0; n < encControl->nChannels; n++ ) {
+            psEnc->state_Fxx[ n ].sCmn.controlled_since_last_payload = 0;
+            psEnc->state_Fxx[ n ].sCmn.prefillFlag = 0;
+        }
     }
 
     return ret;
--- a/src_common/SKP_Silk_encode_indices.c
+++ b/src_common/SKP_Silk_encode_indices.c
@@ -27,9 +27,7 @@
 
 #include "SKP_Silk_main.h"
 
-/*******************************************/
-/* Encode parameters to create the payload */
-/*******************************************/
+/* Encode side-information parameters to payload */
 void SKP_Silk_encode_indices(
     SKP_Silk_encoder_state      *psEncC,            /* I/O  Encoder state                               */
     ec_enc                      *psRangeEnc,        /* I/O  Compressor data structure                   */
@@ -47,6 +45,7 @@
     SKP_int nBytes_after, nBytes_before;
 #endif
 
+    /* Use conditional coding if previous frame available */
     if( FrameIndex > 0 && ( encode_LBRR == 0 || psEncC->LBRR_flags[ FrameIndex - 1 ] == 1 ) ) {
         condCoding = 1;
     } else {
--- /dev/null
+++ b/src_common/SKP_Silk_init_encoder.c
@@ -1,0 +1,57 @@
+/***********************************************************************
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. 
+Redistribution and use in source and binary forms, with or without 
+modification, (subject to the limitations in the disclaimer below) 
+are permitted provided that the following conditions are met:
+- Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+- Redistributions in binary form must reproduce the above copyright 
+notice, this list of conditions and the following disclaimer in the 
+documentation and/or other materials provided with the distribution.
+- Neither the name of Skype Limited, nor the names of specific 
+contributors, may be used to endorse or promote products derived from 
+this software without specific prior written permission.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 
+BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
+CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
+BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+***********************************************************************/
+
+#if FIXED_POINT
+#include "SKP_Silk_main_FIX.h"
+#define SKP_Silk_encoder_state_Fxx      SKP_Silk_encoder_state_FIX
+#else
+#include "SKP_Silk_main_FLP.h"
+#define SKP_Silk_encoder_state_Fxx      SKP_Silk_encoder_state_FLP
+#endif
+
+/*********************************/
+/* Initialize Silk Encoder state */
+/*********************************/
+SKP_int SKP_Silk_init_encoder(
+    SKP_Silk_encoder_state_Fxx  *psEnc          /* I/O  Pointer to Silk encoder state               */
+) {
+    SKP_int ret = 0;
+
+    /* Clear the entire encoder state */
+    SKP_memset( psEnc, 0, sizeof( SKP_Silk_encoder_state_Fxx ) );
+
+    psEnc->sCmn.variable_HP_smth1_Q15 = 200844; /* = SKP_Silk_log2(70)_Q0; */
+    psEnc->sCmn.variable_HP_smth2_Q15 = 200844; /* = SKP_Silk_log2(70)_Q0; */
+
+    /* Used to deactivate LSF interpolation, fluctuation reduction, pitch prediction */
+    psEnc->sCmn.first_frame_after_reset = 1;
+
+    /* Initialize Silk VAD */
+    ret += SKP_Silk_VAD_Init( &psEnc->sCmn.sVAD );
+
+    return( ret );
+}
--- a/src_common/SKP_Silk_main.h
+++ b/src_common/SKP_Silk_main.h
@@ -38,6 +38,7 @@
 #include "SKP_Silk_structs.h"
 #include "SKP_Silk_tables.h"
 #include "SKP_Silk_PLC.h"
+#include "SKP_Silk_control.h"
 #include "SKP_debug.h"
 #include "entenc.h"
 #include "entdec.h"
@@ -49,6 +50,26 @@
 //#define FORCE_INTERNAL_FS_KHZ       16
 
 
+/* Convert Left/Right stereo signal to adaptive Mid/Side representation */
+void SKP_Silk_stereo_LR_to_MS( 
+    stereo_state        *state,                         /* I/O  State                                       */
+    SKP_int16           x1[],                           /* I/O  Left input signal, becomes mid signal       */
+    SKP_int16           x2[],                           /* I/O  Right input signal, becomes side signal     */
+    SKP_int             *predictorIx,                   /* O    Index for predictor filter                  */
+    SKP_int             fs_kHz,                         /* I    Samples rate (kHz)                          */
+    SKP_int             frame_length                    /* I    Number of samples                           */
+);
+
+/* Convert adaptive Mid/Side representation to Left/Right stereo signal */
+void SKP_Silk_stereo_MS_to_LR( 
+    stereo_state        *state,                         /* I/O  State                                       */
+    SKP_int16           x1[],                           /* I/O  Left input signal, becomes mid signal       */
+    SKP_int16           x2[],                           /* I/O  Right input signal, becomes side signal     */
+    SKP_int             predictorIx,                    /* I    Index for predictor filter                  */
+    SKP_int             fs_kHz,                         /* I    Samples rate (kHz)                          */
+    SKP_int             frame_length                    /* I    Number of samples                           */
+);
+
 /* Encodes signs of excitation */
 void SKP_Silk_encode_signs(
     ec_enc                      *psRangeEnc,                        /* I/O  Compressor data structure                   */
@@ -69,6 +90,11 @@
     const SKP_int               sum_pulses[ MAX_NB_SHELL_BLOCKS ]   /* I    Sum of absolute pulses per block            */
 );
 
+/* Check encoder control struct */
+SKP_int check_control_input( 
+    SKP_SILK_SDK_EncControlStruct        *encControl     /* I:   Control structure                               */
+);
+
 /* Control internal sampling rate */
 SKP_int SKP_Silk_control_audio_bandwidth(
     SKP_Silk_encoder_state      *psEncC,            /* I/O  Pointer to Silk encoder state               */
@@ -75,6 +101,12 @@
     SKP_int32                   TargetRate_bps      /* I    Target max bitrate (bps)                    */
 );
 
+/* Control SNR of redidual quantizer */
+SKP_int SKP_Silk_control_SNR(
+    SKP_Silk_encoder_state      *psEncC,            /* I/O  Pointer to Silk encoder state               */
+    SKP_int32                   TargetRate_bps      /* I    Target max bitrate (bps)                    */
+);
+
 /***************/
 /* Shell coder */
 /***************/
@@ -226,7 +258,6 @@
     const SKP_int                   frame_length    /* I    length of input                             */
 );
 
-#if SWITCH_TRANSITION_FILTERING
 /* Low-pass filter with variable cutoff frequency based on  */
 /* piece-wise linear interpolation between elliptic filters */
 /* Start by setting transition_frame_no = 1;                */
@@ -235,14 +266,7 @@
     SKP_int16                   *signal,            /* I/O  Low-pass filtered output signal             */
     const SKP_int               frame_length        /* I    Frame length                                */
 );
-#endif
 
-/* Encode LBRR side info and excitation */
-void SKP_Silk_LBRR_embed(
-    SKP_Silk_encoder_state      *psEncC,            /* I/O  Encoder state                               */
-    ec_enc                      *psRangeEnc         /* I/O  Compressor data structure                   */
-);
-
 /******************/
 /* NLSF Quantizer */
 /******************/
@@ -333,7 +357,6 @@
     ec_dec                      *psRangeDec,        /* I/O  Compressor data structure                   */
     SKP_int16                   pOut[],             /* O    Pointer to output speech frame              */
     SKP_int32                   *pN,                /* O    Pointer to size of output frame             */
-    const SKP_int               nBytes,             /* I    Payload length                              */
     SKP_int                     lostFlag            /* I    0: no loss, 1 loss, 2 decode fec            */
 );
 
--- a/src_common/SKP_Silk_process_NLSFs.c
+++ b/src_common/SKP_Silk_process_NLSFs.c
@@ -50,9 +50,13 @@
     /***********************/
     /* NLSF_mu  = 0.003 - 0.0015 * psEnc->speech_activity; */
     NLSF_mu_Q20 = SKP_SMLAWB( SKP_FIX_CONST( 0.003, 20 ), SKP_FIX_CONST( -0.0015, 28 ), psEncC->speech_activity_Q8 );
+    if( psEncC->nb_subfr == 2 ) {
+        /* Multiply by 1.5 for 10 ms packets */
+        NLSF_mu_Q20 = SKP_ADD_RSHIFT( NLSF_mu_Q20, NLSF_mu_Q20, 1 );
+    }
 
     SKP_assert( NLSF_mu_Q20 >  0 );
-    SKP_assert( NLSF_mu_Q20 <= SKP_FIX_CONST( 0.003, 20 ) );
+    SKP_assert( NLSF_mu_Q20 <= SKP_FIX_CONST( 0.0045, 20 ) );
 
     /* Calculate NLSF weights */
     SKP_Silk_NLSF_VQ_weights_laroia( pNLSFW_Q5, pNLSF_Q15, psEncC->predictLPCOrder );
--- a/src_common/SKP_Silk_setup.h
+++ /dev/null
@@ -1,143 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. 
-Redistribution and use in source and binary forms, with or without 
-modification, (subject to the limitations in the disclaimer below) 
-are permitted provided that the following conditions are met:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright 
-notice, this list of conditions and the following disclaimer in the 
-documentation and/or other materials provided with the distribution.
-- Neither the name of Skype Limited, nor the names of specific 
-contributors, may be used to endorse or promote products derived from 
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-***********************************************************************/
-
-#include "SKP_Silk_main.h"
-#include "SKP_Silk_tuning_parameters.h"
-
-SKP_INLINE SKP_int SKP_Silk_setup_complexity(
-    SKP_Silk_encoder_state          *psEncC,            /* I/O                      */
-    SKP_int                         Complexity          /* I                        */
-)
-{
-    SKP_int ret = 0;
-
-    /* Set encoding complexity */
-    if( Complexity < 2 ) {
-        psEncC->pitchEstimationComplexity       = SKP_Silk_PE_MIN_COMPLEX;
-        psEncC->pitchEstimationThreshold_Q16    = SKP_FIX_CONST( 0.8, 16 );
-        psEncC->pitchEstimationLPCOrder         = 6;
-        psEncC->shapingLPCOrder                 = 8;
-        psEncC->la_shape                        = 3 * psEncC->fs_kHz;
-        psEncC->nStatesDelayedDecision          = 1;
-        psEncC->useInterpolatedNLSFs            = 0;
-        psEncC->LTPQuantLowComplexity           = 1;
-        psEncC->NLSF_MSVQ_Survivors             = 2;
-        psEncC->warping_Q16                     = 0;
-    } else if( Complexity < 4 ) {
-        psEncC->pitchEstimationComplexity       = SKP_Silk_PE_MID_COMPLEX;
-        psEncC->pitchEstimationThreshold_Q16    = SKP_FIX_CONST( 0.76, 16 );
-        psEncC->pitchEstimationLPCOrder         = 8;
-        psEncC->shapingLPCOrder                 = 10;
-        psEncC->la_shape                        = 5 * psEncC->fs_kHz;
-        psEncC->nStatesDelayedDecision          = 1;
-        psEncC->useInterpolatedNLSFs            = 1;
-        psEncC->LTPQuantLowComplexity           = 0;
-        psEncC->NLSF_MSVQ_Survivors             = 4;
-        psEncC->warping_Q16                     = 0;
-    } else if( Complexity < 6 ) {
-        psEncC->pitchEstimationComplexity       = SKP_Silk_PE_MID_COMPLEX;
-        psEncC->pitchEstimationThreshold_Q16    = SKP_FIX_CONST( 0.74, 16 );
-        psEncC->pitchEstimationLPCOrder         = 10;
-        psEncC->shapingLPCOrder                 = 12;
-        psEncC->la_shape                        = 5 * psEncC->fs_kHz;
-        psEncC->nStatesDelayedDecision          = 2;
-        psEncC->useInterpolatedNLSFs            = 0;
-        psEncC->LTPQuantLowComplexity           = 0;
-        psEncC->NLSF_MSVQ_Survivors             = 6;
-        psEncC->warping_Q16                     = psEncC->fs_kHz * SKP_FIX_CONST( WARPING_MULTIPLIER, 16 );
-    } else if( Complexity < 8 ) {
-        psEncC->pitchEstimationComplexity       = SKP_Silk_PE_MID_COMPLEX;
-        psEncC->pitchEstimationThreshold_Q16    = SKP_FIX_CONST( 0.72, 16 );
-        psEncC->pitchEstimationLPCOrder         = 12;
-        psEncC->shapingLPCOrder                 = 14;
-        psEncC->la_shape                        = 5 * psEncC->fs_kHz;
-        psEncC->nStatesDelayedDecision          = 3;
-        psEncC->useInterpolatedNLSFs            = 0;
-        psEncC->LTPQuantLowComplexity           = 0;
-        psEncC->NLSF_MSVQ_Survivors             = 8;
-        psEncC->warping_Q16                     = psEncC->fs_kHz * SKP_FIX_CONST( WARPING_MULTIPLIER, 16 );
-    } else if( Complexity <= 10 ) {
-        psEncC->pitchEstimationComplexity       = SKP_Silk_PE_MAX_COMPLEX;
-        psEncC->pitchEstimationThreshold_Q16    = SKP_FIX_CONST( 0.7, 16 );
-        psEncC->pitchEstimationLPCOrder         = 16;
-        psEncC->shapingLPCOrder                 = 16;
-        psEncC->la_shape                        = 5 * psEncC->fs_kHz;
-        psEncC->nStatesDelayedDecision          = MAX_DEL_DEC_STATES;
-        psEncC->useInterpolatedNLSFs            = 1;
-        psEncC->LTPQuantLowComplexity           = 0;
-        psEncC->NLSF_MSVQ_Survivors             = 16;
-        psEncC->warping_Q16                     = psEncC->fs_kHz * SKP_FIX_CONST( WARPING_MULTIPLIER, 16 );
-    } else {
-        ret = SKP_SILK_ENC_INVALID_COMPLEXITY_SETTING;
-    }
-
-    /* Do not allow higher pitch estimation LPC order than predict LPC order */
-    psEncC->pitchEstimationLPCOrder = SKP_min_int( psEncC->pitchEstimationLPCOrder, psEncC->predictLPCOrder );
-    psEncC->shapeWinLength          = SUB_FRAME_LENGTH_MS * psEncC->fs_kHz + 2 * psEncC->la_shape;
-
-    SKP_assert( psEncC->pitchEstimationLPCOrder <= MAX_FIND_PITCH_LPC_ORDER );
-    SKP_assert( psEncC->shapingLPCOrder         <= MAX_SHAPE_LPC_ORDER      );
-    SKP_assert( psEncC->nStatesDelayedDecision  <= MAX_DEL_DEC_STATES       );
-    SKP_assert( psEncC->warping_Q16             <= 32767                    );
-    SKP_assert( psEncC->la_shape                <= LA_SHAPE_MAX             );
-    SKP_assert( psEncC->shapeWinLength          <= SHAPE_LPC_WIN_MAX        );
-    SKP_assert( psEncC->NLSF_MSVQ_Survivors     <= NLSF_VQ_MAX_SURVIVORS    );
-
-    return( ret );
-}
-
-SKP_INLINE SKP_int SKP_Silk_setup_LBRR(
-    SKP_Silk_encoder_state          *psEncC            /* I/O                      */
-)
-{
-    SKP_int   ret = SKP_SILK_NO_ERROR;
-    SKP_int32 LBRRRate_thres_bps;
-
-    if( psEncC->useInBandFEC < 0 || psEncC->useInBandFEC > 1 ) {
-        ret = SKP_SILK_ENC_INVALID_INBAND_FEC_SETTING;
-    }
-    
-    if( psEncC->fs_kHz == 8 ) {
-        LBRRRate_thres_bps = LBRR_NB_MIN_RATE_BPS;
-    } else if( psEncC->fs_kHz == 12 ) {
-        LBRRRate_thres_bps = LBRR_MB_MIN_RATE_BPS;
-    } else if( psEncC->fs_kHz == 16 ) {
-        LBRRRate_thres_bps = LBRR_WB_MIN_RATE_BPS;
-    } else {
-        SKP_assert( 0 );
-    }
-
-    LBRRRate_thres_bps = SKP_RSHIFT( SKP_SMULBB( LBRRRate_thres_bps, 7 - psEncC->PacketLoss_perc ), 2 );
-    if( psEncC->useInBandFEC && psEncC->TargetRate_bps >= LBRRRate_thres_bps && psEncC->PacketLoss_perc > 0 ) {
-        /* Set gain increase / rate reduction for LBRR usage */
-        psEncC->LBRR_GainIncreases = SKP_max_int( 6 - SKP_SMULWB( psEncC->PacketLoss_perc, SKP_FIX_CONST( 0.4, 16 ) ), 2 );
-        psEncC->LBRR_enabled = 1;
-    } else {
-        psEncC->LBRR_enabled = 0;
-    }
-    return ret;
-}
--- /dev/null
+++ b/src_common/SKP_Silk_stereo_LR_to_MS.c
@@ -1,0 +1,94 @@
+/***********************************************************************
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. 
+Redistribution and use in source and binary forms, with or without 
+modification, (subject to the limitations in the disclaimer below) 
+are permitted provided that the following conditions are met:
+- Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+- Redistributions in binary form must reproduce the above copyright 
+notice, this list of conditions and the following disclaimer in the 
+documentation and/or other materials provided with the distribution.
+- Neither the name of Skype Limited, nor the names of specific 
+contributors, may be used to endorse or promote products derived from 
+this software without specific prior written permission.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 
+BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
+CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
+BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+***********************************************************************/
+
+#include "SKP_Silk_main.h"
+
+/* Convert Left/Right stereo signal to adaptive Mid/Side representation */
+void SKP_Silk_stereo_LR_to_MS( 
+    stereo_state        *state,                         /* I/O  State                                       */
+    SKP_int16           x1[],                           /* I/O  Left input signal, becomes mid signal       */
+    SKP_int16           x2[],                           /* I/O  Right input signal, becomes side signal     */
+    SKP_int             *predictorIx,                   /* O    Index for predictor filter                  */
+    SKP_int             fs_kHz,                         /* I    Samples rate (kHz)                          */
+    SKP_int             frame_length                    /* I    Number of samples                           */
+)
+{
+    SKP_int   n, scale, scale1, scale2;
+    SKP_int32 sum, diff, nrg1, nrg2, corr, predictor_Q16, pred_Q16, delta_Q16;
+
+    /* Convert to basic mid/side signals */
+    for( n = 0; n < frame_length; n++ ) {
+        sum  = x1[ n ] + (SKP_int32)x2[ n ];
+        diff = x1[ n ] - (SKP_int32)x2[ n ];
+        x1[ n ] = (SKP_int16)SKP_RSHIFT32( sum + 1,  1 );
+        x2[ n ] = (SKP_int16)SKP_RSHIFT32( diff, 1 );
+    }
+
+    /* Find  predictor */
+    SKP_Silk_sum_sqr_shift( &nrg1, &scale1, x1, frame_length );
+    SKP_Silk_sum_sqr_shift( &nrg2, &scale2, x2, frame_length );
+    if( scale1 > scale2 ) {
+        scale = scale1;
+    } else {
+        scale = scale2;
+        nrg1 = SKP_RSHIFT32( nrg1, scale2 - scale1 );
+    }
+    corr = SKP_Silk_inner_prod_aligned_scale( x1, x2, scale, frame_length );
+    predictor_Q16 = SKP_DIV32_varQ( corr, nrg1 + 1, 16 );
+
+    /* Hysteresis */
+    if( predictor_Q16 > state->predictor_prev_Q16 ) {
+        predictor_Q16 -= SKP_FIX_CONST( STEREO_QUANT_HYSTERESIS / STEREO_QUANT_STEPS, 16 );
+    } else {
+        predictor_Q16 += SKP_FIX_CONST( STEREO_QUANT_HYSTERESIS / STEREO_QUANT_STEPS, 16 );
+    }
+
+    /* Quantize */
+    *predictorIx = SKP_RSHIFT_ROUND( SKP_MUL( predictor_Q16 + 65536, STEREO_QUANT_STEPS - 1 ), 17 );
+    *predictorIx = SKP_LIMIT( *predictorIx, 0, STEREO_QUANT_STEPS - 1 );
+
+    predictor_Q16 = SKP_SMLABB( -65536, *predictorIx, ( 1 << 17 ) / ( STEREO_QUANT_STEPS - 1 ) );
+
+    /* Subtract prediction from side channel */
+    if( predictor_Q16 != state->predictor_prev_Q16 ) {
+        /* Interpolate predictor */
+        pred_Q16 = -state->predictor_prev_Q16;
+        delta_Q16 = -SKP_DIV32_16( predictor_Q16 - state->predictor_prev_Q16, STEREO_INTERPOL_LENGTH_MS * fs_kHz );
+        for( n = 0; n < STEREO_INTERPOL_LENGTH_MS * fs_kHz; n++ ) {
+            pred_Q16 += delta_Q16;
+            x2[ n ] = (SKP_int16)SKP_SAT16( SKP_SMLAWB( x2[ n ], pred_Q16, x1[ n ] ) );
+        }
+    } else {
+        n = 0;
+    }
+    pred_Q16 = -predictor_Q16;
+    for( ; n < frame_length; n++ ) {
+        x2[ n ] = (SKP_int16)SKP_SAT16( SKP_SMLAWB( x2[ n ], pred_Q16, x1[ n ] ) );
+    }
+
+    state->predictor_prev_Q16 = predictor_Q16;
+}
--- /dev/null
+++ b/src_common/SKP_Silk_stereo_MS_to_LR.c
@@ -1,0 +1,72 @@
+/***********************************************************************
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. 
+Redistribution and use in source and binary forms, with or without 
+modification, (subject to the limitations in the disclaimer below) 
+are permitted provided that the following conditions are met:
+- Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+- Redistributions in binary form must reproduce the above copyright 
+notice, this list of conditions and the following disclaimer in the 
+documentation and/or other materials provided with the distribution.
+- Neither the name of Skype Limited, nor the names of specific 
+contributors, may be used to endorse or promote products derived from 
+this software without specific prior written permission.
+NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 
+BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
+CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
+BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+***********************************************************************/
+
+#include "SKP_Silk_main.h"
+
+/* Convert adaptive Mid/Side representation to Left/Right stereo signal */
+void SKP_Silk_stereo_MS_to_LR( 
+    stereo_state        *state,                         /* I/O  State                                       */
+    SKP_int16           x1[],                           /* I/O  Left input signal, becomes mid signal       */
+    SKP_int16           x2[],                           /* I/O  Right input signal, becomes side signal     */
+    SKP_int             predictorIx,                    /* I    Index for predictor filter                  */
+    SKP_int             fs_kHz,                         /* I    Samples rate (kHz)                          */
+    SKP_int             frame_length                    /* I    Number of samples                           */
+)
+{
+    SKP_int   n;
+    SKP_int32 sum, diff, predictor_Q16, pred_Q16, delta_Q16;
+
+    /* Dequantize */
+    predictor_Q16 = SKP_SMLABB( -65536, predictorIx, ( 1 << 17 ) / ( STEREO_QUANT_STEPS - 1 ) );
+
+    /* Add prediction to side channel */
+    if( predictor_Q16 != state->predictor_prev_Q16 ) {
+        /* Interpolate predictor */
+        pred_Q16 = state->predictor_prev_Q16;
+        delta_Q16 = SKP_DIV32_16( predictor_Q16 - state->predictor_prev_Q16, STEREO_INTERPOL_LENGTH_MS * fs_kHz );
+        for( n = 0; n < STEREO_INTERPOL_LENGTH_MS * fs_kHz; n++ ) {
+            pred_Q16 += delta_Q16;
+            x2[ n ] = (SKP_int16)SKP_SAT16( SKP_SMLAWB( x2[ n ], pred_Q16, x1[ n ] ) );
+        }
+    } else {
+        n = 0;
+    }
+    pred_Q16 = predictor_Q16;
+    for( ; n < frame_length; n++ ) {
+        x2[ n ] = (SKP_int16)SKP_SAT16( SKP_SMLAWB( x2[ n ], pred_Q16, x1[ n ] ) );
+    }
+
+    state->predictor_prev_Q16 = predictor_Q16;
+
+    /* Convert to left/right signals */
+    for( n = 0; n < frame_length; n++ ) {
+        sum  = x1[ n ] + (SKP_int32)x2[ n ];
+        diff = x1[ n ] - (SKP_int32)x2[ n ];
+        x1[ n ] = (SKP_int16)SKP_SAT16( sum );
+        x2[ n ] = (SKP_int16)SKP_SAT16( diff );
+    }
+}
--- a/src_common/SKP_Silk_structs.h
+++ b/src_common/SKP_Silk_structs.h
@@ -28,6 +28,9 @@
 #ifndef SKP_SILK_STRUCTS_H
 #define SKP_SILK_STRUCTS_H
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 
 #include "SKP_Silk_typedef.h"
 #include "SKP_Silk_SigProc_FIX.h"
@@ -96,6 +99,10 @@
 } SKP_Silk_NLSF_CB_struct;
 
 typedef struct {
+    SKP_int32                   predictor_prev_Q16;
+} stereo_state;
+
+typedef struct {
     SKP_int8        GainsIndices[ MAX_NB_SUBFR ];
     SKP_int8        LTPIndex[ MAX_NB_SUBFR ];
     SKP_int8        NLSFIndices[ MAX_LPC_ORDER + 1 ];
@@ -128,8 +135,8 @@
     SKP_int                         max_pitch_lag;                  /* Highest possible pitch lag (samples)                                 */
     SKP_int32                       API_fs_Hz;                      /* API sampling frequency (Hz)                                          */
     SKP_int32                       prev_API_fs_Hz;                 /* Previous API sampling frequency (Hz)                                 */
-    SKP_int                         maxInternal_fs_kHz;             /* Maximum internal sampling frequency (kHz)                            */
-    SKP_int                         minInternal_fs_kHz;             /* Minimum internal sampling frequency (kHz)                            */
+    SKP_int                         maxInternal_fs_Hz;              /* Maximum internal sampling frequency (Hz)                             */
+    SKP_int                         minInternal_fs_Hz;              /* Minimum internal sampling frequency (Hz)                             */
     SKP_int                         fs_kHz;                         /* Internal sampling frequency (kHz)                                    */
     SKP_int                         nb_subfr;                       /* Number of 5 ms subframes in a frame                                  */
     SKP_int                         frame_length;                   /* Frame length (samples)                                               */
@@ -157,7 +164,6 @@
     SKP_int                         controlled_since_last_payload;  /* Flag for ensuring codec_control only runs once per packet            */
 	SKP_int                         warping_Q16;                    /* Warping parameter for warped noise shaping                           */
     SKP_int                         useCBR;                         /* Flag to enable constant bitrate                                      */
-    SKP_int                         prev_nBits;                     /* Use to track bits used by each frame in packet                       */
     SKP_int                         prefillFlag;                    /* Flag to indicate that only buffers are prefilled, no coding          */
     const SKP_uint8                 *pitch_lag_low_bits_iCDF;       /* Pointer to iCDF table for low bits of pitch lag index                */
     const SKP_uint8                 *pitch_contour_iCDF;            /* Pointer to iCDF table for pitch contour index                        */
@@ -164,6 +170,7 @@
     const SKP_Silk_NLSF_CB_struct   *psNLSF_CB;                     /* Pointer to NLSF codebook                                             */
     SKP_int                         input_quality_bands_Q15[ VAD_N_BANDS ];
     SKP_int                         input_tilt_Q15;
+    SKP_int                         SNR_dB_Q7;                      /* Quality setting                                                      */
 
     SKP_int8                        VAD_flags[ MAX_FRAMES_PER_PACKET ];
     SKP_int8                        LBRR_flag;
@@ -237,9 +244,6 @@
     SKP_int16       outBuf[ 2 * MAX_FRAME_LENGTH ];             /* Buffer for output signal                                             */
     SKP_int         lagPrev;                                    /* Previous Lag                                                         */
     SKP_int8        LastGainIndex;                              /* Previous gain index                                                  */
-    SKP_int32       HPState[ DEC_HP_ORDER ];                    /* HP filter state                                                      */
-    const SKP_int32 *HP_A;                                      /* HP filter AR coefficients                                            */
-    const SKP_int32 *HP_B;                                      /* HP filter MA coefficients                                            */
     SKP_int         fs_kHz;                                     /* Sampling frequency in kHz                                            */
     SKP_int32       prev_API_sampleRate;                        /* Previous API sample frequency (Hz)                                   */
     SKP_int         nb_subfr;                                   /* Number of 5 ms subframes in a frame                                  */
--- a/src_common/SKP_Silk_tables.h
+++ b/src_common/SKP_Silk_tables.h
@@ -31,9 +31,6 @@
 #include "SKP_Silk_define.h"
 #include "SKP_Silk_structs.h"
 
-#define PITCH_EST_MAX_LAG_MS                18          /* 18 ms -> 56 Hz */
-#define PITCH_EST_MIN_LAG_MS                2           /* 2 ms -> 500 Hz */
-
 #ifdef __cplusplus
 extern "C"
 {
@@ -44,11 +41,11 @@
 extern const SKP_uint8  SKP_Silk_delta_gain_iCDF[ MAX_DELTA_GAIN_QUANT - MIN_DELTA_GAIN_QUANT + 1 ]; /* 41 */
 
 extern const SKP_uint8  SKP_Silk_pitch_lag_iCDF[ 2 * ( PITCH_EST_MAX_LAG_MS - PITCH_EST_MIN_LAG_MS ) ];  /* 32 */
-extern const SKP_uint8  SKP_Silk_pitch_delta_iCDF[21];                                              /*  21 */
-extern const SKP_uint8  SKP_Silk_pitch_contour_iCDF[34];                                            /*  34 */
+extern const SKP_uint8  SKP_Silk_pitch_delta_iCDF[ 21 ];                                            /*  21 */
+extern const SKP_uint8  SKP_Silk_pitch_contour_iCDF[ 34 ];                                          /*  34 */
 extern const SKP_uint8  SKP_Silk_pitch_contour_NB_iCDF[ 11 ];                                       /*  11 */
-extern const SKP_uint8 SKP_Silk_pitch_contour_10_ms_iCDF[12];                                       /*  12 */
-extern const SKP_uint8 SKP_Silk_pitch_contour_10_ms_NB_iCDF[3];                                     /*   3 */
+extern const SKP_uint8 SKP_Silk_pitch_contour_10_ms_iCDF[ 12 ];                                     /*  12 */
+extern const SKP_uint8 SKP_Silk_pitch_contour_10_ms_NB_iCDF[ 3 ];                                   /*   3 */
 
 extern const SKP_uint8  SKP_Silk_pulses_per_block_iCDF[ N_RATE_LEVELS ][ MAX_PULSES + 2 ];          /* 180 */
 extern const SKP_uint8  SKP_Silk_pulses_per_block_BITS_Q5[ N_RATE_LEVELS - 1 ][ MAX_PULSES + 2 ];   /* 162 */
@@ -85,11 +82,13 @@
 extern const SKP_uint8  SKP_Silk_LTPscale_iCDF[ 3 ];                                                /*   4 */
 extern const SKP_int16  SKP_Silk_LTPScales_table_Q14[ 3 ];
 
-extern const SKP_uint8 SKP_Silk_type_offset_VAD_iCDF[4];                                            /*   4 */
-extern const SKP_uint8 SKP_Silk_type_offset_no_VAD_iCDF[2];                                         /*   2 */
+extern const SKP_uint8 SKP_Silk_type_offset_VAD_iCDF[ 4 ];                                          /*   4 */
+extern const SKP_uint8 SKP_Silk_type_offset_no_VAD_iCDF[ 2 ];                                       /*   2 */
 
-extern const SKP_uint8 * const SKP_Silk_LBRR_flags_iCDF_ptr[2];                                     /*  10 */
+extern const SKP_uint8 SKP_Silk_stereo_predictor_iCDF[ STEREO_QUANT_STEPS + 1 ];
 
+extern const SKP_uint8 * const SKP_Silk_LBRR_flags_iCDF_ptr[ 2 ];                                   /*  10 */
+
 extern const SKP_uint8  SKP_Silk_NLSF_interpolation_factor_iCDF[ 5 ];                               /*   5 */
 
 extern const SKP_Silk_NLSF_CB_struct SKP_Silk_NLSF_CB_WB;
@@ -101,22 +100,12 @@
 extern const SKP_int32  TargetRate_table_WB[  TARGET_RATE_TAB_SZ ];
 extern const SKP_int16  SNR_table_Q1[         TARGET_RATE_TAB_SZ ];
 
-/* Decoder high-pass filter coefficients */
-extern const SKP_int32  SKP_Silk_Dec_A_HP_16[ DEC_HP_ORDER ];                                       /*   2 */
-extern const SKP_int32  SKP_Silk_Dec_B_HP_16[ DEC_HP_ORDER + 1 ];                                   /*   3 */
-extern const SKP_int32  SKP_Silk_Dec_A_HP_12[ DEC_HP_ORDER ];                                       /*   2 */
-extern const SKP_int32  SKP_Silk_Dec_B_HP_12[ DEC_HP_ORDER + 1 ];                                   /*   3 */
-extern const SKP_int32  SKP_Silk_Dec_A_HP_8[ DEC_HP_ORDER ];                                        /*   2 */
-extern const SKP_int32  SKP_Silk_Dec_B_HP_8[ DEC_HP_ORDER + 1 ];                                    /*   3 */
-
 /* Quantization offsets */
 extern const SKP_int16  SKP_Silk_Quantization_Offsets_Q10[ 2 ][ 2 ];
 
-#if SWITCH_TRANSITION_FILTERING
 /* Interpolation points for filter coefficients used in the bandwidth transition smoother */
 extern const SKP_int32 SKP_Silk_Transition_LP_B_Q28[ TRANSITION_INT_NUM ][ TRANSITION_NB ];
 extern const SKP_int32 SKP_Silk_Transition_LP_A_Q28[ TRANSITION_INT_NUM ][ TRANSITION_NA ];
-#endif
 
 #ifdef __cplusplus
 }
--- a/src_common/SKP_Silk_tables_NLSF_CB.h
+++ /dev/null
@@ -1,63 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. 
-Redistribution and use in source and binary forms, with or without 
-modification, (subject to the limitations in the disclaimer below) 
-are permitted provided that the following conditions are met:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright 
-notice, this list of conditions and the following disclaimer in the 
-documentation and/or other materials provided with the distribution.
-- Neither the name of Skype Limited, nor the names of specific 
-contributors, may be used to endorse or promote products derived from 
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-***********************************************************************/
-
-#ifndef SKP_SILK_TABLES_NLSF_CB
-#define SKP_SILK_TABLES_NLSF_CB
-
-#include "SKP_Silk_define.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#define NLSF_MSVQ_CB0_10_STAGES       7
-#define NLSF_MSVQ_CB0_10_VECTORS      128
-#define NLSF_MSVQ_CB1_10_STAGES       7
-#define NLSF_MSVQ_CB1_10_VECTORS      80
-#define NLSF_MSVQ_CB0_16_STAGES       10
-#define NLSF_MSVQ_CB0_16_VECTORS      152
-#define NLSF_MSVQ_CB1_16_STAGES       10
-#define NLSF_MSVQ_CB1_16_VECTORS      104
-
-/* NLSF codebook entropy coding tables */
-extern const SKP_uint8         SKP_Silk_NLSF_MSVQ_CB0_10_CDF[            NLSF_MSVQ_CB0_10_VECTORS ];
-extern const SKP_uint8 * const SKP_Silk_NLSF_MSVQ_CB0_10_CDF_start_ptr[  NLSF_MSVQ_CB0_10_STAGES  ];
-extern const SKP_uint8         SKP_Silk_NLSF_MSVQ_CB1_10_CDF[            NLSF_MSVQ_CB1_10_VECTORS ];
-extern const SKP_uint8 * const SKP_Silk_NLSF_MSVQ_CB1_10_CDF_start_ptr[  NLSF_MSVQ_CB1_10_STAGES  ];
-extern const SKP_uint8         SKP_Silk_NLSF_MSVQ_CB0_16_CDF[            NLSF_MSVQ_CB0_16_VECTORS ];
-extern const SKP_uint8 * const SKP_Silk_NLSF_MSVQ_CB0_16_CDF_start_ptr[  NLSF_MSVQ_CB0_16_STAGES  ];
-extern const SKP_uint8         SKP_Silk_NLSF_MSVQ_CB1_16_CDF[            NLSF_MSVQ_CB1_16_VECTORS ];
-extern const SKP_uint8 * const SKP_Silk_NLSF_MSVQ_CB1_16_CDF_start_ptr[  NLSF_MSVQ_CB1_16_STAGES  ];
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
--- a/src_common/SKP_Silk_tables_NLSF_CB0_10.c
+++ /dev/null
@@ -1,926 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. 
-Redistribution and use in source and binary forms, with or without 
-modification, (subject to the limitations in the disclaimer below) 
-are permitted provided that the following conditions are met:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright 
-notice, this list of conditions and the following disclaimer in the 
-documentation and/or other materials provided with the distribution.
-- Neither the name of Skype Limited, nor the names of specific 
-contributors, may be used to endorse or promote products derived from 
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-***********************************************************************/
-
-/**********************************************/
-/* This file has been automatically generated */
-/*                                            */
-/* ROM usage:  0.16 + 1.43 kB                 */
-/**********************************************/
-
-#include "SKP_Silk_structs.h"
-#include "SKP_Silk_tables.h"
-#include "SKP_Silk_tables_NLSF_CB.h"
-
-const SKP_uint8 SKP_Silk_NLSF_MSVQ_CB0_10_CDF[ NLSF_MSVQ_CB0_10_VECTORS ] =
-{
-          246,
-          237,
-          230,
-          223,
-          216,
-          210,
-          204,
-          198,
-          192,
-          186,
-          180,
-          175,
-          169,
-          164,
-          158,
-          153,
-          147,
-          142,
-          137,
-          132,
-          127,
-          123,
-          118,
-          113,
-          109,
-          105,
-          101,
-           97,
-           93,
-           89,
-           85,
-           81,
-           78,
-           74,
-           71,
-           67,
-           64,
-           60,
-           57,
-           54,
-           50,
-           47,
-           44,
-           41,
-           38,
-           35,
-           32,
-           29,
-           27,
-           24,
-           21,
-           19,
-           16,
-           14,
-           12,
-           10,
-            8,
-            6,
-            5,
-            4,
-            3,
-            2,
-            1,
-            0,
-          234,
-          216,
-          198,
-          180,
-          162,
-          145,
-          128,
-          111,
-           95,
-           79,
-           64,
-           50,
-           37,
-           23,
-           10,
-            0,
-          221,
-          188,
-          154,
-          123,
-           91,
-           59,
-           28,
-            0,
-          220,
-          185,
-          151,
-          118,
-           85,
-           51,
-           26,
-            0,
-          220,
-          185,
-          150,
-          116,
-           86,
-           55,
-           26,
-            0,
-          220,
-          185,
-          152,
-          118,
-           88,
-           57,
-           28,
-            0,
-          236,
-          217,
-          199,
-          181,
-          164,
-          146,
-          130,
-          113,
-           97,
-           81,
-           66,
-           51,
-           37,
-           23,
-           11,
-            0
-};
-
-const SKP_uint8 * const SKP_Silk_NLSF_MSVQ_CB0_10_CDF_start_ptr[ NLSF_MSVQ_CB0_10_STAGES ] =
-{
-     &SKP_Silk_NLSF_MSVQ_CB0_10_CDF[   0 ],
-     &SKP_Silk_NLSF_MSVQ_CB0_10_CDF[  64 ],
-     &SKP_Silk_NLSF_MSVQ_CB0_10_CDF[  80 ],
-     &SKP_Silk_NLSF_MSVQ_CB0_10_CDF[  88 ],
-     &SKP_Silk_NLSF_MSVQ_CB0_10_CDF[  96 ],
-     &SKP_Silk_NLSF_MSVQ_CB0_10_CDF[ 104 ],
-     &SKP_Silk_NLSF_MSVQ_CB0_10_CDF[ 112 ]
-};
-
-const SKP_uint8 SKP_Silk_NLSF_MSVQ_CB0_10_rates_Q4[ NLSF_MSVQ_CB0_10_VECTORS ] =
-{
-               74,               79,
-               83,               83,
-               84,               85,
-               85,               87,
-               87,               87,
-               88,               88,
-               89,               89,
-               89,               89,
-               89,               89,
-               91,               91,
-               92,               92,
-               92,               94,
-               94,               94,
-               95,               96,
-               96,               97,
-               97,               98,
-               98,               99,
-               99,              100,
-              100,              100,
-              100,              100,
-              101,              101,
-              102,              102,
-              102,              103,
-              103,              105,
-              105,              105,
-              106,              106,
-              108,              108,
-              109,              111,
-              111,              121,
-              124,              128,
-              128,              128,
-              128,              128,
-               57,               61,
-               61,               61,
-               61,               63,
-               63,               63,
-               64,               64,
-               65,               67,
-               68,               68,
-               69,               74,
-               46,               47,
-               47,               48,
-               48,               48,
-               49,               51,
-               45,               46,
-               47,               47,
-               47,               47,
-               53,               53,
-               45,               46,
-               46,               47,
-               49,               49,
-               50,               53,
-               45,               46,
-               47,               47,
-               49,               49,
-               50,               51,
-               59,               60,
-               61,               61,
-               62,               62,
-               63,               63,
-               64,               64,
-               65,               65,
-               67,               67,
-               71,               72
-};
-
-const SKP_int SKP_Silk_NLSF_MSVQ_CB0_10_ndelta_min_Q15[ 10 + 1 ] =
-{
-              550,
-                3,
-               22,
-               18,
-                3,
-                3,
-              181,
-              162,
-              310,
-              172,
-              982
-};
-
-const SKP_int8 SKP_Silk_NLSF_MSVQ_CB0_10_Q8[ 10 * NLSF_MSVQ_CB0_10_VECTORS ] =
-{
-             -107,              -97,
-              -74,              -56,
-              -37,               -8,
-               20,               48,
-               75,              100,
-             -109,              -91,
-              -71,              -48,
-              -20,               -1,
-               23,               47,
-               77,              100,
-             -100,              -93,
-              -78,              -50,
-               -5,                8,
-               28,               53,
-               72,               93,
-             -105,              -97,
-              -82,              -49,
-              -16,               -5,
-               33,               52,
-               72,              100,
-              -98,              -92,
-              -75,              -39,
-              -10,                1,
-               24,               41,
-               62,              103,
-              -99,              -92,
-              -74,              -44,
-              -30,              -16,
-               33,               51,
-               69,              105,
-             -105,              -98,
-              -82,              -51,
-                5,               19,
-               35,               54,
-               73,              102,
-             -110,             -101,
-              -85,              -61,
-              -40,              -24,
-               12,               45,
-               67,               97,
-             -104,              -95,
-              -81,              -61,
-              -22,               -8,
-               14,               50,
-               68,               88,
-              -96,              -90,
-              -74,              -44,
-              -30,              -16,
-               20,               34,
-               74,               90,
-              -89,              -83,
-              -64,              -27,
-              -11,                0,
-               36,               54,
-               74,              103,
-             -102,              -96,
-              -71,              -28,
-              -16,                1,
-               21,               40,
-               71,               86,
-             -102,              -96,
-              -80,              -32,
-              -19,               -4,
-               31,               45,
-               88,              103,
-              -90,              -83,
-              -66,              -51,
-              -40,              -20,
-               43,               62,
-               81,              105,
-             -115,             -108,
-              -79,              -49,
-              -21,                0,
-               26,               54,
-               78,              100,
-             -105,              -93,
-              -78,              -59,
-              -28,              -14,
-               11,               32,
-               57,               96,
-             -101,              -96,
-              -68,              -17,
-               -5,                9,
-               30,               46,
-               87,              103,
-             -109,             -101,
-              -87,              -59,
-              -10,                5,
-               23,               41,
-               63,              100,
-              -86,              -78,
-              -63,              -45,
-              -28,              -15,
-               26,               43,
-               63,              102,
-             -106,              -98,
-              -83,              -41,
-              -21,               -7,
-               13,               30,
-               80,               96,
-              -94,              -88,
-              -67,              -30,
-                7,               18,
-               37,               55,
-               73,              102,
-              -96,              -90,
-              -73,              -61,
-              -51,              -15,
-               30,               44,
-               83,               99,
-             -112,             -105,
-              -84,              -61,
-              -35,               -3,
-               21,               39,
-               61,               92,
-             -105,              -98,
-              -80,              -49,
-              -38,               -2,
-               17,               38,
-               79,               94,
-              -86,              -78,
-              -66,              -48,
-              -12,                1,
-               25,               51,
-               71,               94,
-             -108,             -102,
-              -83,              -30,
-                0,               10,
-               35,               51,
-               82,              100,
-             -107,              -99,
-              -84,              -70,
-              -58,              -14,
-               17,               40,
-               75,               97,
-              -94,              -88,
-              -62,              -32,
-              -20,               -6,
-               10,               28,
-               86,              105,
-              -97,              -91,
-              -72,              -62,
-              -50,                1,
-               18,               43,
-               68,               84,
-             -103,              -98,
-              -72,              -32,
-               17,               31,
-               47,               66,
-               83,              105,
-              -99,              -90,
-              -76,              -61,
-              -49,              -33,
-               21,               40,
-               63,              100,
-              -86,              -80,
-              -60,              -43,
-              -32,              -13,
-               26,               39,
-               84,              104,
-             -102,              -96,
-              -61,              -33,
-              -23,               13,
-               31,               54,
-               85,              100,
-             -110,             -100,
-              -87,              -52,
-              -35,              -20,
-               28,               41,
-               83,              102,
-              -91,              -84,
-              -58,              -45,
-              -36,               -2,
-               22,               42,
-               72,               85,
-             -105,              -96,
-              -66,              -47,
-              -24,               11,
-               31,               45,
-               63,               91,
-              -93,              -87,
-              -70,              -45,
-              -31,              -18,
-               -2,               14,
-               69,              105,
-              -98,              -93,
-              -61,              -48,
-              -35,              -19,
-               -6,               44,
-               69,               85,
-             -101,              -94,
-              -77,              -56,
-              -43,              -24,
-               -7,               18,
-               73,               92,
-             -102,              -95,
-              -77,              -48,
-              -34,              -15,
-                5,               30,
-               55,               79,
-             -100,              -95,
-              -50,              -32,
-              -22,               -5,
-               10,               52,
-               77,               91,
-             -114,             -109,
-              -94,              -71,
-              -27,               -5,
-               21,               47,
-               74,              100,
-              -95,              -80,
-              -65,              -46,
-              -27,              -15,
-               16,               61,
-               79,               98,
-             -105,             -100,
-              -62,               -7,
-                7,               20,
-               44,               61,
-               87,              102,
-             -101,              -95,
-              -81,              -66,
-              -57,              -26,
-               40,               57,
-               83,              104,
-              -97,              -92,
-              -66,              -53,
-              -43,               11,
-               32,               49,
-               89,              102,
-              -99,              -91,
-              -75,              -57,
-              -45,              -29,
-               19,               64,
-               83,              101,
-              -91,              -85,
-              -66,              -55,
-              -44,               -9,
-               11,               27,
-               83,               99,
-             -107,              -99,
-              -83,              -59,
-               -9,               29,
-               43,               61,
-               81,               99,
-             -101,              -96,
-              -77,              -68,
-              -53,               17,
-               35,               53,
-               80,               94,
-              -99,              -93,
-              -65,              -50,
-              -37,              -20,
-               -7,               51,
-               85,              101,
-              -97,              -91,
-              -72,              -64,
-              -49,                2,
-               49,               65,
-               89,              105,
-             -107,              -95,
-              -63,              -41,
-              -14,               17,
-               43,               66,
-               89,              106,
-              -84,              -76,
-              -44,              -28,
-              -15,                5,
-               25,               44,
-               78,               95,
-             -102,              -97,
-              -42,              -17,
-               -7,               13,
-               29,               55,
-               82,               98,
-              -99,              -94,
-              -81,              -71,
-              -21,                9,
-               28,               53,
-               76,               95,
-              -86,              -79,
-              -62,              -53,
-              -34,               15,
-               37,               54,
-               83,               97,
-              -76,              -73,
-              -57,              -33,
-              -26,              -14,
-               37,               56,
-               76,              103,
-              -85,              -71,
-              -35,              -10,
-                4,               21,
-               40,               59,
-               84,              100,
-              -79,              -77,
-              -71,              -63,
-              -27,              -18,
-               25,               52,
-               77,              103,
-              -81,              -60,
-              -50,              -47,
-              -42,                3,
-               24,               54,
-               80,              104,
-              -97,              -79,
-              -23,              -16,
-              -12,               -9,
-                6,               55,
-               78,              102,
-              -76,              -74,
-              -66,              -49,
-              -47,              -38,
-               14,               47,
-               75,              101,
-              -93,              -63,
-              -44,              -37,
-              -30,              -23,
-               28,               52,
-               77,              102,
-                5,                4,
-                6,                5,
-                5,                8,
-                4,                4,
-                0,               -2,
-                0,               -1,
-               -3,               -3,
-               -5,               -6,
-              -12,                4,
-               -1,               -3,
-                2,                1,
-                2,                0,
-                1,               -1,
-               -1,               -7,
-              -12,                6,
-               -2,               -3,
-               -8,                8,
-                6,                5,
-                1,                2,
-                0,               -1,
-               -1,               -1,
-                1,                1,
-                1,                0,
-               -3,               -5,
-               -9,              -13,
-                0,                0,
-               -2,               -3,
-               -6,              -10,
-                3,               -3,
-               -3,               -5,
-               -2,               -3,
-               -4,               -7,
-               -8,               10,
-                4,                2,
-                1,               -2,
-               -5,               -6,
-               -9,               -3,
-                0,               -3,
-                2,               -2,
-                2,                3,
-                0,               -1,
-                2,               -1,
-               -2,               -3,
-               -8,              -14,
-                4,                2,
-                2,                1,
-                2,                2,
-               -1,               -4,
-               12,                6,
-                4,                5,
-                2,                1,
-                2,                4,
-                3,                3,
-                1,               -5,
-               10,                7,
-                8,                8,
-                4,               -1,
-               -1,               -4,
-               -6,                2,
-                0,               -1,
-                1,                0,
-               -4,              -12,
-                5,                3,
-                3,                3,
-                2,                2,
-                1,                0,
-                2,               -1,
-                1,                0,
-               -3,               15,
-                7,                4,
-               -5,               -6,
-                9,                5,
-                2,                3,
-                4,                0,
-               -1,                3,
-               -8,                7,
-                3,                2,
-                0,               -2,
-                0,                0,
-               -2,                0,
-               -2,               -2,
-               -3,               -4,
-               -3,               -3,
-               -3,                0,
-               -5,                4,
-                3,                3,
-                2,               -2,
-               -2,                0,
-               -1,               -2,
-               -4,               -8,
-                2,                2,
-                0,                0,
-                7,                4,
-                2,                1,
-                0,                3,
-                2,                2,
-                1,                1,
-               -2,               -6,
-                3,                0,
-               -1,                4,
-               -4,               -4,
-               -5,                1,
-                1,                3,
-                5,                4,
-                1,               -1,
-               -1,               -1,
-                7,                5,
-                3,                0,
-               -2,                5,
-                1,               -2,
-               -2,               -2,
-               -3,                2,
-                2,               -1,
-               -4,               -7,
-                3,               -2,
-                1,                1,
-                2,               -3,
-               -7,                3,
-                1,               -1,
-                7,                2,
-               -1,               -1,
-               -3,                3,
-                0,               -1,
-               -2,                0,
-               -6,                0,
-                0,                0,
-               -2,                3,
-                0,                2,
-                3,                1,
-                4,                5,
-                1,                1,
-               -3,               -3,
-               -4,               -3,
-               -2,               -2,
-                2,                0,
-                1,                1,
-                0,                0,
-               -1,               -2,
-                5,                5,
-                0,               -3,
-               -1,               -1,
-               -1,               -5,
-                5,                4,
-                1,                0,
-               -1,               -2,
-                3,                2,
-                3,                4,
-                1,                1,
-               -1,               -3,
-                0,               -1,
-               -3,               -4,
-                4,                1,
-               -2,                0,
-                0,               -2,
-                2,                0,
-                0,                4,
-                4,               -3,
-                0,               -1,
-               -4,                2,
-                0,                1,
-               -1,               -1,
-                0,               -1,
-               -3,                4,
-                1,               -2,
-               -2,               -1,
-                1,                1,
-                0,                0,
-                1,               -1,
-               -4,               -3,
-                0,                2,
-               -1,               -1,
-                0,                3,
-                4,                0,
-                2,                0,
-               -3,                1,
-               -1,               -1,
-               -3,                2,
-               -1,                2,
-               -3,                3,
-                2,                0,
-                1,                0,
-                4,                0,
-               -1,                0,
-                2,                2,
-                1,                3,
-                0,                0,
-                2,                1,
-                1,               -1,
-                0,               -2,
-                1,               -5,
-               -2,               -1,
-               -2,               -2,
-                0,               -4,
-                1,                0,
-                2,                1,
-                3,                4,
-                0,               -3,
-                1,               -1,
-                1,                1,
-                0,               -1,
-               -4,                2,
-               -1,                0,
-               -1,               -1,
-                0,                0,
-                0,                0,
-                0,               -1,
-                2,                0,
-               -2,               -3,
-               -2,                0,
-               -2,               -1,
-                2,                0,
-               -2,                1,
-                0,                0,
-                1,                0,
-                0,               -3,
-                1,                0,
-                0,               -1,
-                0,               -1,
-                1,               -3,
-                0,                3,
-                0,               -2,
-               -1,               -3,
-                0,                1,
-                0,                2,
-                0,                0,
-                2,                2,
-                1,                1,
-                0,                3,
-                1,                1,
-                0,                1,
-               -1,               -2,
-                2,                2,
-                1,                2,
-                0,               -1,
-                0,                0,
-                1,                0,
-                0,                0,
-                2,               -1,
-               -2,                1,
-                3,                0,
-                1,                0,
-               -1,                0,
-                0,                0,
-               -1,                4,
-               -1,                1,
-               -1,                0,
-                0,               -1,
-                0,                1,
-                4,                0,
-               -2,                0,
-                0,               -1,
-               -3,               -1,
-                0,                0,
-                0,               -2,
-                1,                1,
-               -1,                2,
-                0,                0,
-                0,                1,
-                1,                0,
-                4,                0,
-                1,                0,
-                1,               -1,
-                0,                2,
-               -3,                0,
-                1,               -1,
-                0,                2,
-               -1,                3,
-                1,                0,
-               -1,               -1,
-               -1,                0,
-                0,                1,
-                0,                0,
-               -4,               -1,
-                0,                1,
-                1,                0,
-               -1,                2,
-               -1,               -1,
-                2,                1,
-               -1,                0,
-               -1,               -1,
-               -2,               -2,
-                1,               -1,
-                0,                0,
-               -1,                1,
-                0,                2,
-                2,               -1,
-                1,                1,
-               -1,                1,
-                0,               -1,
-               -3,                0,
-                0,                1,
-                3,               -2,
-                0,                0,
-                0,               -1,
-               -1,               -1,
-               -1,               -2,
-               -1,                1,
-                1,               -1,
-               -1,                0,
-               -1,               -2,
-                0,                1,
-                1,                1,
-                1,               -3,
-                1,                1,
-                0,                0,
-                0,               -1,
-                0,                2,
-               -2,                0,
-                1,                0,
-                1,                0,
-                2,                1,
-               -1,               -1,
-                0,               -1,
-                1,                0,
-                2,                0,
-                0,               -2,
-                1,               -1,
-                1,               -1,
-                1,                0,
-                2,                0
-};
-
-const SKP_Silk_NLSF_CBS SKP_Silk_NLSF_CB0_10_Stage_info[ NLSF_MSVQ_CB0_10_STAGES ] =
-{
-        {  64, &SKP_Silk_NLSF_MSVQ_CB0_10_Q8[ 10 *   0 ], &SKP_Silk_NLSF_MSVQ_CB0_10_rates_Q4[   0 ] },
-        {  16, &SKP_Silk_NLSF_MSVQ_CB0_10_Q8[ 10 *  64 ], &SKP_Silk_NLSF_MSVQ_CB0_10_rates_Q4[  64 ] },
-        {   8, &SKP_Silk_NLSF_MSVQ_CB0_10_Q8[ 10 *  80 ], &SKP_Silk_NLSF_MSVQ_CB0_10_rates_Q4[  80 ] },
-        {   8, &SKP_Silk_NLSF_MSVQ_CB0_10_Q8[ 10 *  88 ], &SKP_Silk_NLSF_MSVQ_CB0_10_rates_Q4[  88 ] },
-        {   8, &SKP_Silk_NLSF_MSVQ_CB0_10_Q8[ 10 *  96 ], &SKP_Silk_NLSF_MSVQ_CB0_10_rates_Q4[  96 ] },
-        {   8, &SKP_Silk_NLSF_MSVQ_CB0_10_Q8[ 10 * 104 ], &SKP_Silk_NLSF_MSVQ_CB0_10_rates_Q4[ 104 ] },
-        {  16, &SKP_Silk_NLSF_MSVQ_CB0_10_Q8[ 10 * 112 ], &SKP_Silk_NLSF_MSVQ_CB0_10_rates_Q4[ 112 ] }
-};
-
-const SKP_Silk_NLSF_CB_struct SKP_Silk_NLSF_CB0_10 =
-{
-        NLSF_MSVQ_CB0_10_STAGES,
-        SKP_Silk_NLSF_CB0_10_Stage_info,
-        SKP_Silk_NLSF_MSVQ_CB0_10_ndelta_min_Q15,
-        SKP_Silk_NLSF_MSVQ_CB0_10_CDF_start_ptr
-};
-
--- a/src_common/SKP_Silk_tables_NLSF_CB0_16.c
+++ /dev/null
@@ -1,942 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. 
-Redistribution and use in source and binary forms, with or without 
-modification, (subject to the limitations in the disclaimer below) 
-are permitted provided that the following conditions are met:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright 
-notice, this list of conditions and the following disclaimer in the 
-documentation and/or other materials provided with the distribution.
-- Neither the name of Skype Limited, nor the names of specific 
-contributors, may be used to endorse or promote products derived from 
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-***********************************************************************/
-
-/**********************************************/
-/* This file has been automatically generated */
-/*                                            */
-/* ROM usage:  0.19 + 2.62 kB                 */
-/**********************************************/
-
-#include "SKP_Silk_structs.h"
-#include "SKP_Silk_tables.h"
-#include "SKP_Silk_tables_NLSF_CB.h"
-
-const SKP_uint8 SKP_Silk_NLSF_MSVQ_CB0_16_CDF[ NLSF_MSVQ_CB0_16_VECTORS ] =
-{
-          247,
-          238,
-          230,
-          223,
-          215,
-          209,
-          203,
-          197,
-          191,
-          186,
-          180,
-          174,
-          169,
-          164,
-          158,
-          153,
-          148,
-          143,
-          138,
-          134,
-          129,
-          124,
-          119,
-          115,
-          111,
-          107,
-          102,
-           98,
-           94,
-           90,
-           86,
-           83,
-           79,
-           76,
-           72,
-           69,
-           65,
-           62,
-           59,
-           56,
-           53,
-           50,
-           47,
-           44,
-           41,
-           38,
-           35,
-           32,
-           30,
-           27,
-           24,
-           22,
-           19,
-           17,
-           14,
-           12,
-           10,
-            8,
-            7,
-            5,
-            3,
-            2,
-            1,
-            0,
-          234,
-          214,
-          196,
-          178,
-          161,
-          144,
-          128,
-          112,
-           96,
-           79,
-           65,
-           51,
-           37,
-           24,
-           11,
-            0,
-          216,
-          178,
-          145,
-          113,
-           83,
-           54,
-           27,
-            0,
-          216,
-          181,
-          148,
-          116,
-           84,
-           53,
-           25,
-            0,
-          220,
-          185,
-          150,
-          116,
-           84,
-           54,
-           26,
-            0,
-          218,
-          183,
-          150,
-          118,
-           87,
-           56,
-           26,
-            0,
-          211,
-          171,
-          134,
-          106,
-           78,
-           50,
-           25,
-            0,
-          215,
-          175,
-          140,
-          108,
-           79,
-           51,
-           24,
-            0,
-          219,
-          184,
-          150,
-          120,
-           89,
-           58,
-           28,
-            0,
-          235,
-          215,
-          197,
-          179,
-          161,
-          144,
-          127,
-          111,
-           95,
-           80,
-           65,
-           51,
-           36,
-           23,
-           11,
-            0
-};
-
-const SKP_uint8 * const SKP_Silk_NLSF_MSVQ_CB0_16_CDF_start_ptr[ NLSF_MSVQ_CB0_16_STAGES ] =
-{
-     &SKP_Silk_NLSF_MSVQ_CB0_16_CDF[   0 ],
-     &SKP_Silk_NLSF_MSVQ_CB0_16_CDF[  64 ],
-     &SKP_Silk_NLSF_MSVQ_CB0_16_CDF[  80 ],
-     &SKP_Silk_NLSF_MSVQ_CB0_16_CDF[  88 ],
-     &SKP_Silk_NLSF_MSVQ_CB0_16_CDF[  96 ],
-     &SKP_Silk_NLSF_MSVQ_CB0_16_CDF[ 104 ],
-     &SKP_Silk_NLSF_MSVQ_CB0_16_CDF[ 112 ],
-     &SKP_Silk_NLSF_MSVQ_CB0_16_CDF[ 120 ],
-     &SKP_Silk_NLSF_MSVQ_CB0_16_CDF[ 128 ],
-     &SKP_Silk_NLSF_MSVQ_CB0_16_CDF[ 136 ]
-};
-
-const SKP_uint8 SKP_Silk_NLSF_MSVQ_CB0_16_rates_Q4[ NLSF_MSVQ_CB0_16_VECTORS ] =
-{
-               77,               78,
-               80,               81,
-               81,               86,
-               87,               87,
-               88,               88,
-               88,               89,
-               89,               89,
-               90,               90,
-               90,               91,
-               92,               92,
-               92,               92,
-               92,               94,
-               95,               95,
-               95,               95,
-               96,               96,
-               97,               98,
-               98,               99,
-               99,              100,
-              100,              101,
-              102,              102,
-              102,              102,
-              103,              103,
-              103,              103,
-              104,              104,
-              104,              105,
-              106,              106,
-              107,              107,
-              108,              111,
-              111,              113,
-              116,              117,
-              118,              121,
-              128,              128,
-               57,               59,
-               61,               61,
-               63,               63,
-               63,               64,
-               64,               64,
-               66,               67,
-               67,               69,
-               70,               72,
-               43,               44,
-               47,               48,
-               50,               50,
-               52,               52,
-               43,               46,
-               47,               48,
-               48,               49,
-               51,               54,
-               45,               46,
-               46,               47,
-               48,               49,
-               51,               53,
-               44,               46,
-               47,               48,
-               49,               49,
-               49,               53,
-               40,               43,
-               45,               51,
-               51,               51,
-               54,               54,
-               42,               43,
-               46,               48,
-               50,               51,
-               52,               55,
-               45,               46,
-               47,               49,
-               49,               49,
-               50,               51,
-               58,               59,
-               61,               61,
-               61,               63,
-               63,               64,
-               64,               65,
-               66,               66,
-               66,               68,
-               71,               73
-};
-
-const SKP_int SKP_Silk_NLSF_MSVQ_CB0_16_ndelta_min_Q15[ 16 + 1 ] =
-{
-              290,
-                3,
-               54,
-                3,
-                3,
-                3,
-              113,
-               90,
-              103,
-              132,
-              172,
-              154,
-              245,
-              248,
-              262,
-              253,
-              618
-};
-
-const SKP_int8 SKP_Silk_NLSF_MSVQ_CB0_16_Q8[ 16 * NLSF_MSVQ_CB0_16_VECTORS ] =
-{
-             -117,             -105,              -93,              -79,
-              -66,              -52,              -37,              -22,
-               -6,               10,               27,               41,
-               58,               75,               92,              107,
-             -114,             -109,              -95,              -80,
-              -68,              -53,              -38,              -19,
-               -6,                7,               26,               40,
-               53,               66,               81,               94,
-             -120,             -116,             -102,              -84,
-              -65,              -51,              -36,              -21,
-               -4,               11,               29,               46,
-               61,               77,               93,              107,
-             -117,             -110,              -99,              -86,
-              -74,              -60,              -42,              -29,
-               -9,                6,               26,               41,
-               58,               75,               91,              107,
-             -117,             -110,              -96,              -85,
-              -67,              -50,              -34,              -16,
-                0,               17,               34,               49,
-               64,               79,               94,              109,
-             -115,             -110,             -100,              -79,
-              -69,              -57,              -43,              -30,
-              -10,                3,               16,               33,
-               52,               67,               86,              105,
-             -113,             -110,              -87,              -78,
-              -68,              -54,              -39,              -23,
-              -13,               12,               29,               43,
-               59,               75,               93,              112,
-             -114,             -103,              -85,              -73,
-              -56,              -43,              -28,              -14,
-                2,               17,               32,               47,
-               63,               78,               94,              109,
-             -115,             -110,              -99,              -76,
-              -66,              -52,              -37,              -26,
-                1,               12,               26,               41,
-               59,               78,               98,              112,
-             -115,             -111,              -96,              -72,
-              -61,              -48,              -30,              -14,
-                1,               16,               34,               48,
-               61,               75,               91,              104,
-             -117,             -110,              -94,              -80,
-              -60,              -48,              -36,              -25,
-               -3,               12,               28,               47,
-               65,               80,               97,              111,
-             -108,             -104,              -94,              -76,
-              -50,              -42,              -30,              -14,
-               -2,               10,               32,               45,
-               58,               71,               85,               98,
-             -112,             -109,              -95,              -67,
-              -57,              -47,              -34,              -23,
-               -5,                8,               19,               35,
-               65,               81,               96,              108,
-             -113,             -109,              -94,              -85,
-              -75,              -64,              -51,              -26,
-              -16,                5,               22,               42,
-               60,               76,               92,              108,
-             -113,             -109,              -97,              -88,
-              -78,              -53,              -43,              -21,
-               -9,               11,               30,               44,
-               57,               71,               86,              104,
-             -115,             -111,             -100,              -69,
-              -60,              -48,              -36,              -22,
-               -8,                5,               18,               34,
-               51,               68,               87,              102,
-             -111,             -108,              -94,              -66,
-              -56,              -46,              -32,              -21,
-               -4,                9,               22,               33,
-               46,               62,               91,              112,
-             -116,             -111,             -102,              -82,
-              -60,              -49,              -35,              -21,
-               -8,               10,               24,               35,
-               49,               65,               88,              107,
-             -113,             -109,              -96,              -78,
-              -69,              -55,              -44,              -27,
-              -14,               -1,               19,               31,
-               58,               76,               94,              109,
-             -116,             -112,             -101,              -92,
-              -82,              -51,              -37,              -21,
-               -7,                6,               23,               41,
-               59,               75,               92,              108,
-             -111,             -107,              -96,              -87,
-              -79,              -49,              -36,              -24,
-               -8,                3,               19,               33,
-               49,               71,               92,              107,
-             -113,             -110,              -92,              -81,
-              -72,              -52,              -43,              -22,
-              -11,               -1,               13,               41,
-               58,               75,               88,              103,
-             -110,             -105,              -92,              -80,
-              -69,              -56,              -39,              -27,
-              -11,                2,               15,               30,
-               42,               58,               87,              104,
-             -109,             -105,              -91,              -74,
-              -66,              -52,              -38,              -25,
-               -6,                6,               19,               31,
-               45,               78,               98,              111,
-             -114,             -111,              -80,              -73,
-              -66,              -53,              -39,              -22,
-              -13,                0,               16,               42,
-               60,               77,               93,              111,
-             -112,             -108,              -94,              -83,
-              -72,              -58,              -44,              -31,
-              -18,               -6,                8,               26,
-               52,               72,               91,              109,
-             -108,              -99,              -89,              -78,
-              -60,              -49,              -38,              -18,
-               -1,                9,               25,               41,
-               54,               67,               88,              103,
-             -108,             -104,              -96,              -90,
-              -58,              -46,              -35,              -19,
-               -8,                7,               21,               36,
-               53,               74,               91,              108,
-             -114,             -110,              -86,              -73,
-              -63,              -48,              -38,              -11,
-                1,               14,               28,               42,
-               61,               81,               96,              112,
-             -115,             -111,              -74,              -66,
-              -56,              -44,              -30,              -16,
-               -5,                9,               27,               43,
-               61,               78,               95,              111,
-             -107,             -104,              -86,              -79,
-              -69,              -45,              -33,              -18,
-               -2,               10,               25,               37,
-               50,               76,               99,              113,
-             -111,             -107,              -97,              -90,
-              -67,              -52,              -36,              -22,
-              -12,                2,               26,               47,
-               63,               77,               93,              109,
-             -103,              -98,              -84,              -72,
-              -61,              -48,              -33,              -21,
-               -4,                8,               27,               42,
-               65,               81,               98,              111,
-             -111,             -108,              -95,              -87,
-              -76,              -44,              -32,              -17,
-               -3,                9,               25,               39,
-               65,               82,               99,              112,
-             -114,             -110,             -100,              -82,
-              -48,              -37,              -27,              -15,
-               -2,               11,               26,               39,
-               52,               65,               82,              105,
-             -110,             -107,              -89,              -82,
-              -71,              -61,              -49,              -13,
-               -1,               11,               26,               38,
-               59,               82,              100,              114,
-             -112,             -109,              -88,              -61,
-              -52,              -41,              -29,              -17,
-                0,               11,               24,               34,
-               48,               80,               99,              112,
-             -115,             -111,              -92,              -58,
-              -47,              -39,              -25,              -14,
-                2,               14,               27,               43,
-               63,               79,               95,              109,
-             -113,             -109,              -96,              -79,
-              -45,              -32,              -21,              -10,
-                3,               16,               33,               46,
-               60,               76,               93,              107,
-             -105,             -102,              -90,              -76,
-              -68,              -56,              -41,              -32,
-              -13,               15,               32,               43,
-               59,               74,               86,              101,
-             -110,             -106,              -94,              -85,
-              -77,              -65,              -31,              -22,
-               -5,                8,               20,               34,
-               59,               77,               96,              109,
-             -112,             -109,              -89,              -61,
-              -52,              -43,              -29,              -18,
-               -3,               14,               27,               39,
-               52,               66,               79,               98,
-             -114,             -110,             -104,              -96,
-              -56,              -44,              -30,              -17,
-               -4,               17,               32,               46,
-               61,               77,               94,              109,
-             -109,             -105,              -94,              -81,
-              -74,              -63,              -29,              -19,
-               -8,               11,               23,               33,
-               46,               62,               85,              107,
-             -111,             -108,              -91,              -83,
-              -72,              -63,              -35,              -24,
-              -13,                5,               29,               49,
-               66,               80,               97,              111,
-             -117,             -111,              -94,              -76,
-              -58,              -43,              -23,               -7,
-               10,               27,               43,               55,
-               69,               83,               97,              110,
-             -111,             -107,              -97,              -91,
-              -74,              -38,              -25,              -13,
-                0,               13,               27,               40,
-               54,               73,               93,              109,
-             -107,             -103,              -91,              -78,
-              -69,              -57,              -46,              -35,
-               -2,               11,               24,               37,
-               51,               64,               84,              107,
-             -109,             -104,              -94,              -82,
-              -72,              -62,              -39,               -9,
-                5,               15,               33,               43,
-               56,               71,               87,              102,
-             -103,              -99,              -88,              -73,
-              -68,              -55,              -28,              -15,
-               -3,               14,               30,               41,
-               56,               69,               82,               96,
-             -109,             -106,              -90,              -69,
-              -39,              -29,              -19,               -7,
-                4,               16,               35,               46,
-               57,               68,               82,               96,
-             -109,             -105,              -93,              -86,
-              -63,              -47,              -36,               -9,
-                3,               14,               30,               46,
-               66,               82,               99,              112,
-             -114,             -109,              -99,              -89,
-              -81,              -69,              -39,              -16,
-               -3,               12,               28,               41,
-               56,               72,               93,              108,
-             -107,             -104,              -91,              -79,
-              -72,              -61,              -51,              -40,
-               -6,                5,               20,               38,
-               61,               78,               97,              111,
-             -102,              -98,              -81,              -72,
-              -66,              -53,              -37,              -24,
-               -9,                3,               17,               31,
-               47,               62,               81,              102,
-             -111,             -108,              -87,              -75,
-              -66,              -53,              -40,              -29,
-              -17,               -7,                6,               16,
-               38,               68,               88,              108,
-             -108,             -105,              -92,              -70,
-              -56,              -47,              -33,              -21,
-               -7,                5,               19,               30,
-               42,               53,               65,              102,
-             -102,              -99,              -88,              -78,
-              -73,              -59,              -32,              -22,
-               -4,               10,               23,               46,
-               66,               80,               95,              107,
-             -106,             -103,              -92,              -85,
-              -82,              -62,              -22,              -11,
-                2,               18,               33,               46,
-               63,               77,               93,              106,
-             -113,             -104,              -81,              -64,
-              -47,              -30,              -13,                0,
-               15,               28,               41,               54,
-               68,               82,               97,              111,
-              -99,              -91,              -71,              -58,
-              -48,              -38,              -24,              -14,
-                0,               13,               28,               40,
-               58,               74,               92,              105,
-              -98,              -94,              -83,              -74,
-              -71,              -60,              -28,               -9,
-                3,               15,               35,               47,
-               61,               78,               96,              108,
-              -98,              -96,              -89,              -82,
-              -68,              -63,              -42,              -16,
-                1,               14,               31,               46,
-               64,               81,               96,              110,
-              -98,              -94,              -88,              -81,
-              -77,              -51,              -30,              -16,
-                1,               19,               34,               49,
-               64,               79,               96,              112,
-               -2,               -2,               -4,               -9,
-                3,                3,                2,                2,
-                1,                0,                0,                1,
-                1,                1,                1,                1,
-                1,                0,                0,                6,
-                4,                4,                2,                2,
-                1,                1,                3,                4,
-                4,                4,                3,                2,
-               -4,               -4,               -7,                2,
-                1,                0,               -1,               -1,
-               -2,               -2,               -1,               -1,
-                0,                0,                1,                1,
-                2,                2,                2,                1,
-                0,               -1,               -2,               -3,
-               -4,               -5,               -5,               -6,
-               -8,               -9,               -6,               -1,
-               -1,                0,                0,                0,
-                1,                1,                2,                0,
-               -1,               -1,               -2,               -1,
-               -2,               -3,               -8,              -10,
-                0,                0,                0,               -1,
-               -3,               -6,               -9,                4,
-                1,               -1,                0,               -1,
-               -2,               -1,                0,                0,
-                0,                0,                5,                3,
-                1,                1,                0,               -1,
-               -2,               -4,               -7,              -10,
-               -4,                2,                1,                1,
-               -3,               -3,                0,                3,
-                2,                6,                7,                6,
-                6,                5,                3,                2,
-                0,               -2,               -2,               -3,
-                0,                0,                0,               -2,
-               -3,               -3,               -3,               -4,
-               -6,               -8,               -6,                4,
-                4,                3,                2,                2,
-               -1,               -1,               -2,               -2,
-               -4,               -6,                6,                3,
-                2,                3,                1,                0,
-                1,                3,                3,                2,
-                7,                7,                3,               -1,
-                3,               -2,                0,                3,
-                0,               -1,                4,                3,
-                2,                0,               -1,               -1,
-               -1,                0,               -1,               -2,
-               -3,               -5,               -5,               -7,
-              -10,                5,                4,                2,
-                2,                2,                1,                1,
-                0,               -1,                0,                1,
-               -1,               -2,               -5,               -8,
-                5,                4,                0,               -2,
-               -3,               -2,               -3,               -1,
-                1,                1,                3,                1,
-               -1,                0,                1,               -1,
-                7,                7,                7,                7,
-                6,                4,                2,                1,
-                1,                1,                3,                2,
-                1,                2,                0,                1,
-                1,               -1,                0,               -1,
-               -4,               -6,                7,                6,
-                5,                4,                2,               -2,
-               -4,                7,                4,                2,
-                4,                2,                2,                1,
-                4,                3,                1,                1,
-                0,                0,               -2,               -3,
-                6,                3,                2,                0,
-               -1,                1,                0,               -1,
-               -1,               -1,               -1,                0,
-               -1,               -1,               -1,               -1,
-               -1,               -2,               -3,               -2,
-               -3,               -4,               -5,               -5,
-               -4,               -1,               -1,                0,
-               -1,               -1,                6,                7,
-                4,                3,                1,                2,
-                2,                1,               -1,               -1,
-               -1,               -1,                0,                0,
-                4,                4,                2,                1,
-               -1,               -2,               -1,               -2,
-               -1,                0,                1,                0,
-                2,                4,                4,                2,
-                1,                1,                0,               -1,
-               -3,               -5,                3,                1,
-                1,                3,                1,               -1,
-               -2,               -4,               -3,               -1,
-               -3,               -2,               -4,               -1,
-               -2,               -2,               -2,                0,
-                3,                2,                1,                2,
-                3,                4,                4,                2,
-                0,                0,               -1,               -2,
-               -4,                6,                4,                3,
-                2,                1,                0,                2,
-                2,                1,                0,               -1,
-                0,               -1,                1,                0,
-               -2,               -2,               -4,               -1,
-               -2,               -3,                6,                5,
-                3,                0,               -2,               -1,
-               -1,               -1,               -4,                3,
-                3,                1,                1,                0,
-                0,                1,               -1,               -2,
-               -3,                0,                0,                0,
-               -1,               -1,                0,               -1,
-                0,               -1,                0,                3,
-                0,                5,                4,                3,
-                2,                1,                0,               -1,
-                0,                1,               -1,               -1,
-               -2,               -3,               -4,               -5,
-                3,                0,                0,                0,
-               -1,               -1,                0,                1,
-               -1,               -1,                0,               -1,
-               -2,                3,                2,                3,
-                2,                1,                0,               -1,
-               -3,               -4,               -2,                1,
-               -2,               -3,                3,                1,
-                0,               -1,               -1,                0,
-               -2,               -2,               -3,                1,
-                0,                0,                0,                1,
-                1,                1,                1,                0,
-                1,                1,                0,               -1,
-               -4,               -5,                5,                3,
-                1,                1,                1,                0,
-                3,                5,                2,                0,
-                0,                1,                2,                1,
-                1,                0,               -2,                0,
-               -1,                0,                0,               -1,
-                0,                0,                0,               -1,
-               -2,               -1,                0,                0,
-               -1,               -1,               -4,               -5,
-                6,                5,                2,                0,
-               -1,                0,               -2,               -4,
-               -3,                0,               -1,               -1,
-               -2,                1,                0,               -1,
-               -1,                0,                0,                0,
-               -1,                0,                1,                1,
-                1,                2,                0,                0,
-                0,                0,                2,                1,
-                1,                0,               -3,               -6,
-                1,                1,                1,                0,
-                0,               -1,               -4,                4,
-                2,                1,                1,                2,
-                2,                1,                2,                1,
-               -1,               -1,               -3,                1,
-                1,                0,               -1,               -3,
-                0,               -1,               -3,                4,
-                3,               -1,                0,               -1,
-                0,               -1,                0,                0,
-                0,               -3,                5,                2,
-                1,                0,                0,                1,
-                2,                0,                0,                0,
-                1,                1,                1,                1,
-                1,                1,                2,                0,
-                2,                2,                0,               -2,
-               -4,               -2,                4,                3,
-                1,                1,                1,                1,
-                0,                0,                0,               -1,
-               -1,               -1,               -1,               -2,
-                0,               -3,               -6,                2,
-               -1,               -1,                2,                1,
-                1,                1,                0,               -1,
-               -2,               -2,                0,               -2,
-               -3,                5,                2,                1,
-                0,                1,                1,                0,
-                0,                1,                1,                0,
-               -1,               -3,               -2,                0,
-               -2,               -3,                1,               -1,
-                1,                0,                1,                0,
-                0,                2,                0,               -1,
-                3,                0,                0,               -2,
-                2,                3,                2,                2,
-                1,                1,                1,                0,
-                0,                0,                0,               -1,
-               -3,                4,                3,                1,
-               -2,               -1,               -1,                1,
-                1,                1,                0,                0,
-               -1,               -1,                0,               -1,
-                0,               -2,               -2,                4,
-                2,                1,               -2,               -1,
-               -1,               -1,               -2,                0,
-                0,               -1,                0,                1,
-                0,               -3,                2,                1,
-               -1,               -1,                2,                3,
-                0,                0,                0,                0,
-               -1,                0,               -3,                4,
-                3,                1,               -1,               -2,
-                0,               -1,               -2,               -1,
-               -1,                0,               -1,                1,
-                1,                0,                0,               -2,
-               -4,                2,                0,               -2,
-                3,                1,                1,                0,
-               -2,               -1,                0,                0,
-                0,               -2,                2,               -1,
-                2,                0,                0,               -1,
-               -3,                1,               -2,               -2,
-                0,                0,               -1,               -3,
-                3,                1,                0,                0,
-               -1,               -1,               -1,               -1,
-                0,                1,               -1,               -1,
-                0,               -1,                0,                0,
-                2,                0,                1,                0,
-                1,                1,                2,                1,
-                0,               -4,                0,                0,
-                0,                0,                1,                0,
-               -1,                0,               -1,               -3,
-                3,                2,               -1,                0,
-                0,                1,                0,               -1,
-                0,                0,                0,                2,
-                1,                1,                1,                1,
-                0,                0,               -1,                2,
-                2,                1,               -2,                3,
-                0,                1,                0,                0,
-               -1,                0,               -1,                1,
-                0,               -2,                2,                0,
-               -3,                2,                1,               -2,
-                0,               -1,                0,                0,
-               -3,                3,                1,                0,
-               -1,               -1,               -1,               -1,
-                1,               -1,                1,                0,
-                1,                2,                0,                0,
-               -1,               -3,                2,                0,
-               -2,                1,                0,               -1,
-                1,                0,                0,               -1,
-               -1,               -1,                0,                0,
-               -1,               -3,               -3,                2,
-                0,               -1,                0,               -1,
-                1,                0,                0,                2,
-                1,                0,                1,                0,
-                0,               -1,               -2,               -1,
-               -2,                1,                0,               -1,
-               -2,               -1,                1,               -1,
-                1,                0,                0,                0,
-                1,                1,                1,                0,
-                1,                1,                1,                0,
-                1,                2,                0,               -1,
-                0,               -1,                0,                0,
-                0,                1,                0,                1,
-                0,                0,               -2,                2,
-               -1,                2,                1,                0,
-                0,               -1,               -3,                0,
-                0,                0,                1,                1,
-                0,               -1,               -1,               -2,
-                0,                0,               -1,               -1,
-                1,                1,                0,                0,
-               -1,                0,                1,               -1,
-                1,                0,               -1,                1,
-               -1,               -2,                0,                2,
-                0,               -1,                2,                0,
-                0,                0,                0,                0,
-               -1,               -1,                1,               -1,
-                2,               -1,                2,                1,
-                0,               -1,                0,                0,
-               -1,                0,               -1,                0,
-                0,               -1,                2,                1,
-                0,                0,               -3,                0,
-               -3,                3,                0,                0,
-                0,                0,                0,                0,
-                0,                0,                0,                0,
-                0,                0,                0,                0,
-                0,                0,               -1,                3,
-                1,               -1,                0,                0,
-                0,                0,                1,                0,
-                0,               -1,                0,               -1,
-               -1,                0,                0,               -2,
-                1,               -2,                0,                0,
-                0,                0,               -1,                0,
-               -1,                0,                2,                1,
-                0,                0,               -2,                0,
-                0,                2,                0,                0,
-                0,                1,                1,                0,
-               -1,                1,                0,                1,
-               -1,               -1,                0,                0,
-                0,                0,               -1,                0,
-                2,                0,               -1,                1,
-                1,               -1,               -2,                0,
-                1,                2,                0,                0,
-                0,                0,               -1,                0,
-               -1,               -1,               -1,                0,
-                2,                0,                0,               -1,
-                0,                0,                0,                0,
-               -2,                0,                1,                0,
-                1,                1,                1,                0,
-                1,                1,                2,               -1,
-                0,               -1,                0,                0,
-                0,                0,                1,               -2,
-               -2,               -1,                1,                0,
-               -1,                0,               -1,                0,
-                0,                0,                2,                0,
-                0,               -1,                1,                2,
-                0,               -1,                0,               -1,
-               -1,                1,               -1,                1,
-                0,                0,                1,                0,
-                0,                0,                1,                0,
-                0,                2,               -2,               -1,
-                1,               -1,               -1,                0,
-                1,                0,               -3,                0,
-                0,                0,                0,               -1,
-                0,                1,                0,                1,
-                1,                0,                0,                0,
-               -1,               -1,                0,                0,
-                1,                0,               -1,                1,
-                0,               -1,                0,                0,
-                0,                0,                1,               -2,
-                0,               -1,                0,                0,
-                1,                0,               -1,               -1,
-                1,               -2,               -1,                0,
-               -1,                0,                0,                1,
-                1,               -1,                1,               -2,
-                0,                1,                0,                1,
-                0,                0,                0,                0,
-                0,               -1,                0,                0,
-                1,                2,                0,                0,
-                0,                0,                0,                1,
-                1,                0,                0,                1,
-                0,                0,                0,               -1,
-                1,                0,                0,                0,
-                0,                0,                1,                0,
-               -1,                0,                0,                0,
-                0,                1,                3,                1,
-                1,                0,                1,                1,
-                0,                2,               -1,                0,
-                0,                0,                1,                0,
-                0,                0,                0,                0,
-                0,                1,                0,                0,
-                0,               -1,                0,               -1,
-                1,               -1,                2,               -2,
-                1,               -1,                0,                0,
-                0,                0,                0,                0,
-                0,                0,                0,                2,
-               -2,                0,                0,                1,
-                1,                0,               -1,                0,
-               -2,                1,                1,                0,
-                0,                0,               -1,               -1,
-                0,                0,                0,                1,
-                0,                0,                0,                1,
-                1,                0,                0,                0,
-               -2,                0,               -1,                0,
-                0,                0,               -1,               -1,
-                0,                2,               -1,                0,
-               -1,                1,                0,                0,
-                0,                1,                2,               -1,
-                0,               -1,                0,                1,
-                0,                0,                0,                0,
-                0,               -1,                1,                0,
-                0,               -3,                0,                0,
-                0,                0,                1,                1,
-               -1,                0,                0,                0,
-               -1,               -1,                0,                0,
-                0,                0,                1,                0,
-                0,                1,                1,               -1,
-               -1,                0,                0,                1,
-               -1,                0,               -1,                1,
-               -2,               -1,               -1,                0,
-                0,                1,                0,                0,
-                0,               -1,                0,                0
-};
-
-const SKP_Silk_NLSF_CBS SKP_Silk_NLSF_CB0_16_Stage_info[ NLSF_MSVQ_CB0_16_STAGES ] =
-{
-        {  64, &SKP_Silk_NLSF_MSVQ_CB0_16_Q8[ 16 *   0 ], &SKP_Silk_NLSF_MSVQ_CB0_16_rates_Q4[   0 ] },
-        {  16, &SKP_Silk_NLSF_MSVQ_CB0_16_Q8[ 16 *  64 ], &SKP_Silk_NLSF_MSVQ_CB0_16_rates_Q4[  64 ] },
-        {   8, &SKP_Silk_NLSF_MSVQ_CB0_16_Q8[ 16 *  80 ], &SKP_Silk_NLSF_MSVQ_CB0_16_rates_Q4[  80 ] },
-        {   8, &SKP_Silk_NLSF_MSVQ_CB0_16_Q8[ 16 *  88 ], &SKP_Silk_NLSF_MSVQ_CB0_16_rates_Q4[  88 ] },
-        {   8, &SKP_Silk_NLSF_MSVQ_CB0_16_Q8[ 16 *  96 ], &SKP_Silk_NLSF_MSVQ_CB0_16_rates_Q4[  96 ] },
-        {   8, &SKP_Silk_NLSF_MSVQ_CB0_16_Q8[ 16 * 104 ], &SKP_Silk_NLSF_MSVQ_CB0_16_rates_Q4[ 104 ] },
-        {   8, &SKP_Silk_NLSF_MSVQ_CB0_16_Q8[ 16 * 112 ], &SKP_Silk_NLSF_MSVQ_CB0_16_rates_Q4[ 112 ] },
-        {   8, &SKP_Silk_NLSF_MSVQ_CB0_16_Q8[ 16 * 120 ], &SKP_Silk_NLSF_MSVQ_CB0_16_rates_Q4[ 120 ] },
-        {   8, &SKP_Silk_NLSF_MSVQ_CB0_16_Q8[ 16 * 128 ], &SKP_Silk_NLSF_MSVQ_CB0_16_rates_Q4[ 128 ] },
-        {  16, &SKP_Silk_NLSF_MSVQ_CB0_16_Q8[ 16 * 136 ], &SKP_Silk_NLSF_MSVQ_CB0_16_rates_Q4[ 136 ] }
-};
-
-const SKP_Silk_NLSF_CB_struct SKP_Silk_NLSF_CB0_16 =
-{
-        NLSF_MSVQ_CB0_16_STAGES,
-        SKP_Silk_NLSF_CB0_16_Stage_info,
-        SKP_Silk_NLSF_MSVQ_CB0_16_ndelta_min_Q15,
-        SKP_Silk_NLSF_MSVQ_CB0_16_CDF_start_ptr
-};
-
--- a/src_common/SKP_Silk_tables_NLSF_CB1_10.c
+++ /dev/null
@@ -1,614 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. 
-Redistribution and use in source and binary forms, with or without 
-modification, (subject to the limitations in the disclaimer below) 
-are permitted provided that the following conditions are met:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright 
-notice, this list of conditions and the following disclaimer in the 
-documentation and/or other materials provided with the distribution.
-- Neither the name of Skype Limited, nor the names of specific 
-contributors, may be used to endorse or promote products derived from 
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-***********************************************************************/
-
-/**********************************************/
-/* This file has been automatically generated */
-/*                                            */
-/* ROM usage:  0.11 + 0.90 kB                 */
-/**********************************************/
-
-#include "SKP_Silk_structs.h"
-#include "SKP_Silk_tables.h"
-#include "SKP_Silk_tables_NLSF_CB.h"
-
-const SKP_uint8 SKP_Silk_NLSF_MSVQ_CB1_10_CDF[ NLSF_MSVQ_CB1_10_VECTORS ] =
-{
-          176,
-          144,
-          119,
-          102,
-           92,
-           85,
-           79,
-           73,
-           68,
-           63,
-           58,
-           53,
-           49,
-           45,
-           41,
-           37,
-           34,
-           30,
-           27,
-           24,
-           22,
-           19,
-           17,
-           15,
-           13,
-           12,
-           10,
-            8,
-            6,
-            4,
-            2,
-            0,
-          149,
-           93,
-           71,
-           55,
-           40,
-           26,
-           12,
-            0,
-          121,
-          100,
-           80,
-           61,
-           45,
-           29,
-           14,
-            0,
-          133,
-          110,
-           88,
-           67,
-           48,
-           30,
-           13,
-            0,
-          199,
-          152,
-          111,
-           76,
-           53,
-           32,
-           15,
-            0,
-          161,
-          109,
-           88,
-           68,
-           49,
-           30,
-           14,
-            0,
-          211,
-          171,
-          134,
-           98,
-           63,
-           37,
-           11,
-            0
-};
-
-const SKP_uint8 * const SKP_Silk_NLSF_MSVQ_CB1_10_CDF_start_ptr[ NLSF_MSVQ_CB1_10_STAGES ] =
-{
-     &SKP_Silk_NLSF_MSVQ_CB1_10_CDF[   0 ],
-     &SKP_Silk_NLSF_MSVQ_CB1_10_CDF[  32 ],
-     &SKP_Silk_NLSF_MSVQ_CB1_10_CDF[  40 ],
-     &SKP_Silk_NLSF_MSVQ_CB1_10_CDF[  48 ],
-     &SKP_Silk_NLSF_MSVQ_CB1_10_CDF[  56 ],
-     &SKP_Silk_NLSF_MSVQ_CB1_10_CDF[  64 ],
-     &SKP_Silk_NLSF_MSVQ_CB1_10_CDF[  72 ]
-};
-
-const SKP_uint8 SKP_Silk_NLSF_MSVQ_CB1_10_rates_Q4[ NLSF_MSVQ_CB1_10_VECTORS ] =
-{
-               27,               48,
-               54,               63,
-               74,               84,
-               85,               89,
-               91,               91,
-               91,               91,
-               94,               95,
-               96,               97,
-              100,              101,
-              102,              104,
-              106,              106,
-              113,              113,
-              113,              113,
-              113,              113,
-              113,              113,
-              113,              113,
-               20,               35,
-               57,               64,
-               66,               66,
-               67,               71,
-               15,               58,
-               58,               61,
-               64,               64,
-               65,               68,
-               17,               55,
-               57,               58,
-               60,               61,
-               63,               68,
-               35,               39,
-               43,               46,
-               56,               58,
-               63,               65,
-               23,               37,
-               57,               59,
-               60,               61,
-               63,               68,
-               40,               43,
-               45,               45,
-               46,               53,
-               53,               73
-};
-
-const SKP_int SKP_Silk_NLSF_MSVQ_CB1_10_ndelta_min_Q15[ 10 + 1 ] =
-{
-              488,
-               31,
-              249,
-              268,
-              153,
-               20,
-               12,
-               15,
-                9,
-                3,
-              685
-};
-
-const SKP_int8 SKP_Silk_NLSF_MSVQ_CB1_10_Q8[ 10 * NLSF_MSVQ_CB1_10_VECTORS ] =
-{
-             -112,              -92,
-              -67,              -43,
-              -20,                3,
-               28,               52,
-               78,              100,
-             -113,             -100,
-              -76,              -53,
-              -30,               -7,
-               20,               45,
-               72,               97,
-              -97,              -81,
-              -58,              -34,
-              -10,               11,
-               37,               59,
-               83,              104,
-             -110,             -100,
-              -80,              -61,
-              -38,              -15,
-               12,               38,
-               66,               90,
-             -114,             -107,
-              -81,              -50,
-              -23,                2,
-               28,               51,
-               77,              101,
-              -92,              -80,
-              -59,              -42,
-              -18,                2,
-               26,               50,
-               77,               97,
-             -102,              -83,
-              -56,              -29,
-               -8,               23,
-               48,               73,
-               98,              111,
-              -98,              -78,
-              -48,              -19,
-                7,               32,
-               54,               73,
-               92,              107,
-             -105,              -90,
-              -69,              -42,
-               -4,               20,
-               38,               57,
-               77,               97,
-             -113,             -101,
-              -71,              -40,
-              -14,               11,
-               42,               65,
-               89,              108,
-             -109,              -99,
-              -84,              -61,
-              -17,                0,
-               19,               46,
-               65,               97,
-             -109,             -100,
-              -85,              -49,
-              -25,              -10,
-               21,               35,
-               79,               97,
-             -109,             -101,
-              -81,              -33,
-              -10,                6,
-               28,               46,
-               81,               99,
-             -115,              -84,
-              -58,              -32,
-              -11,               11,
-               36,               61,
-               84,              104,
-             -114,             -106,
-              -88,              -68,
-              -39,               -3,
-               25,               44,
-               66,               97,
-              -79,              -68,
-              -46,              -29,
-               -7,               13,
-               36,               58,
-               82,              101,
-             -106,              -87,
-              -69,              -51,
-              -27,              -11,
-               15,               52,
-               74,               92,
-              -99,              -87,
-              -70,              -55,
-              -40,              -13,
-               31,               52,
-               78,              101,
-             -109,              -98,
-              -83,              -66,
-              -52,              -28,
-               23,               46,
-               74,               99,
-             -111,             -103,
-              -87,              -57,
-               -2,               19,
-               33,               53,
-               72,               97,
-             -113,              -99,
-              -62,              -21,
-                5,               27,
-               47,               65,
-               86,              103,
-              -99,              -79,
-              -37,              -16,
-                3,               19,
-               37,               62,
-               83,              101,
-              -92,              -79,
-              -57,              -41,
-              -25,              -10,
-                8,               30,
-               68,               96,
-             -104,              -92,
-              -77,              -56,
-              -39,              -23,
-               -7,               21,
-               72,               95,
-              -78,              -65,
-              -34,              -16,
-               10,               30,
-               51,               71,
-               90,              106,
-             -104,              -76,
-              -38,               -5,
-               27,               52,
-               66,               77,
-               89,              101,
-             -106,              -79,
-              -50,              -24,
-               15,               40,
-               43,               35,
-               47,              102,
-             -103,              -71,
-              -40,               -6,
-               22,               22,
-               26,               37,
-               66,               99,
-             -106,              -78,
-              -53,              -30,
-               -3,               40,
-               63,               69,
-               57,               75,
-             -106,              -79,
-              -51,              -33,
-               -1,               17,
-               51,               89,
-              108,              121,
-             -107,              -82,
-              -56,              -37,
-               -7,               17,
-               68,               86,
-               86,               88,
-             -102,              -76,
-              -47,              -13,
-               -3,                3,
-               10,               43,
-               77,              105,
-               -2,               -2,
-               -1,               -1,
-                0,                0,
-               -1,                0,
-                0,                0,
-                2,                4,
-                4,                3,
-                4,                5,
-                4,                3,
-                2,                2,
-               -1,               -3,
-               -5,                0,
-               -5,               -9,
-               -4,               -1,
-               -4,               -6,
-                1,                1,
-                0,                2,
-               -4,               -6,
-               -2,               -4,
-                9,                5,
-               -3,               -6,
-               -9,              -12,
-                2,                0,
-                0,                2,
-                0,               -1,
-                0,               -1,
-                2,                9,
-                6,                2,
-               -4,               -9,
-               -7,               -3,
-                9,                9,
-                7,                3,
-               -3,               -6,
-               -3,               -5,
-               -8,               -2,
-                1,                0,
-               -3,               -8,
-              -12,                4,
-                4,                7,
-                7,                0,
-               -1,                0,
-                0,                0,
-                0,                1,
-                0,                1,
-                1,                1,
-                3,                3,
-                2,               -5,
-               -8,               -3,
-               -3,               -1,
-               -1,               -3,
-                3,                3,
-                4,                4,
-                2,               -4,
-               -9,               -1,
-               -2,               -2,
-                2,                2,
-                2,                4,
-                5,                5,
-                3,                0,
-               -5,               -7,
-               -1,               -2,
-               -6,               -5,
-               -1,               -6,
-                1,               -1,
-               -6,                5,
-               -5,              -10,
-                4,                2,
-                2,                0,
-                0,                1,
-                1,                0,
-                2,                1,
-               -1,                3,
-                3,               -1,
-               12,                3,
-                3,                3,
-                0,               -2,
-               -4,               -4,
-               -4,                5,
-               -1,               -9,
-                1,                0,
-               -1,                0,
-               -1,                0,
-                0,                0,
-                1,                0,
-               -1,               -2,
-                0,               -1,
-               -2,               -1,
-               -1,                0,
-                2,                8,
-                4,                4,
-                6,                4,
-                0,               -2,
-               -2,                0,
-                0,               -1,
-               -2,                1,
-                2,                0,
-               -3,               -2,
-                7,                1,
-                1,               -1,
-               -3,                2,
-               -1,               -3,
-               -4,                6,
-                0,                1,
-               -3,               -1,
-                5,                0,
-                0,               -2,
-                1,               -2,
-               -2,               -2,
-               -6,               -2,
-                2,                5,
-                0,               -2,
-               10,                5,
-               -1,                1,
-                0,                0,
-               -1,               -1,
-               -1,                7,
-                5,               -2,
-                0,                0,
-                0,               -4,
-               -1,               -3,
-               -2,               -1,
-               -2,               -3,
-                1,               -1,
-               -1,               -2,
-                3,                0,
-                0,                0,
-                1,                1,
-               -2,               -5,
-                1,                1,
-                0,                2,
-                2,                1,
-                1,               -3,
-                1,                2,
-                0,                3,
-                0,               -2,
-                2,                1,
-                2,                3,
-                1,                0,
-               -1,               -3,
-                0,               -1,
-               -1,               -2,
-                0,                0,
-                1,                3,
-                5,                1,
-               -1,                1,
-               -4,                5,
-                0,                2,
-                1,                1,
-                0,                0,
-               -1,                0,
-                0,               -2,
-               -1,                1,
-                2,                0,
-               -5,                4,
-               -1,                0,
-                1,                0,
-               -2,                1,
-               -6,                4,
-                0,                0,
-               -2,                0,
-                0,               -1,
-                1,               -1,
-               -1,               -1,
-                0,               -3,
-               -2,                0,
-                1,                1,
-               -1,                4,
-                1,                0,
-                0,                2,
-               -1,                2,
-               -3,                0,
-                3,                0,
-                1,                0,
-                1,                4,
-                2,                0,
-                2,                0,
-                1,                0,
-                0,                1,
-                1,               -1,
-                6,                2,
-                0,                3,
-               -1,               -3,
-                0,               -2,
-               -2,                1,
-                1,                0,
-                0,                0,
-               -1,               -1,
-                1,                6,
-               -1,                0,
-                0,               -1,
-                1,                0,
-                0,                1,
-                0,               -1,
-                1,                1,
-                0,               -7,
-               -1,               -3,
-               -4,               -1,
-               -2,                0,
-                0,                1,
-                0,                1,
-                2,                1,
-               -3,                0,
-                0,                0,
-                0,               -1,
-                1,               -1,
-               -1,                1,
-                1,               -1,
-                0,                2,
-                0,                0,
-                0,                3,
-                1,                0,
-                1,                1,
-               -3,                0,
-               -2,                1,
-                1,                0,
-                0,                0,
-                1,                0,
-                3,               -2,
-                0,                0,
-                1,                0,
-               -1,                0,
-                0,               -1,
-                0,                0,
-               -1,                0,
-               -4,               -1,
-               -2,               -3,
-                0,                1,
-                0,                0,
-                0,               -1,
-                1,                0,
-                0,                1,
-                0,                0,
-               -1,                0,
-                5,                0,
-                1,               -1,
-                2,               -3,
-                1,               -1,
-                0,                0,
-                0,                0,
-                0,                0
-};
-
-const SKP_Silk_NLSF_CBS SKP_Silk_NLSF_CB1_10_Stage_info[ NLSF_MSVQ_CB1_10_STAGES ] =
-{
-        {  32, &SKP_Silk_NLSF_MSVQ_CB1_10_Q8[ 10 *   0 ], &SKP_Silk_NLSF_MSVQ_CB1_10_rates_Q4[   0 ] },
-        {   8, &SKP_Silk_NLSF_MSVQ_CB1_10_Q8[ 10 *  32 ], &SKP_Silk_NLSF_MSVQ_CB1_10_rates_Q4[  32 ] },
-        {   8, &SKP_Silk_NLSF_MSVQ_CB1_10_Q8[ 10 *  40 ], &SKP_Silk_NLSF_MSVQ_CB1_10_rates_Q4[  40 ] },
-        {   8, &SKP_Silk_NLSF_MSVQ_CB1_10_Q8[ 10 *  48 ], &SKP_Silk_NLSF_MSVQ_CB1_10_rates_Q4[  48 ] },
-        {   8, &SKP_Silk_NLSF_MSVQ_CB1_10_Q8[ 10 *  56 ], &SKP_Silk_NLSF_MSVQ_CB1_10_rates_Q4[  56 ] },
-        {   8, &SKP_Silk_NLSF_MSVQ_CB1_10_Q8[ 10 *  64 ], &SKP_Silk_NLSF_MSVQ_CB1_10_rates_Q4[  64 ] },
-        {   8, &SKP_Silk_NLSF_MSVQ_CB1_10_Q8[ 10 *  72 ], &SKP_Silk_NLSF_MSVQ_CB1_10_rates_Q4[  72 ] }
-};
-
-const SKP_Silk_NLSF_CB_struct SKP_Silk_NLSF_CB1_10 =
-{
-        NLSF_MSVQ_CB1_10_STAGES,
-        SKP_Silk_NLSF_CB1_10_Stage_info,
-        SKP_Silk_NLSF_MSVQ_CB1_10_ndelta_min_Q15,
-        SKP_Silk_NLSF_MSVQ_CB1_10_CDF_start_ptr
-};
-
--- a/src_common/SKP_Silk_tables_NLSF_CB1_16.c
+++ /dev/null
@@ -1,678 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. 
-Redistribution and use in source and binary forms, with or without 
-modification, (subject to the limitations in the disclaimer below) 
-are permitted provided that the following conditions are met:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright 
-notice, this list of conditions and the following disclaimer in the 
-documentation and/or other materials provided with the distribution.
-- Neither the name of Skype Limited, nor the names of specific 
-contributors, may be used to endorse or promote products derived from 
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-***********************************************************************/
-
-/**********************************************/
-/* This file has been automatically generated */
-/*                                            */
-/* ROM usage:  0.14 + 1.80 kB                 */
-/**********************************************/
-
-#include "SKP_Silk_structs.h"
-#include "SKP_Silk_tables.h"
-#include "SKP_Silk_tables_NLSF_CB.h"
-
-const SKP_uint8 SKP_Silk_NLSF_MSVQ_CB1_16_CDF[ NLSF_MSVQ_CB1_16_VECTORS ] =
-{
-          192,
-          162,
-          146,
-          130,
-          116,
-          103,
-           92,
-           83,
-           75,
-           69,
-           63,
-           57,
-           51,
-           46,
-           40,
-           36,
-           32,
-           28,
-           25,
-           23,
-           21,
-           19,
-           17,
-           15,
-           13,
-           12,
-           10,
-            8,
-            6,
-            4,
-            2,
-            0,
-          118,
-           91,
-           64,
-           44,
-           32,
-           21,
-           10,
-            0,
-          128,
-          104,
-           81,
-           60,
-           41,
-           26,
-           12,
-            0,
-          134,
-          103,
-           82,
-           60,
-           42,
-           25,
-           12,
-            0,
-          103,
-           83,
-           64,
-           47,
-           32,
-           19,
-            8,
-            0,
-           97,
-           77,
-           59,
-           43,
-           29,
-           17,
-            8,
-            0,
-           96,
-           75,
-           58,
-           41,
-           29,
-           18,
-            9,
-            0,
-          110,
-           82,
-           55,
-           41,
-           28,
-           18,
-            9,
-            0,
-          197,
-          143,
-          101,
-           73,
-           50,
-           33,
-           16,
-            0,
-          169,
-          128,
-           99,
-           72,
-           47,
-           30,
-           13,
-            0
-};
-
-const SKP_uint8 * const SKP_Silk_NLSF_MSVQ_CB1_16_CDF_start_ptr[ NLSF_MSVQ_CB1_16_STAGES ] =
-{
-     &SKP_Silk_NLSF_MSVQ_CB1_16_CDF[   0 ],
-     &SKP_Silk_NLSF_MSVQ_CB1_16_CDF[  32 ],
-     &SKP_Silk_NLSF_MSVQ_CB1_16_CDF[  40 ],
-     &SKP_Silk_NLSF_MSVQ_CB1_16_CDF[  48 ],
-     &SKP_Silk_NLSF_MSVQ_CB1_16_CDF[  56 ],
-     &SKP_Silk_NLSF_MSVQ_CB1_16_CDF[  64 ],
-     &SKP_Silk_NLSF_MSVQ_CB1_16_CDF[  72 ],
-     &SKP_Silk_NLSF_MSVQ_CB1_16_CDF[  80 ],
-     &SKP_Silk_NLSF_MSVQ_CB1_16_CDF[  88 ],
-     &SKP_Silk_NLSF_MSVQ_CB1_16_CDF[  96 ]
-};
-
-const SKP_uint8 SKP_Silk_NLSF_MSVQ_CB1_16_rates_Q4[ NLSF_MSVQ_CB1_16_VECTORS ] =
-{
-               32,               50,
-               63,               65,
-               66,               70,
-               73,               77,
-               81,               85,
-               85,               88,
-               88,               89,
-               89,               93,
-               95,               98,
-              103,              113,
-              113,              113,
-              113,              113,
-              113,              113,
-              113,              113,
-              113,              113,
-              113,              113,
-               14,               52,
-               52,               58,
-               71,               73,
-               73,               74,
-               16,               55,
-               56,               58,
-               60,               65,
-               67,               71,
-               17,               49,
-               57,               57,
-               61,               63,
-               69,               70,
-               12,               60,
-               60,               62,
-               66,               70,
-               72,               80,
-               11,               59,
-               61,               64,
-               67,               72,
-               77,               79,
-               11,               58,
-               63,               63,
-               71,               73,
-               77,               78,
-               13,               51,
-               52,               67,
-               69,               76,
-               77,               77,
-               34,               36,
-               42,               51,
-               55,               63,
-               63,               64,
-               25,               42,
-               50,               52,
-               54,               62,
-               63,               69
-};
-
-const SKP_int SKP_Silk_NLSF_MSVQ_CB1_16_ndelta_min_Q15[ 16 + 1 ] =
-{
-              110,
-               27,
-              146,
-              128,
-               34,
-               27,
-               32,
-               23,
-               31,
-               25,
-               32,
-               25,
-               23,
-               24,
-               29,
-                4,
-              653
-};
-
-const SKP_int8 SKP_Silk_NLSF_MSVQ_CB1_16_Q8[ 16 * NLSF_MSVQ_CB1_16_VECTORS ] =
-{
-             -118,             -106,              -90,              -74,
-              -59,              -44,              -28,              -13,
-                2,               18,               33,               48,
-               64,               79,               95,              110,
-             -118,             -108,              -94,              -78,
-              -65,              -51,              -35,              -19,
-               -4,               12,               28,               44,
-               60,               77,               93,              107,
-             -118,             -111,             -100,              -88,
-              -74,              -57,              -41,              -27,
-               -9,                9,               26,               42,
-               60,               77,               94,              109,
-             -113,             -100,              -86,              -69,
-              -54,              -39,              -24,               -8,
-                6,               21,               36,               51,
-               66,               82,               97,              111,
-             -119,             -113,              -99,              -85,
-              -67,              -50,              -33,              -17,
-                1,               16,               32,               48,
-               64,               79,               95,              110,
-             -119,             -111,              -95,              -81,
-              -68,              -53,              -36,              -21,
-               -6,                9,               27,               40,
-               57,               71,               86,               97,
-             -117,             -106,              -90,              -77,
-              -63,              -49,              -30,              -16,
-               -2,               10,               26,               38,
-               51,               64,               81,               90,
-             -114,             -103,              -88,              -71,
-              -57,              -44,              -31,              -19,
-               -3,               11,               26,               40,
-               55,               71,               89,              106,
-             -113,             -101,              -84,              -67,
-              -50,              -34,              -18,               -1,
-               16,               31,               46,               59,
-               71,               84,               99,              113,
-             -117,             -110,              -95,              -81,
-              -70,              -56,              -43,              -27,
-              -16,               -4,               14,               38,
-               58,               75,               92,              109,
-             -110,              -97,              -79,              -62,
-              -44,              -26,               -8,                9,
-               24,               38,               50,               62,
-               74,               87,              100,              112,
-             -112,              -96,              -75,              -58,
-              -43,              -29,              -18,               -6,
-                7,               19,               34,               46,
-               61,               76,               92,              107,
-             -110,              -94,              -75,              -57,
-              -38,              -22,               -7,                2,
-               15,               28,               40,               51,
-               65,               80,               95,              110,
-             -116,             -108,              -96,              -80,
-              -67,              -54,              -40,              -26,
-               -9,                5,               19,               33,
-               48,               66,               88,              108,
-             -118,             -106,              -86,              -68,
-              -48,              -31,              -14,               -1,
-               14,               26,               39,               50,
-               65,               80,               95,              109,
-             -119,             -112,             -102,              -86,
-              -56,              -42,              -29,              -19,
-               -3,               10,               26,               40,
-               56,               72,               90,              107,
-             -117,             -110,              -99,              -88,
-              -78,              -67,              -46,              -20,
-               -5,               10,               27,               43,
-               60,               77,               93,              110,
-             -118,             -108,              -92,              -75,
-              -58,              -44,              -28,               -9,
-               10,               26,               41,               57,
-               70,               81,               95,              108,
-             -118,             -107,              -87,              -71,
-              -51,              -35,              -18,               -6,
-                7,               19,               34,               44,
-               58,               68,               83,               93,
-             -116,              -96,              -75,              -61,
-              -58,              -49,              -29,                2,
-               16,               19,               32,               54,
-               72,               86,               97,              112,
-             -113,             -101,              -84,              -70,
-              -57,              -41,              -42,              -28,
-              -14,               -8,                8,               19,
-               38,               69,               87,              106,
-             -114,             -104,              -90,              -74,
-              -58,              -45,              -31,              -19,
-               -5,                7,               17,               28,
-               40,               52,               67,              102,
-             -109,              -95,              -77,              -62,
-              -51,              -39,              -24,              -12,
-                1,               10,               23,               35,
-               50,               65,               81,               94,
-             -115,              -95,              -81,              -69,
-              -49,              -27,              -21,              -16,
-               -1,               25,               52,               50,
-               51,               79,               98,              113,
-             -115,              -96,              -81,              -67,
-              -50,              -28,               -9,               -2,
-                9,               15,               34,               52,
-               65,               80,               96,              111,
-             -115,              -95,              -77,              -57,
-              -39,              -29,              -32,              -23,
-                2,               17,               34,               49,
-               66,               81,               96,              110,
-             -117,              -97,              -85,              -74,
-              -52,              -36,              -15,                1,
-               33,               39,               39,               36,
-               56,               80,               94,              110,
-             -112,              -96,              -81,              -65,
-              -52,              -39,              -22,               -8,
-                9,               23,               42,               60,
-               87,               99,              100,              100,
-             -114,              -99,              -80,              -67,
-              -52,              -37,              -19,               -3,
-               10,               29,               54,               63,
-               65,               76,              111,              111,
-             -113,              -96,              -79,              -64,
-              -51,              -37,              -22,               -8,
-               11,               25,               41,               60,
-               78,               99,              118,              119,
-             -112,              -95,              -77,              -59,
-              -48,              -39,              -23,               -8,
-               13,               41,               43,               41,
-               48,               78,               98,              112,
-             -117,             -102,              -82,              -66,
-              -50,              -34,              -16,                0,
-               18,               35,               38,               62,
-               74,               95,              101,              111,
-               -1,               -1,                0,                0,
-                1,                1,                1,                1,
-                2,                2,                2,                1,
-                1,                1,                1,                0,
-                1,                2,                1,               -1,
-               -2,               -2,               -2,               -5,
-               -4,               -3,               -4,               -4,
-               -6,               -4,               -2,                0,
-                0,                0,                2,                7,
-                5,                3,                1,               -2,
-               -5,               -5,               -6,               -4,
-                0,                1,                1,                1,
-                8,                8,                6,                1,
-               -1,               -2,               -2,                0,
-                1,                0,                0,                0,
-                1,                1,                1,                1,
-                1,                1,               -1,               -3,
-               -4,               -7,               -2,                1,
-               -7,               -2,                2,                3,
-                3,                3,                1,                2,
-                1,                0,               -3,               -8,
-              -11,               -1,                0,                3,
-                0,               -2,               -3,               -2,
-               -4,               -2,               -4,               -2,
-                0,                1,                0,               -2,
-               -3,               -1,                0,                1,
-                5,                2,                0,                0,
-               -1,               -5,               -6,               -6,
-               -2,               -5,               -9,               -1,
-                2,               -2,               -4,               -1,
-               -2,               -3,                2,                3,
-                3,               -2,               -1,                0,
-                0,                0,                0,                0,
-               -1,               -1,               -1,               -1,
-               -1,               -1,                0,                0,
-                0,                0,                0,                0,
-               -3,               -7,                1,                3,
-                2,                1,                2,                2,
-                4,                2,                2,                2,
-                2,                1,                1,                2,
-                2,                2,                0,               -2,
-               -3,               -5,               -4,               -5,
-               -1,                0,               -2,               -2,
-               -2,               -1,                1,                0,
-                0,               -2,               -5,               -7,
-                2,                0,                0,                2,
-               -1,                0,                1,                1,
-                2,                3,                3,                3,
-                6,                5,                4,                2,
-                2,                2,               -1,               -1,
-               -2,               -1,               -1,                0,
-               -1,               -3,               -4,               -5,
-               -4,                7,                4,                4,
-                2,                3,                4,                5,
-                3,                4,                4,                4,
-                3,                0,                0,                2,
-                0,               -1,                0,                2,
-                5,                4,                3,                3,
-                2,               -1,               -5,               -9,
-               -6,               -1,               -2,               -1,
-                0,               -2,               -3,               -1,
-               -1,                7,                5,                4,
-                4,                4,                1,                1,
-                1,                0,               -3,               -3,
-               -1,                1,                0,                0,
-                0,                0,                0,                0,
-                0,                0,                0,                0,
-                0,                0,                0,                0,
-                0,               -1,                1,                4,
-                3,                3,                5,                3,
-                1,                1,                0,                0,
-                0,                0,                0,                0,
-               -3,               -5,               -3,               -4,
-               -1,                0,                0,                0,
-               -1,                0,                0,               -1,
-               -1,                0,               -1,               -2,
-                1,                1,                2,                1,
-                0,               -4,               -4,               -5,
-               -4,                0,                0,                1,
-                0,               -1,                0,                1,
-                0,                0,                0,               -1,
-               -2,               -1,                1,                3,
-                4,                3,                5,                4,
-                2,                0,                0,               -1,
-                6,                4,                3,               -1,
-               -2,               -1,               -1,               -2,
-                0,               -2,                0,                0,
-                0,               -1,                0,                1,
-                0,               -2,                0,               -1,
-               -1,               -1,               -8,                0,
-               -2,               -1,                0,                1,
-               -1,                2,                0,                1,
-                1,                0,               -1,                0,
-               -1,                3,                2,                1,
-                2,               -3,               -7,               -7,
-                0,                0,                1,                0,
-                0,                0,               -1,                0,
-                0,                0,                0,                0,
-                0,                0,                0,                0,
-                0,                0,                0,                0,
-                1,                1,                1,               -1,
-               -2,                0,                0,                1,
-               -1,                0,                2,                3,
-                5,                5,                4,                2,
-                1,                1,                2,                0,
-                0,                4,                4,                1,
-               -2,               -5,               -2,               -1,
-                0,               -1,                0,                0,
-                0,               -1,               -3,                2,
-                0,               -2,               -4,               -6,
-                4,                0,                0,                0,
-                0,                1,                0,                0,
-               -1,               -1,                7,                0,
-                0,               -1,                0,                1,
-               -1,                0,                0,                0,
-               -2,               -2,               -1,                0,
-               -1,                0,                0,                0,
-                0,                0,                3,                2,
-                0,                1,               -1,               -3,
-               -5,               -3,                0,                1,
-                0,                1,                1,                2,
-                2,               -1,                1,                0,
-                2,                4,                5,                0,
-               -1,               -2,               -5,               -3,
-                1,                1,               -2,               -5,
-                1,               -1,               -5,                1,
-               -1,                1,                0,                0,
-               -2,               -2,               -2,               -2,
-                0,                0,                0,               -1,
-               -1,                0,                0,                0,
-                0,                0,                0,                0,
-                0,                0,                0,                0,
-                1,               -1,                2,                2,
-                0,                0,                0,                1,
-                0,                0,                0,                1,
-                4,                3,                0,                0,
-                0,                0,               -2,               -2,
-                4,                4,               -1,               -3,
-                0,                0,                0,                0,
-                0,               -1,               -1,                0,
-                0,               -2,               -4,                5,
-                1,                0,               -1,                1,
-                0,                0,                0,                0,
-               -3,               -1,               -2,               -1,
-                0,                0,                0,                1,
-                1,               -3,                6,                0,
-                0,                0,               -4,                0,
-                0,               -1,               -1,               -1,
-                1,                1,                1,                2,
-                1,                0,               -3,                0,
-                0,               -4,                2,                2,
-               -1,               -1,                5,                2,
-                0,               -1,               -1,                1,
-                1,               -2,               -2,               -2,
-               -6,                5,                2,               -2,
-                1,                0,                0,               -1,
-                0,                1,                2,                1,
-                2,                0,               -1,                2,
-                6,                4,                2,               -2,
-               -2,                0,                1,                1,
-                0,               -1,               -1,                0,
-                0,                0,                0,                0,
-                0,                0,                0,                0,
-                0,                0,                0,                0,
-                0,                1,                1,                0,
-                0,                0,                0,               -1,
-                2,                0,                0,               -1,
-               -1,                1,                0,               -5,
-                1,                1,                2,                2,
-                0,                0,               -1,                5,
-                0,                0,               -1,                0,
-                0,                0,                0,                1,
-                0,                1,                0,                0,
-                0,               -3,                3,                0,
-                0,                0,               -1,               -2,
-                0,                2,                4,                4,
-                0,                0,                1,                0,
-                0,                0,                1,               -1,
-                0,               -2,               -3,                5,
-                0,               -1,               -4,               -1,
-                1,                2,                2,                1,
-                3,                0,               -3,               -3,
-               -1,                0,                1,               -3,
-                0,                1,               -1,                1,
-                1,                0,                1,               -1,
-               -4,                5,                0,               -1,
-                1,                1,                2,               -2,
-                0,               -2,                0,                1,
-                1,                1,                0,                0,
-                0,                0,                0,                0,
-               -1,                2,                2,                3,
-               -1,               -5,                1,                2,
-                0,                1,                1,                1,
-                1,                1,                0,                0,
-                0,                0,                0,                0,
-                0,                0,                0,                0,
-                0,               -1,                1,                1,
-               -3,               -2,               -1,                1,
-               -1,                0,               -1,                0,
-                0,                0,                0,                0,
-                1,               -1,               -2,               -3,
-                0,               -1,                0,                0,
-               -1,                1,               -3,                0,
-                0,                0,                0,                1,
-                1,                0,               -3,               -1,
-               -1,               -1,                2,                0,
-                2,                2,                2,               -2,
-                0,                0,                0,                0,
-                0,                0,               -1,               -1,
-                0,               -1,                0,                0,
-                0,               -4,                4,                0,
-                0,                0,               -2,                0,
-                0,               -1,                0,               -1,
-                0,                0,                0,                0,
-                1,                1,                2,                0,
-               -5,                1,                3,                1,
-               -2,               -1,                0,               -2,
-               -2,                0,                0,               -1,
-                2,                0,                1,                0,
-                0,               -3,               -1,               -1,
-                0,                1,               -1,               -1,
-                0,               -1,               -2,               -1,
-                1,                2,                1,                0,
-                5,                4,               -2,               -1,
-                0,                0,                0,                0,
-                0,                0,                0,                0,
-                0,                0,               -1,               -1,
-               -2,               -2,               -1,               -1,
-               -3,                2,                0,                0,
-                0,                0,                0,                0,
-                0,                0,                0,                0,
-                0,                0,                0,                1,
-               -1,               -3,                0,                0,
-                0,                0,                0,                0,
-               -1,                0,                0,                1,
-                1,                0,                0,                0,
-                1,                0,                0,                0,
-                0,               -1,                1,                1,
-                2,               -2,               -1,               -1,
-                1,                1,                1,                0,
-                2,                1,                2,                0,
-                0,                1,                0,               -1,
-               -2,                2,                1,                1,
-                1,                0,                0,                0,
-                1,                0,               -3,                2,
-                0,                0,               -2,                0,
-                0,                0,                0,                0,
-                4,                0,                1,                0,
-                1,                0,               -1,                0,
-                0,                0,                0,                0,
-               -1,               -1,                1,                0,
-               -2,                4,                0,                0,
-                0,                0,                1,               -2,
-                0,                0,                0,                0,
-                2,                2,                2,                1,
-                0,                0,                0,                1,
-               -1,               -1,                1,               -1,
-                0,                0,               -1,                1,
-                0,               -1,                0,                0,
-                0,                0,                0,                0,
-                0,                0,                0,                1,
-               -2,                0,                1,               -2,
-                0,                0,                0,                0,
-                0,                0,                0,                1,
-                1,                2,               -1,               -1,
-                0,                0,                1,                1,
-               -1,               -1,                0,                1,
-                0,                0,               -1,               -1,
-                0,                0,               -1,                1,
-                3,               -2,                0,                0,
-                0,                0,                0,                0,
-                0,                0,                0,                0,
-               -1,                0,               -1,                0,
-                0,                3,                1,                1,
-                1,                1,                0,                1,
-                0,                1,                0,                0,
-                0,                0,                0,                0,
-                0,               -1,                0,                0,
-                1,                3,                0,                1,
-                0,                0,                3,               -1,
-                0,                0,                0,                0,
-                1,                0,                0,                0,
-                0,                0,               -1,               -5,
-                0,               -1,                0,                0,
-                2,               -1,                1,                0,
-                0,                0,                0,               -1,
-               -1,                1,                0,                1,
-                0,               -1,               -1,                0
-};
-
-const SKP_Silk_NLSF_CBS SKP_Silk_NLSF_CB1_16_Stage_info[ NLSF_MSVQ_CB1_16_STAGES ] =
-{
-        {  32, &SKP_Silk_NLSF_MSVQ_CB1_16_Q8[ 16 *   0 ], &SKP_Silk_NLSF_MSVQ_CB1_16_rates_Q4[   0 ] },
-        {   8, &SKP_Silk_NLSF_MSVQ_CB1_16_Q8[ 16 *  32 ], &SKP_Silk_NLSF_MSVQ_CB1_16_rates_Q4[  32 ] },
-        {   8, &SKP_Silk_NLSF_MSVQ_CB1_16_Q8[ 16 *  40 ], &SKP_Silk_NLSF_MSVQ_CB1_16_rates_Q4[  40 ] },
-        {   8, &SKP_Silk_NLSF_MSVQ_CB1_16_Q8[ 16 *  48 ], &SKP_Silk_NLSF_MSVQ_CB1_16_rates_Q4[  48 ] },
-        {   8, &SKP_Silk_NLSF_MSVQ_CB1_16_Q8[ 16 *  56 ], &SKP_Silk_NLSF_MSVQ_CB1_16_rates_Q4[  56 ] },
-        {   8, &SKP_Silk_NLSF_MSVQ_CB1_16_Q8[ 16 *  64 ], &SKP_Silk_NLSF_MSVQ_CB1_16_rates_Q4[  64 ] },
-        {   8, &SKP_Silk_NLSF_MSVQ_CB1_16_Q8[ 16 *  72 ], &SKP_Silk_NLSF_MSVQ_CB1_16_rates_Q4[  72 ] },
-        {   8, &SKP_Silk_NLSF_MSVQ_CB1_16_Q8[ 16 *  80 ], &SKP_Silk_NLSF_MSVQ_CB1_16_rates_Q4[  80 ] },
-        {   8, &SKP_Silk_NLSF_MSVQ_CB1_16_Q8[ 16 *  88 ], &SKP_Silk_NLSF_MSVQ_CB1_16_rates_Q4[  88 ] },
-        {   8, &SKP_Silk_NLSF_MSVQ_CB1_16_Q8[ 16 *  96 ], &SKP_Silk_NLSF_MSVQ_CB1_16_rates_Q4[  96 ] }
-};
-
-const SKP_Silk_NLSF_CB_struct SKP_Silk_NLSF_CB1_16 =
-{
-        NLSF_MSVQ_CB1_16_STAGES,
-        SKP_Silk_NLSF_CB1_16_Stage_info,
-        SKP_Silk_NLSF_MSVQ_CB1_16_ndelta_min_Q15,
-        SKP_Silk_NLSF_MSVQ_CB1_16_CDF_start_ptr
-};
-
--- a/src_common/SKP_Silk_tables_other.c
+++ b/src_common/SKP_Silk_tables_other.c
@@ -48,39 +48,33 @@
     19,     29,     35,     39,     44,     50,     60,     80
 };
 
-/* Decoder high-pass filter coefficients, -6 dB @ 50 Hz, 0.05 dB ripple */
-const SKP_int32 SKP_Silk_Dec_A_HP_16[ DEC_HP_ORDER ]     = {-527234079,  258986528};            /* second order AR coefs, Q28 */
-const SKP_int32 SKP_Silk_Dec_B_HP_16[ DEC_HP_ORDER + 1 ] = { 263603618, -527207236, 263603618}; /* second order MA coefs, Q28 */
+/* Table for stereo predictor coding */
+/* p = [2.^(-7:-1), 1, fliplr(2.^(-7:-1))]+2e-2; p = p/sum(p); fprintf('%d, ', round(256 - 256 * cumsum(p(1:end-1)))) */
+const SKP_uint8 SKP_Silk_stereo_predictor_iCDF[ STEREO_QUANT_STEPS + 1 ] = { 254, 251, 247, 241, 229, 208, 168, 88, 48, 27, 15, 9, 5, 2 };
 
-const SKP_int32 SKP_Silk_Dec_A_HP_12[ DEC_HP_ORDER ]     = {-524058488,  255953207};            /* second order AR coefs, Q28 */
-const SKP_int32 SKP_Silk_Dec_B_HP_12[ DEC_HP_ORDER + 1 ] = { 261993005, -523986010, 261993005}; /* second order MA coefs, Q28 */
-
-const SKP_int32 SKP_Silk_Dec_A_HP_8[ DEC_HP_ORDER   ]    = {-517610668,  249913410};            /* second order AR coefs, Q28 */
-const SKP_int32 SKP_Silk_Dec_B_HP_8[ DEC_HP_ORDER + 1 ]  = { 258905997, -517811995, 258905997}; /* second order MA coefs, Q28 */
-
-/* tables for LBRR flags */
+/* Tables for LBRR flags */
 const SKP_uint8 SKP_Silk_LBRR_flags_2_iCDF[ 3 ] = { 203, 150, 0 };
 const SKP_uint8 SKP_Silk_LBRR_flags_3_iCDF[ 7 ] = { 215, 195, 166, 125, 110, 82, 0 };
-const SKP_uint8 * const SKP_Silk_LBRR_flags_iCDF_ptr[2] = {
+const SKP_uint8 * const SKP_Silk_LBRR_flags_iCDF_ptr[ 2 ] = {
     SKP_Silk_LBRR_flags_2_iCDF,
     SKP_Silk_LBRR_flags_3_iCDF
 };
 
-/* table for LSB coding */
+/* Table for LSB coding */
 const SKP_uint8 SKP_Silk_lsb_iCDF[ 2 ] = { 120, 0 };
 
-/* tables for LTPScale */
+/* Tables for LTPScale */
 const SKP_uint8 SKP_Silk_LTPscale_iCDF[ 3 ] = { 128, 64, 0 };
 
-/* tables for signal type and offset coding */
-const SKP_uint8 SKP_Silk_type_offset_VAD_iCDF[4] = {
+/* Tables for signal type and offset coding */
+const SKP_uint8 SKP_Silk_type_offset_VAD_iCDF[ 4 ] = {
 	   232,    158,    10,      0
 };
-const SKP_uint8 SKP_Silk_type_offset_no_VAD_iCDF[2] = {
+const SKP_uint8 SKP_Silk_type_offset_no_VAD_iCDF[ 2 ] = {
 	   230,      0
 };
 
-/* tables for NLSF interpolation factor */
+/* Tables for NLSF interpolation factor */
 const SKP_uint8 SKP_Silk_NLSF_interpolation_factor_iCDF[ 5 ] = { 243, 221, 192, 181, 0 };
 
 /* Quantization offsets */
@@ -99,7 +93,6 @@
 
 const SKP_uint8 SKP_Silk_NLSF_EXT_iCDF[ 7 ] = { 100, 40, 16, 7, 3, 1, 0 };
 
-#if SWITCH_TRANSITION_FILTERING
 /*  Elliptic/Cauer filters designed with 0.1 dB passband ripple, 
         80 dB minimum stopband attenuation, and
         [0.95 : 0.15 : 0.35] normalized cut off frequencies. */
@@ -123,7 +116,6 @@
 {    185807084,   77959395  },
 {     35497197,   57401098  }
 };
-#endif
 
 #ifdef __cplusplus
 }
--- a/src_common/SKP_Silk_tuning_parameters.h
+++ b/src_common/SKP_Silk_tuning_parameters.h
@@ -82,7 +82,7 @@
 /***********/
 
 /* VAD threshold */
-#define SPEECH_ACTIVITY_DTX_THRES                       0.2f
+#define SPEECH_ACTIVITY_DTX_THRES                       0.05f
 
 /* Speech Activity LBRR enable threshold */
 #define LBRR_SPEECH_ACTIVITY_THRES                      0.3f
--- a/src_common/src_common.vcxproj
+++ b/src_common/src_common.vcxproj
@@ -74,18 +74,22 @@
     <None Include="ReadMe.txt" />
   </ItemGroup>
   <ItemGroup>
+    <ClInclude Include="..\interface\SKP_Silk_control.h" />
+    <ClInclude Include="..\interface\SKP_Silk_errors.h" />
     <ClInclude Include="SKP_Silk_define.h" />
     <ClInclude Include="SKP_Silk_main.h" />
     <ClInclude Include="SKP_Silk_PLC.h" />
-    <ClInclude Include="SKP_Silk_setup.h" />
     <ClInclude Include="SKP_Silk_structs.h" />
     <ClInclude Include="SKP_Silk_tables.h" />
     <ClInclude Include="SKP_Silk_tuning_parameters.h" />
   </ItemGroup>
   <ItemGroup>
+    <ClCompile Include="SKP_Silk_check_control_input.c" />
     <ClCompile Include="SKP_Silk_CNG.c" />
     <ClCompile Include="SKP_Silk_code_signs.c" />
     <ClCompile Include="SKP_Silk_control_audio_bandwidth.c" />
+    <ClCompile Include="SKP_Silk_control_codec.c" />
+    <ClCompile Include="SKP_Silk_control_SNR.c" />
     <ClCompile Include="SKP_Silk_create_init_destroy.c" />
     <ClCompile Include="SKP_Silk_decoder_set_fs.c" />
     <ClCompile Include="SKP_Silk_decode_core.c" />
@@ -99,8 +103,8 @@
     <ClCompile Include="SKP_Silk_enc_API.c" />
     <ClCompile Include="SKP_Silk_gain_quant.c" />
     <ClCompile Include="SKP_Silk_HP_variable_cutoff.c" />
+    <ClCompile Include="SKP_Silk_init_encoder.c" />
     <ClCompile Include="SKP_Silk_interpolate.c" />
-    <ClCompile Include="SKP_Silk_LBRR_embed.c" />
     <ClCompile Include="SKP_Silk_LP_variable_cutoff.c" />
     <ClCompile Include="SKP_Silk_NLSF2A_stable.c" />
     <ClCompile Include="SKP_Silk_NLSF_decode.c" />
@@ -114,6 +118,8 @@
     <ClCompile Include="SKP_Silk_process_NLSFs.c" />
     <ClCompile Include="SKP_Silk_quant_LTP_gains.c" />
     <ClCompile Include="SKP_Silk_shell_coder.c" />
+    <ClCompile Include="SKP_Silk_stereo_LR_to_MS.c" />
+    <ClCompile Include="SKP_Silk_stereo_MS_to_LR.c" />
     <ClCompile Include="SKP_Silk_tables_gain.c" />
     <ClCompile Include="SKP_Silk_tables_LTP.c" />
     <ClCompile Include="SKP_Silk_tables_NLSF_CB_NB_MB.c" />
--- a/src_common/src_common.vcxproj.filters
+++ b/src_common/src_common.vcxproj.filters
@@ -36,9 +36,12 @@
     <ClInclude Include="SKP_Silk_tuning_parameters.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="SKP_Silk_setup.h">
+    <ClInclude Include="..\interface\SKP_Silk_control.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="..\interface\SKP_Silk_errors.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="SKP_Silk_CNG.c">
@@ -131,9 +134,6 @@
     <ClCompile Include="SKP_Silk_encode_indices.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="SKP_Silk_LBRR_embed.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="SKP_Silk_process_NLSFs.c">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -159,6 +159,24 @@
       <Filter>Source Files</Filter>
     </ClCompile>
     <ClCompile Include="SKP_Silk_NLSF_del_dec_quant.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="SKP_Silk_control_SNR.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="SKP_Silk_control_codec.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="SKP_Silk_check_control_input.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="SKP_Silk_init_encoder.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="SKP_Silk_stereo_LR_to_MS.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="SKP_Silk_stereo_MS_to_LR.c">
       <Filter>Source Files</Filter>
     </ClCompile>
   </ItemGroup>
--- a/test/Decoder.c
+++ /dev/null
@@ -1,453 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. 
-Redistribution and use in source and binary forms, with or without 
-modification, (subject to the limitations in the disclaimer below) 
-are permitted provided that the following conditions are met:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright 
-notice, this list of conditions and the following disclaimer in the 
-documentation and/or other materials provided with the distribution.
-- Neither the name of Skype Limited, nor the names of specific 
-contributors, may be used to endorse or promote products derived from 
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-***********************************************************************/
-
-
-/*****************************/
-/* Silk decoder test program */
-/*****************************/
-
-#ifdef _WIN32
-#define _CRT_SECURE_NO_DEPRECATE    1
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif 
-
-#include "SKP_Silk_SDK_API.h"
-#include "../src_SigProc_FIX/SKP_Silk_SigProc_FIX.h"
-
-/* Define codec specific settings should be moved to h file */
-#define MAX_BYTES_PER_FRAME     1024
-#define MAX_INPUT_FRAMES        5
-#define MAX_FRAME_LENGTH        480
-#define MAX_FRAME_LENGTH_MS     20
-#define MAX_API_FS_KHZ          48
-#define MAX_LBRR_DELAY          0
-
-#ifdef _SYSTEM_IS_BIG_ENDIAN
-/* Function to convert a little endian int16 to a */
-/* big endian int16 or vica verca                 */
-void swap_endian(
-    SKP_int16       vec[],
-    SKP_int         len
-)
-{
-    SKP_int i;
-    SKP_int16 tmp;
-    SKP_uint8 *p1, *p2;
-
-    for( i = 0; i < len; i++ ){
-        tmp = vec[ i ];
-        p1 = (SKP_uint8 *)&vec[ i ]; p2 = (SKP_uint8 *)&tmp;
-        p1[ 0 ] = p2[ 1 ]; p1[ 1 ] = p2[ 0 ];
-    }
-}
-#endif
-
-static void print_usage(char* argv[]) {
-    printf( "\nusage: %s in.bit out.pcm [settings]\n", argv[ 0 ] );
-    printf( "\nin.bit       : Bitstream input to decoder" );
-    printf( "\nout.pcm      : Speech output from decoder" );
-    printf( "\n   settings:" );
-    printf( "\n-Fs_API <Hz>       : Sampling rate of output signal in Hz" );
-    printf( "\n-Fs_Internal <Hz>  : Internal sampling rate in Hz, default" ); 
-    printf( "\n-packetlength <ms> : Packet interval in ms, default" );
-    printf( "\n-loss <perc> : Simulated packet loss percentage (0-100); default: 0" );
-    printf( "\n" );
-}
-
-#ifdef SKP_MACRO_COUNT
-    varDefine /* Define and reset global counters */
-#endif
-
-int main( int argc, char* argv[] )
-{
-    double    filetime;
-    size_t    counter;
-    SKP_int32 args, totPackets, i, k, ret, len, tot_len, nBytes;
-    SKP_uint8 payload[    MAX_BYTES_PER_FRAME * MAX_INPUT_FRAMES * ( MAX_LBRR_DELAY + 1 ) ];
-    SKP_uint8 *payloadEnd = NULL, *payloadToDec = NULL;
-#if 0
-    SKP_uint8 FECpayload[ MAX_BYTES_PER_FRAME * MAX_INPUT_FRAMES ];
-    SKP_int32 nBytesFEC;
-#endif
-    SKP_uint8 *payloadPtr;
-    SKP_int16 nBytesPerPacket[ MAX_LBRR_DELAY + 1 ], totBytes;
-    SKP_int16 out[ ( ( MAX_FRAME_LENGTH_MS * MAX_API_FS_KHZ ) << 1 ) * MAX_INPUT_FRAMES ], *outPtr;
-    char      speechOutFileName[ 150 ], bitInFileName[ 150 ];
-    FILE      *bitInFile, *speechOutFile;
-    SKP_int32 API_Fs_Hz = 0, packetSize_ms=0;
-    SKP_int32 decSizeBytes;
-    void      *psDec;
-#ifdef SKP_MACRO_COUNT
-    SKP_int64  Ops, maxOps = 0, totOps = 0;
-#endif
-    float     loss_prob;
-    SKP_int32 frames, lost, quiet;
-    SKP_SILK_SDK_DecControlStruct DecControl;
-    ec_dec         range_dec_celt_state;
-
-    if( argc < 3 ) {
-        print_usage( argv );
-        exit( 0 );
-    } 
-
-    /* default settings */
-    quiet     = 0;
-    loss_prob = 0.0f;
-
-    /* get arguments */
-    args = 1;
-    strcpy( bitInFileName, argv[ args ] );
-    args++;
-    strcpy( speechOutFileName, argv[ args ] );
-    args++;
-    while( args < argc ) {
-        if( SKP_STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-loss" ) == 0 ) {
-            sscanf( argv[ args + 1 ], "%f", &loss_prob );
-            args += 2;
-        } else if( SKP_STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-Fs_API" ) == 0 ) {
-            sscanf( argv[ args + 1 ], "%d", &API_Fs_Hz );
-            args += 2;
-        } else if( SKP_STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-Fs_Internal" ) == 0 ) {
-            sscanf( argv[ args + 1 ], "%d", &DecControl.internalSampleRate );
-            args += 2;
-        } else if( SKP_STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-packetlength" ) == 0 ) {
-            sscanf( argv[ args + 1 ], "%d", &DecControl.payloadSize_ms );
-            args += 2;
-        } else if( SKP_STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-quiet" ) == 0 ) {
-            quiet = 1;
-            args++;
-        } else {
-            printf( "Error: unrecognized setting: %s\n\n", argv[ args ] );
-            print_usage( argv );
-            exit( 0 );
-        }
-    }
-
-    if( !quiet ) {
-        printf("******************* Compiled for %d bit cpu ********* \n", (int)sizeof(void*) * 8 );
-        printf( "Input:                       %s\n", bitInFileName );
-        printf( "Output:                      %s\n", speechOutFileName );
-    }
-
-    /* Open files */
-    bitInFile = fopen( bitInFileName, "rb" );
-    if( bitInFile == NULL ) {
-        printf( "Error: could not open input file %s\n", bitInFileName );
-        exit( 0 );
-    } 
-    speechOutFile = fopen( speechOutFileName, "wb" );
-    if( speechOutFile == NULL ) {
-        printf( "Error: could not open output file %s\n", speechOutFileName );
-        exit( 0 );
-    }
-
-    /* Set the samplingrate that is requested for the output */
-    if( API_Fs_Hz == 0 ) {
-        DecControl.API_sampleRate = 24000;
-    } else {
-        DecControl.API_sampleRate = API_Fs_Hz;
-    }
-
-    /* Create decoder */
-    ret = SKP_Silk_SDK_Get_Decoder_Size( &decSizeBytes );
-    if( ret ) {
-        printf( "\nSKP_Silk_SDK_Get_Decoder_Size returned %d", ret );
-    }
-    psDec = malloc( decSizeBytes );
-
-    /* Reset decoder */
-    ret = SKP_Silk_SDK_InitDecoder( psDec );
-    if( ret ) {
-        printf( "\nSKP_Silk_InitDecoder returned %d", ret );
-    }
-
-    totPackets = 0;
-    payloadEnd = payload;
-
-    /* Simulate the jitter buffer holding MAX_FEC_DELAY packets */
-    for( i = 0; i < MAX_LBRR_DELAY; i++ ) {
-        /* Read payload size */
-        counter = fread( &nBytes, sizeof( SKP_int32 ), 1, bitInFile );
-#ifdef _SYSTEM_IS_BIG_ENDIAN
-        swap_endian( &nBytes, 1 );
-#endif
-        /* Read payload */
-        counter = fread( payloadEnd, sizeof( SKP_uint8 ), nBytes, bitInFile );
-
-        if( ( SKP_int16 )counter < nBytes ) {
-            break;
-        }
-        nBytesPerPacket[ i ] = nBytes;
-        payloadEnd          += nBytes;
-    }
-
-    while( 1 ) {
-        /* Read payload size */
-        counter = fread( &nBytes, sizeof( SKP_int32 ), 1, bitInFile );
-#ifdef _SYSTEM_IS_BIG_ENDIAN
-        swap_endian( &nBytes, 1 );
-#endif
-        if( nBytes < 0 || counter < 1 ) {
-            break;
-        }
-        
-        /* Read payload */
-        counter = fread( payloadEnd, sizeof( SKP_uint8 ), nBytes, bitInFile );
-        if( ( SKP_int16 )counter < nBytes ) {
-            break;
-        }
-
-        /* Initialize range decoder state */
-        ec_dec_init( &range_dec_celt_state, payloadEnd, nBytes );
-
-        /* Simulate losses */
-        if( ( (float)rand() / (float)RAND_MAX >= loss_prob / 100 ) && counter > 0 ) {
-            nBytesPerPacket[ MAX_LBRR_DELAY ] = nBytes;
-            payloadEnd                       += nBytes;
-        } else {
-            nBytesPerPacket[ MAX_LBRR_DELAY ] = 0;
-        }
-
-        if( nBytesPerPacket[ 0 ] == 0 ) {
-            /* Indicate lost packet */
-            lost = 1;
-
-            /* Packet loss. Search after FEC in next packets. Should be done in the jitter buffer */
-            payloadPtr = payload;
-            for( i = 0; i < MAX_LBRR_DELAY; i++ ) {
-                if( nBytesPerPacket[ i + 1 ] > 0 ) {
-#if 0
-                    SKP_Silk_SDK_search_for_LBRR( payloadPtr, nBytesPerPacket[ i + 1 ], i + 1, FECpayload, &nBytesFEC );
-                    if( nBytesFEC > 0 ) {
-                        payloadToDec = FECpayload;
-                        nBytes = nBytesFEC;
-                        lost = 0;
-                        break;
-                    }
-#endif
-                }
-                payloadPtr += nBytesPerPacket[ i + 1 ];
-            }
-        } else {
-            lost = 0;
-            nBytes = nBytesPerPacket[ 0 ];
-            payloadToDec = payload;
-        }
-
-        /* Silk decoder */
-        outPtr = out;
-        tot_len = 0;
-
-        if( lost == 0 ) {
-            /* No Loss: Decode all frames in the packet */
-            frames = 0;
-            do {
-                /* Decode 20 ms */
-                ret = SKP_Silk_SDK_Decode( psDec, &DecControl, 0, frames == 0, &range_dec_celt_state, nBytes, outPtr, &len );
-                if( ret ) {
-                    printf( "\nSKP_Silk_SDK_Decode returned %d", ret );
-                }
-#ifdef SKP_MACRO_COUNT
-                Ops = SKP_SaveResetCount();
-                if( Ops > maxOps ){ maxOps = Ops; }
-                totOps += Ops;
-#endif
-                frames++;
-                outPtr  += len;
-                tot_len += len;
-                if( frames > MAX_INPUT_FRAMES ) {
-                    /* Hack for corrupt stream that could generate too many frames */
-                    outPtr  = out;
-                    tot_len = 0;
-                    frames  = 0;
-                }
-                /* Until last 20 ms frame of packet has been decoded */
-            } while( frames < DecControl.framesPerPayload ); 
-        } else {    
-            /* Loss: Decode enough frames to cover one packet duration */
-            for( i = 0; i < DecControl.framesPerPayload; i++ ) {
-                /* Generate 20 ms */
-                ret = SKP_Silk_SDK_Decode( psDec, &DecControl, 1, i == 0, &range_dec_celt_state, nBytes, outPtr, &len );
-                if( ret ) {
-                    printf( "\nSKP_Silk_Decode returned %d", ret );
-                }
-#ifdef SKP_MACRO_COUNT
-                Ops = SKP_SaveResetCount();
-                if( Ops > maxOps ){ maxOps = Ops; }
-                totOps += Ops;
-#endif
-                outPtr  += len;
-                tot_len += len;
-            }
-        }
-        totPackets++;
-        packetSize_ms = tot_len / ( DecControl.API_sampleRate / 1000 );
-
-        /* Write output to file */
-#ifdef _SYSTEM_IS_BIG_ENDIAN   
-        swap_endian( out, tot_len );
-#endif
-        fwrite( out, sizeof( SKP_int16 ), tot_len, speechOutFile );
-
-        /* Update buffer */
-        totBytes = 0;
-        for( i = 0; i < MAX_LBRR_DELAY; i++ ) {
-            totBytes += nBytesPerPacket[ i + 1 ];
-        }
-        SKP_memmove( payload, &payload[ nBytesPerPacket[ 0 ] ], totBytes * sizeof( SKP_uint8 ) );
-        payloadEnd -= nBytesPerPacket[ 0 ];
-        SKP_memmove( nBytesPerPacket, &nBytesPerPacket[ 1 ], MAX_LBRR_DELAY * sizeof( SKP_int16 ) );
-
-        if( !quiet && totPackets % 100 == 0 ) {
-            fprintf( stderr, "\rPackets decoded:             %d", totPackets );
-        }
-    }
-
-    /* Empty the recieve buffer */
-    for( k = 0; k < MAX_LBRR_DELAY; k++ ) {
-        if( nBytesPerPacket[ 0 ] == 0 ) {
-            /* Indicate lost packet */
-            lost = 1;
-
-            /* Packet loss. Search after FEC in next packets. Should be done in the jitter buffer */
-            payloadPtr = payload;
-            for( i = 0; i < MAX_LBRR_DELAY; i++ ) {
-                if( nBytesPerPacket[ i + 1 ] > 0 ) {
-#if 0
-                    SKP_Silk_SDK_search_for_LBRR( payloadPtr, nBytesPerPacket[ i + 1 ], i + 1, FECpayload, &nBytesFEC );
-                    if( nBytesFEC > 0 ) {
-                        payloadToDec = FECpayload;
-                        nBytes = nBytesFEC;
-                        lost = 0;
-                        break;
-                    }
-#endif
-                }
-                payloadPtr += nBytesPerPacket[ i + 1 ];
-            }
-        } else {
-            lost = 0;
-            nBytes = nBytesPerPacket[ 0 ];
-            payloadToDec = payload;
-        }
-
-        /* Silk decoder */
-        outPtr  = out;
-        tot_len = 0;
-
-        if( lost == 0 ) {
-            /* No loss: Decode all frames in the packet */
-            frames = 0;
-            do {
-                /* Decode 20 ms */
-                ret = SKP_Silk_SDK_Decode( psDec, &DecControl, 0, frames == 0, &range_dec_celt_state, nBytes, outPtr, &len );
-                if( ret ) {
-                    printf( "\nSKP_Silk_SDK_Decode returned %d", ret );
-                }
-
-                frames++;
-                outPtr  += len;
-                tot_len += len;
-                if( frames > MAX_INPUT_FRAMES ) {
-                    /* Hack for corrupt stream that could generate too many frames */
-                    outPtr  = out;
-                    tot_len = 0;
-                    frames  = 0;
-                }
-            /* Until last 20 ms frame of packet has been decoded */
-            } while( frames < DecControl.framesPerPayload ); 
-        } else {    
-            /* Loss: Decode enough frames to cover one packet duration */
-
-            /* Generate 20 ms */
-            for( i = 0; i < DecControl.framesPerPayload; i++ ) {
-                ret = SKP_Silk_SDK_Decode( psDec, &DecControl, 1, i == 0, &range_dec_celt_state, nBytes, outPtr, &len );
-                if( ret ) {
-                    printf( "\nSKP_Silk_Decode returned %d", ret );
-                }
-                outPtr  += len;
-                tot_len += len;
-            }
-        }
-        totPackets++;
-
-        /* Write output to file */
-#ifdef _SYSTEM_IS_BIG_ENDIAN   
-        swap_endian( out, tot_len );
-#endif
-        fwrite( out, sizeof( SKP_int16 ), tot_len, speechOutFile );
-
-        /* Update Buffer */
-        totBytes = 0;
-        for( i = 0; i < MAX_LBRR_DELAY; i++ ) {
-            totBytes += nBytesPerPacket[ i + 1 ];
-        }
-        SKP_memmove( payload, &payload[ nBytesPerPacket[ 0 ] ], totBytes * sizeof( SKP_uint8 ) );
-        payloadEnd -= nBytesPerPacket[ 0 ];
-        SKP_memmove( nBytesPerPacket, &nBytesPerPacket[ 1 ], MAX_LBRR_DELAY * sizeof( SKP_int16 ) );
-
-        if( !quiet && totPackets % 100 == 0 ) {
-            fprintf( stderr, "\rPackets decoded:              %d", totPackets );
-        }
-    }
-
-    filetime = totPackets * 1e-3 * packetSize_ms;
-    if( !quiet ) {
-        printf("\nFile length:                 %.3f s", filetime);
-
-#ifdef SKP_MACRO_COUNT
-        printf("\n \nWMOPS calculation");
-        printf("\nMean:                        %.3f WMOPS", (float)totOps / ((float)packetSize_ms * (float)totPackets * 1e3));
-        printf("\nMax:                         %.3f WMOPS", (float)maxOps / ((float)packetSize_ms * 1e3));
-#endif
-        printf("\n\n");
-    } else {
-#ifdef SKP_MACRO_COUNT
-        /* print average and max WMOPS */
-        printf( "%.3f %.3f \n", (float)totOps / ((float)packetSize_ms * (float)totPackets * 1e3), 
-            (float)maxOps / ((float)packetSize_ms * 1e3));
-#else
-        printf( "%.3f %.3f \n", 0, 0);
-#endif
-    }
-
-    /* Free decoder */
-    free( psDec );
-
-    /* Close files */
-    fclose( speechOutFile );
-    fclose( bitInFile );
-
-    return 0;
-}
--- a/test/Encoder.c
+++ /dev/null
@@ -1,355 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. 
-Redistribution and use in source and binary forms, with or without 
-modification, (subject to the limitations in the disclaimer below) 
-are permitted provided that the following conditions are met:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright 
-notice, this list of conditions and the following disclaimer in the 
-documentation and/or other materials provided with the distribution.
-- Neither the name of Skype Limited, nor the names of specific 
-contributors, may be used to endorse or promote products derived from 
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-***********************************************************************/
-
-
-/*****************************/
-/* Silk encoder test program */
-/*****************************/
-
-#ifdef _WIN32
-#define _CRT_SECURE_NO_DEPRECATE    1
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif 
-
-#include "SKP_Silk_SDK_API.h"
-#include "../src_SigProc_FIX/SKP_Silk_SigProc_FIX.h"
-
-/* Define codec specific settings */
-#define MAX_BYTES_PER_FRAME     250 // Equals peak bitrate of 100 kbps 
-#define MAX_INPUT_FRAMES        5
-#define MAX_LBRR_DELAY          2
-#define MAX_FRAME_LENGTH        320
-#define MAX_FRAME_LENGTH_MS     20
-#define MAX_API_FS_KHZ          48
-
-#ifdef SKP_MACRO_COUNT
-    varDefine /* Define and reset global counters */
-#endif
-
-#ifdef _SYSTEM_IS_BIG_ENDIAN
-/* Function to convert a little endian int16 to a */
-/* big endian int16 or vica verca                 */
-void swap_endian(
-    SKP_int16       vec[],              /*  I/O array of */
-    SKP_int         len                 /*  I   length      */
-)
-{
-    SKP_int i;
-    SKP_int16 tmp;
-    SKP_uint8 *p1, *p2;
-
-    for( i = 0; i < len; i++ ){
-        tmp = vec[ i ];
-        p1 = (SKP_uint8 *)&vec[ i ]; p2 = (SKP_uint8 *)&tmp;
-        p1[ 0 ] = p2[ 1 ]; p1[ 1 ] = p2[ 0 ];
-    }
-}
-#endif
-
-static void print_usage( char* argv[] ) {
-    printf( "\nusage: %s in.pcm out.bit [settings]\n", argv[ 0 ] );
-    printf( "\nin.pcm               : Speech input to encoder" );
-    printf( "\nout.bit              : Bitstream output from encoder" );
-    printf( "\n   settings:" );
-    printf( "\n-Fs_API <Hz>         : API sampling rate in Hz, default: 16000" );
-    printf( "\n-Fs_maxInternal <Hz> : Maximum internal sampling rate in Hz, default: 16000" ); 
-    printf( "\n-packetlength <ms>   : Packet interval in ms, default: 20" );
-    printf( "\n-rate <bps>          : Target bitrate; default: 25000" );
-    printf( "\n-loss <perc>         : Uplink loss estimate, in percent (0-100); default: 0" );
-    printf( "\n-inbandFEC <flag>    : Enable inband FEC usage (0/1); default: 0" );
-    printf( "\n-complexity <comp>   : Set complexity, 0: low, 1: medium, 2: high; default: 2" );
-    printf( "\n-DTX <flag>          : Enable DTX (0/1); default: 0" );
-    printf( "\n-quiet               : Print only some basic values" );
-    printf( "\n");
-}
-
-int main( int argc, char* argv[] )
-{
-    double    filetime;
-    size_t    counter;
-    SKP_int32 k, args, totPackets, totActPackets, ret, nBytes;
-    double    sumBytes, sumActBytes, avg_rate, act_rate, nrg;
-    SKP_int16 in[ MAX_FRAME_LENGTH_MS * MAX_API_FS_KHZ * MAX_INPUT_FRAMES ];
-    char      speechInFileName[ 150 ], bitOutFileName[ 150 ];
-    FILE      *bitOutFile, *speechInFile;
-    SKP_int32 encSizeBytes;
-    void      *psEnc;
-#ifdef SKP_MACRO_COUNT
-    SKP_int64  Ops, maxOps = 0, totOps = 0;
-#endif
-#ifdef _SYSTEM_IS_BIG_ENDIAN
-    SKP_int16 nBytes_LE;
-#endif
-    SKP_uint8      range_buf[ MAX_BYTES_PER_FRAME * MAX_INPUT_FRAMES ];
-    ec_enc         range_enc_celt_state;
-
-    /* default settings */
-    SKP_int32 API_fs_Hz = 16000;
-    SKP_int32 max_internal_fs_Hz = 16000;
-    SKP_int32 min_internal_fs_Hz = 8000;
-    SKP_int32 targetRate_bps = 25000;
-    SKP_int32 packetSize_ms = 20;
-    SKP_int32 frameSizeReadFromFile_ms = 10;
-    SKP_int32 packetLoss_perc = 0, complexity_mode = 2, smplsSinceLastPacket;
-    SKP_int32 INBandFEC_enabled = 0, DTX_enabled = 0, quiet = 0;
-    SKP_SILK_SDK_EncControlStruct encControl; // Struct for input to encoder
-
-        
-    if( argc < 3 ) {
-        print_usage( argv );
-        exit( 0 );
-    } 
-    
-    /* get arguments */
-    args = 1;
-    strcpy( speechInFileName, argv[ args ] );
-    args++;
-    strcpy( bitOutFileName,   argv[ args ] );
-    args++;
-    while( args < argc ) {
-        if( SKP_STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-Fs_API" ) == 0 ) {
-            sscanf( argv[ args + 1 ], "%d", &API_fs_Hz );
-            args += 2;
-        } else if( SKP_STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-Fs_maxInternal" ) == 0 ) {
-            sscanf( argv[ args + 1 ], "%d", &max_internal_fs_Hz );
-            args += 2;
-        } else if( SKP_STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-packetlength" ) == 0 ) {
-            sscanf( argv[ args + 1 ], "%d", &packetSize_ms );
-            args += 2;
-        } else if( SKP_STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-rate" ) == 0 ) {
-            sscanf( argv[ args + 1 ], "%d", &targetRate_bps );
-            args += 2;
-        } else if( SKP_STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-loss" ) == 0 ) {
-            sscanf( argv[ args + 1 ], "%d", &packetLoss_perc );
-            args += 2;
-        } else if( SKP_STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-complexity" ) == 0 ) {
-            sscanf( argv[ args + 1 ], "%d", &complexity_mode );
-            args += 2;
-        } else if( SKP_STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-inbandFEC" ) == 0 ) {
-            sscanf( argv[ args + 1 ], "%d", &INBandFEC_enabled );
-            args += 2;
-        } else if( SKP_STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-DTX") == 0 ) {
-            sscanf( argv[ args + 1 ], "%d", &DTX_enabled );
-            args += 2;
-        } else if( SKP_STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-quiet" ) == 0 ) {
-            quiet = 1;
-            args++;
-        } else {
-            printf( "Error: unrecognized setting: %s\n\n", argv[ args ] );
-            print_usage( argv );
-            exit( 0 );
-        }
-    }
-
-    /* If no max internal set set to API fs */
-    if( max_internal_fs_Hz == 0 ) {
-        max_internal_fs_Hz = API_fs_Hz;
-    }
-
-    /* Print options */
-    if( !quiet ) {
-        printf("******************* Compiled for %d bit cpu ********* \n", (int)sizeof(void*) * 8 );
-        printf( "Input:                          %s\n",     speechInFileName );
-        printf( "Output:                         %s\n",     bitOutFileName );
-        printf( "API sampling rate:              %d Hz\n",  API_fs_Hz );
-        printf( "Maximum internal sampling rate: %d Hz\n",  max_internal_fs_Hz );
-        printf( "Packet interval:                %d ms\n",  packetSize_ms );
-        printf( "Inband FEC used:                %d\n",     INBandFEC_enabled );
-        printf( "DTX used:                       %d\n",     DTX_enabled );
-        printf( "Complexity:                     %d\n",     complexity_mode );
-        printf( "Target bitrate:                 %d bps\n", targetRate_bps );
-    }
-
-    /* Open files */
-    speechInFile = fopen( speechInFileName, "rb" );
-    if( speechInFile == NULL ) {
-        printf( "Error: could not open input file %s\n", speechInFileName );
-        exit( 0 );
-    }
-    bitOutFile = fopen( bitOutFileName, "wb" );
-    if( bitOutFile == NULL ) {
-        printf( "Error: could not open output file %s\n", bitOutFileName );
-        exit( 0 );
-    }
-
-    /* Create Encoder */
-    ret = SKP_Silk_SDK_Get_Encoder_Size( &encSizeBytes );
-    if( ret ) {
-        printf( "\nSKP_Silk_create_encoder returned %d", ret );
-    }
-
-    psEnc = malloc( encSizeBytes );
-
-    /* Reset Encoder */
-    ret = SKP_Silk_SDK_InitEncoder( psEnc, &encControl );
-    if( ret ) {
-        printf( "\nSKP_Silk_reset_encoder returned %d", ret );
-    }
-    
-    /* Set Encoder parameters */
-    encControl.API_sampleRate        = API_fs_Hz;
-    encControl.maxInternalSampleRate = max_internal_fs_Hz;
-    encControl.minInternalSampleRate = min_internal_fs_Hz;
-    encControl.payloadSize_ms        = packetSize_ms;
-    encControl.packetLossPercentage  = packetLoss_perc;
-    encControl.useInBandFEC          = INBandFEC_enabled;
-    encControl.useDTX                = DTX_enabled;
-    encControl.complexity            = complexity_mode;
-    encControl.bitRate               = ( targetRate_bps > 0 ? targetRate_bps : 0 );
-
-    if( API_fs_Hz > MAX_API_FS_KHZ * 1000 || API_fs_Hz < 0 ) {
-        printf( "\nError: API sampling rate = %d out of range, valid range 8000 - 48000 \n \n", API_fs_Hz );
-        exit( 0 );
-    }
-
-    totPackets           = 0;
-    totActPackets        = 0;
-    smplsSinceLastPacket = 0;
-    sumBytes             = 0.0;
-    sumActBytes          = 0.0;
-    
-    while( 1 ) {
-        if( smplsSinceLastPacket == 0 ) {
-            /* Init range coder */
-            ec_enc_init( &range_enc_celt_state, range_buf, MAX_BYTES_PER_FRAME * MAX_INPUT_FRAMES );
-        }
-
-        /* Read input from file */
-        counter = fread( in, sizeof( SKP_int16 ), ( frameSizeReadFromFile_ms * API_fs_Hz ) / 1000, speechInFile );
-#ifdef _SYSTEM_IS_BIG_ENDIAN
-        swap_endian( in, counter );
-#endif
-        if( (SKP_int)counter < ( ( frameSizeReadFromFile_ms * API_fs_Hz ) / 1000 ) ) {
-            break;
-        }
-
-        /* max payload size */
-        nBytes = MAX_BYTES_PER_FRAME * MAX_INPUT_FRAMES;
-
-        /* Silk Encoder */
-        ret = SKP_Silk_SDK_Encode( psEnc, &encControl, in, (SKP_int16)counter, &range_enc_celt_state, &nBytes, 0 );
-        if( ret ) {
-            printf( "\nSKP_Silk_Encode returned %d", ret );
-            break;
-        }
-
-#ifdef SKP_MACRO_COUNT
-        Ops = SKP_SaveResetCount();
-        if( Ops > maxOps ){ maxOps = Ops; }
-        totOps += Ops;
-#endif
-
-        /* Get packet size */
-        packetSize_ms = encControl.payloadSize_ms;
-
-        smplsSinceLastPacket += ( SKP_int )counter;
-        
-        if( ( ( 1000 * smplsSinceLastPacket ) / API_fs_Hz ) == packetSize_ms ) {
-            
-            /* Finish up the range coder */
-            ec_enc_done( &range_enc_celt_state );
-            
-            /* Sends a dummy zero size packet in case of DTX period  */
-            /* to make it work with the decoder test program.        */
-            /* In practice should be handled by RTP sequence numbers */
-            totPackets++;
-            sumBytes += nBytes;
-            nrg = 0.0;
-            for( k = 0; k < ( SKP_int )counter; k++ ) {
-                nrg += in[ k ] * (double)in[ k ];
-            }
-            if( ( nrg / ( SKP_int )counter ) > 1e3 ) {
-                sumActBytes += nBytes;
-                totActPackets++;
-            }
-
-            /* Write payload size */
-#ifdef _SYSTEM_IS_BIG_ENDIAN
-            nBytes_LE = nBytes;
-            swap_endian( &nBytes_LE, 1 );
-            fwrite( &nBytes_LE, sizeof( SKP_int16 ), 1, bitOutFile );
-#else
-            fwrite( &nBytes, sizeof( SKP_int32 ), 1, bitOutFile );
-#endif
-
-            /* Write payload */
-            fwrite( range_buf, sizeof( SKP_uint8 ), nBytes, bitOutFile );
-        
-            if( !quiet && totPackets % 100 == 0 ) {
-                fprintf( stderr, "\rPackets encoded:              %d", totPackets );
-            }
-            smplsSinceLastPacket = 0;
-        }
-    }
-
-    /* Write dummy because it can not end with 0 bytes */
-    nBytes = -1;
-
-    /* Write payload size */
-    fwrite( &nBytes, sizeof( SKP_int32 ), 1, bitOutFile );
-
-    /* Free Encoder */
-    free( psEnc );
-
-    fclose( speechInFile );
-    fclose( bitOutFile   );
-
-    filetime  = totPackets * 1e-3 * packetSize_ms;
-    avg_rate  = 8.0 / packetSize_ms * sumBytes       / totPackets;
-    act_rate  = 8.0 / packetSize_ms * sumActBytes    / totActPackets;
-    if( !quiet ) {
-        printf( "\nFile length:                 %.3f s", filetime );
-        printf( "\nAverage bitrate:             %.3f kbps", avg_rate  );
-        printf( "\nActive bitrate:              %.3f kbps", act_rate  );
-#ifdef SKP_MACRO_COUNT
-        printf( "\n \nWMOPS calculation");
-        printf( "\nMean:                        %.3f WMOPS", (float)totOps / ((float)packetSize_ms * (float)totPackets * 1e3));
-        printf( "\nMax:                         %.3f WMOPS", (float)maxOps / ((float)packetSize_ms * 1e3));
-#endif
-        printf( "\n\n" );
-    } else {
-        /* print average and active bitrates */
-        printf( "%.3f %.3f ", avg_rate, act_rate );
-#ifdef SKP_MACRO_COUNT
-        /* print average and max WMOPS */
-        printf( "%.3f %.3f \n", (float)totOps / ((float)packetSize_ms * (float)totPackets * 1e3), 
-            (float)maxOps / ((float)packetSize_ms * 1e3));
-#else
-        printf( "%.3f %.3f \n", 0, 0);
-#endif
-    }
-
-    return 0;
-}
--- a/test/signalCompare.c
+++ /dev/null
@@ -1,373 +1,0 @@
-/***********************************************************************
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. 
-Redistribution and use in source and binary forms, with or without 
-modification, (subject to the limitations in the disclaimer below) 
-are permitted provided that the following conditions are met:
-- Redistributions of source code must retain the above copyright notice,
-this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright 
-notice, this list of conditions and the following disclaimer in the 
-documentation and/or other materials provided with the distribution.
-- Neither the name of Skype Limited, nor the names of specific 
-contributors, may be used to endorse or promote products derived from 
-this software without specific prior written permission.
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED 
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-***********************************************************************/
-
-/*
-* Compare two audio signals and compute weighted SNR difference
-*/
-
-#ifdef _WIN32
-#define _CRT_SECURE_NO_DEPRECATE    1
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#include "SKP_Silk_SigProc_FIX.h"
-
-#define FRAME_LENGTH_MS         10
-#define WIN_LENGTH_MS           20
-#define BW_EXPANSION            0.7f
-
-#define MAX_FS_KHZ              24
-#define LPC_ORDER               10
-
-#ifdef  __cplusplus
-extern "C"
-{
-#endif
-/* Internally used functions */
-void Autocorrelation( 
-    SKP_float *results,                 /* o    result (length correlationCount)            */
-    const SKP_float *inputData,         /* i    input data to correlate                     */
-    SKP_int inputDataSize,              /* i    length of input                             */
-    SKP_int correlationCount            /* i    number of correlation taps to compute       */
-);
-
-/* inner product of two SKP_float arrays, with result as double */
-double Inner_product( 
-    const SKP_float     *data1, 
-    const SKP_float     *data2, 
-    SKP_int             dataSize
-);
-/* Solve the normal equations using the Levinson-Durbin recursion */
-SKP_float Levinsondurbin(               /* O    prediction error energy                     */
-    SKP_float       A[],                /* O    prediction coefficients [order]             */
-    const SKP_float corr[],             /* I    input auto-correlations [order + 1]         */
-    const SKP_int   order               /* I    prediction order                            */
-);
-
-/* Chirp (bw expand) LP AR filter */
-void Bwexpander( 
-    SKP_float *ar,                      /* io   AR filter to be expanded (without leading 1)    */
-    const SKP_int d,                    /* i    length of ar                                    */
-    const SKP_float chirp               /* i    chirp factor (typically in range (0..1) )       */
-);
-
-#ifdef  __cplusplus
-}
-#endif
-
-static void print_usage(char* argv[]) {
-    printf("\nusage: %s ref.pcm test.pcm [settings]\n", argv[ 0 ]);
-    printf("\nref.pcm       : Reference file");
-    printf("\ntest.pcm      : File to be tested, should be of same length as ref.pcm");
-    printf("\n   settings:");
-    printf("\n-diff         : Only determine bit-exactness");
-    printf("\n-fs <Hz>      : Sampling rate in Hz, max: %d; default: 24000", MAX_FS_KHZ * 1000 );
-    printf("\n");
-}
-
-#ifdef SKP_MACRO_COUNT
-    varDefine /* Define and reset global counters */
-#endif
-
-int main(int argc, char* argv[])
-{
-    SKP_int   args, n, i, counterRef, counterTest;
-    char      testInFileName[150], refInFileName[150];
-    FILE      *refInFile, *testInFile;
-    SKP_int   nFrames = 0, isUnequal = 0;
-    SKP_int   diff = 0, Fs_kHz;
-    SKP_int32 Fs_Hz = 24000;
-    SKP_float c, refWhtnd, testWhtnd, refNrg, diffNrg;
-    double    SNR = 0.0;
-    SKP_int16 refIn[WIN_LENGTH_MS * MAX_FS_KHZ], testIn[WIN_LENGTH_MS * MAX_FS_KHZ];
-    SKP_float refWin[WIN_LENGTH_MS * MAX_FS_KHZ], testWin[WIN_LENGTH_MS * MAX_FS_KHZ];
-    SKP_float autoCorr[LPC_ORDER + 1], LPC_Coef[LPC_ORDER];
-
-    if (argc < 3) {
-        print_usage(argv);
-        exit(0);
-    } 
-
-    /* get arguments */
-    args = 1;
-    strcpy(refInFileName, argv[args]);
-    args++;
-    strcpy(testInFileName, argv[args]);
-    args++;
-    while(args < argc ) {
-        if (SKP_STR_CASEINSENSITIVE_COMPARE(argv[args], "-diff") == 0) {
-            diff = 1;
-            args++;
-        }else if (SKP_STR_CASEINSENSITIVE_COMPARE(argv[args], "-fs") == 0) {
-            sscanf(argv[args+1], "%d", &Fs_Hz);
-            args += 2;
-        } else {
-            printf("Error: unrecognized setting: %s\n\n", argv[args]);
-            print_usage(argv);
-            exit(0);
-        }
-    }
-
-    Fs_kHz = SKP_DIV32_16( Fs_Hz, 1000 );
-
-    if( Fs_kHz > MAX_FS_KHZ ) {
-        printf("Error: sampling rate too high: %d\n\n", Fs_kHz);
-        print_usage(argv);
-        exit(0);
-    }
-
-    printf("Reference:  %s\n", refInFileName);
-    //printf("Test:       %s\n", testInFileName);
-
-    /* open files */
-    refInFile = fopen(refInFileName, "rb");
-    if (refInFile==NULL) {
-        printf("Error: could not open input file %s\n", refInFileName);
-        exit(0);
-    } 
-    testInFile = fopen(testInFileName, "rb");
-    if (testInFile==NULL) {
-        printf("Error: could not open input file %s\n", testInFileName);
-        exit(0);
-    }
-
-    SKP_memset( refIn,  0, sizeof(refIn) );
-    SKP_memset( testIn, 0, sizeof(testIn) );
-
-    while(1) {
-        /* Read inputs */
-        counterRef  = (SKP_int)fread(&refIn[(WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz], 
-            sizeof(SKP_int16), FRAME_LENGTH_MS * Fs_kHz, refInFile);
-        counterTest = (SKP_int)fread(&testIn[(WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz], 
-            sizeof(SKP_int16), FRAME_LENGTH_MS * Fs_kHz, testInFile);
-        if(counterRef != FRAME_LENGTH_MS * Fs_kHz || counterTest != FRAME_LENGTH_MS * Fs_kHz){
-            break;
-        }
-
-        /* test for bit-exactness */
-        for( n = 0; n < FRAME_LENGTH_MS * Fs_kHz; n++ ) {
-            if( refIn[(WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz + n] != 
-                testIn[(WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz + n] ) {
-                    isUnequal = 1;
-                    break;
-            }
-        }
-
-        /* apply sine window */
-        for( n = 0; n < WIN_LENGTH_MS * Fs_kHz; n++ ) {
-            c = (SKP_float)sin( 3.14159265 * (n + 1) / (WIN_LENGTH_MS * Fs_kHz + 1) );
-            refWin[n]  = refIn[n]  * c;
-            testWin[n] = testIn[n] * c;
-        }
-
-        /* LPC analysis on reference signal */
-
-        /* Calculate auto correlation */
-        Autocorrelation(autoCorr, refWin, WIN_LENGTH_MS * Fs_kHz, LPC_ORDER + 1);
-
-        /* Add white noise */
-        autoCorr[ 0 ] += autoCorr[ 0 ] * 1e-6f + 1.0f; 
-
-        /* Convert correlations to prediction coefficients */
-        Levinsondurbin(LPC_Coef, autoCorr, LPC_ORDER);
-
-        /* Bandwdith expansion */
-        Bwexpander(LPC_Coef, LPC_ORDER, BW_EXPANSION);
-
-        /* Filter both signals */
-        refNrg = 1.0f;
-        diffNrg = 1e-10f;
-        for( n = (WIN_LENGTH_MS - FRAME_LENGTH_MS) / 2 * Fs_kHz; 
-             n < (WIN_LENGTH_MS + FRAME_LENGTH_MS) / 2 * Fs_kHz; n++ ) {
-                refWhtnd = refIn[n];
-                testWhtnd = testIn[n];
-                for( i = 0; i < LPC_ORDER; i++ ) {
-                    refWhtnd  -= LPC_Coef[ i ] * refIn[n - i - 1];
-                    testWhtnd -= LPC_Coef[ i ] * testIn[n - i - 1];
-                }
-                refNrg += refWhtnd * refWhtnd;
-                diffNrg += (refWhtnd - testWhtnd) * (refWhtnd - testWhtnd);
-        }
-
-        /* weighted SNR */
-        if( refNrg > FRAME_LENGTH_MS * Fs_kHz ) {
-            SNR += 10.0 * log10( refNrg / diffNrg );
-            nFrames++;
-        }
-
-        /* Update Buffer */
-        SKP_memmove( refIn,  &refIn[FRAME_LENGTH_MS * Fs_kHz],  (WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz * sizeof(SKP_int16));
-        SKP_memmove( testIn, &testIn[FRAME_LENGTH_MS * Fs_kHz], (WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz * sizeof(SKP_int16));
-    }
-
-    if( diff ) {
-        if( isUnequal ) {
-            printf("Signals     DIFFER\n");
-        } else {
-            if(counterRef != counterTest){
-                printf("Warning: signals differ in length\n");
-            }
-            printf("Signals     BIT-EXACT\n");
-        }
-    } else {
-        if( nFrames == 0 ) {
-            printf("At least one signal too short or not loud enough\n");
-            exit(0);
-        }
-        if(counterRef != counterTest){
-            printf("Warning: signals differ in length\n");
-        }
-        if( isUnequal == 0 ) {
-            printf("Signals     BIT-EXACT\n");
-        } else {
-            printf("AVERAGE WEIGHTED SNR: %4.1f dB\n", SNR / nFrames);
-        }
-    }
-    printf("\n");
-
-    /* Close Files */
-    fclose(refInFile);
-    fclose(testInFile);
-
-    return 0;
-}
-
-/* compute autocorrelation */
-void Autocorrelation( 
-    SKP_float *results,                 /* o    result (length correlationCount)            */
-    const SKP_float *inputData,         /* i    input data to correlate                     */
-    SKP_int inputDataSize,              /* i    length of input                             */
-    SKP_int correlationCount            /* i    number of correlation taps to compute       */
-)
-{
-    SKP_int i;
-
-    if (correlationCount > inputDataSize) {
-        correlationCount = inputDataSize;
-    }
-
-    for( i = 0; i < correlationCount; i++ ) {
-        results[ i ] =  (SKP_float)Inner_product( inputData, inputData + i, inputDataSize - i );
-    }
-}
-
-/* inner product of two SKP_float arrays, with result as double */
-double Inner_product( 
-    const SKP_float     *data1, 
-    const SKP_float     *data2, 
-    SKP_int             dataSize
-)
-{
-    SKP_int  i, dataSize4;
-    double   result;
-
-    /* 4x unrolled loop */
-    result = 0.0f;
-    dataSize4 = dataSize & 0xFFFC;
-    for( i = 0; i < dataSize4; i += 4 ) {
-        result += data1[ i + 0 ] * data2[ i + 0 ] + 
-                  data1[ i + 1 ] * data2[ i + 1 ] +
-                  data1[ i + 2 ] * data2[ i + 2 ] +
-                  data1[ i + 3 ] * data2[ i + 3 ];
-    }
-
-    /* add any remaining products */
-    for( ; i < dataSize; i++ ) {
-        result += data1[ i ] * data2[ i ];
-    }
-
-    return result;
-}
-
-/* Solve the normal equations using the Levinson-Durbin recursion */
-SKP_float Levinsondurbin(               /* O    prediction error energy                     */
-    SKP_float       A[],                /* O    prediction coefficients [order]             */
-    const SKP_float corr[],             /* I    input auto-correlations [order + 1]         */
-    const SKP_int   order               /* I    prediction order                            */
-)
-{
-    SKP_int   i, mHalf, m;
-    SKP_float min_nrg, nrg, t, km, Atmp1, Atmp2;
-    
-    min_nrg = 1e-12f * corr[ 0 ] + 1e-9f;
-    nrg = corr[ 0 ];
-    nrg = SKP_max( min_nrg, nrg );
-    A[ 0 ] = corr[ 1 ] / nrg;
-    nrg -= A[ 0 ] * corr[ 1 ];
-    nrg = SKP_max(min_nrg, nrg);
-
-    for( m = 1; m < order; m++ )
-    {
-        t = corr[ m + 1 ];
-        for( i = 0; i < m; i++ ) {
-            t -= A[ i ] * corr[ m - i ];
-        }
-
-        /* reflection coefficient */
-        km = t / nrg;
-
-        /* residual energy */
-        nrg -= km * t;
-        nrg = SKP_max(min_nrg, nrg);
-
-        mHalf = m >> 1;
-        for( i = 0; i < mHalf; i++ ) {
-            Atmp1 = A[ i ];
-            Atmp2 = A[ m - i - 1 ];
-            A[ m - i - 1 ] -= km * Atmp1;
-            A[ i ]         -= km * Atmp2;
-        }
-        if( m & 1 ) {
-            A[ mHalf ]     -= km * A[ mHalf ];
-        }
-        A[ m ] = km;
-    }
-
-    /* return the residual energy */
-    return nrg;
-}
-
-/* Chirp (bw expand) LP AR filter */
-void Bwexpander( 
-    SKP_float *ar,                      /* io   AR filter to be expanded (without leading 1)    */
-    const SKP_int d,                    /* i    length of ar                                    */
-    const SKP_float chirp               /* i    chirp factor (typically in range (0..1) )       */
-)
-{
-    SKP_int   i;
-    SKP_float cfac = chirp;
-
-    for( i = 0; i < d - 1; i++ ) {
-        ar[ i ] *=  cfac;
-        cfac    *=  chirp;
-    }
-    ar[ d - 1 ] *=  cfac;
-}