Squashed commit of the following:
authorKoen Vos <koen.vos@skype.net>
Thu, 17 Feb 2011 21:35:44 +0000 (16:35 -0500)
committerJean-Marc Valin <jean-marc.valin@octasic.com>
Thu, 17 Feb 2011 21:35:44 +0000 (16:35 -0500)
commit 8501776e52242de200b48841b0a19a512f78085d
Author: Jean-Marc Valin <jean-marc.valin@octasic.com>
Date:   Thu Feb 17 16:35:02 2011 -0500

    Remove useless file

commit 8fdc775812f84df1bb75aa4366760c768b101d02
Author: Koen Vos <koen.vos@skype.net>
Date:   Thu Feb 17 16:22:05 2011 -0500

    SILK update (fixes a bandwidth control bug and adds encoder prefill)

61 files changed:
Makefile.am
interface/SKP_Silk_SDK_API.h
src_FIX/SKP_Silk_NLSF_VQ_sum_error_FIX.c [deleted file]
src_FIX/SKP_Silk_control_codec_FIX.c
src_FIX/SKP_Silk_encode_frame_FIX.c
src_FIX/SKP_Silk_find_pitch_lags_FIX.c
src_FIX/SKP_Silk_find_pred_coefs_FIX.c
src_FIX/SKP_Silk_init_encoder_FIX.c
src_FIX/SKP_Silk_main_FIX.h
src_FIX/SKP_Silk_noise_shape_analysis_FIX.c
src_FIX/SKP_Silk_process_gains_FIX.c
src_FIX/SKP_Silk_structs_FIX.h
src_FIX/src_FIX.vcxproj
src_FIX/src_FIX.vcxproj.filters
src_FLP/SKP_Silk_HP_variable_cutoff_FLP.c [deleted file]
src_FLP/SKP_Silk_NLSF_MSVQ_decode_FLP.c [deleted file]
src_FLP/SKP_Silk_NLSF_MSVQ_encode_FLP.c [deleted file]
src_FLP/SKP_Silk_NLSF_VQ_rate_distortion_FLP.c [deleted file]
src_FLP/SKP_Silk_NLSF_VQ_sum_error_FLP.c [deleted file]
src_FLP/SKP_Silk_control_codec_FLP.c
src_FLP/SKP_Silk_encode_frame_FLP.c
src_FLP/SKP_Silk_find_LPC_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_main_FLP.h
src_FLP/SKP_Silk_noise_shape_analysis_FLP.c
src_FLP/SKP_Silk_process_NLSFs_FLP.c [deleted file]
src_FLP/SKP_Silk_process_gains_FLP.c
src_FLP/SKP_Silk_structs_FLP.h
src_FLP/SKP_Silk_wrappers_FLP.c
src_FLP/src_FLP.vcxproj
src_FLP/src_FLP.vcxproj.filters
src_SigProc_FIX/SKP_Silk_NLSF_VQ_weights_laroia.c
src_SigProc_FIX/SKP_Silk_SigProc_FIX.h
src_SigProc_FIX/SKP_Silk_ana_filt_bank_1.c
src_SigProc_FIX/src_SigProc_FIX.vcxproj
src_SigProc_FLP/SKP_Silk_NLSF_VQ_weights_laroia_FLP.c [deleted file]
src_SigProc_FLP/SKP_Silk_SigProc_FLP.h
src_SigProc_FLP/src_SigProc_FLP.vcxproj
src_SigProc_FLP/src_SigProc_FLP.vcxproj.filters
src_common/SKP_Silk_HP_variable_cutoff.c [moved from src_FIX/SKP_Silk_HP_variable_cutoff_FIX.c with 70% similarity]
src_common/SKP_Silk_LP_variable_cutoff.c
src_common/SKP_Silk_NLSF_MSVQ_decode.c
src_common/SKP_Silk_NLSF_MSVQ_encode.c [moved from src_FIX/SKP_Silk_NLSF_MSVQ_encode_FIX.c with 91% similarity]
src_common/SKP_Silk_NLSF_VQ_rate_distortion.c [moved from src_FIX/SKP_Silk_NLSF_VQ_rate_distortion_FIX.c with 75% similarity]
src_common/SKP_Silk_NLSF_VQ_sum_error.c [new file with mode: 0644]
src_common/SKP_Silk_NSQ.c
src_common/SKP_Silk_VAD.c
src_common/SKP_Silk_control_audio_bandwidth.c
src_common/SKP_Silk_decode_frame.c
src_common/SKP_Silk_define.h
src_common/SKP_Silk_enc_API.c
src_common/SKP_Silk_interpolate.c
src_common/SKP_Silk_main.h
src_common/SKP_Silk_process_NLSFs.c [moved from src_FIX/SKP_Silk_process_NLSFs_FIX.c with 50% similarity]
src_common/SKP_Silk_structs.h
src_common/SKP_Silk_tables.h
src_common/SKP_Silk_tables_other.c
src_common/src_common.vcxproj
src_common/src_common.vcxproj.filters

index 2ca8fa4..ec45a7b 100644 (file)
@@ -3,7 +3,7 @@
 NAME = libSKP_SILK_SDK
 AM_CPPFLAGS = $(AM_CFLAGS)
 
-INCLUDES = -I$(top_srcdir)/src_FLP -I$(top_srcdir)/src_SigProc_FIX -I$(top_srcdir)/src_SigProc_FLP -I$(top_srcdir)/src_common -I$(top_srcdir)/interface -I$(top_srcdir)/../celt/libcelt
+INCLUDES = -I$(top_srcdir)/src_FLP -I$(top_srcdir)/src_FIX -I$(top_srcdir)/src_SigProc_FIX -I$(top_srcdir)/src_SigProc_FLP -I$(top_srcdir)/src_common -I$(top_srcdir)/interface -I$(top_srcdir)/../celt/libcelt
 EXTRA_DIST = src_FIX/src_FIX.vcxproj \
 src_FIX/src_FIX.vcxproj.filters \
 src_FLP/src_FLP.vcxproj \
@@ -59,6 +59,11 @@ src_common/SKP_Silk_VAD.c \
 src_common/SKP_Silk_control_audio_bandwidth.c \
 src_common/SKP_Silk_quant_LTP_gains.c \
 src_common/SKP_Silk_VQ_WMat_EC.c \
+src_common/SKP_Silk_HP_variable_cutoff.c \
+src_common/SKP_Silk_NLSF_MSVQ_encode.c \
+src_common/SKP_Silk_NLSF_VQ_rate_distortion.c \
+src_common/SKP_Silk_NLSF_VQ_sum_error.c \
+src_common/SKP_Silk_process_NLSFs.c \
 src_FLP/SKP_Silk_apply_sine_window_FLP.c \
 src_FLP/SKP_Silk_control_codec_FLP.c \
 src_FLP/SKP_Silk_corrMatrix_FLP.c \
@@ -67,19 +72,13 @@ src_FLP/SKP_Silk_find_LPC_FLP.c \
 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_HP_variable_cutoff_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 \
-src_FLP/SKP_Silk_NLSF_MSVQ_decode_FLP.c \
-src_FLP/SKP_Silk_NLSF_MSVQ_encode_FLP.c \
-src_FLP/SKP_Silk_NLSF_VQ_rate_distortion_FLP.c \
-src_FLP/SKP_Silk_NLSF_VQ_sum_error_FLP.c \
 src_FLP/SKP_Silk_noise_shape_analysis_FLP.c \
 src_FLP/SKP_Silk_prefilter_FLP.c \
 src_FLP/SKP_Silk_process_gains_FLP.c \
-src_FLP/SKP_Silk_process_NLSFs_FLP.c \
 src_FLP/SKP_Silk_regularize_correlations_FLP.c \
 src_FLP/SKP_Silk_residual_energy_FLP.c \
 src_FLP/SKP_Silk_solve_LS_FLP.c \
@@ -144,7 +143,6 @@ src_SigProc_FLP/SKP_Silk_inner_product_FLP.c \
 src_SigProc_FLP/SKP_Silk_k2a_FLP.c \
 src_SigProc_FLP/SKP_Silk_levinsondurbin_FLP.c \
 src_SigProc_FLP/SKP_Silk_LPC_inv_pred_gain_FLP.c \
-src_SigProc_FLP/SKP_Silk_NLSF_VQ_weights_laroia_FLP.c \
 src_SigProc_FLP/SKP_Silk_pitch_analysis_core_FLP.c \
 src_SigProc_FLP/SKP_Silk_scale_copy_vector_FLP.c \
 src_SigProc_FLP/SKP_Silk_scale_vector_FLP.c \
index ed4fcc4..2a7546e 100644 (file)
@@ -75,6 +75,16 @@ SKP_int SKP_Silk_SDK_QueryEncoder(                      /* O:   Returns error co
     SKP_SILK_SDK_EncControlStruct       *encStatus      /* O:   Encoder Status                                  */\r
 );\r
 \r
+/*****************************/\r
+/* Prefill look-ahead buffer */\r
+/*****************************/\r
+SKP_int SKP_Silk_SDK_Encoder_prefill_buffer( \r
+    void                                *encState,      /* I/O: State                                                       */\r
+    SKP_SILK_SDK_EncControlStruct       *encControl,    /* I:   Control structure                                           */\r
+    const SKP_int16                     *samplesIn,     /* I:   Speech sample input vector  (last part will be used)        */\r
+    SKP_int                             nSamplesIn      /* I:   Number of samples in input vector                           */\r
+);\r
+\r
 /**************************/\r
 /* Encode frame with Silk */\r
 /**************************/\r
diff --git a/src_FIX/SKP_Silk_NLSF_VQ_sum_error_FIX.c b/src_FIX/SKP_Silk_NLSF_VQ_sum_error_FIX.c
deleted file mode 100644 (file)
index 4c448f9..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/***********************************************************************\r
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
-Redistribution and use in source and binary forms, with or without \r
-modification, (subject to the limitations in the disclaimer below) \r
-are permitted provided that the following conditions are met:\r
-- Redistributions of source code must retain the above copyright notice,\r
-this list of conditions and the following disclaimer.\r
-- Redistributions in binary form must reproduce the above copyright \r
-notice, this list of conditions and the following disclaimer in the \r
-documentation and/or other materials provided with the distribution.\r
-- Neither the name of Skype Limited, nor the names of specific \r
-contributors, may be used to endorse or promote products derived from \r
-this software without specific prior written permission.\r
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED \r
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND \r
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,\r
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND \r
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \r
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \r
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF \r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON \r
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \r
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-***********************************************************************/\r
-\r
-#include "SKP_Silk_main_FIX.h"\r
-\r
-/* Compute weighted quantization errors for an LPC_order element input vector, over one codebook stage */\r
-void SKP_Silk_NLSF_VQ_sum_error_FIX(\r
-    SKP_int32                       *err_Q20,           /* O    Weighted quantization errors  [N*K]         */\r
-    const SKP_int16                 *in_Q15,            /* I    Input vectors to be quantized [N*LPC_order] */\r
-    const SKP_int                   *w_Q6,              /* I    Weighting vectors             [LPC_order]   */\r
-    const SKP_int8                  *pCB_Q8,            /* I    Codebook vectors              [K*LPC_order] */\r
-    const SKP_int                   N,                  /* I    Number of input vectors                     */\r
-    const SKP_int                   K,                  /* I    Number of codebook vectors                  */\r
-    const SKP_int                   LPC_order           /* I    Number of LPCs                              */\r
-)\r
-{\r
-    SKP_int        i, n, m;\r
-    SKP_int32      diff_Q15, sum_error, Wtmp_Q6;\r
-    SKP_int32      Wcpy_Q6[ MAX_LPC_ORDER / 2 ];\r
-    const SKP_int8 *cb_vec_Q8;\r
-\r
-    SKP_assert( LPC_order <= 16 );\r
-    SKP_assert( ( LPC_order & 1 ) == 0 );\r
-\r
-    /* Copy to local stack and pack two weights per int32 */\r
-    for( m = 0; m < SKP_RSHIFT( LPC_order, 1 ); m++ ) {\r
-        Wcpy_Q6[ m ] = w_Q6[ 2 * m ] | SKP_LSHIFT( ( SKP_int32 )w_Q6[ 2 * m + 1 ], 16 );\r
-    }\r
-\r
-    /* Loop over input vectors */\r
-    for( n = 0; n < N; n++ ) {\r
-        /* Loop over codebook */\r
-        cb_vec_Q8 = pCB_Q8;\r
-        for( i = 0; i < K; i++ ) {\r
-            sum_error = 0;\r
-            for( m = 0; m < LPC_order; m += 2 ) {\r
-                /* Get two weights packed in an int32 */\r
-                Wtmp_Q6 = Wcpy_Q6[ SKP_RSHIFT( m, 1 ) ];\r
-\r
-                /* Compute weighted squared quantization error for index m */\r
-                diff_Q15 = in_Q15[ m ] - SKP_LSHIFT16( ( SKP_int16 )( *cb_vec_Q8++ ), 7 ); // range: [ -32767 : 32767 ]\r
-                sum_error = SKP_SMLAWB( sum_error, SKP_SMULBB( diff_Q15, diff_Q15 ), Wtmp_Q6 );\r
-\r
-                /* Compute weighted squared quantization error for index m + 1 */\r
-                diff_Q15 = in_Q15[m + 1] - SKP_LSHIFT16( ( SKP_int16 )( *cb_vec_Q8++ ), 7 ); // range: [ -32767 : 32767 ]\r
-                sum_error = SKP_SMLAWT( sum_error, SKP_SMULBB( diff_Q15, diff_Q15 ), Wtmp_Q6 );\r
-            }\r
-            SKP_assert( sum_error >= 0 );\r
-            err_Q20[ i ] = sum_error;\r
-        }\r
-        err_Q20 += K;\r
-        in_Q15 += LPC_order;\r
-    }\r
-}\r
-\r
index 016c88e..5c92427 100644 (file)
@@ -28,7 +28,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "SKP_Silk_main_FIX.h"\r
 #include "SKP_Silk_setup.h"\r
 \r
-/* ToDo: Move the functions belowto common to be able to use them in FLP control codec also */\r
 SKP_INLINE SKP_int SKP_Silk_setup_resamplers(\r
     SKP_Silk_encoder_state_FIX      *psEnc,             /* I/O                      */\r
     SKP_int                         fs_kHz              /* I                        */\r
@@ -180,7 +179,7 @@ SKP_INLINE SKP_int SKP_Silk_setup_fs(
         if( PacketSize_ms == 10 ) {\r
             psEnc->sCmn.nFramesPerPacket = 1;\r
             psEnc->sCmn.nb_subfr = MAX_NB_SUBFR >> 1;\r
-            psEnc->sPred.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS_2_SF, fs_kHz );\r
+            psEnc->sCmn.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS_2_SF, fs_kHz );\r
             if( psEnc->sCmn.fs_kHz == 8 ) {\r
                 psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_NB_iCDF;\r
             } else {\r
@@ -189,7 +188,7 @@ SKP_INLINE SKP_int SKP_Silk_setup_fs(
         } else {\r
             psEnc->sCmn.nFramesPerPacket = SKP_DIV32_16( PacketSize_ms, MAX_FRAME_LENGTH_MS );\r
             psEnc->sCmn.nb_subfr = MAX_NB_SUBFR;\r
-            psEnc->sPred.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS, fs_kHz );\r
+            psEnc->sCmn.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS, fs_kHz );\r
             if( psEnc->sCmn.fs_kHz == 8 ) {\r
                 psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_NB_iCDF;\r
             } else {\r
@@ -202,24 +201,14 @@ SKP_INLINE SKP_int SKP_Silk_setup_fs(
     /* Set internal sampling frequency */\r
     if( psEnc->sCmn.fs_kHz != fs_kHz ) {\r
         /* reset part of the state */\r
-        SKP_memset( &psEnc->sShape,              0, sizeof( SKP_Silk_shape_state_FIX ) );\r
-        SKP_memset( &psEnc->sPrefilt,            0, sizeof( SKP_Silk_prefilter_state_FIX ) );\r
-        SKP_memset( &psEnc->sCmn.sNSQ,           0, sizeof( SKP_Silk_nsq_state ) );\r
-        SKP_memset( &psEnc->sPred,               0, sizeof( SKP_Silk_predict_state_FIX ) );\r
-        SKP_memset( psEnc->sPred.prev_NLSFq_Q15, 0, sizeof( psEnc->sPred.prev_NLSFq_Q15 ) );\r
-#if SWITCH_TRANSITION_FILTERING\r
-        SKP_memset( psEnc->sCmn.sLP.In_LP_State, 0, sizeof( psEnc->sCmn.sLP.In_LP_State ) );\r
-        if( psEnc->sCmn.sLP.mode == 1 ) {\r
-            /* Begin transition phase */\r
-            psEnc->sCmn.sLP.transition_frame_no = 1;\r
-        } else {\r
-            /* End transition phase */\r
-            psEnc->sCmn.sLP.transition_frame_no = 0;\r
-        }\r
-#endif\r
-        psEnc->sCmn.inputBufIx          = 0;\r
-        psEnc->sCmn.nFramesAnalyzed     = 0;\r
-        psEnc->sCmn.TargetRate_bps      = 0; /* Ensures that psEnc->SNR_dB is recomputed */\r
+        SKP_memset( &psEnc->sShape,               0, sizeof( SKP_Silk_shape_state_FIX ) );\r
+        SKP_memset( &psEnc->sPrefilt,             0, sizeof( SKP_Silk_prefilter_state_FIX ) );\r
+        SKP_memset( &psEnc->sCmn.sNSQ,            0, sizeof( SKP_Silk_nsq_state ) );\r
+        SKP_memset( psEnc->sCmn.prev_NLSFq_Q15,   0, sizeof( psEnc->sCmn.prev_NLSFq_Q15 ) );\r
+        SKP_memset( &psEnc->sCmn.sLP.In_LP_State, 0, sizeof( psEnc->sCmn.sLP.In_LP_State ) );\r
+        psEnc->sCmn.inputBufIx                  = 0;\r
+        psEnc->sCmn.nFramesAnalyzed             = 0;\r
+        psEnc->sCmn.TargetRate_bps              = 0; /* Ensures that psEnc->SNR_dB is recomputed */\r
 \r
         /* Initialize non-zero parameters */\r
         psEnc->sCmn.prevLag                     = 100;\r
@@ -259,30 +248,23 @@ SKP_INLINE SKP_int SKP_Silk_setup_fs(
         psEnc->sCmn.frame_length   = SKP_SMULBB( psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr );\r
         psEnc->sCmn.ltp_mem_length = SKP_SMULBB( LTP_MEM_LENGTH_MS, fs_kHz ); \r
         psEnc->sCmn.la_pitch       = SKP_SMULBB( LA_PITCH_MS, fs_kHz );\r
-        psEnc->sPred.min_pitch_lag = SKP_SMULBB(  3, fs_kHz );\r
-        psEnc->sPred.max_pitch_lag = SKP_SMULBB( 18, fs_kHz );\r
+        psEnc->sCmn.max_pitch_lag  = SKP_SMULBB( 18, fs_kHz );\r
         if( psEnc->sCmn.nb_subfr == MAX_NB_SUBFR ){\r
-            psEnc->sPred.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS, fs_kHz );\r
+            psEnc->sCmn.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS, fs_kHz );\r
         } else if( psEnc->sCmn.nb_subfr == MAX_NB_SUBFR / 2 ){\r
-            psEnc->sPred.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS_2_SF, fs_kHz );\r
+            psEnc->sCmn.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS_2_SF, fs_kHz );\r
         } else {\r
             /* Unsupported number of frames */\r
             SKP_assert( 0 );\r
         }\r
         if( psEnc->sCmn.fs_kHz == 16 ) {\r
             psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_WB, 9 );\r
-            psEnc->sCmn.bitrate_threshold_up    = SKP_int32_MAX;\r
-            psEnc->sCmn.bitrate_threshold_down  = WB2MB_BITRATE_BPS; \r
             psEnc->sCmn.pitch_lag_low_bits_iCDF = SKP_Silk_uniform8_iCDF;\r
         } else if( psEnc->sCmn.fs_kHz == 12 ) {\r
             psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_MB, 9 );\r
-            psEnc->sCmn.bitrate_threshold_up    = MB2WB_BITRATE_BPS;\r
-            psEnc->sCmn.bitrate_threshold_down  = MB2NB_BITRATE_BPS;\r
             psEnc->sCmn.pitch_lag_low_bits_iCDF = SKP_Silk_uniform6_iCDF;\r
         } else if( psEnc->sCmn.fs_kHz == 8 ) {\r
             psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_NB, 9 );\r
-            psEnc->sCmn.bitrate_threshold_up    = NB2MB_BITRATE_BPS;\r
-            psEnc->sCmn.bitrate_threshold_down  = 0;\r
             psEnc->sCmn.pitch_lag_low_bits_iCDF = SKP_Silk_uniform4_iCDF;\r
         } else {\r
             /* unsupported sampling rate */\r
index 43e4f0a..985b114 100644 (file)
@@ -38,7 +38,7 @@ SKP_int SKP_Silk_encode_frame_FIX(
 )\r
 {\r
     SKP_Silk_encoder_control_FIX sEncCtrl;\r
-    SKP_int     i, nBits, SNR_dB_Q7, ret = 0;\r
+    SKP_int     i, nBits, ret = 0;\r
     SKP_uint8   flags;\r
     SKP_int16   *x_frame, *res_pitch_frame;\r
     SKP_int16   xfw[ MAX_FRAME_LENGTH ];\r
@@ -77,15 +77,13 @@ TIC(ENCODE_FRAME)
     /* Voice Activity Detection */\r
     /****************************/\r
 TIC(VAD)\r
-    ret = SKP_Silk_VAD_GetSA_Q8( &psEnc->sCmn.sVAD, &psEnc->speech_activity_Q8, &SNR_dB_Q7, \r
-                                 sEncCtrl.input_quality_bands_Q15, &sEncCtrl.input_tilt_Q15,\r
-                                 psEnc->sCmn.inputBuf, psEnc->sCmn.frame_length, psEnc->sCmn.fs_kHz );\r
+    ret = SKP_Silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf );\r
 TOC(VAD)\r
 \r
     /**************************************************/\r
     /* Convert speech activity into VAD and DTX flags */\r
     /**************************************************/\r
-    if( psEnc->speech_activity_Q8 < SKP_FIX_CONST( SPEECH_ACTIVITY_DTX_THRES, 8 ) ) {\r
+    if( psEnc->sCmn.speech_activity_Q8 < SKP_FIX_CONST( SPEECH_ACTIVITY_DTX_THRES, 8 ) ) {\r
         psEnc->sCmn.indices.signalType = TYPE_NO_VOICE_ACTIVITY;\r
         psEnc->sCmn.noSpeechCounter++;\r
         if( psEnc->sCmn.noSpeechCounter > NO_SPEECH_FRAMES_BEFORE_DTX ) {\r
@@ -109,7 +107,7 @@ TOC(VAD)
 TIC(HP_IN)\r
 #if HIGH_PASS_INPUT\r
     /* Variable high-pass filter */\r
-    SKP_Silk_HP_variable_cutoff_FIX( psEnc, &sEncCtrl, x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, psEnc->sCmn.inputBuf );\r
+    SKP_Silk_HP_variable_cutoff( &psEnc->sCmn, x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, psEnc->sCmn.inputBuf, psEnc->sCmn.frame_length );\r
 #else\r
     SKP_memcpy( x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, psEnc->sCmn.inputBuf, psEnc->sCmn.frame_length * sizeof( SKP_int16 ) );\r
 #endif\r
@@ -257,13 +255,11 @@ TOC(ENCODE_FRAME)
         }\r
         DEBUG_STORE_DATA( PredCoef.dat,             tmp,                            psEnc->sCmn.predictLPCOrder * sizeof( SKP_float ) );\r
         \r
-        tmp[ 0 ] = (SKP_float)sEncCtrl.pitch_freq_low_Hz;\r
-        DEBUG_STORE_DATA( pitch_freq_low_Hz.dat,    tmp,                            sizeof( SKP_float ) );\r
         tmp[ 0 ] = (SKP_float)sEncCtrl.LTPredCodGain_Q7 / 128.0f;\r
         DEBUG_STORE_DATA( LTPredCodGain.dat,        tmp,                            sizeof( SKP_float ) );\r
         tmp[ 0 ] = (SKP_float)psEnc->LTPCorr_Q15 / 32768.0f;\r
         DEBUG_STORE_DATA( LTPcorr.dat,              tmp,                            sizeof( SKP_float ) );\r
-        tmp[ 0 ] = (SKP_float)sEncCtrl.input_tilt_Q15 / 32768.0f;\r
+        tmp[ 0 ] = (SKP_float)psEnc->sCmn.input_tilt_Q15 / 32768.0f;\r
         DEBUG_STORE_DATA( tilt.dat,                 tmp,                            sizeof( SKP_float ) );\r
         for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) {\r
             tmp[ i ] = (SKP_float)sEncCtrl.Gains_Q16[ i ] / 65536.0f;\r
@@ -277,7 +273,7 @@ TOC(ENCODE_FRAME)
         tmp[ 0 ] = (SKP_float)psEnc->speech_activity_Q8 / 256.0f;\r
         DEBUG_STORE_DATA( speech_activity.dat,      tmp,                            sizeof( SKP_float ) );\r
         for( i = 0; i < VAD_N_BANDS; i++ ) {\r
-            tmp[ i ] = (SKP_float)sEncCtrl.input_quality_bands_Q15[ i ] / 32768.0f;\r
+            tmp[ i ] = (SKP_float)psEnc->sCmn.input_quality_bands_Q15[ i ] / 32768.0f;\r
         }\r
         DEBUG_STORE_DATA( input_quality_bands.dat,  tmp,                            VAD_N_BANDS * sizeof( SKP_float ) );\r
         DEBUG_STORE_DATA( signalType.dat,           &psEnc->sCmn.indices.signalType,         sizeof( SKP_int ) ); \r
@@ -304,7 +300,7 @@ void SKP_Silk_LBRR_encode_FIX(
     /*******************************************/\r
     /* Control use of inband LBRR              */\r
     /*******************************************/\r
-    if( psEnc->sCmn.LBRR_enabled && psEnc->speech_activity_Q8 > SKP_FIX_CONST( LBRR_SPEECH_ACTIVITY_THRES, 8 ) ) {\r
+    if( psEnc->sCmn.LBRR_enabled && psEnc->sCmn.speech_activity_Q8 > SKP_FIX_CONST( LBRR_SPEECH_ACTIVITY_THRES, 8 ) ) {\r
         psEnc->sCmn.LBRR_flags[ psEnc->sCmn.nFramesAnalyzed ] = 1;\r
 \r
         /* Copy noise shaping quantizer state and quantization indices from regular encoding */\r
index 2a66f52..bfc3e36 100644 (file)
@@ -36,7 +36,6 @@ void SKP_Silk_find_pitch_lags_FIX(
     const SKP_int16                 x[]             /* I    Speech signal                               */\r
 )\r
 {\r
-    SKP_Silk_predict_state_FIX *psPredSt = &psEnc->sPred;\r
     SKP_int   buf_len, i, scale;\r
     SKP_int32 thrhld_Q15, res_nrg;\r
     const SKP_int16 *x_buf, *x_buf_ptr;\r
@@ -52,7 +51,7 @@ void SKP_Silk_find_pitch_lags_FIX(
     buf_len = psEnc->sCmn.la_pitch + psEnc->sCmn.frame_length + psEnc->sCmn.ltp_mem_length;\r
 \r
     /* Safty check */\r
-    SKP_assert( buf_len >= psPredSt->pitch_LPC_win_length );\r
+    SKP_assert( buf_len >= psEnc->sCmn.pitch_LPC_win_length );\r
 \r
     x_buf = x - psEnc->sCmn.ltp_mem_length;\r
 \r
@@ -63,22 +62,22 @@ void SKP_Silk_find_pitch_lags_FIX(
     /* Calculate windowed signal */\r
     \r
     /* First LA_LTP samples */\r
-    x_buf_ptr = x_buf + buf_len - psPredSt->pitch_LPC_win_length;\r
+    x_buf_ptr = x_buf + buf_len - psEnc->sCmn.pitch_LPC_win_length;\r
     Wsig_ptr  = Wsig;\r
     SKP_Silk_apply_sine_window( Wsig_ptr, x_buf_ptr, 1, psEnc->sCmn.la_pitch );\r
 \r
     /* Middle un - windowed samples */\r
     Wsig_ptr  += psEnc->sCmn.la_pitch;\r
     x_buf_ptr += psEnc->sCmn.la_pitch;\r
-    SKP_memcpy( Wsig_ptr, x_buf_ptr, ( psPredSt->pitch_LPC_win_length - SKP_LSHIFT( psEnc->sCmn.la_pitch, 1 ) ) * sizeof( SKP_int16 ) );\r
+    SKP_memcpy( Wsig_ptr, x_buf_ptr, ( psEnc->sCmn.pitch_LPC_win_length - SKP_LSHIFT( psEnc->sCmn.la_pitch, 1 ) ) * sizeof( SKP_int16 ) );\r
 \r
     /* Last LA_LTP samples */\r
-    Wsig_ptr  += psPredSt->pitch_LPC_win_length - SKP_LSHIFT( psEnc->sCmn.la_pitch, 1 );\r
-    x_buf_ptr += psPredSt->pitch_LPC_win_length - SKP_LSHIFT( psEnc->sCmn.la_pitch, 1 );\r
+    Wsig_ptr  += psEnc->sCmn.pitch_LPC_win_length - SKP_LSHIFT( psEnc->sCmn.la_pitch, 1 );\r
+    x_buf_ptr += psEnc->sCmn.pitch_LPC_win_length - SKP_LSHIFT( psEnc->sCmn.la_pitch, 1 );\r
     SKP_Silk_apply_sine_window( Wsig_ptr, x_buf_ptr, 2, psEnc->sCmn.la_pitch );\r
 \r
     /* Calculate autocorrelation sequence */\r
-    SKP_Silk_autocorr( auto_corr, &scale, Wsig, psPredSt->pitch_LPC_win_length, psEnc->sCmn.pitchEstimationLPCOrder + 1 ); \r
+    SKP_Silk_autocorr( auto_corr, &scale, Wsig, psEnc->sCmn.pitch_LPC_win_length, psEnc->sCmn.pitchEstimationLPCOrder + 1 ); \r
         \r
     /* Add white noise, as fraction of energy */\r
     auto_corr[ 0 ] = SKP_SMLAWB( auto_corr[ 0 ], auto_corr[ 0 ], SKP_FIX_CONST( FIND_PITCH_WHITE_NOISE_FRACTION, 16 ) ) + 1;\r
@@ -105,13 +104,13 @@ void SKP_Silk_find_pitch_lags_FIX(
     /*****************************************/\r
     SKP_Silk_LPC_analysis_filter( res, x_buf, A_Q12, buf_len, psEnc->sCmn.pitchEstimationLPCOrder );\r
 \r
-    if( psEnc->sCmn.indices.signalType != TYPE_NO_VOICE_ACTIVITY ) {\r
+    if( psEnc->sCmn.indices.signalType != TYPE_NO_VOICE_ACTIVITY && psEnc->sCmn.first_frame_after_reset == 0 ) {\r
         /* Threshold for pitch estimator */\r
         thrhld_Q15 = SKP_FIX_CONST( 0.6, 15 );\r
         thrhld_Q15 = SKP_SMLABB( thrhld_Q15, SKP_FIX_CONST( -0.004, 15 ), psEnc->sCmn.pitchEstimationLPCOrder );\r
-        thrhld_Q15 = SKP_SMLABB( thrhld_Q15, SKP_FIX_CONST( -0.1,   7  ), psEnc->speech_activity_Q8 );\r
+        thrhld_Q15 = SKP_SMLABB( thrhld_Q15, SKP_FIX_CONST( -0.1,   7  ), psEnc->sCmn.speech_activity_Q8 );\r
         thrhld_Q15 = SKP_SMLABB( thrhld_Q15, SKP_FIX_CONST( -0.15,  15 ), SKP_RSHIFT( psEnc->sCmn.prevSignalType, 1 ) );\r
-        thrhld_Q15 = SKP_SMLAWB( thrhld_Q15, SKP_FIX_CONST( -0.1,   16 ), psEncCtrl->input_tilt_Q15 );\r
+        thrhld_Q15 = SKP_SMLAWB( thrhld_Q15, SKP_FIX_CONST( -0.1,   16 ), psEnc->sCmn.input_tilt_Q15 );\r
         thrhld_Q15 = SKP_SAT16(  thrhld_Q15 );\r
 \r
         /*****************************************/\r
index 5f3dcdc..babc4e8 100644 (file)
@@ -108,14 +108,14 @@ void SKP_Silk_find_pred_coefs_FIX(
 \r
     /* LPC_in_pre contains the LTP-filtered input for voiced, and the unfiltered input for unvoiced */\r
     TIC(FIND_LPC)\r
-    SKP_Silk_find_LPC_FIX( NLSF_Q15, &psEnc->sCmn.indices.NLSFInterpCoef_Q2, psEnc->sPred.prev_NLSFq_Q15, \r
+    SKP_Silk_find_LPC_FIX( NLSF_Q15, &psEnc->sCmn.indices.NLSFInterpCoef_Q2, psEnc->sCmn.prev_NLSFq_Q15, \r
         psEnc->sCmn.useInterpolatedNLSFs * ( 1 - psEnc->sCmn.first_frame_after_reset ), psEnc->sCmn.predictLPCOrder, \r
         LPC_in_pre, psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder, psEnc->sCmn.nb_subfr );\r
     TOC(FIND_LPC)\r
 \r
     /* Quantize LSFs */\r
     TIC(PROCESS_LSFS)\r
-        SKP_Silk_process_NLSFs_FIX( psEnc, psEncCtrl, NLSF_Q15 );\r
+    SKP_Silk_process_NLSFs( &psEnc->sCmn, psEncCtrl->PredCoef_Q12, NLSF_Q15, psEnc->sCmn.prev_NLSFq_Q15 );\r
     TOC(PROCESS_LSFS)\r
 \r
     /* Calculate residual energy using quantized LPC coefficients */\r
@@ -123,5 +123,5 @@ void SKP_Silk_find_pred_coefs_FIX(
         psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.predictLPCOrder );\r
 \r
     /* Copy to prediction struct for use in next frame for fluctuation reduction */\r
-    SKP_memcpy( psEnc->sPred.prev_NLSFq_Q15, NLSF_Q15, psEnc->sCmn.predictLPCOrder * sizeof( SKP_int ) );\r
+    SKP_memcpy( psEnc->sCmn.prev_NLSFq_Q15, NLSF_Q15, sizeof( psEnc->sCmn.prev_NLSFq_Q15 ) );\r
 }\r
index d57d15b..1818b19 100644 (file)
@@ -38,11 +38,11 @@ SKP_int SKP_Silk_init_encoder_FIX(
     SKP_memset( psEnc, 0, sizeof( SKP_Silk_encoder_state_FIX ) );\r
 \r
 #if HIGH_PASS_INPUT\r
-    psEnc->variable_HP_smth1_Q15 = 200844; /* = SKP_Silk_log2(70)_Q0; */\r
-    psEnc->variable_HP_smth2_Q15 = 200844; /* = SKP_Silk_log2(70)_Q0; */\r
+    psEnc->sCmn.variable_HP_smth1_Q15 = 200844; /* = SKP_Silk_log2(70)_Q0; */\r
+    psEnc->sCmn.variable_HP_smth2_Q15 = 200844; /* = SKP_Silk_log2(70)_Q0; */\r
 #endif\r
 \r
-    /* Used to deactivate e.g. LSF interpolation and fluctuation reduction */\r
+    /* Used to deactivate LSF interpolation, fluctuation reduction, pitch prediction */\r
     psEnc->sCmn.first_frame_after_reset = 1;\r
 \r
     /* Initialize Silk VAD */\r
index 64c5b8b..004e7d2 100644 (file)
@@ -46,14 +46,6 @@ extern "C"
 /* Encoder Functions */\r
 /*********************/\r
 \r
-/* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */\r
-void SKP_Silk_HP_variable_cutoff_FIX(\r
-    SKP_Silk_encoder_state_FIX      *psEnc,         /* I/O  Encoder state                               */\r
-    SKP_Silk_encoder_control_FIX    *psEncCtrl,     /* I/O  Encoder control                             */\r
-    SKP_int16                       *out,           /* O    high-pass filtered output signal            */\r
-    const SKP_int16                 *in             /* I    input signal                                */\r
-);\r
-\r
 /* Encoder main function */\r
 SKP_int SKP_Silk_encode_frame_FIX( \r
     SKP_Silk_encoder_state_FIX      *psEnc,             /* I/O  Pointer to Silk FIX encoder state       */\r
@@ -188,53 +180,6 @@ void SKP_Silk_residual_energy_FIX(
     const SKP_int   LPC_order                       /* I    LPC order                       */\r
 );\r
 \r
-/******************/\r
-/* NLSF Quantizer */\r
-/******************/\r
-/* Limit, stabilize, convert and quantize NLSFs.    */ \r
-void SKP_Silk_process_NLSFs_FIX(\r
-    SKP_Silk_encoder_state_FIX      *psEnc,     /* I/O  encoder state                               */\r
-    SKP_Silk_encoder_control_FIX    *psEncCtrl, /* I/O  encoder control                             */\r
-    SKP_int                         *pNLSF_Q15  /* I/O  Normalized LSFs (quant out) (0 - (2^15-1))  */\r
-);\r
-\r
-/* NLSF vector encoder */\r
-void SKP_Silk_NLSF_MSVQ_encode_FIX(\r
-          SKP_int8                  *NLSFIndices,           /* O    Codebook path vector [ CB_STAGES ]      */\r
-          SKP_int                   *pNLSF_Q15,             /* I/O  Quantized NLSF vector [ LPC_ORDER ]     */\r
-    const SKP_Silk_NLSF_CB_struct   *psNLSF_CB,             /* I    Codebook object                         */\r
-    const SKP_int                   *pNLSF_q_Q15_prev,      /* I    Prev. quantized NLSF vector [LPC_ORDER] */\r
-    const SKP_int                   *pW_Q6,                 /* I    NLSF weight vector [ LPC_ORDER ]        */\r
-    const SKP_int                   NLSF_mu_Q15,            /* I    Rate weight for the RD optimization     */\r
-    const SKP_int                   NLSF_mu_fluc_red_Q16,   /* I    Fluctuation reduction error weight      */\r
-    const SKP_int                   NLSF_MSVQ_Survivors,    /* I    Max survivors from each stage           */\r
-    const SKP_int                   LPC_order,              /* I    LPC order                               */\r
-    const SKP_int                   deactivate_fluc_red     /* I    Deactivate fluctuation reduction        */\r
-);\r
-\r
-/* Rate-Distortion calculations for multiple input data vectors */\r
-void SKP_Silk_NLSF_VQ_rate_distortion_FIX(\r
-    SKP_int32                       *pRD_Q20,           /* O    Rate-distortion values [psNLSF_CBS->nVectors*N] */\r
-    const SKP_Silk_NLSF_CBS         *psNLSF_CBS,        /* I    NLSF codebook stage struct                      */\r
-    const SKP_int16                 *in_Q15,            /* I    Input vectors to be quantized                   */\r
-    const SKP_int                   *w_Q6,              /* I    Weight vector                                   */\r
-    const SKP_int32                 *rate_acc_Q5,       /* I    Accumulated rates from previous stage           */\r
-    const SKP_int                   mu_Q15,             /* I    Weight between weighted error and rate          */\r
-    const SKP_int                   N,                  /* I    Number of input vectors to be quantized         */\r
-    const SKP_int                   LPC_order           /* I    LPC order                                       */\r
-);\r
-\r
-/* Compute weighted quantization errors for an LPC_order element input vector, over one codebook stage */\r
-void SKP_Silk_NLSF_VQ_sum_error_FIX(\r
-    SKP_int32                       *err_Q20,           /* O    Weighted quantization errors  [N*K]         */\r
-    const SKP_int16                 *in_Q15,            /* I    Input vectors to be quantized [N*LPC_order] */\r
-    const SKP_int                   *w_Q6,              /* I    Weighting vectors             [N*LPC_order] */\r
-    const SKP_int8                  *pCB_Q9,            /* I    Codebook vectors              [K*LPC_order] */\r
-    const SKP_int                   N,                  /* I    Number of input vectors                     */\r
-    const SKP_int                   K,                  /* I    Number of codebook vectors                  */\r
-    const SKP_int                   LPC_order           /* I    Number of LPCs                              */\r
-);\r
-\r
 /* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */\r
 SKP_int32 SKP_Silk_residual_energy16_covar_FIX(\r
     const SKP_int16                 *c,                 /* I    Prediction vector                           */\r
index 649161d..e43e253 100644 (file)
@@ -170,8 +170,8 @@ void SKP_Silk_noise_shape_analysis_FIX(
     /* GAIN CONTROL */\r
     /****************/\r
     /* Input quality is the average of the quality in the lowest two VAD bands */\r
-    psEncCtrl->input_quality_Q14 = ( SKP_int )SKP_RSHIFT( ( SKP_int32 )psEncCtrl->input_quality_bands_Q15[ 0 ] \r
-        + psEncCtrl->input_quality_bands_Q15[ 1 ], 2 );\r
+    psEncCtrl->input_quality_Q14 = ( SKP_int )SKP_RSHIFT( ( SKP_int32 )psEnc->sCmn.input_quality_bands_Q15[ 0 ] \r
+        + psEnc->sCmn.input_quality_bands_Q15[ 1 ], 2 );\r
 \r
     /* Coding quality level, between 0.0_Q0 and 1.0_Q0, but in Q14 */\r
     psEncCtrl->coding_quality_Q14 = SKP_RSHIFT( SKP_Silk_sigm_Q15( SKP_RSHIFT_ROUND( psEncCtrl->current_SNR_dB_Q7 - \r
@@ -180,7 +180,7 @@ void SKP_Silk_noise_shape_analysis_FIX(
     /* Reduce coding SNR during low speech activity */\r
     SNR_adj_dB_Q7 = psEncCtrl->current_SNR_dB_Q7;\r
     if( psEnc->sCmn.useCBR == 0 ) {\r
-        b_Q8 = SKP_FIX_CONST( 1.0, 8 ) - psEnc->speech_activity_Q8;\r
+        b_Q8 = SKP_FIX_CONST( 1.0, 8 ) - psEnc->sCmn.speech_activity_Q8;\r
         b_Q8 = SKP_SMULWB( SKP_LSHIFT( b_Q8, 8 ), b_Q8 );\r
         SNR_adj_dB_Q7 = SKP_SMLAWB( SNR_adj_dB_Q7,\r
             SKP_SMULBB( SKP_FIX_CONST( -BG_SNR_DECR_dB, 7 ) >> ( 4 + 1 ), b_Q8 ),                                       // Q11\r
@@ -370,15 +370,9 @@ void SKP_Silk_noise_shape_analysis_FIX(
     /* Control low-frequency shaping and noise tilt */\r
     /************************************************/\r
     /* Less low frequency shaping for noisy inputs */\r
-#if 1\r
-    strength_Q16 = SKP_MUL( SKP_FIX_CONST( LOW_FREQ_SHAPING, 0 ), SKP_FIX_CONST( 1.0, 16 ) + \r
-        SKP_SMULBB( SKP_FIX_CONST( LOW_QUALITY_LOW_FREQ_SHAPING_DECR, 1 ), psEncCtrl->input_quality_bands_Q15[ 0 ] - SKP_FIX_CONST( 1.0, 15 ) ) );\r
-#else\r
-// TODO: CHECK THAT BELOW WORKS FINE AND REPLACE\r
     strength_Q16 = SKP_MUL( SKP_FIX_CONST( LOW_FREQ_SHAPING, 4 ), SKP_SMLAWB( SKP_FIX_CONST( 1.0, 12 ),\r
-        SKP_FIX_CONST( LOW_QUALITY_LOW_FREQ_SHAPING_DECR, 13 ), psEncCtrl->input_quality_bands_Q15[ 0 ] - SKP_FIX_CONST( 1.0, 15 ) ) );\r
-#endif\r
-    strength_Q16 = SKP_RSHIFT( SKP_MUL( strength_Q16, psEnc->speech_activity_Q8 ), 8 );\r
+        SKP_FIX_CONST( LOW_QUALITY_LOW_FREQ_SHAPING_DECR, 13 ), psEnc->sCmn.input_quality_bands_Q15[ 0 ] - SKP_FIX_CONST( 1.0, 15 ) ) );\r
+    strength_Q16 = SKP_RSHIFT( SKP_MUL( strength_Q16, psEnc->sCmn.speech_activity_Q8 ), 8 );\r
     if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) {\r
         /* Reduce low frequencies quantization noise for periodic signals, depending on pitch lag */\r
         /*f = 400; freqz([1, -0.98 + 2e-4 * f], [1, -0.97 + 7e-4 * f], 2^12, Fs); axis([0, 1000, -10, 1])*/\r
@@ -392,7 +386,7 @@ void SKP_Silk_noise_shape_analysis_FIX(
         SKP_assert( SKP_FIX_CONST( HARM_HP_NOISE_COEF, 24 ) < SKP_FIX_CONST( 0.5, 24 ) ); // Guarantees that second argument to SMULWB() is within range of an SKP_int16\r
         Tilt_Q16 = - SKP_FIX_CONST( HP_NOISE_COEF, 16 ) - \r
             SKP_SMULWB( SKP_FIX_CONST( 1.0, 16 ) - SKP_FIX_CONST( HP_NOISE_COEF, 16 ), \r
-                SKP_SMULWB( SKP_FIX_CONST( HARM_HP_NOISE_COEF, 24 ), psEnc->speech_activity_Q8 ) );\r
+                SKP_SMULWB( SKP_FIX_CONST( HARM_HP_NOISE_COEF, 24 ), psEnc->sCmn.speech_activity_Q8 ) );\r
     } else {\r
         b_Q14 = SKP_DIV32_16( 21299, psEnc->sCmn.fs_kHz ); // 1.3_Q0 = 21299_Q14\r
         /* Pack two coefficients in one int32 */\r
index dfa0980..f8bb295 100644 (file)
@@ -87,7 +87,7 @@ void SKP_Silk_process_gains_FIX(
         &psShapeSt->LastGainIndex, psEnc->sCmn.nFramesAnalyzed, psEnc->sCmn.nb_subfr );\r
     /* Set quantizer offset for voiced signals. Larger offset when LTP coding gain is low or tilt is high (ie low-pass) */\r
     if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) {\r
-        if( psEncCtrl->LTPredCodGain_Q7 + SKP_RSHIFT( psEncCtrl->input_tilt_Q15, 8 ) > SKP_FIX_CONST( 1.0, 7 ) ) {\r
+        if( psEncCtrl->LTPredCodGain_Q7 + SKP_RSHIFT( psEnc->sCmn.input_tilt_Q15, 8 ) > SKP_FIX_CONST( 1.0, 7 ) ) {\r
             psEnc->sCmn.indices.quantOffsetType = 0;\r
         } else {\r
             psEnc->sCmn.indices.quantOffsetType = 1;\r
@@ -98,7 +98,7 @@ void SKP_Silk_process_gains_FIX(
     quant_offset_Q10 = SKP_Silk_Quantization_Offsets_Q10[ psEnc->sCmn.indices.signalType >> 1 ][ psEnc->sCmn.indices.quantOffsetType ];\r
     psEncCtrl->Lambda_Q10 = SKP_FIX_CONST( LAMBDA_OFFSET, 10 )\r
                           + SKP_SMULBB( SKP_FIX_CONST( LAMBDA_DELAYED_DECISIONS, 10 ), psEnc->sCmn.nStatesDelayedDecision )\r
-                          + SKP_SMULWB( SKP_FIX_CONST( LAMBDA_SPEECH_ACT,        18 ), psEnc->speech_activity_Q8          )\r
+                          + SKP_SMULWB( SKP_FIX_CONST( LAMBDA_SPEECH_ACT,        18 ), psEnc->sCmn.speech_activity_Q8     )\r
                           + SKP_SMULWB( SKP_FIX_CONST( LAMBDA_INPUT_QUALITY,     12 ), psEncCtrl->input_quality_Q14       )\r
                           + SKP_SMULWB( SKP_FIX_CONST( LAMBDA_CODING_QUALITY,    12 ), psEncCtrl->coding_quality_Q14      )\r
                           + SKP_SMULWB( SKP_FIX_CONST( LAMBDA_QUANT_OFFSET,      16 ), quant_offset_Q10                   );\r
index 0cc0489..9f60477 100644 (file)
@@ -61,37 +61,19 @@ typedef struct {
     SKP_int     lagPrev;\r
 } SKP_Silk_prefilter_state_FIX;\r
 \r
-/*****************************/\r
-/* Prediction analysis state */\r
-/*****************************/\r
-typedef struct {\r
-    SKP_int   pitch_LPC_win_length;\r
-    SKP_int   min_pitch_lag;                                        /* Lowest possible pitch lag (samples)  */\r
-    SKP_int   max_pitch_lag;                                        /* Highest possible pitch lag (samples) */\r
-    SKP_int   prev_NLSFq_Q15[ MAX_LPC_ORDER ];                      /* Previously quantized NLSF vector     */\r
-} SKP_Silk_predict_state_FIX;\r
-\r
-\r
 /********************************/\r
 /* Encoder state FIX            */\r
 /********************************/\r
 typedef struct {\r
     SKP_Silk_encoder_state          sCmn;                           /* Common struct, shared with floating-point code */\r
-\r
-#if HIGH_PASS_INPUT\r
-    SKP_int32                       variable_HP_smth1_Q15;          /* State of first smoother                                              */\r
-    SKP_int32                       variable_HP_smth2_Q15;          /* State of second smoother                                             */\r
-#endif\r
     SKP_Silk_shape_state_FIX        sShape;                         /* Shape state                                                          */\r
     SKP_Silk_prefilter_state_FIX    sPrefilt;                       /* Prefilter State                                                      */\r
-    SKP_Silk_predict_state_FIX      sPred;                          /* Prediction state                                                     */\r
 \r
     /* Buffer for find pitch and noise shape analysis */\r
     SKP_DWORD_ALIGN SKP_int16 x_buf[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ];\r
     SKP_int                         LTPCorr_Q15;                    /* Normalized correlation from pitch lag estimator                      */\r
     SKP_int32                       SNR_dB_Q7;                      /* Quality setting                                                      */\r
     SKP_int                         BufferedInChannel_ms;           /* Simulated number of ms buffer because of exceeded TargetRate_bps     */\r
-    SKP_int                         speech_activity_Q8;             /* Speech activity in Q8                                                */\r
 \r
     /* Parameters For LTP scaling Control */\r
     SKP_int                         prevLTPredCodGain_Q7;\r
@@ -124,15 +106,12 @@ typedef struct {
     SKP_int     Lambda_Q10;\r
     SKP_int     input_quality_Q14;\r
     SKP_int     coding_quality_Q14;\r
-    SKP_int32   pitch_freq_low_Hz;\r
     SKP_int     current_SNR_dB_Q7;\r
 \r
     /* measures */\r
     SKP_int     sparseness_Q8;\r
     SKP_int32   predGain_Q16;\r
     SKP_int     LTPredCodGain_Q7;\r
-    SKP_int     input_quality_bands_Q15[ VAD_N_BANDS ];\r
-    SKP_int     input_tilt_Q15;\r
     SKP_int32   ResNrg[ MAX_NB_SUBFR ];             /* Residual energy per subframe                             */\r
     SKP_int     ResNrgQ[ MAX_NB_SUBFR ];            /* Q domain for the residual energy > 0                     */\r
     \r
index 1b73d8a..15da4c6 100644 (file)
     <ClCompile Include="SKP_Silk_find_LTP_FIX.c" />\r
     <ClCompile Include="SKP_Silk_find_pitch_lags_FIX.c" />\r
     <ClCompile Include="SKP_Silk_find_pred_coefs_FIX.c" />\r
-    <ClCompile Include="SKP_Silk_HP_variable_cutoff_FIX.c" />\r
     <ClCompile Include="SKP_Silk_init_encoder_FIX.c" />\r
     <ClCompile Include="SKP_Silk_LTP_analysis_filter_FIX.c" />\r
     <ClCompile Include="SKP_Silk_LTP_scale_ctrl_FIX.c" />\r
-    <ClCompile Include="SKP_Silk_NLSF_MSVQ_encode_FIX.c" />\r
-    <ClCompile Include="SKP_Silk_NLSF_VQ_rate_distortion_FIX.c" />\r
-    <ClCompile Include="SKP_Silk_NLSF_VQ_sum_error_FIX.c" />\r
     <ClCompile Include="SKP_Silk_noise_shape_analysis_FIX.c" />\r
     <ClCompile Include="SKP_Silk_prefilter_FIX.c" />\r
     <ClCompile Include="SKP_Silk_process_gains_FIX.c" />\r
-    <ClCompile Include="SKP_Silk_process_NLSFs_FIX.c" />\r
     <ClCompile Include="SKP_Silk_regularize_correlations_FIX.c" />\r
     <ClCompile Include="SKP_Silk_residual_energy16_FIX.c" />\r
     <ClCompile Include="SKP_Silk_residual_energy_FIX.c" />\r
index ad867d7..1718e61 100644 (file)
@@ -47,9 +47,6 @@
     <ClCompile Include="SKP_Silk_find_pred_coefs_FIX.c">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
-    <ClCompile Include="SKP_Silk_HP_variable_cutoff_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
     <ClCompile Include="SKP_Silk_init_encoder_FIX.c">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
     <ClCompile Include="SKP_Silk_LTP_scale_ctrl_FIX.c">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
-    <ClCompile Include="SKP_Silk_NLSF_MSVQ_encode_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_NLSF_VQ_rate_distortion_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_NLSF_VQ_sum_error_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
     <ClCompile Include="SKP_Silk_noise_shape_analysis_FIX.c">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
@@ -77,9 +65,6 @@
     <ClCompile Include="SKP_Silk_process_gains_FIX.c">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
-    <ClCompile Include="SKP_Silk_process_NLSFs_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
     <ClCompile Include="SKP_Silk_regularize_correlations_FIX.c">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
diff --git a/src_FLP/SKP_Silk_HP_variable_cutoff_FLP.c b/src_FLP/SKP_Silk_HP_variable_cutoff_FLP.c
deleted file mode 100644 (file)
index dcac37b..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/***********************************************************************\r
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
-Redistribution and use in source and binary forms, with or without \r
-modification, (subject to the limitations in the disclaimer below) \r
-are permitted provided that the following conditions are met:\r
-- Redistributions of source code must retain the above copyright notice,\r
-this list of conditions and the following disclaimer.\r
-- Redistributions in binary form must reproduce the above copyright \r
-notice, this list of conditions and the following disclaimer in the \r
-documentation and/or other materials provided with the distribution.\r
-- Neither the name of Skype Limited, nor the names of specific \r
-contributors, may be used to endorse or promote products derived from \r
-this software without specific prior written permission.\r
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED \r
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND \r
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,\r
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND \r
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \r
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \r
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF \r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON \r
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \r
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-***********************************************************************/\r
-\r
-#include "SKP_Silk_main_FLP.h"\r
-#include "SKP_Silk_tuning_parameters.h"\r
-\r
-#if HIGH_PASS_INPUT\r
-\r
-/* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */\r
-void SKP_Silk_HP_variable_cutoff_FLP(\r
-    SKP_Silk_encoder_state_FLP      *psEnc,             /* I/O  Encoder state FLP                       */\r
-    SKP_Silk_encoder_control_FLP    *psEncCtrl,         /* I/O  Encoder control FLP                     */\r
-          SKP_int16                 *out,               /* O    High-pass filtered output signal        */\r
-    const SKP_int16                 *in                 /* I    Input signal                            */\r
-)\r
-{\r
-    SKP_float pitch_freq_Hz, pitch_freq_log, quality, delta_freq, smth_coef, Fc, r;\r
-    SKP_int32 B_Q28[ 3 ], A_Q28[ 2 ];\r
-\r
-    /*********************************************/\r
-    /* Estimate low end of pitch frequency range */\r
-    /*********************************************/\r
-    if( psEnc->sCmn.prevSignalType == TYPE_VOICED ) {\r
-        /* Difference, in log domain */\r
-        pitch_freq_Hz  = 1e3f * psEnc->sCmn.fs_kHz / psEnc->sCmn.prevLag;\r
-        pitch_freq_log = SKP_Silk_log2( pitch_freq_Hz );\r
-\r
-        /* Adjustment based on quality */\r
-        quality = psEncCtrl->input_quality_bands[ 0 ];\r
-        pitch_freq_log -= quality * quality * ( pitch_freq_log - SKP_Silk_log2( VARIABLE_HP_MIN_FREQ ) );\r
-        pitch_freq_log += 0.5f * ( 0.6f - quality );\r
-\r
-        delta_freq = pitch_freq_log - psEnc->variable_HP_smth1;\r
-        if( delta_freq < 0.0 ) {\r
-            /* Less smoothing for decreasing pitch frequency, to track something close to the minimum */\r
-            delta_freq *= 3.0f;\r
-        }\r
-\r
-        /* Limit delta, to reduce impact of outliers */\r
-        delta_freq = SKP_LIMIT_float( delta_freq, -VARIABLE_HP_MAX_DELTA_FREQ, VARIABLE_HP_MAX_DELTA_FREQ );\r
-    \r
-        /* Update smoother */\r
-        smth_coef = VARIABLE_HP_SMTH_COEF1 * psEnc->speech_activity;\r
-        psEnc->variable_HP_smth1 += smth_coef * delta_freq;\r
-    }\r
-\r
-    /* Second smoother */\r
-    psEnc->variable_HP_smth2 += VARIABLE_HP_SMTH_COEF2 * ( psEnc->variable_HP_smth1 - psEnc->variable_HP_smth2 );\r
-\r
-    /* Convert from log scale to Hertz */\r
-    psEncCtrl->pitch_freq_low_Hz = ( SKP_float )pow( 2.0f, psEnc->variable_HP_smth2 );\r
-\r
-    /* Limit frequency range */\r
-    psEncCtrl->pitch_freq_low_Hz = SKP_LIMIT_float( psEncCtrl->pitch_freq_low_Hz, VARIABLE_HP_MIN_FREQ, VARIABLE_HP_MAX_FREQ );\r
-\r
-    /*******************************/\r
-    /* Compute filter coefficients */\r
-    /*******************************/\r
-    /* Compute cut-off frequency, in radians */\r
-    Fc = ( SKP_float )( 0.45f * 2.0f * 3.14159265359 * psEncCtrl->pitch_freq_low_Hz / ( 1e3f * psEnc->sCmn.fs_kHz ) );\r
-\r
-    /* 2nd order ARMA coefficients */\r
-    r = 1.0f - 0.92f * Fc;\r
-\r
-    /* b = r * [1; -2; 1]; */\r
-    /* a = [1; -2 * r * (1 - 0.5 * Fc^2); r^2]; */\r
-    B_Q28[ 0 ] = SKP_float2int( ( 1 << 28 ) * r );\r
-    B_Q28[ 1 ] = SKP_float2int( ( 1 << 28 ) * -2.0f * r );\r
-    B_Q28[ 2 ] = B_Q28[ 0 ];\r
-    A_Q28[ 0 ] = SKP_float2int( ( 1 << 28 ) * -2.0f * r * ( 1.0f - 0.5f * Fc * Fc ) );\r
-    A_Q28[ 1 ] = SKP_float2int( ( 1 << 28 ) * r * r );\r
-\r
-    /********************/\r
-    /* High-pass filter */\r
-    /********************/\r
-    SKP_Silk_biquad_alt( in, B_Q28, A_Q28, psEnc->sCmn.In_HP_State, out, psEnc->sCmn.frame_length );\r
-}\r
-\r
-#endif // HIGH_PASS_INPUT\r
diff --git a/src_FLP/SKP_Silk_NLSF_MSVQ_decode_FLP.c b/src_FLP/SKP_Silk_NLSF_MSVQ_decode_FLP.c
deleted file mode 100644 (file)
index 6525371..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/***********************************************************************\r
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
-Redistribution and use in source and binary forms, with or without \r
-modification, (subject to the limitations in the disclaimer below) \r
-are permitted provided that the following conditions are met:\r
-- Redistributions of source code must retain the above copyright notice,\r
-this list of conditions and the following disclaimer.\r
-- Redistributions in binary form must reproduce the above copyright \r
-notice, this list of conditions and the following disclaimer in the \r
-documentation and/or other materials provided with the distribution.\r
-- Neither the name of Skype Limited, nor the names of specific \r
-contributors, may be used to endorse or promote products derived from \r
-this software without specific prior written permission.\r
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED \r
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND \r
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,\r
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND \r
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \r
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \r
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF \r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON \r
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \r
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-***********************************************************************/\r
-\r
-#include "SKP_Silk_main_FLP.h"\r
-\r
-/* NLSF vector decoder */\r
-void SKP_Silk_NLSF_MSVQ_decode_FLP(\r
-          SKP_float                 *pNLSF,             /* O    Decoded output vector [ LPC_ORDER ]     */\r
-    const SKP_Silk_NLSF_CB_struct   *psNLSF_CB,         /* I    NLSF codebook struct                    */  \r
-    const SKP_int8                  *NLSFIndices,       /* I    NLSF indices [ nStages ]                */\r
-    const SKP_int                   LPC_order           /* I    LPC order used                          */\r
-)\r
-{\r
-    const SKP_int8 *pCB_element;\r
-          SKP_int  s;\r
-          SKP_int  i;\r
-\r
-    /* Check that each index is within valid range */\r
-    SKP_assert( 0 <= NLSFIndices[ 0 ] && NLSFIndices[ 0 ] < psNLSF_CB->CBStages[ 0 ].nVectors );\r
-\r
-    /* Point to the first vector element */\r
-    pCB_element = &psNLSF_CB->CBStages[ 0 ].CB_NLSF_Q8[ SKP_SMULBB( (SKP_int)NLSFIndices[ 0 ], LPC_order ) ];\r
-\r
-    /* Initialize with the codebook vector from stage 0 */\r
-    for( i = 0; i < LPC_order; i++ ) {\r
-        pNLSF[ i ] = ( SKP_float )pCB_element[ i ];\r
-    }\r
-          \r
-    for( s = 1; s < psNLSF_CB->nStages; s++ ) {\r
-        /* Check that each index is within valid range */\r
-        SKP_assert( 0 <= NLSFIndices[ s ] && NLSFIndices[ s ] < psNLSF_CB->CBStages[ s ].nVectors );\r
-\r
-        if( LPC_order == 16 ) {\r
-            /* Point to the first vector element */\r
-            pCB_element = &psNLSF_CB->CBStages[ s ].CB_NLSF_Q8[ 16 * (SKP_int)NLSFIndices[ s ] ];\r
-\r
-            /* Add the codebook vector from the current stage */\r
-            pNLSF[ 0 ]  += ( SKP_float )pCB_element[ 0 ];\r
-            pNLSF[ 1 ]  += ( SKP_float )pCB_element[ 1 ];\r
-            pNLSF[ 2 ]  += ( SKP_float )pCB_element[ 2 ];\r
-            pNLSF[ 3 ]  += ( SKP_float )pCB_element[ 3 ];\r
-            pNLSF[ 4 ]  += ( SKP_float )pCB_element[ 4 ];\r
-            pNLSF[ 5 ]  += ( SKP_float )pCB_element[ 5 ];\r
-            pNLSF[ 6 ]  += ( SKP_float )pCB_element[ 6 ];\r
-            pNLSF[ 7 ]  += ( SKP_float )pCB_element[ 7 ];\r
-            pNLSF[ 8 ]  += ( SKP_float )pCB_element[ 8 ];\r
-            pNLSF[ 9 ]  += ( SKP_float )pCB_element[ 9 ];\r
-            pNLSF[ 10 ] += ( SKP_float )pCB_element[ 10 ];\r
-            pNLSF[ 11 ] += ( SKP_float )pCB_element[ 11 ];\r
-            pNLSF[ 12 ] += ( SKP_float )pCB_element[ 12 ];\r
-            pNLSF[ 13 ] += ( SKP_float )pCB_element[ 13 ];\r
-            pNLSF[ 14 ] += ( SKP_float )pCB_element[ 14 ];\r
-            pNLSF[ 15 ] += ( SKP_float )pCB_element[ 15 ];\r
-        } else {\r
-            /* Point to the first vector element */\r
-            pCB_element = &psNLSF_CB->CBStages[ s ].CB_NLSF_Q8[ (SKP_int)NLSFIndices[ s ] * LPC_order ];\r
-\r
-            /* Add the codebook vector from the current stage */\r
-            for( i = 0; i < LPC_order; i++ ) {\r
-                pNLSF[ i ] += ( SKP_float )pCB_element[ i ];\r
-            }\r
-        }\r
-    }\r
-\r
-    /* Add 1/2 in Q8 and convert to Q0 */\r
-    for( i = 0; i < LPC_order; i++ ) {\r
-        pNLSF[ i ] += 128.0f;\r
-        pNLSF[ i ] *= ( 1.0f / 256.0f );\r
-    }\r
-\r
-    /* NLSF stabilization */\r
-    SKP_Silk_NLSF_stabilize_FLP( pNLSF, psNLSF_CB->NDeltaMin_Q15, LPC_order );\r
-}\r
diff --git a/src_FLP/SKP_Silk_NLSF_MSVQ_encode_FLP.c b/src_FLP/SKP_Silk_NLSF_MSVQ_encode_FLP.c
deleted file mode 100644 (file)
index 416a1ce..0000000
+++ /dev/null
@@ -1,221 +0,0 @@
-/***********************************************************************\r
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
-Redistribution and use in source and binary forms, with or without \r
-modification, (subject to the limitations in the disclaimer below) \r
-are permitted provided that the following conditions are met:\r
-- Redistributions of source code must retain the above copyright notice,\r
-this list of conditions and the following disclaimer.\r
-- Redistributions in binary form must reproduce the above copyright \r
-notice, this list of conditions and the following disclaimer in the \r
-documentation and/or other materials provided with the distribution.\r
-- Neither the name of Skype Limited, nor the names of specific \r
-contributors, may be used to endorse or promote products derived from \r
-this software without specific prior written permission.\r
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED \r
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND \r
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,\r
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND \r
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \r
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \r
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF \r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON \r
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \r
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-***********************************************************************/\r
-\r
-#include "SKP_Silk_main_FLP.h"\r
-\r
-/***********************/\r
-/* NLSF vector encoder */\r
-/***********************/\r
-void SKP_Silk_NLSF_MSVQ_encode_FLP(\r
-          SKP_int8                  *NLSFIndices,       /* O    Codebook path vector [ CB_STAGES ]      */\r
-          SKP_float                 *pNLSF,             /* I/O  Quantized NLSF vector [ LPC_ORDER ]     */\r
-    const SKP_Silk_NLSF_CB_struct   *psNLSF_CB,         /* I    Codebook object                         */\r
-    const SKP_float                 *pNLSF_q_prev,      /* I    Prev. quantized NLSF vector [LPC_ORDER] */\r
-    const SKP_float                 *pW,                /* I    NLSF weight vector [ LPC_ORDER ]        */\r
-    const SKP_float                 NLSF_mu,            /* I    Rate weight for the RD optimization     */\r
-    const SKP_float                 NLSF_mu_fluc_red,   /* I    Fluctuation reduction error weight      */\r
-    const SKP_int                   NLSF_MSVQ_Survivors,/* I    Max survivors from each stage           */\r
-    const SKP_int                   LPC_order,          /* I    LPC order                               */\r
-    const SKP_int                   deactivate_fluc_red /* I    Deactivate fluctuation reduction        */\r
-)\r
-{\r
-    SKP_int     i, s, k, cur_survivors, prev_survivors, min_survivors, input_index, cb_index, bestIndex;\r
-    SKP_float   rateDistThreshold;\r
-#if( NLSF_MSVQ_FLUCTUATION_REDUCTION == 1 )\r
-    SKP_float   se, wsse, bestRateDist;\r
-#endif\r
-\r
-    SKP_float   pRateDist[      NLSF_MSVQ_TREE_SEARCH_MAX_VECTORS_EVALUATED ];\r
-    SKP_float   pRate[          MAX_NLSF_MSVQ_SURVIVORS ];\r
-    SKP_float   pRate_new[      MAX_NLSF_MSVQ_SURVIVORS ];\r
-    SKP_int     pTempIndices[   MAX_NLSF_MSVQ_SURVIVORS ];\r
-    SKP_int8    pPath[          MAX_NLSF_MSVQ_SURVIVORS * NLSF_MSVQ_MAX_CB_STAGES ];\r
-    SKP_int8    pPath_new[      MAX_NLSF_MSVQ_SURVIVORS * NLSF_MSVQ_MAX_CB_STAGES ];\r
-    SKP_float   pRes_Q8[        MAX_NLSF_MSVQ_SURVIVORS * MAX_LPC_ORDER ];\r
-    SKP_float   pRes_Q8_new[    MAX_NLSF_MSVQ_SURVIVORS * MAX_LPC_ORDER ];\r
-\r
-    const SKP_float *pConstFloat;\r
-          SKP_float *pFloat;\r
-    const SKP_int8  *pConstInt8;\r
-          SKP_int8  *pInt8;\r
-    const SKP_int8  *pCB_element;\r
-    const SKP_Silk_NLSF_CBS *pCurrentCBStage;\r
-\r
-    SKP_assert( NLSF_MSVQ_Survivors <= MAX_NLSF_MSVQ_SURVIVORS );\r
-\r
-#ifdef SAVE_ALL_INTERNAL_DATA\r
-    DEBUG_STORE_DATA( NLSF.dat,    pNLSF,    LPC_order * sizeof( SKP_float ) );\r
-    DEBUG_STORE_DATA( WNLSF.dat,   pW,       LPC_order * sizeof( SKP_float ) );\r
-    DEBUG_STORE_DATA( NLSF_mu.dat, &NLSF_mu,             sizeof( SKP_float ) );\r
-#endif\r
-\r
-    cur_survivors = NLSF_MSVQ_Survivors;\r
-\r
-    /****************************************************/\r
-    /* Tree search for the multi-stage vector quantizer */\r
-    /****************************************************/\r
-\r
-    /* Clear accumulated rates */\r
-    SKP_memset( pRate, 0, NLSF_MSVQ_Survivors * sizeof( SKP_float ) );\r
-\r
-    /* Subtract 1/2 from NLSF input vector to create initial residual, and scale to Q8 */\r
-    for( i = 0; i < LPC_order; i++ ) {\r
-        pRes_Q8[ i ] = ( pNLSF[ i ] - 0.5f ) * 256.0f;        \r
-    }\r
-\r
-    /* Set first stage values */\r
-    prev_survivors = 1;\r
-\r
-    /* Minimum number of survivors */\r
-    min_survivors = NLSF_MSVQ_Survivors / 2;\r
-\r
-    /* Loop over all stages */\r
-    for( s = 0; s < psNLSF_CB->nStages; s++ ) {\r
-\r
-        /* Set a pointer to the current stage codebook */\r
-        pCurrentCBStage = &psNLSF_CB->CBStages[ s ];\r
-\r
-        /* Calculate the number of survivors in the current stage */\r
-        cur_survivors = SKP_min_32( NLSF_MSVQ_Survivors, prev_survivors * pCurrentCBStage->nVectors );\r
-\r
-#if( NLSF_MSVQ_FLUCTUATION_REDUCTION == 0 )\r
-        /* Find a single best survivor in the last stage, if we */\r
-        /* do not need candidates for fluctuation reduction     */\r
-        if( s == psNLSF_CB->nStages - 1 ) {\r
-            cur_survivors = 1;\r
-        }\r
-#endif\r
-        /* Nearest neighbor clustering for multiple input data vectors */\r
-        SKP_Silk_NLSF_VQ_rate_distortion_FLP( pRateDist, pCurrentCBStage, pRes_Q8, pW, pRate, NLSF_mu, prev_survivors, LPC_order );\r
-\r
-        /* Sort the rate-distortion errors */\r
-        SKP_Silk_insertion_sort_increasing_FLP( pRateDist, pTempIndices, prev_survivors * pCurrentCBStage->nVectors, cur_survivors );\r
-\r
-        /* Discard survivors with rate-distortion values too far above the best one */\r
-        rateDistThreshold = ( 1.0f + NLSF_MSVQ_Survivors * NLSF_MSVQ_SURV_MAX_REL_RD ) * pRateDist[ 0 ];\r
-        while( pRateDist[ cur_survivors - 1 ] > rateDistThreshold && cur_survivors > min_survivors ) {\r
-            cur_survivors--;\r
-        }\r
-\r
-        /* Update accumulated codebook contributions for the 'cur_survivors' best codebook indices */\r
-        for( k = 0; k < cur_survivors; k++ ) { \r
-            if( s > 0 ) {\r
-                /* Find the indices of the input and the codebook vector */\r
-                if( pCurrentCBStage->nVectors == 8 ) {\r
-                    input_index = SKP_RSHIFT( pTempIndices[ k ], 3 );\r
-                    cb_index    = pTempIndices[ k ] & 7;\r
-                } else {\r
-                    input_index = pTempIndices[ k ] / pCurrentCBStage->nVectors;  \r
-                    cb_index    = pTempIndices[ k ] - input_index * pCurrentCBStage->nVectors;\r
-                }\r
-            } else {\r
-                /* Find the indices of the input and the codebook vector */\r
-                input_index = 0;\r
-                cb_index    = pTempIndices[ k ];\r
-            }\r
-\r
-            /* Subtract new contribution from the previous residual vector for each of 'cur_survivors' */\r
-            pConstFloat = &pRes_Q8[ input_index * LPC_order ];\r
-            pCB_element = &pCurrentCBStage->CB_NLSF_Q8[ cb_index * LPC_order ];\r
-            pFloat      = &pRes_Q8_new[ k * LPC_order ];\r
-            for( i = 0; i < LPC_order; i++ ) {\r
-                pFloat[ i ] = pConstFloat[ i ] - pCB_element[ i ];\r
-            }\r
-\r
-            /* Update accumulated rate for stage 1 to the current */\r
-            pRate_new[ k ] = pRate[ input_index ] + 0.0625f * ( SKP_float )pCurrentCBStage->Rates_Q4[ cb_index ];\r
-\r
-            /* Copy paths from previous matrix, starting with the best path */\r
-            pConstInt8 = &pPath[ input_index * psNLSF_CB->nStages ];\r
-            pInt8      = &pPath_new[       k * psNLSF_CB->nStages ];\r
-            for( i = 0; i < s; i++ ) {\r
-                pInt8[ i ] = pConstInt8[ i ];\r
-            }\r
-            /* Write the current stage indices for the 'cur_survivors' to the best path matrix */\r
-            pInt8[ s ] = (SKP_int8)cb_index;\r
-        }\r
-\r
-        if( s < psNLSF_CB->nStages - 1 ) {\r
-            /* Copy NLSF residual matrix for next stage */\r
-            SKP_memcpy( pRes_Q8, pRes_Q8_new, cur_survivors * LPC_order * sizeof( SKP_float ) );\r
-\r
-            /* Copy rate vector for next stage */\r
-            SKP_memcpy( pRate, pRate_new, cur_survivors * sizeof( SKP_float ) );\r
-\r
-            /* Copy best path matrix for next stage */\r
-            SKP_memcpy( pPath, pPath_new, cur_survivors * psNLSF_CB->nStages * sizeof( SKP_int8) );\r
-        }\r
-\r
-        prev_survivors = cur_survivors;\r
-    }\r
-\r
-    /* (Preliminary) index of the best survivor, later to be decoded */\r
-    bestIndex = 0;\r
-\r
-#if( NLSF_MSVQ_FLUCTUATION_REDUCTION == 1 )\r
-    /******************************/\r
-    /* NLSF fluctuation reduction */\r
-    /******************************/\r
-    if( deactivate_fluc_red != 1 ) {\r
-    \r
-        /* Search among all survivors, now taking also weighted fluctuation errors into account */\r
-        bestRateDist = SKP_float_MAX;\r
-        for( s = 0; s < cur_survivors; s++ ) {\r
-            /* Decode survivor to compare with previous quantized NLSF vector */\r
-            SKP_Silk_NLSF_MSVQ_decode_FLP( pNLSF, psNLSF_CB, &pPath_new[ s * psNLSF_CB->nStages ], LPC_order );\r
-\r
-            /* Compare decoded NLSF vector with the previously quantized vector */ \r
-            wsse = 0;\r
-            for( i = 0; i < LPC_order; i += 2 ) {\r
-                /* Compute weighted squared quantization error for index i */\r
-                se = pNLSF[ i ] - pNLSF_q_prev[ i ];\r
-                wsse += pW[ i ] * se * se;\r
-\r
-                /* Compute weighted squared quantization error for index i + 1 */\r
-                se = pNLSF[ i + 1 ] - pNLSF_q_prev[ i + 1 ];\r
-                wsse += pW[ i + 1 ] * se * se;\r
-            }\r
-\r
-            /* Add the fluctuation reduction penalty to the rate distortion error */\r
-            wsse = pRateDist[s] + wsse * NLSF_mu_fluc_red;\r
-\r
-            /* Keep index of best survivor */\r
-            if( wsse < bestRateDist ) {\r
-                bestRateDist = wsse;\r
-                bestIndex = s;\r
-            }\r
-        }\r
-    }\r
-#endif\r
-\r
-    /* Copy best path to output argument */\r
-    SKP_memcpy( NLSFIndices, &pPath_new[ bestIndex * psNLSF_CB->nStages ], psNLSF_CB->nStages * sizeof( SKP_int8 ) );\r
-\r
-    /* Decode and stabilize the best survivor */\r
-    SKP_Silk_NLSF_MSVQ_decode_FLP( pNLSF, psNLSF_CB, NLSFIndices, LPC_order );\r
-\r
-}\r
diff --git a/src_FLP/SKP_Silk_NLSF_VQ_rate_distortion_FLP.c b/src_FLP/SKP_Silk_NLSF_VQ_rate_distortion_FLP.c
deleted file mode 100644 (file)
index c45b683..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/***********************************************************************\r
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
-Redistribution and use in source and binary forms, with or without \r
-modification, (subject to the limitations in the disclaimer below) \r
-are permitted provided that the following conditions are met:\r
-- Redistributions of source code must retain the above copyright notice,\r
-this list of conditions and the following disclaimer.\r
-- Redistributions in binary form must reproduce the above copyright \r
-notice, this list of conditions and the following disclaimer in the \r
-documentation and/or other materials provided with the distribution.\r
-- Neither the name of Skype Limited, nor the names of specific \r
-contributors, may be used to endorse or promote products derived from \r
-this software without specific prior written permission.\r
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED \r
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND \r
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,\r
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND \r
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \r
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \r
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF \r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON \r
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \r
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-***********************************************************************/\r
-\r
-#include "SKP_Silk_main_FLP.h"\r
-\r
-/* Rate-Distortion calculations for multiple input data vectors */\r
-void SKP_Silk_NLSF_VQ_rate_distortion_FLP(\r
-          SKP_float             *pRD,               /* O   Rate-distortion values [psNLSF_CBS_FLP->nVectors*N] */\r
-    const SKP_Silk_NLSF_CBS     *psNLSF_CBS,        /* I   NLSF codebook stage struct                          */\r
-    const SKP_float             *in,                /* I   Input vectors to be quantized                       */\r
-    const SKP_float             *w,                 /* I   Weight vector                                       */\r
-    const SKP_float             *rate_acc,          /* I   Accumulated rates from previous stage               */\r
-    const SKP_float             mu,                 /* I   Weight between weighted error and rate              */\r
-    const SKP_int               N,                  /* I   Number of input vectors to be quantized             */\r
-    const SKP_int               LPC_order           /* I   LPC order                                           */\r
-)\r
-{\r
-    SKP_float *pRD_vec;\r
-    SKP_int   i, n;\r
-\r
-    /* Compute weighted quantization errors for all input vectors over one codebook stage */\r
-    SKP_Silk_NLSF_VQ_sum_error_FLP( pRD, in, w, psNLSF_CBS->CB_NLSF_Q8, N, psNLSF_CBS->nVectors, LPC_order );\r
-\r
-    /* Loop over input vectors */\r
-    pRD_vec = pRD;\r
-    for( n = 0; n < N; n++ ) {\r
-        /* Add rate cost to error for each codebook vector */\r
-        for( i = 0; i < psNLSF_CBS->nVectors; i++ ) {\r
-            pRD_vec[ i ] += mu * ( rate_acc[n] + 0.0625f * ( SKP_float )psNLSF_CBS->Rates_Q4[ i ] );\r
-        }\r
-        pRD_vec += psNLSF_CBS->nVectors;\r
-    }\r
-}\r
diff --git a/src_FLP/SKP_Silk_NLSF_VQ_sum_error_FLP.c b/src_FLP/SKP_Silk_NLSF_VQ_sum_error_FLP.c
deleted file mode 100644 (file)
index 6e4df16..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-/***********************************************************************\r
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
-Redistribution and use in source and binary forms, with or without \r
-modification, (subject to the limitations in the disclaimer below) \r
-are permitted provided that the following conditions are met:\r
-- Redistributions of source code must retain the above copyright notice,\r
-this list of conditions and the following disclaimer.\r
-- Redistributions in binary form must reproduce the above copyright \r
-notice, this list of conditions and the following disclaimer in the \r
-documentation and/or other materials provided with the distribution.\r
-- Neither the name of Skype Limited, nor the names of specific \r
-contributors, may be used to endorse or promote products derived from \r
-this software without specific prior written permission.\r
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED \r
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND \r
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,\r
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND \r
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \r
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \r
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF \r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON \r
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \r
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-***********************************************************************/\r
-\r
-#include "SKP_Silk_main_FLP.h"\r
-\r
-/* compute weighted quantization errors for LPC_order element input vectors, over one codebook stage */\r
-void SKP_Silk_NLSF_VQ_sum_error_FLP(\r
-          SKP_float                 *err,               /* O    Weighted quantization errors [ N * K ]  */\r
-    const SKP_float                 *in_NLSF_Q8,        /* I    Input vectors [ N * LPC_order ]         */\r
-    const SKP_float                 *w,                 /* I    Weighting vectors [ N * LPC_order ]     */\r
-    const SKP_int8                  *pCB_NLSF_Q8,       /* I    Codebook vectors [ K * LPC_order ]      */\r
-    const SKP_int                   N,                  /* I    Number of input vectors                 */\r
-    const SKP_int                   K,                  /* I    Number of codebook vectors              */\r
-    const SKP_int                   LPC_order           /* I    LPC order                               */\r
-)\r
-{\r
-    SKP_int        i, n;\r
-    SKP_float      diff_Q8, sum_error_Q16;\r
-    SKP_float      Wcpy[ MAX_LPC_ORDER ];\r
-    const SKP_int8 *cb_vec_NLSF_Q8;\r
-\r
-    /* Copy to local stack */\r
-    SKP_memcpy( Wcpy, w, LPC_order * sizeof( SKP_float ) );\r
-\r
-    if( LPC_order == 16 ) {\r
-        /* Loop over input vectors */\r
-        for( n = 0; n < N; n++ ) {\r
-            /* Loop over codebook */\r
-            cb_vec_NLSF_Q8 = pCB_NLSF_Q8;\r
-            for( i = 0; i < K; i++ ) {\r
-                /* Compute weighted squared quantization error */\r
-                diff_Q8 = in_NLSF_Q8[ 0 ] - ( SKP_float )cb_vec_NLSF_Q8[ 0 ];\r
-                sum_error_Q16  = Wcpy[ 0 ] * diff_Q8 * diff_Q8;\r
-                diff_Q8 = in_NLSF_Q8[ 1 ] - ( SKP_float )cb_vec_NLSF_Q8[ 1 ];\r
-                sum_error_Q16 += Wcpy[ 1 ] * diff_Q8 * diff_Q8;\r
-                diff_Q8 = in_NLSF_Q8[ 2 ] - ( SKP_float )cb_vec_NLSF_Q8[ 2 ];\r
-                sum_error_Q16 += Wcpy[ 2 ] * diff_Q8 * diff_Q8;\r
-                diff_Q8 = in_NLSF_Q8[ 3 ] - ( SKP_float )cb_vec_NLSF_Q8[ 3 ];\r
-                sum_error_Q16 += Wcpy[ 3 ] * diff_Q8 * diff_Q8;\r
-                diff_Q8 = in_NLSF_Q8[ 4 ] - ( SKP_float )cb_vec_NLSF_Q8[ 4 ];\r
-                sum_error_Q16 += Wcpy[ 4 ] * diff_Q8 * diff_Q8;\r
-                diff_Q8 = in_NLSF_Q8[ 5 ] - ( SKP_float )cb_vec_NLSF_Q8[ 5 ];\r
-                sum_error_Q16 += Wcpy[ 5 ] * diff_Q8 * diff_Q8;\r
-                diff_Q8 = in_NLSF_Q8[ 6 ] - ( SKP_float )cb_vec_NLSF_Q8[ 6 ];\r
-                sum_error_Q16 += Wcpy[ 6 ] * diff_Q8 * diff_Q8;\r
-                diff_Q8 = in_NLSF_Q8[ 7 ] - ( SKP_float )cb_vec_NLSF_Q8[ 7 ];\r
-                sum_error_Q16 += Wcpy[ 7 ] * diff_Q8 * diff_Q8;\r
-                diff_Q8 = in_NLSF_Q8[ 8 ] - ( SKP_float )cb_vec_NLSF_Q8[ 8 ];\r
-                sum_error_Q16 += Wcpy[ 8 ] * diff_Q8 * diff_Q8;\r
-                diff_Q8 = in_NLSF_Q8[ 9 ] - ( SKP_float )cb_vec_NLSF_Q8[ 9 ];\r
-                sum_error_Q16 += Wcpy[ 9 ] * diff_Q8 * diff_Q8;\r
-                diff_Q8 = in_NLSF_Q8[ 10 ] - ( SKP_float )cb_vec_NLSF_Q8[ 10 ];\r
-                sum_error_Q16 += Wcpy[ 10 ] * diff_Q8 * diff_Q8;\r
-                diff_Q8 = in_NLSF_Q8[ 11 ] - ( SKP_float )cb_vec_NLSF_Q8[ 11 ];\r
-                sum_error_Q16 += Wcpy[ 11 ] * diff_Q8 * diff_Q8;\r
-                diff_Q8 = in_NLSF_Q8[ 12 ] - ( SKP_float )cb_vec_NLSF_Q8[ 12 ];\r
-                sum_error_Q16 += Wcpy[ 12 ] * diff_Q8 * diff_Q8;\r
-                diff_Q8 = in_NLSF_Q8[ 13 ] - ( SKP_float )cb_vec_NLSF_Q8[ 13 ];\r
-                sum_error_Q16 += Wcpy[ 13 ] * diff_Q8 * diff_Q8;\r
-                diff_Q8 = in_NLSF_Q8[ 14 ] - ( SKP_float )cb_vec_NLSF_Q8[ 14 ];\r
-                sum_error_Q16 += Wcpy[ 14 ] * diff_Q8 * diff_Q8;\r
-                diff_Q8 = in_NLSF_Q8[ 15 ] - ( SKP_float )cb_vec_NLSF_Q8[ 15 ];\r
-                sum_error_Q16 += Wcpy[ 15 ] * diff_Q8 * diff_Q8;\r
-\r
-                err[ i ] = ( 1.0f / 65536.0f ) * sum_error_Q16;\r
-                cb_vec_NLSF_Q8 += 16;\r
-            }\r
-            err        += K;\r
-            in_NLSF_Q8 += 16;\r
-        }\r
-    } else {\r
-        SKP_assert( LPC_order == 10 );\r
-\r
-        /* Loop over input vectors */\r
-        for( n = 0; n < N; n++ ) {\r
-            /* Loop over codebook */\r
-            cb_vec_NLSF_Q8 = pCB_NLSF_Q8;\r
-            for( i = 0; i < K; i++ ) {\r
-                /* Compute weighted squared quantization error */\r
-                diff_Q8 = in_NLSF_Q8[ 0 ] - ( SKP_float )cb_vec_NLSF_Q8[ 0 ];\r
-                sum_error_Q16  = Wcpy[ 0 ] * diff_Q8 * diff_Q8;\r
-                diff_Q8 = in_NLSF_Q8[ 1 ] - ( SKP_float )cb_vec_NLSF_Q8[ 1 ];\r
-                sum_error_Q16 += Wcpy[ 1 ] * diff_Q8 * diff_Q8;\r
-                diff_Q8 = in_NLSF_Q8[ 2 ] - ( SKP_float )cb_vec_NLSF_Q8[ 2 ];\r
-                sum_error_Q16 += Wcpy[ 2 ] * diff_Q8 * diff_Q8;\r
-                diff_Q8 = in_NLSF_Q8[ 3 ] - ( SKP_float )cb_vec_NLSF_Q8[ 3 ];\r
-                sum_error_Q16 += Wcpy[ 3 ] * diff_Q8 * diff_Q8;\r
-                diff_Q8 = in_NLSF_Q8[ 4 ] - ( SKP_float )cb_vec_NLSF_Q8[ 4 ];\r
-                sum_error_Q16 += Wcpy[ 4 ] * diff_Q8 * diff_Q8;\r
-                diff_Q8 = in_NLSF_Q8[ 5 ] - ( SKP_float )cb_vec_NLSF_Q8[ 5 ];\r
-                sum_error_Q16 += Wcpy[ 5 ] * diff_Q8 * diff_Q8;\r
-                diff_Q8 = in_NLSF_Q8[ 6 ] - ( SKP_float )cb_vec_NLSF_Q8[ 6 ];\r
-                sum_error_Q16 += Wcpy[ 6 ] * diff_Q8 * diff_Q8;\r
-                diff_Q8 = in_NLSF_Q8[ 7 ] - ( SKP_float )cb_vec_NLSF_Q8[ 7 ];\r
-                sum_error_Q16 += Wcpy[ 7 ] * diff_Q8 * diff_Q8;\r
-                diff_Q8 = in_NLSF_Q8[ 8 ] - ( SKP_float )cb_vec_NLSF_Q8[ 8 ];\r
-                sum_error_Q16 += Wcpy[ 8 ] * diff_Q8 * diff_Q8;\r
-                diff_Q8 = in_NLSF_Q8[ 9 ] - ( SKP_float )cb_vec_NLSF_Q8[ 9 ];\r
-                sum_error_Q16 += Wcpy[ 9 ] * diff_Q8 * diff_Q8;\r
-\r
-                err[ i ] = ( 1.0f / 65536.0f ) * sum_error_Q16;\r
-                cb_vec_NLSF_Q8 += 10;\r
-            }\r
-            err        += K;\r
-            in_NLSF_Q8 += 10;\r
-        }\r
-    }\r
-}\r
index 028729c..77de4ea 100644 (file)
@@ -184,7 +184,7 @@ SKP_INLINE SKP_int SKP_Silk_setup_fs(
             /* Only allowed when the payload buffer is empty */\r
             psEnc->sCmn.nFramesPerPacket = 1;\r
             psEnc->sCmn.nb_subfr = MAX_NB_SUBFR >> 1;\r
-            psEnc->sPred.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS_2_SF, fs_kHz );\r
+            psEnc->sCmn.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS_2_SF, fs_kHz );\r
             if( psEnc->sCmn.fs_kHz == 8 ) {\r
                 psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_NB_iCDF;\r
             } else {\r
@@ -193,7 +193,7 @@ SKP_INLINE SKP_int SKP_Silk_setup_fs(
         } else {\r
             psEnc->sCmn.nFramesPerPacket = SKP_DIV32_16( PacketSize_ms, MAX_FRAME_LENGTH_MS );\r
             psEnc->sCmn.nb_subfr = MAX_NB_SUBFR;\r
-            psEnc->sPred.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS, fs_kHz );\r
+            psEnc->sCmn.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS, fs_kHz );\r
             if( psEnc->sCmn.fs_kHz == 8 ) {\r
                 psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_NB_iCDF;\r
             } else {\r
@@ -206,24 +206,14 @@ SKP_INLINE SKP_int SKP_Silk_setup_fs(
     /* Set internal sampling frequency */\r
     if( psEnc->sCmn.fs_kHz != fs_kHz ) {\r
         /* reset part of the state */\r
-        SKP_memset( &psEnc->sShape,          0, sizeof( SKP_Silk_shape_state_FLP ) );\r
-        SKP_memset( &psEnc->sPrefilt,        0, sizeof( SKP_Silk_prefilter_state_FLP ) );\r
-        SKP_memset( &psEnc->sCmn.sNSQ,       0, sizeof( SKP_Silk_nsq_state ) );\r
-        SKP_memset( &psEnc->sPred,           0, sizeof( SKP_Silk_predict_state_FLP ) );\r
-        SKP_memset( psEnc->sPred.prev_NLSFq, 0, sizeof( psEnc->sPred.prev_NLSFq ) );\r
-#if SWITCH_TRANSITION_FILTERING\r
-        SKP_memset( psEnc->sCmn.sLP.In_LP_State, 0, sizeof( psEnc->sCmn.sLP.In_LP_State ) );\r
-        if( psEnc->sCmn.sLP.mode == 1 ) {\r
-            /* Begin transition phase */\r
-            psEnc->sCmn.sLP.transition_frame_no = 1;\r
-        } else {\r
-            /* End transition phase */\r
-            psEnc->sCmn.sLP.transition_frame_no = 0;\r
-        }\r
-#endif\r
-        psEnc->sCmn.inputBufIx          = 0;\r
-        psEnc->sCmn.nFramesAnalyzed     = 0;\r
-        psEnc->sCmn.TargetRate_bps      = 0; /* Ensures that psEnc->SNR_dB is recomputed */\r
+        SKP_memset( &psEnc->sShape,               0, sizeof( SKP_Silk_shape_state_FLP ) );\r
+        SKP_memset( &psEnc->sPrefilt,             0, sizeof( SKP_Silk_prefilter_state_FLP ) );\r
+        SKP_memset( &psEnc->sCmn.sNSQ,            0, sizeof( SKP_Silk_nsq_state ) );\r
+        SKP_memset( psEnc->sCmn.prev_NLSFq_Q15,   0, sizeof( psEnc->sCmn.prev_NLSFq_Q15 ) );\r
+        SKP_memset( &psEnc->sCmn.sLP.In_LP_State, 0, sizeof( psEnc->sCmn.sLP.In_LP_State ) );\r
+        psEnc->sCmn.inputBufIx                  = 0;\r
+        psEnc->sCmn.nFramesAnalyzed             = 0;\r
+        psEnc->sCmn.TargetRate_bps              = 0; /* Ensures that psEnc->SNR_dB is recomputed */\r
 \r
         /* Initialize non-zero parameters */\r
         psEnc->sCmn.prevLag                     = 100;\r
@@ -263,30 +253,23 @@ SKP_INLINE SKP_int SKP_Silk_setup_fs(
         psEnc->sCmn.frame_length   = psEnc->sCmn.subfr_length * psEnc->sCmn.nb_subfr;\r
         psEnc->sCmn.ltp_mem_length = LTP_MEM_LENGTH_MS * fs_kHz; \r
         psEnc->sCmn.la_pitch       = LA_PITCH_MS * fs_kHz;\r
-        psEnc->sPred.min_pitch_lag =  3 * fs_kHz;\r
-        psEnc->sPred.max_pitch_lag = 18 * fs_kHz;\r
+        psEnc->sCmn.max_pitch_lag = 18 * fs_kHz;\r
         if( psEnc->sCmn.nb_subfr == MAX_NB_SUBFR ){\r
-            psEnc->sPred.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS, fs_kHz );\r
+            psEnc->sCmn.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS, fs_kHz );\r
         } else if( psEnc->sCmn.nb_subfr == MAX_NB_SUBFR / 2 ){\r
-            psEnc->sPred.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS_2_SF, fs_kHz );\r
+            psEnc->sCmn.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS_2_SF, fs_kHz );\r
         } else {\r
             /* Unsupported number of frames */\r
             SKP_assert( 0 );\r
         }\r
         if( psEnc->sCmn.fs_kHz == 16 ) {\r
             psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_WB, 9 );\r
-            psEnc->sCmn.bitrate_threshold_up    = SKP_int32_MAX;\r
-            psEnc->sCmn.bitrate_threshold_down  = WB2MB_BITRATE_BPS; \r
             psEnc->sCmn.pitch_lag_low_bits_iCDF = SKP_Silk_uniform8_iCDF;\r
         } else if( psEnc->sCmn.fs_kHz == 12 ) {\r
             psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_MB, 9 );\r
-            psEnc->sCmn.bitrate_threshold_up    = MB2WB_BITRATE_BPS;\r
-            psEnc->sCmn.bitrate_threshold_down  = MB2NB_BITRATE_BPS;\r
             psEnc->sCmn.pitch_lag_low_bits_iCDF = SKP_Silk_uniform6_iCDF;\r
         } else if( psEnc->sCmn.fs_kHz == 8 ) {\r
             psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_NB, 9 );\r
-            psEnc->sCmn.bitrate_threshold_up    = NB2MB_BITRATE_BPS;\r
-            psEnc->sCmn.bitrate_threshold_down  = 0;\r
             psEnc->sCmn.pitch_lag_low_bits_iCDF = SKP_Silk_uniform4_iCDF;\r
         } else {\r
             /* unsupported sampling rate */\r
index eb3eac9..5d4d269 100644 (file)
@@ -78,13 +78,13 @@ TIC(ENCODE_FRAME)
     /* Voice Activity Detection */\r
     /****************************/\r
 TIC(VAD)\r
-    SKP_Silk_VAD_FLP( psEnc, &sEncCtrl, psEnc->sCmn.inputBuf );\r
+    ret = SKP_Silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf );\r
 TOC(VAD)\r
 \r
     /**************************************************/\r
     /* Convert speech activity into VAD and DTX flags */\r
     /**************************************************/\r
-    if( psEnc->speech_activity < SPEECH_ACTIVITY_DTX_THRES ) {\r
+    if( psEnc->sCmn.speech_activity_Q8 < SKP_FIX_CONST( SPEECH_ACTIVITY_DTX_THRES, 8 ) ) {\r
         psEnc->sCmn.indices.signalType = TYPE_NO_VOICE_ACTIVITY;\r
         psEnc->sCmn.noSpeechCounter++;\r
         if( psEnc->sCmn.noSpeechCounter > NO_SPEECH_FRAMES_BEFORE_DTX ) {\r
@@ -98,7 +98,7 @@ TOC(VAD)
     } else {\r
         psEnc->sCmn.noSpeechCounter = 0;\r
         psEnc->sCmn.inDTX           = 0;\r
-        psEnc->sCmn.indices.signalType       = TYPE_UNVOICED;\r
+        psEnc->sCmn.indices.signalType = TYPE_UNVOICED;\r
         psEnc->sCmn.VAD_flags[ psEnc->sCmn.nFramesAnalyzed ] = 1;\r
     }\r
 \r
@@ -108,7 +108,7 @@ TOC(VAD)
 TIC(HP_IN)\r
 #if HIGH_PASS_INPUT\r
     /* Variable high-pass filter */\r
-    SKP_Silk_HP_variable_cutoff_FLP( psEnc, &sEncCtrl, pIn_HP, psEnc->sCmn.inputBuf );\r
+    SKP_Silk_HP_variable_cutoff( &psEnc->sCmn, pIn_HP, psEnc->sCmn.inputBuf, psEnc->sCmn.frame_length );\r
 #else\r
     SKP_memcpy( pIn_HP, psEnc->sCmn.inputBuf, psEnc->sCmn.frame_length * sizeof( SKP_int16 ) );\r
 #endif\r
@@ -247,7 +247,6 @@ TOC(ENCODE_FRAME)
     //DEBUG_STORE_DATA( xfw.dat,                  xfw,                                 psEnc->sCmn.frame_length * sizeof( SKP_float ) );\r
     DEBUG_STORE_DATA( pitchL.dat,               sEncCtrl.pitchL,                                 MAX_NB_SUBFR * sizeof( SKP_int   ) );\r
     DEBUG_STORE_DATA( pitchG_quantized.dat,     sEncCtrl.LTPCoef,            psEnc->sCmn.nb_subfr * LTP_ORDER * sizeof( SKP_float ) );\r
-    DEBUG_STORE_DATA( pitch_freq_low_Hz.dat,    &sEncCtrl.pitch_freq_low_Hz,                                    sizeof( SKP_float ) );\r
     DEBUG_STORE_DATA( LTPcorr.dat,              &psEnc->LTPCorr,                                                sizeof( SKP_float ) );\r
     DEBUG_STORE_DATA( tilt.dat,                 &sEncCtrl.input_tilt,                                           sizeof( SKP_float ) );\r
     DEBUG_STORE_DATA( gains.dat,                sEncCtrl.Gains,                          psEnc->sCmn.nb_subfr * sizeof( SKP_float ) );\r
@@ -255,7 +254,7 @@ TOC(ENCODE_FRAME)
     DEBUG_STORE_DATA( nBits.dat,                &nBits,                                                         sizeof( SKP_int   ) );\r
     DEBUG_STORE_DATA( current_SNR_db.dat,       &sEncCtrl.current_SNR_dB,                                       sizeof( SKP_float ) );\r
     DEBUG_STORE_DATA( quantOffsetType.dat,      &sEncCtrl.sCmn.quantOffsetType,                                 sizeof( SKP_int   ) );\r
-    DEBUG_STORE_DATA( speech_activity.dat,      &psEnc->speech_activity,                                        sizeof( SKP_float ) );\r
+    DEBUG_STORE_DATA( speech_activity_q8.dat,   &psEnc->speech_activity_Q8,                                     sizeof( SKP_in    ) );\r
     DEBUG_STORE_DATA( input_quality_bands.dat,  sEncCtrl.input_quality_bands,                     VAD_N_BANDS * sizeof( SKP_float ) );\r
     DEBUG_STORE_DATA( signalType.dat,           &sEncCtrl.sCmn.signalType,                                      sizeof( SKP_int   ) ); \r
     DEBUG_STORE_DATA( ratelevel.dat,            &sEncCtrl.sCmn.RateLevelIndex,                                  sizeof( SKP_int   ) ); \r
@@ -285,7 +284,7 @@ void SKP_Silk_LBRR_encode_FLP(
     /*******************************************/\r
     /* Control use of inband LBRR              */\r
     /*******************************************/\r
-    if( psEnc->sCmn.LBRR_enabled && psEnc->speech_activity > LBRR_SPEECH_ACTIVITY_THRES ) {\r
+    if( psEnc->sCmn.LBRR_enabled && psEnc->sCmn.speech_activity_Q8 > SKP_FIX_CONST( LBRR_SPEECH_ACTIVITY_THRES, 8 ) ) {\r
         psEnc->sCmn.LBRR_flags[ psEnc->sCmn.nFramesAnalyzed ] = 1;\r
 \r
         /* Copy noise shaping quantizer state and quantization indices from regular encoding */\r
index 8f6be16..a3215cf 100644 (file)
@@ -29,9 +29,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "SKP_Silk_tuning_parameters.h"\r
 \r
 void SKP_Silk_find_LPC_FLP(\r
-          SKP_float                 NLSF[],             /* O    NLSFs                                   */\r
+          SKP_int                   NLSF_Q15[],         /* O    NLSFs                                   */\r
           SKP_int8                  *interpIndex,       /* O    NLSF interp. index for NLSF interp.     */\r
-    const SKP_float                 prev_NLSFq[],       /* I    Previous NLSFs, for NLSF interpolation  */\r
+    const SKP_int                   prev_NLSFq_Q15[],   /* I    Previous NLSFs, for NLSF interpolation  */\r
     const SKP_int                   useInterpNLSFs,     /* I    Flag                                    */\r
     const SKP_int                   LPC_order,          /* I    LPC order                               */\r
     const SKP_float                 x[],                /* I    Input signal                            */\r
@@ -44,7 +44,8 @@ void SKP_Silk_find_LPC_FLP(
 \r
     /* Used only for NLSF interpolation */\r
     double      res_nrg, res_nrg_2nd, res_nrg_interp;\r
-    SKP_float   a_tmp[ MAX_LPC_ORDER ], NLSF0[ MAX_LPC_ORDER ];\r
+    SKP_int     NLSF0_Q15[ MAX_LPC_ORDER ];\r
+    SKP_float   a_tmp[ MAX_LPC_ORDER ];\r
     SKP_float   LPC_res[ ( MAX_FRAME_LENGTH + MAX_NB_SUBFR * MAX_LPC_ORDER ) / 2 ];\r
 \r
     /* Default: No interpolation */\r
@@ -61,16 +62,16 @@ void SKP_Silk_find_LPC_FLP(
         SKP_Silk_bwexpander_FLP( a_tmp, LPC_order, FIND_LPC_CHIRP );\r
 \r
         /* Convert to NLSFs */\r
-        SKP_Silk_A2NLSF_FLP( NLSF, a_tmp, LPC_order );\r
+        SKP_Silk_A2NLSF_FLP( NLSF_Q15, a_tmp, LPC_order );\r
 \r
         /* Search over interpolation indices to find the one with lowest residual energy */\r
         res_nrg_2nd = SKP_float_MAX;\r
         for( k = 3; k >= 0; k-- ) {\r
             /* Interpolate NLSFs for first half */\r
-            SKP_Silk_interpolate_wrapper_FLP( NLSF0, prev_NLSFq, NLSF, 0.25f * k, LPC_order );\r
+            SKP_Silk_interpolate( NLSF0_Q15, prev_NLSFq_Q15, NLSF_Q15, k, LPC_order );\r
 \r
             /* Convert to LPC for residual energy evaluation */\r
-            SKP_Silk_NLSF2A_stable_FLP( a_tmp, NLSF0, LPC_order );\r
+            SKP_Silk_NLSF2A_stable_FLP( a_tmp, NLSF0_Q15, LPC_order );\r
 \r
             /* Calculate residual energy with LSF interpolation */\r
             SKP_Silk_LPC_analysis_filter_FLP( LPC_res, a_tmp, x, 2 * subfr_length, LPC_order );\r
@@ -93,7 +94,7 @@ void SKP_Silk_find_LPC_FLP(
 \r
     if( *interpIndex == 4 ) {\r
         /* NLSF interpolation is currently inactive, calculate NLSFs from full frame AR coefficients */\r
-        SKP_Silk_A2NLSF_FLP( NLSF, a, LPC_order );\r
+        SKP_Silk_A2NLSF_FLP( NLSF_Q15, a, LPC_order );\r
     }\r
 \r
 }\r
index f35899d..c8de0e2 100644 (file)
@@ -36,7 +36,6 @@ void SKP_Silk_find_pitch_lags_FLP(
     const SKP_float                 x[]                 /* I    Speech signal                           */\r
 )\r
 {\r
-    SKP_Silk_predict_state_FLP *psPredSt = &psEnc->sPred;\r
     SKP_int   buf_len;\r
     SKP_float thrhld, res_nrg;\r
     const SKP_float *x_buf_ptr, *x_buf;\r
@@ -52,7 +51,7 @@ void SKP_Silk_find_pitch_lags_FLP(
     buf_len = psEnc->sCmn.la_pitch + psEnc->sCmn.frame_length + psEnc->sCmn.ltp_mem_length;\r
 \r
     /* Safty check */\r
-    SKP_assert( buf_len >= psPredSt->pitch_LPC_win_length );\r
+    SKP_assert( buf_len >= psEnc->sCmn.pitch_LPC_win_length );\r
 \r
     x_buf = x - psEnc->sCmn.ltp_mem_length;\r
 \r
@@ -63,22 +62,22 @@ void SKP_Silk_find_pitch_lags_FLP(
     /* Calculate windowed signal */\r
     \r
     /* First LA_LTP samples */\r
-    x_buf_ptr = x_buf + buf_len - psPredSt->pitch_LPC_win_length;\r
+    x_buf_ptr = x_buf + buf_len - psEnc->sCmn.pitch_LPC_win_length;\r
     Wsig_ptr  = Wsig;\r
     SKP_Silk_apply_sine_window_FLP( Wsig_ptr, x_buf_ptr, 1, psEnc->sCmn.la_pitch );\r
 \r
     /* Middle non-windowed samples */\r
     Wsig_ptr  += psEnc->sCmn.la_pitch;\r
     x_buf_ptr += psEnc->sCmn.la_pitch;\r
-    SKP_memcpy( Wsig_ptr, x_buf_ptr, ( psPredSt->pitch_LPC_win_length - ( psEnc->sCmn.la_pitch << 1 ) ) * sizeof( SKP_float ) );\r
+    SKP_memcpy( Wsig_ptr, x_buf_ptr, ( psEnc->sCmn.pitch_LPC_win_length - ( psEnc->sCmn.la_pitch << 1 ) ) * sizeof( SKP_float ) );\r
 \r
     /* Last LA_LTP samples */\r
-    Wsig_ptr  += psPredSt->pitch_LPC_win_length - ( psEnc->sCmn.la_pitch << 1 );\r
-    x_buf_ptr += psPredSt->pitch_LPC_win_length - ( psEnc->sCmn.la_pitch << 1 );\r
+    Wsig_ptr  += psEnc->sCmn.pitch_LPC_win_length - ( psEnc->sCmn.la_pitch << 1 );\r
+    x_buf_ptr += psEnc->sCmn.pitch_LPC_win_length - ( psEnc->sCmn.la_pitch << 1 );\r
     SKP_Silk_apply_sine_window_FLP( Wsig_ptr, x_buf_ptr, 2, psEnc->sCmn.la_pitch );\r
 \r
     /* Calculate autocorrelation sequence */\r
-    SKP_Silk_autocorrelation_FLP( auto_corr, Wsig, psPredSt->pitch_LPC_win_length, psEnc->sCmn.pitchEstimationLPCOrder + 1 );\r
+    SKP_Silk_autocorrelation_FLP( auto_corr, Wsig, psEnc->sCmn.pitch_LPC_win_length, psEnc->sCmn.pitchEstimationLPCOrder + 1 );\r
 \r
     /* Add white noise, as a fraction of the energy */\r
     auto_corr[ 0 ] += auto_corr[ 0 ] * FIND_PITCH_WHITE_NOISE_FRACTION + 1;\r
@@ -100,13 +99,13 @@ void SKP_Silk_find_pitch_lags_FLP(
     /*****************************************/\r
     SKP_Silk_LPC_analysis_filter_FLP( res, A, x_buf, buf_len, psEnc->sCmn.pitchEstimationLPCOrder );\r
 \r
-    if( psEnc->sCmn.indices.signalType != TYPE_NO_VOICE_ACTIVITY ) {\r
+    if( psEnc->sCmn.indices.signalType != TYPE_NO_VOICE_ACTIVITY && psEnc->sCmn.first_frame_after_reset == 0 ) {\r
         /* Threshold for pitch estimator */\r
         thrhld  = 0.6f;\r
         thrhld -= 0.004f * psEnc->sCmn.pitchEstimationLPCOrder;\r
-        thrhld -= 0.1f   * psEnc->speech_activity;\r
+        thrhld -= 0.1f   * psEnc->sCmn.speech_activity_Q8 * ( 1.0f /  256.0f );\r
         thrhld -= 0.15f  * (psEnc->sCmn.prevSignalType >> 1);\r
-        thrhld -= 0.1f   * psEncCtrl->input_tilt;\r
+        thrhld -= 0.1f   * psEnc->sCmn.input_tilt_Q15 * ( 1.0f / 32768.0f );\r
 \r
         /*****************************************/\r
         /* Call Pitch estimator                  */\r
index 5ef9a21..761ec5c 100644 (file)
@@ -38,7 +38,7 @@ void SKP_Silk_find_pred_coefs_FLP(
     SKP_int         i;\r
     SKP_float       WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ];\r
     SKP_float       invGains[ MAX_NB_SUBFR ], Wght[ MAX_NB_SUBFR ];\r
-    SKP_float       NLSF[ MAX_LPC_ORDER ];\r
+    SKP_int         NLSF_Q15[ MAX_LPC_ORDER ];\r
     const SKP_float *x_ptr;\r
     SKP_float       *x_pre_ptr, LPC_in_pre[ MAX_NB_SUBFR * MAX_LPC_ORDER + MAX_FRAME_LENGTH ];\r
 \r
@@ -94,14 +94,14 @@ void SKP_Silk_find_pred_coefs_FLP(
     }\r
 \r
     /* LPC_in_pre contains the LTP-filtered input for voiced, and the unfiltered input for unvoiced */\r
-    SKP_Silk_find_LPC_FLP( NLSF, &psEnc->sCmn.indices.NLSFInterpCoef_Q2, psEnc->sPred.prev_NLSFq\r
+    SKP_Silk_find_LPC_FLP( NLSF_Q15, &psEnc->sCmn.indices.NLSFInterpCoef_Q2, psEnc->sCmn.prev_NLSFq_Q15\r
         psEnc->sCmn.useInterpolatedNLSFs * ( 1 - psEnc->sCmn.first_frame_after_reset ), psEnc->sCmn.predictLPCOrder, \r
         LPC_in_pre, psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder, psEnc->sCmn.nb_subfr );\r
 \r
 \r
     /* Quantize LSFs */\r
 TIC(LSF_quant);\r
-    SKP_Silk_process_NLSFs_FLP( psEnc, psEncCtrl, NLSF );\r
+    SKP_Silk_process_NLSFs_FLP( &psEnc->sCmn, psEncCtrl->PredCoef, NLSF_Q15, psEnc->sCmn.prev_NLSFq_Q15 );\r
 TOC(LSF_quant);\r
 \r
     /* Calculate residual energy using quantized LPC coefficients */\r
@@ -109,6 +109,6 @@ TOC(LSF_quant);
         psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.predictLPCOrder );\r
 \r
     /* Copy to prediction struct for use in next frame for fluctuation reduction */\r
-    SKP_memcpy( psEnc->sPred.prev_NLSFq, NLSF, psEnc->sCmn.predictLPCOrder * sizeof( SKP_float ) );\r
+    SKP_memcpy( psEnc->sCmn.prev_NLSFq_Q15, NLSF_Q15, sizeof( psEnc->sCmn.prev_NLSFq_Q15 ) );\r
 }\r
 \r
index 4b9ffdf..e3eb187 100644 (file)
@@ -40,8 +40,8 @@ SKP_int SKP_Silk_init_encoder_FLP(
     SKP_memset( psEnc, 0, sizeof( SKP_Silk_encoder_state_FLP ) );\r
 \r
 #if HIGH_PASS_INPUT\r
-    psEnc->variable_HP_smth1 = SKP_Silk_log2( 70.0 );\r
-    psEnc->variable_HP_smth2 = SKP_Silk_log2( 70.0 );\r
+    psEnc->sCmn.variable_HP_smth1_Q15 = 200844; /* = SKP_Silk_log2(70)_Q0; */\r
+    psEnc->sCmn.variable_HP_smth2_Q15 = 200844; /* = SKP_Silk_log2(70)_Q0; */\r
 #endif\r
 \r
     /* Used to deactivate e.g. LSF interpolation and fluctuation reduction */\r
index d406421..cbf2077 100644 (file)
@@ -48,14 +48,6 @@ extern "C"
 /* Encoder Functions */\r
 /*********************/\r
 \r
-/* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */\r
-void SKP_Silk_HP_variable_cutoff_FLP(\r
-    SKP_Silk_encoder_state_FLP      *psEnc,             /* I/O  Encoder state FLP                       */\r
-    SKP_Silk_encoder_control_FLP    *psEncCtrl,         /* I/O  Encoder control FLP                     */\r
-          SKP_int16                 *out,               /* O    High-pass filtered output signal        */\r
-    const SKP_int16                 *in                 /* I    Input signal                            */\r
-);\r
-\r
 /* Encoder main function */\r
 SKP_int SKP_Silk_encode_frame_FLP( \r
     SKP_Silk_encoder_state_FLP      *psEnc,             /* I/O  Encoder state FLP                       */\r
@@ -141,9 +133,9 @@ void SKP_Silk_find_pred_coefs_FLP(
 \r
 /* LPC analysis */\r
 void SKP_Silk_find_LPC_FLP(\r
-          SKP_float                 NLSF[],             /* O    NLSFs                                   */\r
+          SKP_int                   NLSF_Q15[],         /* O    NLSFs                                   */\r
           SKP_int8                  *interpIndex,       /* O    NLSF interp. index for NLSF interp.     */\r
-    const SKP_float                 prev_NLSFq[],       /* I    Previous NLSFs, for NLSF interpolation  */\r
+    const SKP_int                   prev_NLSFq_Q15[],   /* I    Previous NLSFs, for NLSF interpolation  */\r
     const SKP_int                   useInterpNLSFs,     /* I    Flag                                    */\r
     const SKP_int                   LPC_order,          /* I    LPC order                               */\r
     const SKP_float                 x[],                /* I    Input signal                            */\r
@@ -212,54 +204,10 @@ void SKP_Silk_quant_LTP_gains_FLP(
 /******************/\r
 /* Limit, stabilize, and quantize NLSFs */\r
 void SKP_Silk_process_NLSFs_FLP(\r
-    SKP_Silk_encoder_state_FLP      *psEnc,             /* I/O  Encoder state FLP                       */\r
-    SKP_Silk_encoder_control_FLP    *psEncCtrl,         /* I/O  Encoder control FLP                     */\r
-    SKP_float                       *pNLSF              /* I/O  NLSFs (quantized output)                */\r
-);\r
-\r
-/* NLSF vector encoder */\r
-void SKP_Silk_NLSF_MSVQ_encode_FLP(\r
-          SKP_int8                  *NLSFIndices,       /* O    Codebook path vector [ CB_STAGES ]      */\r
-          SKP_float                 *pNLSF,             /* I/O  Quantized NLSF vector [ LPC_ORDER ]     */\r
-    const SKP_Silk_NLSF_CB_struct   *psNLSF_CB,         /* I    Codebook object                         */\r
-    const SKP_float                 *pNLSF_q_prev,      /* I    Prev. quantized NLSF vector [LPC_ORDER] */\r
-    const SKP_float                 *pW,                /* I    NLSF weight vector [ LPC_ORDER ]        */\r
-    const SKP_float                 NLSF_mu,            /* I    Rate weight for the RD optimization     */\r
-    const SKP_float                 NLSF_mu_fluc_red,   /* I    Fluctuation reduction error weight      */\r
-    const SKP_int                   NLSF_MSVQ_Survivors,/* I    Max survivors from each stage           */\r
-    const SKP_int                   LPC_order,          /* I    LPC order                               */\r
-    const SKP_int                   deactivate_fluc_red /* I    Deactivate fluctuation reduction        */\r
-);\r
-\r
-/* Rate-Distortion calculations for multiple input data vectors */\r
-void SKP_Silk_NLSF_VQ_rate_distortion_FLP(\r
-          SKP_float             *pRD,               /* O   Rate-distortion values [psNLSF_CBS_FLP->nVectors*N] */\r
-    const SKP_Silk_NLSF_CBS     *psNLSF_CBS,        /* I   NLSF codebook stage struct                          */\r
-    const SKP_float             *in,                /* I   Input vectors to be quantized                       */\r
-    const SKP_float             *w,                 /* I   Weight vector                                       */\r
-    const SKP_float             *rate_acc,          /* I   Accumulated rates from previous stage               */\r
-    const SKP_float             mu,                 /* I   Weight between weighted error and rate              */\r
-    const SKP_int               N,                  /* I   Number of input vectors to be quantized             */\r
-    const SKP_int               LPC_order           /* I   LPC order                                           */\r
-);\r
-\r
-/* Compute weighted quantization errors for an LPC_order element input vector, over one codebook stage */\r
-void SKP_Silk_NLSF_VQ_sum_error_FLP(\r
-          SKP_float                 *err,               /* O    Weighted quantization errors [ N * K ]  */\r
-    const SKP_float                 *in,                /* I    Input vectors [ N * LPC_order ]         */\r
-    const SKP_float                 *w,                 /* I    Weighting vectors [ N * LPC_order ]     */\r
-    const SKP_int8                  *pCB_NLSF_Q8,       /* I    Codebook vectors [ K * LPC_order ]      */\r
-    const SKP_int                   N,                  /* I    Number of input vectors                 */\r
-    const SKP_int                   K,                  /* I    Number of codebook vectors              */\r
-    const SKP_int                   LPC_order           /* I    LPC order                               */\r
-);\r
-\r
-/* NLSF vector decoder */\r
-void SKP_Silk_NLSF_MSVQ_decode_FLP(\r
-          SKP_float                 *pNLSF,             /* O    Decoded output vector [ LPC_ORDER ]     */\r
-    const SKP_Silk_NLSF_CB_struct   *psNLSF_CB,         /* I    NLSF codebook struct                    */  \r
-    const SKP_int8                  *NLSFIndices,       /* I    NLSF indices [ nStages ]                */\r
-    const SKP_int                   LPC_order           /* I    LPC order used                          */\r
+    SKP_Silk_encoder_state          *psEncC,                            /* I/O  Encoder state                               */\r
+    SKP_float                       PredCoef[ 2 ][ MAX_LPC_ORDER ],     /* O    Prediction coefficients                     */\r
+    SKP_int                         NLSF_Q15[      MAX_LPC_ORDER ],     /* I/O  Normalized LSFs (quant out) (0 - (2^15-1))  */\r
+    const SKP_int                   prev_NLSF_Q15[ MAX_LPC_ORDER ]      /* I    Previous Normalized LSFs (0 - (2^15-1))     */\r
 );\r
 \r
 /* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */\r
@@ -340,7 +288,7 @@ void SKP_Silk_apply_sine_window_FLP(
 \r
 /* Convert AR filter coefficients to NLSF parameters */\r
 void SKP_Silk_A2NLSF_FLP( \r
-          SKP_float                 *pNLSF,             /* O    NLSF vector      [ LPC_order ]          */\r
+          SKP_int                   *NLSF_Q15,          /* O    NLSF vector      [ LPC_order ]          */\r
     const SKP_float                 *pAR,               /* I    LPC coefficients [ LPC_order ]          */\r
     const SKP_int                   LPC_order           /* I    LPC order                               */\r
 );\r
@@ -348,14 +296,7 @@ void SKP_Silk_A2NLSF_FLP(
 /* Convert NLSF parameters to AR prediction filter coefficients */\r
 void SKP_Silk_NLSF2A_stable_FLP( \r
           SKP_float                 *pAR,               /* O    LPC coefficients [ LPC_order ]          */\r
-    const SKP_float                 *pNLSF,             /* I    NLSF vector      [ LPC_order ]          */\r
-    const SKP_int                   LPC_order           /* I    LPC order                               */\r
-);\r
-\r
-/* NLSF stabilizer, for a single input data vector */\r
-void SKP_Silk_NLSF_stabilize_FLP(\r
-          SKP_float                 *pNLSF,            /* I/O  (Un)stable NLSF vector [ LPC_order ]    */\r
-    const SKP_int                   *pNDelta_min_Q15,   /* I    Normalized delta min vector[LPC_order+1]*/\r
+    const SKP_int                   *NLSF_Q15,          /* I    NLSF vector      [ LPC_order ]          */\r
     const SKP_int                   LPC_order           /* I    LPC order                               */\r
 );\r
 \r
@@ -369,15 +310,6 @@ void SKP_Silk_interpolate_wrapper_FLP(
 );\r
 \r
 /****************************************/\r
-/* Floating-point Silk VAD wrapper      */\r
-/****************************************/\r
-SKP_int SKP_Silk_VAD_FLP(\r
-    SKP_Silk_encoder_state_FLP      *psEnc,             /* I/O  Encoder state FLP                       */\r
-    SKP_Silk_encoder_control_FLP    *psEncCtrl,         /* I/O  Encoder control FLP                     */\r
-    const SKP_int16                 *pIn                /* I    Input signal                            */\r
-);\r
-\r
-/****************************************/\r
 /* Floating-point Silk NSQ wrapper      */\r
 /****************************************/\r
 void SKP_Silk_NSQ_wrapper_FLP(\r
index 17a991e..001c3ac 100644 (file)
@@ -151,7 +151,7 @@ void SKP_Silk_noise_shape_analysis_FLP(
     /* GAIN CONTROL */\r
     /****************/\r
     /* Input quality is the average of the quality in the lowest two VAD bands */\r
-    psEncCtrl->input_quality = 0.5f * ( psEncCtrl->input_quality_bands[ 0 ] + psEncCtrl->input_quality_bands[ 1 ] );\r
+    psEncCtrl->input_quality = 0.5f * ( psEnc->sCmn.input_quality_bands_Q15[ 0 ] + psEnc->sCmn.input_quality_bands_Q15[ 1 ] ) * ( 1.0f / 32768.0f );\r
 \r
     /* Coding quality level, between 0.0 and 1.0 */\r
     psEncCtrl->coding_quality = SKP_sigmoid( 0.25f * ( psEncCtrl->current_SNR_dB - 18.0f ) );\r
@@ -159,7 +159,7 @@ void SKP_Silk_noise_shape_analysis_FLP(
     SNR_adj_dB = psEncCtrl->current_SNR_dB;\r
     if( psEnc->sCmn.useCBR == 0 ) {\r
         /* Reduce coding SNR during low speech activity */\r
-        b = 1.0f - psEnc->speech_activity;\r
+        b = 1.0f - psEnc->sCmn.speech_activity_Q8 * ( 1.0f /  256.0f );\r
         SNR_adj_dB -= BG_SNR_DECR_dB * psEncCtrl->coding_quality * ( 0.5f + 0.5f * psEncCtrl->input_quality ) * b * b;\r
     }\r
 \r
@@ -307,8 +307,8 @@ void SKP_Silk_noise_shape_analysis_FLP(
     /* Control low-frequency shaping and noise tilt */\r
     /************************************************/\r
     /* Less low frequency shaping for noisy inputs */\r
-    strength = LOW_FREQ_SHAPING * ( 1.0f + LOW_QUALITY_LOW_FREQ_SHAPING_DECR * ( psEncCtrl->input_quality_bands[ 0 ] - 1.0f ) );\r
-    strength *= psEnc->speech_activity;\r
+    strength = LOW_FREQ_SHAPING * ( 1.0f + LOW_QUALITY_LOW_FREQ_SHAPING_DECR * ( psEnc->sCmn.input_quality_bands_Q15[ 0 ] * ( 1.0f / 32768.0f ) - 1.0f ) );\r
+    strength *= psEnc->sCmn.speech_activity_Q8 * ( 1.0f /  256.0f );\r
     if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) {\r
         /* Reduce low frequencies quantization noise for periodic signals, depending on pitch lag */\r
         /*f = 400; freqz([1, -0.98 + 2e-4 * f], [1, -0.97 + 7e-4 * f], 2^12, Fs); axis([0, 1000, -10, 1])*/\r
@@ -318,7 +318,7 @@ void SKP_Silk_noise_shape_analysis_FLP(
             psEncCtrl->LF_AR_shp[ k ] =  1.0f - b - b * strength;\r
         }\r
         Tilt = - HP_NOISE_COEF - \r
-            (1 - HP_NOISE_COEF) * HARM_HP_NOISE_COEF * psEnc->speech_activity;\r
+            (1 - HP_NOISE_COEF) * HARM_HP_NOISE_COEF * psEnc->sCmn.speech_activity_Q8 * ( 1.0f /  256.0f );\r
     } else {\r
         b = 1.3f / psEnc->sCmn.fs_kHz;\r
         psEncCtrl->LF_MA_shp[ 0 ] = -1.0f + b;\r
diff --git a/src_FLP/SKP_Silk_process_NLSFs_FLP.c b/src_FLP/SKP_Silk_process_NLSFs_FLP.c
deleted file mode 100644 (file)
index 0f13a47..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/***********************************************************************\r
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
-Redistribution and use in source and binary forms, with or without \r
-modification, (subject to the limitations in the disclaimer below) \r
-are permitted provided that the following conditions are met:\r
-- Redistributions of source code must retain the above copyright notice,\r
-this list of conditions and the following disclaimer.\r
-- Redistributions in binary form must reproduce the above copyright \r
-notice, this list of conditions and the following disclaimer in the \r
-documentation and/or other materials provided with the distribution.\r
-- Neither the name of Skype Limited, nor the names of specific \r
-contributors, may be used to endorse or promote products derived from \r
-this software without specific prior written permission.\r
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED \r
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND \r
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,\r
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND \r
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \r
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \r
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF \r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON \r
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \r
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-***********************************************************************/\r
-\r
-#include <stdlib.h>\r
-#include "SKP_Silk_main_FLP.h"\r
-\r
-/* Limit, stabilize, convert and quantize NLSFs */\r
-void SKP_Silk_process_NLSFs_FLP(\r
-    SKP_Silk_encoder_state_FLP      *psEnc,             /* I/O  Encoder state FLP                       */\r
-    SKP_Silk_encoder_control_FLP    *psEncCtrl,         /* I/O  Encoder control FLP                     */\r
-    SKP_float                       *pNLSF              /* I/O  NLSFs (quantized output)                */\r
-)\r
-{\r
-    SKP_int     doInterpolate;\r
-    SKP_float   pNLSFW[ MAX_LPC_ORDER ];\r
-    SKP_float   NLSF_mu, NLSF_mu_fluc_red, i_sqr, NLSF_interpolation_factor = 0.0f;\r
-    const SKP_Silk_NLSF_CB_struct *psNLSF_CB;\r
-\r
-    /* Used only for NLSF interpolation */\r
-    SKP_float   pNLSF0_temp[  MAX_LPC_ORDER ];\r
-    SKP_float   pNLSFW0_temp[ MAX_LPC_ORDER ];\r
-    SKP_int     i;\r
-\r
-    /***********************/\r
-    /* Calculate mu values */\r
-    /***********************/\r
-    if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) {\r
-        NLSF_mu          = 0.002f - 0.001f * psEnc->speech_activity;\r
-        NLSF_mu_fluc_red = 0.1f   - 0.05f  * psEnc->speech_activity;\r
-    } else { \r
-        NLSF_mu          = 0.005f - 0.004f * psEnc->speech_activity;\r
-        NLSF_mu_fluc_red = 0.2f   - 0.1f   * ( psEnc->speech_activity + psEncCtrl->sparseness );\r
-    }\r
-\r
-    /* Calculate NLSF weights */\r
-    SKP_Silk_NLSF_VQ_weights_laroia_FLP( pNLSFW, pNLSF, psEnc->sCmn.predictLPCOrder );\r
-\r
-    /* Update NLSF weights for interpolated NLSFs */\r
-    doInterpolate = ( psEnc->sCmn.useInterpolatedNLSFs == 1 ) && ( psEnc->sCmn.indices.NLSFInterpCoef_Q2 < ( 1 << 2 ) );\r
-    if( doInterpolate ) {\r
-\r
-        /* Calculate the interpolated NLSF vector for the first half */\r
-        NLSF_interpolation_factor = 0.25f * psEnc->sCmn.indices.NLSFInterpCoef_Q2;\r
-        SKP_Silk_interpolate_wrapper_FLP( pNLSF0_temp, psEnc->sPred.prev_NLSFq, pNLSF, \r
-            NLSF_interpolation_factor, psEnc->sCmn.predictLPCOrder );\r
-\r
-        /* Calculate first half NLSF weights for the interpolated NLSFs */\r
-        SKP_Silk_NLSF_VQ_weights_laroia_FLP( pNLSFW0_temp, pNLSF0_temp, psEnc->sCmn.predictLPCOrder );\r
-\r
-        /* Update NLSF weights with contribution from first half */\r
-        i_sqr = NLSF_interpolation_factor * NLSF_interpolation_factor;\r
-        for( i = 0; i < psEnc->sCmn.predictLPCOrder; i++ ) {\r
-            pNLSFW[ i ] = 0.5f * ( pNLSFW[ i ] + i_sqr * pNLSFW0_temp[ i ] );\r
-        }\r
-    }\r
-\r
-    /* Set pointer to the NLSF codebook for the current signal type and LPC order */\r
-    psNLSF_CB = psEnc->sCmn.psNLSF_CB[ 1 - ( psEnc->sCmn.indices.signalType >> 1 ) ];\r
-\r
-    /* Quantize NLSF parameters given the trained NLSF codebooks */\r
-    SKP_Silk_NLSF_MSVQ_encode_FLP( psEnc->sCmn.indices.NLSFIndices, pNLSF, psNLSF_CB, psEnc->sPred.prev_NLSFq, pNLSFW, NLSF_mu, \r
-        NLSF_mu_fluc_red, psEnc->sCmn.NLSF_MSVQ_Survivors, psEnc->sCmn.predictLPCOrder, psEnc->sCmn.first_frame_after_reset );\r
-\r
-    /* Convert quantized NLSFs back to LPC coefficients */\r
-    SKP_Silk_NLSF2A_stable_FLP( psEncCtrl->PredCoef[ 1 ], pNLSF, psEnc->sCmn.predictLPCOrder );\r
-\r
-    if( doInterpolate ) {\r
-        /* Calculate the interpolated, quantized NLSF vector for the first half */\r
-        SKP_Silk_interpolate_wrapper_FLP( pNLSF0_temp, psEnc->sPred.prev_NLSFq, pNLSF, \r
-            NLSF_interpolation_factor, psEnc->sCmn.predictLPCOrder );\r
-\r
-        /* Convert back to LPC coefficients */\r
-        SKP_Silk_NLSF2A_stable_FLP( psEncCtrl->PredCoef[ 0 ], pNLSF0_temp, psEnc->sCmn.predictLPCOrder );\r
-\r
-    } else {\r
-        /* Copy LPC coefficients for first half from second half */\r
-        SKP_memcpy( psEncCtrl->PredCoef[ 0 ], psEncCtrl->PredCoef[ 1 ], psEnc->sCmn.predictLPCOrder * sizeof( SKP_float ) );\r
-    }\r
-}\r
-\r
index 9a0d462..7090933 100644 (file)
@@ -73,7 +73,7 @@ void SKP_Silk_process_gains_FLP(
 \r
     /* Set quantizer offset for voiced signals. Larger offset when LTP coding gain is low or tilt is high (ie low-pass) */\r
     if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) {\r
-        if( psEncCtrl->LTPredCodGain + psEncCtrl->input_tilt > 1.0f ) {\r
+        if( psEncCtrl->LTPredCodGain + psEnc->sCmn.input_tilt_Q15 * ( 1.0f / 32768.0f ) > 1.0f ) {\r
             psEnc->sCmn.indices.quantOffsetType = 0;\r
         } else {\r
             psEnc->sCmn.indices.quantOffsetType = 1;\r
@@ -84,7 +84,7 @@ void SKP_Silk_process_gains_FLP(
     quant_offset = SKP_Silk_Quantization_Offsets_Q10[ psEnc->sCmn.indices.signalType >> 1 ][ psEnc->sCmn.indices.quantOffsetType ] / 1024.0f;\r
     psEncCtrl->Lambda = LAMBDA_OFFSET \r
                       + LAMBDA_DELAYED_DECISIONS * psEnc->sCmn.nStatesDelayedDecision\r
-                      + LAMBDA_SPEECH_ACT        * psEnc->speech_activity \r
+                      + LAMBDA_SPEECH_ACT        * psEnc->sCmn.speech_activity_Q8 * ( 1.0f /  256.0f ) \r
                       + LAMBDA_INPUT_QUALITY     * psEncCtrl->input_quality   \r
                       + LAMBDA_CODING_QUALITY    * psEncCtrl->coding_quality\r
                       + LAMBDA_QUANT_OFFSET      * quant_offset;\r
index 5a950e0..8dbf734 100644 (file)
@@ -60,35 +60,19 @@ typedef struct {
     SKP_int     lagPrev;\r
 } SKP_Silk_prefilter_state_FLP;\r
 \r
-/*****************************/\r
-/* Prediction analysis state */\r
-/*****************************/\r
-typedef struct {\r
-    SKP_int     pitch_LPC_win_length;\r
-    SKP_int     min_pitch_lag;                      /* Lowest possible pitch lag (samples)  */\r
-    SKP_int     max_pitch_lag;                      /* Highest possible pitch lag (samples) */\r
-    SKP_float   prev_NLSFq[ MAX_LPC_ORDER ];        /* Previously quantized NLSF vector     */\r
-} SKP_Silk_predict_state_FLP;\r
-\r
 /********************************/\r
 /* Encoder state FLP            */\r
 /********************************/\r
 typedef struct {\r
     SKP_Silk_encoder_state              sCmn;                       /* Common struct, shared with fixed-point code */\r
-\r
-    SKP_float                           variable_HP_smth1;          /* State of first smoother */\r
-    SKP_float                           variable_HP_smth2;          /* State of second smoother */\r
-\r
     SKP_Silk_shape_state_FLP            sShape;                     /* Noise shaping state */\r
     SKP_Silk_prefilter_state_FLP        sPrefilt;                   /* Prefilter State */\r
-    SKP_Silk_predict_state_FLP          sPred;                      /* Prediction State */\r
 \r
     /* Buffer for find pitch and noise shape analysis */\r
     SKP_float                           x_buf[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ];/* Buffer for find pitch and noise shape analysis */\r
     SKP_float                           LTPCorr;                    /* Normalized correlation from pitch lag estimator */\r
     SKP_float                           SNR_dB;                     /* Quality setting */\r
     SKP_float                           BufferedInChannel_ms;       /* Simulated number of ms buffer in channel because of exceeded TargetRate_bps */\r
-    SKP_float                           speech_activity;            /* Speech activity */\r
 \r
     /* Parameters for LTP scaling control */\r
     SKP_float                           prevLTPredCodGain;\r
@@ -121,15 +105,12 @@ typedef struct {
        SKP_float                                       Lambda;\r
        SKP_float                                       input_quality;\r
        SKP_float                                       coding_quality;\r
-       SKP_float                                       pitch_freq_low_Hz;\r
        SKP_float                                       current_SNR_dB;\r
 \r
        /* Measures */\r
        SKP_float                                       sparseness;\r
     SKP_float                   predGain;\r
        SKP_float                                       LTPredCodGain;\r
-       SKP_float                                       input_quality_bands[ VAD_N_BANDS ];\r
-       SKP_float                                       input_tilt;\r
        SKP_float                                       ResNrg[ MAX_NB_SUBFR ];                                 /* Residual energy per subframe */\r
 } SKP_Silk_encoder_control_FLP;\r
 \r
index 0af6813..2347359 100644 (file)
@@ -31,122 +31,58 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 \r
 /* Convert AR filter coefficients to NLSF parameters */\r
 void SKP_Silk_A2NLSF_FLP( \r
-          SKP_float                 *pNLSF,             /* O    NLSF vector      [ LPC_order ]          */\r
+          SKP_int                   *NLSF_Q15,          /* O    NLSF vector      [ LPC_order ]          */\r
     const SKP_float                 *pAR,               /* I    LPC coefficients [ LPC_order ]          */\r
     const SKP_int                   LPC_order           /* I    LPC order                               */\r
 )\r
 {\r
     SKP_int   i;\r
-    SKP_int   NLSF_fix[  MAX_LPC_ORDER ];\r
     SKP_int32 a_fix_Q16[ MAX_LPC_ORDER ];\r
 \r
     for( i = 0; i < LPC_order; i++ ) {\r
         a_fix_Q16[ i ] = SKP_float2int( pAR[ i ] * 65536.0f );\r
     }\r
-    SKP_Silk_A2NLSF( NLSF_fix, a_fix_Q16, LPC_order );\r
 \r
-    for( i = 0; i < LPC_order; i++ ) {\r
-        pNLSF[ i ] = ( SKP_float )NLSF_fix[ i ] * ( 1.0f / 32768.0f );\r
-    }\r
+    SKP_Silk_A2NLSF( NLSF_Q15, a_fix_Q16, LPC_order );\r
 }\r
 \r
 /* Convert LSF parameters to AR prediction filter coefficients */\r
 void SKP_Silk_NLSF2A_stable_FLP( \r
           SKP_float                 *pAR,               /* O    LPC coefficients [ LPC_order ]          */\r
-    const SKP_float                 *pNLSF,             /* I    NLSF vector      [ LPC_order ]          */\r
+    const SKP_int                   *NLSF_Q15,          /* I    NLSF vector      [ LPC_order ]          */\r
     const SKP_int                   LPC_order           /* I    LPC order                               */\r
 )\r
 {\r
     SKP_int   i;\r
-    SKP_int   NLSF_fix[  MAX_LPC_ORDER ];\r
     SKP_int16 a_fix_Q12[ MAX_LPC_ORDER ];\r
 \r
-    for( i = 0; i < LPC_order; i++ ) {\r
-        NLSF_fix[ i ] = ( SKP_int )SKP_CHECK_FIT16( SKP_float2int( pNLSF[ i ] * 32768.0f ) );\r
-    }\r
-\r
-    SKP_Silk_NLSF2A_stable( a_fix_Q12, NLSF_fix, LPC_order );\r
+    SKP_Silk_NLSF2A_stable( a_fix_Q12, NLSF_Q15, LPC_order );\r
 \r
     for( i = 0; i < LPC_order; i++ ) {\r
-        pAR[ i ] = ( SKP_float )a_fix_Q12[ i ] / 4096.0f;\r
+        pAR[ i ] = ( SKP_float )a_fix_Q12[ i ] * ( 1.0f / 4096.0f );\r
     }\r
 }\r
 \r
-\r
-/* LSF stabilizer, for a single input data vector */\r
-void SKP_Silk_NLSF_stabilize_FLP(\r
-          SKP_float                 *pNLSF,             /* I/O  (Un)stable NLSF vector [ LPC_order ]    */\r
-    const SKP_int                   *pNDelta_min_Q15,   /* I    Normalized delta min vector[LPC_order+1]*/\r
-    const SKP_int                   LPC_order           /* I    LPC order                               */\r
+/******************************************/\r
+/* Floating-point NLSF processing wrapper */\r
+/******************************************/\r
+void SKP_Silk_process_NLSFs_FLP(\r
+    SKP_Silk_encoder_state          *psEncC,                            /* I/O  Encoder state                               */\r
+    SKP_float                       PredCoef[ 2 ][ MAX_LPC_ORDER ],     /* O    Prediction coefficients                     */\r
+    SKP_int                         NLSF_Q15[      MAX_LPC_ORDER ],     /* I/O  Normalized LSFs (quant out) (0 - (2^15-1))  */\r
+    const SKP_int                   prev_NLSF_Q15[ MAX_LPC_ORDER ]      /* I    Previous Normalized LSFs (0 - (2^15-1))     */\r
 )\r
 {\r
-    SKP_int   i;\r
-    SKP_int   NLSF_Q15[ MAX_LPC_ORDER ], ndelta_min_Q15[ MAX_LPC_ORDER + 1 ];\r
-\r
-    for( i = 0; i < LPC_order; i++ ) {\r
-        NLSF_Q15[       i ] = ( SKP_int )SKP_float2int( pNLSF[ i ] * 32768.0f );\r
-        ndelta_min_Q15[ i ] = ( SKP_int )SKP_float2int( pNDelta_min_Q15[ i ] );\r
-    }\r
-    ndelta_min_Q15[ LPC_order ] = ( SKP_int )SKP_float2int( pNDelta_min_Q15[ LPC_order ] );\r
-\r
-    /* NLSF stabilizer, for a single input data vector */\r
-    SKP_Silk_NLSF_stabilize( NLSF_Q15, ndelta_min_Q15, LPC_order );\r
-\r
-    for( i = 0; i < LPC_order; i++ ) {\r
-        pNLSF[ i ] = ( SKP_float )NLSF_Q15[ i ] * ( 1.0f / 32768.0f );\r
-    }\r
-}\r
-\r
-/* Interpolation function with fixed point rounding */\r
-void SKP_Silk_interpolate_wrapper_FLP(\r
-          SKP_float                 xi[],               /* O    Interpolated vector                     */\r
-    const SKP_float                 x0[],               /* I    First vector                            */\r
-    const SKP_float                 x1[],               /* I    Second vector                           */\r
-    const SKP_float                 ifact,              /* I    Interp. factor, weight on second vector */\r
-    const SKP_int                   d                   /* I    Number of parameters                    */\r
-)\r
-{\r
-    SKP_int x0_int[ MAX_LPC_ORDER ], x1_int[ MAX_LPC_ORDER ], xi_int[ MAX_LPC_ORDER ];\r
-    SKP_int ifact_Q2 = ( SKP_int )( ifact * 4.0f );\r
-    SKP_int i;\r
-\r
-    /* Convert input from flp to fix */\r
-    for( i = 0; i < d; i++ ) {\r
-        x0_int[ i ] = SKP_float2int( x0[ i ] * 32768.0f );\r
-        x1_int[ i ] = SKP_float2int( x1[ i ] * 32768.0f );\r
-    }\r
-\r
-    /* Interpolate two vectors */\r
-    SKP_Silk_interpolate( xi_int, x0_int, x1_int, ifact_Q2, d );\r
-    \r
-    /* Convert output from fix to flp */\r
-    for( i = 0; i < d; i++ ) {\r
-        xi[ i ] = ( SKP_float )xi_int[ i ] * ( 1.0f / 32768.0f );\r
-    }\r
-}\r
-\r
-/****************************************/\r
-/* Floating-point Silk VAD wrapper      */\r
-/****************************************/\r
-SKP_int SKP_Silk_VAD_FLP(\r
-    SKP_Silk_encoder_state_FLP      *psEnc,             /* I/O  Encoder state FLP                       */\r
-    SKP_Silk_encoder_control_FLP    *psEncCtrl,         /* I/O  Encoder control FLP                     */\r
-    const SKP_int16                 *pIn                /* I    Input signal                            */\r
-)\r
-{\r
-    SKP_int i, ret, SA_Q8, SNR_dB_Q7, Tilt_Q15;\r
-    SKP_int Quality_Bands_Q15[ VAD_N_BANDS ];\r
+    SKP_int     i, j;\r
+    SKP_int16   PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ];\r
 \r
-    ret = SKP_Silk_VAD_GetSA_Q8( &psEnc->sCmn.sVAD, &SA_Q8, &SNR_dB_Q7, Quality_Bands_Q15, &Tilt_Q15,\r
-        pIn, psEnc->sCmn.frame_length, psEnc->sCmn.fs_kHz );\r
+    SKP_Silk_process_NLSFs( psEncC, PredCoef_Q12, NLSF_Q15, prev_NLSF_Q15);\r
 \r
-    psEnc->speech_activity = ( SKP_float )SA_Q8 / 256.0f;\r
-    for( i = 0; i < VAD_N_BANDS; i++ ) {\r
-        psEncCtrl->input_quality_bands[ i ] = ( SKP_float )Quality_Bands_Q15[ i ] / 32768.0f;\r
+    for( j = 0; j < 2; j++ ) {\r
+        for( i = 0; i < psEncC->predictLPCOrder; i++ ) {\r
+            PredCoef[ j ][ i ] = ( SKP_float )PredCoef_Q12[ j ][ i ] * ( 1.0f / 4096.0f );\r
+        }\r
     }\r
-    psEncCtrl->input_tilt = ( SKP_float )Tilt_Q15 / 32768.0f;\r
-\r
-    return ret;\r
 }\r
 \r
 /****************************************/\r
@@ -253,6 +189,6 @@ void SKP_Silk_quant_LTP_gains_FLP(
     SKP_Silk_quant_LTP_gains( B_Q14, cbk_index, periodicity_index, W_Q18, mu_Q10, lowComplexity, nb_subfr );\r
 \r
     for( i = 0; i < nb_subfr * LTP_ORDER; i++ ) {\r
-        B[ i ] = ( (SKP_float)B_Q14[ i ] ) / 16384.0f;\r
+        B[ i ] = (SKP_float)B_Q14[ i ] * ( 1.0f / 16384.0f );\r
     }\r
 }\r
index 8e28b7e..256ba7a 100644 (file)
     <ClCompile Include="SKP_Silk_find_LTP_FLP.c" />\r
     <ClCompile Include="SKP_Silk_find_pitch_lags_FLP.c" />\r
     <ClCompile Include="SKP_Silk_find_pred_coefs_FLP.c" />\r
-    <ClCompile Include="SKP_Silk_HP_variable_cutoff_FLP.c" />\r
     <ClCompile Include="SKP_Silk_init_encoder_FLP.c" />\r
     <ClCompile Include="SKP_Silk_LPC_analysis_filter_FLP.c" />\r
     <ClCompile Include="SKP_Silk_LTP_analysis_filter_FLP.c" />\r
     <ClCompile Include="SKP_Silk_LTP_scale_ctrl_FLP.c" />\r
-    <ClCompile Include="SKP_Silk_NLSF_MSVQ_decode_FLP.c" />\r
-    <ClCompile Include="SKP_Silk_NLSF_MSVQ_encode_FLP.c" />\r
-    <ClCompile Include="SKP_Silk_NLSF_VQ_rate_distortion_FLP.c" />\r
-    <ClCompile Include="SKP_Silk_NLSF_VQ_sum_error_FLP.c" />\r
     <ClCompile Include="SKP_Silk_noise_shape_analysis_FLP.c" />\r
     <ClCompile Include="SKP_Silk_prefilter_FLP.c" />\r
     <ClCompile Include="SKP_Silk_process_gains_FLP.c" />\r
-    <ClCompile Include="SKP_Silk_process_NLSFs_FLP.c" />\r
     <ClCompile Include="SKP_Silk_regularize_correlations_FLP.c" />\r
     <ClCompile Include="SKP_Silk_residual_energy_FLP.c" />\r
     <ClCompile Include="SKP_Silk_solve_LS_FLP.c" />\r
index 781af93..d55e607 100644 (file)
@@ -53,9 +53,6 @@
     <ClCompile Include="SKP_Silk_find_pred_coefs_FLP.c">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
-    <ClCompile Include="SKP_Silk_HP_variable_cutoff_FLP.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
     <ClCompile Include="SKP_Silk_init_encoder_FLP.c">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
     <ClCompile Include="SKP_Silk_LTP_scale_ctrl_FLP.c">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
-    <ClCompile Include="SKP_Silk_NLSF_MSVQ_decode_FLP.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_NLSF_MSVQ_encode_FLP.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_NLSF_VQ_rate_distortion_FLP.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_NLSF_VQ_sum_error_FLP.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
     <ClCompile Include="SKP_Silk_noise_shape_analysis_FLP.c">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
@@ -89,9 +74,6 @@
     <ClCompile Include="SKP_Silk_process_gains_FLP.c">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
-    <ClCompile Include="SKP_Silk_process_NLSFs_FLP.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
     <ClCompile Include="SKP_Silk_regularize_correlations_FLP.c">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
index b6e44bc..b1f05ba 100644 (file)
@@ -33,12 +33,11 @@ Parameters Using Structured Vector Quantization", Proc. IEEE Int. Conf. Acoust.,
 Signal Processing, pp. 641-644, 1991.\r
 */\r
 \r
-#define Q_OUT                       6\r
-#define MIN_NDELTA                  3\r
+#define Q_OUT                       5\r
 \r
 /* Laroia low complexity NLSF weights */\r
 void SKP_Silk_NLSF_VQ_weights_laroia(\r
-    SKP_int             *pNLSFW_Q6,         /* O: Pointer to input vector weights           [D x 1]     */\r
+    SKP_int             *pNLSFW_Q5,         /* O: Pointer to input vector weights           [D x 1]     */\r
     const SKP_int       *pNLSF_Q15,         /* I: Pointer to input vector                   [D x 1]     */ \r
     const SKP_int       D                   /* I: Input vector dimension (even)                         */\r
 )\r
@@ -46,34 +45,33 @@ void SKP_Silk_NLSF_VQ_weights_laroia(
     SKP_int   k;\r
     SKP_int32 tmp1_int, tmp2_int;\r
     \r
-    /* Check that we are guaranteed to end up within the required range */\r
     SKP_assert( D > 0 );\r
     SKP_assert( ( D & 1 ) == 0 );\r
     \r
     /* First value */\r
-    tmp1_int = SKP_max_int( pNLSF_Q15[ 0 ], MIN_NDELTA );\r
+    tmp1_int = SKP_max_int( pNLSF_Q15[ 0 ], 1 );\r
     tmp1_int = SKP_DIV32_16( 1 << ( 15 + Q_OUT ), tmp1_int );\r
-    tmp2_int = SKP_max_int( pNLSF_Q15[ 1 ] - pNLSF_Q15[ 0 ], MIN_NDELTA );\r
+    tmp2_int = SKP_max_int( pNLSF_Q15[ 1 ] - pNLSF_Q15[ 0 ], 1 );\r
     tmp2_int = SKP_DIV32_16( 1 << ( 15 + Q_OUT ), tmp2_int );\r
-    pNLSFW_Q6[ 0 ] = (SKP_int)SKP_min_int( tmp1_int + tmp2_int, SKP_int16_MAX );\r
-    SKP_assert( pNLSFW_Q6[ 0 ] > 0 );\r
+    pNLSFW_Q5[ 0 ] = (SKP_int)SKP_min_int( tmp1_int + tmp2_int, SKP_int16_MAX );\r
+    SKP_assert( pNLSFW_Q5[ 0 ] > 0 );\r
     \r
     /* Main loop */\r
     for( k = 1; k < D - 1; k += 2 ) {\r
-        tmp1_int = SKP_max_int( pNLSF_Q15[ k + 1 ] - pNLSF_Q15[ k ], MIN_NDELTA );\r
+        tmp1_int = SKP_max_int( pNLSF_Q15[ k + 1 ] - pNLSF_Q15[ k ], 1 );\r
         tmp1_int = SKP_DIV32_16( 1 << ( 15 + Q_OUT ), tmp1_int );\r
-        pNLSFW_Q6[ k ] = (SKP_int)SKP_min_int( tmp1_int + tmp2_int, SKP_int16_MAX );\r
-        SKP_assert( pNLSFW_Q6[ k ] > 0 );\r
+        pNLSFW_Q5[ k ] = (SKP_int)SKP_min_int( tmp1_int + tmp2_int, SKP_int16_MAX );\r
+        SKP_assert( pNLSFW_Q5[ k ] > 0 );\r
 \r
-        tmp2_int = SKP_max_int( pNLSF_Q15[ k + 2 ] - pNLSF_Q15[ k + 1 ], MIN_NDELTA );\r
+        tmp2_int = SKP_max_int( pNLSF_Q15[ k + 2 ] - pNLSF_Q15[ k + 1 ], 1 );\r
         tmp2_int = SKP_DIV32_16( 1 << ( 15 + Q_OUT ), tmp2_int );\r
-        pNLSFW_Q6[ k + 1 ] = (SKP_int)SKP_min_int( tmp1_int + tmp2_int, SKP_int16_MAX );\r
-        SKP_assert( pNLSFW_Q6[ k + 1 ] > 0 );\r
+        pNLSFW_Q5[ k + 1 ] = (SKP_int)SKP_min_int( tmp1_int + tmp2_int, SKP_int16_MAX );\r
+        SKP_assert( pNLSFW_Q5[ k + 1 ] > 0 );\r
     }\r
     \r
     /* Last value */\r
-    tmp1_int = SKP_max_int( ( 1 << 15 ) - pNLSF_Q15[ D - 1 ], MIN_NDELTA );\r
+    tmp1_int = SKP_max_int( ( 1 << 15 ) - pNLSF_Q15[ D - 1 ], 1 );\r
     tmp1_int = SKP_DIV32_16( 1 << ( 15 + Q_OUT ), tmp1_int );\r
-    pNLSFW_Q6[ D - 1 ] = (SKP_int)SKP_min_int( tmp1_int + tmp2_int, SKP_int16_MAX );\r
-    SKP_assert( pNLSFW_Q6[ D - 1 ] > 0 );\r
+    pNLSFW_Q5[ D - 1 ] = (SKP_int)SKP_min_int( tmp1_int + tmp2_int, SKP_int16_MAX );\r
+    SKP_assert( pNLSFW_Q5[ D - 1 ] > 0 );\r
 }\r
index eeff580..3569914 100644 (file)
@@ -55,7 +55,7 @@ extern "C"
  * Initialize/reset the resampler state for a given pair of input/output sampling rates \r
 */\r
 SKP_int SKP_Silk_resampler_init( \r
-       SKP_Silk_resampler_state_struct *S,                     /* I/O: Resampler state                         */\r
+       SKP_Silk_resampler_state_struct     *S,         /* I/O: Resampler state                         */\r
        SKP_int32                                                       Fs_Hz_in,       /* I:   Input sampling rate (Hz)        */\r
        SKP_int32                                                       Fs_Hz_out       /* I:   Output sampling rate (Hz)       */\r
 );\r
@@ -65,14 +65,14 @@ SKP_int SKP_Silk_resampler_init(
  * Clear the states of all resampling filters, without resetting sampling rate ratio \r
  */\r
 SKP_int SKP_Silk_resampler_clear( \r
-       SKP_Silk_resampler_state_struct *S                      /* I/O: Resampler state                         */\r
+       SKP_Silk_resampler_state_struct     *S          /* I/O: Resampler state                         */\r
 );\r
 \r
 /*!\r
  * Resampler: convert from one sampling rate to another\r
  */\r
 SKP_int SKP_Silk_resampler( \r
-       SKP_Silk_resampler_state_struct *S,                     /* I/O: Resampler state                         */\r
+       SKP_Silk_resampler_state_struct     *S,         /* I/O: Resampler state                         */\r
        SKP_int16                                                       out[],      /* O:       Output signal                           */\r
        const SKP_int16                                         in[],       /* I:       Input signal                            */\r
        SKP_int32                                                       inLen       /* I:       Number of input samples         */\r
@@ -243,7 +243,6 @@ void SKP_Silk_ana_filt_bank_1(
     SKP_int32            *S,            /* I/O: State vector [2]        */\r
     SKP_int16            *outL,         /* O:   Low band [N/2]          */\r
     SKP_int16            *outH,         /* O:   High band [N/2]         */\r
-    SKP_int32            *scratch,      /* I:   Scratch memory [3*N/2]  */\r
     const SKP_int32      N              /* I:   Number of input samples */\r
 );\r
 \r
@@ -429,7 +428,7 @@ void SKP_Silk_NLSF_stabilize_multi(
 \r
 /* Laroia low complexity NLSF weights */\r
 void SKP_Silk_NLSF_VQ_weights_laroia(\r
-    SKP_int              *pNLSFW_Q6,     /* O:    Pointer to input vector weights            [D x 1]       */\r
+    SKP_int              *pNLSFW_Q5,     /* O:    Pointer to input vector weights            [D x 1]       */\r
     const SKP_int        *pNLSF_Q15,     /* I:    Pointer to input vector                    [D x 1]       */\r
     const SKP_int        D               /* I:    Input vector dimension (even)                            */\r
 );\r
@@ -575,8 +574,6 @@ SKP_INLINE SKP_int32 SKP_ROR32( SKP_int32 a32, SKP_int rot )
 #define SKP_SMLAWB_ovflw(a32, b32, c32)    SKP_SMLAWB(a32, b32, c32)\r
 #define SKP_SMLAWT_ovflw(a32, b32, c32)    SKP_SMLAWT(a32, b32, c32)\r
 \r
-#define SKP_DIV64_32(a64, b32)             ((a64)/(b32))        /* TODO: rewrite it as a set of SKP_DIV32.*/\r
-\r
 #define SKP_DIV32_16(a32, b16)             ((SKP_int32)((a32) / (b16)))\r
 #define SKP_DIV32(a32, b32)                ((SKP_int32)((a32) / (b32)))\r
 \r
index 04cbe07..66bc6a4 100644 (file)
@@ -46,7 +46,6 @@ void SKP_Silk_ana_filt_bank_1(
     SKP_int32            *S,         /* I/O: State vector [2]        */\r
     SKP_int16            *outL,      /* O:   Low band [N/2]          */\r
     SKP_int16            *outH,      /* O:   High band [N/2]         */\r
-    SKP_int32            *scratch,   /* I:   Scratch memory [3*N/2]  */   // todo: remove - no longer used\r
     const SKP_int32      N           /* I:   Number of input samples */\r
 )\r
 {\r
index e34ce97..a6921d3 100644 (file)
@@ -45,7 +45,7 @@
       <WarningLevel>Level3</WarningLevel>\r
       <Optimization>Disabled</Optimization>\r
       <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
-      <AdditionalIncludeDirectories>../interface</AdditionalIncludeDirectories>\r
+      <AdditionalIncludeDirectories>../interface;H:\Work\Codecs_silk_celt_experiments\ietfcodec\celt\libcelt</AdditionalIncludeDirectories>\r
     </ClCompile>\r
     <Link>\r
       <SubSystem>Windows</SubSystem>\r
@@ -61,7 +61,7 @@
       <FunctionLevelLinking>true</FunctionLevelLinking>\r
       <IntrinsicFunctions>true</IntrinsicFunctions>\r
       <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
-      <AdditionalIncludeDirectories>../interface</AdditionalIncludeDirectories>\r
+      <AdditionalIncludeDirectories>../interface;H:\Work\Codecs_silk_celt_experiments\ietfcodec\celt\libcelt</AdditionalIncludeDirectories>\r
     </ClCompile>\r
     <Link>\r
       <SubSystem>Windows</SubSystem>\r
diff --git a/src_SigProc_FLP/SKP_Silk_NLSF_VQ_weights_laroia_FLP.c b/src_SigProc_FLP/SKP_Silk_NLSF_VQ_weights_laroia_FLP.c
deleted file mode 100644 (file)
index f582857..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/***********************************************************************\r
-Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
-Redistribution and use in source and binary forms, with or without \r
-modification, (subject to the limitations in the disclaimer below) \r
-are permitted provided that the following conditions are met:\r
-- Redistributions of source code must retain the above copyright notice,\r
-this list of conditions and the following disclaimer.\r
-- Redistributions in binary form must reproduce the above copyright \r
-notice, this list of conditions and the following disclaimer in the \r
-documentation and/or other materials provided with the distribution.\r
-- Neither the name of Skype Limited, nor the names of specific \r
-contributors, may be used to endorse or promote products derived from \r
-this software without specific prior written permission.\r
-NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED \r
-BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND \r
-CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,\r
-BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND \r
-FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \r
-COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \r
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF \r
-USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON \r
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \r
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-***********************************************************************/\r
-\r
-#include "SKP_Silk_SigProc_FLP.h"\r
-\r
-/* \r
-R. Laroia, N. Phamdo and N. Farvardin, "Robust and Efficient Quantization of Speech LSP\r
-Parameters Using Structured Vector Quantization", Proc. IEEE Int. Conf. Acoust., Speech,\r
-Signal Processing, pp. 641-644, 1991.\r
-*/\r
-\r
-#define MIN_NDELTA                  1e-4f\r
-\r
-/* Laroia low complexity NLSF weights */\r
-void SKP_Silk_NLSF_VQ_weights_laroia_FLP( \r
-          SKP_float     *pXW,           /* 0: Pointer to input vector weights           [D x 1] */\r
-    const SKP_float     *pX,            /* I: Pointer to input vector                   [D x 1] */ \r
-    const SKP_int        D              /* I: Input vector dimension                            */\r
-)\r
-{\r
-    SKP_int   k;\r
-    SKP_float tmp1, tmp2;\r
-    \r
-    /* Safety checks */\r
-    SKP_assert( D > 0 );\r
-    SKP_assert( ( D & 1 ) == 0 );\r
-    \r
-    /* First value */\r
-    tmp1 = 1.0f / SKP_max_float( pX[ 0 ],           MIN_NDELTA );\r
-    tmp2 = 1.0f / SKP_max_float( pX[ 1 ] - pX[ 0 ], MIN_NDELTA );\r
-    pXW[ 0 ] = tmp1 + tmp2;\r
-    \r
-    /* Main loop */\r
-    for( k = 1; k < D - 1; k += 2 ) {\r
-        tmp1 = 1.0f / SKP_max_float( pX[ k + 1 ] - pX[ k ], MIN_NDELTA );\r
-        pXW[ k ] = tmp1 + tmp2;\r
-\r
-        tmp2 = 1.0f / SKP_max_float( pX[ k + 2 ] - pX[ k + 1 ], MIN_NDELTA );\r
-        pXW[ k + 1 ] = tmp1 + tmp2;\r
-    }\r
-    \r
-    /* Last value */\r
-    tmp1 = 1.0f / SKP_max_float( 1.0f - pX[ D - 1 ], MIN_NDELTA );\r
-    pXW[ D - 1 ] = tmp1 + tmp2;\r
-}\r
index 115de3a..9c37d69 100644 (file)
@@ -107,24 +107,17 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv
 #define PI               (3.1415926536f)\r
 \r
 void SKP_Silk_insertion_sort_decreasing_FLP(\r
-    SKP_float            *a,          /* I/O:  Unsorted / Sorted vector                */\r
-    SKP_int              *index,      /* O:    Index vector for the sorted elements    */\r
-    const SKP_int        L,           /* I:    Vector length                           */\r
-    const SKP_int        K            /* I:    Number of correctly sorted positions    */\r
+    SKP_float            *a,            /* I/O:  Unsorted / Sorted vector                */\r
+    SKP_int              *index,        /* O:    Index vector for the sorted elements    */\r
+    const SKP_int        L,             /* I:    Vector length                           */\r
+    const SKP_int        K              /* I:    Number of correctly sorted positions    */\r
 );\r
 \r
 void SKP_Silk_insertion_sort_increasing_FLP(\r
-    SKP_float            *a,          /* I/O:  Unsorted / Sorted vector                */\r
-    SKP_int              *index,      /* O:    Index vector for the sorted elements    */\r
-    const SKP_int        L,           /* I:    Vector length                           */\r
-    const SKP_int        K            /* I:    Number of correctly sorted positions    */\r
-);\r
-\r
-/* Laroia low complexity NLSF weights */\r
-void SKP_Silk_NLSF_VQ_weights_laroia_FLP(      \r
-    SKP_float            *pXW,           /* 0: Pointer to input vector weights                [D x 1]    */\r
-    const SKP_float      *pX,            /* I: Pointer to input vector                        [D x 1]    */ \r
-    const SKP_int        D               /* I: Input vector dimension                                    */\r
+    SKP_float            *a,            /* I/O:  Unsorted / Sorted vector                */\r
+    SKP_int              *index,        /* O:    Index vector for the sorted elements    */\r
+    const SKP_int        L,             /* I:    Vector length                           */\r
+    const SKP_int        K              /* I:    Number of correctly sorted positions    */\r
 );\r
 \r
 /* Compute reflection coefficients from input signal */\r
index c4e9004..9284850 100644 (file)
@@ -45,7 +45,7 @@
       <WarningLevel>Level3</WarningLevel>\r
       <Optimization>Disabled</Optimization>\r
       <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
-      <AdditionalIncludeDirectories>../interface;../src_SigProc_FIX</AdditionalIncludeDirectories>\r
+      <AdditionalIncludeDirectories>H:\Work\Codecs_silk_celt_experiments\ietfcodec\celt\libcelt;../interface;../src_SigProc_FIX</AdditionalIncludeDirectories>\r
     </ClCompile>\r
     <Link>\r
       <SubSystem>Windows</SubSystem>\r
@@ -61,7 +61,7 @@
       <FunctionLevelLinking>true</FunctionLevelLinking>\r
       <IntrinsicFunctions>true</IntrinsicFunctions>\r
       <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
-      <AdditionalIncludeDirectories>../interface;../src_SigProc_FIX</AdditionalIncludeDirectories>\r
+      <AdditionalIncludeDirectories>H:\Work\Codecs_silk_celt_experiments\ietfcodec\celt\libcelt;../interface;../src_SigProc_FIX</AdditionalIncludeDirectories>\r
     </ClCompile>\r
     <Link>\r
       <SubSystem>Windows</SubSystem>\r
@@ -85,7 +85,6 @@
     <ClCompile Include="SKP_Silk_k2a_FLP.c" />\r
     <ClCompile Include="SKP_Silk_levinsondurbin_FLP.c" />\r
     <ClCompile Include="SKP_Silk_LPC_inv_pred_gain_FLP.c" />\r
-    <ClCompile Include="SKP_Silk_NLSF_VQ_weights_laroia_FLP.c" />\r
     <ClCompile Include="SKP_Silk_pitch_analysis_core_FLP.c" />\r
     <ClCompile Include="SKP_Silk_scale_copy_vector_FLP.c" />\r
     <ClCompile Include="SKP_Silk_scale_vector_FLP.c" />\r
index 4bc3334..717b1c2 100644 (file)
@@ -47,9 +47,6 @@
     <ClCompile Include="SKP_Silk_LPC_inv_pred_gain_FLP.c">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
-    <ClCompile Include="SKP_Silk_NLSF_VQ_weights_laroia_FLP.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
     <ClCompile Include="SKP_Silk_pitch_analysis_core_FLP.c">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
similarity index 70%
rename from src_FIX/SKP_Silk_HP_variable_cutoff_FIX.c
rename to src_common/SKP_Silk_HP_variable_cutoff.c
index bfc310b..48daad4 100644 (file)
@@ -34,14 +34,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #define SKP_LOG2_VARIABLE_HP_MIN_FREQ_Q7    809     // log(80) in Q7\r
 \r
 /* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */\r
-void SKP_Silk_HP_variable_cutoff_FIX(\r
-    SKP_Silk_encoder_state_FIX      *psEnc,             /* I/O  Encoder state FIX                           */\r
-    SKP_Silk_encoder_control_FIX    *psEncCtrl,         /* I/O  Encoder control FIX                         */\r
-    SKP_int16                       *out,               /* O    high-pass filtered output signal            */\r
-    const SKP_int16                 *in                 /* I    input signal                                */\r
+void SKP_Silk_HP_variable_cutoff(\r
+    SKP_Silk_encoder_state          *psEncC,        /* I/O  Encoder state                               */\r
+    SKP_int16                       *out,           /* O    high-pass filtered output signal            */\r
+    const SKP_int16                 *in,            /* I    input signal                                */\r
+    const SKP_int                   frame_length    /* I    length of input                             */\r
 )\r
 {\r
     SKP_int   quality_Q15;\r
+       SKP_float pitch_freq_low_Hz;\r
     SKP_int32 B_Q28[ 3 ], A_Q28[ 2 ];\r
     SKP_int32 Fc_Q19, r_Q28, r_Q22;\r
     SKP_int32 pitch_freq_Hz_Q16, pitch_freq_log_Q7, delta_freq_Q7;\r
@@ -49,19 +50,19 @@ void SKP_Silk_HP_variable_cutoff_FIX(
     /*********************************************/\r
     /* Estimate Low End of Pitch Frequency Range */\r
     /*********************************************/\r
-    if( psEnc->sCmn.prevSignalType == TYPE_VOICED ) {\r
+    if( psEncC->prevSignalType == TYPE_VOICED ) {\r
         /* difference, in log domain */\r
-        pitch_freq_Hz_Q16 = SKP_DIV32_16( SKP_LSHIFT( SKP_MUL( psEnc->sCmn.fs_kHz, 1000 ), 16 ), psEnc->sCmn.prevLag );\r
+        pitch_freq_Hz_Q16 = SKP_DIV32_16( SKP_LSHIFT( SKP_MUL( psEncC->fs_kHz, 1000 ), 16 ), psEncC->prevLag );\r
         pitch_freq_log_Q7 = SKP_Silk_lin2log( pitch_freq_Hz_Q16 ) - ( 16 << 7 ); //0x70\r
 \r
         /* adjustment based on quality */\r
-        quality_Q15 = psEncCtrl->input_quality_bands_Q15[ 0 ];\r
+        quality_Q15 = psEncC->input_quality_bands_Q15[ 0 ];\r
         pitch_freq_log_Q7 = SKP_SUB32( pitch_freq_log_Q7, SKP_SMULWB( SKP_SMULWB( SKP_LSHIFT( quality_Q15, 2 ), quality_Q15 ), \r
             pitch_freq_log_Q7 - SKP_LOG2_VARIABLE_HP_MIN_FREQ_Q7 ) );\r
         pitch_freq_log_Q7 = SKP_ADD32( pitch_freq_log_Q7, SKP_RSHIFT( SKP_FIX_CONST( 0.6, 15 ) - quality_Q15, 9 ) );\r
 \r
         //delta_freq = pitch_freq_log - psEnc->variable_HP_smth1;\r
-        delta_freq_Q7 = pitch_freq_log_Q7 - SKP_RSHIFT( psEnc->variable_HP_smth1_Q15, 8 );\r
+        delta_freq_Q7 = pitch_freq_log_Q7 - SKP_RSHIFT( psEncC->variable_HP_smth1_Q15, 8 );\r
         if( delta_freq_Q7 < 0 ) {\r
             /* less smoothing for decreasing pitch frequency, to track something close to the minimum */\r
             delta_freq_Q7 = SKP_MUL( delta_freq_Q7, 3 );\r
@@ -71,28 +72,28 @@ void SKP_Silk_HP_variable_cutoff_FIX(
         delta_freq_Q7 = SKP_LIMIT_32( delta_freq_Q7, -SKP_FIX_CONST( VARIABLE_HP_MAX_DELTA_FREQ, 7 ), SKP_FIX_CONST( VARIABLE_HP_MAX_DELTA_FREQ, 7 ) );\r
 \r
         /* update smoother */\r
-        psEnc->variable_HP_smth1_Q15 = SKP_SMLAWB( psEnc->variable_HP_smth1_Q15, \r
-            SKP_MUL( SKP_LSHIFT( psEnc->speech_activity_Q8, 1 ), delta_freq_Q7 ), SKP_FIX_CONST( VARIABLE_HP_SMTH_COEF1, 16 ) );\r
+        psEncC->variable_HP_smth1_Q15 = SKP_SMLAWB( psEncC->variable_HP_smth1_Q15, \r
+            SKP_MUL( SKP_LSHIFT( psEncC->speech_activity_Q8, 1 ), delta_freq_Q7 ), SKP_FIX_CONST( VARIABLE_HP_SMTH_COEF1, 16 ) );\r
     }\r
+\r
     /* second smoother */\r
-    psEnc->variable_HP_smth2_Q15 = SKP_SMLAWB( psEnc->variable_HP_smth2_Q15, \r
-        psEnc->variable_HP_smth1_Q15 - psEnc->variable_HP_smth2_Q15, SKP_FIX_CONST( VARIABLE_HP_SMTH_COEF2, 16 ) );\r
+    psEncC->variable_HP_smth2_Q15 = SKP_SMLAWB( psEncC->variable_HP_smth2_Q15, \r
+        psEncC->variable_HP_smth1_Q15 - psEncC->variable_HP_smth2_Q15, SKP_FIX_CONST( VARIABLE_HP_SMTH_COEF2, 16 ) );\r
 \r
     /* convert from log scale to Hertz */\r
-    psEncCtrl->pitch_freq_low_Hz = SKP_Silk_log2lin( SKP_RSHIFT( psEnc->variable_HP_smth2_Q15, 8 ) );\r
+    pitch_freq_low_Hz = SKP_Silk_log2lin( SKP_RSHIFT( psEncC->variable_HP_smth2_Q15, 8 ) );\r
 \r
     /* limit frequency range */\r
-    psEncCtrl->pitch_freq_low_Hz = SKP_LIMIT_32( psEncCtrl->pitch_freq_low_Hz, \r
-        SKP_FIX_CONST( VARIABLE_HP_MIN_FREQ, 0 ), SKP_FIX_CONST( VARIABLE_HP_MAX_FREQ, 0 ) );\r
+    pitch_freq_low_Hz = SKP_LIMIT_32( pitch_freq_low_Hz, SKP_FIX_CONST( VARIABLE_HP_MIN_FREQ, 0 ), SKP_FIX_CONST( VARIABLE_HP_MAX_FREQ, 0 ) );\r
 \r
     /********************************/\r
     /* Compute Filter Coefficients  */\r
     /********************************/\r
     /* compute cut-off frequency, in radians */\r
-    //Fc_num   = (SKP_float)( 0.45f * 2.0f * 3.14159265359 * psEncCtrl->pitch_freq_low_Hz );\r
-    //Fc_denom = (SKP_float)( 1e3f * psEnc->sCmn.fs_kHz );\r
-    SKP_assert( psEncCtrl->pitch_freq_low_Hz <= SKP_int32_MAX / SKP_RADIANS_CONSTANT_Q19 );\r
-    Fc_Q19 = SKP_DIV32_16( SKP_SMULBB( SKP_RADIANS_CONSTANT_Q19, psEncCtrl->pitch_freq_low_Hz ), psEnc->sCmn.fs_kHz ); // range: 3704 - 27787, 11-15 bits\r
+    //Fc_num   = (SKP_float)( 0.45f * 2.0f * 3.14159265359 * pitch_freq_low_Hz );\r
+    //Fc_denom = (SKP_float)( 1e3f * psEncC->fs_kHz );\r
+    SKP_assert( pitch_freq_low_Hz <= SKP_int32_MAX / SKP_RADIANS_CONSTANT_Q19 );\r
+    Fc_Q19 = SKP_DIV32_16( SKP_SMULBB( SKP_RADIANS_CONSTANT_Q19, pitch_freq_low_Hz ), psEncC->fs_kHz ); // range: 3704 - 27787, 11-15 bits\r
     SKP_assert( Fc_Q19 >=  3704 );\r
     SKP_assert( Fc_Q19 <= 27787 );\r
 \r
@@ -114,7 +115,7 @@ void SKP_Silk_HP_variable_cutoff_FIX(
     /********************************/\r
     /* High-Pass Filter             */\r
     /********************************/\r
-    SKP_Silk_biquad_alt( in, B_Q28, A_Q28, psEnc->sCmn.In_HP_State, out, psEnc->sCmn.frame_length );\r
+    SKP_Silk_biquad_alt( in, B_Q28, A_Q28, psEncC->In_HP_State, out, frame_length );\r
 }\r
 \r
 #endif // HIGH_PASS_INPUT\r
index 82183dd..371d35b 100644 (file)
@@ -48,7 +48,7 @@ SKP_INLINE void SKP_Silk_LP_interpolate_filter_taps(
 \r
     if( ind < TRANSITION_INT_NUM - 1 ) {\r
         if( fac_Q16 > 0 ) {\r
-            if( fac_Q16 == SKP_SAT16( fac_Q16 ) ) { /* fac_Q16 is in range of a 16-bit int */\r
+            if( fac_Q16 < 32768 ) { /* fac_Q16 is in range of a 16-bit int */\r
                 /* Piece-wise linear interpolation of B and A */\r
                 for( nb = 0; nb < TRANSITION_NB; nb++ ) {\r
                     B_Q28[ nb ] = SKP_SMLAWB(\r
@@ -64,38 +64,23 @@ SKP_INLINE void SKP_Silk_LP_interpolate_filter_taps(
                         SKP_Silk_Transition_LP_A_Q28[ ind     ][ na ],\r
                         fac_Q16 );\r
                 }\r
-            } else if( fac_Q16 == ( 1 << 15 ) ) { /* Neither fac_Q16 nor ( ( 1 << 16 ) - fac_Q16 ) is in range of a 16-bit int */\r
-\r
-                /* Piece-wise linear interpolation of B and A */\r
-                for( nb = 0; nb < TRANSITION_NB; nb++ ) {\r
-                    B_Q28[ nb ] = SKP_RSHIFT( \r
-                        SKP_Silk_Transition_LP_B_Q28[ ind     ][ nb ] +\r
-                        SKP_Silk_Transition_LP_B_Q28[ ind + 1 ][ nb ],\r
-                        1 );\r
-                }\r
-                for( na = 0; na < TRANSITION_NA; na++ ) {\r
-                    A_Q28[ na ] = SKP_RSHIFT( \r
-                        SKP_Silk_Transition_LP_A_Q28[ ind     ][ na ] + \r
-                        SKP_Silk_Transition_LP_A_Q28[ ind + 1 ][ na ], \r
-                        1 );\r
-                }\r
-            } else { /* ( ( 1 << 16 ) - fac_Q16 ) is in range of a 16-bit int */\r
+            } else { /* ( fac_Q16 - ( 1 << 16 ) ) is in range of a 16-bit int */\r
                 \r
-                SKP_assert( ( ( 1 << 16 ) - fac_Q16 ) == SKP_SAT16( ( ( 1 << 16 ) - fac_Q16) ) );\r
+                SKP_assert( fac_Q16 - ( 1 << 16 ) == SKP_SAT16( fac_Q16 - ( 1 << 16 ) ) );\r
                 /* Piece-wise linear interpolation of B and A */\r
                 for( nb = 0; nb < TRANSITION_NB; nb++ ) {\r
                     B_Q28[ nb ] = SKP_SMLAWB(\r
                         SKP_Silk_Transition_LP_B_Q28[ ind + 1 ][ nb ],\r
-                        SKP_Silk_Transition_LP_B_Q28[ ind     ][ nb ] -\r
-                        SKP_Silk_Transition_LP_B_Q28[ ind + 1 ][ nb ],\r
-                        ( 1 << 16 ) - fac_Q16 );\r
+                        SKP_Silk_Transition_LP_B_Q28[ ind + 1 ][ nb ] -\r
+                        SKP_Silk_Transition_LP_B_Q28[ ind     ][ nb ],\r
+                        fac_Q16 - ( 1 << 16 ) );\r
                 }\r
                 for( na = 0; na < TRANSITION_NA; na++ ) {\r
                     A_Q28[ na ] = SKP_SMLAWB(\r
                         SKP_Silk_Transition_LP_A_Q28[ ind + 1 ][ na ],\r
-                        SKP_Silk_Transition_LP_A_Q28[ ind     ][ na ] -\r
-                        SKP_Silk_Transition_LP_A_Q28[ ind + 1 ][ na ],\r
-                        ( 1 << 16 ) - fac_Q16 );\r
+                        SKP_Silk_Transition_LP_A_Q28[ ind + 1 ][ na ] -\r
+                        SKP_Silk_Transition_LP_A_Q28[ ind     ][ na ],\r
+                        fac_Q16 - ( 1 << 16 ) );\r
                 }\r
             }\r
         } else {\r
@@ -110,8 +95,8 @@ SKP_INLINE void SKP_Silk_LP_interpolate_filter_taps(
 \r
 /* Low-pass filter with variable cutoff frequency based on  */\r
 /* piece-wise linear interpolation between elliptic filters */\r
-/* Start by setting psEncC->transition_frame_no = 1;            */\r
-/* Deactivate by setting psEncC->transition_frame_no = 0;   */\r
+/* Start by setting psEncC->mode <> 0;                      */\r
+/* Deactivate by setting psEncC->mode = 0;                  */\r
 void SKP_Silk_LP_variable_cutoff(\r
     SKP_Silk_LP_state               *psLP,          /* I/O  LP filter state                     */\r
     SKP_int16                       *signal,        /* I/O  Low-pass filtered output signal     */\r
@@ -121,67 +106,28 @@ void SKP_Silk_LP_variable_cutoff(
     SKP_int32   B_Q28[ TRANSITION_NB ], A_Q28[ TRANSITION_NA ], fac_Q16 = 0;\r
     SKP_int     ind = 0;\r
 \r
-    SKP_assert( psLP->transition_frame_no >= 0 );\r
-    SKP_assert( ( ( ( psLP->transition_frame_no <= TRANSITION_FRAMES_DOWN ) && ( psLP->mode == 0 ) ) || \r
-                  ( ( psLP->transition_frame_no <= TRANSITION_FRAMES_UP   ) && ( psLP->mode == 1 ) ) ) );\r
+    SKP_assert( psLP->transition_frame_no >= 0 && psLP->transition_frame_no <= TRANSITION_FRAMES );\r
 \r
     /* Interpolate filter coefficients if needed */\r
-    if( psLP->transition_frame_no > 0 ) {\r
-        if( psLP->mode == 0 ) {\r
-            if( psLP->transition_frame_no < TRANSITION_FRAMES_DOWN ) {\r
-                /* Calculate index and interpolation factor for interpolation */\r
-#if( TRANSITION_INT_STEPS_DOWN == 32 )\r
-                fac_Q16 = SKP_LSHIFT( psLP->transition_frame_no, 16 - 5 );\r
+    if( psLP->mode != 0 ) {\r
+        /* Calculate index and interpolation factor for interpolation */\r
+#if( TRANSITION_INT_STEPS == 64 )\r
+        fac_Q16 = SKP_LSHIFT( TRANSITION_FRAMES - psLP->transition_frame_no, 16 - 6 );\r
 #else\r
-                fac_Q16 = SKP_DIV32_16( SKP_LSHIFT( psLP->transition_frame_no, 16 ), TRANSITION_INT_STEPS_DOWN );\r
+        fac_Q16 = SKP_DIV32_16( SKP_LSHIFT( TRANSITION_FRAMES - psLP->transition_frame_no, 16 ), TRANSITION_FRAMES );\r
 #endif\r
-                ind      = SKP_RSHIFT( fac_Q16, 16 );\r
-                fac_Q16 -= SKP_LSHIFT( ind, 16 );\r
+        ind      = SKP_RSHIFT( fac_Q16, 16 );\r
+        fac_Q16 -= SKP_LSHIFT( ind, 16 );\r
 \r
-                SKP_assert( ind >= 0 );\r
-                SKP_assert( ind < TRANSITION_INT_NUM );\r
+        SKP_assert( ind >= 0 );\r
+        SKP_assert( ind < TRANSITION_INT_NUM );\r
 \r
-                /* Interpolate filter coefficients */\r
-                SKP_Silk_LP_interpolate_filter_taps( B_Q28, A_Q28, ind, fac_Q16 );\r
+        /* Interpolate filter coefficients */\r
+        SKP_Silk_LP_interpolate_filter_taps( B_Q28, A_Q28, ind, fac_Q16 );\r
 \r
-                /* Increment transition frame number for next frame */\r
-                psLP->transition_frame_no++;\r
+        /* Update transition frame number for next frame */\r
+        psLP->transition_frame_no = SKP_LIMIT( psLP->transition_frame_no + psLP->mode, 0, TRANSITION_FRAMES );\r
 \r
-            } else {\r
-                SKP_assert( psLP->transition_frame_no == TRANSITION_FRAMES_DOWN );\r
-                /* End of transition phase */\r
-                SKP_Silk_LP_interpolate_filter_taps( B_Q28, A_Q28, TRANSITION_INT_NUM - 1, 0 );\r
-            }\r
-        } else {\r
-            SKP_assert( psLP->mode == 1 );\r
-            if( psLP->transition_frame_no < TRANSITION_FRAMES_UP ) {\r
-                /* Calculate index and interpolation factor for interpolation */\r
-#if( TRANSITION_INT_STEPS_UP == 64 )\r
-                fac_Q16 = SKP_LSHIFT( TRANSITION_FRAMES_UP - psLP->transition_frame_no, 16 - 6 );\r
-#else\r
-                fac_Q16 = SKP_DIV32_16( SKP_LSHIFT( TRANSITION_FRAMES_UP - psLP->transition_frame_no, 16 ), TRANSITION_INT_STEPS_UP );\r
-#endif\r
-                ind      = SKP_RSHIFT( fac_Q16, 16 );\r
-                fac_Q16 -= SKP_LSHIFT( ind, 16 );\r
-\r
-                SKP_assert( ind >= 0 );\r
-                SKP_assert( ind < TRANSITION_INT_NUM );\r
-\r
-                /* Interpolate filter coefficients */\r
-                SKP_Silk_LP_interpolate_filter_taps( B_Q28, A_Q28, ind, fac_Q16 );\r
-\r
-                /* Increment transition frame number for next frame */\r
-                psLP->transition_frame_no++;\r
-            \r
-            } else {\r
-                SKP_assert( psLP->transition_frame_no == TRANSITION_FRAMES_UP );\r
-                /* End of transition phase */\r
-                SKP_Silk_LP_interpolate_filter_taps( B_Q28, A_Q28, 0, 0 );\r
-            }\r
-        }\r
-    } \r
-    \r
-    if( psLP->transition_frame_no > 0 ) {\r
         /* ARMA low-pass filtering */\r
         SKP_assert( TRANSITION_NB == 3 && TRANSITION_NA == 2 );\r
         SKP_Silk_biquad_alt( signal, B_Q28, A_Q28, psLP->In_LP_State, signal, frame_length );\r
index 3cd0a3e..a48448f 100644 (file)
@@ -47,7 +47,7 @@ void SKP_Silk_NLSF_MSVQ_decode(
 \r
     /* Initialize with the codebook vector from stage 0 */\r
     for( i = 0; i < LPC_order; i++ ) {\r
-        pNLSF_Q8[ i ] = ( SKP_int )pCB_element[ i ];\r
+        pNLSF_Q8[ i ] = SKP_LSHIFT( ( SKP_int )pCB_element[ i ], NLSF_Q_DOMAIN_STAGE_2_TO_LAST - NLSF_Q_DOMAIN_STAGE_0 );\r
     }\r
           \r
     if( LPC_order == 16 ) {\r
@@ -98,7 +98,7 @@ void SKP_Silk_NLSF_MSVQ_decode(
 \r
     /* Add 1/2 in Q15 */\r
     for( i = 0; i < LPC_order; i++ ) {\r
-        pNLSF_Q15[ i ] = SKP_LSHIFT16( pNLSF_Q8[ i ], 7 ) + SKP_FIX_CONST( 0.5f, 15 );\r
+        pNLSF_Q15[ i ] = SKP_LSHIFT16( pNLSF_Q8[ i ], 15 - NLSF_Q_DOMAIN_STAGE_2_TO_LAST ) + SKP_FIX_CONST( 0.5f, 15 );\r
     }\r
 \r
     /* NLSF stabilization */\r
similarity index 91%
rename from src_FIX/SKP_Silk_NLSF_MSVQ_encode_FIX.c
rename to src_common/SKP_Silk_NLSF_MSVQ_encode.c
index 81a5edd..343e1fd 100644 (file)
@@ -25,17 +25,17 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
 ***********************************************************************/\r
 \r
-#include "SKP_Silk_main_FIX.h"\r
+#include "SKP_Silk_main.h"\r
 \r
 /***********************/\r
 /* NLSF vector encoder */\r
 /***********************/\r
-void SKP_Silk_NLSF_MSVQ_encode_FIX(\r
+void SKP_Silk_NLSF_MSVQ_encode(\r
           SKP_int8                  *NLSFIndices,           /* O    Codebook path vector [ CB_STAGES ]      */\r
           SKP_int                   *pNLSF_Q15,             /* I/O  Quantized NLSF vector [ LPC_ORDER ]     */\r
     const SKP_Silk_NLSF_CB_struct   *psNLSF_CB,             /* I    Codebook object                         */\r
     const SKP_int                   *pNLSF_q_Q15_prev,      /* I    Prev. quantized NLSF vector [LPC_ORDER] */\r
-    const SKP_int                   *pW_Q6,                 /* I    NLSF weight vector [ LPC_ORDER ]        */\r
+    const SKP_int                   *pW_Q5,                 /* I    NLSF weight vector [ LPC_ORDER ]        */\r
     const SKP_int                   NLSF_mu_Q15,            /* I    Rate weight for the RD optimization     */\r
     const SKP_int                   NLSF_mu_fluc_red_Q16,   /* I    Fluctuation reduction error weight      */\r
     const SKP_int                   NLSF_MSVQ_Survivors,    /* I    Max survivors from each stage           */\r
@@ -50,8 +50,8 @@ void SKP_Silk_NLSF_MSVQ_encode_FIX(
 #endif\r
 \r
     SKP_int32   pRateDist_Q18[  NLSF_MSVQ_TREE_SEARCH_MAX_VECTORS_EVALUATED ];\r
-    SKP_int32   pRate_Q5[       MAX_NLSF_MSVQ_SURVIVORS ];\r
-    SKP_int32   pRate_new_Q5[   MAX_NLSF_MSVQ_SURVIVORS ];\r
+    SKP_int32   pRate_Q4[       MAX_NLSF_MSVQ_SURVIVORS ];\r
+    SKP_int32   pRate_new_Q4[   MAX_NLSF_MSVQ_SURVIVORS ];\r
     SKP_int     pTempIndices[   MAX_NLSF_MSVQ_SURVIVORS ];\r
     SKP_int8    pPath[          MAX_NLSF_MSVQ_SURVIVORS * NLSF_MSVQ_MAX_CB_STAGES ];\r
     SKP_int8    pPath_new[      MAX_NLSF_MSVQ_SURVIVORS * NLSF_MSVQ_MAX_CB_STAGES ];\r
@@ -69,7 +69,7 @@ void SKP_Silk_NLSF_MSVQ_encode_FIX(
 \r
 #ifdef SAVE_ALL_INTERNAL_DATA\r
     DEBUG_STORE_DATA( NLSF.dat,    pNLSF_Q15,    LPC_order * sizeof( SKP_int   ) );\r
-    DEBUG_STORE_DATA( WNLSF.dat,   pW_Q6,        LPC_order * sizeof( SKP_int   ) );\r
+    DEBUG_STORE_DATA( WNLSF.dat,   pW_Q5,        LPC_order * sizeof( SKP_int   ) );\r
     DEBUG_STORE_DATA( NLSF_mu.dat, &NLSF_mu_Q15,             sizeof( SKP_int32 ) );\r
 #endif\r
 \r
@@ -78,7 +78,7 @@ void SKP_Silk_NLSF_MSVQ_encode_FIX(
     /****************************************************/\r
 \r
     /* Clear accumulated rates */\r
-    SKP_memset( pRate_Q5, 0, NLSF_MSVQ_Survivors * sizeof( SKP_int32 ) );\r
+    SKP_memset( pRate_Q4, 0, NLSF_MSVQ_Survivors * sizeof( SKP_int32 ) );\r
 \r
     /* Subtract 1/2 from NLSF input vector to create initial residual */\r
     for( i = 0; i < LPC_order; i++ ) {\r
@@ -109,8 +109,8 @@ void SKP_Silk_NLSF_MSVQ_encode_FIX(
 #endif\r
 \r
         /* Nearest neighbor clustering for multiple input data vectors */\r
-        SKP_Silk_NLSF_VQ_rate_distortion_FIX( pRateDist_Q18, pCurrentCBStage, pRes_Q15, pW_Q6\r
-            pRate_Q5, NLSF_mu_Q15, prev_survivors, LPC_order );\r
+        SKP_Silk_NLSF_VQ_rate_distortion( pRateDist_Q18, pCurrentCBStage, pRes_Q15, pW_Q5\r
+            pRate_Q4, NLSF_mu_Q15, prev_survivors, s, LPC_order );\r
 \r
         /* Sort the rate-distortion errors */\r
         SKP_Silk_insertion_sort_increasing( pRateDist_Q18, pTempIndices, \r
@@ -150,7 +150,7 @@ void SKP_Silk_NLSF_MSVQ_encode_FIX(
             }\r
 \r
             /* Update accumulated rate for stage 1 to the current */\r
-            pRate_new_Q5[ k ] = pRate_Q5[ input_index ] + SKP_LSHIFT32( ( SKP_int32 )pCurrentCBStage->Rates_Q4[ cb_index ], 1 );\r
+            pRate_new_Q4[ k ] = pRate_Q4[ input_index ] + pCurrentCBStage->Rates_Q4[ cb_index ];\r
 \r
             /* Copy paths from previous matrix, starting with the best path */\r
             pConstInt8 = &pPath[ SKP_SMULBB( input_index, psNLSF_CB->nStages ) ];\r
@@ -167,7 +167,7 @@ void SKP_Silk_NLSF_MSVQ_encode_FIX(
             SKP_memcpy( pRes_Q15, pRes_new_Q15, SKP_SMULBB( cur_survivors, LPC_order ) * sizeof( SKP_int16 ) );\r
 \r
             /* Copy rate vector for next stage */\r
-            SKP_memcpy( pRate_Q5, pRate_new_Q5, cur_survivors * sizeof( SKP_int32 ) );\r
+            SKP_memcpy( pRate_Q4, pRate_new_Q4, cur_survivors * sizeof( SKP_int32 ) );\r
 \r
             /* Copy best path matrix for next stage */\r
             SKP_memcpy( pPath, pPath_new, SKP_SMULBB( cur_survivors, psNLSF_CB->nStages ) * sizeof( SKP_int8) );\r
@@ -196,11 +196,11 @@ void SKP_Silk_NLSF_MSVQ_encode_FIX(
             for( i = 0; i < LPC_order; i += 2 ) {\r
                 /* Compute weighted squared quantization error for index i */\r
                 se_Q15 = pNLSF_Q15[ i ] - pNLSF_q_Q15_prev[ i ]; // range: [ -32767 : 32767 ]\r
-                wsse_Q20 = SKP_SMLAWB( wsse_Q20, SKP_SMULBB( se_Q15, se_Q15 ), pW_Q6[ i ] );\r
+                wsse_Q20 = SKP_SMLAWB( wsse_Q20, SKP_SMULBB( se_Q15, se_Q15 ), pW_Q5[ i ] );\r
 \r
                 /* Compute weighted squared quantization error for index i + 1 */\r
                 se_Q15 = pNLSF_Q15[ i + 1 ] - pNLSF_q_Q15_prev[ i + 1 ]; // range: [ -32767 : 32767 ]\r
-                wsse_Q20 = SKP_SMLAWB( wsse_Q20, SKP_SMULBB( se_Q15, se_Q15 ), pW_Q6[ i + 1 ] );\r
+                wsse_Q20 = SKP_SMLAWB( wsse_Q20, SKP_SMULBB( se_Q15, se_Q15 ), pW_Q5[ i + 1 ] );\r
             }\r
             SKP_assert( wsse_Q20 >= 0 );\r
 \r
@@ -25,37 +25,38 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
 ***********************************************************************/\r
 \r
-#include "SKP_Silk_main_FIX.h"\r
+#include "SKP_Silk_main.h"\r
 \r
 /* Rate-Distortion calculations for multiple input data vectors */\r
-void SKP_Silk_NLSF_VQ_rate_distortion_FIX(\r
-    SKP_int32                       *pRD_Q20,           /* O    Rate-distortion values [psNLSF_CBS->nVectors*N] */\r
+void SKP_Silk_NLSF_VQ_rate_distortion(\r
+    SKP_int32                       *pRD_Q19,           /* O    Rate-distortion values [psNLSF_CBS->nVectors*N] */\r
     const SKP_Silk_NLSF_CBS         *psNLSF_CBS,        /* I    NLSF codebook stage struct                      */\r
     const SKP_int16                 *in_Q15,            /* I    Input vectors to be quantized                   */\r
-    const SKP_int                   *w_Q6,              /* I    Weight vector                                   */\r
-    const SKP_int32                 *rate_acc_Q5,       /* I    Accumulated rates from previous stage           */\r
+    const SKP_int                   *w_Q5,              /* I    Weight vector                                   */\r
+    const SKP_int32                 *rate_acc_Q4,       /* I    Accumulated rates from previous stage           */\r
     const SKP_int                   mu_Q15,             /* I    Weight between weighted error and rate          */\r
     const SKP_int                   N,                  /* I    Number of input vectors to be quantized         */\r
+    const SKP_int                   stage,              /* I    Stage number                                */\r
     const SKP_int                   LPC_order           /* I    LPC order                                       */\r
 )\r
 {\r
     SKP_int   i, n;\r
-    SKP_int32 *pRD_vec_Q20;\r
+    SKP_int32 *pRD_vec_Q19;\r
 \r
     /* Compute weighted quantization errors for all input vectors over one codebook stage */\r
-    SKP_Silk_NLSF_VQ_sum_error_FIX( pRD_Q20, in_Q15, w_Q6, psNLSF_CBS->CB_NLSF_Q8, \r
-        N, psNLSF_CBS->nVectors, LPC_order );\r
+    SKP_Silk_NLSF_VQ_sum_error( pRD_Q19, in_Q15, w_Q5, psNLSF_CBS->CB_NLSF_Q8, \r
+        N, psNLSF_CBS->nVectors, stage, LPC_order );\r
 \r
     /* Loop over input vectors */\r
-    pRD_vec_Q20 = pRD_Q20;\r
+    pRD_vec_Q19 = pRD_Q19;\r
     for( n = 0; n < N; n++ ) {\r
         /* Add rate cost to error for each codebook vector */\r
         for( i = 0; i < psNLSF_CBS->nVectors; i++ ) {\r
-            SKP_assert( rate_acc_Q5[ n ] + SKP_LSHIFT32( ( SKP_int32 )psNLSF_CBS->Rates_Q4[ i ], 1 ) >= 0 );\r
-            SKP_assert( rate_acc_Q5[ n ] + SKP_LSHIFT32( ( SKP_int32 )psNLSF_CBS->Rates_Q4[ i ], 1 ) <= SKP_int16_MAX );\r
-            pRD_vec_Q20[ i ] = SKP_SMLABB( pRD_vec_Q20[ i ], rate_acc_Q5[ n ] + SKP_LSHIFT32( ( SKP_int32 )psNLSF_CBS->Rates_Q4[ i ], 1 ), mu_Q15 );\r
-            SKP_assert( pRD_vec_Q20[ i ] >= 0 );\r
+            SKP_assert( rate_acc_Q4[ n ] + SKP_LSHIFT32( ( SKP_int32 )psNLSF_CBS->Rates_Q4[ i ], 1 ) >= 0 );\r
+            SKP_assert( rate_acc_Q4[ n ] + SKP_LSHIFT32( ( SKP_int32 )psNLSF_CBS->Rates_Q4[ i ], 1 ) <= SKP_int16_MAX );\r
+            pRD_vec_Q19[ i ] = SKP_SMLABB( pRD_vec_Q19[ i ], rate_acc_Q4[ n ] + psNLSF_CBS->Rates_Q4[ i ], mu_Q15 );\r
+            SKP_assert( pRD_vec_Q19[ i ] >= 0 );\r
         }\r
-        pRD_vec_Q20 += psNLSF_CBS->nVectors;\r
+        pRD_vec_Q19 += psNLSF_CBS->nVectors;\r
     }\r
 }\r
diff --git a/src_common/SKP_Silk_NLSF_VQ_sum_error.c b/src_common/SKP_Silk_NLSF_VQ_sum_error.c
new file mode 100644 (file)
index 0000000..bb52c51
--- /dev/null
@@ -0,0 +1,107 @@
+/***********************************************************************\r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
+Redistribution and use in source and binary forms, with or without \r
+modification, (subject to the limitations in the disclaimer below) \r
+are permitted provided that the following conditions are met:\r
+- Redistributions of source code must retain the above copyright notice,\r
+this list of conditions and the following disclaimer.\r
+- Redistributions in binary form must reproduce the above copyright \r
+notice, this list of conditions and the following disclaimer in the \r
+documentation and/or other materials provided with the distribution.\r
+- Neither the name of Skype Limited, nor the names of specific \r
+contributors, may be used to endorse or promote products derived from \r
+this software without specific prior written permission.\r
+NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED \r
+BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND \r
+CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,\r
+BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND \r
+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \r
+COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \r
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF \r
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON \r
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \r
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+***********************************************************************/\r
+\r
+#include "SKP_Silk_main.h"\r
+\r
+/* Compute weighted quantization errors for an LPC_order element input vector, over one codebook stage */\r
+void SKP_Silk_NLSF_VQ_sum_error(\r
+    SKP_int32                       *err_Q19,           /* O    Weighted quantization errors  [N*K]         */\r
+    const SKP_int16                 *in_Q15,            /* I    Input vectors to be quantized [N*LPC_order] */\r
+    const SKP_int                   *w_Q5,              /* I    Weighting vectors             [LPC_order]   */\r
+    const SKP_int8                  *pCB_Q8,            /* I    Codebook vectors              [K*LPC_order] */\r
+    const SKP_int                   N,                  /* I    Number of input vectors                     */\r
+    const SKP_int                   K,                  /* I    Number of codebook vectors                  */\r
+    const SKP_int                   stage,              /* I    Stage number                                */\r
+    const SKP_int                   LPC_order           /* I    Number of LPCs                              */\r
+)\r
+{\r
+    SKP_int        i, n, m;\r
+    SKP_int32      diff_Q15, sum_error, Wtmp_Q5;\r
+    SKP_int32      Wcpy_Q5[ MAX_LPC_ORDER / 2 ];\r
+    const SKP_int8 *cb_vec_Q8;\r
+\r
+    SKP_assert( LPC_order <= 16 );\r
+    SKP_assert( ( LPC_order & 1 ) == 0 );\r
+\r
+    /* Copy to local stack and pack two weights per int32 */\r
+    for( m = 0; m < SKP_RSHIFT( LPC_order, 1 ); m++ ) {\r
+        Wcpy_Q5[ m ] = w_Q5[ 2 * m ] | SKP_LSHIFT( ( SKP_int32 )w_Q5[ 2 * m + 1 ], 16 );\r
+    }\r
+\r
+    if( stage == 0 ) {\r
+        /* Loop over input vectors */\r
+        for( n = 0; n < N; n++ ) {\r
+            /* Loop over codebook */\r
+            cb_vec_Q8 = pCB_Q8;\r
+            for( i = 0; i < K; i++ ) {\r
+                sum_error = 0;\r
+                for( m = 0; m < LPC_order; m += 2 ) {\r
+                    /* Get two weights packed in an int32 */\r
+                    Wtmp_Q5 = Wcpy_Q5[ m >> 1 ];\r
+\r
+                    /* Compute weighted squared quantization error for index m */\r
+                    diff_Q15 = in_Q15[ m ] - SKP_LSHIFT16( ( SKP_int16 )( *cb_vec_Q8++ ), 15 - NLSF_Q_DOMAIN_STAGE_0 ); // range: [ -32767 : 32767 ]\r
+                    sum_error = SKP_SMLAWB( sum_error, SKP_SMULBB( diff_Q15, diff_Q15 ), Wtmp_Q5 );\r
+\r
+                    /* Compute weighted squared quantization error for index m + 1 */\r
+                    diff_Q15 = in_Q15[m + 1] - SKP_LSHIFT16( ( SKP_int16 )( *cb_vec_Q8++ ), 15 - NLSF_Q_DOMAIN_STAGE_0 ); // range: [ -32767 : 32767 ]\r
+                    sum_error = SKP_SMLAWT( sum_error, SKP_SMULBB( diff_Q15, diff_Q15 ), Wtmp_Q5 );\r
+                }\r
+                SKP_assert( sum_error >= 0 );\r
+                err_Q19[ i ] = sum_error;\r
+            }\r
+            err_Q19 += K;\r
+            in_Q15 += LPC_order;\r
+        }\r
+    } else {\r
+        /* Loop over input vectors */\r
+        for( n = 0; n < N; n++ ) {\r
+            /* Loop over codebook */\r
+            cb_vec_Q8 = pCB_Q8;\r
+            for( i = 0; i < K; i++ ) {\r
+                sum_error = 0;\r
+                for( m = 0; m < LPC_order; m += 2 ) {\r
+                    /* Get two weights packed in an int32 */\r
+                    Wtmp_Q5 = Wcpy_Q5[ m >> 1 ];\r
+\r
+                    /* Compute weighted squared quantization error for index m */\r
+                    diff_Q15 = in_Q15[ m ] - SKP_LSHIFT16( ( SKP_int16 )( *cb_vec_Q8++ ), 15 - NLSF_Q_DOMAIN_STAGE_2_TO_LAST ); // range: [ -32767 : 32767 ]\r
+                    sum_error = SKP_SMLAWB( sum_error, SKP_SMULBB( diff_Q15, diff_Q15 ), Wtmp_Q5 );\r
+\r
+                    /* Compute weighted squared quantization error for index m + 1 */\r
+                    diff_Q15 = in_Q15[m + 1] - SKP_LSHIFT16( ( SKP_int16 )( *cb_vec_Q8++ ), 15 - NLSF_Q_DOMAIN_STAGE_2_TO_LAST ); // range: [ -32767 : 32767 ]\r
+                    sum_error = SKP_SMLAWT( sum_error, SKP_SMULBB( diff_Q15, diff_Q15 ), Wtmp_Q5 );\r
+                }\r
+                SKP_assert( sum_error >= 0 );\r
+                err_Q19[ i ] = sum_error;\r
+            }\r
+            err_Q19 += K;\r
+            in_Q15 += LPC_order;\r
+        }\r
+    }\r
+}\r
+\r
index 8eea901..4aa918f 100644 (file)
@@ -89,10 +89,10 @@ void SKP_Silk_NSQ(
     SKP_int     offset_Q10;\r
     SKP_int32   x_sc_Q10[ MAX_FRAME_LENGTH / MAX_NB_SUBFR ];\r
 \r
-    NSQ->rand_seed  =  psIndices->Seed;\r
+    NSQ->rand_seed = psIndices->Seed;\r
 \r
     /* Set unvoiced lag to the previous one, overwrite later for voiced */\r
-    lag             = NSQ->lagPrev;\r
+    lag = NSQ->lagPrev;\r
 \r
     SKP_assert( NSQ->prev_inv_gain_Q16 != 0 );\r
 \r
index 96ca24b..cecdce2 100644 (file)
@@ -28,8 +28,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <stdlib.h>\r
 #include "SKP_Silk_main.h"\r
 \r
-#define SKP_SILK_VAD_HANDLE_10MS_FRAMES     1\r
-\r
 /**********************************/\r
 /* Initialization of the Silk VAD */\r
 /**********************************/\r
@@ -69,55 +67,44 @@ const static SKP_int32 tiltWeights[ VAD_N_BANDS ] = { 30000, 6000, -12000, -1200
 /***************************************/\r
 /* Get the speech activity level in Q8 */\r
 /***************************************/\r
-SKP_int SKP_Silk_VAD_GetSA_Q8(                                  /* O    Return value, 0 if success      */\r
-    SKP_Silk_VAD_state          *psSilk_VAD,                    /* I/O  Silk VAD state                  */\r
-    SKP_int                     *pSA_Q8,                        /* O    Speech activity level in Q8     */\r
-    SKP_int                     *pSNR_dB_Q7,                    /* O    SNR for current frame in Q7     */\r
-    SKP_int                     pQuality_Q15[ VAD_N_BANDS ],    /* O    Smoothed SNR for each band      */\r
-    SKP_int                     *pTilt_Q15,                     /* O    current frame's frequency tilt  */\r
-    const SKP_int16             pIn[],                          /* I    PCM input       [framelength]   */\r
-    const SKP_int               framelength,                    /* I    Input frame length              */\r
-    const SKP_int               fs_kHz                          /* I    Input frame sample frequency    */\r
+SKP_int SKP_Silk_VAD_GetSA_Q8(                      /* O    Return value, 0 if success                  */\r
+    SKP_Silk_encoder_state      *psEncC,            /* I/O  Encoder state                               */\r
+    const SKP_int16             pIn[]               /* I    PCM input                                   */\r
 )\r
 {\r
-    SKP_int   SA_Q15, input_tilt;\r
-    SKP_int32 scratch[ 3 * MAX_FRAME_LENGTH / 2 ];\r
+    SKP_int   SA_Q15, pSNR_dB_Q7, input_tilt;\r
     SKP_int   decimated_framelength, dec_subframe_length, dec_subframe_offset, SNR_Q7, i, b, s;\r
     SKP_int32 sumSquared, smooth_coef_Q16;\r
     SKP_int16 HPstateTmp;\r
-\r
     SKP_int16 X[ VAD_N_BANDS ][ MAX_FRAME_LENGTH / 2 ];\r
     SKP_int32 Xnrg[ VAD_N_BANDS ];\r
     SKP_int32 NrgToNoiseRatio_Q8[ VAD_N_BANDS ];\r
     SKP_int32 speech_nrg, x_tmp;\r
     SKP_int   ret = 0;\r
-    \r
-#if SKP_SILK_VAD_HANDLE_10MS_FRAMES\r
-    SKP_int   normalizer;\r
-#endif\r
+    SKP_Silk_VAD_state *psSilk_VAD = &psEncC->sVAD;\r
 \r
     /* Safety checks */\r
     SKP_assert( VAD_N_BANDS == 4 );\r
-    SKP_assert( MAX_FRAME_LENGTH >= framelength );\r
-    SKP_assert( framelength <= 512 );\r
-    SKP_assert( framelength == 8 * SKP_RSHIFT( framelength, 3 ) );\r
+    SKP_assert( MAX_FRAME_LENGTH >= psEncC->frame_length );\r
+    SKP_assert( psEncC->frame_length <= 512 );\r
+    SKP_assert( psEncC->frame_length == 8 * SKP_RSHIFT( psEncC->frame_length, 3 ) );\r
 \r
     /***********************/\r
     /* Filter and Decimate */\r
     /***********************/\r
     /* 0-8 kHz to 0-4 kHz and 4-8 kHz */\r
-    SKP_Silk_ana_filt_bank_1( pIn,          &psSilk_VAD->AnaState[  0 ], &X[ 0 ][ 0 ], &X[ 3 ][ 0 ], &scratch[ 0 ], framelength );        \r
+    SKP_Silk_ana_filt_bank_1( pIn,          &psSilk_VAD->AnaState[  0 ], &X[ 0 ][ 0 ], &X[ 3 ][ 0 ], psEncC->frame_length );        \r
     \r
     /* 0-4 kHz to 0-2 kHz and 2-4 kHz */\r
-    SKP_Silk_ana_filt_bank_1( &X[ 0 ][ 0 ], &psSilk_VAD->AnaState1[ 0 ], &X[ 0 ][ 0 ], &X[ 2 ][ 0 ], &scratch[ 0 ], SKP_RSHIFT( framelength, 1 ) );\r
+    SKP_Silk_ana_filt_bank_1( &X[ 0 ][ 0 ], &psSilk_VAD->AnaState1[ 0 ], &X[ 0 ][ 0 ], &X[ 2 ][ 0 ], SKP_RSHIFT( psEncC->frame_length, 1 ) );\r
     \r
     /* 0-2 kHz to 0-1 kHz and 1-2 kHz */\r
-    SKP_Silk_ana_filt_bank_1( &X[ 0 ][ 0 ], &psSilk_VAD->AnaState2[ 0 ], &X[ 0 ][ 0 ], &X[ 1 ][ 0 ], &scratch[ 0 ], SKP_RSHIFT( framelength, 2 ) );\r
+    SKP_Silk_ana_filt_bank_1( &X[ 0 ][ 0 ], &psSilk_VAD->AnaState2[ 0 ], &X[ 0 ][ 0 ], &X[ 1 ][ 0 ], SKP_RSHIFT( psEncC->frame_length, 2 ) );\r
 \r
     /*********************************************/\r
     /* HP filter on lowest band (differentiator) */\r
     /*********************************************/\r
-    decimated_framelength = SKP_RSHIFT( framelength, 3 );\r
+    decimated_framelength = SKP_RSHIFT( psEncC->frame_length, 3 );\r
     X[ 0 ][ decimated_framelength - 1 ] = SKP_RSHIFT( X[ 0 ][ decimated_framelength - 1 ], 1 );\r
     HPstateTmp = X[ 0 ][ decimated_framelength - 1 ];\r
     for( i = decimated_framelength - 1; i > 0; i-- ) {\r
@@ -132,7 +119,7 @@ SKP_int SKP_Silk_VAD_GetSA_Q8(                                  /* O    Return v
     /*************************************/\r
     for( b = 0; b < VAD_N_BANDS; b++ ) {        \r
         /* Find the decimated framelength in the non-uniformly divided bands */\r
-        decimated_framelength = SKP_RSHIFT( framelength, SKP_min_int( VAD_N_BANDS - b, VAD_N_BANDS - 1 ) );\r
+        decimated_framelength = SKP_RSHIFT( psEncC->frame_length, SKP_min_int( VAD_N_BANDS - b, VAD_N_BANDS - 1 ) );\r
 \r
         /* Split length into subframe lengths */\r
         dec_subframe_length = SKP_RSHIFT( decimated_framelength, VAD_INTERNAL_SUBFRAMES_LOG2 );\r
@@ -207,17 +194,17 @@ SKP_int SKP_Silk_VAD_GetSA_Q8(                                  /* O    Return v
     sumSquared = SKP_DIV32_16( sumSquared, VAD_N_BANDS ); /* Q14 */\r
 \r
     /* Root-mean-square approximation, scale to dBs, and write to output pointer */\r
-    *pSNR_dB_Q7 = ( SKP_int16 )( 3 * SKP_Silk_SQRT_APPROX( sumSquared ) ); /* Q7 */\r
+    pSNR_dB_Q7 = ( SKP_int16 )( 3 * SKP_Silk_SQRT_APPROX( sumSquared ) ); /* Q7 */\r
 \r
     /*********************************/\r
     /* Speech Probability Estimation */\r
     /*********************************/\r
-    SA_Q15 = SKP_Silk_sigm_Q15( SKP_SMULWB( VAD_SNR_FACTOR_Q16, *pSNR_dB_Q7 ) - VAD_NEGATIVE_OFFSET_Q5 );\r
+    SA_Q15 = SKP_Silk_sigm_Q15( SKP_SMULWB( VAD_SNR_FACTOR_Q16, pSNR_dB_Q7 ) - VAD_NEGATIVE_OFFSET_Q5 );\r
 \r
     /**************************/\r
     /* Frequency Tilt Measure */\r
     /**************************/\r
-    *pTilt_Q15 = SKP_LSHIFT( SKP_Silk_sigm_Q15( input_tilt ) - 16384, 1 );\r
+    psEncC->input_tilt_Q15 = SKP_LSHIFT( SKP_Silk_sigm_Q15( input_tilt ) - 16384, 1 );\r
 \r
     /**************************************************/\r
     /* Scale the sigmoid output based on power levels */\r
@@ -232,24 +219,19 @@ SKP_int SKP_Silk_VAD_GetSA_Q8(                                  /* O    Return v
     if( speech_nrg <= 0 ) {\r
         SA_Q15 = SKP_RSHIFT( SA_Q15, 1 ); \r
     } else if( speech_nrg < 32768 ) {\r
-        \r
-#if SKP_SILK_VAD_HANDLE_10MS_FRAMES\r
-        /* Energy normalization of frames shorter than 320 samples */\r
-        normalizer = 0;\r
-        while( SKP_LSHIFT( framelength, normalizer ) < 320 ) {\r
-            normalizer++;\r
+        if( psEncC->frame_length == 10 * psEncC->fs_kHz ) {\r
+            speech_nrg = SKP_LSHIFT_SAT32( speech_nrg, 16 );\r
+        } else {\r
+            speech_nrg = SKP_LSHIFT_SAT32( speech_nrg, 15 );\r
         }\r
-        speech_nrg = SKP_LSHIFT_SAT32( speech_nrg, 15 + normalizer );\r
-#else\r
-        speech_nrg = SKP_LSHIFT_SAT32( speech_nrg, 15 );\r
-#endif\r
+\r
         /* square-root */\r
         speech_nrg = SKP_Silk_SQRT_APPROX( speech_nrg );\r
         SA_Q15 = SKP_SMULWB( 32768 + speech_nrg, SA_Q15 ); \r
     }\r
 \r
-    /* Copy the resulting speech activity in Q8 to *pSA_Q8 */\r
-    *pSA_Q8 = SKP_min_int( SKP_RSHIFT( SA_Q15, 7 ), SKP_uint8_MAX );\r
+    /* Copy the resulting speech activity in Q8 */\r
+    psEncC->speech_activity_Q8 = SKP_min_int( SKP_RSHIFT( SA_Q15, 7 ), SKP_uint8_MAX );\r
 \r
     /***********************************/\r
     /* Energy Level and SNR estimation */\r
@@ -257,13 +239,11 @@ SKP_int SKP_Silk_VAD_GetSA_Q8(                                  /* O    Return v
     /* Smoothing coefficient */\r
     smooth_coef_Q16 = SKP_SMULWB( VAD_SNR_SMOOTH_COEF_Q18, SKP_SMULWB( SA_Q15, SA_Q15 ) );\r
     \r
-#if SKP_SILK_VAD_HANDLE_10MS_FRAMES\r
-    if( framelength == 10 * fs_kHz ) {\r
+    if( psEncC->frame_length == 10 * psEncC->fs_kHz ) {\r
         smooth_coef_Q16 >>= 1;\r
     } else {\r
-       SKP_assert( framelength == 20 * fs_kHz );\r
+       SKP_assert( psEncC->frame_length == 20 * psEncC->fs_kHz );\r
     }\r
-#endif\r
 \r
     for( b = 0; b < VAD_N_BANDS; b++ ) {\r
         /* compute smoothed energy-to-noise ratio per band */\r
@@ -273,7 +253,7 @@ SKP_int SKP_Silk_VAD_GetSA_Q8(                                  /* O    Return v
         /* signal to noise ratio in dB per band */\r
         SNR_Q7 = 3 * ( SKP_Silk_lin2log( psSilk_VAD->NrgRatioSmth_Q8[b] ) - 8 * 128 );\r
         /* quality = sigmoid( 0.25 * ( SNR_dB - 16 ) ); */\r
-        pQuality_Q15[ b ] = SKP_Silk_sigm_Q15( SKP_RSHIFT( SNR_Q7 - 16 * 128, 4 ) );\r
+        psEncC->input_quality_bands_Q15[ b ] = SKP_Silk_sigm_Q15( SKP_RSHIFT( SNR_Q7 - 16 * 128, 4 ) );\r
     }\r
 \r
     return( ret );\r
index 6b728da..efa482a 100644 (file)
@@ -62,76 +62,51 @@ SKP_int SKP_Silk_control_audio_bandwidth(
         fs_kHz = SKP_max( fs_kHz, psEncC->minInternal_fs_kHz );\r
     } else {\r
         /* State machine for the internal sampling rate switching */\r
-        if( psEncC->API_fs_Hz > 8000 ) {\r
-            /* Accumulate the difference between the target rate and limit for switching down */\r
-            psEncC->bitrateDiff += SKP_MUL( psEncC->PacketSize_ms, TargetRate_bps - psEncC->bitrate_threshold_down );\r
-            psEncC->bitrateDiff  = SKP_min( psEncC->bitrateDiff, 0 );\r
+        if( psEncC->API_fs_Hz > 8000 && psEncC->prevSignalType == TYPE_NO_VOICE_ACTIVITY ) { /* Low speech activity */\r
+            /* Check if we should switch down */\r
+            if( ( psEncC->fs_kHz == 12 && TargetRate_bps < MB2NB_BITRATE_BPS && psEncC->minInternal_fs_kHz <=  8 ) ||\r
+                ( psEncC->fs_kHz == 16 && TargetRate_bps < WB2MB_BITRATE_BPS && psEncC->minInternal_fs_kHz <= 12 ) ) \r
+            {\r
+                /* Switch down */\r
+                if( SWITCH_TRANSITION_FILTERING && psEncC->sLP.mode == 0 ) {\r
+                    /* New transition */\r
+                    psEncC->sLP.transition_frame_no = TRANSITION_FRAMES;\r
 \r
-            if( psEncC->prevSignalType == TYPE_NO_VOICE_ACTIVITY ) { /* Low speech activity */\r
-                /* Check if we should switch down */\r
-#if SWITCH_TRANSITION_FILTERING \r
-                if( ( psEncC->sLP.transition_frame_no == 0 ) &&                         /* Transition phase not active */\r
-                    ( psEncC->bitrateDiff <= -ACCUM_BITS_DIFF_THRESHOLD ) ) {           /* Bitrate threshold is met */\r
-                        psEncC->sLP.transition_frame_no = 1;                            /* Begin transition phase */\r
-                        psEncC->sLP.mode                = 0;                            /* Switch down */\r
-                } else if( \r
-                    ( psEncC->sLP.transition_frame_no >= TRANSITION_FRAMES_DOWN ) &&    /* Transition phase complete */\r
-                    ( psEncC->sLP.mode == 0 ) ) {                                       /* Ready to switch down */\r
-                        psEncC->sLP.transition_frame_no = 0;                            /* Ready for new transition phase */\r
-#else\r
-                if( psEncC->bitrateDiff <= -ACCUM_BITS_DIFF_THRESHOLD ) {               /* Bitrate threshold is met */ \r
-#endif            \r
-                    psEncC->bitrateDiff = 0;\r
+                    /* Reset transition filter state */\r
+                    SKP_memset( psEncC->sLP.In_LP_State, 0, sizeof( psEncC->sLP.In_LP_State ) );\r
+                } \r
+                if( psEncC->sLP.transition_frame_no <= 0 ) {\r
+                    /* Stop transition phase */\r
+                    psEncC->sLP.mode = 0;\r
 \r
                     /* Switch to a lower sample frequency */\r
-                    if( psEncC->fs_kHz == 24 ) {\r
-                        fs_kHz = 16;\r
-                    } else if( psEncC->fs_kHz == 16 ) {\r
-                        fs_kHz = 12;\r
-                    } else {\r
-                        SKP_assert( psEncC->fs_kHz == 12 );\r
-                        fs_kHz = 8;\r
-                    }\r
-                }\r
-\r
-                /* Check if we should switch up */\r
-                if( ( ( psEncC->fs_kHz * 1000 < psEncC->API_fs_Hz ) &&\r
-                    ( TargetRate_bps > psEncC->bitrate_threshold_up ) ) && \r
-                    ( ( psEncC->fs_kHz == 12 ) && ( psEncC->maxInternal_fs_kHz >= 16 ) ||\r
-                    ( psEncC->fs_kHz ==  8 ) && ( psEncC->maxInternal_fs_kHz >= 12 ) ) \r
-#if SWITCH_TRANSITION_FILTERING\r
-                    && ( psEncC->sLP.transition_frame_no == 0 ) )  /* No transition phase running, ready to switch */\r
-                {\r
-                    psEncC->sLP.mode = 1; /* Switch up */\r
-#else\r
-                ) {\r
-#endif\r
-                    psEncC->bitrateDiff = 0;\r
-\r
+                    fs_kHz = psEncC->fs_kHz == 16 ? 12 : 8;\r
+                } else {\r
+                    /* Direction: down (at double speed) */\r
+                    psEncC->sLP.mode = -2;\r
+                } \r
+            } \r
+            else\r
+            if( ( psEncC->fs_kHz ==  8 && TargetRate_bps > NB2MB_BITRATE_BPS && psEncC->maxInternal_fs_kHz >= 12 && psEncC->API_fs_Hz >= 12000 ) ||\r
+                ( psEncC->fs_kHz == 12 && TargetRate_bps > MB2WB_BITRATE_BPS && psEncC->maxInternal_fs_kHz >= 16 && psEncC->API_fs_Hz >= 16000 ) ) \r
+            {\r
+                /* Switch up */\r
+                if( SWITCH_TRANSITION_FILTERING && psEncC->sLP.mode == 0 ) {\r
                     /* Switch to a higher sample frequency */\r
-                    if( psEncC->fs_kHz == 8 ) {\r
-                        fs_kHz = 12;\r
-                    } else if( psEncC->fs_kHz == 12 ) {\r
-                        fs_kHz = 16;\r
-                    } else {\r
-                        SKP_assert( 0 );\r
-                    }\r
+                    fs_kHz = psEncC->fs_kHz == 8 ? 12 : 16;\r
+\r
+                    /* New transition */\r
+                    psEncC->sLP.transition_frame_no = 0;\r
+                } \r
+                if( psEncC->sLP.transition_frame_no >= TRANSITION_FRAMES ) {\r
+                    /* Stop transition phase */\r
+                    psEncC->sLP.mode = 0;\r
+                } else {\r
+                    /* Direction: up */\r
+                    psEncC->sLP.mode = 1;\r
                 }\r
             }\r
         }\r
-\r
-#if SWITCH_TRANSITION_FILTERING\r
-        /* After switching up, stop transition filter during speech inactivity */\r
-        if( ( psEncC->sLP.mode == 1 ) &&\r
-            ( psEncC->sLP.transition_frame_no >= TRANSITION_FRAMES_UP ) && \r
-            ( psEncC->prevSignalType == TYPE_NO_VOICE_ACTIVITY ) ) {\r
-\r
-                psEncC->sLP.transition_frame_no = 0;\r
-\r
-                /* Reset transition filter state */\r
-                SKP_memset( psEncC->sLP.In_LP_State, 0, 2 * sizeof( SKP_int32 ) );\r
-        }\r
-#endif\r
     }\r
 \r
 #ifdef FORCE_INTERNAL_FS_KHZ\r
index b457b32..b090450 100644 (file)
@@ -64,7 +64,6 @@ TIC(DECODE_FRAME)
     if( lostFlag != PACKET_LOST && psDec->nFramesDecoded == 0 ) {\r
         /* First decoder call for this payload */\r
         /* Decode VAD flags and LBRR flag */\r
-        SKP_uint8 iCDF[ 2 ] = { 128, 0 };\r
         flags = SKP_RSHIFT( psRangeDec->buf[ 0 ], 7 - psDec->nFramesPerPacket ) & \r
             ( SKP_LSHIFT( 1, psDec->nFramesPerPacket + 1 ) - 1 );\r
         psDec->LBRR_flag = flags & 1;\r
@@ -73,7 +72,7 @@ TIC(DECODE_FRAME)
             psDec->VAD_flags[ i ] = flags & 1;\r
         }\r
         for( i = 0; i < psDec->nFramesPerPacket + 1; i++ ) {\r
-            ec_dec_icdf( psRangeDec, iCDF, 8 );\r
+            ec_dec_icdf( psRangeDec, SKP_Silk_uniform2_iCDF, 8 );\r
         }\r
        \r
         /* Decode LBRR flags */\r
index 58f3ae4..61bbcbd 100644 (file)
@@ -58,10 +58,6 @@ extern "C"
 #define MB2WB_BITRATE_BPS                       16000\r
 #define MB2NB_BITRATE_BPS                        9000\r
 #define NB2MB_BITRATE_BPS                       12000\r
-\r
-/* Integration/hysteresis threshold for lowering internal sample frequency */\r
-/* 30000000 -> 6 sec if bitrate is 5000 bps below limit; 3 sec if bitrate is 10000 bps below limit */\r
-#define ACCUM_BITS_DIFF_THRESHOLD               30000000 \r
 #define TARGET_RATE_TAB_SZ                      8\r
 \r
 /* DTX settings                                 */\r
@@ -215,6 +211,9 @@ extern "C"
 #define NLSF_MSVQ_FLUCTUATION_REDUCTION         1\r
 #define MAX_NLSF_MSVQ_SURVIVORS                 16\r
 \r
+#define NLSF_Q_DOMAIN_STAGE_0                   8\r
+#define NLSF_Q_DOMAIN_STAGE_2_TO_LAST           8\r
+\r
 /* Based on above defines, calculate how much memory is necessary to allocate */\r
 #if( NLSF_MSVQ_MAX_VECTORS_IN_STAGE > ( MAX_NLSF_MSVQ_SURVIVORS_LC_MODE * NLSF_MSVQ_MAX_VECTORS_IN_STAGE_TWO_TO_END ) )\r
 #   define NLSF_MSVQ_TREE_SEARCH_MAX_VECTORS_EVALUATED_LC_MODE  NLSF_MSVQ_MAX_VECTORS_IN_STAGE\r
@@ -232,15 +231,14 @@ extern "C"
 \r
 /* Transition filtering for mode switching */\r
 #if SWITCH_TRANSITION_FILTERING\r
-#  define TRANSITION_TIME_UP_MS                 5120 // 5120 = 64 * FRAME_LENGTH_MS * ( TRANSITION_INT_NUM - 1 ) = 64*(20*4)\r
-#  define TRANSITION_TIME_DOWN_MS               2560 // 2560 = 32 * FRAME_LENGTH_MS * ( TRANSITION_INT_NUM - 1 ) = 32*(20*4)\r
+#  define TRANSITION_TIME_MS                    5120 // 5120 = 64 * FRAME_LENGTH_MS * ( TRANSITION_INT_NUM - 1 ) = 64*(20*4)\r
 #  define TRANSITION_NB                         3 /* Hardcoded in tables */\r
 #  define TRANSITION_NA                         2 /* Hardcoded in tables */\r
 #  define TRANSITION_INT_NUM                    5 /* Hardcoded in tables */\r
-#  define TRANSITION_FRAMES_UP                  ( TRANSITION_TIME_UP_MS   / MAX_FRAME_LENGTH_MS ) // NB! needs to be made flexible for 10 ms frames\r
-#  define TRANSITION_FRAMES_DOWN                ( TRANSITION_TIME_DOWN_MS / MAX_FRAME_LENGTH_MS ) // NB! needs to be made flexible for 10 ms frames\r
-#  define TRANSITION_INT_STEPS_UP               ( TRANSITION_FRAMES_UP    / ( TRANSITION_INT_NUM - 1 )  )\r
-#  define TRANSITION_INT_STEPS_DOWN             ( TRANSITION_FRAMES_DOWN  / ( TRANSITION_INT_NUM - 1 )  )\r
+#  define TRANSITION_FRAMES                     ( TRANSITION_TIME_MS / MAX_FRAME_LENGTH_MS ) // todo: needs to be made flexible for 10 ms frames\r
+#  define TRANSITION_INT_STEPS                  ( TRANSITION_FRAMES  / ( TRANSITION_INT_NUM - 1 ) )\r
+#else\r
+#  define TRANSITION_FRAMES                     0\r
 #endif\r
 \r
 /* BWE factors to apply after packet loss */\r
index 1c7b59c..d2b6bac 100644 (file)
@@ -46,6 +46,74 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #endif\r
 #define SKP_Silk_EncodeControlStruct    SKP_SILK_SDK_EncControlStruct\r
 \r
+/**************************/\r
+/* Encode frame with Silk */\r
+/**************************/\r
+static SKP_int process_enc_control_struct( \r
+    SKP_Silk_encoder_state_Fxx          *psEnc,         /* I/O: State                                           */\r
+    SKP_Silk_EncodeControlStruct        *encControl     /* I:   Control structure                               */\r
+)\r
+{\r
+    SKP_int   max_internal_fs_kHz, min_internal_fs_kHz, Complexity, PacketSize_ms, PacketLoss_perc, UseInBandFEC, ret = SKP_SILK_NO_ERROR;\r
+    SKP_int32 TargetRate_bps, API_fs_Hz;\r
+\r
+    SKP_assert( encControl != NULL );\r
+\r
+    /* Check sampling frequency first, to avoid divide by zero later */\r
+    if( ( ( encControl->API_sampleRate        !=  8000 ) &&\r
+          ( encControl->API_sampleRate        != 12000 ) &&\r
+          ( encControl->API_sampleRate        != 16000 ) &&\r
+          ( encControl->API_sampleRate        != 24000 ) && \r
+          ( encControl->API_sampleRate        != 32000 ) &&\r
+          ( encControl->API_sampleRate        != 44100 ) &&\r
+          ( encControl->API_sampleRate        != 48000 ) ) ||\r
+        ( ( encControl->maxInternalSampleRate !=  8000 ) &&\r
+          ( encControl->maxInternalSampleRate != 12000 ) &&\r
+          ( encControl->maxInternalSampleRate != 16000 ) ) ||\r
+        ( ( encControl->minInternalSampleRate !=  8000 ) &&\r
+          ( encControl->minInternalSampleRate != 12000 ) &&\r
+          ( encControl->minInternalSampleRate != 16000 ) ) ||\r
+          ( encControl->minInternalSampleRate > encControl->maxInternalSampleRate ) ) {\r
+        ret = SKP_SILK_ENC_FS_NOT_SUPPORTED;\r
+        SKP_assert( 0 );\r
+        return( ret );\r
+    }\r
+    if( encControl->useDTX < 0 || encControl->useDTX > 1 ) {\r
+        ret = SKP_SILK_ENC_INVALID_DTX_SETTING;\r
+    }\r
+       if( encControl->useCBR < 0 || encControl->useCBR > 1 ) {\r
+        ret = SKP_SILK_ENC_INVALID_CBR_SETTING;\r
+    }\r
+\r
+    /* Set encoder parameters from control structure */\r
+    API_fs_Hz           =            encControl->API_sampleRate;\r
+    max_internal_fs_kHz = (SKP_int)( encControl->maxInternalSampleRate >> 10 ) + 1;   /* convert Hz -> kHz */\r
+    min_internal_fs_kHz = (SKP_int)( encControl->minInternalSampleRate >> 10 ) + 1;   /* convert Hz -> kHz */\r
+    PacketSize_ms       =            encControl->payloadSize_ms;\r
+    TargetRate_bps      =            encControl->bitRate;\r
+    PacketLoss_perc     =            encControl->packetLossPercentage;\r
+    UseInBandFEC        =            encControl->useInBandFEC;\r
+    Complexity          =            encControl->complexity;\r
+    psEnc->sCmn.useDTX  =            encControl->useDTX;\r
+       psEnc->sCmn.useCBR  =                    encControl->useCBR;\r
+\r
+    /* Save values in state */\r
+    psEnc->sCmn.API_fs_Hz          = API_fs_Hz;\r
+    psEnc->sCmn.maxInternal_fs_kHz = max_internal_fs_kHz;\r
+    psEnc->sCmn.minInternal_fs_kHz = min_internal_fs_kHz;\r
+    psEnc->sCmn.useInBandFEC       = UseInBandFEC;\r
+\r
+    TargetRate_bps = SKP_LIMIT( TargetRate_bps, MIN_TARGET_RATE_BPS, MAX_TARGET_RATE_BPS );\r
+    if( ( ret = SKP_Silk_control_encoder_Fxx( psEnc, PacketSize_ms, TargetRate_bps, \r
+                        PacketLoss_perc, Complexity) ) != 0 ) {\r
+        SKP_assert( 0 );\r
+        return( ret );\r
+    }\r
+\r
+    encControl->internalSampleRate = SKP_SMULBB( psEnc->sCmn.fs_kHz, 1000 );\r
+    \r
+    return ret;\r
+}\r
 \r
 /****************************************/\r
 /* Encoder functions                    */\r
@@ -60,6 +128,33 @@ SKP_int SKP_Silk_SDK_Get_Encoder_Size( SKP_int32 *encSizeBytes )
     return ret;\r
 }\r
 \r
+/*************************/\r
+/* Init or Reset encoder */\r
+/*************************/\r
+SKP_int SKP_Silk_SDK_InitEncoder(\r
+    void                            *encState,          /* I/O: State                                           */\r
+    SKP_Silk_EncodeControlStruct    *encStatus          /* O:   Control structure                               */\r
+)\r
+{\r
+    SKP_Silk_encoder_state_Fxx *psEnc;\r
+    SKP_int ret = SKP_SILK_NO_ERROR;\r
+\r
+        \r
+    psEnc = ( SKP_Silk_encoder_state_Fxx* )encState;\r
+\r
+    /* Reset Encoder */\r
+    if( ret += SKP_Silk_init_encoder_Fxx( psEnc ) ) {\r
+        SKP_assert( 0 );\r
+    }\r
+\r
+    /* Read control structure */\r
+    if( ret += SKP_Silk_SDK_QueryEncoder( encState, encStatus ) ) {\r
+        SKP_assert( 0 );\r
+    }\r
+\r
+\r
+    return ret;\r
+}\r
 \r
 /***************************************/\r
 /* Read control structure from encoder */\r
@@ -88,30 +183,72 @@ SKP_int SKP_Silk_SDK_QueryEncoder(
     return ret;\r
 }\r
 \r
-/*************************/\r
-/* Init or Reset encoder */\r
-/*************************/\r
-SKP_int SKP_Silk_SDK_InitEncoder(\r
-    void                            *encState,          /* I/O: State                                           */\r
-    SKP_Silk_EncodeControlStruct    *encStatus          /* O:   Control structure                               */\r
+/*****************************/\r
+/* Prefill look-ahead buffer */\r
+/*****************************/\r
+#define MAX_PREFILL_LENGTH_MS       10\r
+SKP_int SKP_Silk_SDK_Encoder_prefill_buffer( \r
+    void                                *encState,      /* I/O: State                                                       */\r
+    SKP_Silk_EncodeControlStruct        *encControl,    /* I:   Control structure                                           */\r
+    const SKP_int16                     *samplesIn,     /* I:   Speech sample input vector  (last part will be used)        */\r
+    SKP_int                             nSamplesIn      /* I:   Number of samples in input vector                           */\r
 )\r
 {\r
-    SKP_Silk_encoder_state_Fxx *psEnc;\r
-    SKP_int ret = SKP_SILK_NO_ERROR;\r
+    SKP_int start_ix, offset, nSamples, ret;\r
+    SKP_Silk_encoder_state_Fxx *psEnc = ( SKP_Silk_encoder_state_Fxx* )encState;\r
+    SKP_int16 buf[ MAX_PREFILL_LENGTH_MS * MAX_FS_KHZ ];\r
+    const SKP_int16 *in_ptr;\r
 \r
-        \r
-    psEnc = ( SKP_Silk_encoder_state_Fxx* )encState;\r
+    ret = process_enc_control_struct( psEnc, encControl );\r
 \r
-    /* Reset Encoder */\r
-    if( ret += SKP_Silk_init_encoder_Fxx( psEnc ) ) {\r
-        SKP_assert( 0 );\r
+    /* Compute some numbers at API sampling rate */\r
+    start_ix = nSamplesIn - SKP_DIV32_16( psEnc->sCmn.API_fs_Hz, 1000 / MAX_PREFILL_LENGTH_MS );     /* 10 ms */\r
+    if( start_ix < 0 ) {\r
+        offset = -start_ix;\r
+        start_ix = 0;\r
+    } else {\r
+        offset = 0;\r
     }\r
+    nSamples = nSamplesIn - start_ix;\r
 \r
-    /* Read control structure */\r
-    if( ret += SKP_Silk_SDK_QueryEncoder( encState, encStatus ) ) {\r
-        SKP_assert( 0 );\r
+    if( psEnc->sCmn.API_fs_Hz != SKP_SMULBB( 1000, psEnc->sCmn.fs_kHz ) ) { \r
+        /* resample input */\r
+        ret += SKP_Silk_resampler( &psEnc->sCmn.resampler_state, buf, samplesIn + start_ix, nSamples );\r
+        in_ptr = buf;\r
+        /* Convert to internal sampling rate */\r
+        offset   = SKP_DIV32( SKP_MUL( offset,   SKP_SMULBB( 1000, psEnc->sCmn.fs_kHz ) ), psEnc->sCmn.API_fs_Hz );\r
+        nSamples = SKP_DIV32( SKP_MUL( nSamples, SKP_SMULBB( 1000, psEnc->sCmn.fs_kHz ) ), psEnc->sCmn.API_fs_Hz );\r
+    } else {\r
+        in_ptr = samplesIn + start_ix;\r
     }\r
 \r
+#if HIGH_PASS_INPUT\r
+    /* Variable high-pass filter */\r
+    SKP_Silk_HP_variable_cutoff( &psEnc->sCmn, buf, in_ptr, nSamples );\r
+#else\r
+    SKP_memcpy( buf, in_ptr, nSamples * sizeof( SKP_int16 ) );\r
+#endif\r
+\r
+#if SWITCH_TRANSITION_FILTERING\r
+    /* Ensure smooth bandwidth transitions */\r
+    SKP_Silk_LP_variable_cutoff( &psEnc->sCmn.sLP, buf, nSamples );\r
+#endif\r
+\r
+#if FIXED_POINT \r
+{\r
+    SKP_int16 *buf_ptr = psEnc->x_buf + psEnc->sCmn.ltp_mem_length + ( LA_SHAPE_MS - MAX_PREFILL_LENGTH_MS ) * psEnc->sCmn.fs_kHz + offset;\r
+    SKP_memcpy( buf_ptr, buf, nSamples * sizeof( SKP_int16 ) );\r
+}\r
+#else\r
+{\r
+    SKP_float *buf_ptr;\r
+    buf_ptr = psEnc->x_buf + psEnc->sCmn.ltp_mem_length + ( LA_SHAPE_MS - MAX_PREFILL_LENGTH_MS ) * psEnc->sCmn.fs_kHz + offset;\r
+    SKP_short2float_array( buf_ptr, buf, nSamples );\r
+}\r
+#endif\r
+\r
+    /* Avoid using LSF interpolation or pitch prediction in first next frame */\r
+    psEnc->sCmn.first_frame_after_reset = 1;\r
 \r
     return ret;\r
 }\r
@@ -128,77 +265,22 @@ SKP_int SKP_Silk_SDK_Encode(
     SKP_int32                           *nBytesOut      /* I/O: Number of bytes in payload (input: Max bytes)   */\r
 )\r
 {\r
-    SKP_int   max_internal_fs_kHz, min_internal_fs_kHz, PacketSize_ms, PacketLoss_perc, UseInBandFEC, ret = SKP_SILK_NO_ERROR;\r
-    SKP_int   nSamplesToBuffer, Complexity, input_10ms, nSamplesFromInput = 0;\r
-    SKP_int32 TargetRate_bps, API_fs_Hz;\r
+    SKP_int   ret;\r
+    SKP_int   nSamplesToBuffer, input_10ms, nSamplesFromInput = 0;\r
     SKP_Silk_encoder_state_Fxx *psEnc = ( SKP_Silk_encoder_state_Fxx* )encState;\r
 \r
-    SKP_assert( encControl != NULL );\r
-\r
-    /* Check sampling frequency first, to avoid divide by zero later */\r
-    if( ( ( encControl->API_sampleRate        !=  8000 ) &&\r
-          ( encControl->API_sampleRate        != 12000 ) &&\r
-          ( encControl->API_sampleRate        != 16000 ) &&\r
-          ( encControl->API_sampleRate        != 24000 ) && \r
-          ( encControl->API_sampleRate        != 32000 ) &&\r
-          ( encControl->API_sampleRate        != 44100 ) &&\r
-          ( encControl->API_sampleRate        != 48000 ) ) ||\r
-        ( ( encControl->maxInternalSampleRate !=  8000 ) &&\r
-          ( encControl->maxInternalSampleRate != 12000 ) &&\r
-          ( encControl->maxInternalSampleRate != 16000 ) ) ||\r
-        ( ( encControl->minInternalSampleRate !=  8000 ) &&\r
-          ( encControl->minInternalSampleRate != 12000 ) &&\r
-          ( encControl->minInternalSampleRate != 16000 ) ) ||\r
-          ( encControl->minInternalSampleRate > encControl->maxInternalSampleRate ) ) {\r
-        ret = SKP_SILK_ENC_FS_NOT_SUPPORTED;\r
-        SKP_assert( 0 );\r
-        return( ret );\r
-    }\r
-    if( encControl->useDTX < 0 || encControl->useDTX > 1 ) {\r
-        ret = SKP_SILK_ENC_INVALID_DTX_SETTING;\r
-    }\r
-       if( encControl->useCBR < 0 || encControl->useCBR > 1 ) {\r
-        ret = SKP_SILK_ENC_INVALID_DTX_SETTING;\r
-    }\r
-\r
-\r
-    /* Set encoder parameters from control structure */\r
-    API_fs_Hz           =            encControl->API_sampleRate;\r
-    max_internal_fs_kHz = (SKP_int)( encControl->maxInternalSampleRate >> 10 ) + 1;   /* convert Hz -> kHz */\r
-    min_internal_fs_kHz = (SKP_int)( encControl->minInternalSampleRate >> 10 ) + 1;   /* convert Hz -> kHz */\r
-    PacketSize_ms       =            encControl->payloadSize_ms;\r
-    TargetRate_bps      =            encControl->bitRate;\r
-    PacketLoss_perc     =            encControl->packetLossPercentage;\r
-    UseInBandFEC        =            encControl->useInBandFEC;\r
-    Complexity          =            encControl->complexity;\r
-    psEnc->sCmn.useDTX  =            encControl->useDTX;\r
-       psEnc->sCmn.useCBR  =                    encControl->useCBR;\r
-\r
-    /* Save values in state */\r
-    psEnc->sCmn.API_fs_Hz          = API_fs_Hz;\r
-    psEnc->sCmn.maxInternal_fs_kHz = max_internal_fs_kHz;\r
-    psEnc->sCmn.minInternal_fs_kHz = min_internal_fs_kHz;\r
-    psEnc->sCmn.useInBandFEC       = UseInBandFEC;\r
+    ret = process_enc_control_struct( psEnc, encControl );\r
 \r
     /* Only accept input lengths that are a multiple of 10 ms */\r
-    input_10ms = SKP_DIV32( 100 * nSamplesIn, API_fs_Hz );\r
-    if( input_10ms * API_fs_Hz != 100 * nSamplesIn || nSamplesIn < 0 ) {\r
+    input_10ms = SKP_DIV32( 100 * nSamplesIn, psEnc->sCmn.API_fs_Hz );\r
+    if( input_10ms * psEnc->sCmn.API_fs_Hz != 100 * nSamplesIn || nSamplesIn < 0 ) {\r
         ret = SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES;\r
         SKP_assert( 0 );\r
         return( ret );\r
     }\r
 \r
-    TargetRate_bps = SKP_LIMIT( TargetRate_bps, MIN_TARGET_RATE_BPS, MAX_TARGET_RATE_BPS );\r
-    if( ( ret = SKP_Silk_control_encoder_Fxx( psEnc, PacketSize_ms, TargetRate_bps, \r
-                        PacketLoss_perc, Complexity) ) != 0 ) {\r
-        SKP_assert( 0 );\r
-        return( ret );\r
-    }\r
-\r
-    encControl->internalSampleRate = SKP_SMULBB( psEnc->sCmn.fs_kHz, 1000 );\r
-    \r
     /* Make sure no more than one packet can be produced */\r
-    if( 1000 * (SKP_int32)nSamplesIn > psEnc->sCmn.PacketSize_ms * API_fs_Hz ) {\r
+    if( 1000 * (SKP_int32)nSamplesIn > psEnc->sCmn.PacketSize_ms * psEnc->sCmn.API_fs_Hz ) {\r
         ret = SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES;\r
         SKP_assert( 0 );\r
         return( ret );\r
@@ -207,14 +289,14 @@ SKP_int SKP_Silk_SDK_Encode(
     /* Input buffering/resampling and encoding */\r
     while( 1 ) {\r
         nSamplesToBuffer = psEnc->sCmn.frame_length - psEnc->sCmn.inputBufIx;\r
-        if( API_fs_Hz == SKP_SMULBB( 1000, psEnc->sCmn.fs_kHz ) ) { \r
+        if( psEnc->sCmn.API_fs_Hz == SKP_SMULBB( 1000, psEnc->sCmn.fs_kHz ) ) { \r
             nSamplesToBuffer  = SKP_min_int( nSamplesToBuffer, nSamplesIn );\r
             nSamplesFromInput = nSamplesToBuffer;\r
             /* Copy to buffer */\r
             SKP_memcpy( &psEnc->sCmn.inputBuf[ psEnc->sCmn.inputBufIx ], samplesIn, nSamplesFromInput * sizeof( SKP_int16 ) );\r
         } else {  \r
             nSamplesToBuffer  = SKP_min( nSamplesToBuffer, 10 * input_10ms * psEnc->sCmn.fs_kHz );\r
-            nSamplesFromInput = SKP_DIV32_16( nSamplesToBuffer * API_fs_Hz, psEnc->sCmn.fs_kHz * 1000 );\r
+            nSamplesFromInput = SKP_DIV32_16( nSamplesToBuffer * psEnc->sCmn.API_fs_Hz, psEnc->sCmn.fs_kHz * 1000 );\r
             /* Resample and write to buffer */\r
             ret += SKP_Silk_resampler( &psEnc->sCmn.resampler_state, &psEnc->sCmn.inputBuf[ psEnc->sCmn.inputBufIx ], samplesIn, nSamplesFromInput );\r
         } \r
index f3adcbe..73d0eca 100644 (file)
@@ -39,7 +39,7 @@ void SKP_Silk_interpolate(
     SKP_int i;\r
 \r
     SKP_assert( ifact_Q2 >= 0 );\r
-    SKP_assert( ifact_Q2 <= ( 1 << 2 ) );\r
+    SKP_assert( ifact_Q2 <= 4 );\r
 \r
     for( i = 0; i < d; i++ ) {\r
         xi[ i ] = ( SKP_int )( ( SKP_int32 )x0[ i ] + SKP_RSHIFT( SKP_MUL( ( SKP_int32 )x1[ i ] - ( SKP_int32 )x0[ i ], ifact_Q2 ), 2 ) );\r
index 9f12506..95252ea 100644 (file)
@@ -213,15 +213,17 @@ void SKP_Silk_VAD_GetNoiseLevels(
 );\r
 \r
 /* Get speech activity level in Q8 */\r
-SKP_int SKP_Silk_VAD_GetSA_Q8(                                  /* O    Return value, 0 if success      */\r
-    SKP_Silk_VAD_state          *psSilk_VAD,                    /* I/O  Silk VAD state                  */\r
-    SKP_int                     *pSA_Q8,                        /* O    Speech activity level in Q8     */\r
-    SKP_int                     *pSNR_dB_Q7,                    /* O    SNR for current frame in Q7     */\r
-    SKP_int                     pQuality_Q15[ VAD_N_BANDS ],    /* O    Smoothed SNR for each band      */\r
-    SKP_int                     *pTilt_Q15,                     /* O    current frame's frequency tilt  */\r
-    const SKP_int16             pIn[],                          /* I    PCM input       [framelength]   */\r
-    const SKP_int               framelength,                    /* I    Input frame length              */\r
-    const SKP_int               fs_kHz                          /* I    Input frame sample frequency    */\r
+SKP_int SKP_Silk_VAD_GetSA_Q8(                      /* O    Return value, 0 if success                  */\r
+    SKP_Silk_encoder_state      *psEncC,            /* I/O  Encoder state                               */\r
+    const SKP_int16             pIn[]               /* I    PCM input                                   */\r
+);\r
+\r
+/* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */\r
+void SKP_Silk_HP_variable_cutoff(\r
+    SKP_Silk_encoder_state          *psEncC,        /* I/O  Encoder state                               */\r
+    SKP_int16                       *out,           /* O    high-pass filtered output signal            */\r
+    const SKP_int16                 *in,            /* I    input signal                                */\r
+    const SKP_int                   frame_length    /* I    length of input                             */\r
 );\r
 \r
 #if SWITCH_TRANSITION_FILTERING\r
@@ -241,19 +243,69 @@ void SKP_Silk_LBRR_embed(
     ec_enc                      *psRangeEnc         /* I/O  Compressor data structure                   */\r
 );\r
 \r
+/******************/\r
+/* NLSF Quantizer */\r
+/******************/\r
+/* Limit, stabilize, convert and quantize NLSFs.    */ \r
+void SKP_Silk_process_NLSFs(\r
+    SKP_Silk_encoder_state          *psEncC,                                /* I/O  Encoder state                               */\r
+    SKP_int16                       PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ],     /* O    Prediction coefficients                     */\r
+    SKP_int                         pNLSF_Q15[         MAX_LPC_ORDER ],     /* I/O  Normalized LSFs (quant out) (0 - (2^15-1))  */\r
+    const SKP_int                   prev_NLSFq_Q15[    MAX_LPC_ORDER ]      /* I    Previous Normalized LSFs (0 - (2^15-1))     */\r
+);\r
+\r
+/* NLSF vector encoder */\r
+void SKP_Silk_NLSF_MSVQ_encode(\r
+          SKP_int8                  *NLSFIndices,           /* O    Codebook path vector [ CB_STAGES ]      */\r
+          SKP_int                   *pNLSF_Q15,             /* I/O  Quantized NLSF vector [ LPC_ORDER ]     */\r
+    const SKP_Silk_NLSF_CB_struct   *psNLSF_CB,             /* I    Codebook object                         */\r
+    const SKP_int                   *pNLSF_q_Q15_prev,      /* I    Prev. quantized NLSF vector [LPC_ORDER] */\r
+    const SKP_int                   *pW_Q5,                 /* I    NLSF weight vector [ LPC_ORDER ]        */\r
+    const SKP_int                   NLSF_mu_Q15,            /* I    Rate weight for the RD optimization     */\r
+    const SKP_int                   NLSF_mu_fluc_red_Q16,   /* I    Fluctuation reduction error weight      */\r
+    const SKP_int                   NLSF_MSVQ_Survivors,    /* I    Max survivors from each stage           */\r
+    const SKP_int                   LPC_order,              /* I    LPC order                               */\r
+    const SKP_int                   deactivate_fluc_red     /* I    Deactivate fluctuation reduction        */\r
+);\r
+\r
+/* Rate-Distortion calculations for multiple input data vectors */\r
+void SKP_Silk_NLSF_VQ_rate_distortion(\r
+    SKP_int32                       *pRD_Q19,           /* O    Rate-distortion values [psNLSF_CBS->nVectors*N] */\r
+    const SKP_Silk_NLSF_CBS         *psNLSF_CBS,        /* I    NLSF codebook stage struct                      */\r
+    const SKP_int16                 *in_Q15,            /* I    Input vectors to be quantized                   */\r
+    const SKP_int                   *w_Q5,              /* I    Weight vector                                   */\r
+    const SKP_int32                 *rate_acc_Q4,       /* I    Accumulated rates from previous stage           */\r
+    const SKP_int                   mu_Q15,             /* I    Weight between weighted error and rate          */\r
+    const SKP_int                   N,                  /* I    Number of input vectors to be quantized         */\r
+    const SKP_int                   stage,              /* I    Stage number                                    */\r
+    const SKP_int                   LPC_order           /* I    LPC order                                       */\r
+);\r
+\r
+/* Compute weighted quantization errors for an LPC_order element input vector, over one codebook stage */\r
+void SKP_Silk_NLSF_VQ_sum_error(\r
+    SKP_int32                       *err_Q19,           /* O    Weighted quantization errors  [N*K]         */\r
+    const SKP_int16                 *in_Q15,            /* I    Input vectors to be quantized [N*LPC_order] */\r
+    const SKP_int                   *w_Q5,              /* I    Weighting vectors             [N*LPC_order] */\r
+    const SKP_int8                  *pCB_Q9,            /* I    Codebook vectors              [K*LPC_order] */\r
+    const SKP_int                   N,                  /* I    Number of input vectors                     */\r
+    const SKP_int                   K,                  /* I    Number of codebook vectors                  */\r
+    const SKP_int                   stage,              /* I    Stage number                                */\r
+    const SKP_int                   LPC_order           /* I    Number of LPCs                              */\r
+);\r
+\r
 /****************************************************/\r
 /* Decoder Functions                                */\r
 /****************************************************/\r
 SKP_int SKP_Silk_create_decoder(\r
-    SKP_Silk_decoder_state      **ppsDec            /* I/O  Decoder state pointer pointer               */\r
+    SKP_Silk_decoder_state          **ppsDec            /* I/O  Decoder state pointer pointer               */\r
 );\r
 \r
 SKP_int SKP_Silk_free_decoder(\r
-    SKP_Silk_decoder_state      *psDec              /* I/O  Decoder state pointer                       */\r
+    SKP_Silk_decoder_state          *psDec              /* I/O  Decoder state pointer                       */\r
 );\r
 \r
 SKP_int SKP_Silk_init_decoder(\r
-    SKP_Silk_decoder_state      *psDec              /* I/O  Decoder state pointer                       */\r
+    SKP_Silk_decoder_state          *psDec              /* I/O  Decoder state pointer                       */\r
 );\r
 \r
 /* Set decoder sampling rate */\r
@@ -288,7 +340,7 @@ void SKP_Silk_decode_indices(
     SKP_int                     decode_LBRR         /* I    Flag indicating LBRR data is being decoded  */\r
 );\r
 \r
-/* Decode parameters from payload v4 Bitstream */\r
+/* Decode parameters from payload */\r
 void SKP_Silk_decode_parameters(\r
     SKP_Silk_decoder_state      *psDec,                             /* I/O  State                                    */\r
     SKP_Silk_decoder_control    *psDecCtrl                          /* I/O  Decoder control                          */\r
similarity index 50%
rename from src_FIX/SKP_Silk_process_NLSFs_FIX.c
rename to src_common/SKP_Silk_process_NLSFs.c
index 09e7ba7..6c3c931 100644 (file)
@@ -25,98 +25,92 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
 ***********************************************************************/\r
 \r
-#include "SKP_Silk_main_FIX.h"\r
+#include "SKP_Silk_main.h"\r
 \r
 /* Limit, stabilize, convert and quantize NLSFs.    */ \r
-void SKP_Silk_process_NLSFs_FIX(\r
-    SKP_Silk_encoder_state_FIX      *psEnc,             /* I/O  Encoder state FIX                           */\r
-    SKP_Silk_encoder_control_FIX    *psEncCtrl,         /* I/O  Encoder control FIX                         */\r
-    SKP_int                         *pNLSF_Q15          /* I/O  Normalized LSFs (quant out) (0 - (2^15-1))  */\r
+void SKP_Silk_process_NLSFs(\r
+    SKP_Silk_encoder_state          *psEncC,                                /* I/O  Encoder state                               */\r
+    SKP_int16                       PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ],     /* O    Prediction coefficients                     */\r
+    SKP_int                         pNLSF_Q15[         MAX_LPC_ORDER ],     /* I/O  Normalized LSFs (quant out) (0 - (2^15-1))  */\r
+    const SKP_int                   prev_NLSFq_Q15[    MAX_LPC_ORDER ]      /* I    Previous Normalized LSFs (0 - (2^15-1))     */\r
 )\r
 {\r
-    SKP_int     doInterpolate;\r
-    SKP_int     pNLSFW_Q6[ MAX_LPC_ORDER ];\r
+    SKP_int     i, doInterpolate;\r
+    SKP_int     pNLSFW_Q5[ MAX_LPC_ORDER ];\r
     SKP_int     NLSF_mu_Q15, NLSF_mu_fluc_red_Q16;\r
     SKP_int32   i_sqr_Q15;\r
-    const SKP_Silk_NLSF_CB_struct *psNLSF_CB;\r
-\r
-    /* Used only for NLSF interpolation */\r
     SKP_int     pNLSF0_temp_Q15[ MAX_LPC_ORDER ];\r
-    SKP_int     pNLSFW0_temp_Q6[ MAX_LPC_ORDER ];\r
-    SKP_int     i;\r
+    SKP_int     pNLSFW0_temp_Q5[ MAX_LPC_ORDER ];\r
+    const SKP_Silk_NLSF_CB_struct *psNLSF_CB;\r
 \r
-    SKP_assert( psEnc->speech_activity_Q8 >=   0 );\r
-    SKP_assert( psEnc->speech_activity_Q8 <= 256 );\r
-    SKP_assert( psEncCtrl->sparseness_Q8  >=   0 );\r
-    SKP_assert( psEncCtrl->sparseness_Q8  <= 256 );\r
+    SKP_assert( psEncC->speech_activity_Q8 >=   0 );\r
+    SKP_assert( psEncC->speech_activity_Q8 <= SKP_FIX_CONST( 1.0, 8 ) );\r
 \r
     /***********************/\r
     /* Calculate mu values */\r
     /***********************/\r
-    if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) {\r
+    if( psEncC->indices.signalType == TYPE_VOICED ) {\r
         /* NLSF_mu           = 0.002f - 0.001f * psEnc->speech_activity; */\r
         /* NLSF_mu_fluc_red  = 0.1f   - 0.05f  * psEnc->speech_activity; */\r
-        NLSF_mu_Q15          = SKP_SMLAWB(   66,   -8388, psEnc->speech_activity_Q8 );\r
-        NLSF_mu_fluc_red_Q16 = SKP_SMLAWB( 6554, -838848, psEnc->speech_activity_Q8 );\r
+        NLSF_mu_Q15          = SKP_SMLAWB( SKP_FIX_CONST( 0.002, 15 ), SKP_FIX_CONST( -0.001, 23 ), psEncC->speech_activity_Q8 );\r
+        NLSF_mu_fluc_red_Q16 = SKP_SMLAWB( SKP_FIX_CONST( 0.1,   16 ), SKP_FIX_CONST( -0.05,  24 ), psEncC->speech_activity_Q8 );\r
     } else { \r
         /* NLSF_mu           = 0.005f - 0.004f * psEnc->speech_activity; */\r
         /* NLSF_mu_fluc_red  = 0.2f   - 0.1f   * psEnc->speech_activity - 0.1f * psEncCtrl->sparseness; */\r
-        NLSF_mu_Q15          = SKP_SMLAWB(   164,   -33554, psEnc->speech_activity_Q8 );\r
-        NLSF_mu_fluc_red_Q16 = SKP_SMLAWB( 13107, -1677696, psEnc->speech_activity_Q8 + psEncCtrl->sparseness_Q8 ); \r
+        NLSF_mu_Q15          = SKP_SMLAWB( SKP_FIX_CONST( 0.005, 15 ), SKP_FIX_CONST( -0.004, 23 ), psEncC->speech_activity_Q8 );\r
+        NLSF_mu_fluc_red_Q16 = SKP_SMLAWB( SKP_FIX_CONST( 0.15,  16 ), SKP_FIX_CONST( -0.1,   24 ), psEncC->speech_activity_Q8 ); \r
     }\r
-    SKP_assert( NLSF_mu_Q15          >= 0     );\r
-    SKP_assert( NLSF_mu_Q15          <= 164   );\r
-    SKP_assert( NLSF_mu_fluc_red_Q16 >= 0     );\r
-    SKP_assert( NLSF_mu_fluc_red_Q16 <= 13107 );\r
+    SKP_assert( NLSF_mu_Q15          >= 0 );\r
+    SKP_assert( NLSF_mu_Q15          <= SKP_FIX_CONST( 0.005, 15 ) );\r
+    SKP_assert( NLSF_mu_fluc_red_Q16 >= 0 );\r
+    SKP_assert( NLSF_mu_fluc_red_Q16 <= SKP_FIX_CONST( 0.15, 16 ) );\r
 \r
     NLSF_mu_Q15 = SKP_max( NLSF_mu_Q15, 1 );\r
 \r
     /* Calculate NLSF weights */\r
-    SKP_Silk_NLSF_VQ_weights_laroia( pNLSFW_Q6, pNLSF_Q15, psEnc->sCmn.predictLPCOrder );\r
+    SKP_Silk_NLSF_VQ_weights_laroia( pNLSFW_Q5, pNLSF_Q15, psEncC->predictLPCOrder );\r
 \r
     /* Update NLSF weights for interpolated NLSFs */\r
-    doInterpolate = ( psEnc->sCmn.useInterpolatedNLSFs == 1 ) && ( psEnc->sCmn.indices.NLSFInterpCoef_Q2 < ( 1 << 2 ) );\r
+    doInterpolate = ( psEncC->useInterpolatedNLSFs == 1 ) && ( psEncC->indices.NLSFInterpCoef_Q2 < 4 );\r
     if( doInterpolate ) {\r
-\r
         /* Calculate the interpolated NLSF vector for the first half */\r
-        SKP_Silk_interpolate( pNLSF0_temp_Q15, psEnc->sPred.prev_NLSFq_Q15, pNLSF_Q15, \r
-            psEnc->sCmn.indices.NLSFInterpCoef_Q2, psEnc->sCmn.predictLPCOrder );\r
+        SKP_Silk_interpolate( pNLSF0_temp_Q15, prev_NLSFq_Q15, pNLSF_Q15, \r
+            psEncC->indices.NLSFInterpCoef_Q2, psEncC->predictLPCOrder );\r
 \r
         /* Calculate first half NLSF weights for the interpolated NLSFs */\r
-        SKP_Silk_NLSF_VQ_weights_laroia( pNLSFW0_temp_Q6, pNLSF0_temp_Q15, psEnc->sCmn.predictLPCOrder );\r
+        SKP_Silk_NLSF_VQ_weights_laroia( pNLSFW0_temp_Q5, pNLSF0_temp_Q15, psEncC->predictLPCOrder );\r
 \r
         /* Update NLSF weights with contribution from first half */\r
-        i_sqr_Q15 = SKP_LSHIFT( SKP_SMULBB( psEnc->sCmn.indices.NLSFInterpCoef_Q2, psEnc->sCmn.indices.NLSFInterpCoef_Q2 ), 11 );\r
-        for( i = 0; i < psEnc->sCmn.predictLPCOrder; i++ ) {\r
-            pNLSFW_Q6[ i ] = SKP_SMLAWB( SKP_RSHIFT( pNLSFW_Q6[ i ], 1 ), pNLSFW0_temp_Q6[ i ], i_sqr_Q15 );\r
-            SKP_assert( pNLSFW_Q6[ i ] <= SKP_int16_MAX );\r
-            SKP_assert( pNLSFW_Q6[ i ] >= 1 );\r
+        i_sqr_Q15 = SKP_LSHIFT( SKP_SMULBB( psEncC->indices.NLSFInterpCoef_Q2, psEncC->indices.NLSFInterpCoef_Q2 ), 11 );\r
+        for( i = 0; i < psEncC->predictLPCOrder; i++ ) {\r
+            pNLSFW_Q5[ i ] = SKP_SMLAWB( SKP_RSHIFT( pNLSFW_Q5[ i ], 1 ), pNLSFW0_temp_Q5[ i ], i_sqr_Q15 );\r
+            SKP_assert( pNLSFW_Q5[ i ] <= SKP_int16_MAX );\r
+            SKP_assert( pNLSFW_Q5[ i ] >= 1 );\r
         }\r
     }\r
 \r
     /* Set pointer to the NLSF codebook for the current signal type and LPC order */\r
-    psNLSF_CB = psEnc->sCmn.psNLSF_CB[ 1 - ( psEnc->sCmn.indices.signalType >> 1 ) ];\r
+    psNLSF_CB = psEncC->psNLSF_CB[ 1 - ( psEncC->indices.signalType >> 1 ) ];\r
 \r
     /* Quantize NLSF parameters given the trained NLSF codebooks */\r
     TIC(MSVQ_encode_FIX)\r
-    SKP_Silk_NLSF_MSVQ_encode_FIX( psEnc->sCmn.indices.NLSFIndices, pNLSF_Q15, psNLSF_CB, \r
-        psEnc->sPred.prev_NLSFq_Q15, pNLSFW_Q6, NLSF_mu_Q15, NLSF_mu_fluc_red_Q16, \r
-        psEnc->sCmn.NLSF_MSVQ_Survivors, psEnc->sCmn.predictLPCOrder, psEnc->sCmn.first_frame_after_reset );\r
+    SKP_Silk_NLSF_MSVQ_encode( psEncC->indices.NLSFIndices, pNLSF_Q15, psNLSF_CB, prev_NLSFq_Q15, pNLSFW_Q5, NLSF_mu_Q15, \r
+        NLSF_mu_fluc_red_Q16, psEncC->NLSF_MSVQ_Survivors, psEncC->predictLPCOrder, psEncC->first_frame_after_reset );\r
     TOC(MSVQ_encode_FIX)\r
 \r
     /* Convert quantized NLSFs back to LPC coefficients */\r
-    SKP_Silk_NLSF2A_stable( psEncCtrl->PredCoef_Q12[ 1 ], pNLSF_Q15, psEnc->sCmn.predictLPCOrder );\r
+    SKP_Silk_NLSF2A_stable( PredCoef_Q12[ 1 ], pNLSF_Q15, psEncC->predictLPCOrder );\r
 \r
     if( doInterpolate ) {\r
         /* Calculate the interpolated, quantized LSF vector for the first half */\r
-        SKP_Silk_interpolate( pNLSF0_temp_Q15, psEnc->sPred.prev_NLSFq_Q15, pNLSF_Q15, \r
-            psEnc->sCmn.indices.NLSFInterpCoef_Q2, psEnc->sCmn.predictLPCOrder );\r
+        SKP_Silk_interpolate( pNLSF0_temp_Q15, prev_NLSFq_Q15, pNLSF_Q15, \r
+            psEncC->indices.NLSFInterpCoef_Q2, psEncC->predictLPCOrder );\r
 \r
         /* Convert back to LPC coefficients */\r
-        SKP_Silk_NLSF2A_stable( psEncCtrl->PredCoef_Q12[ 0 ], pNLSF0_temp_Q15, psEnc->sCmn.predictLPCOrder );\r
+        SKP_Silk_NLSF2A_stable( PredCoef_Q12[ 0 ], pNLSF0_temp_Q15, psEncC->predictLPCOrder );\r
 \r
     } else {\r
         /* Copy LPC coefficients for first half from second half */\r
-        SKP_memcpy( psEncCtrl->PredCoef_Q12[ 0 ], psEncCtrl->PredCoef_Q12[ 1 ], psEnc->sCmn.predictLPCOrder * sizeof( SKP_int16 ) );\r
+        SKP_memcpy( PredCoef_Q12[ 0 ], PredCoef_Q12[ 1 ], psEncC->predictLPCOrder * sizeof( SKP_int16 ) );\r
     }\r
 }\r
index 0321c21..1bcd108 100644 (file)
@@ -72,14 +72,12 @@ typedef struct {
     SKP_int32   counter;                        /* Frame counter used in the initial phase                  */\r
 } SKP_Silk_VAD_state;\r
 \r
-#if SWITCH_TRANSITION_FILTERING\r
 /* Variable cut-off low-pass filter state */\r
 typedef struct {\r
     SKP_int32                   In_LP_State[ 2 ];           /* Low pass filter state */\r
     SKP_int32                   transition_frame_no;        /* Counter which is mapped to a cut-off frequency */\r
-    SKP_int                     mode;                       /* Operating mode, 0: switch down, 1: switch up */\r
+    SKP_int                     mode;                       /* Operating mode, <0: switch down, >0: switch up; 0: do nothing */\r
 } SKP_Silk_LP_state;\r
-#endif\r
 \r
 /* Structure for one stage of MSVQ */\r
 typedef struct {\r
@@ -120,15 +118,19 @@ typedef struct {
 typedef struct {\r
 #if HIGH_PASS_INPUT\r
     SKP_int32                       In_HP_State[ 2 ];               /* High pass filter state                                               */\r
+    SKP_int32                       variable_HP_smth1_Q15;          /* State of first smoother                                              */\r
+    SKP_int32                       variable_HP_smth2_Q15;          /* State of second smoother                                             */\r
 #endif\r
-#if SWITCH_TRANSITION_FILTERING\r
     SKP_Silk_LP_state               sLP;                            /* Low pass filter state                                                */\r
-#endif\r
     SKP_Silk_VAD_state              sVAD;                           /* Voice activity detector state                                        */\r
     SKP_Silk_nsq_state              sNSQ;                           /* Noise Shape Quantizer State                                          */\r
+    SKP_int                         prev_NLSFq_Q15[ MAX_LPC_ORDER ];/* Previously quantized NLSF vector                                     */\r
+    SKP_int                         speech_activity_Q8;             /* Speech activity                                                      */\r
     SKP_int8                        LBRRprevLastGainIndex;\r
     SKP_int8                        prevSignalType;\r
     SKP_int                         prevLag;\r
+    SKP_int                         pitch_LPC_win_length;\r
+    SKP_int                         max_pitch_lag;                  /* Highest possible pitch lag (samples)                                 */\r
     SKP_int32                       API_fs_Hz;                      /* API sampling frequency (Hz)                                          */\r
     SKP_int32                       prev_API_fs_Hz;                 /* Previous API sampling frequency (Hz)                                 */\r
     SKP_int                         maxInternal_fs_kHz;             /* Maximum internal sampling frequency (kHz)                            */\r
@@ -164,6 +166,8 @@ typedef struct {
     const SKP_uint8                 *pitch_lag_low_bits_iCDF;       /* Pointer to iCDF table for low bits of pitch lag index                */\r
     const SKP_uint8                 *pitch_contour_iCDF;            /* Pointer to iCDF table for pitch contour index                        */\r
     const SKP_Silk_NLSF_CB_struct   *psNLSF_CB[ 2 ];                /* Pointers to voiced/unvoiced NLSF codebooks                           */\r
+    SKP_int                         input_quality_bands_Q15[ VAD_N_BANDS ];\r
+    SKP_int                         input_tilt_Q15;\r
 \r
     SKP_int8                        VAD_flags[ MAX_FRAMES_PER_PACKET ];\r
     SKP_int8                        LBRR_flag;\r
@@ -185,11 +189,6 @@ typedef struct {
     SKP_int                         ec_prevSignalType;\r
     SKP_int16                       ec_prevLagIndex;\r
 \r
-    /* Bitrate control */\r
-    SKP_int32                       bitrateDiff;                    /* Accumulated diff. between the target bitrate and the switch bitrates */\r
-    SKP_int32                       bitrate_threshold_up;           /* Threshold for switching to a higher internal sample frequency        */\r
-    SKP_int32                       bitrate_threshold_down;         /* Threshold for switching to a lower internal sample frequency         */\r
-\r
     SKP_Silk_resampler_state_struct resampler_state;\r
 \r
     /* DTX */\r
index 5c510e0..6764472 100644 (file)
@@ -68,6 +68,7 @@ extern const SKP_uint8  SKP_Silk_lsb_iCDF[ 2 ];
 \r
 extern const SKP_uint8  SKP_Silk_sign_iCDF[ 36 ];                                                   /*  36 */\r
 \r
+extern const SKP_uint8  SKP_Silk_uniform2_iCDF[   2 ];                                              /*   2 */\r
 extern const SKP_uint8  SKP_Silk_uniform4_iCDF[   4 ];                                              /*   4 */\r
 extern const SKP_uint8  SKP_Silk_uniform6_iCDF[   6 ];                                              /*   6 */\r
 extern const SKP_uint8  SKP_Silk_uniform8_iCDF[   8 ];                                              /*   8 */\r
index 422429d..21a03c7 100644 (file)
@@ -92,6 +92,7 @@ const SKP_int16  SKP_Silk_Quantization_Offsets_Q10[ 2 ][ 2 ] = {
 const SKP_int16 SKP_Silk_LTPScales_table_Q14[ 3 ] = { 15565, 12288, 8192 };\r
 \r
 /* Uniform entropy tables */\r
+const SKP_uint8 SKP_Silk_uniform2_iCDF[ 2 ] = { 128, 0 };\r
 const SKP_uint8 SKP_Silk_uniform4_iCDF[ 4 ] = { 192, 128, 64, 0 };\r
 const SKP_uint8 SKP_Silk_uniform6_iCDF[ 6 ] = { 213, 171, 128, 85, 43, 0 };\r
 const SKP_uint8 SKP_Silk_uniform8_iCDF[ 8 ] = { 224, 192, 160, 128, 96, 64, 32, 0 };\r
index 985c0ab..ce04adb 100644 (file)
     <ClCompile Include="SKP_Silk_encode_pulses.c" />\r
     <ClCompile Include="SKP_Silk_enc_API.c" />\r
     <ClCompile Include="SKP_Silk_gain_quant.c" />\r
+    <ClCompile Include="SKP_Silk_HP_variable_cutoff.c" />\r
     <ClCompile Include="SKP_Silk_interpolate.c" />\r
     <ClCompile Include="SKP_Silk_LBRR_embed.c" />\r
     <ClCompile Include="SKP_Silk_LP_variable_cutoff.c" />\r
     <ClCompile Include="SKP_Silk_NLSF2A_stable.c" />\r
     <ClCompile Include="SKP_Silk_NLSF_MSVQ_decode.c" />\r
+    <ClCompile Include="SKP_Silk_NLSF_MSVQ_encode.c" />\r
+    <ClCompile Include="SKP_Silk_NLSF_VQ_rate_distortion.c" />\r
+    <ClCompile Include="SKP_Silk_NLSF_VQ_sum_error.c" />\r
     <ClCompile Include="SKP_Silk_NSQ.c" />\r
     <ClCompile Include="SKP_Silk_NSQ_del_dec.c" />\r
     <ClCompile Include="SKP_Silk_PLC.c" />\r
+    <ClCompile Include="SKP_Silk_process_NLSFs.c" />\r
     <ClCompile Include="SKP_Silk_quant_LTP_gains.c" />\r
     <ClCompile Include="SKP_Silk_shell_coder.c" />\r
     <ClCompile Include="SKP_Silk_tables_gain.c" />\r
index 7c9b57c..107d02d 100644 (file)
     <ClCompile Include="SKP_Silk_LBRR_embed.c">\r
       <Filter>Source Files</Filter>\r
     </ClCompile>\r
+    <ClCompile Include="SKP_Silk_NLSF_VQ_rate_distortion.c">\r
+      <Filter>Source Files</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="SKP_Silk_process_NLSFs.c">\r
+      <Filter>Source Files</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="SKP_Silk_NLSF_VQ_sum_error.c">\r
+      <Filter>Source Files</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="SKP_Silk_NLSF_MSVQ_encode.c">\r
+      <Filter>Source Files</Filter>\r
+    </ClCompile>\r
+    <ClCompile Include="SKP_Silk_HP_variable_cutoff.c">\r
+      <Filter>Source Files</Filter>\r
+    </ClCompile>\r
   </ItemGroup>\r
 </Project>
\ No newline at end of file