SILK update
authorKoen Vos <koen.vos@skype.net>
Wed, 2 Feb 2011 15:01:59 +0000 (10:01 -0500)
committerJean-Marc Valin <jean-marc.valin@octasic.com>
Wed, 2 Feb 2011 15:03:10 +0000 (10:03 -0500)
67 files changed:
Makefile.am
interface/SKP_Silk_SDK_API.h
interface/SKP_Silk_control.h
interface/SKP_Silk_errors.h
interface/SKP_debug.h
src_FIX/SKP_Silk_HP_variable_cutoff_FIX.c
src_FIX/SKP_Silk_NLSF_MSVQ_encode_FIX.c
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_main_FIX.h
src_FIX/SKP_Silk_noise_shape_analysis_FIX.c
src_FIX/SKP_Silk_prefilter_FIX.c
src_FIX/SKP_Silk_process_NLSFs_FIX.c
src_FIX/SKP_Silk_process_gains_FIX.c
src_FLP/SKP_Silk_HP_variable_cutoff_FLP.c
src_FLP/SKP_Silk_LPC_analysis_filter_FLP.c
src_FLP/SKP_Silk_NLSF_MSVQ_encode_FLP.c
src_FLP/SKP_Silk_control_codec_FLP.c
src_FLP/SKP_Silk_encode_frame_FLP.c
src_FLP/SKP_Silk_find_pitch_lags_FLP.c
src_FLP/SKP_Silk_find_pred_coefs_FLP.c
src_FLP/SKP_Silk_main_FLP.h
src_FLP/SKP_Silk_noise_shape_analysis_FLP.c
src_FLP/SKP_Silk_prefilter_FLP.c
src_FLP/SKP_Silk_process_NLSFs_FLP.c
src_FLP/SKP_Silk_process_gains_FLP.c
src_FLP/SKP_Silk_wrappers_FLP.c
src_common/SKP_Silk_LBRR_reset.c [deleted file]
src_common/SKP_Silk_NSQ.c
src_common/SKP_Silk_NSQ_del_dec.c
src_common/SKP_Silk_PLC.c
src_common/SKP_Silk_VQ_WMat_EC.c
src_common/SKP_Silk_code_signs.c
src_common/SKP_Silk_control_audio_bandwidth.c
src_common/SKP_Silk_dec_API.c
src_common/SKP_Silk_decode_core.c
src_common/SKP_Silk_decode_frame.c
src_common/SKP_Silk_decode_indices.c
src_common/SKP_Silk_decode_parameters.c
src_common/SKP_Silk_decode_pulses.c
src_common/SKP_Silk_decoder_set_fs.c
src_common/SKP_Silk_define.h
src_common/SKP_Silk_encode_indices.c [moved from src_common/SKP_Silk_encode_parameters.c with 90% similarity]
src_common/SKP_Silk_encode_pulses.c
src_common/SKP_Silk_main.h
src_common/SKP_Silk_quant_LTP_gains.c
src_common/SKP_Silk_range_coder.c [deleted file]
src_common/SKP_Silk_setup_complexity.h
src_common/SKP_Silk_shell_coder.c
src_common/SKP_Silk_structs.h
src_common/SKP_Silk_tables.h
src_common/SKP_Silk_tables_LTP.c
src_common/SKP_Silk_tables_NLSF_CB0_10.c
src_common/SKP_Silk_tables_NLSF_CB0_16.c
src_common/SKP_Silk_tables_NLSF_CB1_10.h [deleted file]
src_common/SKP_Silk_tables_gain.c
src_common/SKP_Silk_tables_other.c
src_common/SKP_Silk_tables_pulses_per_block.c
src_common/SKP_Silk_tables_sign.c [deleted file]
src_common/SKP_Silk_tuning_parameters.h
src_common/Silk_Common.vcproj [deleted file]
src_common/src_common.vcxproj
src_common/src_common.vcxproj.filters
test/Decoder.c
test/Encoder.c

index 8ead2de..167f715 100644 (file)
@@ -30,18 +30,17 @@ src_common/SKP_Silk_code_signs.c \
 src_common/SKP_Silk_create_init_destroy.c \
 src_common/SKP_Silk_decode_core.c \
 src_common/SKP_Silk_decode_frame.c \
-src_common/SKP_Silk_decode_indices.c \
 src_common/SKP_Silk_decode_parameters.c \
+src_common/SKP_Silk_decode_indices.c \
 src_common/SKP_Silk_decode_pulses.c \
 src_common/SKP_Silk_decoder_set_fs.c \
 src_common/SKP_Silk_dec_API.c \
 src_common/SKP_Silk_detect_SWB_input.c \
 src_common/SKP_Silk_enc_API.c \
-src_common/SKP_Silk_encode_parameters.c \
+src_common/SKP_Silk_encode_indices.c \
 src_common/SKP_Silk_encode_pulses.c \
 src_common/SKP_Silk_gain_quant.c \
 src_common/SKP_Silk_interpolate.c \
-src_common/SKP_Silk_LBRR_reset.c \
 src_common/SKP_Silk_LP_variable_cutoff.c \
 src_common/SKP_Silk_NLSF2A_stable.c \
 src_common/SKP_Silk_NLSF_MSVQ_decode.c \
@@ -49,7 +48,6 @@ src_common/SKP_Silk_NSQ.c \
 src_common/SKP_Silk_NSQ_del_dec.c \
 src_common/SKP_Silk_PLC.c \
 src_common/SKP_Silk_pulses_to_bytes.c \
-src_common/SKP_Silk_range_coder.c \
 src_common/SKP_Silk_shell_coder.c \
 src_common/SKP_Silk_tables_gain.c \
 src_common/SKP_Silk_tables_LTP.c \
@@ -60,7 +58,6 @@ src_common/SKP_Silk_tables_NLSF_CB1_16.c \
 src_common/SKP_Silk_tables_other.c \
 src_common/SKP_Silk_tables_pitch_lag.c \
 src_common/SKP_Silk_tables_pulses_per_block.c \
-src_common/SKP_Silk_tables_sign.c \
 src_common/SKP_Silk_VAD.c \
 src_common/SKP_Silk_control_audio_bandwidth.c \
 src_common/SKP_Silk_quant_LTP_gains.c \
index f263c0a..f8d981d 100644 (file)
@@ -39,16 +39,15 @@ extern "C"
 {\r
 #endif\r
 \r
-#define SILK_MAX_FRAMES_PER_PACKET  5\r
+#define SILK_MAX_FRAMES_PER_PACKET  3\r
 \r
 /* Struct for TOC (Table of Contents) */\r
 typedef struct {\r
-    SKP_int     framesInPacket;                             /* Number of 20 ms frames in packet     */\r
-    SKP_int     fs_kHz;                                     /* Sampling frequency in packet         */\r
-    SKP_int     inbandLBRR;                                 /* Does packet contain LBRR information */\r
-    SKP_int     corrupt;                                    /* Packet is corrupt                    */\r
-    SKP_int     vadFlags[     SILK_MAX_FRAMES_PER_PACKET ]; /* VAD flag for each frame in packet    */\r
-    SKP_int     sigtypeFlags[ SILK_MAX_FRAMES_PER_PACKET ]; /* Signal type for each frame in packet */\r
+    SKP_int     framesInPacket;                                 /* Number of 20 ms frames in packet     */\r
+    SKP_int     fs_kHz;                                         /* Sampling frequency in packet         */\r
+    SKP_int     inbandLBRR;                                     /* Does packet contain LBRR information */\r
+    SKP_int     corrupt;                                        /* Packet is corrupt                    */\r
+    SKP_int     signalTypeFlags[ SILK_MAX_FRAMES_PER_PACKET ];  /* Signal type for each frame in packet */\r
 } SKP_Silk_TOC_struct;\r
 \r
 /****************************************/\r
@@ -136,17 +135,11 @@ void SKP_Silk_SDK_search_for_LBRR(
 /* Get table of contents for a packet */\r
 /**************************************/\r
 void SKP_Silk_SDK_get_TOC(\r
-    ec_dec                              *psRangeDec,    /* I/O  Compressor data structure                   */\r
+    ec_dec                              *psRangeDec,    /* I/O  Compressor data structure                       */\r
     const SKP_int16                     nBytesIn,       /* I:   Number of input bytes                           */\r
     SKP_Silk_TOC_struct                 *Silk_TOC       /* O:   Table of contents                               */\r
 );\r
 \r
-/**************************/\r
-/* Get the version number */\r
-/**************************/\r
-/* Return a pointer to string specifying the version */ \r
-const char *SKP_Silk_SDK_get_version();\r
-\r
 #ifdef __cplusplus\r
 }\r
 #endif\r
index d10e3f9..2b7c6eb 100644 (file)
@@ -57,7 +57,7 @@ typedef struct {
     /* I:   Uplink packet loss in percent (0-100)                                           */\r
     SKP_int packetLossPercentage;\r
     \r
-    /* I:   Complexity mode; 0 is lowest; 1 is medium and 2 is highest complexity           */\r
+    /* I:   Complexity mode; 0 is lowest, 10 is highest complexity                          */\r
     SKP_int complexity;\r
 \r
     /* I:   Flag to enable in-band Forward Error Correction (FEC); 0/1                      */\r
index a1032f8..cb3079e 100644 (file)
@@ -42,7 +42,7 @@ extern "C"
 /* Encoder error messages */\r
 /**************************/\r
 \r
-/* Input length is not a multiplum of 10 ms, or length is longer than the packet length */\r
+/* Input length is not a multiple of 10 ms, or length is longer than the packet length */\r
 #define SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES        -101\r
 \r
 /* Sampling frequency not 8000, 12000, 16000 or 24000 Hertz */\r
@@ -57,7 +57,7 @@ extern "C"
 /* Loss rate not between 0 and 100 percent */\r
 #define SKP_SILK_ENC_INVALID_LOSS_RATE                  -105\r
 \r
-/* Complexity setting not valid, use 0, 1 or 2 */\r
+/* Complexity setting not valid, use 0...10 */\r
 #define SKP_SILK_ENC_INVALID_COMPLEXITY_SETTING         -106\r
 \r
 /* Inband FEC setting not valid, use 0 or 1 */\r
index cbe1657..73d5323 100644 (file)
@@ -25,15 +25,6 @@ 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
-\r
-/*                                                                      *\r
- * SKP_debug.h                                                          *\r
- *                                                                      *\r
- * This contains code to help debugging                                 *\r
- *                                                                      *\r
- * Copyright 2009 (c), Skype Limited                                    *\r
- * Date: 090629                                                         *\r
- *                                                                      */\r
 #ifndef _SKP_DEBUG_H_\r
 #define _SKP_DEBUG_H_\r
 \r
index 10bd439..c238687 100644 (file)
@@ -49,7 +49,7 @@ void SKP_Silk_HP_variable_cutoff_FIX(
     /*********************************************/\r
     /* Estimate Low End of Pitch Frequency Range */\r
     /*********************************************/\r
-    if( psEnc->sCmn.prev_sigtype == SIG_TYPE_VOICED ) {\r
+    if( psEnc->sCmn.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_log_Q7 = SKP_Silk_lin2log( pitch_freq_Hz_Q16 ) - ( 16 << 7 ); //0x70\r
index 67b14a2..aa357f2 100644 (file)
@@ -78,7 +78,6 @@ void SKP_Silk_NLSF_MSVQ_encode_FIX(
     SKP_assert( ( LOW_COMPLEXITY_ONLY == 0 ) || ( NLSF_MSVQ_Survivors <= MAX_NLSF_MSVQ_SURVIVORS_LC_MODE ) );\r
 \r
 #ifdef SAVE_ALL_INTERNAL_DATA\r
-    /* Use sigtype.dat to seperate into signal types */\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( NLSF_mu.dat, &NLSF_mu_Q15,             sizeof( SKP_int32 ) );\r
index 63ddd76..5c34fc1 100644 (file)
@@ -55,7 +55,7 @@ SKP_int SKP_Silk_control_encoder_FIX(
     const SKP_int               PacketSize_ms,          /* I    Packet length (ms)                      */\r
     const SKP_int32             TargetRate_bps,         /* I    Target max bitrate (bps)                */\r
     const SKP_int               PacketLoss_perc,        /* I    Packet loss rate (in percent)           */\r
-    const SKP_int               Complexity              /* I    Complexity (0->low; 1->medium; 2->high) */\r
+    const SKP_int               Complexity              /* I    Complexity (0-10)                       */\r
 )\r
 {\r
     SKP_int   fs_kHz, ret = 0;\r
@@ -113,29 +113,6 @@ SKP_int SKP_Silk_control_encoder_FIX(
     return ret;\r
 }\r
 \r
-/* Control low bitrate redundancy usage */\r
-void SKP_Silk_LBRR_ctrl_FIX(\r
-    SKP_Silk_encoder_state_FIX      *psEnc,     /* I/O  encoder state                               */\r
-    SKP_Silk_encoder_control        *psEncCtrlC /* I/O  encoder control                             */\r
-)\r
-{\r
-    SKP_int LBRR_usage;\r
-\r
-    if( psEnc->sCmn.LBRR_enabled ) {\r
-        /* Control LBRR */\r
-\r
-        /* Usage Control based on sensitivity and packet loss caracteristics */\r
-        /* For now only enable adding to next for active frames. Make more complex later */\r
-        LBRR_usage = SKP_SILK_NO_LBRR;\r
-        if( psEnc->speech_activity_Q8 > SKP_FIX_CONST( LBRR_SPEECH_ACTIVITY_THRES, 8 ) && psEnc->sCmn.PacketLoss_perc > LBRR_LOSS_THRES ) {\r
-            LBRR_usage = SKP_SILK_LBRR;\r
-        }\r
-        psEncCtrlC->LBRR_usage = LBRR_usage;\r
-    } else {\r
-        psEncCtrlC->LBRR_usage = SKP_SILK_NO_LBRR;\r
-    }\r
-}\r
-\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
@@ -208,25 +185,34 @@ SKP_INLINE SKP_int SKP_Silk_setup_fs(
             /* Only allowed when the payload buffer is empty */\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
+            if( psEnc->sCmn.fs_kHz == 8 ) {\r
+                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_NB_iCDF;\r
+            } else {\r
+                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_iCDF;\r
+            }\r
         } else {\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
+            if( psEnc->sCmn.fs_kHz == 8 ) {\r
+                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_NB_iCDF;\r
+            } else {\r
+                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_iCDF; \r
+            }\r
         }\r
-        /* Packet length changes. Reset LBRR buffer */\r
-        SKP_Silk_LBRR_reset( &psEnc->sCmn );\r
         psEnc->sCmn.PacketSize_ms = PacketSize_ms;\r
+        psEnc->sCmn.LBRR_nBytes = 0;\r
     }\r
 \r
     /* 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->sNSQ,            0,                        sizeof( SKP_Silk_nsq_state ) );\r
-        SKP_memset( &psEnc->sPred,           0,                        sizeof( SKP_Silk_predict_state_FIX ) );\r
-        SKP_memset( psEnc->sNSQ.xq,          0, 2 * MAX_FRAME_LENGTH * sizeof( SKP_int16 ) );\r
-        SKP_memset( psEnc->sNSQ_LBRR.xq,     0, 2 * MAX_FRAME_LENGTH * sizeof( SKP_int16 ) );\r
-        SKP_memset( psEnc->sCmn.LBRR_buffer, 0,       MAX_LBRR_DELAY * sizeof( SKP_SILK_LBRR_struct ) );\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->sNSQ,                0,                        sizeof( SKP_Silk_nsq_state ) );\r
+        SKP_memset( &psEnc->sPred,               0,                        sizeof( SKP_Silk_predict_state_FIX ) );\r
+        SKP_memset( psEnc->sNSQ.xq,              0, 2 * MAX_FRAME_LENGTH * sizeof( SKP_int16 ) );\r
+        SKP_memset( psEnc->sNSQ_LBRR.xq,         0, 2 * MAX_FRAME_LENGTH * sizeof( SKP_int16 ) );\r
+        SKP_memset( psEnc->sPred.prev_NLSFq_Q15, 0,        MAX_LPC_ORDER * sizeof( SKP_int ) );\r
 #if SWITCH_TRANSITION_FILTERING\r
         SKP_memset( psEnc->sCmn.sLP.In_LP_State, 0, 2 * sizeof( SKP_int32 ) );\r
         if( psEnc->sCmn.sLP.mode == 1 ) {\r
@@ -237,17 +223,14 @@ SKP_INLINE SKP_int SKP_Silk_setup_fs(
             psEnc->sCmn.sLP.transition_frame_no = 0;\r
         }\r
 #endif\r
+        psEnc->sCmn.LBRR_nBytes         = 0;\r
         psEnc->sCmn.inputBufIx          = 0;\r
         psEnc->sCmn.nFramesInPayloadBuf = 0;\r
         psEnc->sCmn.nBytesInPayloadBuf  = 0;\r
-        psEnc->sCmn.oldest_LBRR_idx     = 0;\r
         psEnc->sCmn.TargetRate_bps      = 0; /* Ensures that psEnc->SNR_dB is recomputed */\r
 \r
-        SKP_memset( psEnc->sPred.prev_NLSFq_Q15, 0, MAX_LPC_ORDER * sizeof( SKP_int ) );\r
-\r
         /* Initialize non-zero parameters */\r
         psEnc->sCmn.prevLag                 = 100;\r
-        psEnc->sCmn.prev_sigtype            = SIG_TYPE_UNVOICED;\r
         psEnc->sCmn.first_frame_after_reset = 1;\r
         psEnc->sPrefilt.lagPrev             = 100;\r
         psEnc->sShape.LastGainIndex         = 1;\r
@@ -296,22 +279,22 @@ SKP_INLINE SKP_int SKP_Silk_setup_fs(
             SKP_assert( 0 );\r
         }\r
         if( psEnc->sCmn.fs_kHz == 24 ) {\r
-            psEnc->sCmn.mu_LTP_Q10 = SKP_FIX_CONST( MU_LTP_QUANT_SWB, 10 );\r
+            psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_SWB, 9 );\r
             psEnc->sCmn.bitrate_threshold_up    = SKP_int32_MAX;\r
             psEnc->sCmn.bitrate_threshold_down  = SWB2WB_BITRATE_BPS; \r
             psEnc->sCmn.pitch_lag_low_bits_iCDF = SKP_Silk_uniform12_iCDF;\r
         } else if( psEnc->sCmn.fs_kHz == 16 ) {\r
-            psEnc->sCmn.mu_LTP_Q10 = SKP_FIX_CONST( MU_LTP_QUANT_WB, 10 );\r
+            psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_WB, 9 );\r
             psEnc->sCmn.bitrate_threshold_up    = WB2SWB_BITRATE_BPS;\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_Q10 = SKP_FIX_CONST( MU_LTP_QUANT_MB, 10 );\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_Q10 = SKP_FIX_CONST( MU_LTP_QUANT_NB, 10 );\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
index e3d8789..1c93fd5 100644 (file)
@@ -33,8 +33,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 /****************/\r
 SKP_int SKP_Silk_encode_frame_FIX( \r
     SKP_Silk_encoder_state_FIX      *psEnc,             /* I/O  Encoder state FIX                       */\r
-    SKP_int32                       *pnBytesOut,        /* I/O  Number of payload bytes                 */\r
-                                                        /*      input: max length; output: used         */\r
+    SKP_int32                       *pnBytesOut,        /*   O  Number of payload bytes                 */\r
     ec_enc                          *psRangeEnc,        /* I/O  compressor data structure               */\r
     const SKP_int16                 *pIn                /* I    Input speech frame                      */\r
 )\r
@@ -45,11 +44,7 @@ SKP_int SKP_Silk_encode_frame_FIX(
     SKP_int16   xfw[ MAX_FRAME_LENGTH ];\r
     SKP_int16   pIn_HP[ MAX_FRAME_LENGTH ];\r
     SKP_int16   res_pitch[ 2 * MAX_FRAME_LENGTH + LA_PITCH_MAX ];\r
-    SKP_int     LBRR_idx, frame_terminator, SNR_dB_Q7;\r
-\r
-    /* Low bitrate redundancy parameters */\r
-    SKP_uint8   LBRRpayload[ MAX_ARITHM_BYTES ];\r
-    SKP_int32   nBytesLBRR;\r
+    SKP_int     frame_terminator, SNR_dB_Q7;\r
 \r
 TIC(ENCODE_FRAME)\r
 \r
@@ -70,6 +65,25 @@ TIC(VAD)
                                  pIn, psEnc->sCmn.frame_length, psEnc->sCmn.fs_kHz );\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
+        sEncCtrl.sCmn.signalType = TYPE_NO_VOICE_ACTIVITY;\r
+        psEnc->sCmn.noSpeechCounter++;\r
+        if( psEnc->sCmn.noSpeechCounter > NO_SPEECH_FRAMES_BEFORE_DTX ) {\r
+            psEnc->sCmn.inDTX = 1;\r
+        }\r
+        if( psEnc->sCmn.noSpeechCounter > MAX_CONSECUTIVE_DTX ) {\r
+            psEnc->sCmn.noSpeechCounter = 0;\r
+            psEnc->sCmn.inDTX           = 0;\r
+        }\r
+    } else {\r
+        psEnc->sCmn.noSpeechCounter = 0;\r
+        psEnc->sCmn.inDTX           = 0;\r
+        sEncCtrl.sCmn.signalType = TYPE_UNVOICED;\r
+    }\r
+\r
     /*******************************************/\r
     /* High-pass filtering of the input signal */\r
     /*******************************************/\r
@@ -124,15 +138,15 @@ TIC(PROCESS_GAINS)
     SKP_Silk_process_gains_FIX( psEnc, &sEncCtrl );\r
 TOC(PROCESS_GAINS)\r
     \r
-    psEnc->sCmn.sigtype[         psEnc->sCmn.nFramesInPayloadBuf ] = sEncCtrl.sCmn.sigtype;\r
-    psEnc->sCmn.QuantOffsetType[ psEnc->sCmn.nFramesInPayloadBuf ] = sEncCtrl.sCmn.QuantOffsetType;\r
+    psEnc->sCmn.quantOffsetType[ psEnc->sCmn.nFramesInPayloadBuf ] = sEncCtrl.sCmn.quantOffsetType;\r
+    psEnc->sCmn.signalType[      psEnc->sCmn.nFramesInPayloadBuf ] = sEncCtrl.sCmn.signalType;\r
 \r
     /****************************************/\r
     /* Low Bitrate Redundant Encoding       */\r
     /****************************************/\r
-    nBytesLBRR = MAX_ARITHM_BYTES;\r
+    psEnc->sCmn.LBRR_nBytes = MAX_ARITHM_BYTES;\r
 TIC(LBRR)\r
-    //SKP_Silk_LBRR_encode_FIX( psEnc, &sEncCtrl, LBRRpayload, &nBytesLBRR, xfw );\r
+    //SKP_Silk_LBRR_encode_FIX( psEnc, &sEncCtrl, psEnc->sCmn.LBRR_payload, &psEnc->sCmn.LBRR_nBytes, xfw );\r
 TOC(LBRR)\r
 \r
     /*****************************************/\r
@@ -154,25 +168,6 @@ TIC(NSQ)
     }\r
 TOC(NSQ)\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
-        psEnc->sCmn.vadFlag = NO_VOICE_ACTIVITY;\r
-        psEnc->sCmn.noSpeechCounter++;\r
-        if( psEnc->sCmn.noSpeechCounter > NO_SPEECH_FRAMES_BEFORE_DTX ) {\r
-            psEnc->sCmn.inDTX = 1;\r
-        }\r
-        if( psEnc->sCmn.noSpeechCounter > MAX_CONSECUTIVE_DTX ) {\r
-            psEnc->sCmn.noSpeechCounter = 0;\r
-            psEnc->sCmn.inDTX           = 0;\r
-        }\r
-    } else {\r
-        psEnc->sCmn.noSpeechCounter = 0;\r
-        psEnc->sCmn.inDTX           = 0;\r
-        psEnc->sCmn.vadFlag         = VOICE_ACTIVITY;\r
-    }\r
-\r
     /****************************************/\r
     /* Initialize range coder               */\r
     /****************************************/\r
@@ -184,7 +179,7 @@ TOC(NSQ)
     /* Encode Parameters                    */\r
     /****************************************/\r
 TIC(ENCODE_PARAMS)\r
-    SKP_Silk_encode_parameters( &psEnc->sCmn, &sEncCtrl.sCmn, psRangeEnc );\r
+    SKP_Silk_encode_indices( &psEnc->sCmn, &sEncCtrl.sCmn, psRangeEnc );\r
 TOC(ENCODE_PARAMS)\r
 \r
     /****************************************/\r
@@ -195,26 +190,18 @@ TOC(ENCODE_PARAMS)
         ( psEnc->sCmn.ltp_mem_length + LA_SHAPE_MS * psEnc->sCmn.fs_kHz ) * sizeof( SKP_int16 ) );\r
     \r
     /* Parameters needed for next frame */\r
-    psEnc->sCmn.prev_sigtype            = sEncCtrl.sCmn.sigtype;\r
     psEnc->sCmn.prevLag                 = sEncCtrl.sCmn.pitchL[ psEnc->sCmn.nb_subfr - 1 ];\r
+    psEnc->sCmn.prevSignalType          = sEncCtrl.sCmn.signalType;\r
     psEnc->sCmn.first_frame_after_reset = 0;\r
-\r
-    if( 0 ) { //psEnc->sCmn.sRC.error ) {\r
-        /* Encoder returned error: clear payload buffer */\r
-        psEnc->sCmn.nFramesInPayloadBuf = 0;\r
-    } else {\r
-        psEnc->sCmn.nFramesInPayloadBuf++;\r
-    }\r
+    psEnc->sCmn.nFramesInPayloadBuf++;\r
 \r
     /****************************************/\r
     /* Finalize payload and copy to output  */\r
     /****************************************/\r
     if( psEnc->sCmn.nFramesInPayloadBuf * SUB_FRAME_LENGTH_MS * psEnc->sCmn.nb_subfr >= psEnc->sCmn.PacketSize_ms ) {\r
 \r
-        LBRR_idx = ( psEnc->sCmn.oldest_LBRR_idx + 1 ) & LBRR_IDX_MASK;\r
-\r
         /* Check if FEC information should be added */\r
-        //frame_terminator = psEnc->sCmn.LBRR_buffer[ LBRR_idx ].usage;\r
+        //frame_terminator = psEnc->sCmn.usage;\r
         frame_terminator = SKP_SILK_NO_LBRR;\r
 \r
         /* Add the frame termination info to stream */\r
@@ -222,56 +209,13 @@ TOC(ENCODE_PARAMS)
 \r
         /* Code excitation signal */\r
         for( i = 0; i < psEnc->sCmn.nFramesInPayloadBuf; i++ ) {\r
-            SKP_Silk_encode_pulses( psRangeEnc, psEnc->sCmn.sigtype[ i ], psEnc->sCmn.QuantOffsetType[ i ], \r
+            SKP_Silk_encode_pulses( psRangeEnc, psEnc->sCmn.signalType[ i ], psEnc->sCmn.quantOffsetType[ i ], \r
                 &psEnc->sCmn.q[ i * psEnc->sCmn.frame_length ], psEnc->sCmn.frame_length );\r
         }\r
 \r
         /* Payload length so far */\r
         nBytes = SKP_RSHIFT( ec_enc_tell( psRangeEnc, 0 ) + 7, 3 );\r
-\r
-        /* Check that there is enough space in external output buffer, and move data */\r
-        if( *pnBytesOut >= nBytes ) {\r
-            //SKP_int bits_in_stream, mask;\r
-            //bits_in_stream = ec_enc_tell( psRangeEnc, 0 );\r
-            //ec_enc_done( psRangeEnc );\r
-            \r
-#if 0\r
-            /* Fill up any remaining bits in the last byte with 1s */\r
-            if( bits_in_stream & 7 ) {\r
-                mask = SKP_RSHIFT( 0xFF, bits_in_stream & 7 );\r
-                if( nBytes - 1 < *pnBytesOut ) {\r
-                    psEnc->sCmn.sRC.range_enc_celt_state.buf->buf[ nBytes - 1 ] |= mask;\r
-                }\r
-            }\r
-            SKP_memcpy( pCode, psEnc->sCmn.sRC.range_enc_celt_state.buf->buf, nBytes * sizeof( SKP_uint8 ) );\r
-#endif\r
-\r
-#if 0\r
-            if( frame_terminator > SKP_SILK_MORE_FRAMES && \r
-                    *pnBytesOut >= nBytes + psEnc->sCmn.LBRR_buffer[ LBRR_idx ].nBytes ) {\r
-                /* Get old packet and add to payload. */\r
-                SKP_memcpy( &pCode[ nBytes ],\r
-                    psEnc->sCmn.LBRR_buffer[ LBRR_idx ].payload,\r
-                    psEnc->sCmn.LBRR_buffer[ LBRR_idx ].nBytes * sizeof( SKP_uint8 ) );\r
-                nBytes += psEnc->sCmn.LBRR_buffer[ LBRR_idx ].nBytes;\r
-            }\r
-#endif\r
-            *pnBytesOut = nBytes;\r
-\r
-            /* Update FEC buffer */\r
-            SKP_memcpy( psEnc->sCmn.LBRR_buffer[ psEnc->sCmn.oldest_LBRR_idx ].payload, LBRRpayload, \r
-                nBytesLBRR * sizeof( SKP_uint8 ) );\r
-            psEnc->sCmn.LBRR_buffer[ psEnc->sCmn.oldest_LBRR_idx ].nBytes = nBytesLBRR;\r
-            /* The line below describes how FEC should be used */\r
-            psEnc->sCmn.LBRR_buffer[ psEnc->sCmn.oldest_LBRR_idx ].usage = sEncCtrl.sCmn.LBRR_usage;\r
-            psEnc->sCmn.oldest_LBRR_idx = ( psEnc->sCmn.oldest_LBRR_idx + 1 ) & LBRR_IDX_MASK;\r
-\r
-        } else {\r
-            /* Not enough space: Payload will be discarded */\r
-            *pnBytesOut = 0;\r
-            nBytes      = 0;\r
-            ret = SKP_SILK_ENC_PAYLOAD_BUF_TOO_SHORT;\r
-        }\r
+        *pnBytesOut = nBytes;\r
 \r
         /* Reset the number of frames in payload buffer */\r
         psEnc->sCmn.nFramesInPayloadBuf = 0;\r
@@ -287,11 +231,6 @@ TOC(ENCODE_PARAMS)
             &psEnc->sCmn.q[ psEnc->sCmn.nFramesInPayloadBuf * psEnc->sCmn.frame_length ] );\r
     }\r
 \r
-    /* Check for arithmetic coder errors */\r
-    if( 0 ) { //psEnc->sCmn.sRC.error ) {\r
-        ret = SKP_SILK_ENC_INTERNAL_ERROR;\r
-    }\r
-\r
     /* Simulate number of ms buffered in channel because of exceeding TargetRate */\r
     SKP_assert(  ( 8 * 1000 * ( (SKP_int64)nBytes - (SKP_int64)psEnc->sCmn.nBytesInPayloadBuf ) ) == \r
         SKP_SAT32( 8 * 1000 * ( (SKP_int64)nBytes - (SKP_int64)psEnc->sCmn.nBytesInPayloadBuf ) ) );\r
@@ -339,14 +278,14 @@ TOC(ENCODE_FRAME)
         DEBUG_STORE_DATA( nBytes.dat,               &nBytes,                        sizeof( SKP_int ) );\r
         tmp[ 0 ] = (SKP_float)sEncCtrl.current_SNR_dB_Q7 / 128.0f;\r
         DEBUG_STORE_DATA( current_SNR_db.dat,       tmp,                            sizeof( SKP_float ) );\r
-        DEBUG_STORE_DATA( QuantOffsetType.dat,      &sEncCtrl.sCmn.QuantOffsetType, sizeof( SKP_int ) );\r
+        DEBUG_STORE_DATA( quantOffsetType.dat,      &sEncCtrl.sCmn.quantOffsetType, sizeof( SKP_int ) );\r
         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
         }\r
         DEBUG_STORE_DATA( input_quality_bands.dat,  tmp,                            VAD_N_BANDS * sizeof( SKP_float ) );\r
-        DEBUG_STORE_DATA( sigtype.dat,              &sEncCtrl.sCmn.sigtype,         sizeof( SKP_int ) ); \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
         DEBUG_STORE_DATA( lag_index.dat,            &sEncCtrl.sCmn.lagIndex,        sizeof( SKP_int ) ); \r
         DEBUG_STORE_DATA( contour_index.dat,        &sEncCtrl.sCmn.contourIndex,    sizeof( SKP_int ) ); \r
@@ -375,7 +314,14 @@ void SKP_Silk_LBRR_encode_FIX(
     /*******************************************/\r
     /* Control use of inband LBRR              */\r
     /*******************************************/\r
-    SKP_Silk_LBRR_ctrl_FIX( psEnc, &psEncCtrl->sCmn );\r
+    psEnc->sCmn.LBRR_usage = SKP_SILK_NO_LBRR;\r
+    if( psEnc->sCmn.LBRR_enabled ) {\r
+        /* Control LBRR */\r
+        /* Usage Control based on sensitivity and packet loss caracteristics */\r
+        if( psEnc->speech_activity_Q8 > SKP_FIX_CONST( LBRR_SPEECH_ACTIVITY_THRES, 8 ) && psEnc->sCmn.PacketLoss_perc > LBRR_LOSS_THRES ) {\r
+            psEnc->sCmn.LBRR_usage = SKP_SILK_LBRR;\r
+        }\r
+    }\r
 \r
     if( psEnc->sCmn.LBRR_enabled ) {\r
         /* Save original gains */\r
@@ -398,7 +344,7 @@ void SKP_Silk_LBRR_encode_FIX(
             SKP_assert( 0 );\r
         }\r
 \r
-        if( psEnc->sCmn.Complexity > 0 && psEnc->sCmn.TargetRate_bps > Rate_only_parameters ) {\r
+        if( psEnc->sCmn.Complexity >= 4 && psEnc->sCmn.TargetRate_bps > Rate_only_parameters ) {\r
             if( psEnc->sCmn.nFramesInPayloadBuf == 0 ) {\r
                 /* First frame in packet; copy everything */\r
                 SKP_memcpy( &psEnc->sNSQ_LBRR, &psEnc->sNSQ, sizeof( SKP_Silk_nsq_state ) );\r
@@ -445,8 +391,7 @@ void SKP_Silk_LBRR_encode_FIX(
         /****************************************/\r
         /* Encode Parameters                    */\r
         /****************************************/\r
-        SKP_Silk_encode_parameters( &psEnc->sCmn, &psEncCtrl->sCmn, \r
-            &psEnc->sCmn.sRC_LBRR );\r
+        SKP_Silk_encode_indices( &psEnc->sCmn, &psEncCtrl->sCmn, &psEnc->sCmn.sRC_LBRR );\r
 \r
         /****************************************/\r
         /* Encode Parameters                    */\r
@@ -473,7 +418,7 @@ void SKP_Silk_LBRR_encode_FIX(
             /* Encode quantization indices of excitation */\r
             /*********************************************/\r
             for( i = 0; i < nFramesInPayloadBuf; i++ ) {\r
-                SKP_Silk_encode_pulses( &psEnc->sCmn.sRC_LBRR, psEnc->sCmn.sigtype[ i ], psEnc->sCmn.QuantOffsetType[ i ],\r
+                SKP_Silk_encode_pulses( &psEnc->sCmn.sRC_LBRR, psEnc->sCmn.signalType[ i ], psEnc->sCmn.quantOffsetType[ i ],\r
                     &psEnc->sCmn.q_LBRR[ i * psEnc->sCmn.frame_length ], psEnc->sCmn.frame_length );\r
             }\r
 \r
index 876403e..ad78d55 100644 (file)
@@ -108,20 +108,25 @@ void SKP_Silk_find_pitch_lags_FIX(
     SKP_Silk_MA_Prediction( x_buf, A_Q12, FiltState, res, buf_len, psEnc->sCmn.pitchEstimationLPCOrder );\r
     SKP_memset( res, 0, psEnc->sCmn.pitchEstimationLPCOrder * sizeof( SKP_int16 ) );\r
 \r
-    /* Threshold for pitch estimator */\r
-    thrhld_Q15 = SKP_FIX_CONST( 0.45, 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.15,  15 ), psEnc->sCmn.prev_sigtype );\r
-    thrhld_Q15 = SKP_SMLAWB( thrhld_Q15, SKP_FIX_CONST( -0.1,   16 ), psEncCtrl->input_tilt_Q15 );\r
-    thrhld_Q15 = SKP_SAT16(  thrhld_Q15 );\r
+    if( psEncCtrl->sCmn.signalType != TYPE_NO_VOICE_ACTIVITY ) {\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.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_SAT16(  thrhld_Q15 );\r
 \r
-    /*****************************************/\r
-    /* Call pitch estimator                  */\r
-    /*****************************************/\r
-TIC(pitch_analysis_core_FIX)\r
-    psEncCtrl->sCmn.sigtype = SKP_Silk_pitch_analysis_core( res, psEncCtrl->sCmn.pitchL, &psEncCtrl->sCmn.lagIndex, \r
-        &psEncCtrl->sCmn.contourIndex, &psEnc->LTPCorr_Q15, psEnc->sCmn.prevLag, psEnc->sCmn.pitchEstimationThreshold_Q16, \r
-        ( SKP_int16 )thrhld_Q15, psEnc->sCmn.fs_kHz, psEnc->sCmn.pitchEstimationComplexity, psEnc->sCmn.nb_subfr );\r
-TOC(pitch_analysis_core_FIX)\r
+        /*****************************************/\r
+        /* Call pitch estimator                  */\r
+        /*****************************************/\r
+        if( SKP_Silk_pitch_analysis_core( res, psEncCtrl->sCmn.pitchL, &psEncCtrl->sCmn.lagIndex, \r
+                &psEncCtrl->sCmn.contourIndex, &psEnc->LTPCorr_Q15, psEnc->sCmn.prevLag, psEnc->sCmn.pitchEstimationThreshold_Q16, \r
+                ( SKP_int16 )thrhld_Q15, psEnc->sCmn.fs_kHz, psEnc->sCmn.pitchEstimationComplexity, psEnc->sCmn.nb_subfr ) == 0 ) \r
+        {\r
+            psEncCtrl->sCmn.signalType = TYPE_VOICED;\r
+        } else {\r
+            psEncCtrl->sCmn.signalType = TYPE_UNVOICED;\r
+        }\r
+    }\r
 }\r
index 9fa696b..efe2dfb 100644 (file)
@@ -114,7 +114,7 @@ void SKP_Silk_find_pred_coefs_FIX(
         local_gains[ i ] = SKP_DIV32( ( 1 << 16 ), invGains_Q16[ i ] );\r
     }\r
 \r
-    if( psEncCtrl->sCmn.sigtype == SIG_TYPE_VOICED ) {\r
+    if( psEncCtrl->sCmn.signalType == TYPE_VOICED ) {\r
         /**********/\r
         /* VOICED */\r
         /**********/\r
@@ -134,7 +134,7 @@ void SKP_Silk_find_pred_coefs_FIX(
 \r
         /* Quantize LTP gain parameters */\r
         SKP_Silk_quant_LTP_gains( psEncCtrl->LTPCoef_Q14, psEncCtrl->sCmn.LTPIndex, &psEncCtrl->sCmn.PERIndex, \r
-            WLTP, psEnc->sCmn.mu_LTP_Q10, psEnc->sCmn.LTPQuantLowComplexity, psEnc->sCmn.nb_subfr);\r
+            WLTP, psEnc->sCmn.mu_LTP_Q9, psEnc->sCmn.LTPQuantLowComplexity, psEnc->sCmn.nb_subfr);\r
 \r
         /* Control LTP scaling */\r
         SKP_Silk_LTP_scale_ctrl_FIX( psEnc, psEncCtrl );\r
@@ -266,7 +266,7 @@ void SKP_Silk_find_pred_coefs_FIX(
                 in_ptr      += psEnc->sCmn.subfr_length;\r
             }\r
                 \r
-            if( psEncCtrl->sCmn.sigtype == SIG_TYPE_VOICED ) {\r
+            if( psEncCtrl->sCmn.signalType == TYPE_VOICED ) {\r
                 /* Calculate LTP residual with unquantized LTP and unquantized LPC */\r
                 SKP_Silk_LTP_ana_core( LPC_res, LTP_res, &psEncCtrl->sCmn.pitchL[ j ],\r
                     &uq_LTPCoef[ j * LTP_ORDER ], psEnc->sCmn.subfr_length, psEnc->sCmn.ltp_mem_length );\r
@@ -291,7 +291,7 @@ void SKP_Silk_find_pred_coefs_FIX(
                 in_ptr       += psEnc->sCmn.subfr_length;\r
             }\r
 \r
-            if( psEncCtrl->sCmn.sigtype == SIG_TYPE_VOICED ) {\r
+            if( psEncCtrl->sCmn.signalType == TYPE_VOICED ) {\r
                 /* Calculate LTP residual with unquantized LTP and unquantized LPC */\r
                 SKP_Silk_LTP_ana_core( LPC_res, LTP_res, &psEncCtrl->sCmn.pitchL[ j ],\r
                     &LTPCoef[ j * LTP_ORDER ], psEnc->sCmn.subfr_length, psEnc->sCmn.ltp_mem_length );\r
@@ -310,7 +310,7 @@ void SKP_Silk_find_pred_coefs_FIX(
             DEBUG_STORE_DATA( LPC_res.dat, &LPC_res[ psEnc->sCmn.ltp_mem_length ], ( psEnc->sCmn.subfr_length << 1 ) * sizeof( SKP_float ) );\r
             DEBUG_STORE_DATA( res.dat,     LTP_res,                                ( psEnc->sCmn.subfr_length << 1 ) * sizeof( SKP_float ) );\r
         }\r
-        if( psEncCtrl->sCmn.sigtype == SIG_TYPE_VOICED ) {\r
+        if( psEncCtrl->sCmn.signalType == TYPE_VOICED ) {\r
             LPC_predCodGain  = 3.0f * SKP_Silk_log2( in_nrg       / LPC_res_nrg  );\r
             QLPC_predCodGain = 3.0f * SKP_Silk_log2( in_nrg       / qLPC_res_nrg );\r
             LTPredCodGain    = 3.0f * SKP_Silk_log2( LPC_res_nrg  / LTP_res_nrg  );\r
index 577f2b8..382443e 100644 (file)
@@ -83,7 +83,7 @@ SKP_int SKP_Silk_control_encoder_FIX(
     const SKP_int               PacketSize_ms,          /* I    Packet length (ms)                      */\r
     const SKP_int32             TargetRate_bps,         /* I    Target max bitrate (bps)                */\r
     const SKP_int               PacketLoss_perc,        /* I    Packet loss rate (in percent)           */\r
-    const SKP_int               Complexity              /* I    Complexity (0->low; 1->medium; 2->high) */\r
+    const SKP_int               Complexity              /* I    Complexity (0-10)                       */\r
 );\r
 \r
 /****************/\r
@@ -117,12 +117,6 @@ void SKP_Silk_warped_autocorrelation_FIX(
     const SKP_int                   order               /* I    Correlation order (even)                */\r
 );\r
 \r
-/* Control low bitrate redundancy usage */\r
-void SKP_Silk_LBRR_ctrl_FIX(\r
-    SKP_Silk_encoder_state_FIX      *psEnc,         /* I/O  encoder state                               */\r
-    SKP_Silk_encoder_control        *psEncCtrlC     /* I/O  encoder control                             */\r
-);\r
-\r
 /* Calculation of LTP state scaling */\r
 void SKP_Silk_LTP_scale_ctrl_FIX(\r
     SKP_Silk_encoder_state_FIX      *psEnc,         /* I/O  encoder state                               */\r
index 6c4e074..3ce166f 100644 (file)
@@ -196,7 +196,7 @@ void SKP_Silk_noise_shape_analysis_FIX(
             SKP_SMULWB( SKP_FIX_CONST( 1.0, 14 ) + psEncCtrl->input_quality_Q14, psEncCtrl->coding_quality_Q14 ) );     // Q12\r
     }\r
 \r
-    if( psEncCtrl->sCmn.sigtype == SIG_TYPE_VOICED ) {\r
+    if( psEncCtrl->sCmn.signalType == TYPE_VOICED ) {\r
         /* Reduce gains for periodic signals */\r
         SNR_adj_dB_Q7 = SKP_SMLAWB( SNR_adj_dB_Q7, SKP_FIX_CONST( HARM_SNR_INCR_dB, 8 ), psEnc->LTPCorr_Q15 );\r
     } else { \r
@@ -210,9 +210,9 @@ void SKP_Silk_noise_shape_analysis_FIX(
     /* SPARSENESS PROCESSING */\r
     /*************************/\r
     /* Set quantizer offset */\r
-    if( psEncCtrl->sCmn.sigtype == SIG_TYPE_VOICED ) {\r
+    if( psEncCtrl->sCmn.signalType == TYPE_VOICED ) {\r
         /* Initally set to 0; may be overruled in process_gains(..) */\r
-        psEncCtrl->sCmn.QuantOffsetType = 0;\r
+        psEncCtrl->sCmn.quantOffsetType = 0;\r
         psEncCtrl->sparseness_Q8 = 0;\r
     } else {\r
         /* Sparseness measure, based on relative fluctuations of energy per 2 milliseconds */\r
@@ -237,9 +237,9 @@ void SKP_Silk_noise_shape_analysis_FIX(
 \r
         /* Set quantization offset depending on sparseness measure */\r
         if( psEncCtrl->sparseness_Q8 > SKP_FIX_CONST( SPARSENESS_THRESHOLD_QNT_OFFSET, 8 ) ) {\r
-            psEncCtrl->sCmn.QuantOffsetType = 0;\r
+            psEncCtrl->sCmn.quantOffsetType = 0;\r
         } else {\r
-            psEncCtrl->sCmn.QuantOffsetType = 1;\r
+            psEncCtrl->sCmn.quantOffsetType = 1;\r
         }\r
         \r
         /* Increase coding SNR for sparse signals */\r
@@ -388,7 +388,7 @@ void SKP_Silk_noise_shape_analysis_FIX(
         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
-    if( psEncCtrl->sCmn.sigtype == SIG_TYPE_VOICED ) {\r
+    if( psEncCtrl->sCmn.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
         SKP_int fs_kHz_inv = SKP_DIV32_16( SKP_FIX_CONST( 0.2, 14 ), psEnc->sCmn.fs_kHz );\r
@@ -425,7 +425,7 @@ void SKP_Silk_noise_shape_analysis_FIX(
     HarmBoost_Q16 = SKP_SMLAWB( HarmBoost_Q16, \r
         SKP_FIX_CONST( 1.0, 16 ) - SKP_LSHIFT( psEncCtrl->input_quality_Q14, 2 ), SKP_FIX_CONST( LOW_INPUT_QUALITY_HARMONIC_BOOST, 16 ) );\r
 \r
-    if( USE_HARM_SHAPING && psEncCtrl->sCmn.sigtype == SIG_TYPE_VOICED ) {\r
+    if( USE_HARM_SHAPING && psEncCtrl->sCmn.signalType == TYPE_VOICED ) {\r
         /* More harmonic noise shaping for high bitrates or noisy input */\r
         HarmShapeGain_Q16 = SKP_SMLAWB( SKP_FIX_CONST( HARMONIC_SHAPING, 16 ), \r
                 SKP_FIX_CONST( 1.0, 16 ) - SKP_SMULWB( SKP_FIX_CONST( 1.0, 18 ) - SKP_LSHIFT( psEncCtrl->coding_quality_Q14, 4 ),\r
index c0a2272..994bac2 100644 (file)
@@ -106,7 +106,7 @@ void SKP_Silk_prefilter_FIX(
     lag = P->lagPrev;\r
     for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) {\r
         /* Update Variables that change per sub frame */\r
-        if( psEncCtrl->sCmn.sigtype == SIG_TYPE_VOICED ) {\r
+        if( psEncCtrl->sCmn.signalType == TYPE_VOICED ) {\r
             lag = psEncCtrl->sCmn.pitchL[ k ];\r
         }\r
 \r
index 6bff532..9e41e75 100644 (file)
@@ -49,12 +49,11 @@ void SKP_Silk_process_NLSFs_FIX(
     SKP_assert( psEnc->speech_activity_Q8 <= 256 );\r
     SKP_assert( psEncCtrl->sparseness_Q8  >=   0 );\r
     SKP_assert( psEncCtrl->sparseness_Q8  <= 256 );\r
-    SKP_assert( psEncCtrl->sCmn.sigtype == SIG_TYPE_VOICED || psEncCtrl->sCmn.sigtype == SIG_TYPE_UNVOICED );\r
 \r
     /***********************/\r
     /* Calculate mu values */\r
     /***********************/\r
-    if( psEncCtrl->sCmn.sigtype == SIG_TYPE_VOICED ) {\r
+    if( psEncCtrl->sCmn.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
@@ -100,7 +99,7 @@ void SKP_Silk_process_NLSFs_FIX(
     }\r
 \r
     /* Set pointer to the NLSF codebook for the current signal type and LPC order */\r
-    psNLSF_CB = psEnc->sCmn.psNLSF_CB[ psEncCtrl->sCmn.sigtype ];\r
+    psNLSF_CB = psEnc->sCmn.psNLSF_CB[ 1 - ( psEncCtrl->sCmn.signalType >> 1 ) ];\r
 \r
     /* Quantize NLSF parameters given the trained NLSF codebooks */\r
     TIC(MSVQ_encode_FIX)\r
index 301687a..23ea9cc 100644 (file)
@@ -39,7 +39,7 @@ void SKP_Silk_process_gains_FIX(
     SKP_int32   s_Q16, InvMaxSqrVal_Q16, gain, gain_squared, ResNrg, ResNrgPart, quant_offset_Q10;\r
 \r
     /* Gain reduction when LTP coding gain is high */\r
-    if( psEncCtrl->sCmn.sigtype == SIG_TYPE_VOICED ) {\r
+    if( psEncCtrl->sCmn.signalType == TYPE_VOICED ) {\r
         /*s = -0.5f * SKP_sigmoid( 0.25f * ( psEncCtrl->LTPredCodGain - 12.0f ) ); */\r
         s_Q16 = -SKP_Silk_sigm_Q15( SKP_RSHIFT_ROUND( psEncCtrl->LTPredCodGain_Q7 - SKP_FIX_CONST( 12.0, 7 ), 4 ) );\r
         for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) {\r
@@ -86,16 +86,16 @@ void SKP_Silk_process_gains_FIX(
     SKP_Silk_gains_quant( psEncCtrl->sCmn.GainsIndices, psEncCtrl->Gains_Q16, \r
         &psShapeSt->LastGainIndex, psEnc->sCmn.nFramesInPayloadBuf, 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( psEncCtrl->sCmn.sigtype == SIG_TYPE_VOICED ) {\r
+    if( psEncCtrl->sCmn.signalType == TYPE_VOICED ) {\r
         if( psEncCtrl->LTPredCodGain_Q7 + SKP_RSHIFT( psEncCtrl->input_tilt_Q15, 8 ) > SKP_FIX_CONST( 1.0, 7 ) ) {\r
-            psEncCtrl->sCmn.QuantOffsetType = 0;\r
+            psEncCtrl->sCmn.quantOffsetType = 0;\r
         } else {\r
-            psEncCtrl->sCmn.QuantOffsetType = 1;\r
+            psEncCtrl->sCmn.quantOffsetType = 1;\r
         }\r
     }\r
 \r
     /* Quantizer boundary adjustment */\r
-    quant_offset_Q10 = SKP_Silk_Quantization_Offsets_Q10[ psEncCtrl->sCmn.sigtype ][ psEncCtrl->sCmn.QuantOffsetType ];\r
+    quant_offset_Q10 = SKP_Silk_Quantization_Offsets_Q10[ psEncCtrl->sCmn.signalType >> 1 ][ psEncCtrl->sCmn.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
index 9700f7b..4d3fdfa 100644 (file)
@@ -44,8 +44,7 @@ void SKP_Silk_HP_variable_cutoff_FLP(
     /*********************************************/\r
     /* Estimate low end of pitch frequency range */\r
     /*********************************************/\r
-    if( psEnc->sCmn.prev_sigtype == SIG_TYPE_VOICED ) {\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
index e3668b9..ae400b5 100644 (file)
@@ -35,55 +35,53 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 /* first Order output samples are not set  */\r
 /*******************************************/\r
 \r
-void SKP_Silk_LPC_analysis_filter_FLP(\r
+/* 16th order LPC analysis filter, does not write first 16 samples */\r
+void SKP_Silk_LPC_analysis_filter16_FLP(\r
           SKP_float                 r_LPC[],            /* O    LPC residual signal                     */\r
     const SKP_float                 PredCoef[],         /* I    LPC coefficients                        */\r
     const SKP_float                 s[],                /* I    Input signal                            */\r
-    const SKP_int                   length,             /* I    Length of input signal                  */\r
-    const SKP_int                   Order               /* I    LPC order                               */\r
+    const SKP_int                   length              /* I    Length of input signal                  */\r
 )\r
 {\r
-    SKP_assert( Order <= length );\r
-\r
-    switch( Order ) {\r
-        case 6:\r
-            SKP_Silk_LPC_analysis_filter6_FLP(  r_LPC, PredCoef, s, length );\r
-        break;\r
-\r
-        case 8:\r
-            SKP_Silk_LPC_analysis_filter8_FLP(  r_LPC, PredCoef, s, length );\r
-        break;\r
-\r
-        case 10:\r
-            SKP_Silk_LPC_analysis_filter10_FLP( r_LPC, PredCoef, s, length );\r
-        break;\r
+    SKP_int   ix = 16;\r
+    SKP_float LPC_pred;\r
+    const SKP_float *s_ptr;\r
 \r
-        case 12:\r
-            SKP_Silk_LPC_analysis_filter12_FLP( r_LPC, PredCoef, s, length );\r
-        break;\r
+    for ( ; ix < length; ix++) {\r
+        s_ptr = &s[ix - 1];\r
 \r
-        case 16:\r
-            SKP_Silk_LPC_analysis_filter16_FLP( r_LPC, PredCoef, s, length );\r
-        break;\r
+        /* short-term prediction */\r
+        LPC_pred = s_ptr[  0 ]  * PredCoef[ 0 ]  + \r
+                   s_ptr[ -1 ]  * PredCoef[ 1 ]  +\r
+                   s_ptr[ -2 ]  * PredCoef[ 2 ]  +\r
+                   s_ptr[ -3 ]  * PredCoef[ 3 ]  +\r
+                   s_ptr[ -4 ]  * PredCoef[ 4 ]  +\r
+                   s_ptr[ -5 ]  * PredCoef[ 5 ]  +\r
+                   s_ptr[ -6 ]  * PredCoef[ 6 ]  +\r
+                   s_ptr[ -7 ]  * PredCoef[ 7 ]  +\r
+                   s_ptr[ -8 ]  * PredCoef[ 8 ]  +\r
+                   s_ptr[ -9 ]  * PredCoef[ 9 ]  +\r
+                   s_ptr[ -10 ] * PredCoef[ 10 ] +\r
+                   s_ptr[ -11 ] * PredCoef[ 11 ] +\r
+                   s_ptr[ -12 ] * PredCoef[ 12 ] +\r
+                   s_ptr[ -13 ] * PredCoef[ 13 ] +\r
+                   s_ptr[ -14 ] * PredCoef[ 14 ] +\r
+                   s_ptr[ -15 ] * PredCoef[ 15 ];\r
 \r
-        default:\r
-            SKP_assert( 0 );\r
-        break;\r
+        /* prediction error */\r
+        r_LPC[ix] = s_ptr[ 1 ] - LPC_pred;\r
     }\r
-\r
-    /* Set first LPC Order samples to zero instead of undefined */\r
-    SKP_memset( r_LPC, 0, Order * sizeof( SKP_float ) );\r
 }\r
 \r
-/* 16th order LPC analysis filter, does not write first 16 samples */\r
-void SKP_Silk_LPC_analysis_filter16_FLP(\r
+/* 14th order LPC analysis filter, does not write first 14 samples */\r
+void SKP_Silk_LPC_analysis_filter14_FLP(\r
           SKP_float                 r_LPC[],            /* O    LPC residual signal                     */\r
     const SKP_float                 PredCoef[],         /* I    LPC coefficients                        */\r
     const SKP_float                 s[],                /* I    Input signal                            */\r
     const SKP_int                   length              /* I    Length of input signal                  */\r
 )\r
 {\r
-    SKP_int   ix = 16;\r
+    SKP_int   ix = 14;\r
     SKP_float LPC_pred;\r
     const SKP_float *s_ptr;\r
 \r
@@ -104,9 +102,7 @@ void SKP_Silk_LPC_analysis_filter16_FLP(
                    s_ptr[ -10 ] * PredCoef[ 10 ] +\r
                    s_ptr[ -11 ] * PredCoef[ 11 ] +\r
                    s_ptr[ -12 ] * PredCoef[ 12 ] +\r
-                   s_ptr[ -13 ] * PredCoef[ 13 ] +\r
-                   s_ptr[ -14 ] * PredCoef[ 14 ] +\r
-                   s_ptr[ -15 ] * PredCoef[ 15 ];\r
+                   s_ptr[ -13 ] * PredCoef[ 13 ];\r
 \r
         /* prediction error */\r
         r_LPC[ix] = s_ptr[ 1 ] - LPC_pred;\r
@@ -236,3 +232,48 @@ void SKP_Silk_LPC_analysis_filter6_FLP(
         r_LPC[ix] = s_ptr[ 1 ] - LPC_pred;\r
     }\r
 }\r
+\r
+void SKP_Silk_LPC_analysis_filter_FLP(\r
+          SKP_float                 r_LPC[],            /* O    LPC residual signal                     */\r
+    const SKP_float                 PredCoef[],         /* I    LPC coefficients                        */\r
+    const SKP_float                 s[],                /* I    Input signal                            */\r
+    const SKP_int                   length,             /* I    Length of input signal                  */\r
+    const SKP_int                   Order               /* I    LPC order                               */\r
+)\r
+{\r
+    SKP_assert( Order <= length );\r
+\r
+    switch( Order ) {\r
+        case 6:\r
+            SKP_Silk_LPC_analysis_filter6_FLP(  r_LPC, PredCoef, s, length );\r
+        break;\r
+\r
+        case 8:\r
+            SKP_Silk_LPC_analysis_filter8_FLP(  r_LPC, PredCoef, s, length );\r
+        break;\r
+\r
+        case 10:\r
+            SKP_Silk_LPC_analysis_filter10_FLP( r_LPC, PredCoef, s, length );\r
+        break;\r
+\r
+        case 12:\r
+            SKP_Silk_LPC_analysis_filter12_FLP( r_LPC, PredCoef, s, length );\r
+        break;\r
+\r
+        case 14:\r
+            SKP_Silk_LPC_analysis_filter14_FLP( r_LPC, PredCoef, s, length );\r
+        break;\r
+\r
+        case 16:\r
+            SKP_Silk_LPC_analysis_filter16_FLP( r_LPC, PredCoef, s, length );\r
+        break;\r
+\r
+        default:\r
+            SKP_assert( 0 );\r
+        break;\r
+    }\r
+\r
+    /* Set first LPC Order samples to zero instead of undefined */\r
+    SKP_memset( r_LPC, 0, Order * sizeof( SKP_float ) );\r
+}\r
+\r
index 3550778..94f5810 100644 (file)
@@ -80,7 +80,6 @@ void SKP_Silk_NLSF_MSVQ_encode_FLP(
     SKP_assert( ( LOW_COMPLEXITY_ONLY == 0 ) || ( NLSF_MSVQ_Survivors <= MAX_NLSF_MSVQ_SURVIVORS_LC_MODE ) );\r
 \r
 #ifdef SAVE_ALL_INTERNAL_DATA\r
-    /* Use sigtype.dat to seperate into signal types */\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
index e8dff23..2b0333a 100644 (file)
@@ -54,7 +54,7 @@ SKP_int SKP_Silk_control_encoder_FLP(
     const SKP_int               PacketSize_ms,          /* I    Packet length (ms)                      */\r
     const SKP_int32             TargetRate_bps,         /* I    Target max bitrate (bps)                */\r
     const SKP_int               PacketLoss_perc,        /* I    Packet loss rate (in percent)           */\r
-    const SKP_int               Complexity              /* I    Complexity (0->low; 1->medium; 2->high) */\r
+    const SKP_int               Complexity              /* I    Complexity (0-10)                       */\r
 )\r
 {\r
     SKP_int   fs_kHz, ret = 0;\r
@@ -112,29 +112,6 @@ SKP_int SKP_Silk_control_encoder_FLP(
     return ret;\r
 }\r
 \r
-/* Control low bitrate redundancy usage */\r
-void SKP_Silk_LBRR_ctrl_FLP(\r
-    SKP_Silk_encoder_state_FLP      *psEnc,             /* I    Encoder state FLP                       */\r
-    SKP_Silk_encoder_control        *psEncCtrlC         /* I/O  Encoder control                         */\r
-)\r
-{\r
-    SKP_int LBRR_usage;\r
-\r
-    if( psEnc->sCmn.LBRR_enabled ) {\r
-        /* Control LBRR */\r
-\r
-        /* Usage Control based on sensitivity and packet loss caracteristics */\r
-        /* For now only enable adding to next for active frames. Make more complex later */\r
-        LBRR_usage = SKP_SILK_NO_LBRR;\r
-        if( psEnc->speech_activity > LBRR_SPEECH_ACTIVITY_THRES && psEnc->sCmn.PacketLoss_perc > LBRR_LOSS_THRES ) {\r
-            LBRR_usage = SKP_SILK_LBRR;\r
-        }\r
-        psEncCtrlC->LBRR_usage = LBRR_usage;\r
-    } else {\r
-        psEncCtrlC->LBRR_usage = SKP_SILK_NO_LBRR;\r
-    }\r
-}\r
-\r
 SKP_INLINE SKP_int SKP_Silk_setup_resamplers(\r
     SKP_Silk_encoder_state_FLP      *psEnc,             /* I/O  Pointer to Silk encoder state FLP       */\r
     SKP_int                         fs_kHz              /* I    External (API) sampling rate (Hz)       */\r
@@ -211,13 +188,22 @@ SKP_INLINE SKP_int SKP_Silk_setup_fs(
             /* Only allowed when the payload buffer is empty */\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
+            if( psEnc->sCmn.fs_kHz == 8 ) {\r
+                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_NB_iCDF;\r
+            } else {\r
+                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_iCDF;\r
+            }\r
         } else {\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
+            if( psEnc->sCmn.fs_kHz == 8 ) {\r
+                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_NB_iCDF;\r
+            } else {\r
+                psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_iCDF; \r
+            }\r
         }\r
-        /* Packet length changes. Reset LBRR buffer */\r
-        SKP_Silk_LBRR_reset( &psEnc->sCmn );\r
         psEnc->sCmn.PacketSize_ms = PacketSize_ms;\r
+        psEnc->sCmn.LBRR_nBytes = 0;\r
     }\r
 \r
     /* Set internal sampling frequency */\r
@@ -229,7 +215,7 @@ SKP_INLINE SKP_int SKP_Silk_setup_fs(
         SKP_memset( &psEnc->sPred,           0,                        sizeof( SKP_Silk_predict_state_FLP ) );\r
         SKP_memset( psEnc->sNSQ.xq,          0, 2 * MAX_FRAME_LENGTH * sizeof( SKP_int16 ) );\r
         SKP_memset( psEnc->sNSQ_LBRR.xq,     0, 2 * MAX_FRAME_LENGTH * sizeof( SKP_int16 ) );\r
-        SKP_memset( psEnc->sCmn.LBRR_buffer, 0,       MAX_LBRR_DELAY * sizeof( SKP_SILK_LBRR_struct ) );\r
+        SKP_memset( psEnc->sPred.prev_NLSFq, 0,        MAX_LPC_ORDER * sizeof( SKP_float ) );\r
 #if SWITCH_TRANSITION_FILTERING\r
         SKP_memset( psEnc->sCmn.sLP.In_LP_State, 0, 2 * sizeof( SKP_int32 ) );\r
         if( psEnc->sCmn.sLP.mode == 1 ) {\r
@@ -240,17 +226,14 @@ SKP_INLINE SKP_int SKP_Silk_setup_fs(
             psEnc->sCmn.sLP.transition_frame_no = 0;\r
         }\r
 #endif\r
+        psEnc->sCmn.LBRR_nBytes         = 0;\r
         psEnc->sCmn.inputBufIx          = 0;\r
         psEnc->sCmn.nFramesInPayloadBuf = 0;\r
         psEnc->sCmn.nBytesInPayloadBuf  = 0;\r
-        psEnc->sCmn.oldest_LBRR_idx     = 0;\r
         psEnc->sCmn.TargetRate_bps      = 0; /* Ensures that psEnc->SNR_dB is recomputed */\r
 \r
-        SKP_memset( psEnc->sPred.prev_NLSFq, 0, MAX_LPC_ORDER * sizeof( SKP_float ) );\r
-\r
         /* Initialize non-zero parameters */\r
         psEnc->sCmn.prevLag                 = 100;\r
-        psEnc->sCmn.prev_sigtype            = SIG_TYPE_UNVOICED;\r
         psEnc->sCmn.first_frame_after_reset = 1;\r
         psEnc->sPrefilt.lagPrev             = 100;\r
         psEnc->sShape.LastGainIndex         = 1;\r
@@ -299,22 +282,22 @@ SKP_INLINE SKP_int SKP_Silk_setup_fs(
             SKP_assert( 0 );\r
         }\r
         if( psEnc->sCmn.fs_kHz == 24 ) {\r
-            psEnc->sCmn.mu_LTP_Q10 = SKP_FIX_CONST( MU_LTP_QUANT_SWB, 10 );\r
+            psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_SWB, 9 );\r
             psEnc->sCmn.bitrate_threshold_up    = SKP_int32_MAX;\r
             psEnc->sCmn.bitrate_threshold_down  = SWB2WB_BITRATE_BPS; \r
             psEnc->sCmn.pitch_lag_low_bits_iCDF = SKP_Silk_uniform12_iCDF;\r
         } else if( psEnc->sCmn.fs_kHz == 16 ) {\r
-            psEnc->sCmn.mu_LTP_Q10 = SKP_FIX_CONST( MU_LTP_QUANT_WB, 10 );\r
+            psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_WB, 9 );\r
             psEnc->sCmn.bitrate_threshold_up    = WB2SWB_BITRATE_BPS;\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_Q10 = SKP_FIX_CONST( MU_LTP_QUANT_MB, 10 );\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_Q10 = SKP_FIX_CONST( MU_LTP_QUANT_NB, 10 );\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
index 9ea62eb..08ed3be 100644 (file)
@@ -33,8 +33,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 /****************/\r
 SKP_int SKP_Silk_encode_frame_FLP( \r
     SKP_Silk_encoder_state_FLP      *psEnc,             /* I/O  Encoder state FLP                       */\r
-    SKP_int32                       *pnBytesOut,        /* I/O  Number of payload bytes                 */\r
-                                                        /*      input: max length; output: used         */\r
+    SKP_int32                       *pnBytesOut,        /*   O  Number of payload bytes                 */\r
     ec_enc                          *psRangeEnc,        /* I/O  compressor data structure               */\r
     const SKP_int16                 *pIn                /* I    Input speech frame                      */\r
 )\r
@@ -46,11 +45,7 @@ SKP_int SKP_Silk_encode_frame_FLP(
     SKP_int16   pIn_HP_LP[ MAX_FRAME_LENGTH ];\r
     SKP_float   xfw[       MAX_FRAME_LENGTH ];\r
     SKP_float   res_pitch[ 2 * MAX_FRAME_LENGTH + LA_PITCH_MAX ];\r
-    SKP_int     LBRR_idx, frame_terminator;\r
-\r
-    /* Low bitrate redundancy parameters */\r
-    SKP_uint8   LBRRpayload[ MAX_ARITHM_BYTES ];\r
-    SKP_int16   nBytesLBRR;\r
+    SKP_int     frame_terminator;\r
 \r
 TIC(ENCODE_FRAME)\r
 \r
@@ -69,6 +64,25 @@ TIC(VAD)
     SKP_Silk_VAD_FLP( psEnc, &sEncCtrl, pIn );\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
+        sEncCtrl.sCmn.signalType = TYPE_NO_VOICE_ACTIVITY;\r
+        psEnc->sCmn.noSpeechCounter++;\r
+        if( psEnc->sCmn.noSpeechCounter > NO_SPEECH_FRAMES_BEFORE_DTX ) {\r
+            psEnc->sCmn.inDTX = 1;\r
+        }\r
+        if( psEnc->sCmn.noSpeechCounter > MAX_CONSECUTIVE_DTX ) {\r
+            psEnc->sCmn.noSpeechCounter = 0;\r
+            psEnc->sCmn.inDTX           = 0;\r
+        }\r
+    } else {\r
+        psEnc->sCmn.noSpeechCounter = 0;\r
+        psEnc->sCmn.inDTX           = 0;\r
+        sEncCtrl.sCmn.signalType = TYPE_UNVOICED;\r
+    }\r
+\r
     /*******************************************/\r
     /* High-pass filtering of the input signal */\r
     /*******************************************/\r
@@ -133,14 +147,15 @@ TIC(PROCESS_GAINS)
     SKP_Silk_process_gains_FLP( psEnc, &sEncCtrl );\r
 TOC(PROCESS_GAINS)\r
     \r
-    psEnc->sCmn.sigtype[         psEnc->sCmn.nFramesInPayloadBuf ] = sEncCtrl.sCmn.sigtype;\r
-    psEnc->sCmn.QuantOffsetType[ psEnc->sCmn.nFramesInPayloadBuf ] = sEncCtrl.sCmn.QuantOffsetType;\r
+    psEnc->sCmn.quantOffsetType[ psEnc->sCmn.nFramesInPayloadBuf ] = sEncCtrl.sCmn.quantOffsetType;\r
+    psEnc->sCmn.signalType[      psEnc->sCmn.nFramesInPayloadBuf ] = sEncCtrl.sCmn.signalType;\r
+\r
     /****************************************/\r
     /* Low Bitrate Redundant Encoding       */\r
     /****************************************/\r
-    nBytesLBRR = MAX_ARITHM_BYTES;\r
+    psEnc->sCmn.LBRR_nBytes = MAX_ARITHM_BYTES;\r
 TIC(LBRR)\r
-    //SKP_Silk_LBRR_encode_FLP( psEnc, &sEncCtrl, LBRRpayload, &nBytesLBRR, xfw );\r
+    //SKP_Silk_LBRR_encode_FLP( psEnc, &sEncCtrl, psEnc->sCmn.LBRR_payload, &psEnc->sCmn.LBRR_nBytes, xfw );\r
 TOC(LBRR)\r
 \r
     /*****************************************/\r
@@ -150,25 +165,6 @@ TIC(NSQ)
     SKP_Silk_NSQ_wrapper_FLP( psEnc, &sEncCtrl, xfw, &psEnc->sCmn.q[ psEnc->sCmn.nFramesInPayloadBuf * psEnc->sCmn.frame_length ], 0 );\r
 TOC(NSQ)\r
 \r
-    /**************************************************/\r
-    /* Convert speech activity into VAD and DTX flags */\r
-    /**************************************************/\r
-    if( psEnc->speech_activity < SPEECH_ACTIVITY_DTX_THRES ) {\r
-        psEnc->sCmn.vadFlag = NO_VOICE_ACTIVITY;\r
-        psEnc->sCmn.noSpeechCounter++;\r
-        if( psEnc->sCmn.noSpeechCounter > NO_SPEECH_FRAMES_BEFORE_DTX ) {\r
-            psEnc->sCmn.inDTX = 1;\r
-        }\r
-        if( psEnc->sCmn.noSpeechCounter > MAX_CONSECUTIVE_DTX ) {\r
-            psEnc->sCmn.noSpeechCounter = 0;\r
-            psEnc->sCmn.inDTX           = 0;\r
-        }\r
-    } else {\r
-        psEnc->sCmn.noSpeechCounter = 0;\r
-        psEnc->sCmn.inDTX           = 0;\r
-        psEnc->sCmn.vadFlag         = VOICE_ACTIVITY;\r
-    }\r
-\r
     /****************************************/\r
     /* Initialize range coder               */\r
     /****************************************/\r
@@ -180,7 +176,7 @@ TOC(NSQ)
     /* Encode Parameters                    */\r
     /****************************************/\r
 TIC(ENCODE_PARAMS)\r
-    SKP_Silk_encode_parameters( &psEnc->sCmn, &sEncCtrl.sCmn, psRangeEnc );\r
+    SKP_Silk_encode_indices( &psEnc->sCmn, &sEncCtrl.sCmn, psRangeEnc );\r
 TOC(ENCODE_PARAMS)\r
 \r
     /****************************************/\r
@@ -191,26 +187,18 @@ TOC(ENCODE_PARAMS)
         ( psEnc->sCmn.ltp_mem_length + LA_SHAPE_MS * psEnc->sCmn.fs_kHz ) * sizeof( SKP_float ) );\r
     \r
     /* Parameters needed for next frame */\r
-    psEnc->sCmn.prev_sigtype            = sEncCtrl.sCmn.sigtype;\r
+    psEnc->sCmn.prevSignalType          = sEncCtrl.sCmn.signalType;\r
     psEnc->sCmn.prevLag                 = sEncCtrl.sCmn.pitchL[ psEnc->sCmn.nb_subfr - 1 ];\r
     psEnc->sCmn.first_frame_after_reset = 0;\r
-\r
-    if( 0 ) { //psEnc->sCmn.sRC.error ) {\r
-        /* Encoder returned error: Clear payload buffer */\r
-        psEnc->sCmn.nFramesInPayloadBuf = 0;\r
-    } else {\r
-        psEnc->sCmn.nFramesInPayloadBuf++;\r
-    }\r
+    psEnc->sCmn.nFramesInPayloadBuf++;\r
 \r
     /****************************************/\r
     /* Finalize payload and copy to output  */\r
     /****************************************/\r
     if( psEnc->sCmn.nFramesInPayloadBuf * SUB_FRAME_LENGTH_MS * psEnc->sCmn.nb_subfr >= psEnc->sCmn.PacketSize_ms ) {\r
 \r
-        LBRR_idx = ( psEnc->sCmn.oldest_LBRR_idx + 1 ) & LBRR_IDX_MASK;\r
-\r
         /* Check if FEC information should be added */\r
-        //frame_terminator = psEnc->sCmn.LBRR_buffer[ LBRR_idx ].usage;\r
+        //frame_terminator = psEnc->sCmn.LBRR_usage;\r
         frame_terminator = SKP_SILK_NO_LBRR;\r
 \r
         /* Add the frame termination info to stream */\r
@@ -218,56 +206,13 @@ TOC(ENCODE_PARAMS)
 \r
         /* Code excitation signal */\r
         for( i = 0; i < psEnc->sCmn.nFramesInPayloadBuf; i++ ) {\r
-            SKP_Silk_encode_pulses( psRangeEnc, psEnc->sCmn.sigtype[ i ], psEnc->sCmn.QuantOffsetType[ i ], \r
+            SKP_Silk_encode_pulses( psRangeEnc, psEnc->sCmn.signalType[ i ], psEnc->sCmn.quantOffsetType[ i ], \r
                 &psEnc->sCmn.q[ i * psEnc->sCmn.frame_length ], psEnc->sCmn.frame_length );\r
         }\r
 \r
         /* Payload length so far */\r
         nBytes = SKP_RSHIFT( ec_enc_tell( psRangeEnc, 0 ) + 7, 3 );\r
-\r
-        /* Check that there is enough space in external output buffer, and move data */\r
-        if( *pnBytesOut >= nBytes ) {\r
-            //SKP_int bits_in_stream, mask;\r
-            //bits_in_stream = ec_enc_tell( psRangeEnc, 0 );\r
-            //ec_enc_done( psRangeEnc );\r
-            \r
-#if 0\r
-            /* Fill up any remaining bits in the last byte with 1s */\r
-            if( bits_in_stream & 7 ) {\r
-                mask = SKP_RSHIFT( 0xFF, bits_in_stream & 7 );\r
-                if( nBytes - 1 < *pnBytesOut ) {\r
-                    psEnc->sCmn.sRC.range_enc_celt_state.buf->buf[ nBytes - 1 ] |= mask;\r
-                }\r
-            }\r
-            SKP_memcpy( pCode, psEnc->sCmn.sRC.range_enc_celt_state.buf->buf, nBytes * sizeof( SKP_uint8 ) );\r
-#endif\r
-\r
-#if 0\r
-            if( frame_terminator > SKP_SILK_MORE_FRAMES && \r
-                    *pnBytesOut >= nBytes + psEnc->sCmn.LBRR_buffer[ LBRR_idx ].nBytes ) {\r
-                /* Get old packet and add to payload. */\r
-                SKP_memcpy( &pCode[ nBytes ],\r
-                    psEnc->sCmn.LBRR_buffer[ LBRR_idx ].payload,\r
-                    psEnc->sCmn.LBRR_buffer[ LBRR_idx ].nBytes * sizeof( SKP_uint8 ) );\r
-                nBytes += psEnc->sCmn.LBRR_buffer[ LBRR_idx ].nBytes;\r
-            }\r
-#endif\r
-            *pnBytesOut = nBytes;\r
-\r
-            /* Update FEC buffer */\r
-            SKP_memcpy( psEnc->sCmn.LBRR_buffer[ psEnc->sCmn.oldest_LBRR_idx ].payload, LBRRpayload, \r
-                nBytesLBRR * sizeof( SKP_uint8 ) );\r
-            psEnc->sCmn.LBRR_buffer[ psEnc->sCmn.oldest_LBRR_idx ].nBytes = nBytesLBRR;\r
-            /* The line below describes how FEC should be used */\r
-            psEnc->sCmn.LBRR_buffer[ psEnc->sCmn.oldest_LBRR_idx ].usage = sEncCtrl.sCmn.LBRR_usage;\r
-            psEnc->sCmn.oldest_LBRR_idx = ( psEnc->sCmn.oldest_LBRR_idx + 1 ) & LBRR_IDX_MASK;\r
-\r
-        } else {\r
-            /* Not enough space: Payload will be discarded */\r
-            *pnBytesOut = 0;\r
-            nBytes      = 0;\r
-            ret = SKP_SILK_ENC_PAYLOAD_BUF_TOO_SHORT;\r
-        }\r
+        *pnBytesOut = nBytes;\r
 \r
         /* Reset the number of frames in payload buffer */\r
         psEnc->sCmn.nFramesInPayloadBuf = 0;\r
@@ -283,11 +228,6 @@ TOC(ENCODE_PARAMS)
             &psEnc->sCmn.q[ psEnc->sCmn.nFramesInPayloadBuf * psEnc->sCmn.frame_length ] );\r
     }\r
 \r
-    /* Check for arithmetic coder errors */\r
-    if( 0 ) { //psEnc->sCmn.sRC.error ) {\r
-        ret = SKP_SILK_ENC_INTERNAL_ERROR;\r
-    }\r
-\r
     /* Simulate number of ms buffered in channel because of exceeding TargetRate */\r
     psEnc->BufferedInChannel_ms   += ( 8.0f * 1000.0f * ( nBytes - psEnc->sCmn.nBytesInPayloadBuf ) ) / psEnc->sCmn.TargetRate_bps;\r
     psEnc->BufferedInChannel_ms   -= SKP_SMULBB( SUB_FRAME_LENGTH_MS, psEnc->sCmn.nb_subfr );\r
@@ -311,10 +251,10 @@ TOC(ENCODE_FRAME)
     DEBUG_STORE_DATA( gains_indices.dat,        &sEncCtrl.sCmn.GainsIndices,             psEnc->sCmn.nb_subfr * sizeof( SKP_int   ) );\r
     DEBUG_STORE_DATA( nBytes.dat,               &nBytes,                                                        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( 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( input_quality_bands.dat,  sEncCtrl.input_quality_bands,                     VAD_N_BANDS * sizeof( SKP_float ) );\r
-    DEBUG_STORE_DATA( sigtype.dat,              &sEncCtrl.sCmn.sigtype,                                         sizeof( SKP_int   ) ); \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
     DEBUG_STORE_DATA( lag_index.dat,            &sEncCtrl.sCmn.lagIndex,                                        sizeof( SKP_int   ) ); \r
     DEBUG_STORE_DATA( contour_index.dat,        &sEncCtrl.sCmn.contourIndex,                                    sizeof( SKP_int   ) ); \r
@@ -326,8 +266,8 @@ TOC(ENCODE_FRAME)
     return( ret );\r
 }\r
 \r
-#if 0  //tmp\r
-/* Low Bitrate Redundancy (LBRR) encoding. Reuse all parameters but encode with lower bitrate           */\r
+#if 0\r
+/* Low-Bitrate Redundancy (LBRR) encoding. Reuse all parameters but encode with lower bitrate           */\r
 void SKP_Silk_LBRR_encode_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
@@ -346,9 +286,13 @@ void SKP_Silk_LBRR_encode_FLP(
     /*******************************************/\r
     /* Control use of inband LBRR              */\r
     /*******************************************/\r
-    SKP_Silk_LBRR_ctrl_FLP( psEnc, &psEncCtrl->sCmn );\r
-\r
+    psEnc->sCmn.LBRR_usage = SKP_SILK_NO_LBRR;\r
     if( psEnc->sCmn.LBRR_enabled ) {\r
+        /* Control LBRR based on sensitivity and packet loss caracteristics */\r
+        if( psEnc->speech_activity > LBRR_SPEECH_ACTIVITY_THRES && psEnc->sCmn.PacketLoss_perc > LBRR_LOSS_THRES ) {\r
+            psEnc->sCmn.LBRR_usage = SKP_SILK_LBRR;\r
+        }\r
+\r
         /* Save original gains */\r
         SKP_memcpy( TempGainsIndices, psEncCtrl->sCmn.GainsIndices, MAX_NB_SUBFR * sizeof( SKP_int   ) );\r
         SKP_memcpy( TempGains,        psEncCtrl->Gains,             MAX_NB_SUBFR * sizeof( SKP_float ) );\r
@@ -369,7 +313,7 @@ void SKP_Silk_LBRR_encode_FLP(
             SKP_assert( 0 );\r
         }\r
 \r
-        if( psEnc->sCmn.Complexity > 0 && psEnc->sCmn.TargetRate_bps > Rate_only_parameters ) {\r
+        if( psEnc->sCmn.Complexity >= 4 && psEnc->sCmn.TargetRate_bps > Rate_only_parameters ) {\r
             if( psEnc->sCmn.nFramesInPayloadBuf == 0 ) {\r
                 /* First frame in packet copy everything */\r
                 SKP_memcpy( &psEnc->sNSQ_LBRR, &psEnc->sNSQ, sizeof( SKP_Silk_nsq_state ) );\r
@@ -409,7 +353,7 @@ void SKP_Silk_LBRR_encode_FLP(
         /****************************************/\r
         /* Encode Parameters                    */\r
         /****************************************/\r
-        SKP_Silk_encode_parameters( &psEnc->sCmn, &psEncCtrl->sCmn, &psEnc->sCmn.sRC_LBRR );\r
+        SKP_Silk_encode_indices( &psEnc->sCmn, &psEncCtrl->sCmn, &psEnc->sCmn.sRC_LBRR );\r
 \r
         if( psEnc->sCmn.sRC_LBRR.error ) {\r
             /* Encoder returned error: Clear payload buffer */\r
@@ -434,7 +378,7 @@ void SKP_Silk_LBRR_encode_FLP(
             /* Encode quantization indices of excitation */\r
             /*********************************************/\r
             for( i = 0; i < nFramesInPayloadBuf; i++ ) {\r
-                SKP_Silk_encode_pulses( &psEnc->sCmn.sRC_LBRR, psEnc->sCmn.sigtype[ i ], psEnc->sCmn.QuantOffsetType[ i ],\r
+                SKP_Silk_encode_pulses( &psEnc->sCmn.sRC_LBRR, psEnc->sCmn.signalType[ i ], psEnc->sCmn.quantOffsetType[ i ],\r
                     &psEnc->sCmn.q_LBRR[ i * psEnc->sCmn.frame_length ], psEnc->sCmn.frame_length );\r
             }\r
 \r
index 46856b7..5ab8ef6 100644 (file)
@@ -101,17 +101,24 @@ void SKP_Silk_find_pitch_lags_FLP(
     SKP_Silk_LPC_analysis_filter_FLP( res, A, x_buf, buf_len, psEnc->sCmn.pitchEstimationLPCOrder );\r
     SKP_memset( res, 0, psEnc->sCmn.pitchEstimationLPCOrder * sizeof( SKP_float ) );\r
 \r
-    /* Threshold for pitch estimator */\r
-    thrhld  = 0.45f;\r
-    thrhld -= 0.004f * psEnc->sCmn.pitchEstimationLPCOrder;\r
-    thrhld -= 0.1f   * psEnc->speech_activity;\r
-    thrhld += 0.15f  * psEnc->sCmn.prev_sigtype;\r
-    thrhld -= 0.1f   * psEncCtrl->input_tilt;\r
-\r
-    /*****************************************/\r
-    /* Call Pitch estimator                  */\r
-    /*****************************************/\r
-    psEncCtrl->sCmn.sigtype = SKP_Silk_pitch_analysis_core_FLP( res, psEncCtrl->sCmn.pitchL, &psEncCtrl->sCmn.lagIndex, \r
-        &psEncCtrl->sCmn.contourIndex, &psEnc->LTPCorr, psEnc->sCmn.prevLag, psEnc->sCmn.pitchEstimationThreshold_Q16 / 65536.0f,\r
-        thrhld, psEnc->sCmn.fs_kHz, psEnc->sCmn.pitchEstimationComplexity, psEnc->sCmn.nb_subfr );\r
+    if( psEncCtrl->sCmn.signalType != TYPE_NO_VOICE_ACTIVITY ) {\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.15f  * (psEnc->sCmn.prevSignalType >> 1);\r
+        thrhld -= 0.1f   * psEncCtrl->input_tilt;\r
+\r
+        /*****************************************/\r
+        /* Call Pitch estimator                  */\r
+        /*****************************************/\r
+        if( SKP_Silk_pitch_analysis_core_FLP( res, psEncCtrl->sCmn.pitchL, &psEncCtrl->sCmn.lagIndex, \r
+            &psEncCtrl->sCmn.contourIndex, &psEnc->LTPCorr, psEnc->sCmn.prevLag, psEnc->sCmn.pitchEstimationThreshold_Q16 / 65536.0f,\r
+            thrhld, psEnc->sCmn.fs_kHz, psEnc->sCmn.pitchEstimationComplexity, psEnc->sCmn.nb_subfr ) == 0 ) \r
+        {\r
+            psEncCtrl->sCmn.signalType = TYPE_VOICED;\r
+        } else {\r
+            psEncCtrl->sCmn.signalType = TYPE_UNVOICED;\r
+        }\r
+    }\r
 }\r
index 1efd8dc..c408e81 100644 (file)
@@ -50,7 +50,7 @@ void SKP_Silk_find_pred_coefs_FLP(
         Wght[ i ]     = invGains[ i ] * invGains[ i ];\r
     }\r
 \r
-    if( psEncCtrl->sCmn.sigtype == SIG_TYPE_VOICED ) {\r
+    if( psEncCtrl->sCmn.signalType == TYPE_VOICED ) {\r
         /**********/\r
         /* VOICED */\r
         /**********/\r
@@ -68,7 +68,7 @@ void SKP_Silk_find_pred_coefs_FLP(
 \r
         /* Quantize LTP gain parameters */\r
         SKP_Silk_quant_LTP_gains_FLP( psEncCtrl->LTPCoef, psEncCtrl->sCmn.LTPIndex, &psEncCtrl->sCmn.PERIndex, \r
-            WLTP, psEnc->sCmn.mu_LTP_Q10, psEnc->sCmn.LTPQuantLowComplexity , psEnc->sCmn.nb_subfr );\r
+            WLTP, psEnc->sCmn.mu_LTP_Q9, psEnc->sCmn.LTPQuantLowComplexity , psEnc->sCmn.nb_subfr );\r
 \r
         /* Control LTP scaling */\r
         SKP_Silk_LTP_scale_ctrl_FLP( psEnc, psEncCtrl );\r
index 8b18c1f..d91af20 100644 (file)
@@ -85,7 +85,7 @@ SKP_int SKP_Silk_control_encoder_FLP(
     const SKP_int               PacketSize_ms,          /* I    Packet length (ms)                      */\r
     const SKP_int32             TargetRate_bps,         /* I    Target max bitrate (bps)                */\r
     const SKP_int               PacketLoss_perc,        /* I    Packet loss rate (in percent)           */\r
-    const SKP_int               Complexity              /* I    Complexity (0->low; 1->medium; 2->high) */\r
+    const SKP_int               Complexity              /* I    Complexity (0-10)                       */\r
 );\r
 \r
 /****************/\r
@@ -118,12 +118,6 @@ void SKP_Silk_warped_autocorrelation_FLP(
     const SKP_int                   order               /* I    Correlation order (even)                */\r
 );\r
 \r
-/* Control low bitrate redundancy usage */\r
-void SKP_Silk_LBRR_ctrl_FLP(\r
-    SKP_Silk_encoder_state_FLP      *psEnc,             /* I    Encoder state FLP                       */\r
-    SKP_Silk_encoder_control        *psEncCtrlC         /* I/O  Encoder control                         */\r
-);\r
-\r
 /* Calculation of LTP state scaling */\r
 void SKP_Silk_LTP_scale_ctrl_FLP(\r
     SKP_Silk_encoder_state_FLP      *psEnc,             /* I/O  Encoder state FLP                       */\r
@@ -206,46 +200,6 @@ void SKP_Silk_LPC_analysis_filter_FLP(
     const SKP_int                   Order               /* I    LPC order                               */\r
 );\r
 \r
-/* 16th order LPC analysis filter, does not write first 16 samples */\r
-void SKP_Silk_LPC_analysis_filter16_FLP(\r
-          SKP_float                 r_LPC[],            /* O    LPC residual signal                     */\r
-    const SKP_float                 PredCoef[],         /* I    LPC coefficients                        */\r
-    const SKP_float                 s[],                /* I    Input signal                            */\r
-    const SKP_int                   length              /* I    Length of input signal                  */\r
-);\r
-\r
-/* 12th order LPC analysis filter, does not write first 12 samples */\r
-void SKP_Silk_LPC_analysis_filter12_FLP(\r
-          SKP_float                 r_LPC[],            /* O    LPC residual signal                     */\r
-    const SKP_float                 PredCoef[],         /* I    LPC coefficients                        */\r
-    const SKP_float                 s[],                /* I    Input signal                            */\r
-    const SKP_int                   length              /* I    Length of input signal                  */\r
-);\r
-\r
-/* 10th order LPC analysis filter, does not write first 10 samples */\r
-void SKP_Silk_LPC_analysis_filter10_FLP(\r
-          SKP_float                 r_LPC[],            /* O    LPC residual signal                     */\r
-    const SKP_float                 PredCoef[],         /* I    LPC coefficients                        */\r
-    const SKP_float                 s[],                /* I    Input signal                            */\r
-    const SKP_int                   length              /* I    Length of input signal                  */\r
-);\r
-\r
-/* 8th order LPC analysis filter, does not write first 8 samples */\r
-void SKP_Silk_LPC_analysis_filter8_FLP(\r
-          SKP_float                 r_LPC[],            /* O    LPC residual signal                     */\r
-    const SKP_float                 PredCoef[],         /* I    LPC coefficients                        */\r
-    const SKP_float                 s[],                /* I    Input signal                            */\r
-    const SKP_int                   length              /* I    Length of input signal                  */\r
-);\r
-\r
-/* 6th order LPC analysis filter, does not write first 6 samples */\r
-void SKP_Silk_LPC_analysis_filter6_FLP(\r
-          SKP_float                 r_LPC[],            /* O    LPC residual signal                     */\r
-    const SKP_float                 PredCoef[],         /* I    LPC coefficients                        */\r
-    const SKP_float                 s[],                /* I    Input signal                            */\r
-    const SKP_int                   length              /* I    Length of input signal                  */\r
-);\r
-\r
 /* LTP tap quantizer */\r
 void SKP_Silk_quant_LTP_gains_FLP(\r
           SKP_float B[ MAX_NB_SUBFR * LTP_ORDER ],              /* I/O  (Un-)quantized LTP gains                */\r
index 6cca1f4..ced1f0d 100644 (file)
@@ -170,7 +170,7 @@ void SKP_Silk_noise_shape_analysis_FLP(
         SNR_adj_dB -= BG_SNR_DECR_dB * psEncCtrl->coding_quality * ( 0.5f + 0.5f * psEncCtrl->input_quality ) * b * b;\r
     }\r
 \r
-    if( psEncCtrl->sCmn.sigtype == SIG_TYPE_VOICED ) {\r
+    if( psEncCtrl->sCmn.signalType == TYPE_VOICED ) {\r
         /* Reduce gains for periodic signals */\r
         SNR_adj_dB += HARM_SNR_INCR_dB * psEnc->LTPCorr;\r
     } else { \r
@@ -182,9 +182,9 @@ void SKP_Silk_noise_shape_analysis_FLP(
     /* SPARSENESS PROCESSING */\r
     /*************************/\r
     /* Set quantizer offset */\r
-    if( psEncCtrl->sCmn.sigtype == SIG_TYPE_VOICED ) {\r
+    if( psEncCtrl->sCmn.signalType == TYPE_VOICED ) {\r
         /* Initally set to 0; may be overruled in process_gains(..) */\r
-        psEncCtrl->sCmn.QuantOffsetType = 0;\r
+        psEncCtrl->sCmn.quantOffsetType = 0;\r
         psEncCtrl->sparseness = 0.0f;\r
     } else {\r
         /* Sparseness measure, based on relative fluctuations of energy per 2 milliseconds */\r
@@ -205,9 +205,9 @@ void SKP_Silk_noise_shape_analysis_FLP(
 \r
         /* Set quantization offset depending on sparseness measure */\r
         if( psEncCtrl->sparseness > SPARSENESS_THRESHOLD_QNT_OFFSET ) {\r
-            psEncCtrl->sCmn.QuantOffsetType = 0;\r
+            psEncCtrl->sCmn.quantOffsetType = 0;\r
         } else {\r
-            psEncCtrl->sCmn.QuantOffsetType = 1;\r
+            psEncCtrl->sCmn.quantOffsetType = 1;\r
         }\r
         \r
         /* Increase coding SNR for sparse signals */\r
@@ -316,7 +316,7 @@ void SKP_Silk_noise_shape_analysis_FLP(
     /* 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
-    if( psEncCtrl->sCmn.sigtype == SIG_TYPE_VOICED ) {\r
+    if( psEncCtrl->sCmn.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
         for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) {\r
@@ -346,7 +346,7 @@ void SKP_Silk_noise_shape_analysis_FLP(
     /* More harmonic boost for noisy input signals */\r
     HarmBoost += LOW_INPUT_QUALITY_HARMONIC_BOOST * ( 1.0f - psEncCtrl->input_quality );\r
 \r
-    if( USE_HARM_SHAPING && psEncCtrl->sCmn.sigtype == SIG_TYPE_VOICED ) {\r
+    if( USE_HARM_SHAPING && psEncCtrl->sCmn.signalType == TYPE_VOICED ) {\r
         /* Harmonic noise shaping */\r
         HarmShapeGain = HARMONIC_SHAPING;\r
 \r
index 80ec457..d8b0f66 100644 (file)
@@ -110,7 +110,7 @@ void SKP_Silk_prefilter_FLP(
     lag = P->lagPrev;\r
     for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) {\r
         /* Update Variables that change per sub frame */\r
-        if( psEncCtrl->sCmn.sigtype == SIG_TYPE_VOICED ) {\r
+        if( psEncCtrl->sCmn.signalType == TYPE_VOICED ) {\r
             lag = psEncCtrl->sCmn.pitchL[ k ];\r
         }\r
 \r
index 6989955..e21ac88 100644 (file)
@@ -45,12 +45,10 @@ void SKP_Silk_process_NLSFs_FLP(
     SKP_float   pNLSFW0_temp[ MAX_LPC_ORDER ];\r
     SKP_int     i;\r
 \r
-    SKP_assert( psEncCtrl->sCmn.sigtype == SIG_TYPE_VOICED || psEncCtrl->sCmn.sigtype == SIG_TYPE_UNVOICED );\r
-\r
     /***********************/\r
     /* Calculate mu values */\r
     /***********************/\r
-    if( psEncCtrl->sCmn.sigtype == SIG_TYPE_VOICED ) {\r
+    if( psEncCtrl->sCmn.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
@@ -81,7 +79,7 @@ void SKP_Silk_process_NLSFs_FLP(
     }\r
 \r
     /* Set pointer to the NLSF codebook for the current signal type and LPC order */\r
-    psNLSF_CB = psEnc->sCmn.psNLSF_CB[ psEncCtrl->sCmn.sigtype ];\r
+    psNLSF_CB = psEnc->sCmn.psNLSF_CB[ 1 - (psEncCtrl->sCmn.signalType >> 1) ];\r
 \r
     /* Quantize NLSF parameters given the trained NLSF codebooks */\r
     SKP_Silk_NLSF_MSVQ_encode_FLP( psEncCtrl->sCmn.NLSFIndices, pNLSF, psNLSF_CB, psEnc->sPred.prev_NLSFq, pNLSFW, NLSF_mu, \r
index 5b2852d..e49e9ba 100644 (file)
@@ -40,7 +40,7 @@ void SKP_Silk_process_gains_FLP(
     SKP_float   s, InvMaxSqrVal, gain, quant_offset;\r
 \r
     /* Gain reduction when LTP coding gain is high */\r
-    if( psEncCtrl->sCmn.sigtype == SIG_TYPE_VOICED ) {\r
+    if( psEncCtrl->sCmn.signalType == TYPE_VOICED ) {\r
         s = 1.0f - 0.5f * SKP_sigmoid( 0.25f * ( psEncCtrl->LTPredCodGain - 12.0f ) );\r
         for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) {\r
             psEncCtrl->Gains[ k ] *= s;\r
@@ -72,16 +72,16 @@ void SKP_Silk_process_gains_FLP(
     }\r
 \r
     /* Set quantizer offset for voiced signals. Larger offset when LTP coding gain is low or tilt is high (ie low-pass) */\r
-    if( psEncCtrl->sCmn.sigtype == SIG_TYPE_VOICED ) {\r
+    if( psEncCtrl->sCmn.signalType == TYPE_VOICED ) {\r
         if( psEncCtrl->LTPredCodGain + psEncCtrl->input_tilt > 1.0f ) {\r
-            psEncCtrl->sCmn.QuantOffsetType = 0;\r
+            psEncCtrl->sCmn.quantOffsetType = 0;\r
         } else {\r
-            psEncCtrl->sCmn.QuantOffsetType = 1;\r
+            psEncCtrl->sCmn.quantOffsetType = 1;\r
         }\r
     }\r
 \r
     /* Quantizer boundary adjustment */\r
-    quant_offset = SKP_Silk_Quantization_Offsets_Q10[ psEncCtrl->sCmn.sigtype ][ psEncCtrl->sCmn.QuantOffsetType ] / 1024.0f;\r
+    quant_offset = SKP_Silk_Quantization_Offsets_Q10[ psEncCtrl->sCmn.signalType >> 1 ][ psEncCtrl->sCmn.quantOffsetType ] / 1024.0f;\r
     psEncCtrl->Lambda = LAMBDA_OFFSET \r
                       + LAMBDA_DELAYED_DECISIONS * psEnc->sCmn.nStatesDelayedDecision\r
                       + LAMBDA_SPEECH_ACT        * psEnc->speech_activity \r
index 6a8ae0e..c87c20b 100644 (file)
@@ -211,7 +211,7 @@ void SKP_Silk_NSQ_wrapper_FLP(
         }\r
     }\r
 \r
-    if( psEncCtrl->sCmn.sigtype == SIG_TYPE_VOICED ) {\r
+    if( psEncCtrl->sCmn.signalType == TYPE_VOICED ) {\r
         LTP_scale_Q14 = SKP_Silk_LTPScales_table_Q14[ psEncCtrl->sCmn.LTP_scaleIndex ];\r
     } else {\r
         LTP_scale_Q14 = 0;\r
diff --git a/src_common/SKP_Silk_LBRR_reset.c b/src_common/SKP_Silk_LBRR_reset.c
deleted file mode 100644 (file)
index 22e6830..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/***********************************************************************\r
-Copyright (c) 2006-2010, 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
-/* Resets LBRR buffer, used if packet size changes */\r
-void SKP_Silk_LBRR_reset( \r
-    SKP_Silk_encoder_state      *psEncC             /* I/O  state                                       */\r
-)\r
-{\r
-    SKP_int i;\r
-\r
-    for( i = 0; i < MAX_LBRR_DELAY; i++ ) {\r
-        psEncC->LBRR_buffer[ i ].usage = SKP_SILK_NO_LBRR;\r
-    }\r
-}\r
index 4235687..7cde053 100644 (file)
@@ -43,7 +43,7 @@ SKP_INLINE void SKP_Silk_nsq_scale_states(
 \r
 SKP_INLINE void SKP_Silk_noise_shape_quantizer(\r
     SKP_Silk_nsq_state  *NSQ,               /* I/O  NSQ state                       */\r
-    SKP_int             sigtype,            /* I    Signal type                     */\r
+    SKP_int             signalType,         /* I    Signal type                     */\r
     const SKP_int32     x_sc_Q10[],         /* I                                    */\r
     SKP_int8            q[],                /* O                                    */\r
     SKP_int16           xq[],               /* O                                    */\r
@@ -118,7 +118,7 @@ void SKP_Silk_NSQ(
 \r
     SKP_assert( NSQ->prev_inv_gain_Q16 != 0 );\r
 \r
-    offset_Q10 = SKP_Silk_Quantization_Offsets_Q10[ psEncCtrlC->sigtype ][ psEncCtrlC->QuantOffsetType ];\r
+    offset_Q10 = SKP_Silk_Quantization_Offsets_Q10[ psEncCtrlC->signalType >> 1 ][ psEncCtrlC->quantOffsetType ];\r
 \r
     if( LSFInterpFactor_Q2 == ( 1 << 2 ) ) {\r
         LSF_interpolation_flag = 0;\r
@@ -141,7 +141,7 @@ void SKP_Silk_NSQ(
         HarmShapeFIRPacked_Q14 |= SKP_LSHIFT( ( SKP_int32 )SKP_RSHIFT( HarmShapeGain_Q14[ k ], 1 ), 16 );\r
 \r
         NSQ->rewhite_flag = 0;\r
-        if( psEncCtrlC->sigtype == SIG_TYPE_VOICED ) {\r
+        if( psEncCtrlC->signalType == TYPE_VOICED ) {\r
             /* Voiced */\r
             lag = psEncCtrlC->pitchL[ k ];\r
 \r
@@ -164,7 +164,7 @@ void SKP_Silk_NSQ(
         SKP_Silk_nsq_scale_states( psEncC, NSQ, x, x_sc_Q10, psEncC->subfr_length, sLTP, \r
             sLTP_Q16, k, LTP_scale_Q14, Gains_Q16, psEncCtrlC->pitchL );\r
 \r
-        SKP_Silk_noise_shape_quantizer( NSQ, psEncCtrlC->sigtype, x_sc_Q10, q, pxq, sLTP_Q16, A_Q12, B_Q14, \r
+        SKP_Silk_noise_shape_quantizer( NSQ, psEncCtrlC->signalType, x_sc_Q10, q, pxq, sLTP_Q16, A_Q12, B_Q14, \r
             AR_shp_Q13, lag, HarmShapeFIRPacked_Q14, Tilt_Q14[ k ], LF_shp_Q14[ k ], Gains_Q16[ k ], Lambda_Q10, \r
             offset_Q10, psEncC->subfr_length, psEncC->shapingLPCOrder, psEncC->predictLPCOrder\r
 #ifdef SAVE_ALL_INTERNAL_DATA\r
@@ -204,7 +204,7 @@ void SKP_Silk_NSQ(
 /***********************************/\r
 SKP_INLINE void SKP_Silk_noise_shape_quantizer(\r
     SKP_Silk_nsq_state  *NSQ,               /* I/O  NSQ state                       */\r
-    SKP_int             sigtype,            /* I    Signal type                     */\r
+    SKP_int             signalType,         /* I    Signal type                     */\r
     const SKP_int32     x_sc_Q10[],         /* I                                    */\r
     SKP_int8            q[],                /* O                                    */\r
     SKP_int16           xq[],               /* O                                    */\r
@@ -278,7 +278,7 @@ SKP_INLINE void SKP_Silk_noise_shape_quantizer(
         }\r
 \r
         /* Long-term prediction */\r
-        if( sigtype == SIG_TYPE_VOICED ) {\r
+        if( signalType == TYPE_VOICED ) {\r
             /* Unrolled loop */\r
             LTP_pred_Q14 = SKP_SMULWB(               pred_lag_ptr[  0 ], b_Q14[ 0 ] );\r
             LTP_pred_Q14 = SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -1 ], b_Q14[ 1 ] );\r
@@ -313,7 +313,7 @@ SKP_INLINE void SKP_Silk_noise_shape_quantizer(
         n_LF_Q10 = SKP_LSHIFT( SKP_SMULWB( NSQ->sLTP_shp_Q10[ NSQ->sLTP_shp_buf_idx - 1 ], LF_shp_Q14 ), 2 ); \r
         n_LF_Q10 = SKP_SMLAWT( n_LF_Q10, NSQ->sLF_AR_shp_Q12, LF_shp_Q14 );\r
 \r
-        SKP_assert( lag > 0 || sigtype == SIG_TYPE_UNVOICED );\r
+        SKP_assert( lag > 0 || signalType != TYPE_VOICED );\r
 \r
         /* Long-term shaping */\r
         if( lag > 0 ) {\r
index 4113c20..7b19730 100644 (file)
@@ -80,7 +80,7 @@ SKP_INLINE void SKP_Silk_nsq_del_dec_scale_states(
 SKP_INLINE void SKP_Silk_noise_shape_quantizer_del_dec(\r
     SKP_Silk_nsq_state  *NSQ,                   /* I/O  NSQ state                           */\r
     NSQ_del_dec_struct  psDelDec[],             /* I/O  Delayed decision states             */\r
-    SKP_int             sigtype,                /* I    Signal type                         */\r
+    SKP_int             signalType,             /* I    Signal type                         */\r
     const SKP_int32     x_Q10[],                /* I                                        */\r
     SKP_int8            q[],                    /* O                                        */\r
     SKP_int16           xq[],                   /* O                                        */\r
@@ -156,13 +156,13 @@ void SKP_Silk_NSQ_del_dec(
         SKP_memcpy( psDD->sAR2_Q14, NSQ->sAR2_Q14, sizeof( NSQ->sAR2_Q14 ) );\r
     }\r
 \r
-    offset_Q10   = SKP_Silk_Quantization_Offsets_Q10[ psEncCtrlC->sigtype ][ psEncCtrlC->QuantOffsetType ];\r
+    offset_Q10   = SKP_Silk_Quantization_Offsets_Q10[ psEncCtrlC->signalType >> 1 ][ psEncCtrlC->quantOffsetType ];\r
     smpl_buf_idx = 0; /* index of oldest samples */\r
 \r
     decisionDelay = SKP_min_int( DECISION_DELAY, subfr_length );\r
 \r
     /* For voiced frames limit the decision delay to lower than the pitch lag */\r
-    if( psEncCtrlC->sigtype == SIG_TYPE_VOICED ) {\r
+    if( psEncCtrlC->signalType == TYPE_VOICED ) {\r
         for( k = 0; k < psEncC->nb_subfr; k++ ) {\r
             decisionDelay = SKP_min_int( decisionDelay, psEncCtrlC->pitchL[ k ] - LTP_ORDER / 2 - 1 );\r
         }\r
@@ -194,7 +194,7 @@ void SKP_Silk_NSQ_del_dec(
         HarmShapeFIRPacked_Q14 |= SKP_LSHIFT( ( SKP_int32 )SKP_RSHIFT( HarmShapeGain_Q14[ k ], 1 ), 16 );\r
 \r
         NSQ->rewhite_flag = 0;\r
-        if( psEncCtrlC->sigtype == SIG_TYPE_VOICED ) {\r
+        if( psEncCtrlC->signalType == TYPE_VOICED ) {\r
             /* Voiced */\r
             lag = psEncCtrlC->pitchL[ k ];\r
 \r
@@ -250,7 +250,7 @@ void SKP_Silk_NSQ_del_dec(
             subfr_length, sLTP, sLTP_Q16, k, psEncC->nStatesDelayedDecision, smpl_buf_idx,\r
             LTP_scale_Q14, Gains_Q16, psEncCtrlC->pitchL );\r
 \r
-        SKP_Silk_noise_shape_quantizer_del_dec( NSQ, psDelDec, psEncCtrlC->sigtype, x_sc_Q10, q, pxq, sLTP_Q16,\r
+        SKP_Silk_noise_shape_quantizer_del_dec( NSQ, psDelDec, psEncCtrlC->signalType, x_sc_Q10, q, pxq, sLTP_Q16,\r
             A_Q12, B_Q14, AR_shp_Q13, lag, HarmShapeFIRPacked_Q14, Tilt_Q14[ k ], LF_shp_Q14[ k ], Gains_Q16[ k ], \r
             Lambda_Q10, offset_Q10, psEncC->subfr_length, subfr++, psEncC->shapingLPCOrder, psEncC->predictLPCOrder, \r
             psEncC->warping_Q16, psEncC->nStatesDelayedDecision, &smpl_buf_idx, decisionDelay );\r
@@ -296,6 +296,7 @@ void SKP_Silk_NSQ_del_dec(
 #ifdef SAVE_ALL_INTERNAL_DATA\r
     DEBUG_STORE_DATA( sLTP_Q16.dat, &sLTP_Q16[ psEncC->frame_length ], psEncC->frame_length * sizeof( SKP_int32 ) );\r
     DEBUG_STORE_DATA( xq.dat,       NSQ->xq,                           psEncC->frame_length * sizeof( SKP_int16 ) );\r
+    DEBUG_STORE_DATA( q.dat,        &q[ -psEncC->frame_length ],       psEncC->frame_length * sizeof( SKP_int8 ) );\r
 #endif\r
 }\r
 \r
@@ -305,7 +306,7 @@ void SKP_Silk_NSQ_del_dec(
 SKP_INLINE void SKP_Silk_noise_shape_quantizer_del_dec(\r
     SKP_Silk_nsq_state  *NSQ,                   /* I/O  NSQ state                           */\r
     NSQ_del_dec_struct  psDelDec[],             /* I/O  Delayed decision states             */\r
-    SKP_int             sigtype,                /* I    Signal type                         */\r
+    SKP_int             signalType,             /* I    Signal type                         */\r
     const SKP_int32     x_Q10[],                /* I                                        */\r
     SKP_int8            q[],                    /* O                                        */\r
     SKP_int16           xq[],                   /* O                                        */\r
@@ -348,7 +349,7 @@ SKP_INLINE void SKP_Silk_noise_shape_quantizer_del_dec(
         /* Perform common calculations used in all states */\r
 \r
         /* Long-term prediction */\r
-        if( sigtype == SIG_TYPE_VOICED ) {\r
+        if( signalType == TYPE_VOICED ) {\r
             /* Unrolled loop */\r
             LTP_pred_Q14 = SKP_SMULWB(               pred_lag_ptr[  0 ], b_Q14[ 0 ] );\r
             LTP_pred_Q14 = SKP_SMLAWB( LTP_pred_Q14, pred_lag_ptr[ -1 ], b_Q14[ 1 ] );\r
index 5807ef5..a9f7a8d 100644 (file)
@@ -86,9 +86,9 @@ void SKP_Silk_PLC_update(
     psPLC = &psDec->sPLC;\r
 \r
     /* Update parameters used in case of packet loss */\r
-    psDec->prev_sigtype = psDecCtrl->sigtype;\r
+    psDec->prevSignalType = psDecCtrl->signalType;\r
     LTP_Gain_Q14 = 0;\r
-    if( psDecCtrl->sigtype == SIG_TYPE_VOICED ) {\r
+    if( psDecCtrl->signalType == TYPE_VOICED ) {\r
         /* Find the parameters for the last subframe which contains a pitch pulse */\r
         for( j = 0; j * psDec->subfr_length < psDecCtrl->pitchL[ psDec->nb_subfr - 1 ]; j++ ) {\r
             if( j == psDec->nb_subfr ){\r
@@ -197,7 +197,7 @@ void SKP_Silk_PLC_conceal(
 \r
     /* Setup attenuation gains */\r
     harm_Gain_Q15 = HARM_ATT_Q15[ SKP_min_int( NB_ATT - 1, psDec->lossCnt ) ];\r
-    if( psDec->prev_sigtype == SIG_TYPE_VOICED ) {\r
+    if( psDec->prevSignalType == TYPE_VOICED ) {\r
         rand_Gain_Q15 = PLC_RAND_ATTENUATE_V_Q15[  SKP_min_int( NB_ATT - 1, psDec->lossCnt ) ];\r
     } else {\r
         rand_Gain_Q15 = PLC_RAND_ATTENUATE_UV_Q15[ SKP_min_int( NB_ATT - 1, psDec->lossCnt ) ];\r
@@ -208,16 +208,14 @@ void SKP_Silk_PLC_conceal(
         rand_scale_Q14 = (1 << 14 );\r
     \r
         /* Reduce random noise Gain for voiced frames */\r
-        if( psDec->prev_sigtype == SIG_TYPE_VOICED ) {\r
+        if( psDec->prevSignalType == TYPE_VOICED ) {\r
             for( i = 0; i < LTP_ORDER; i++ ) {\r
                 rand_scale_Q14 -= B_Q14[ i ];\r
             }\r
             rand_scale_Q14 = SKP_max_16( 3277, rand_scale_Q14 ); /* 0.2 */\r
             rand_scale_Q14 = ( SKP_int16 )SKP_RSHIFT( SKP_SMULBB( rand_scale_Q14, psPLC->prevLTP_scale_Q14 ), 14 );\r
-        }\r
-\r
-        /* Reduce random noise for unvoiced frames with high LPC gain */\r
-        if( psDec->prev_sigtype == SIG_TYPE_UNVOICED ) {\r
+        } else {\r
+            /* Reduce random noise for unvoiced frames with high LPC gain */\r
             SKP_int32 invGain_Q30, down_scale_Q30;\r
             \r
             SKP_Silk_LPC_inverse_pred_gain( &invGain_Q30, psPLC->prevLPC_Q12, psDec->LPC_order );\r
@@ -382,6 +380,5 @@ void SKP_Silk_PLC_glue_frames(
             }\r
         }\r
         psPLC->last_frame_lost = 0;\r
-\r
     }\r
 }\r
index 1b3ceb4..4d7ba85 100644 (file)
@@ -34,8 +34,8 @@ void SKP_Silk_VQ_WMat_EC(
     const SKP_int16                 *in_Q14,            /* I    input vector to be quantized                */\r
     const SKP_int32                 *W_Q18,             /* I    weighting matrix                            */\r
     const SKP_int8                  *cb_Q7,             /* I    codebook                                    */\r
-    const SKP_int8                  *cl_Q4,             /* I    code length for each codebook vector        */\r
-    const SKP_int                   mu_Q10,             /* I    tradeoff between weighted error and rate    */\r
+    const SKP_uint8                 *cl_Q5,             /* I    code length for each codebook vector        */\r
+    const SKP_int                   mu_Q9,              /* I    tradeoff between weighted error and rate    */\r
     SKP_int                         L                   /* I    number of vectors in codebook               */\r
 )\r
 {\r
@@ -55,7 +55,7 @@ void SKP_Silk_VQ_WMat_EC(
         diff_Q14[ 4 ] = in_Q14[ 4 ] - SKP_LSHIFT( cb_row_Q7[ 4 ], 7 );\r
 \r
         /* Weighted rate */\r
-        sum1_Q14 = SKP_SMULBB( mu_Q10, cl_Q4[ k ] );\r
+        sum1_Q14 = SKP_SMULBB( mu_Q9, cl_Q5[ k ] );\r
 \r
         SKP_assert( sum1_Q14 >= 0 );\r
 \r
index 2bb8231..44c7423 100644 (file)
@@ -35,53 +35,72 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 \r
 /* Encodes signs of excitation */\r
 void SKP_Silk_encode_signs(\r
-    ec_enc                      *psRangeEnc,        /* I/O  Compressor data structure                   */\r
-    const SKP_int8              q[],                /* I    Pulse signal                                */\r
-    const SKP_int               length,             /* I    Length of input                             */\r
-    const SKP_int               sigtype,            /* I    Signal type                                 */\r
-    const SKP_int               QuantOffsetType,    /* I    Quantization offset type                    */\r
-    const SKP_int               RateLevelIndex      /* I    Rate level index                            */\r
+    ec_enc                      *psRangeEnc,                        /* I/O  Compressor data structure                   */\r
+    const SKP_int8              q[],                                /* I    pulse signal                                */\r
+    SKP_int                     length,                             /* I    length of input                             */\r
+    const SKP_int               signalType,                         /* I    Signal type                                 */\r
+    const SKP_int               quantOffsetType,                    /* I    Quantization offset type                    */\r
+    const SKP_int               sum_pulses[ MAX_NB_SHELL_BLOCKS ]   /* I    Sum of absolute pulses per block            */\r
 )\r
 {\r
-    SKP_int   i, inData;\r
-    SKP_uint8 icdf[ 2 ];\r
+    SKP_int         i, j, p, inData;\r
+    SKP_uint8       icdf[ 2 ];\r
+    const SKP_int8  *q_ptr;\r
+    const SKP_uint8 *icdf_ptr;\r
 \r
-    i = SKP_SMULBB( N_RATE_LEVELS - 1, SKP_LSHIFT( sigtype, 1 ) + QuantOffsetType ) + RateLevelIndex;\r
-    icdf[ 0 ] = SKP_Silk_sign_iCDF[ i ];\r
     icdf[ 1 ] = 0;\r
-    \r
+    q_ptr = q;\r
+    i = SKP_SMULBB( 6, SKP_ADD_LSHIFT( quantOffsetType, signalType, 1 ) );\r
+    icdf_ptr = &SKP_Silk_sign_iCDF[ i ];\r
+    length = SKP_RSHIFT( length, LOG2_SHELL_CODEC_FRAME_LENGTH );\r
     for( i = 0; i < length; i++ ) {\r
-        if( q[ i ] != 0 ) {\r
-            inData = SKP_enc_map( q[ i ] ); /* - = 0, + = 1 */\r
-            ec_enc_icdf( psRangeEnc, inData, icdf, 8 );\r
+        p = sum_pulses[ i ];\r
+        if( p > 0 ) {\r
+            icdf[ 0 ] = icdf_ptr[ SKP_min( p - 1, 5 ) ];\r
+            for( j = 0; j < SHELL_CODEC_FRAME_LENGTH; j++ ) {\r
+                if( q_ptr[ j ] != 0 ) {\r
+                    inData = SKP_enc_map( q_ptr[ j ]); /* - = 0, + = 1 */\r
+                    ec_enc_icdf( psRangeEnc, inData, icdf, 8 );\r
+                }\r
+            }\r
         }\r
+        q_ptr += SHELL_CODEC_FRAME_LENGTH;\r
     }\r
 }\r
 \r
 /* Decodes signs of excitation */\r
 void SKP_Silk_decode_signs(\r
-    ec_dec                          *psRangeDec,        /* I/O  Compressor data structure                   */\r
-    SKP_int                         q[],                /* I/O  pulse signal                                */\r
-    const SKP_int                   length,             /* I    length of output                            */\r
-    const SKP_int                   sigtype,            /* I    Signal type                                 */\r
-    const SKP_int                   QuantOffsetType,    /* I    Quantization offset type                    */\r
-    const SKP_int                   RateLevelIndex      /* I    Rate Level Index                            */\r
+    ec_dec                      *psRangeDec,                        /* I/O  Compressor data structure                   */\r
+    SKP_int                     q[],                                /* I/O  pulse signal                                */\r
+    SKP_int                     length,                             /* I    length of input                             */\r
+    const SKP_int               signalType,                         /* I    Signal type                                 */\r
+    const SKP_int               quantOffsetType,                    /* I    Quantization offset type                    */\r
+    const SKP_int               sum_pulses[ MAX_NB_SHELL_BLOCKS ]   /* I    Sum of absolute pulses per block            */\r
 )\r
 {\r
-    SKP_int   i, data;\r
-    SKP_uint8 icdf[ 2 ];\r
+    SKP_int         i, j, p, data;\r
+    SKP_uint8       icdf[ 2 ];\r
+    SKP_int         *q_ptr;\r
+    const SKP_uint8 *icdf_ptr;\r
 \r
-    i = SKP_SMULBB( N_RATE_LEVELS - 1, SKP_LSHIFT( sigtype, 1 ) + QuantOffsetType ) + RateLevelIndex;\r
-    icdf[ 0 ] = SKP_Silk_sign_iCDF[ i ];\r
     icdf[ 1 ] = 0;\r
-    \r
+    q_ptr = q;\r
+    i = SKP_SMULBB( 6, SKP_ADD_LSHIFT( quantOffsetType, signalType, 1 ) );\r
+    icdf_ptr = &SKP_Silk_sign_iCDF[ i ];\r
+    length = SKP_RSHIFT( length, LOG2_SHELL_CODEC_FRAME_LENGTH );\r
     for( i = 0; i < length; i++ ) {\r
-        if( q[ i ] > 0 ) {\r
-            data = ec_dec_icdf( psRangeDec, icdf, 8 );\r
-            /* attach sign */\r
-            /* implementation with shift, subtraction, multiplication */\r
-            q[ i ] *= SKP_dec_map( data );\r
+        p = sum_pulses[ i ];\r
+        if( p > 0 ) {\r
+            icdf[ 0 ] = icdf_ptr[ SKP_min( p - 1, 5 ) ];\r
+            for( j = 0; j < SHELL_CODEC_FRAME_LENGTH; j++ ) {\r
+                if( q_ptr[ j ] > 0 ) {\r
+                    data = ec_dec_icdf( psRangeDec, icdf, 8 );\r
+                    /* attach sign */\r
+                    /* implementation with shift, subtraction, multiplication */\r
+                    q_ptr[ j ] *= SKP_dec_map( data );\r
+                }\r
+            }\r
         }\r
+        q_ptr += SHELL_CODEC_FRAME_LENGTH;\r
     }\r
 }\r
-\r
index 1d00c98..ddbc2ae 100644 (file)
@@ -63,7 +63,7 @@ SKP_int SKP_Silk_control_audio_bandwidth(
             psEncC->bitrateDiff += SKP_MUL( psEncC->PacketSize_ms, psEncC->TargetRate_bps - psEncC->bitrate_threshold_down );\r
             psEncC->bitrateDiff  = SKP_min( psEncC->bitrateDiff, 0 );\r
 \r
-            if( psEncC->vadFlag == NO_VOICE_ACTIVITY ) { /* Low speech activity */\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
@@ -124,7 +124,7 @@ SKP_int SKP_Silk_control_audio_bandwidth(
         /* 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->vadFlag == NO_VOICE_ACTIVITY ) ) {\r
+            ( psEncC->prevSignalType == TYPE_NO_VOICE_ACTIVITY ) ) {\r
 \r
                 psEncC->sLP.transition_frame_no = 0;\r
 \r
index b5fa3ec..f4a3629 100644 (file)
@@ -232,7 +232,6 @@ void SKP_Silk_SDK_search_for_LBRR(
 }\r
 #endif\r
 \r
-#if 0  // todo: clean up, make efficient\r
 /* Getting type of content for a packet */\r
 void SKP_Silk_SDK_get_TOC(\r
     ec_dec                              *psRangeDec,    /* I/O  Compressor data structure                   */\r
@@ -247,9 +246,9 @@ void SKP_Silk_SDK_get_TOC(
     sDec.fs_kHz         = 0; /* Force update parameters LPC_order etc */\r
 \r
     /* Decode all parameter indices for the whole packet*/\r
-    SKP_Silk_decode_indices( &sDec );\r
+    SKP_Silk_decode_indices( &sDec, psRangeDec );\r
     \r
-    if( sDec.sRC.error ) {\r
+    if( psRangeDec->error ) {\r
         /* Corrupt packet */\r
         SKP_memset( Silk_TOC, 0, sizeof( SKP_Silk_TOC_struct ) );\r
         Silk_TOC->corrupt = 1;\r
@@ -257,26 +256,14 @@ void SKP_Silk_SDK_get_TOC(
         Silk_TOC->corrupt = 0;\r
         Silk_TOC->framesInPacket = sDec.nFramesInPacket;\r
         Silk_TOC->fs_kHz         = sDec.fs_kHz;\r
-        if( sDec.FrameTermination == SKP_SILK_LAST_FRAME ) {\r
-            Silk_TOC->inbandLBRR = sDec.FrameTermination;\r
+        if( sDec.FrameTermination == SKP_SILK_LBRR ) {\r
+            Silk_TOC->inbandLBRR = 1;\r
         } else {\r
-            Silk_TOC->inbandLBRR = sDec.FrameTermination - 1;\r
+            Silk_TOC->inbandLBRR = 0;\r
         }\r
         /* Copy data */\r
         for( i = 0; i < sDec.nFramesInPacket; i++ ) {\r
-            Silk_TOC->vadFlags[ i ]     = sDec.vadFlagBuf[ i ];\r
-            Silk_TOC->sigtypeFlags[ i ] = sDec.sigtype[ i ];\r
+            Silk_TOC->signalTypeFlags[ i ] = sDec.signalType[ i ];\r
         }\r
     }\r
 }\r
-#endif\r
-\r
-/**************************/\r
-/* Get the version number */\r
-/**************************/\r
-/* Return a pointer to string specifying the version */ \r
-const char *SKP_Silk_SDK_get_version()\r
-{\r
-    static const char version[] = "1.0.4";\r
-    return version;\r
-}
\ No newline at end of file
index 619e2fb..d17b8bc 100644 (file)
@@ -37,7 +37,7 @@ void SKP_Silk_decode_core(
     const SKP_int               q[ MAX_FRAME_LENGTH ]               /* I    Pulse signal                */\r
 )\r
 {\r
-    SKP_int   i, j, k, lag = 0, start_idx, sLTP_buf_idx, NLSF_interpolation_flag, sigtype;\r
+    SKP_int   i, j, k, lag = 0, start_idx, sLTP_buf_idx, NLSF_interpolation_flag, signalType;\r
     SKP_int16 *A_Q12, *B_Q14, *pxq, A_Q12_tmp[ MAX_LPC_ORDER ];\r
     SKP_int16 sLTP[ MAX_FRAME_LENGTH ];\r
     SKP_int32 LTP_pred_Q14, LPC_pred_Q10, Gain_Q16, inv_gain_Q16, inv_gain_Q32, gain_adj_Q16, rand_seed, offset_Q10, dither;\r
@@ -47,7 +47,7 @@ void SKP_Silk_decode_core(
 \r
     SKP_assert( psDec->prev_inv_gain_Q16 != 0 );\r
     \r
-    offset_Q10 = SKP_Silk_Quantization_Offsets_Q10[ psDecCtrl->sigtype ][ psDecCtrl->QuantOffsetType ];\r
+    offset_Q10 = SKP_Silk_Quantization_Offsets_Q10[ psDecCtrl->signalType >> 1 ][ psDecCtrl->quantOffsetType ];\r
 \r
     if( psDecCtrl->NLSFInterpCoef_Q2 < ( 1 << 2 ) ) {\r
         NLSF_interpolation_flag = 1;\r
@@ -90,7 +90,7 @@ void SKP_Silk_decode_core(
         SKP_memcpy( A_Q12_tmp, A_Q12, psDec->LPC_order * sizeof( SKP_int16 ) ); \r
         B_Q14         = &psDecCtrl->LTPCoef_Q14[ k * LTP_ORDER ];\r
         Gain_Q16      = psDecCtrl->Gains_Q16[ k ];\r
-        sigtype       = psDecCtrl->sigtype;\r
+        signalType    = psDecCtrl->signalType;\r
 \r
         inv_gain_Q16 = SKP_INVERSE32_varQ( SKP_max( Gain_Q16, 1 ), 32 );\r
         inv_gain_Q16 = SKP_min( inv_gain_Q16, SKP_int16_MAX );\r
@@ -102,17 +102,17 @@ void SKP_Silk_decode_core(
         }\r
 \r
         /* Avoid abrupt transition from voiced PLC to unvoiced normal decoding */\r
-        if( psDec->lossCnt && psDec->prev_sigtype == SIG_TYPE_VOICED &&\r
-            psDecCtrl->sigtype == SIG_TYPE_UNVOICED && k < ( MAX_NB_SUBFR >> 1 ) ) {\r
+        if( psDec->lossCnt && psDec->prevSignalType == TYPE_VOICED &&\r
+            psDecCtrl->signalType != TYPE_VOICED && k < ( MAX_NB_SUBFR >> 1 ) ) {\r
             \r
             SKP_memset( B_Q14, 0, LTP_ORDER * sizeof( SKP_int16 ) );\r
             B_Q14[ LTP_ORDER/2 ] = ( SKP_int16 )1 << 12; /* 0.25 */\r
         \r
-            sigtype = SIG_TYPE_VOICED;\r
+            signalType = TYPE_VOICED;\r
             psDecCtrl->pitchL[ k ] = psDec->lagPrev;\r
         }\r
 \r
-        if( sigtype == SIG_TYPE_VOICED ) {\r
+        if( signalType == TYPE_VOICED ) {\r
             /* Voiced */\r
             \r
             lag = psDecCtrl->pitchL[ k ];\r
@@ -155,7 +155,7 @@ void SKP_Silk_decode_core(
         psDec->prev_inv_gain_Q16 = inv_gain_Q16;\r
 \r
         /* Long-term prediction */\r
-        if( sigtype == SIG_TYPE_VOICED ) {\r
+        if( signalType == TYPE_VOICED ) {\r
             /* Setup pointer */\r
             pred_lag_ptr = &psDec->sLTP_Q16[ sLTP_buf_idx - lag + LTP_ORDER / 2 ];\r
             for( i = 0; i < psDec->subfr_length; i++ ) {\r
index 5fc33c9..f9817c9 100644 (file)
@@ -110,7 +110,7 @@ TOC(decode_core)
             SKP_Silk_PLC( psDec, &sDecCtrl, pOut, L, action );\r
 \r
             psDec->lossCnt = 0;\r
-            psDec->prev_sigtype = sDecCtrl.sigtype;\r
+            psDec->prevSignalType = sDecCtrl.signalType;\r
 \r
             /* A frame has been decoded without errors */\r
             psDec->first_frame_after_reset = 0;\r
index 790c881..5b8b885 100644 (file)
@@ -34,28 +34,23 @@ void SKP_Silk_decode_indices(
 )\r
 {\r
     SKP_int   i, k, Ix, FrameIndex;\r
-    SKP_int   sigtype, QuantOffsetType, nBytesUsed;\r
+    SKP_int   signalType, quantOffsetType, nBytesUsed;\r
     SKP_int   decode_absolute_lagIndex, delta_lagIndex, prev_lagIndex = 0;\r
     const SKP_Silk_NLSF_CB_struct *psNLSF_CB = NULL;\r
 \r
     for( FrameIndex = 0; FrameIndex < psDec->nFramesInPacket; FrameIndex++ ) {\r
-        /*******************/\r
-        /* Decode VAD flag */\r
-        /*******************/\r
-        psDec->vadFlagBuf[ FrameIndex ] = ec_dec_icdf( psRangeDec, SKP_Silk_vadflag_iCDF, 8 );\r
-\r
         /*******************************************/\r
         /* Decode signal type and quantizer offset */\r
         /*******************************************/\r
         if( FrameIndex == 0 ) {\r
-            /* first frame in packet: independent coding, in two stages: MSB bits followed by 3 LSBs */\r
+            /* first frame in packet: independent coding */\r
             Ix = ec_dec_icdf( psRangeDec, SKP_Silk_type_offset_iCDF, 8 );\r
         } else {\r
-            /* condidtional coding */\r
+            /* conditional coding */\r
             Ix = ec_dec_icdf( psRangeDec, SKP_Silk_type_offset_joint_iCDF[ psDec->typeOffsetPrev ], 8 );\r
         }\r
-        sigtype               = SKP_RSHIFT( Ix, 1 );\r
-        QuantOffsetType       = Ix & 1;\r
+        signalType            = SKP_RSHIFT( Ix, 1 );\r
+        quantOffsetType       = Ix & 1;\r
         psDec->typeOffsetPrev = Ix;\r
 \r
         /****************/\r
@@ -63,12 +58,11 @@ void SKP_Silk_decode_indices(
         /****************/\r
         /* first subframe */    \r
         if( FrameIndex == 0 ) {\r
-            /* first frame in packet: independent coding */\r
-            psDec->GainsIndices[ FrameIndex ][ 0 ] = SKP_LSHIFT( ec_dec_icdf( psRangeDec, SKP_Silk_gain_iCDF[ sigtype ], 8 ), 3 );\r
-            //psDec->GainsIndices[ FrameIndex ][ 0 ] += ec_dec_bits( psRangeDec, 3 );           /* doesn't work somehow */\r
+            /* first frame in packet: independent coding, in two stages: MSB bits followed by 3 LSBs */\r
+            psDec->GainsIndices[ FrameIndex ][ 0 ] = SKP_LSHIFT( ec_dec_icdf( psRangeDec, SKP_Silk_gain_iCDF[ signalType ], 8 ), 3 );\r
             psDec->GainsIndices[ FrameIndex ][ 0 ] += ec_dec_icdf( psRangeDec, SKP_Silk_uniform8_iCDF, 8 );\r
         } else {\r
-            /* condidtional coding */\r
+            /* conditional coding */\r
             psDec->GainsIndices[ FrameIndex ][ 0 ] = ec_dec_icdf( psRangeDec, SKP_Silk_delta_gain_iCDF, 8 );\r
         }\r
 \r
@@ -80,9 +74,8 @@ void SKP_Silk_decode_indices(
         /**********************/\r
         /* Decode LSF Indices */\r
         /**********************/\r
-\r
         /* Set pointer to LSF VQ CB for the current signal type */\r
-        psNLSF_CB = psDec->psNLSF_CB[ sigtype ];\r
+        psNLSF_CB = psDec->psNLSF_CB[ 1 - (signalType >> 1) ];\r
 \r
         /* Range decoding of the NLSF path */\r
         for( i = 0; i < psNLSF_CB->nStages; i++ ) {\r
@@ -94,13 +87,13 @@ void SKP_Silk_decode_indices(
         /***********************************/\r
         psDec->NLSFInterpCoef_Q2[ FrameIndex ] = ec_dec_icdf( psRangeDec, SKP_Silk_NLSF_interpolation_factor_iCDF, 8 );\r
         \r
-        if( sigtype == SIG_TYPE_VOICED ) {\r
+        if( signalType == TYPE_VOICED ) {\r
             /*********************/\r
             /* Decode pitch lags */\r
             /*********************/\r
             /* Get lag index */\r
             decode_absolute_lagIndex = 1;\r
-            if( FrameIndex > 0 && psDec->sigtype[ FrameIndex - 1 ] == SIG_TYPE_VOICED ) {\r
+            if( FrameIndex > 0 && psDec->signalType[ FrameIndex - 1 ] == TYPE_VOICED ) {\r
                 /* Decode Delta index */\r
                 delta_lagIndex = ec_dec_icdf( psRangeDec, SKP_Silk_pitch_delta_iCDF, 8 );\r
                 if( delta_lagIndex > 0 ) {\r
@@ -111,7 +104,7 @@ void SKP_Silk_decode_indices(
             }\r
             if( decode_absolute_lagIndex ) {\r
                 /* Absolute decoding */\r
-                psDec->lagIndex[ FrameIndex ] = ec_dec_icdf( psRangeDec, SKP_Silk_pitch_lag_iCDF, 8 ) * SKP_RSHIFT( psDec->fs_kHz, 1 );\r
+                psDec->lagIndex[ FrameIndex ]  = ec_dec_icdf( psRangeDec, SKP_Silk_pitch_lag_iCDF, 8 ) * SKP_RSHIFT( psDec->fs_kHz, 1 );\r
                 psDec->lagIndex[ FrameIndex ] += ec_dec_icdf( psRangeDec, psDec->pitch_lag_low_bits_iCDF, 8 );\r
             }\r
             prev_lagIndex = psDec->lagIndex[ FrameIndex ];\r
@@ -140,8 +133,8 @@ void SKP_Silk_decode_indices(
         /***************/\r
         psDec->Seed[ FrameIndex ] = ec_dec_icdf( psRangeDec, SKP_Silk_Seed_iCDF, 8 );\r
 \r
-        psDec->sigtype[ FrameIndex ]         = sigtype;\r
-        psDec->QuantOffsetType[ FrameIndex ] = QuantOffsetType;\r
+        psDec->signalType[ FrameIndex ]      = signalType;\r
+        psDec->quantOffsetType[ FrameIndex ] = quantOffsetType;\r
     }\r
 \r
     /**************************************/\r
index d112306..8dc5ec1 100644 (file)
@@ -41,9 +41,9 @@ void SKP_Silk_decode_parameters(
     const SKP_int8 *cbk_ptr_Q7;\r
     const SKP_Silk_NLSF_CB_struct *psNLSF_CB = NULL;\r
     \r
-    psDecCtrl->sigtype            = psDec->sigtype[ psDec->nFramesDecoded ];\r
-    psDecCtrl->QuantOffsetType    = psDec->QuantOffsetType[ psDec->nFramesDecoded ];\r
-    psDec->vadFlag                = psDec->vadFlagBuf[ psDec->nFramesDecoded ];\r
+    psDecCtrl->signalType         = psDec->signalType[ psDec->nFramesDecoded ];\r
+    psDecCtrl->quantOffsetType    = psDec->quantOffsetType[ psDec->nFramesDecoded ];\r
+    psDec->vadFlag                = psDecCtrl->signalType > 0 ? 1 : 0;\r
     psDecCtrl->NLSFInterpCoef_Q2  = psDec->NLSFInterpCoef_Q2[ psDec->nFramesDecoded ];\r
     psDecCtrl->Seed               = psDec->Seed[ psDec->nFramesDecoded ];\r
 \r
@@ -55,7 +55,7 @@ void SKP_Silk_decode_parameters(
     /* Decode NLSFs */\r
     /****************/\r
     /* Set pointer to NLSF VQ CB for the current signal type */\r
-    psNLSF_CB = psDec->psNLSF_CB[ psDecCtrl->sigtype ];\r
+    psNLSF_CB = psDec->psNLSF_CB[ 1 - (psDecCtrl->signalType >> 1) ];\r
 \r
     /* From the NLSF path, decode an NLSF vector */\r
     SKP_Silk_NLSF_MSVQ_decode( pNLSF_Q15, psNLSF_CB, psDec->NLSFIndices[ psDec->nFramesDecoded ], psDec->LPC_order );\r
@@ -93,7 +93,7 @@ void SKP_Silk_decode_parameters(
         SKP_Silk_bwexpander( psDecCtrl->PredCoef_Q12[ 1 ], psDec->LPC_order, BWE_AFTER_LOSS_Q16 );\r
     }\r
 \r
-    if( psDecCtrl->sigtype == SIG_TYPE_VOICED ) {\r
+    if( psDecCtrl->signalType == TYPE_VOICED ) {\r
         /*********************/\r
         /* Decode pitch lags */\r
         /*********************/\r
@@ -123,7 +123,6 @@ void SKP_Silk_decode_parameters(
         Ix = psDec->LTP_scaleIndex[ psDec->nFramesDecoded ];\r
         psDecCtrl->LTP_scale_Q14 = SKP_Silk_LTPScales_table_Q14[ Ix ];\r
     } else {\r
-        SKP_assert( psDecCtrl->sigtype == SIG_TYPE_UNVOICED );\r
         SKP_memset( psDecCtrl->pitchL,      0,             psDec->nb_subfr * sizeof( SKP_int   ) );\r
         SKP_memset( psDecCtrl->LTPCoef_Q14, 0, LTP_ORDER * psDec->nb_subfr * sizeof( SKP_int16 ) );\r
         psDecCtrl->PERIndex      = 0;\r
index 546b726..b0d0a00 100644 (file)
@@ -40,13 +40,12 @@ void SKP_Silk_decode_pulses(
     SKP_int   i, j, k, iter, abs_q, nLS;\r
     SKP_int   sum_pulses[ MAX_NB_SHELL_BLOCKS ], nLshifts[ MAX_NB_SHELL_BLOCKS ];\r
     SKP_int   *pulses_ptr;\r
-    const SKP_uint16 *cdf_ptr;\r
+    const SKP_uint8 *cdf_ptr;\r
     \r
     /*********************/\r
     /* Decode rate level */\r
     /*********************/\r
-    SKP_Silk_range_decoder( &psDecCtrl->RateLevelIndex, psRangeDec, \r
-            SKP_Silk_rate_levels_CDF[ psDecCtrl->sigtype ], SKP_Silk_rate_levels_CDF_offset );\r
+    psDecCtrl->RateLevelIndex = ec_dec_icdf( psRangeDec, SKP_Silk_rate_levels_iCDF[ psDecCtrl->signalType >> 1 ], 8 );\r
 \r
     /* Calculate number of shell blocks */\r
     SKP_assert( 1 << LOG2_SHELL_CODEC_FRAME_LENGTH == SHELL_CODEC_FRAME_LENGTH );\r
@@ -58,16 +57,15 @@ void SKP_Silk_decode_pulses(
     /***************************************************/\r
     /* Sum-Weighted-Pulses Decoding                    */\r
     /***************************************************/\r
-    cdf_ptr = SKP_Silk_pulses_per_block_CDF[ psDecCtrl->RateLevelIndex ];\r
+    cdf_ptr = SKP_Silk_pulses_per_block_iCDF[ psDecCtrl->RateLevelIndex ];\r
     for( i = 0; i < iter; i++ ) {\r
         nLshifts[ i ] = 0;\r
-        SKP_Silk_range_decoder( &sum_pulses[ i ], psRangeDec, cdf_ptr, SKP_Silk_pulses_per_block_CDF_offset );\r
+        sum_pulses[ i ] = ec_dec_icdf( psRangeDec, cdf_ptr, 8 );\r
 \r
         /* LSB indication */\r
-        while( sum_pulses[ i ] == ( MAX_PULSES + 1 ) ) {\r
+        while( sum_pulses[ i ] == MAX_PULSES + 1 ) {\r
             nLshifts[ i ]++;\r
-            SKP_Silk_range_decoder( &sum_pulses[ i ], psRangeDec, \r
-                    SKP_Silk_pulses_per_block_CDF[ N_RATE_LEVELS - 1 ], SKP_Silk_pulses_per_block_CDF_offset );\r
+            sum_pulses[ i ] = ec_dec_icdf( psRangeDec, SKP_Silk_pulses_per_block_iCDF[ N_RATE_LEVELS - 1 ], 8 );\r
         }\r
     }\r
     \r
@@ -103,6 +101,6 @@ void SKP_Silk_decode_pulses(
     /****************************************/\r
     /* Decode and add signs to pulse signal */\r
     /****************************************/\r
-    SKP_Silk_decode_signs( psRangeDec, q, frame_length, psDecCtrl->sigtype, \r
-        psDecCtrl->QuantOffsetType, psDecCtrl->RateLevelIndex);\r
+    SKP_Silk_decode_signs( psRangeDec, q, frame_length, psDecCtrl->signalType, \r
+        psDecCtrl->quantOffsetType, sum_pulses );\r
 }\r
index cf2a133..ce1b972 100644 (file)
@@ -71,7 +71,7 @@ void SKP_Silk_decoder_set_fs(
 \r
         psDec->lagPrev                 = 100;\r
         psDec->LastGainIndex           = 1;\r
-        psDec->prev_sigtype            = 0;\r
+        psDec->prevSignalType          = TYPE_NO_VOICE_ACTIVITY;\r
         psDec->first_frame_after_reset = 1;\r
 \r
         if( fs_kHz == 24 ) {\r
index add2cc3..fbfdd7e 100644 (file)
@@ -102,9 +102,10 @@ extern "C"
 #define MAX_FS_KHZ                              24 \r
 #define MAX_API_FS_KHZ                          48\r
 \r
-/* Signal Types used by silk */\r
-#define SIG_TYPE_VOICED                         0\r
-#define SIG_TYPE_UNVOICED                       1\r
+/* Signal types used by silk */\r
+#define TYPE_NO_VOICE_ACTIVITY                  0\r
+#define TYPE_UNVOICED                           1\r
+#define TYPE_VOICED                             2\r
 \r
 /* VAD Types used by silk */\r
 #define NO_VOICE_ACTIVITY                       0\r
@@ -197,7 +198,7 @@ extern "C"
 #define N_RATE_LEVELS                           10\r
 \r
 /* maximum sum of pulses per shell coding frame */\r
-#define MAX_PULSES                              18\r
+#define MAX_PULSES                              16\r
 \r
 #define MAX_MATRIX_SIZE                         MAX_LPC_ORDER /* Max of LPC Order and LTP order */\r
 \r
@@ -239,8 +240,6 @@ extern "C"
 \r
 #define NLSF_MSVQ_FLUCTUATION_REDUCTION         1\r
 #define MAX_NLSF_MSVQ_SURVIVORS                 16\r
-#define MAX_NLSF_MSVQ_SURVIVORS_LC_MODE         2\r
-#define MAX_NLSF_MSVQ_SURVIVORS_MC_MODE         4\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
similarity index 90%
rename from src_common/SKP_Silk_encode_parameters.c
rename to src_common/SKP_Silk_encode_indices.c
index accd3d5..56a8949 100644 (file)
@@ -30,7 +30,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 /*******************************************/\r
 /* Encode parameters to create the payload */\r
 /*******************************************/\r
-void SKP_Silk_encode_parameters(\r
+void SKP_Silk_encode_indices(\r
     SKP_Silk_encoder_state      *psEncC,            /* I/O  Encoder state                               */\r
     SKP_Silk_encoder_control    *psEncCtrlC,        /* I/O  Encoder control                             */\r
     ec_enc                      *psRangeEnc         /* I/O  Compressor data structure                   */\r
@@ -45,20 +45,15 @@ void SKP_Silk_encode_parameters(
     SKP_int nBytes_after, nBytes_before;\r
 #endif\r
 \r
-    /*********************************************/\r
-    /* Encode VAD flag                           */\r
-    /*********************************************/\r
-    ec_enc_icdf( psRangeEnc, psEncC->vadFlag, SKP_Silk_vadflag_iCDF, 8 );\r
-\r
     /*******************************************/\r
     /* Encode signal type and quantizer offset */\r
     /*******************************************/\r
-    typeOffset = 2 * psEncCtrlC->sigtype + psEncCtrlC->QuantOffsetType;\r
+    typeOffset = 2 * psEncCtrlC->signalType + psEncCtrlC->quantOffsetType;\r
     if( psEncC->nFramesInPayloadBuf == 0 ) {\r
         /* first frame in packet: independent coding */\r
         ec_enc_icdf( psRangeEnc, typeOffset, SKP_Silk_type_offset_iCDF, 8 );\r
     } else {\r
-        /* condidtional coding */\r
+        /* conditional coding */\r
         ec_enc_icdf( psRangeEnc, typeOffset, SKP_Silk_type_offset_joint_iCDF[ psEncC->typeOffsetPrev ], 8 );\r
     }\r
     psEncC->typeOffsetPrev = typeOffset;\r
@@ -72,11 +67,10 @@ void SKP_Silk_encode_parameters(
     /* first subframe */\r
     if( psEncC->nFramesInPayloadBuf == 0 ) {\r
         /* first frame in packet: independent coding, in two stages: MSB bits followed by 3 LSBs */\r
-        ec_enc_icdf( psRangeEnc, SKP_RSHIFT( psEncCtrlC->GainsIndices[ 0 ], 3 ), SKP_Silk_gain_iCDF[ psEncCtrlC->sigtype ], 8 );\r
-        //ec_enc_bits( psRangeEnc, psEncCtrlC->GainsIndices[ 0 ] & 7, 3 );          /* doesn't work somehow */\r
+        ec_enc_icdf( psRangeEnc, SKP_RSHIFT( psEncCtrlC->GainsIndices[ 0 ], 3 ), SKP_Silk_gain_iCDF[ psEncCtrlC->signalType ], 8 );\r
         ec_enc_icdf( psRangeEnc, psEncCtrlC->GainsIndices[ 0 ] & 7, SKP_Silk_uniform8_iCDF, 8 );\r
     } else {\r
-        /* condidtional coding */\r
+        /* conditional coding */\r
         ec_enc_icdf( psRangeEnc, psEncCtrlC->GainsIndices[ 0 ], SKP_Silk_delta_gain_iCDF, 8 );\r
     }\r
 \r
@@ -98,7 +92,7 @@ void SKP_Silk_encode_parameters(
     nBytes_before = SKP_RSHIFT( ec_enc_tell( psRangeEnc, 0 ) + 7, 3 );\r
 #endif\r
     /* Range encoding of the NLSF path */\r
-    psNLSF_CB = psEncC->psNLSF_CB[ psEncCtrlC->sigtype ];\r
+    psNLSF_CB = psEncC->psNLSF_CB[ 1 - (psEncCtrlC->signalType>>1) ];\r
     for( i = 0; i < psNLSF_CB->nStages; i++ ) {\r
         ec_enc_icdf( psRangeEnc, psEncCtrlC->NLSFIndices[ i ], psNLSF_CB->StartPtr[ i ], 8 );\r
     }\r
@@ -114,7 +108,7 @@ void SKP_Silk_encode_parameters(
     DEBUG_STORE_DATA( nBytes_LSF.dat, &nBytes_after, sizeof( SKP_int ) );\r
 #endif\r
 \r
-    if( psEncCtrlC->sigtype == SIG_TYPE_VOICED ) {\r
+    if( psEncCtrlC->signalType == TYPE_VOICED ) {\r
         /*********************/\r
         /* Encode pitch lags */\r
         /*********************/\r
@@ -123,7 +117,7 @@ void SKP_Silk_encode_parameters(
 #endif\r
         /* lag index */\r
         encode_absolute_lagIndex = 1;\r
-        if( psEncC->nFramesInPayloadBuf > 0 && psEncC->prev_sigtype == SIG_TYPE_VOICED ) {\r
+        if( psEncC->nFramesInPayloadBuf > 0 && psEncC->prevSignalType == TYPE_VOICED ) {\r
             /* Delta Encoding */\r
             delta_lagIndex = psEncCtrlC->lagIndex - psEncC->prev_lagIndex;\r
             if( delta_lagIndex < -8 || delta_lagIndex > 11 ) {\r
index 36bcade..5dcda30 100644 (file)
@@ -72,22 +72,22 @@ SKP_INLINE SKP_int combine_and_check(       /* return ok */
 /* Encode quantization indices of excitation */\r
 void SKP_Silk_encode_pulses(\r
     ec_enc                      *psRangeEnc,        /* I/O  compressor data structure                   */\r
-    const SKP_int               sigtype,            /* I    Sigtype                                     */\r
-    const SKP_int               QuantOffsetType,    /* I    QuantOffsetType                             */\r
+    const SKP_int               signalType,         /* I    Sigtype                                     */\r
+    const SKP_int               quantOffsetType,    /* I    quantOffsetType                             */\r
     SKP_int8                    q[],                /* I    quantization indices                        */\r
     const SKP_int               frame_length        /* I    Frame length                                */\r
 )\r
 {\r
     SKP_int   i, k, j, iter, bit, nLS, scale_down, RateLevelIndex = 0;\r
-    SKP_int32 abs_q, minSumBits_Q6, sumBits_Q6;\r
+    SKP_int32 abs_q, minSumBits_Q5, sumBits_Q5;\r
     SKP_int   abs_pulses[ MAX_FRAME_LENGTH ];\r
     SKP_int   sum_pulses[ MAX_NB_SHELL_BLOCKS ];\r
     SKP_int   nRshifts[   MAX_NB_SHELL_BLOCKS ];\r
     SKP_int   pulses_comb[ 8 ];\r
     SKP_int   *abs_pulses_ptr;\r
     const SKP_int8 *pulses_ptr;\r
-    const SKP_uint16 *cdf_ptr;\r
-    const SKP_int16 *nBits_ptr;\r
+    const SKP_uint8 *cdf_ptr;\r
+    const SKP_uint8 *nBits_ptr;\r
 \r
     SKP_memset( pulses_comb, 0, 8 * sizeof( SKP_int ) ); // Fixing Valgrind reported problem\r
 \r
@@ -150,40 +150,37 @@ void SKP_Silk_encode_pulses(
     /* Rate level */\r
     /**************/\r
     /* find rate level that leads to fewest bits for coding of pulses per block info */\r
-    minSumBits_Q6 = SKP_int32_MAX;\r
+    minSumBits_Q5 = SKP_int32_MAX;\r
     for( k = 0; k < N_RATE_LEVELS - 1; k++ ) {\r
-        nBits_ptr  = SKP_Silk_pulses_per_block_BITS_Q6[ k ];\r
-        sumBits_Q6 = SKP_Silk_rate_levels_BITS_Q6[sigtype][ k ];\r
+        nBits_ptr  = SKP_Silk_pulses_per_block_BITS_Q5[ k ];\r
+        sumBits_Q5 = SKP_Silk_rate_levels_BITS_Q5[ signalType >> 1 ][ k ];\r
         for( i = 0; i < iter; i++ ) {\r
             if( nRshifts[ i ] > 0 ) {\r
-                sumBits_Q6 += nBits_ptr[ MAX_PULSES + 1 ];\r
+                sumBits_Q5 += nBits_ptr[ MAX_PULSES + 1 ];\r
             } else {\r
-                sumBits_Q6 += nBits_ptr[ sum_pulses[ i ] ];\r
+                sumBits_Q5 += nBits_ptr[ sum_pulses[ i ] ];\r
             }\r
         }\r
-        if( sumBits_Q6 < minSumBits_Q6 ) {\r
-            minSumBits_Q6 = sumBits_Q6;\r
+        if( sumBits_Q5 < minSumBits_Q5 ) {\r
+            minSumBits_Q5 = sumBits_Q5;\r
             RateLevelIndex = k;\r
         }\r
     }\r
-    ec_encode_bin( psRangeEnc, SKP_Silk_rate_levels_CDF[ sigtype ][ RateLevelIndex ], \r
-        SKP_Silk_rate_levels_CDF[ sigtype ][ RateLevelIndex + 1 ], 16 );\r
+    ec_enc_icdf( psRangeEnc, RateLevelIndex, SKP_Silk_rate_levels_iCDF[ signalType >> 1 ], 8 );\r
 \r
     /***************************************************/\r
     /* Sum-Weighted-Pulses Encoding                    */\r
     /***************************************************/\r
-    cdf_ptr = SKP_Silk_pulses_per_block_CDF[ RateLevelIndex ];\r
+    cdf_ptr = SKP_Silk_pulses_per_block_iCDF[ RateLevelIndex ];\r
     for( i = 0; i < iter; i++ ) {\r
         if( nRshifts[ i ] == 0 ) {\r
-            ec_encode_bin( psRangeEnc, cdf_ptr[ sum_pulses[ i ] ], cdf_ptr[ sum_pulses[ i ] + 1 ], 16 );\r
+            ec_enc_icdf( psRangeEnc, sum_pulses[ i ], cdf_ptr, 8 );\r
         } else {\r
-            ec_encode_bin( psRangeEnc, cdf_ptr[ MAX_PULSES + 1 ], cdf_ptr[ MAX_PULSES + 2 ], 16 );\r
+            ec_enc_icdf( psRangeEnc, MAX_PULSES + 1, cdf_ptr, 8 );\r
             for( k = 0; k < nRshifts[ i ] - 1; k++ ) {\r
-                ec_encode_bin( psRangeEnc, SKP_Silk_pulses_per_block_CDF[ N_RATE_LEVELS - 1 ][ MAX_PULSES + 1 ], \r
-                    SKP_Silk_pulses_per_block_CDF[ N_RATE_LEVELS - 1 ][ MAX_PULSES + 2 ], 16 );\r
+                ec_enc_icdf( psRangeEnc, MAX_PULSES + 1, SKP_Silk_pulses_per_block_iCDF[ N_RATE_LEVELS - 1 ], 8 );\r
             }\r
-            ec_encode_bin( psRangeEnc, SKP_Silk_pulses_per_block_CDF[ N_RATE_LEVELS - 1 ][ sum_pulses[ i ] ], \r
-                SKP_Silk_pulses_per_block_CDF[ N_RATE_LEVELS - 1 ][ sum_pulses[ i ] + 1 ], 16 );\r
+            ec_enc_icdf( psRangeEnc, sum_pulses[ i ], SKP_Silk_pulses_per_block_iCDF[ N_RATE_LEVELS - 1 ], 8 );\r
         }\r
     }\r
 \r
@@ -219,6 +216,6 @@ void SKP_Silk_encode_pulses(
     /****************/\r
     /* Encode signs */\r
     /****************/\r
-    SKP_Silk_encode_signs( psRangeEnc, q, frame_length, sigtype, QuantOffsetType, RateLevelIndex );\r
+    SKP_Silk_encode_signs( psRangeEnc, q, frame_length, signalType, quantOffsetType, sum_pulses );\r
 #endif\r
 }\r
index bfceea7..68d85fd 100644 (file)
@@ -51,22 +51,22 @@ extern "C"
 \r
 /* Encodes signs of excitation */\r
 void SKP_Silk_encode_signs(\r
-    ec_enc                      *psRangeEnc,        /* I/O  Compressor data structure                   */\r
-    const SKP_int8              q[],                /* I    pulse signal                                */\r
-    const SKP_int               length,             /* I    length of input                             */\r
-    const SKP_int               sigtype,            /* I    Signal type                                 */\r
-    const SKP_int               QuantOffsetType,    /* I    Quantization offset type                    */\r
-    const SKP_int               RateLevelIndex      /* I    Rate Level Index                            */\r
+    ec_enc                      *psRangeEnc,                        /* I/O  Compressor data structure                   */\r
+    const SKP_int8              q[],                                /* I    pulse signal                                */\r
+    SKP_int                     length,                             /* I    length of input                             */\r
+    const SKP_int               signalType,                         /* I    Signal type                                 */\r
+    const SKP_int               quantOffsetType,                    /* I    Quantization offset type                    */\r
+    const SKP_int               sum_pulses[ MAX_NB_SHELL_BLOCKS ]   /* I    Sum of absolute pulses per block            */\r
 );\r
 \r
 /* Decodes signs of excitation */\r
 void SKP_Silk_decode_signs(\r
-    ec_dec                      *psRangeDec,        /* I/O  Compressor data structure                   */\r
-    SKP_int                     q[],                /* I/O  pulse signal                                */\r
-    const SKP_int               length,             /* I    length of output                            */\r
-    const SKP_int               sigtype,            /* I    Signal type                                 */\r
-    const SKP_int               QuantOffsetType,    /* I    Quantization offset type                    */\r
-    const SKP_int               RateLevelIndex      /* I    Rate Level Index                            */\r
+    ec_dec                      *psRangeDec,                        /* I/O  Compressor data structure                   */\r
+    SKP_int                     q[],                                /* I/O  pulse signal                                */\r
+    SKP_int                     length,                             /* I    length of input                             */\r
+    const SKP_int               signalType,                         /* I    Signal type                                 */\r
+    const SKP_int               quantOffsetType,                    /* I    Quantization offset type                    */\r
+    const SKP_int               sum_pulses[ MAX_NB_SHELL_BLOCKS ]   /* I    Sum of absolute pulses per block            */\r
 );\r
 \r
 /* Control internal sampling rate */\r
@@ -82,8 +82,8 @@ SKP_int SKP_Silk_control_audio_bandwidth(
 /* Encode quantization indices of excitation */\r
 void SKP_Silk_encode_pulses(\r
     ec_enc                      *psRangeEnc,        /* I/O  compressor data structure                   */\r
-    const SKP_int               sigtype,            /* I    Sigtype                                     */\r
-    const SKP_int               QuantOffsetType,    /* I    QuantOffsetType                             */\r
+    const SKP_int               signalType,         /* I    Signal type                                 */\r
+    const SKP_int               quantOffsetType,    /* I    quantOffsetType                             */\r
     SKP_int8                    q[],                /* I    quantization indices                        */\r
     const SKP_int               frame_length        /* I    Frame length                                */\r
 );\r
@@ -101,17 +101,6 @@ void SKP_Silk_shell_decoder(
     const SKP_int               pulses4             /* I    number of pulses per pulse-subframe         */\r
 );\r
 \r
-/***************/\r
-/* Range coder */\r
-/***************/\r
-/* Range decoder for one symbol */\r
-void SKP_Silk_range_decoder(\r
-    SKP_int                     data[],             /* O    uncompressed data                           */\r
-    ec_dec                      *psRangeDec,        /* I/O  Compressor data structure                   */\r
-    const SKP_uint16            prob[],             /* I    cumulative density function                 */\r
-    SKP_int                     probIx              /* I    initial (middle) entry of cdf               */\r
-);\r
-\r
 /* Gain scalar quantization with hysteresis, uniform on log scale */\r
 void SKP_Silk_gains_quant(\r
     SKP_int                         ind[ MAX_NB_SUBFR ],        /* O    gain indices                            */\r
@@ -152,7 +141,7 @@ void SKP_Silk_quant_LTP_gains(
     SKP_int             cbk_index[ MAX_NB_SUBFR ],                      /* O    Codebook Index              */\r
     SKP_int             *periodicity_index,                             /* O    Periodicity Index           */\r
     const SKP_int32     W_Q18[ MAX_NB_SUBFR*LTP_ORDER*LTP_ORDER ],      /* I    Error Weights in Q18        */\r
-    SKP_int             mu_Q10,                                         /* I    Mu value (R/D tradeoff)     */\r
+    SKP_int             mu_Q9,                                          /* I    Mu value (R/D tradeoff)     */\r
     SKP_int             lowComplexity,                                  /* I    Flag for low complexity     */\r
     const SKP_int       nb_subfr                                        /* I    number of subframes         */\r
 );\r
@@ -164,8 +153,8 @@ void SKP_Silk_VQ_WMat_EC(
     const SKP_int16                 *in_Q14,            /* I    input vector to be quantized                */\r
     const SKP_int32                 *W_Q18,             /* I    weighting matrix                            */\r
     const SKP_int8                  *cb_Q7,             /* I    codebook                                    */\r
-    const SKP_int8                  *cl_Q4,             /* I    code length for each codebook vector        */\r
-    const SKP_int                   mu_Q10,             /* I    tradeoff between weighted error and rate    */\r
+    const SKP_uint8                 *cl_Q5,             /* I    code length for each codebook vector        */\r
+    const SKP_int                   mu_Q9,              /* I    tradeoff between weighted error and rate    */\r
     SKP_int                         L                   /* I    number of vectors in codebook               */\r
 );\r
 \r
@@ -349,7 +338,7 @@ void SKP_Silk_CNG(
 );\r
 \r
 /* Encoding of various parameters */\r
-void SKP_Silk_encode_parameters(\r
+void SKP_Silk_encode_indices(\r
     SKP_Silk_encoder_state      *psEncC,            /* I/O  Encoder state                               */\r
     SKP_Silk_encoder_control    *psEncCtrlC,        /* I/O  Encoder control                             */\r
     ec_enc                      *psRangeEnc         /* I/O  Compressor data structure                   */\r
@@ -363,11 +352,6 @@ void SKP_Silk_get_low_layer_internal(
     SKP_int32                   *nLayer0Bytes       /* O:   Number of FEC Bytes                         */\r
 );\r
 \r
-/* Resets LBRR buffer, used if packet size changes */\r
-void SKP_Silk_LBRR_reset( \r
-    SKP_Silk_encoder_state      *psEncC             /* I/O  Pointer to Silk encoder state               */\r
-);\r
-\r
 /* Predict number of bytes used to encode q */\r
 SKP_int SKP_Silk_pulses_to_bytes( /* O  Return value, predicted number of bytes used to encode q */ \r
     SKP_Silk_encoder_state      *psEncC,            /* I/O  Encoder State*/\r
index 5405186..87ae339 100644 (file)
@@ -32,13 +32,13 @@ void SKP_Silk_quant_LTP_gains(
     SKP_int             cbk_index[ MAX_NB_SUBFR ],                      /* O    Codebook Index              */\r
     SKP_int             *periodicity_index,                             /* O    Periodicity Index           */\r
     const SKP_int32     W_Q18[ MAX_NB_SUBFR*LTP_ORDER*LTP_ORDER ],      /* I    Error Weights in Q18        */\r
-    SKP_int             mu_Q10,                                         /* I    Mu value (R/D tradeoff)     */\r
+    SKP_int             mu_Q9,                                          /* I    Mu value (R/D tradeoff)     */\r
     SKP_int             lowComplexity,                                  /* I    Flag for low complexity     */\r
     const SKP_int       nb_subfr                                        /* I    number of subframes         */\r
 )\r
 {\r
     SKP_int             j, k, temp_idx[ MAX_NB_SUBFR ], cbk_size;\r
-    const SKP_int8      *cl_ptr_Q4;\r
+    const SKP_uint8     *cl_ptr_Q5;\r
     const SKP_int8      *cbk_ptr_Q7;\r
     const SKP_int16     *b_Q14_ptr;\r
     const SKP_int32     *W_Q18_ptr;\r
@@ -53,7 +53,7 @@ TIC(quant_LTP)
     /***************************************************/\r
     min_rate_dist_Q14 = SKP_int32_MAX;\r
     for( k = 0; k < 3; k++ ) {\r
-        cl_ptr_Q4  = SKP_Silk_LTP_gain_BITS_Q4_ptrs[ k ];\r
+        cl_ptr_Q5  = SKP_Silk_LTP_gain_BITS_Q5_ptrs[ k ];\r
         cbk_ptr_Q7 = SKP_Silk_LTP_vq_ptrs_Q7[        k ];\r
         cbk_size   = SKP_Silk_LTP_vq_sizes[          k ];\r
 \r
@@ -70,8 +70,8 @@ TIC(quant_LTP)
                 b_Q14_ptr,              /* I    input vector to be quantized                            */\r
                 W_Q18_ptr,              /* I    weighting matrix                                        */\r
                 cbk_ptr_Q7,             /* I    codebook                                                */\r
-                cl_ptr_Q4,              /* I    code length for each codebook vector                    */\r
-                mu_Q10,                 /* I    tradeoff between weighted error and rate                */\r
+                cl_ptr_Q5,              /* I    code length for each codebook vector                    */\r
+                mu_Q9,                  /* I    tradeoff between weighted error and rate                */\r
                 cbk_size                /* I    number of vectors in codebook                           */\r
             );\r
 \r
diff --git a/src_common/SKP_Silk_range_coder.c b/src_common/SKP_Silk_range_coder.c
deleted file mode 100644 (file)
index b731f19..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/***********************************************************************\r
-Copyright (c) 2006-2010, 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
-/* Range decoder for one symbol */\r
-void SKP_Silk_range_decoder(\r
-    SKP_int                         data[],             /* O    uncompressed data                           */\r
-    ec_dec                          *psRangeDec,        /* I/O  Compressor data structure                   */\r
-    const SKP_uint16                prob[],             /* I    cumulative density function                 */\r
-    SKP_int                         probIx              /* I    initial (middle) entry of cdf               */\r
-)\r
-{\r
-    SKP_uint32 low_Q16, high_Q16;\r
-\r
-    SKP_uint32 low_Q16_returned;\r
-    SKP_int    temp;\r
-\r
-    if( prob[ 2 ] == 65535 ) {\r
-        /* Instead of detection, we could add a separate function and call when we know that output is a bit */\r
-        *data = ec_dec_bit_prob( psRangeDec, 65536 - prob[ 1 ] );\r
-    } else {\r
-        low_Q16_returned = ec_decode_bin( psRangeDec, 16 );\r
-\r
-#if 1\r
-        temp = 0;\r
-        while( low_Q16_returned >= prob[ ++temp ] ) {}\r
-        *data = temp - 1;\r
-#else\r
-        temp = probIx;\r
-        if( low_Q16_returned >= prob[ temp ] ){\r
-            while( low_Q16_returned >= prob[ temp ] ) {\r
-                temp++;\r
-            }\r
-            temp = temp - 1;\r
-        } else {\r
-            /* search down */\r
-            while( low_Q16_returned < prob[ temp ] ) {\r
-                temp--;\r
-            }\r
-        }\r
-        *data = temp;\r
-#endif\r
-\r
-        low_Q16  = prob[ *data ];\r
-        high_Q16 = prob[ *data + 1 ];\r
-\r
-#ifdef SAVE_ALL_INTERNAL_DATA\r
-        DEBUG_STORE_DATA( dec_lr.dat, &low_Q16_returned,  sizeof( SKP_uint32 ) );\r
-        DEBUG_STORE_DATA( dec_l.dat,  &low_Q16,           sizeof( SKP_uint32 ) );\r
-        DEBUG_STORE_DATA( dec_h.dat,  &high_Q16,          sizeof( SKP_uint32 ) );\r
-#endif  \r
-        ec_dec_update( psRangeDec, low_Q16, high_Q16,( 1 << 16 ) );\r
-    }\r
-#ifdef SAVE_ALL_INTERNAL_DATA\r
-    DEBUG_STORE_DATA( dec.dat, data, sizeof( SKP_int ) );\r
-#endif\r
-}\r
index 0d24fd6..42e8108 100644 (file)
@@ -41,52 +41,69 @@ SKP_INLINE SKP_int SKP_Silk_setup_complexity(
     }\r
 \r
     /* Set encoding complexity */\r
-    if( Complexity == 0 || LOW_COMPLEXITY_ONLY ) {\r
-        /* Low complexity */\r
-        psEncC->Complexity                      = 0;\r
+    if( Complexity < 2 || LOW_COMPLEXITY_ONLY ) {\r
         psEncC->pitchEstimationComplexity       = SKP_Silk_PE_MIN_COMPLEX;\r
-        psEncC->pitchEstimationThreshold_Q16    = SKP_FIX_CONST( FIND_PITCH_CORRELATION_THRESHOLD_LOW_COMPL_MODE, 16 );\r
+        psEncC->pitchEstimationThreshold_Q16    = SKP_FIX_CONST( 0.8, 16 );\r
         psEncC->pitchEstimationLPCOrder         = 6;\r
         psEncC->shapingLPCOrder                 = 8;\r
         psEncC->la_shape                        = 3 * psEncC->fs_kHz;\r
         psEncC->nStatesDelayedDecision          = 1;\r
         psEncC->useInterpolatedNLSFs            = 0;\r
         psEncC->LTPQuantLowComplexity           = 1;\r
-        psEncC->NLSF_MSVQ_Survivors             = MAX_NLSF_MSVQ_SURVIVORS_LC_MODE;\r
+        psEncC->NLSF_MSVQ_Survivors             = 2;\r
         psEncC->warping_Q16                     = 0;\r
-    } else if( Complexity == 1 ) {\r
-        /* Medium complexity */\r
-        psEncC->Complexity                      = 1;\r
+    } else if( Complexity < 4 || LOW_COMPLEXITY_ONLY ) {\r
         psEncC->pitchEstimationComplexity       = SKP_Silk_PE_MID_COMPLEX;\r
-        psEncC->pitchEstimationThreshold_Q16    = SKP_FIX_CONST( FIND_PITCH_CORRELATION_THRESHOLD_MID_COMPL_MODE, 16 );\r
-        psEncC->pitchEstimationLPCOrder         = 12;\r
+        psEncC->pitchEstimationThreshold_Q16    = SKP_FIX_CONST( 0.76, 16 );\r
+        psEncC->pitchEstimationLPCOrder         = 8;\r
+        psEncC->shapingLPCOrder                 = 10;\r
+        psEncC->la_shape                        = 5 * psEncC->fs_kHz;\r
+        psEncC->nStatesDelayedDecision          = 1;\r
+        psEncC->useInterpolatedNLSFs            = 1;\r
+        psEncC->LTPQuantLowComplexity           = 0;\r
+        psEncC->NLSF_MSVQ_Survivors             = 4;\r
+        psEncC->warping_Q16                     = 0;\r
+    } else if( Complexity < 6 ) {\r
+        psEncC->pitchEstimationComplexity       = SKP_Silk_PE_MID_COMPLEX;\r
+        psEncC->pitchEstimationThreshold_Q16    = SKP_FIX_CONST( 0.74, 16 );\r
+        psEncC->pitchEstimationLPCOrder         = 10;\r
         psEncC->shapingLPCOrder                 = 12;\r
         psEncC->la_shape                        = 5 * psEncC->fs_kHz;\r
         psEncC->nStatesDelayedDecision          = 2;\r
         psEncC->useInterpolatedNLSFs            = 0;\r
         psEncC->LTPQuantLowComplexity           = 0;\r
-        psEncC->NLSF_MSVQ_Survivors             = MAX_NLSF_MSVQ_SURVIVORS_MC_MODE;\r
+        psEncC->NLSF_MSVQ_Survivors             = 6;\r
+        psEncC->warping_Q16                     = psEncC->fs_kHz * SKP_FIX_CONST( WARPING_MULTIPLIER, 16 );\r
+    } else if( Complexity < 8 ) {\r
+        psEncC->pitchEstimationComplexity       = SKP_Silk_PE_MID_COMPLEX;\r
+        psEncC->pitchEstimationThreshold_Q16    = SKP_FIX_CONST( 0.72, 16 );\r
+        psEncC->pitchEstimationLPCOrder         = 12;\r
+        psEncC->shapingLPCOrder                 = 14;\r
+        psEncC->la_shape                        = 5 * psEncC->fs_kHz;\r
+        psEncC->nStatesDelayedDecision          = 3;\r
+        psEncC->useInterpolatedNLSFs            = 0;\r
+        psEncC->LTPQuantLowComplexity           = 0;\r
+        psEncC->NLSF_MSVQ_Survivors             = 8;\r
         psEncC->warping_Q16                     = psEncC->fs_kHz * SKP_FIX_CONST( WARPING_MULTIPLIER, 16 );\r
-    } else if( Complexity == 2 ) {\r
-        /* High complexity */\r
-        psEncC->Complexity                      = 2;\r
+    } else if( Complexity <= 10 ) {\r
         psEncC->pitchEstimationComplexity       = SKP_Silk_PE_MAX_COMPLEX;\r
-        psEncC->pitchEstimationThreshold_Q16    = SKP_FIX_CONST( FIND_PITCH_CORRELATION_THRESHOLD_HI_COMPL_MODE, 16 );\r
+        psEncC->pitchEstimationThreshold_Q16    = SKP_FIX_CONST( 0.7, 16 );\r
         psEncC->pitchEstimationLPCOrder         = 16;\r
         psEncC->shapingLPCOrder                 = 16;\r
         psEncC->la_shape                        = 5 * psEncC->fs_kHz;\r
         psEncC->nStatesDelayedDecision          = MAX_DEL_DEC_STATES;\r
         psEncC->useInterpolatedNLSFs            = 1;\r
         psEncC->LTPQuantLowComplexity           = 0;\r
-        psEncC->NLSF_MSVQ_Survivors             = MAX_NLSF_MSVQ_SURVIVORS;\r
+        psEncC->NLSF_MSVQ_Survivors             = 16;\r
         psEncC->warping_Q16                     = psEncC->fs_kHz * SKP_FIX_CONST( WARPING_MULTIPLIER, 16 );\r
     } else {\r
         ret = SKP_SILK_ENC_INVALID_COMPLEXITY_SETTING;\r
     }\r
 \r
     /* Do not allow higher pitch estimation LPC order than predict LPC order */\r
-    psEncC->pitchEstimationLPCOrder             = SKP_min_int( psEncC->pitchEstimationLPCOrder, psEncC->predictLPCOrder );\r
-    psEncC->shapeWinLength                      = SUB_FRAME_LENGTH_MS * psEncC->fs_kHz + 2 * psEncC->la_shape;\r
+    psEncC->pitchEstimationLPCOrder = SKP_min_int( psEncC->pitchEstimationLPCOrder, psEncC->predictLPCOrder );\r
+    psEncC->shapeWinLength          = SUB_FRAME_LENGTH_MS * psEncC->fs_kHz + 2 * psEncC->la_shape;\r
+    psEncC->Complexity              = Complexity;\r
 \r
     SKP_assert( psEncC->pitchEstimationLPCOrder <= MAX_FIND_PITCH_LPC_ORDER );\r
     SKP_assert( psEncC->shapingLPCOrder         <= MAX_SHAPE_LPC_ORDER      );\r
@@ -94,6 +111,7 @@ SKP_INLINE SKP_int SKP_Silk_setup_complexity(
     SKP_assert( psEncC->warping_Q16             <= 32767                    );\r
     SKP_assert( psEncC->la_shape                <= LA_SHAPE_MAX             );\r
     SKP_assert( psEncC->shapeWinLength          <= SHAPE_LPC_WIN_MAX        );\r
+    SKP_assert( psEncC->NLSF_MSVQ_Survivors     <= MAX_NLSF_MSVQ_SURVIVORS  );\r
 \r
     return( ret );\r
 }\r
index 15a2628..73166ad 100644 (file)
@@ -45,18 +45,11 @@ SKP_INLINE void encode_split(
     ec_enc                      *psRangeEnc,    /* I/O  compressor data structure                   */\r
     const SKP_int               p_child1,       /* I:   pulse amplitude of first child subframe     */\r
     const SKP_int               p,              /* I:   pulse amplitude of current subframe         */\r
-    const SKP_uint16            *shell_table    /* I:   table of shell cdfs                         */\r
+    const SKP_uint            *shell_table    /* I:   table of shell cdfs                         */\r
 )\r
 {\r
-    const SKP_uint16 *cdf;\r
-\r
     if( p > 0 ) {\r
-        cdf = &shell_table[ SKP_Silk_shell_code_table_offsets[ p ] ];\r
-        if( cdf[ 2 ] == 65535 ) {\r
-            ec_enc_bit_prob( psRangeEnc, p_child1, 65536 - cdf[ 1 ] );\r
-        } else {\r
-            ec_encode_bin( psRangeEnc, cdf[ p_child1 ], cdf[ p_child1 + 1 ], 16 );\r
-        }\r
+        ec_enc_icdf( psRangeEnc, p_child1, &shell_table[ SKP_Silk_shell_code_table_offsets[ p ] ], 8 );\r
     }\r
 }\r
 \r
@@ -65,16 +58,11 @@ SKP_INLINE void decode_split(
     SKP_int                     *p_child2,      /* O:   pulse amplitude of second child subframe    */\r
     ec_dec                      *psRangeDec,    /* I/O  Compressor data structure                   */\r
     const SKP_int               p,              /* I:   pulse amplitude of current subframe         */\r
-    const SKP_uint16            *shell_table    /* I:   table of shell cdfs                         */\r
+    const SKP_uint            *shell_table    /* I:   table of shell cdfs                         */\r
 )\r
 {\r
-    SKP_int cdf_middle;\r
-    const SKP_uint16 *cdf;\r
-\r
     if( p > 0 ) {\r
-        cdf_middle = SKP_RSHIFT( p, 1 );\r
-        cdf = &shell_table[ SKP_Silk_shell_code_table_offsets[ p ] ];\r
-        SKP_Silk_range_decoder( p_child1, psRangeDec, cdf, cdf_middle );\r
+        p_child1[ 0 ] = ec_dec_icdf( psRangeDec, &shell_table[ SKP_Silk_shell_code_table_offsets[ p ] ], 8 );\r
         p_child2[ 0 ] = p - p_child1[ 0 ];\r
     } else {\r
         p_child1[ 0 ] = 0;\r
index 6b5b389..bb93ebb 100644 (file)
@@ -57,13 +57,6 @@ typedef struct {
     SKP_int     rewhite_flag;\r
 } SKP_Silk_nsq_state; /* FIX*/\r
 \r
-/* Struct for Low BitRate Redundant (LBRR) information */\r
-typedef struct {\r
-    SKP_uint8   payload[ MAX_ARITHM_BYTES ];    \r
-    SKP_int     nBytes;                         /* Number of bytes in payload                               */\r
-    SKP_int     usage;                          /* Tells how the payload should be used as FEC              */\r
-} SKP_SILK_LBRR_struct;\r
-\r
 /********************************/\r
 /* VAD state                    */\r
 /********************************/\r
@@ -138,8 +131,6 @@ typedef struct {
 /* Encoder state                */\r
 /********************************/\r
 typedef struct {\r
-    //SKP_Silk_range_coder_state      sRC;                            /* Range coder state                                                    */\r
-    //SKP_Silk_range_coder_state      sRC_LBRR;                       /* Range coder state (for low bitrate redundancy)                       */\r
 #if HIGH_PASS_INPUT\r
     SKP_int32                       In_HP_State[ 2 ];               /* High pass filter state                                               */\r
 #endif\r
@@ -149,7 +140,7 @@ typedef struct {
     SKP_Silk_VAD_state              sVAD;                           /* Voice activity detector state                                        */\r
 \r
     SKP_int                         LBRRprevLastGainIndex;\r
-    SKP_int                         prev_sigtype;\r
+    SKP_int                         prevSignalType;\r
     SKP_int                         typeOffsetPrev;                 /* Previous signal type and quantization offset                         */\r
     SKP_int                         prevLag;\r
     SKP_int                         prev_lagIndex;\r
@@ -179,7 +170,7 @@ typedef struct {
     SKP_int                         pitchEstimationLPCOrder;        /* Whitening filter order for pitch estimator                           */\r
     SKP_int32                       pitchEstimationThreshold_Q16;   /* Threshold for pitch estimator                                        */\r
     SKP_int                         LTPQuantLowComplexity;          /* Flag for low complexity LTP quantization                             */\r
-    SKP_int                         mu_LTP_Q10;                     /* Rate-distortion tradeoff in LTP quantization                         */\r
+    SKP_int                         mu_LTP_Q9;                      /* Rate-distortion tradeoff in LTP quantization                         */\r
     SKP_int                         NLSF_MSVQ_Survivors;            /* Number of survivors in NLSF MSVQ                                     */\r
     SKP_int                         first_frame_after_reset;        /* Flag for deactivating NLSF interp. and fluc. reduction after resets  */\r
     SKP_int                         controlled_since_last_payload;  /* Flag for ensuring codec_control only runs once per packet            */\r
@@ -199,9 +190,7 @@ typedef struct {
 \r
     const SKP_Silk_NLSF_CB_struct   *psNLSF_CB[ 2 ];                /* Pointers to voiced/unvoiced NLSF codebooks */\r
 \r
-    /* Struct for Inband LBRR */ \r
-    SKP_SILK_LBRR_struct            LBRR_buffer[ MAX_LBRR_DELAY ];\r
-    SKP_int                         oldest_LBRR_idx;\r
+    /* Inband Low Bitrate Redundancy (LBRR) data */ \r
     SKP_int                         useInBandFEC;                   /* Saves the API setting for query                                      */\r
     SKP_int                         LBRR_enabled;\r
     SKP_int                         LBRR_GainIncreases;             /* Number of shifts to Gains to get LBRR rate Voiced frames             */\r
@@ -217,7 +206,7 @@ typedef struct {
     SKP_int                         noSpeechCounter;                /* Counts concecutive nonactive frames, used by DTX                     */\r
     SKP_int                         useDTX;                         /* Flag to enable DTX                                                   */\r
     SKP_int                         inDTX;                          /* Flag to signal DTX period                                            */\r
-    SKP_int                         vadFlag;                        /* Flag to indicate Voice Activity                                      */\r
+    SKP_int                         LBRR_nBytes;\r
 \r
     /* Struct for detecting SWB input */\r
     SKP_Silk_detect_SWB_state       sSWBdetect;\r
@@ -226,8 +215,8 @@ typedef struct {
     /* Buffers */\r
        SKP_int8                        q[ MAX_FRAME_LENGTH * MAX_FRAMES_PER_PACKET ];      /* pulse signal buffer */\r
     SKP_int8                        q_LBRR[ MAX_FRAME_LENGTH * MAX_FRAMES_PER_PACKET ]; /* pulse signal buffer */\r
-    SKP_int                         sigtype[ MAX_FRAMES_PER_PACKET ];\r
-    SKP_int                         QuantOffsetType[ MAX_FRAMES_PER_PACKET ];\r
+    SKP_int                         quantOffsetType[ MAX_FRAMES_PER_PACKET ];\r
+    SKP_int                         signalType[ MAX_FRAMES_PER_PACKET ];\r
 } SKP_Silk_encoder_state;\r
 \r
 \r
@@ -246,8 +235,8 @@ typedef struct {
     SKP_int32   Seed;\r
     SKP_int     LTP_scaleIndex;\r
     SKP_int     RateLevelIndex;\r
-    SKP_int     QuantOffsetType;\r
-    SKP_int     sigtype;\r
+    SKP_int     quantOffsetType;\r
+    SKP_int     signalType;\r
 \r
     /* Prediction and coding parameters */\r
     SKP_int     pitchL[ MAX_NB_SUBFR ];\r
@@ -321,8 +310,8 @@ typedef struct {
 \r
     const SKP_Silk_NLSF_CB_struct *psNLSF_CB[ 2 ];      /* Pointers to voiced/unvoiced NLSF codebooks */\r
 \r
-    SKP_int         sigtype[               MAX_FRAMES_PER_PACKET ];\r
-    SKP_int         QuantOffsetType[       MAX_FRAMES_PER_PACKET ];\r
+    SKP_int         signalType[            MAX_FRAMES_PER_PACKET ];\r
+    SKP_int         quantOffsetType[       MAX_FRAMES_PER_PACKET ];\r
     SKP_int         GainsIndices[          MAX_FRAMES_PER_PACKET ][ MAX_NB_SUBFR ];\r
     SKP_int         GainsIndices_EnhLayer[ MAX_FRAMES_PER_PACKET ][ MAX_NB_SUBFR ];\r
     SKP_int         NLSFIndices[           MAX_FRAMES_PER_PACKET ][ NLSF_MSVQ_MAX_CB_STAGES ];\r
@@ -333,7 +322,6 @@ typedef struct {
     SKP_int         LTPIndex[              MAX_FRAMES_PER_PACKET ][ MAX_NB_SUBFR ];\r
     SKP_int         LTP_scaleIndex[        MAX_FRAMES_PER_PACKET ];\r
     SKP_int         Seed[                  MAX_FRAMES_PER_PACKET ];\r
-    SKP_int         vadFlagBuf[            MAX_FRAMES_PER_PACKET ];\r
     \r
     /* Parameters used to investigate if inband FEC is used */\r
     SKP_int         vadFlag;\r
@@ -345,7 +333,7 @@ typedef struct {
 \r
     /* Stuff used for PLC */\r
     SKP_int         lossCnt;\r
-    SKP_int         prev_sigtype;                               /* Previous sigtype                                                     */\r
+    SKP_int         prevSignalType;\r
 \r
     SKP_Silk_PLC_struct sPLC;\r
 \r
@@ -367,8 +355,8 @@ typedef struct {
     /* quantization indices */\r
     SKP_int             PERIndex;\r
     SKP_int             RateLevelIndex;\r
-    SKP_int             QuantOffsetType;\r
-    SKP_int             sigtype;\r
+    SKP_int             quantOffsetType;\r
+    SKP_int             signalType;\r
     SKP_int             NLSFInterpCoef_Q2;\r
 } SKP_Silk_decoder_control;\r
 \r
index 7dd008a..30a5ac6 100644 (file)
@@ -40,7 +40,7 @@ extern "C"
 #endif\r
 \r
 /* entropy coding tables */\r
-extern const SKP_uint8  SKP_Silk_gain_iCDF[ 2 ][ N_LEVELS_QGAIN / 8 ];                               /* 16 */\r
+extern const SKP_uint8  SKP_Silk_gain_iCDF[ 3 ][ N_LEVELS_QGAIN / 8 ];                               /* 24 */\r
 extern const SKP_uint8  SKP_Silk_delta_gain_iCDF[ MAX_DELTA_GAIN_QUANT - MIN_DELTA_GAIN_QUANT + 1 ]; /* 43 */\r
 \r
 extern const SKP_uint8  SKP_Silk_pitch_lag_iCDF[ 2 * ( PITCH_EST_MAX_LAG_MS - PITCH_EST_MIN_LAG_MS ) ];  /* 32 */\r
@@ -50,21 +50,19 @@ extern const SKP_uint8  SKP_Silk_pitch_contour_NB_iCDF[ 11 ];
 extern const SKP_uint8 SKP_Silk_pitch_contour_10_ms_iCDF[12];                                       /*  12 */\r
 extern const SKP_uint8 SKP_Silk_pitch_contour_10_ms_NB_iCDF[3];                                     /*   3 */\r
 \r
-extern const SKP_uint16 SKP_Silk_pulses_per_block_CDF[ N_RATE_LEVELS ][ MAX_PULSES + 3 ];           /* 210 */\r
-extern const SKP_int    SKP_Silk_pulses_per_block_CDF_offset;\r
-extern const SKP_int16  SKP_Silk_pulses_per_block_BITS_Q6[ N_RATE_LEVELS - 1 ][ MAX_PULSES + 2 ];   /* 180 */\r
+extern const SKP_uint8  SKP_Silk_pulses_per_block_iCDF[ N_RATE_LEVELS ][ MAX_PULSES + 2 ];          /* 180 */\r
+extern const SKP_uint8  SKP_Silk_pulses_per_block_BITS_Q5[ N_RATE_LEVELS - 1 ][ MAX_PULSES + 2 ];   /* 162 */\r
 \r
-extern const SKP_uint16 SKP_Silk_rate_levels_CDF[ 2 ][ N_RATE_LEVELS ];                             /*  20 */\r
-extern const SKP_int    SKP_Silk_rate_levels_CDF_offset;\r
-extern const SKP_int16  SKP_Silk_rate_levels_BITS_Q6[ 2 ][ N_RATE_LEVELS - 1 ];                     /*  18 */\r
+extern const SKP_uint8  SKP_Silk_rate_levels_iCDF[ 2 ][ N_RATE_LEVELS - 1 ];                        /*  18 */\r
+extern const SKP_uint8  SKP_Silk_rate_levels_BITS_Q5[ 2 ][ N_RATE_LEVELS - 1 ];                     /*  18 */\r
 \r
-extern const SKP_int    SKP_Silk_max_pulses_table[ 4 ];                                             /*   4 */\r
+extern const SKP_uint8  SKP_Silk_max_pulses_table[ 4 ];                                             /*   4 */\r
 \r
-extern const SKP_uint16 SKP_Silk_shell_code_table0[  33 ];                                          /*  33 */\r
-extern const SKP_uint16 SKP_Silk_shell_code_table1[  52 ];                                          /*  52 */\r
-extern const SKP_uint16 SKP_Silk_shell_code_table2[ 102 ];                                          /* 102 */\r
-extern const SKP_uint16 SKP_Silk_shell_code_table3[ 207 ];                                          /* 207 */\r
-extern const SKP_uint16 SKP_Silk_shell_code_table_offsets[ 19 ];                                    /*  19 */\r
+extern const SKP_uint8  SKP_Silk_shell_code_table0[  44 ];                                          /*  44 */\r
+extern const SKP_uint8  SKP_Silk_shell_code_table1[  65 ];                                          /*  65 */\r
+extern const SKP_uint8  SKP_Silk_shell_code_table2[  90 ];                                          /*  90 */\r
+extern const SKP_uint8  SKP_Silk_shell_code_table3[ 152 ];                                          /* 152 */\r
+extern const SKP_uint8  SKP_Silk_shell_code_table_offsets[ MAX_PULSES + 1 ];                        /*  17 */\r
 \r
 extern const SKP_uint8  SKP_Silk_lsb_iCDF[ 2 ];                                                     /*   2 */\r
 \r
@@ -77,7 +75,7 @@ extern const SKP_uint8  SKP_Silk_uniform12_iCDF[ 12 ];
 \r
 extern const SKP_uint8  SKP_Silk_LTP_per_index_iCDF[ 3 ];                                           /*   3 */\r
 extern const SKP_uint8  * const SKP_Silk_LTP_gain_iCDF_ptrs[ NB_LTP_CBKS ];                         /*   3 */\r
-extern const SKP_int8   * const SKP_Silk_LTP_gain_BITS_Q4_ptrs[ NB_LTP_CBKS ];                      /*   3 */\r
+extern const SKP_uint8  * const SKP_Silk_LTP_gain_BITS_Q5_ptrs[ NB_LTP_CBKS ];                      /*   3 */\r
 extern const SKP_int16  SKP_Silk_LTP_gain_middle_avg_RD_Q14;\r
 extern const SKP_int8   * const SKP_Silk_LTP_vq_ptrs_Q7[ NB_LTP_CBKS ];                             /* 168 */\r
 extern const SKP_int8   SKP_Silk_LTP_vq_sizes[ NB_LTP_CBKS ];                                       /*   3 */\r
@@ -85,10 +83,8 @@ extern const SKP_int8   SKP_Silk_LTP_vq_sizes[ NB_LTP_CBKS ];
 extern const SKP_uint8  SKP_Silk_LTPscale_iCDF[ 3 ];                                                /*   4 */\r
 extern const SKP_int16  SKP_Silk_LTPScales_table_Q14[ 3 ];\r
 \r
-extern const SKP_uint8  SKP_Silk_vadflag_iCDF[ 2 ];                                                 /*   2 */\r
-\r
-extern const SKP_uint8 SKP_Silk_type_offset_iCDF[4];                                                /*   4 */\r
-extern const SKP_uint8 SKP_Silk_type_offset_joint_iCDF[4][4];                                       /*  16 */\r
+const SKP_uint8 SKP_Silk_type_offset_iCDF[6];                                                       /*   6 */\r
+const SKP_uint8 SKP_Silk_type_offset_joint_iCDF[6][6];                                              /*  36 */\r
 \r
 extern const SKP_uint8  SKP_Silk_NLSF_interpolation_factor_iCDF[ 5 ];                               /*   5 */\r
 \r
index 65b5799..2433d7c 100644 (file)
@@ -28,41 +28,41 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "SKP_Silk_tables.h"\r
 \r
 const SKP_uint8 SKP_Silk_LTP_per_index_iCDF[3] = {\r
-          188,    111,      0\r
+          179,     99,      0\r
 };\r
 \r
 const SKP_uint8 SKP_Silk_LTP_gain_iCDF_0[8] = {\r
-           83,     65,     48,     34,     24,     15,      7,      0\r
+           71,     56,     43,     30,     21,     12,      6,      0\r
 };\r
 \r
 const SKP_uint8 SKP_Silk_LTP_gain_iCDF_1[16] = {\r
-          211,    186,    163,    144,    129,    115,    102,     89,\r
-           77,     65,     53,     42,     31,     19,      9,      0\r
+          199,    165,    144,    124,    109,     96,     84,     71,\r
+           61,     51,     42,     32,     23,     15,      8,      0\r
 };\r
 \r
 const SKP_uint8 SKP_Silk_LTP_gain_iCDF_2[32] = {\r
-          241,    227,    214,    202,    191,    180,    170,    160,\r
-          149,    139,    129,    120,    110,    101,     92,     84,\r
-           76,     69,     61,     54,     47,     40,     35,     30,\r
-           26,     21,     17,     13,     10,      6,      3,      0\r
+          241,    225,    211,    199,    187,    175,    164,    153,\r
+          142,    132,    123,    114,    105,     96,     88,     80,\r
+           72,     64,     57,     50,     44,     38,     33,     29,\r
+           24,     20,     16,     12,      9,      5,      2,      0\r
 };\r
 \r
-const SKP_int16 SKP_Silk_LTP_gain_middle_avg_RD_Q14 = 14008;\r
+const SKP_int16 SKP_Silk_LTP_gain_middle_avg_RD_Q14 = 12304;\r
 \r
-const SKP_int8 SKP_Silk_LTP_gain_BITS_Q4_0[8] = {\r
-            9,     61,     63,     66,     76,     77,     81,     83\r
+const SKP_uint8 SKP_Silk_LTP_gain_BITS_Q5_0[8] = {\r
+           15,    131,    138,    138,    155,    155,    173,    173\r
 };\r
 \r
-const SKP_int8 SKP_Silk_LTP_gain_BITS_Q4_1[16] = {\r
-           40,     54,     56,     60,     65,     68,     68,     68,\r
-           71,     71,     72,     72,     72,     72,     76,     76\r
+const SKP_uint8 SKP_Silk_LTP_gain_BITS_Q5_1[16] = {\r
+           69,     93,    115,    118,    131,    138,    141,    138,\r
+          150,    150,    155,    150,    155,    160,    166,    160\r
 };\r
 \r
-const SKP_int8 SKP_Silk_LTP_gain_BITS_Q4_2[32] = {\r
-           65,     67,     69,     70,     73,     74,     74,     74,\r
-           74,     75,     75,     76,     76,     76,     78,     80,\r
-           80,     81,     82,     82,     82,     86,     90,     91,\r
-           92,     95,     95,     96,     99,    100,    102,    102\r
+const SKP_uint8 SKP_Silk_LTP_gain_BITS_Q5_2[32] = {\r
+          131,    128,    134,    141,    141,    141,    145,    145,\r
+          145,    150,    155,    155,    155,    155,    160,    160,\r
+          160,    160,    166,    166,    173,    173,    182,    192,\r
+          182,    192,    192,    192,    205,    192,    205,    224\r
 };\r
 \r
 const SKP_uint8 * const SKP_Silk_LTP_gain_iCDF_ptrs[NB_LTP_CBKS] = {\r
@@ -71,189 +71,189 @@ const SKP_uint8 * const SKP_Silk_LTP_gain_iCDF_ptrs[NB_LTP_CBKS] = {
     SKP_Silk_LTP_gain_iCDF_2\r
 };\r
 \r
-const SKP_int8 * const SKP_Silk_LTP_gain_BITS_Q4_ptrs[NB_LTP_CBKS] = {\r
-    SKP_Silk_LTP_gain_BITS_Q4_0,\r
-    SKP_Silk_LTP_gain_BITS_Q4_1,\r
-    SKP_Silk_LTP_gain_BITS_Q4_2\r
+const SKP_uint8 * const SKP_Silk_LTP_gain_BITS_Q5_ptrs[NB_LTP_CBKS] = {\r
+    SKP_Silk_LTP_gain_BITS_Q5_0,\r
+    SKP_Silk_LTP_gain_BITS_Q5_1,\r
+    SKP_Silk_LTP_gain_BITS_Q5_2\r
 };\r
 \r
 const SKP_int8 SKP_Silk_LTP_gain_vq_0[8][5] = \r
 {\r
 {\r
-            6,      9,     28,      9,      8\r
+            4,      6,     24,      7,      5\r
 },\r
 {\r
             0,      0,      2,      0,      0\r
 },\r
 {\r
-           -4,     32,     55,      5,     -1\r
+           12,     28,     41,     13,     -4\r
 },\r
 {\r
-           -6,      6,     51,     34,      1\r
+           -9,     15,     42,     25,     14\r
 },\r
 {\r
-           27,      8,     43,     26,    -20\r
+            1,     -2,     62,     41,     -9\r
 },\r
 {\r
-            2,      5,     11,      5,      3\r
+          -10,     37,     65,     -4,      3\r
 },\r
 {\r
-          -23,      8,     35,      4,     22\r
+           -6,      4,     66,      7,     -8\r
 },\r
 {\r
-           22,     18,     26,     -6,    -14\r
+           16,     14,     38,     -3,     33\r
 }\r
 };\r
 \r
 const SKP_int8 SKP_Silk_LTP_gain_vq_1[16][5] = \r
 {\r
 {\r
-           10,     22,     39,     23,     17\r
+           13,     22,     39,     23,     12\r
 },\r
 {\r
-            5,     29,     56,     38,     -8\r
+           -1,     36,     64,     27,     -6\r
 },\r
 {\r
-           20,     40,     54,      4,     -5\r
+           -7,     10,     55,     43,     17\r
 },\r
 {\r
-            0,      1,      7,      0,      1\r
+            1,      1,      8,      1,      1\r
 },\r
 {\r
-          -20,     12,     67,     46,      9\r
+            6,    -11,     74,     53,     -9\r
 },\r
 {\r
-           -9,     51,     75,     12,    -12\r
+          -12,     55,     76,    -12,      8\r
 },\r
 {\r
-            6,    -11,     84,     41,    -14\r
+           -3,      3,     93,     27,     -4\r
 },\r
 {\r
-           -8,     15,     96,      5,      3\r
+           26,     39,     59,      3,     -8\r
 },\r
 {\r
-           41,      5,     32,      4,     10\r
+            2,      0,     77,     11,      9\r
 },\r
 {\r
-          -13,     50,     73,    -18,     18\r
+           -8,     22,     44,     -6,      7\r
 },\r
 {\r
-            7,    -14,     56,     47,     10\r
+           40,      9,     26,      3,      9\r
 },\r
 {\r
-           -3,     -2,     73,      8,     10\r
+           -7,     20,    101,     -7,      4\r
 },\r
 {\r
-          -11,     30,     42,     -7,     14\r
+            3,     -8,     42,     26,      0\r
 },\r
 {\r
-          -23,     42,     57,     15,     21\r
+          -15,     33,     68,      2,     23\r
 },\r
 {\r
-           -1,      0,     21,     23,     38\r
+           -2,     55,     46,     -2,     15\r
 },\r
 {\r
-           -1,     -6,     37,     20,     -3\r
+            3,     -1,     21,     16,     41\r
 }\r
 };\r
 \r
 const SKP_int8 SKP_Silk_LTP_gain_vq_2[32][5] = \r
 {\r
 {\r
-           -6,     59,     68,      3,      0\r
+           -6,     27,     61,     39,      5\r
 },\r
 {\r
-           -6,     36,     72,     29,     -6\r
+          -11,     42,     88,      4,      1\r
 },\r
 {\r
-           -3,      1,     93,     24,      6\r
+           -2,     60,     65,      6,     -4\r
 },\r
 {\r
-           -4,     16,     52,     39,     19\r
+           -1,     -5,     73,     56,      1\r
 },\r
 {\r
-            0,    -11,     80,     52,      1\r
+           -9,     19,     94,     29,     -9\r
 },\r
 {\r
-            3,      4,     19,      3,      6\r
+            0,     12,     99,      6,      4\r
 },\r
 {\r
-           -3,     35,     98,      5,    -13\r
+            8,    -19,    102,     46,    -13\r
 },\r
 {\r
-           -9,     16,     75,     60,    -15\r
+            3,      2,     13,      3,      2\r
 },\r
 {\r
-            9,    -21,     84,     71,    -17\r
+            9,    -21,     84,     72,    -18\r
 },\r
 {\r
-           11,    -20,    106,     44,    -13\r
+          -11,     46,    104,    -22,      8\r
 },\r
 {\r
-            3,      9,     98,     33,    -23\r
+           18,     38,     48,     23,      0\r
 },\r
 {\r
-           22,     -4,     65,     51,    -15\r
+          -16,     70,     83,    -21,     11\r
 },\r
 {\r
-           -6,     11,    109,      7,      2\r
+            5,    -11,    117,     22,     -8\r
 },\r
 {\r
-           21,     38,     41,     22,      4\r
+           -6,     23,    117,    -12,      3\r
 },\r
 {\r
-          -19,     72,     83,    -22,     13\r
+            3,     -8,     95,     28,      4\r
 },\r
 {\r
-            1,     24,     77,     -5,     17\r
+          -10,     15,     77,     60,    -15\r
 },\r
 {\r
-            4,    -12,    121,     19,     -6\r
+           -1,      4,    124,      2,     -4\r
 },\r
 {\r
-           -6,     25,    115,    -17,      7\r
+            3,     38,     84,     24,    -25\r
 },\r
 {\r
-           27,     11,     84,     12,    -27\r
+            2,     13,     42,     13,     31\r
 },\r
 {\r
-          -13,     49,    105,    -24,      8\r
+           21,     -4,     56,     46,     -1\r
 },\r
 {\r
-          -21,     43,     91,     -4,     15\r
+           -1,     35,     79,    -13,     19\r
 },\r
 {\r
-            7,     49,     88,    -25,     -4\r
+           -7,     65,     88,     -9,    -14\r
 },\r
 {\r
-            0,      5,    128,     -5,     -4\r
+           20,      4,     81,     49,    -29\r
 },\r
 {\r
-           -9,     67,     95,     -4,    -23\r
+           20,      0,     75,      3,    -17\r
 },\r
 {\r
-            6,    -10,     45,     93,     -9\r
+            5,     -9,     44,     92,     -8\r
 },\r
 {\r
-           -8,     95,     43,    -11,      6\r
+            1,     -3,     22,     69,     31\r
 },\r
 {\r
-           17,    -19,    101,     77,    -42\r
+           -6,     95,     41,    -12,      5\r
 },\r
 {\r
-           35,     74,     19,     -7,      1\r
+           39,     67,     16,     -4,      1\r
 },\r
 {\r
-            3,     12,    128,     27,    -39\r
+            0,     -6,    120,     55,    -36\r
 },\r
 {\r
-            1,     -2,     14,     80,     31\r
+          -13,     44,    122,      4,    -24\r
 },\r
 {\r
-           86,     10,     12,     -3,      3\r
+           81,      5,     11,      3,      7\r
 },\r
 {\r
-            5,     -3,     14,      7,     85\r
+            2,      0,      9,     10,     88\r
 }\r
 };\r
 \r
index 87e13be..905d72c 100644 (file)
@@ -37,63 +37,63 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 \r
 const SKP_uint8 SKP_Silk_NLSF_MSVQ_CB0_10_CDF[ NLSF_MSVQ_CB0_10_VECTORS ] =\r
 {\r
-          244,\r
-          236,\r
-          228,\r
-          220,\r
-          213,\r
-          207,\r
-          201,\r
-          195,\r
-          190,\r
-          184,\r
-          179,\r
-          173,\r
-          168,\r
-          163,\r
+          246,\r
+          237,\r
+          230,\r
+          223,\r
+          216,\r
+          210,\r
+          204,\r
+          198,\r
+          192,\r
+          186,\r
+          180,\r
+          175,\r
+          169,\r
+          164,\r
           158,\r
           153,\r
-          148,\r
-          143,\r
-          139,\r
-          134,\r
-          129,\r
-          125,\r
-          120,\r
-          116,\r
-          112,\r
-          107,\r
-          103,\r
-           99,\r
-           95,\r
-           91,\r
-           88,\r
-           84,\r
-           80,\r
-           77,\r
-           73,\r
-           69,\r
-           66,\r
-           62,\r
-           59,\r
-           55,\r
-           52,\r
-           48,\r
-           45,\r
-           42,\r
-           39,\r
-           36,\r
+          147,\r
+          142,\r
+          137,\r
+          132,\r
+          127,\r
+          123,\r
+          118,\r
+          113,\r
+          109,\r
+          105,\r
+          101,\r
+           97,\r
+           93,\r
+           89,\r
+           85,\r
+           81,\r
+           78,\r
+           74,\r
+           71,\r
+           67,\r
+           64,\r
+           60,\r
+           57,\r
+           54,\r
+           50,\r
+           47,\r
+           44,\r
+           41,\r
+           38,\r
+           35,\r
            32,\r
            29,\r
            27,\r
            24,\r
            21,\r
-           18,\r
+           19,\r
            16,\r
-           13,\r
-           11,\r
-            9,\r
-            7,\r
+           14,\r
+           12,\r
+           10,\r
+            8,\r
             6,\r
             5,\r
             4,\r
@@ -101,68 +101,68 @@ const SKP_uint8 SKP_Silk_NLSF_MSVQ_CB0_10_CDF[ NLSF_MSVQ_CB0_10_VECTORS ] =
             2,\r
             1,\r
             0,\r
-          235,\r
+          234,\r
           216,\r
           198,\r
           180,\r
           162,\r
           145,\r
-          129,\r
-          112,\r
-           96,\r
-           80,\r
-           65,\r
+          128,\r
+          111,\r
+           95,\r
+           79,\r
+           64,\r
            50,\r
-           36,\r
-           22,\r
+           37,\r
+           23,\r
            10,\r
             0,\r
-          222,\r
-          189,\r
-          155,\r
-          123,\r
-           92,\r
-           62,\r
-           31,\r
-            0,\r
           221,\r
-          187,\r
+          188,\r
           154,\r
-          122,\r
+          123,\r
            91,\r
-           60,\r
-           29,\r
+           59,\r
+           28,\r
             0,\r
           220,\r
-          186,\r
-          154,\r
-          122,\r
-           90,\r
-           60,\r
-           29,\r
+          185,\r
+          151,\r
+          118,\r
+           85,\r
+           51,\r
+           26,\r
             0,\r
-          223,\r
-          189,\r
-          156,\r
-          124,\r
-           92,\r
-           60,\r
-           29,\r
+          220,\r
+          185,\r
+          150,\r
+          116,\r
+           86,\r
+           55,\r
+           26,\r
+            0,\r
+          220,\r
+          185,\r
+          152,\r
+          118,\r
+           88,\r
+           57,\r
+           28,\r
             0,\r
           236,\r
-          219,\r
-          201,\r
-          184,\r
-          168,\r
-          151,\r
-          134,\r
-          117,\r
-          101,\r
-           85,\r
-           69,\r
-           53,\r
-           38,\r
-           24,\r
+          217,\r
+          199,\r
+          181,\r
+          164,\r
+          146,\r
+          130,\r
+          113,\r
+           97,\r
+           81,\r
+           66,\r
+           51,\r
+           37,\r
+           23,\r
            11,\r
             0\r
 };\r
@@ -180,70 +180,70 @@ const SKP_uint8 * const SKP_Silk_NLSF_MSVQ_CB0_10_CDF_start_ptr[ NLSF_MSVQ_CB0_1
 \r
 const SKP_uint8 SKP_Silk_NLSF_MSVQ_CB0_10_rates_Q4[ NLSF_MSVQ_CB0_10_VECTORS ] =\r
 {\r
-               71,               79,\r
-               80,               81,\r
+               74,               79,\r
+               83,               83,\r
                84,               85,\r
-               87,               88,\r
+               85,               87,\r
+               87,               87,\r
                88,               88,\r
                89,               89,\r
-               90,               90,\r
+               89,               89,\r
+               89,               89,\r
                91,               91,\r
                92,               92,\r
-               92,               92,\r
-               93,               93,\r
+               92,               94,\r
                94,               94,\r
-               94,               95,\r
-               96,               96,\r
+               95,               96,\r
                96,               97,\r
                97,               98,\r
-               98,               98,\r
-               98,               98,\r
-               99,               99,\r
-               99,               99,\r
+               98,               99,\r
                99,              100,\r
-              100,              101,\r
+              100,              100,\r
+              100,              100,\r
+              101,              101,\r
               102,              102,\r
               102,              103,\r
-              104,              104,\r
+              103,              105,\r
               105,              105,\r
-              105,              108,\r
-              111,              111,\r
-              114,              123,\r
+              106,              106,\r
+              108,              108,\r
+              109,              111,\r
+              111,              121,\r
+              124,              128,\r
               128,              128,\r
               128,              128,\r
-              128,              128,\r
-               58,               60,\r
+               57,               61,\r
                61,               61,\r
-               62,               63,\r
+               61,               63,\r
                63,               63,\r
                64,               64,\r
-               65,               66,\r
-               67,               68,\r
-               69,               76,\r
-               47,               47,\r
-               47,               48,\r
-               49,               49,\r
-               49,               49,\r
+               65,               67,\r
+               68,               68,\r
+               69,               74,\r
                46,               47,\r
                47,               48,\r
-               49,               49,\r
-               49,               50,\r
-               45,               47,\r
                48,               48,\r
-               48,               49,\r
-               49,               50,\r
+               49,               51,\r
+               45,               46,\r
                47,               47,\r
-               47,               48,\r
-               48,               48,\r
-               49,               50,\r
-               59,               62,\r
-               62,               63,\r
-               63,               63,\r
+               47,               47,\r
+               53,               53,\r
+               45,               46,\r
+               46,               47,\r
+               49,               49,\r
+               50,               53,\r
+               45,               46,\r
+               47,               47,\r
+               49,               49,\r
+               50,               51,\r
+               59,               60,\r
+               61,               61,\r
+               62,               62,\r
                63,               63,\r
                64,               64,\r
-               64,               64,\r
-               65,               68,\r
-               68,               73\r
+               65,               65,\r
+               67,               67,\r
+               71,               72\r
 };\r
 \r
 const SKP_int SKP_Silk_NLSF_MSVQ_CB0_10_ndelta_min_Q15[ 10 + 1 ] =\r
@@ -263,646 +263,646 @@ const SKP_int SKP_Silk_NLSF_MSVQ_CB0_10_ndelta_min_Q15[ 10 + 1 ] =
 \r
 const SKP_int8 SKP_Silk_NLSF_MSVQ_CB0_10_Q8[ 10 * NLSF_MSVQ_CB0_10_VECTORS ] =\r
 {\r
-             -109,              -96,\r
+             -107,              -97,\r
               -74,              -56,\r
-              -35,              -11,\r
-               17,               45,\r
-               74,              100,\r
+              -37,               -8,\r
+               20,               48,\r
+               75,              100,\r
+             -109,              -91,\r
+              -71,              -48,\r
+              -20,               -1,\r
+               23,               47,\r
+               77,              100,\r
+             -100,              -93,\r
+              -78,              -50,\r
+               -5,                8,\r
+               28,               53,\r
+               72,               93,\r
+             -105,              -97,\r
+              -82,              -49,\r
+              -16,               -5,\r
+               33,               52,\r
+               72,              100,\r
               -98,              -92,\r
-              -76,              -40,\r
-              -10,                0,\r
-               28,               47,\r
-               65,              103,\r
-             -107,              -92,\r
-              -69,              -48,\r
-              -16,                4,\r
-               29,               49,\r
-               77,              101,\r
-             -104,              -94,\r
-              -81,              -60,\r
-              -24,              -10,\r
-               13,               49,\r
-               67,               94,\r
-             -104,              -97,\r
-              -81,              -51,\r
-                2,               18,\r
-               33,               53,\r
-               70,              101,\r
-             -104,              -96,\r
-              -82,              -54,\r
-              -10,                3,\r
-               26,               51,\r
-               70,               89,\r
-             -109,              -99,\r
-              -84,              -53,\r
-              -33,              -18,\r
-               22,               36,\r
-               77,               96,\r
-              -92,              -86,\r
-              -70,              -37,\r
-              -25,              -10,\r
-               24,               40,\r
-               79,               95,\r
-             -102,              -95,\r
-              -78,              -47,\r
-              -32,              -17,\r
-               34,               52,\r
-               71,              105,\r
-             -113,             -106,\r
-              -85,              -60,\r
-              -34,              -15,\r
-               15,               40,\r
-               63,               93,\r
-              -99,              -94,\r
-              -64,              -18,\r
-               -6,               10,\r
-               32,               47,\r
-               88,              104,\r
-             -115,             -108,\r
-              -79,              -48,\r
-              -21,                0,\r
-               28,               55,\r
-               77,              101,\r
-              -94,              -88,\r
-              -69,              -32,\r
-                5,               16,\r
-               37,               57,\r
-               75,              103,\r
-             -110,             -101,\r
-              -87,              -58,\r
-              -12,                1,\r
-               19,               38,\r
-               65,              101,\r
-             -103,              -96,\r
-              -80,              -40,\r
-              -26,              -11,\r
-                8,               26,\r
-               78,               93,\r
-             -104,              -98,\r
-              -83,              -35,\r
-              -21,               -7,\r
-               30,               43,\r
-               88,              104,\r
-             -105,             -100,\r
-              -78,              -21,\r
-               -7,                6,\r
-               28,               45,\r
-               77,               92,\r
-             -102,              -95,\r
-              -71,              -34,\r
-              -21,               -1,\r
-               22,               41,\r
-               66,               83,\r
-              -98,              -91,\r
-              -71,              -60,\r
-              -49,               -4,\r
-               20,               36,\r
-               85,              101,\r
-              -86,              -80,\r
-              -61,              -28,\r
+              -75,              -39,\r
               -10,                1,\r
+               24,               41,\r
+               62,              103,\r
+              -99,              -92,\r
+              -74,              -44,\r
+              -30,              -16,\r
+               33,               51,\r
+               69,              105,\r
+             -105,              -98,\r
+              -82,              -51,\r
+                5,               19,\r
                35,               54,\r
+               73,              102,\r
+             -110,             -101,\r
+              -85,              -61,\r
+              -40,              -24,\r
+               12,               45,\r
+               67,               97,\r
+             -104,              -95,\r
+              -81,              -61,\r
+              -22,               -8,\r
+               14,               50,\r
+               68,               88,\r
+              -96,              -90,\r
+              -74,              -44,\r
+              -30,              -16,\r
+               20,               34,\r
+               74,               90,\r
+              -89,              -83,\r
+              -64,              -27,\r
+              -11,                0,\r
+               36,               54,\r
                74,              103,\r
-             -107,             -100,\r
-              -81,              -45,\r
-              -35,                2,\r
-               25,               45,\r
-               83,               99,\r
-             -103,              -97,\r
-              -73,              -33,\r
-               17,               30,\r
-               45,               64,\r
-               81,              105,\r
-              -86,              -79,\r
-              -59,              -41,\r
-              -29,              -14,\r
-               41,               59,\r
-               78,              105,\r
-              -87,              -76,\r
-              -62,              -45,\r
-              -23,              -10,\r
-               20,               44,\r
-               63,               96,\r
-             -108,              -99,\r
-              -73,              -53,\r
-              -28,                7,\r
-               27,               42,\r
-               60,               94,\r
-              -95,              -87,\r
-              -72,              -54,\r
-              -40,              -26,\r
-               24,               42,\r
-               60,              102,\r
-              -96,              -89,\r
-              -73,              -59,\r
-              -49,              -25,\r
+             -102,              -96,\r
+              -71,              -28,\r
+              -16,                1,\r
+               21,               40,\r
+               71,               86,\r
+             -102,              -96,\r
+              -80,              -32,\r
+              -19,               -4,\r
                31,               45,\r
+               88,              103,\r
+              -90,              -83,\r
+              -66,              -51,\r
+              -40,              -20,\r
+               43,               62,\r
+               81,              105,\r
+             -115,             -108,\r
+              -79,              -49,\r
+              -21,                0,\r
+               26,               54,\r
+               78,              100,\r
+             -105,              -93,\r
+              -78,              -59,\r
+              -28,              -14,\r
+               11,               32,\r
+               57,               96,\r
+             -101,              -96,\r
+              -68,              -17,\r
+               -5,                9,\r
+               30,               46,\r
+               87,              103,\r
+             -109,             -101,\r
+              -87,              -59,\r
+              -10,                5,\r
+               23,               41,\r
+               63,              100,\r
+              -86,              -78,\r
+              -63,              -45,\r
+              -28,              -15,\r
+               26,               43,\r
+               63,              102,\r
+             -106,              -98,\r
+              -83,              -41,\r
+              -21,               -7,\r
+               13,               30,\r
                80,               96,\r
-             -100,              -94,\r
-              -77,              -67,\r
-              -56,              -14,\r
-               41,               59,\r
-               85,              104,\r
-              -96,              -91,\r
-              -65,              -30,\r
-              -18,               -4,\r
-               14,               28,\r
-               82,              105,\r
-             -102,              -95,\r
-              -59,              -41,\r
-              -29,               10,\r
-               31,               52,\r
+              -94,              -88,\r
+              -67,              -30,\r
+                7,               18,\r
+               37,               55,\r
+               73,              102,\r
+              -96,              -90,\r
+              -73,              -61,\r
+              -51,              -15,\r
+               30,               44,\r
                83,               99,\r
-             -103,              -97,\r
-              -78,              -66,\r
-              -54,                1,\r
+             -112,             -105,\r
+              -84,              -61,\r
+              -35,               -3,\r
+               21,               39,\r
+               61,               92,\r
+             -105,              -98,\r
+              -80,              -49,\r
+              -38,               -2,\r
+               17,               38,\r
+               79,               94,\r
+              -86,              -78,\r
+              -66,              -48,\r
+              -12,                1,\r
+               25,               51,\r
+               71,               94,\r
+             -108,             -102,\r
+              -83,              -30,\r
+                0,               10,\r
+               35,               51,\r
+               82,              100,\r
+             -107,              -99,\r
+              -84,              -70,\r
+              -58,              -14,\r
+               17,               40,\r
+               75,               97,\r
+              -94,              -88,\r
+              -62,              -32,\r
+              -20,               -6,\r
+               10,               28,\r
+               86,              105,\r
+              -97,              -91,\r
+              -72,              -62,\r
+              -50,                1,\r
+               18,               43,\r
+               68,               84,\r
+             -103,              -98,\r
+              -72,              -32,\r
+               17,               31,\r
+               47,               66,\r
+               83,              105,\r
+              -99,              -90,\r
+              -76,              -61,\r
+              -49,              -33,\r
+               21,               40,\r
+               63,              100,\r
+              -86,              -80,\r
+              -60,              -43,\r
+              -32,              -13,\r
+               26,               39,\r
+               84,              104,\r
+             -102,              -96,\r
+              -61,              -33,\r
+              -23,               13,\r
+               31,               54,\r
+               85,              100,\r
+             -110,             -100,\r
+              -87,              -52,\r
+              -35,              -20,\r
+               28,               41,\r
+               83,              102,\r
+              -91,              -84,\r
+              -58,              -45,\r
+              -36,               -2,\r
                22,               42,\r
-               70,               87,\r
-             -109,             -101,\r
-              -86,              -70,\r
-              -57,              -17,\r
-               19,               41,\r
-               75,               98,\r
-              -87,              -80,\r
-              -67,              -51,\r
-               -7,                6,\r
-               26,               54,\r
-               74,               94,\r
-             -101,              -91,\r
-              -76,              -52,\r
-              -27,              -14,\r
-                8,               27,\r
-               54,               96,\r
-              -99,              -93,\r
-              -65,              -51,\r
-              -39,              -23,\r
-              -10,               48,\r
-               79,               95,\r
-             -100,              -95,\r
-              -54,              -37,\r
-              -25,               -9,\r
-                5,               51,\r
-               74,               89,\r
-             -113,             -107,\r
-              -93,              -70,\r
-              -27,                1,\r
-               23,               46,\r
-               72,               96,\r
-              -96,              -86,\r
-              -67,              -40,\r
-              -22,              -10,\r
-               21,               62,\r
-               80,              100,\r
-              -93,              -87,\r
-              -65,              -49,\r
-              -37,              -10,\r
-               11,               30,\r
-               67,               82,\r
-             -106,              -97,\r
-              -83,              -64,\r
-              -51,              -33,\r
-               20,               52,\r
-               72,              100,\r
+               72,               85,\r
+             -105,              -96,\r
+              -66,              -47,\r
+              -24,               11,\r
+               31,               45,\r
+               63,               91,\r
               -93,              -87,\r
-              -65,              -55,\r
-              -41,                6,\r
-               27,               46,\r
-               70,               84,\r
-             -109,             -103,\r
-              -86,              -37,\r
-                1,               11,\r
-               34,               50,\r
-               84,              100,\r
-             -105,              -99,\r
-              -61,               -7,\r
-                6,               20,\r
+              -70,              -45,\r
+              -31,              -18,\r
+               -2,               14,\r
+               69,              105,\r
+              -98,              -93,\r
+              -61,              -48,\r
+              -35,              -19,\r
+               -6,               44,\r
+               69,               85,\r
+             -101,              -94,\r
+              -77,              -56,\r
+              -43,              -24,\r
+               -7,               18,\r
+               73,               92,\r
+             -102,              -95,\r
+              -77,              -48,\r
+              -34,              -15,\r
+                5,               30,\r
+               55,               79,\r
+             -100,              -95,\r
+              -50,              -32,\r
+              -22,               -5,\r
+               10,               52,\r
+               77,               91,\r
+             -114,             -109,\r
+              -94,              -71,\r
+              -27,               -5,\r
+               21,               47,\r
+               74,              100,\r
+              -95,              -80,\r
+              -65,              -46,\r
+              -27,              -15,\r
+               16,               61,\r
+               79,               98,\r
+             -105,             -100,\r
+              -62,               -7,\r
+                7,               20,\r
+               44,               61,\r
+               87,              102,\r
+             -101,              -95,\r
+              -81,              -66,\r
+              -57,              -26,\r
+               40,               57,\r
+               83,              104,\r
+              -97,              -92,\r
+              -66,              -53,\r
+              -43,               11,\r
+               32,               49,\r
+               89,              102,\r
+              -99,              -91,\r
+              -75,              -57,\r
+              -45,              -29,\r
+               19,               64,\r
+               83,              101,\r
+              -91,              -85,\r
+              -66,              -55,\r
+              -44,               -9,\r
+               11,               27,\r
+               83,               99,\r
+             -107,              -99,\r
+              -83,              -59,\r
+               -9,               29,\r
                43,               61,\r
-               86,              101,\r
-              -96,              -88,\r
-              -73,              -54,\r
-              -40,              -25,\r
-               18,               64,\r
-               82,              100,\r
-              -90,              -83,\r
-              -67,              -56,\r
-              -45,              -18,\r
-               47,               67,\r
-               85,              106,\r
-             -103,              -95,\r
-              -80,              -57,\r
-              -45,              -24,\r
-               -4,               19,\r
-               70,               92,\r
-              -93,              -87,\r
-              -69,              -47,\r
-              -34,              -20,\r
-               -5,               12,\r
-               75,              106,\r
-              -87,              -81,\r
-              -59,              -42,\r
-              -28,               -8,\r
-               10,               30,\r
-               86,              104,\r
-             -107,             -100,\r
-              -85,              -60,\r
-               -8,               28,\r
-               42,               61,\r
-               80,               98,\r
-              -88,              -81,\r
-              -62,              -51,\r
-              -37,                9,\r
-               37,               52,\r
-               88,              103,\r
-              -99,              -94,\r
-              -74,              -66,\r
-              -51,               19,\r
-               41,               57,\r
-               86,              101,\r
-             -103,              -96,\r
-              -76,              -52,\r
-              -39,              -18,\r
-               -1,               34,\r
-               56,               79,\r
-             -104,              -98,\r
-              -44,              -21,\r
-              -11,                9,\r
-               25,               55,\r
-               80,               95,\r
+               81,               99,\r
+             -101,              -96,\r
+              -77,              -68,\r
+              -53,               17,\r
+               35,               53,\r
+               80,               94,\r
+              -99,              -93,\r
+              -65,              -50,\r
+              -37,              -20,\r
+               -7,               51,\r
+               85,              101,\r
+              -97,              -91,\r
+              -72,              -64,\r
+              -49,                2,\r
+               49,               65,\r
+               89,              105,\r
+             -107,              -95,\r
+              -63,              -41,\r
+              -14,               17,\r
+               43,               66,\r
+               89,              106,\r
               -84,              -76,\r
-              -43,              -28,\r
-              -15,                8,\r
-               28,               47,\r
-               79,               95,\r
-             -106,              -95,\r
-              -63,              -39,\r
-              -12,               19,\r
-               45,               68,\r
-               90,              107,\r
-              -83,              -79,\r
-              -61,              -49,\r
-              -41,              -22,\r
-               26,               40,\r
-               81,              105,\r
-              -98,              -93,\r
-              -81,              -73,\r
-              -27,                8,\r
-               28,               58,\r
+              -44,              -28,\r
+              -15,                5,\r
+               25,               44,\r
                78,               95,\r
-              -85,              -72,\r
-              -35,              -11,\r
-                4,               22,\r
-               40,               61,\r
-               83,               99,\r
-              -74,              -70,\r
-              -62,              -37,\r
-              -30,              -17,\r
-               19,               57,\r
-               75,               97,\r
-              -95,              -75,\r
-              -31,              -22,\r
-              -16,              -11,\r
-                5,               56,\r
-               80,              100,\r
-              -82,              -79,\r
-              -75,              -72,\r
-              -23,              -16,\r
-               24,               49,\r
-               78,              105,\r
-              -74,              -70,\r
-              -61,              -50,\r
-              -44,                6,\r
-               29,               50,\r
-               76,               99,\r
+             -102,              -97,\r
+              -42,              -17,\r
+               -7,               13,\r
+               29,               55,\r
+               82,               98,\r
+              -99,              -94,\r
+              -81,              -71,\r
+              -21,                9,\r
+               28,               53,\r
+               76,               95,\r
+              -86,              -79,\r
+              -62,              -53,\r
+              -34,               15,\r
+               37,               54,\r
+               83,               97,\r
               -76,              -73,\r
-              -68,              -51,\r
-              -46,              -40,\r
-               14,               46,\r
+              -57,              -33,\r
+              -26,              -14,\r
+               37,               56,\r
+               76,              103,\r
+              -85,              -71,\r
+              -35,              -10,\r
+                4,               21,\r
+               40,               59,\r
+               84,              100,\r
+              -79,              -77,\r
+              -71,              -63,\r
+              -27,              -18,\r
+               25,               52,\r
+               77,              103,\r
+              -81,              -60,\r
+              -50,              -47,\r
+              -42,                3,\r
+               24,               54,\r
+               80,              104,\r
+              -97,              -79,\r
+              -23,              -16,\r
+              -12,               -9,\r
+                6,               55,\r
+               78,              102,\r
+              -76,              -74,\r
+              -66,              -49,\r
+              -47,              -38,\r
+               14,               47,\r
                75,              101,\r
-              -99,              -51,\r
-              -42,              -39,\r
-              -34,              -25,\r
-               27,               53,\r
-               79,              103,\r
+              -93,              -63,\r
+              -44,              -37,\r
+              -30,              -23,\r
+               28,               52,\r
+               77,              102,\r
+                5,                4,\r
+                6,                5,\r
+                5,                8,\r
+                4,                4,\r
+                0,               -2,\r
+                0,               -1,\r
+               -3,               -3,\r
+               -5,               -6,\r
+              -12,                4,\r
+               -1,               -3,\r
+                2,                1,\r
                 2,                0,\r
-                4,               10,\r
+                1,               -1,\r
+               -1,               -7,\r
+              -12,                6,\r
+               -2,               -3,\r
+               -8,                8,\r
                 6,                5,\r
-                3,                1,\r
-                3,                0,\r
+                1,                2,\r
+                0,               -1,\r
+