]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-3486 --resolve update silk
authorBrian West <brian@freeswitch.org>
Thu, 25 Aug 2011 22:24:46 +0000 (17:24 -0500)
committerBrian West <brian@freeswitch.org>
Thu, 25 Aug 2011 22:25:07 +0000 (17:25 -0500)
148 files changed:
libs/silk/Makefile.am
libs/silk/configure.in
libs/silk/interface/SKP_Silk_SDK_API.h
libs/silk/interface/SKP_Silk_control.h
libs/silk/interface/SKP_Silk_errors.h
libs/silk/interface/SKP_Silk_typedef.h
libs/silk/readme.txt
libs/silk/src/SKP_Silk_A2NLSF.c
libs/silk/src/SKP_Silk_CNG.c
libs/silk/src/SKP_Silk_HP_variable_cutoff_FIX.c
libs/silk/src/SKP_Silk_Inlines.h
libs/silk/src/SKP_Silk_LBRR_reset.c
libs/silk/src/SKP_Silk_LPC_inv_pred_gain.c
libs/silk/src/SKP_Silk_LPC_stabilize.c [deleted file]
libs/silk/src/SKP_Silk_LPC_synthesis_filter.c
libs/silk/src/SKP_Silk_LPC_synthesis_order16.c
libs/silk/src/SKP_Silk_LP_variable_cutoff.c
libs/silk/src/SKP_Silk_LSF_cos_table.c
libs/silk/src/SKP_Silk_LTP_analysis_filter_FIX.c
libs/silk/src/SKP_Silk_LTP_scale_ctrl_FIX.c
libs/silk/src/SKP_Silk_MA.c
libs/silk/src/SKP_Silk_NLSF2A.c
libs/silk/src/SKP_Silk_NLSF2A_stable.c
libs/silk/src/SKP_Silk_NLSF_MSVQ_decode.c
libs/silk/src/SKP_Silk_NLSF_MSVQ_encode_FIX.c
libs/silk/src/SKP_Silk_NLSF_VQ_rate_distortion_FIX.c
libs/silk/src/SKP_Silk_NLSF_VQ_sum_error_FIX.c
libs/silk/src/SKP_Silk_NLSF_VQ_weights_laroia.c
libs/silk/src/SKP_Silk_NLSF_stabilize.c
libs/silk/src/SKP_Silk_NSQ.c
libs/silk/src/SKP_Silk_NSQ_del_dec.c
libs/silk/src/SKP_Silk_PLC.c
libs/silk/src/SKP_Silk_PLC.h
libs/silk/src/SKP_Silk_SigProc_FIX.h
libs/silk/src/SKP_Silk_VAD.c
libs/silk/src/SKP_Silk_VQ_nearest_neighbor_FIX.c
libs/silk/src/SKP_Silk_allpass_int.c [deleted file]
libs/silk/src/SKP_Silk_ana_filt_bank_1.c
libs/silk/src/SKP_Silk_apply_sine_window.c [deleted file]
libs/silk/src/SKP_Silk_array_maxabs.c
libs/silk/src/SKP_Silk_autocorr.c
libs/silk/src/SKP_Silk_biquad.c
libs/silk/src/SKP_Silk_biquad_alt.c
libs/silk/src/SKP_Silk_burg_modified.c
libs/silk/src/SKP_Silk_bwexpander.c
libs/silk/src/SKP_Silk_bwexpander_32.c
libs/silk/src/SKP_Silk_code_signs.c
libs/silk/src/SKP_Silk_common_pitch_est_defines.h
libs/silk/src/SKP_Silk_control_codec_FIX.c
libs/silk/src/SKP_Silk_corrMatrix_FIX.c
libs/silk/src/SKP_Silk_create_init_destroy.c
libs/silk/src/SKP_Silk_dec_API.c
libs/silk/src/SKP_Silk_decode_core.c
libs/silk/src/SKP_Silk_decode_frame.c
libs/silk/src/SKP_Silk_decode_indices_v4.c [deleted file]
libs/silk/src/SKP_Silk_decode_parameters.c
libs/silk/src/SKP_Silk_decode_parameters_v4.c [deleted file]
libs/silk/src/SKP_Silk_decode_pulses.c
libs/silk/src/SKP_Silk_decoder_set_fs.c
libs/silk/src/SKP_Silk_define.h
libs/silk/src/SKP_Silk_define_FIX.h [deleted file]
libs/silk/src/SKP_Silk_detect_SWB_input.c
libs/silk/src/SKP_Silk_enc_API.c
libs/silk/src/SKP_Silk_encode_frame_FIX.c
libs/silk/src/SKP_Silk_encode_parameters.c
libs/silk/src/SKP_Silk_encode_parameters_v4.c [deleted file]
libs/silk/src/SKP_Silk_encode_pulses.c
libs/silk/src/SKP_Silk_find_LPC_FIX.c
libs/silk/src/SKP_Silk_find_LTP_FIX.c
libs/silk/src/SKP_Silk_find_pitch_lags_FIX.c
libs/silk/src/SKP_Silk_find_pred_coefs_FIX.c
libs/silk/src/SKP_Silk_gain_quant.c
libs/silk/src/SKP_Silk_init_encoder_FIX.c
libs/silk/src/SKP_Silk_inner_prod_aligned.c
libs/silk/src/SKP_Silk_interpolate.c
libs/silk/src/SKP_Silk_k2a.c
libs/silk/src/SKP_Silk_k2a_Q16.c
libs/silk/src/SKP_Silk_lin2log.c
libs/silk/src/SKP_Silk_log2lin.c
libs/silk/src/SKP_Silk_lowpass_int.c [deleted file]
libs/silk/src/SKP_Silk_lowpass_short.c [deleted file]
libs/silk/src/SKP_Silk_macros.h
libs/silk/src/SKP_Silk_main.h
libs/silk/src/SKP_Silk_main_FIX.h
libs/silk/src/SKP_Silk_noise_shape_analysis_FIX.c
libs/silk/src/SKP_Silk_perceptual_parameters_FIX.h [deleted file]
libs/silk/src/SKP_Silk_pitch_analysis_core.c
libs/silk/src/SKP_Silk_pitch_est_defines.h
libs/silk/src/SKP_Silk_pitch_est_tables.c
libs/silk/src/SKP_Silk_prefilter_FIX.c
libs/silk/src/SKP_Silk_process_NLSFs_FIX.c
libs/silk/src/SKP_Silk_process_gains_FIX.c
libs/silk/src/SKP_Silk_pulses_to_bytes.c [deleted file]
libs/silk/src/SKP_Silk_quant_LTP_gains_FIX.c
libs/silk/src/SKP_Silk_range_coder.c
libs/silk/src/SKP_Silk_regularize_correlations_FIX.c
libs/silk/src/SKP_Silk_resample_1_2.c [deleted file]
libs/silk/src/SKP_Silk_resample_1_2_coarse.c [deleted file]
libs/silk/src/SKP_Silk_resample_1_2_coarsest.c [deleted file]
libs/silk/src/SKP_Silk_resample_1_3.c [deleted file]
libs/silk/src/SKP_Silk_resample_2_1_coarse.c [deleted file]
libs/silk/src/SKP_Silk_resample_2_3.c [deleted file]
libs/silk/src/SKP_Silk_resample_2_3_coarse.c [deleted file]
libs/silk/src/SKP_Silk_resample_2_3_coarsest.c [deleted file]
libs/silk/src/SKP_Silk_resample_2_3_rom.c [deleted file]
libs/silk/src/SKP_Silk_resample_3_1.c [deleted file]
libs/silk/src/SKP_Silk_resample_3_2.c [deleted file]
libs/silk/src/SKP_Silk_resample_3_2_rom.c [deleted file]
libs/silk/src/SKP_Silk_resample_3_4.c [deleted file]
libs/silk/src/SKP_Silk_resample_4_3.c [deleted file]
libs/silk/src/SKP_Silk_resample_rom.h [deleted file]
libs/silk/src/SKP_Silk_residual_energy16_FIX.c
libs/silk/src/SKP_Silk_residual_energy_FIX.c
libs/silk/src/SKP_Silk_scale_copy_vector16.c
libs/silk/src/SKP_Silk_scale_vector.c
libs/silk/src/SKP_Silk_schur.c
libs/silk/src/SKP_Silk_schur64.c
libs/silk/src/SKP_Silk_shell_coder.c
libs/silk/src/SKP_Silk_sigm_Q15.c
libs/silk/src/SKP_Silk_solve_LS_FIX.c
libs/silk/src/SKP_Silk_sort.c
libs/silk/src/SKP_Silk_structs.h
libs/silk/src/SKP_Silk_structs_FIX.h
libs/silk/src/SKP_Silk_sum_sqr_shift.c
libs/silk/src/SKP_Silk_tables.h
libs/silk/src/SKP_Silk_tables_LTP.c
libs/silk/src/SKP_Silk_tables_NLSF_CB0_10.c
libs/silk/src/SKP_Silk_tables_NLSF_CB0_10.h
libs/silk/src/SKP_Silk_tables_NLSF_CB0_16.c
libs/silk/src/SKP_Silk_tables_NLSF_CB0_16.h
libs/silk/src/SKP_Silk_tables_NLSF_CB1_10.c
libs/silk/src/SKP_Silk_tables_NLSF_CB1_10.h
libs/silk/src/SKP_Silk_tables_NLSF_CB1_16.c
libs/silk/src/SKP_Silk_tables_NLSF_CB1_16.h
libs/silk/src/SKP_Silk_tables_gain.c
libs/silk/src/SKP_Silk_tables_other.c
libs/silk/src/SKP_Silk_tables_pitch_lag.c
libs/silk/src/SKP_Silk_tables_pulses_per_block.c
libs/silk/src/SKP_Silk_tables_sign.c
libs/silk/src/SKP_Silk_tables_type_offset.c
libs/silk/src/Silk_FIX.2008.vcproj [deleted file]
libs/silk/src/Silk_FIX.2010.vcxproj [deleted file]
libs/silk/src/Silk_FIX.2010.vcxproj.filters [deleted file]
libs/silk/src/Silk_FIX.vcproj
libs/silk/test/Decoder.c
libs/silk/test/Encoder.c
libs/silk/test/SignalCompare.vcproj
libs/silk/test/signalCompare.c

index 2a681e8739d0c092c66c722bb615ff4d26bad9de..235e46891302c1cffd828f9be52a0d356cfa2f8f 100644 (file)
@@ -15,34 +15,32 @@ test/SignalCompare.vcproj
 
 lib_LTLIBRARIES        = libSKP_SILK_SDK.la
 libSKP_SILK_SDK_la_SOURCES = src/SKP_Silk_A2NLSF.c \
-src/SKP_Silk_allpass_int.c \
 src/SKP_Silk_ana_filt_bank_1.c \
-src/SKP_Silk_apply_sine_window.c \
+src/SKP_Silk_apply_sine_window_new.c \
 src/SKP_Silk_array_maxabs.c \
 src/SKP_Silk_autocorr.c \
-src/SKP_Silk_biquad_alt.c \
 src/SKP_Silk_biquad.c \
+src/SKP_Silk_biquad_alt.c \
 src/SKP_Silk_burg_modified.c \
-src/SKP_Silk_bwexpander_32.c \
 src/SKP_Silk_bwexpander.c \
+src/SKP_Silk_bwexpander_32.c \
 src/SKP_Silk_CNG.c \
 src/SKP_Silk_code_signs.c \
+src/SKP_Silk_control_audio_bandwidth.c \
 src/SKP_Silk_control_codec_FIX.c \
 src/SKP_Silk_corrMatrix_FIX.c \
 src/SKP_Silk_create_init_destroy.c \
 src/SKP_Silk_dec_API.c \
 src/SKP_Silk_decode_core.c \
 src/SKP_Silk_decode_frame.c \
-src/SKP_Silk_decode_indices_v4.c \
 src/SKP_Silk_decode_parameters.c \
-src/SKP_Silk_decode_parameters_v4.c \
+src/SKP_Silk_decode_pitch.c \
 src/SKP_Silk_decode_pulses.c \
 src/SKP_Silk_decoder_set_fs.c \
 src/SKP_Silk_detect_SWB_input.c \
 src/SKP_Silk_enc_API.c \
 src/SKP_Silk_encode_frame_FIX.c \
 src/SKP_Silk_encode_parameters.c \
-src/SKP_Silk_encode_parameters_v4.c \
 src/SKP_Silk_encode_pulses.c \
 src/SKP_Silk_find_LPC_FIX.c \
 src/SKP_Silk_find_LTP_FIX.c \
@@ -56,78 +54,75 @@ src/SKP_Silk_interpolate.c \
 src/SKP_Silk_k2a.c \
 src/SKP_Silk_k2a_Q16.c \
 src/SKP_Silk_LBRR_reset.c \
-src/SKP_Silk_lin2log.c \
-src/SKP_Silk_log2lin.c \
-src/SKP_Silk_lowpass_int.c \
-src/SKP_Silk_lowpass_short.c \
 src/SKP_Silk_LPC_inv_pred_gain.c \
-src/SKP_Silk_LPC_stabilize.c \
 src/SKP_Silk_LPC_synthesis_filter.c \
 src/SKP_Silk_LPC_synthesis_order16.c \
 src/SKP_Silk_LP_variable_cutoff.c \
 src/SKP_Silk_LSF_cos_table.c \
 src/SKP_Silk_LTP_analysis_filter_FIX.c \
 src/SKP_Silk_LTP_scale_ctrl_FIX.c \
+src/SKP_Silk_lin2log.c \
+src/SKP_Silk_log2lin.c \
 src/SKP_Silk_MA.c \
 src/SKP_Silk_NLSF2A.c \
 src/SKP_Silk_NLSF2A_stable.c \
 src/SKP_Silk_NLSF_MSVQ_decode.c \
 src/SKP_Silk_NLSF_MSVQ_encode_FIX.c \
-src/SKP_Silk_NLSF_stabilize.c \
 src/SKP_Silk_NLSF_VQ_rate_distortion_FIX.c \
 src/SKP_Silk_NLSF_VQ_sum_error_FIX.c \
 src/SKP_Silk_NLSF_VQ_weights_laroia.c \
-src/SKP_Silk_noise_shape_analysis_FIX.c \
+src/SKP_Silk_NLSF_stabilize.c \
 src/SKP_Silk_NSQ.c \
 src/SKP_Silk_NSQ_del_dec.c \
+src/SKP_Silk_noise_shape_analysis_FIX.c \
+src/SKP_Silk_PLC.c \
 src/SKP_Silk_pitch_analysis_core.c \
 src/SKP_Silk_pitch_est_tables.c \
-src/SKP_Silk_PLC.c \
 src/SKP_Silk_prefilter_FIX.c \
-src/SKP_Silk_process_gains_FIX.c \
 src/SKP_Silk_process_NLSFs_FIX.c \
-src/SKP_Silk_pulses_to_bytes.c \
+src/SKP_Silk_process_gains_FIX.c \
 src/SKP_Silk_quant_LTP_gains_FIX.c \
 src/SKP_Silk_range_coder.c \
 src/SKP_Silk_regularize_correlations_FIX.c \
-src/SKP_Silk_resample_1_2.c \
-src/SKP_Silk_resample_1_2_coarse.c \
-src/SKP_Silk_resample_1_2_coarsest.c \
-src/SKP_Silk_resample_1_3.c \
-src/SKP_Silk_resample_2_1_coarse.c \
-src/SKP_Silk_resample_2_3.c \
-src/SKP_Silk_resample_2_3_coarse.c \
-src/SKP_Silk_resample_2_3_coarsest.c \
-src/SKP_Silk_resample_2_3_rom.c \
-src/SKP_Silk_resample_3_1.c \
-src/SKP_Silk_resample_3_2.c \
-src/SKP_Silk_resample_3_2_rom.c \
-src/SKP_Silk_resample_3_4.c \
-src/SKP_Silk_resample_4_3.c \
+src/SKP_Silk_resampler.c \
+src/SKP_Silk_resampler_down2.c \
+src/SKP_Silk_resampler_down2_3.c \
+src/SKP_Silk_resampler_down3.c \
+src/SKP_Silk_resampler_private_AR2.c \
+src/SKP_Silk_resampler_private_ARMA4.c \
+src/SKP_Silk_resampler_private_IIR_FIR.c \
+src/SKP_Silk_resampler_private_copy.c \
+src/SKP_Silk_resampler_private_down4.c \
+src/SKP_Silk_resampler_private_down_FIR.c \
+src/SKP_Silk_resampler_private_up2_HQ.c \
+src/SKP_Silk_resampler_private_up4.c \
+src/SKP_Silk_resampler_rom.c \
+src/SKP_Silk_resampler_up2.c \
 src/SKP_Silk_residual_energy16_FIX.c \
 src/SKP_Silk_residual_energy_FIX.c \
 src/SKP_Silk_scale_copy_vector16.c \
 src/SKP_Silk_scale_vector.c \
-src/SKP_Silk_schur64.c \
 src/SKP_Silk_schur.c \
+src/SKP_Silk_schur64.c \
 src/SKP_Silk_shell_coder.c \
 src/SKP_Silk_sigm_Q15.c \
 src/SKP_Silk_solve_LS_FIX.c \
 src/SKP_Silk_sort.c \
 src/SKP_Silk_sum_sqr_shift.c \
-src/SKP_Silk_tables_gain.c \
 src/SKP_Silk_tables_LTP.c \
 src/SKP_Silk_tables_NLSF_CB0_10.c \
 src/SKP_Silk_tables_NLSF_CB0_16.c \
 src/SKP_Silk_tables_NLSF_CB1_10.c \
 src/SKP_Silk_tables_NLSF_CB1_16.c \
+src/SKP_Silk_tables_gain.c \
 src/SKP_Silk_tables_other.c \
 src/SKP_Silk_tables_pitch_lag.c \
 src/SKP_Silk_tables_pulses_per_block.c \
 src/SKP_Silk_tables_sign.c \
 src/SKP_Silk_tables_type_offset.c \
 src/SKP_Silk_VAD.c \
-src/SKP_Silk_VQ_nearest_neighbor_FIX.c 
+src/SKP_Silk_VQ_nearest_neighbor_FIX.c \
+src/SKP_Silk_warped_autocorrelation_FIX.c
 
 
 libSKP_SILK_SDK_la_CFLAGS = $(AM_CFLAGS)
@@ -135,24 +130,26 @@ libSKP_SILK_SDK_la_LDFLAGS = $(LIBS)
 
 library_includedir = $(prefix)/include/silk
 library_include_HEADERS        = src/SKP_Silk_common_pitch_est_defines.h \
-src/SKP_Silk_define_FIX.h \
 src/SKP_Silk_define.h \
 src/SKP_Silk_Inlines.h \
 src/SKP_Silk_macros.h \
-src/SKP_Silk_main_FIX.h \
 src/SKP_Silk_main.h \
-src/SKP_Silk_perceptual_parameters_FIX.h \
+src/SKP_Silk_main_FIX.h \
 src/SKP_Silk_pitch_est_defines.h \
 src/SKP_Silk_PLC.h \
-src/SKP_Silk_resample_rom.h \
+src/SKP_Silk_resampler_private.h \
+src/SKP_Silk_resampler_rom.h \
+src/SKP_Silk_resampler_structs.h \
 src/SKP_Silk_SigProc_FIX.h \
-src/SKP_Silk_structs_FIX.h \
+src/SKP_Silk_setup_complexity.h \
 src/SKP_Silk_structs.h \
+src/SKP_Silk_structs_FIX.h \
 src/SKP_Silk_tables.h \
 src/SKP_Silk_tables_NLSF_CB0_10.h \
 src/SKP_Silk_tables_NLSF_CB0_16.h \
 src/SKP_Silk_tables_NLSF_CB1_10.h \
 src/SKP_Silk_tables_NLSF_CB1_16.h \
+src/SKP_Silk_tuning_parameters.h \
 interface/SKP_Silk_control.h \
 interface/SKP_Silk_errors.h \
 interface/SKP_Silk_SDK_API.h \
index bd71b658a5dfac44f4ad5af040f15763efadae92..5075677c33bd82f0b42e6c90ce930685f3e5a67f 100644 (file)
@@ -2,8 +2,8 @@
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ([2.59])
-AC_INIT(libSKP_SILK_SDK, 1.0.2, brian@freeswitch.org, libSKP_SILK_SDK)
-AM_INIT_AUTOMAKE(libSKP_SILK_SDK,1.0.2)
+AC_INIT(libSKP_SILK_SDK, 1.0.8, brian@freeswitch.org, libSKP_SILK_SDK)
+AM_INIT_AUTOMAKE(libSKP_SILK_SDK,1.0.8)
 
 # Checks for programs.
 AC_PROG_CC
index cb31db2444d30b949364295322e4921c13ac24b3..1e6778273b90170b18959046be58e171c97370cc 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -39,7 +39,7 @@ extern "C"
 \r
 #define SILK_MAX_FRAMES_PER_PACKET  5\r
 \r
-/* Struct for TOC (Table Of Contents) */\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
@@ -85,7 +85,7 @@ SKP_int SKP_Silk_SDK_Encode(
     const SKP_int16                     *samplesIn,     /* I:   Speech sample input vector                      */\r
     SKP_int                             nSamplesIn,     /* I:   Number of samples in input vector               */\r
     SKP_uint8                           *outData,       /* O:   Encoded output vector                           */\r
-    SKP_int16                           *nBytesOut      /* I/O: Number of Bytes in outData (input: Max Bytes)   */\r
+    SKP_int16                           *nBytesOut      /* I/O: Number of bytes in outData (input: Max bytes)   */\r
 );\r
 \r
 /****************************************/\r
@@ -114,7 +114,7 @@ SKP_int SKP_Silk_SDK_Decode(
     SKP_SILK_SDK_DecControlStruct*      decControl,     /* I/O: Control Structure                               */\r
     SKP_int                             lostFlag,       /* I:   0: no loss, 1 loss                              */\r
     const SKP_uint8                     *inData,        /* I:   Encoded input vector                            */\r
-    const SKP_int                       nBytesIn,       /* I:   Number of input Bytes                           */\r
+    const SKP_int                       nBytesIn,       /* I:   Number of input bytes                           */\r
     SKP_int16                           *samplesOut,    /* O:   Decoded output speech vector                    */\r
     SKP_int16                           *nSamplesOut    /* I/O: Number of samples (vector/decoded)              */\r
 );\r
@@ -123,22 +123,20 @@ SKP_int SKP_Silk_SDK_Decode(
 /* Find Low Bit Rate Redundancy (LBRR) information in a packet */\r
 /***************************************************************/\r
 void SKP_Silk_SDK_search_for_LBRR(\r
-    void                                *decState,      /* I:   Decoder state, to select bitstream version only */\r
     const SKP_uint8                     *inData,        /* I:   Encoded input vector                            */\r
-    const SKP_int16                     nBytesIn,       /* I:   Number of input Bytes                           */\r
+    const SKP_int                       nBytesIn,       /* I:   Number of input Bytes                           */\r
     SKP_int                             lost_offset,    /* I:   Offset from lost packet                         */\r
     SKP_uint8                           *LBRRData,      /* O:   LBRR payload                                    */\r
     SKP_int16                           *nLBRRBytes     /* O:   Number of LBRR Bytes                            */\r
 );\r
 \r
-/************************************/\r
-/* Get type of content for a packet */\r
-/************************************/\r
+/**************************************/\r
+/* Get table of contents for a packet */\r
+/**************************************/\r
 void SKP_Silk_SDK_get_TOC(\r
-    void                                       *decState,      /* I:   Decoder state, to select bitstream version only */\r
     const SKP_uint8                     *inData,        /* I:   Encoded input vector                            */\r
-    const SKP_int16                     nBytesIn,       /* I:   Number of input bytes                           */\r
-    SKP_Silk_TOC_struct                 *Silk_TOC       /* O:   Type of content                                 */\r
+    const SKP_int                       nBytesIn,       /* I:   Number of input bytes                           */\r
+    SKP_Silk_TOC_struct                 *Silk_TOC       /* O:   Table of contents                               */\r
 );\r
 \r
 /**************************/\r
index 2bd056fd22320c25054241e54a274a7c1ff0c46c..4e52dce97d5958b5d897012cc394a7dff50a1d5e 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -39,8 +39,11 @@ extern "C"
 /* Structure for controlling encoder operation */\r
 /***********************************************/\r
 typedef struct {\r
-    /* I:   Sampling rate in Hertz; 8000/12000/16000/24000                                  */\r
-    SKP_int32 sampleRate;\r
+    /* I:   Input signal sampling rate in Hertz; 8000/12000/16000/24000                     */\r
+    SKP_int32 API_sampleRate;\r
+\r
+    /* I:   Maximum internal sampling rate in Hertz; 8000/12000/16000/24000                 */\r
+    SKP_int32 maxInternalSampleRate;\r
 \r
     /* I:   Number of samples per packet; must be equivalent of 20, 40, 60, 80 or 100 ms    */\r
     SKP_int packetSize;\r
@@ -48,7 +51,7 @@ typedef struct {
     /* I:   Bitrate during active speech in bits/second; internally limited                 */\r
     SKP_int32 bitRate;                        \r
 \r
-    /* I:   Uplink Packet loss in pct (0...100)                                             */\r
+    /* 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
@@ -57,7 +60,7 @@ typedef struct {
     /* I:   Flag to enable in-band Forward Error Correction (FEC); 0/1                      */\r
     SKP_int useInBandFEC;\r
 \r
-    /* I:   Flag to enable Discontinous Transmission; 0/1                                   */\r
+    /* I:   Flag to enable discontinuous transmission (DTX); 0/1                            */\r
     SKP_int useDTX;\r
 } SKP_SILK_SDK_EncControlStruct;\r
 \r
@@ -65,8 +68,8 @@ typedef struct {
 /* Structure for controlling decoder operation and reading decoder status */\r
 /**************************************************************************/\r
 typedef struct {\r
-    /* I:   Sampling rate in Hertz; 8000/12000/16000/24000                                  */\r
-    SKP_int32 sampleRate;\r
+    /* I:   Output signal sampling rate in Hertz; 8000/12000/16000/24000                    */\r
+    SKP_int32 API_sampleRate;\r
 \r
     /* O:   Number of samples per frame                                                     */\r
     SKP_int frameSize;\r
index 99b837cb3082d98e43da8e3f467416b6b860060d..eb196cee48d5bfb07c4ef8de9eef101b515e1697 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -36,48 +36,45 @@ extern "C"
 /******************/\r
 /* Error messages */\r
 /******************/\r
-#define SKP_SILK_NO_ERROR                                 0\r
+#define SKP_SILK_NO_ERROR                               0\r
 \r
 /**************************/\r
 /* Encoder error messages */\r
 /**************************/\r
 \r
-/* Input length is not a multiplum of 10 ms, \r
-   or length is longer than the packet length */\r
-#define SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES         -1\r
+/* Input length is not a multiplum of 10 ms, or length is longer than the packet length */\r
+#define SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES        -1\r
 \r
-/* Sampling frequency not 8000, 12000, 16000 \r
-   or 24000 Hertz */\r
-#define SKP_SILK_ENC_FS_NOT_SUPPORTED                    -2\r
+/* Sampling frequency not 8000, 12000, 16000 or 24000 Hertz */\r
+#define SKP_SILK_ENC_FS_NOT_SUPPORTED                   -2\r
 \r
 /* Packet size not 20, 40, 60, 80 or 100 ms */\r
-#define SKP_SILK_ENC_PACKET_SIZE_NOT_SUPPORTED           -3\r
+#define SKP_SILK_ENC_PACKET_SIZE_NOT_SUPPORTED          -3\r
 \r
 /* Allocated payload buffer too short */\r
-#define SKP_SILK_ENC_PAYLOAD_BUF_TOO_SHORT               -4\r
+#define SKP_SILK_ENC_PAYLOAD_BUF_TOO_SHORT              -4\r
 \r
 /* Loss rate not between 0 and 100 percent */\r
-#define SKP_SILK_ENC_WRONG_LOSS_RATE                     -5\r
+#define SKP_SILK_ENC_INVALID_LOSS_RATE                  -5\r
 \r
 /* Complexity setting not valid, use 0, 1 or 2 */\r
-#define SKP_SILK_ENC_WRONG_COMPLEXITY_SETTING            -6\r
+#define SKP_SILK_ENC_INVALID_COMPLEXITY_SETTING         -6\r
 \r
 /* Inband FEC setting not valid, use 0 or 1 */\r
-#define SKP_SILK_ENC_WRONG_INBAND_FEC_SETTING            -7\r
+#define SKP_SILK_ENC_INVALID_INBAND_FEC_SETTING         -7\r
 \r
 /* DTX setting not valid, use 0 or 1 */\r
-#define SKP_SILK_ENC_WRONG_DTX_SETTING                   -8\r
+#define SKP_SILK_ENC_INVALID_DTX_SETTING                -8\r
 \r
 /* Internal encoder error */\r
-#define SKP_SILK_ENC_INTERNAL_ERROR                      -9\r
+#define SKP_SILK_ENC_INTERNAL_ERROR                     -9\r
 \r
 /**************************/\r
 /* Decoder error messages */\r
 /**************************/\r
 \r
-/* Output sampling frequency lower than internal \r
-   decoded sampling frequency */\r
-#define SKP_SILK_DEC_WRONG_SAMPLING_FREQUENCY           -10\r
+/* Output sampling frequency lower than internal decoded sampling frequency */\r
+#define SKP_SILK_DEC_INVALID_SAMPLING_FREQUENCY         -10\r
 \r
 /* Payload size exceeded the maximum allowed 1024 bytes */\r
 #define SKP_SILK_DEC_PAYLOAD_TOO_LARGE                  -11\r
@@ -85,7 +82,6 @@ extern "C"
 /* Payload has bit errors */\r
 #define SKP_SILK_DEC_PAYLOAD_ERROR                      -12\r
 \r
-\r
 #ifdef __cplusplus\r
 }\r
 #endif\r
index 7cb661a490fb2244530e53350dd4e51c4f4d0695..f2c1f6f2c2136e77922a19562e5b92afa80faf37 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
index 11cf53134f2784456ada540af228eca306eb8c5c..b1ad84170c7c4f118cfc050dbb086c34be47395f 100644 (file)
@@ -1,14 +1,14 @@
 ************************************************************************\r
-Fixed Point SILK SDK 1.0.2 beta source code package\r
+Fixed Point SILK SDK 1.0.8 beta source code package\r
 Copyright 2010 (c), Skype Limited\r
 https://developer.skype.com/silk/\r
 ************************************************************************\r
 \r
-Date: 09/03/2010 (Format: DD/MM/YYYY)\r
+Date: 15/06/2011 (Format: DD/MM/YYYY)\r
 \r
 I. Description\r
 \r
-This package contains files for compiling and testing the fixed\r
+This package contains files for compilation and evaluation of the fixed\r
 point SILK SDK library. The following is included in this package:\r
 \r
     o Source code for the fixed point SILK SDK library\r
@@ -51,22 +51,38 @@ III. How to use the Makefile
 \r
        make clean all\r
 \r
-    6. How to use the comparison tool:\r
-       \r
+    6. How to build for big endian CPU's\r
+\r
+       Make clean all ADDED_DEFINES+=_SYSTEM_IS_BIG_ENDIAN\r
+       To be able to use the test vectors with big endian CPU's the test programs\r
+       need to be compiled in a different way. Note that the 16 bit input and output \r
+       from the test programs will have the upper and lower bytes swapped with this setting. \r
+\r
+    7. How to use the comparison tool:\r
+\r
        See 'How to use the test vectors.txt' in the test_vectors folder.       \r
 \r
 IV. History\r
 \r
+    Version 1.0.8 - Improved noise shaping, various other improvements, and various bugfixes. Added a MIPS version\r
+    Version 1.0.7 - Updated with bugfixes for LBRR and pitch estimator. SignalCompare updated\r
+    Version 1.0.6 - Updated with bugfixes for ARM builds\r
+    Version 1.0.5 - Updated with bugfixes for ARM builds\r
+    Version 1.0.4 - Updated with various bugfixes and improvements, including some API changes\r
+                    Added support for big endian platforms\r
+                    Added resampler support for additional API sample rates\r
+    Version 1.0.3 - Updated with various bugfixes and improvements\r
     Version 1.0.2 - Updated with various bugfixes and improvements\r
     Version 1.0.1 - First beta source code release\r
     \r
 V. Compatibility\r
 \r
-    This package has been tested under the following platforms:\r
+    This package has been tested on the following platforms:\r
 \r
     Windows XP Home and Professional\r
     Windows Vista, 32-bit version\r
-    Mac OS X Version 10.5.8\r
+    Mac OSX intel\r
+    Mac OSX ppc\r
     Ubuntu Linux 9.10, 64-bit version \r
 \r
 VI. Known Issues\r
index f8e56ca78c8482008d5126960e2b27f5d33e2353..98cc8c1ace8532b2bfada4fb44c137dd4b5143df 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -33,10 +33,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 \r
 #include "SKP_Silk_SigProc_FIX.h"\r
 \r
-/* Number of binary divisions, when not in low complexity mode */\r
-#define BIN_DIV_STEPS_A2NLSF_FIX      2 /* must be no higher than 16 - log2( LSF_COS_TAB_SZ_FIX ) */\r
+/* Number of binary divisions */\r
+#define BIN_DIV_STEPS_A2NLSF_FIX      3 /* must be no higher than 16 - log2( LSF_COS_TAB_SZ_FIX ) */\r
 #define QPoly                        16\r
-#define MAX_ITERATIONS_A2NLSF_FIX    50\r
+#define MAX_ITERATIONS_A2NLSF_FIX    30\r
 \r
 /* Flag for using 2x as many cosine sampling points, reduces the risk of missing a root */\r
 #define OVERSAMPLE_COSINE_TABLE       0\r
@@ -57,12 +57,11 @@ SKP_INLINE void SKP_Silk_A2NLSF_trans_poly(
         p[ k - 2 ] -= SKP_LSHIFT( p[ k ], 1 );\r
     }\r
 }    \r
-\r
 /* Helper function for A2NLSF(..)                    */\r
 /* Polynomial evaluation                             */\r
 SKP_INLINE SKP_int32 SKP_Silk_A2NLSF_eval_poly(    /* return the polynomial evaluation, in QPoly */\r
     SKP_int32        *p,    /* I    Polynomial, QPoly        */\r
-    const SKP_int32    x,   /* I    Evaluation point, Q12    */\r
+    const SKP_int32   x,    /* I    Evaluation point, Q12    */\r
     const SKP_int    dd     /* I    Order                    */\r
 )\r
 {\r
@@ -79,9 +78,9 @@ SKP_INLINE SKP_int32 SKP_Silk_A2NLSF_eval_poly(    /* return the polynomial eval
 \r
 SKP_INLINE void SKP_Silk_A2NLSF_init(\r
      const SKP_int32    *a_Q16,\r
-     SKP_int32            *P, \r
-     SKP_int32            *Q, \r
-     const SKP_int        dd\r
+     SKP_int32          *P, \r
+     SKP_int32          *Q, \r
+     const SKP_int      dd\r
 ) \r
 {\r
     SKP_int k;\r
@@ -127,8 +126,8 @@ void SKP_Silk_A2NLSF(
     SKP_int32 xlo, xhi, xmid;\r
     SKP_int32 ylo, yhi, ymid;\r
     SKP_int32 nom, den;\r
-    SKP_int32 P[ SigProc_MAX_ORDER_LPC / 2 + 1 ];\r
-    SKP_int32 Q[ SigProc_MAX_ORDER_LPC / 2 + 1 ];\r
+    SKP_int32 P[ SKP_Silk_MAX_ORDER_LPC / 2 + 1 ];\r
+    SKP_int32 Q[ SKP_Silk_MAX_ORDER_LPC / 2 + 1 ];\r
     SKP_int32 *PQ[ 2 ];\r
     SKP_int32 *p;\r
 \r
@@ -258,7 +257,7 @@ void SKP_Silk_A2NLSF(
                 }\r
 \r
                 /* Error: Apply progressively more bandwidth expansion and run again */\r
-                SKP_Silk_bwexpander_32( a_Q16, d, 65536 - SKP_SMULBB( 66, i ) ); // 66_Q16 = 0.001\r
+                SKP_Silk_bwexpander_32( a_Q16, d, 65536 - SKP_SMULBB( 10 + i, i ) ); // 10_Q16 = 0.00015\r
 \r
                 SKP_Silk_A2NLSF_init( a_Q16, P, Q, dd );\r
                 p = P;                            /* Pointer to polynomial */\r
@@ -269,9 +268,9 @@ void SKP_Silk_A2NLSF(
                     NLSF[ 0 ] = 0;\r
                     p = Q;                        /* Pointer to polynomial */\r
                     ylo = SKP_Silk_A2NLSF_eval_poly( p, xlo, dd );\r
-                    root_ix = 1;                /* Index of current root */\r
+                    root_ix = 1;                  /* Index of current root */\r
                 } else {\r
-                    root_ix = 0;                /* Index of current root */\r
+                    root_ix = 0;                  /* Index of current root */\r
                 }\r
                 k = 1;                            /* Reset loop counter */\r
             }\r
index 2958fadb5edbc15bf39bff8148e682bbd2c9911d..00bde3b83eb009c8e047651d1d4a85cc33f02133 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -25,7 +25,7 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
 ***********************************************************************/\r
 \r
-#include "SKP_Silk_main_FIX.h"\r
+#include "SKP_Silk_main.h"\r
 \r
 /* Generates excitation for CNG LPC synthesis */\r
 SKP_INLINE void SKP_Silk_CNG_exc(\r
index 68356fa1b6232c1bd275fbd7951bc33626157ed7..bfef9c8ce242b08b1b27cca09da2eca0559b7836 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -26,6 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***********************************************************************/\r
 \r
 #include "SKP_Silk_main_FIX.h"\r
+#include "SKP_Silk_tuning_parameters.h"\r
 \r
 #if HIGH_PASS_INPUT\r
 \r
@@ -57,7 +58,7 @@ void SKP_Silk_HP_variable_cutoff_FIX(
         quality_Q15 = psEncCtrl->input_quality_bands_Q15[ 0 ];\r
         pitch_freq_log_Q7 = SKP_SUB32( pitch_freq_log_Q7, SKP_SMULWB( SKP_SMULWB( SKP_LSHIFT( quality_Q15, 2 ), quality_Q15 ), \r
             pitch_freq_log_Q7 - SKP_LOG2_VARIABLE_HP_MIN_FREQ_Q7 ) );\r
-        pitch_freq_log_Q7 = SKP_ADD32( pitch_freq_log_Q7, SKP_RSHIFT( 19661 - quality_Q15, 9 ) ); // 19661_Q15 = 0.6_Q0\r
+        pitch_freq_log_Q7 = SKP_ADD32( pitch_freq_log_Q7, SKP_RSHIFT( SKP_FIX_CONST( 0.6, 15 ) - quality_Q15, 9 ) );\r
 \r
         //delta_freq = pitch_freq_log - psEnc->variable_HP_smth1;\r
         delta_freq_Q7 = pitch_freq_log_Q7 - SKP_RSHIFT( psEnc->variable_HP_smth1_Q15, 8 );\r
@@ -67,21 +68,22 @@ void SKP_Silk_HP_variable_cutoff_FIX(
         }\r
 \r
         /* limit delta, to reduce impact of outliers */\r
-        delta_freq_Q7 = SKP_LIMIT( delta_freq_Q7, -VARIABLE_HP_MAX_DELTA_FREQ_Q7, VARIABLE_HP_MAX_DELTA_FREQ_Q7 );\r
+        delta_freq_Q7 = SKP_LIMIT_32( delta_freq_Q7, -SKP_FIX_CONST( VARIABLE_HP_MAX_DELTA_FREQ, 7 ), SKP_FIX_CONST( VARIABLE_HP_MAX_DELTA_FREQ, 7 ) );\r
 \r
         /* update smoother */\r
         psEnc->variable_HP_smth1_Q15 = SKP_SMLAWB( psEnc->variable_HP_smth1_Q15, \r
-            SKP_MUL( SKP_LSHIFT( psEnc->speech_activity_Q8, 1 ), delta_freq_Q7 ), VARIABLE_HP_SMTH_COEF1_Q16 );\r
+            SKP_MUL( SKP_LSHIFT( psEnc->speech_activity_Q8, 1 ), delta_freq_Q7 ), SKP_FIX_CONST( VARIABLE_HP_SMTH_COEF1, 16 ) );\r
     }\r
     /* second smoother */\r
     psEnc->variable_HP_smth2_Q15 = SKP_SMLAWB( psEnc->variable_HP_smth2_Q15, \r
-        psEnc->variable_HP_smth1_Q15 - psEnc->variable_HP_smth2_Q15, VARIABLE_HP_SMTH_COEF2_Q16 );\r
+        psEnc->variable_HP_smth1_Q15 - psEnc->variable_HP_smth2_Q15, SKP_FIX_CONST( VARIABLE_HP_SMTH_COEF2, 16 ) );\r
 \r
     /* convert from log scale to Hertz */\r
-    psEncCtrl->pitch_freq_low_Hz = SKP_Silk_log2lin( SKP_RSHIFT( psEnc->variable_HP_smth2_Q15, 8 ) ); //pow( 2.0, psEnc->variable_HP_smth2 );\r
+    psEncCtrl->pitch_freq_low_Hz = SKP_Silk_log2lin( SKP_RSHIFT( psEnc->variable_HP_smth2_Q15, 8 ) );\r
 \r
     /* limit frequency range */\r
-    psEncCtrl->pitch_freq_low_Hz = SKP_LIMIT( psEncCtrl->pitch_freq_low_Hz, VARIABLE_HP_MIN_FREQ_Q0, VARIABLE_HP_MAX_FREQ_Q0 );\r
+    psEncCtrl->pitch_freq_low_Hz = SKP_LIMIT_32( psEncCtrl->pitch_freq_low_Hz, \r
+        SKP_FIX_CONST( VARIABLE_HP_MIN_FREQ, 0 ), SKP_FIX_CONST( VARIABLE_HP_MAX_FREQ, 0 ) );\r
 \r
     /********************************/\r
     /* Compute Filter Coefficients  */\r
@@ -94,7 +96,7 @@ void SKP_Silk_HP_variable_cutoff_FIX(
     SKP_assert( Fc_Q19 >=  3704 );\r
     SKP_assert( Fc_Q19 <= 27787 );\r
 \r
-    r_Q28 = ( 1 << 28 ) - SKP_MUL( 471, Fc_Q19 ); // 471_Q9 = 0.92_Q0, range: 255347779 to 266690872, 27-28 bits\r
+    r_Q28 = SKP_FIX_CONST( 1.0, 28 ) - SKP_MUL( SKP_FIX_CONST( 0.92, 9 ), Fc_Q19 );\r
     SKP_assert( r_Q28 >= 255347779 );\r
     SKP_assert( r_Q28 <= 266690872 );\r
 \r
@@ -106,7 +108,7 @@ void SKP_Silk_HP_variable_cutoff_FIX(
     \r
     // -r * ( 2 - Fc * Fc );\r
     r_Q22  = SKP_RSHIFT( r_Q28, 6 );\r
-    A_Q28[ 0 ] = SKP_SMULWW( r_Q22, SKP_SMULWW( Fc_Q19, Fc_Q19 ) - ( 2 << 22 ) );\r
+    A_Q28[ 0 ] = SKP_SMULWW( r_Q22, SKP_SMULWW( Fc_Q19, Fc_Q19 ) - SKP_FIX_CONST( 2.0,  22 ) );\r
     A_Q28[ 1 ] = SKP_SMULWW( r_Q22, r_Q22 );\r
 \r
     /********************************/\r
index 66a09bd712eae4f2afff246dec5a68f02832ed79..fd6dec04de008329c428dd56a01b7bc318cb6a7b 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -57,20 +57,15 @@ SKP_INLINE void SKP_Silk_CLZ_FRAC(SKP_int32 in,            /* I: input */
                                     SKP_int32 *lz,           /* O: number of leading zeros */\r
                                     SKP_int32 *frac_Q7)      /* O: the 7 bits right after the leading one */\r
 {\r
-    SKP_int32 leadingZeros;\r
+    SKP_int32 lzeros = SKP_Silk_CLZ32(in);\r
 \r
-    leadingZeros = SKP_Silk_CLZ32(in);\r
-    *lz = leadingZeros;\r
-    if( leadingZeros < 24 ) { \r
-        *frac_Q7 = SKP_RSHIFT(in, 24 - leadingZeros) & 0x7F;\r
-    } else {\r
-        *frac_Q7 = SKP_LSHIFT(in, leadingZeros - 24) & 0x7F;\r
-    }\r
+    * lz = lzeros;\r
+    * frac_Q7 = SKP_ROR32(in, 24 - lzeros) & 0x7f;\r
 }\r
 \r
 /* Approximation of square root                                          */\r
-/* Accuracy: < +/- 10% for output values > 15                            */\r
-/*             < +/- 2.5% for output values > 120                        */\r
+/* Accuracy: < +/- 10%  for output values > 15                           */\r
+/*           < +/- 2.5% for output values > 120                          */\r
 SKP_INLINE SKP_int32 SKP_Silk_SQRT_APPROX(SKP_int32 x)\r
 {\r
     SKP_int32 y, lz, frac_Q7;\r
@@ -125,9 +120,9 @@ SKP_INLINE SKP_int32 SKP_Silk_norm32(SKP_int32 a) {
 \r
 /* Divide two int32 values and return result as int32 in a given Q-domain */\r
 SKP_INLINE SKP_int32 SKP_DIV32_varQ(    /* O    returns a good approximation of "(a32 << Qres) / b32" */\r
-    const SKP_int32        a32,         /* I    numerator (Q0)                  */\r
-    const SKP_int32        b32,         /* I    denominator (Q0)                */\r
-    const SKP_int        Qres           /* I    Q-domain of result (>= 0)       */\r
+    const SKP_int32     a32,            /* I    numerator (Q0)                  */\r
+    const SKP_int32     b32,            /* I    denominator (Q0)                */\r
+    const SKP_int       Qres            /* I    Q-domain of result (>= 0)       */\r
 )\r
 {\r
     SKP_int   a_headrm, b_headrm, lshift;\r
@@ -170,14 +165,15 @@ SKP_INLINE SKP_int32 SKP_DIV32_varQ(    /* O    returns a good approximation of
 \r
 /* Invert int32 value and return result as int32 in a given Q-domain */\r
 SKP_INLINE SKP_int32 SKP_INVERSE32_varQ(    /* O    returns a good approximation of "(1 << Qres) / b32" */\r
-    const SKP_int32        b32,             /* I    denominator (Q0)                */\r
-    const SKP_int        Qres               /* I    Q-domain of result (> 0)        */\r
+    const SKP_int32     b32,                /* I    denominator (Q0)                */\r
+    const SKP_int       Qres                /* I    Q-domain of result (> 0)        */\r
 )\r
 {\r
     SKP_int   b_headrm, lshift;\r
     SKP_int32 b32_inv, b32_nrm, err_Q32, result;\r
 \r
     SKP_assert( b32 != 0 );\r
+    SKP_assert( b32 != SKP_int32_MIN ); /* SKP_int32_MIN is not handled by SKP_abs */\r
     SKP_assert( Qres > 0 );\r
 \r
     /* Compute number of bits head room and normalize input */\r
@@ -277,4 +273,4 @@ SKP_INLINE SKP_int32 SKP_Silk_COS_APPROX_Q24(        /* O    returns approximate
 }\r
 #endif\r
 \r
-#endif //_SKP_SILK_FIX_INLINES_H_\r
+#endif /*_SKP_SILK_FIX_INLINES_H_*/\r
index 22e68303fff57f2bc9a5904457230e9ef1157a0c..d1c2e9fe60867fb94ef5c0b6924358cfb8835d34 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
index a350a6f407afeb5c0d11ab573b4505568defd1cb..4e40ccceb95cee7c99a8f990aa2928a630bf2940 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -31,30 +31,27 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  * Compute inverse of LPC prediction gain, and                          *\r
  * test if LPC coefficients are stable (all poles within unit circle)   *\r
  *                                                                      *\r
- * Copyright 2008 (c), Skype Limited                                           *\r
+ * Copyright 2008 (c), Skype Limited                                    *\r
  *                                                                      */\r
 #include "SKP_Silk_SigProc_FIX.h"\r
+\r
 #define QA          16\r
-#define A_LIMIT     65520\r
+#define A_LIMIT     SKP_FIX_CONST( 0.99975, QA )\r
 \r
 /* Compute inverse of LPC prediction gain, and                          */\r
 /* test if LPC coefficients are stable (all poles within unit circle)   */\r
-SKP_int SKP_Silk_LPC_inverse_pred_gain(       /* O:   Returns 1 if unstable, otherwise 0          */\r
+static SKP_int LPC_inverse_pred_gain_QA(        /* O:   Returns 1 if unstable, otherwise 0          */\r
     SKP_int32           *invGain_Q30,           /* O:   Inverse prediction gain, Q30 energy domain  */\r
-    const SKP_int16     *A_Q12,                 /* I:   Prediction coefficients, Q12 [order]        */\r
+    SKP_int32           A_QA[ 2 ][ SKP_Silk_MAX_ORDER_LPC ],         \r
+                                                /* I:   Prediction coefficients                     */\r
     const SKP_int       order                   /* I:   Prediction order                            */\r
 )\r
 {\r
     SKP_int   k, n, headrm;\r
-    SKP_int32 rc_Q31, rc_mult1_Q30, rc_mult2_Q16;\r
-    SKP_int32 Atmp_QA[ 2 ][ SigProc_MAX_ORDER_LPC ], tmp_QA;\r
+    SKP_int32 rc_Q31, rc_mult1_Q30, rc_mult2_Q16, tmp_QA;\r
     SKP_int32 *Aold_QA, *Anew_QA;\r
 \r
-    Anew_QA = Atmp_QA[ order & 1 ];\r
-    /* Increase Q domain of the AR coefficients */\r
-    for( k = 0; k < order; k++ ) {\r
-        Anew_QA[ k ] = SKP_LSHIFT( (SKP_int32)A_Q12[ k ], QA - 12 );\r
-    }\r
+    Anew_QA = A_QA[ order & 1 ];\r
 \r
     *invGain_Q30 = ( 1 << 30 );\r
     for( k = order - 1; k > 0; k-- ) {\r
@@ -82,7 +79,7 @@ SKP_int SKP_Silk_LPC_inverse_pred_gain(       /* O:   Returns 1 if unstable, oth
 \r
         /* Swap pointers */\r
         Aold_QA = Anew_QA;\r
-        Anew_QA = Atmp_QA[ k & 1 ];\r
+        Anew_QA = A_QA[ k & 1 ];\r
         \r
         /* Update AR coefficient */\r
         headrm = SKP_Silk_CLZ32( rc_mult2_Q16 ) - 1;\r
@@ -112,78 +109,45 @@ SKP_int SKP_Silk_LPC_inverse_pred_gain(       /* O:   Returns 1 if unstable, oth
 \r
     return 0;\r
 }\r
-\r
-/* For input in Q13 domain */\r
-SKP_int SKP_Silk_LPC_inverse_pred_gain_Q13(   /* O:   Returns 1 if unstable, otherwise 0          */\r
+/* For input in Q12 domain */\r
+SKP_int SKP_Silk_LPC_inverse_pred_gain(       /* O:   Returns 1 if unstable, otherwise 0          */\r
     SKP_int32           *invGain_Q30,           /* O:   Inverse prediction gain, Q30 energy domain  */\r
-    const SKP_int16     *A_Q13,                 /* I:   Prediction coefficients, Q13 [order]        */\r
+    const SKP_int16     *A_Q12,                 /* I:   Prediction coefficients, Q12 [order]        */\r
     const SKP_int       order                   /* I:   Prediction order                            */\r
 )\r
 {\r
-    SKP_int   k, n, headrm;\r
-    SKP_int32 rc_Q31, rc_mult1_Q30, rc_mult2_Q16;\r
-    SKP_int32 Atmp_QA[ 2 ][ SigProc_MAX_ORDER_LPC ], tmp_QA;\r
-    SKP_int32 *Aold_QA, *Anew_QA;\r
+    SKP_int   k;\r
+    SKP_int32 Atmp_QA[ 2 ][ SKP_Silk_MAX_ORDER_LPC ];\r
+    SKP_int32 *Anew_QA;\r
 \r
     Anew_QA = Atmp_QA[ order & 1 ];\r
+\r
     /* Increase Q domain of the AR coefficients */\r
     for( k = 0; k < order; k++ ) {\r
-        Anew_QA[ k ] = SKP_LSHIFT( (SKP_int32)A_Q13[ k ], QA - 13 );\r
+        Anew_QA[ k ] = SKP_LSHIFT( (SKP_int32)A_Q12[ k ], QA - 12 );\r
     }\r
 \r
-    *invGain_Q30 = ( 1 << 30 );\r
-    for( k = order - 1; k > 0; k-- ) {\r
-        /* Check for stability */\r
-        if( ( Anew_QA[ k ] > A_LIMIT ) || ( Anew_QA[ k ] < -A_LIMIT ) ) {\r
-            return 1;\r
-        }\r
-\r
-        /* Set RC equal to negated AR coef */\r
-        rc_Q31 = -SKP_LSHIFT( Anew_QA[ k ], 31 - QA );\r
-        \r
-        /* rc_mult1_Q30 range: [ 1 : 2^30-1 ] */\r
-        rc_mult1_Q30 = ( SKP_int32_MAX >> 1 ) - SKP_SMMUL( rc_Q31, rc_Q31 );\r
-        SKP_assert( rc_mult1_Q30 > ( 1 << 15 ) );                   /* reduce A_LIMIT if fails */\r
-        SKP_assert( rc_mult1_Q30 < ( 1 << 30 ) );\r
-\r
-        /* rc_mult2_Q16 range: [ 2^16 : SKP_int32_MAX ] */\r
-        rc_mult2_Q16 = SKP_INVERSE32_varQ( rc_mult1_Q30, 46 );      /* 16 = 46 - 30 */\r
+    return LPC_inverse_pred_gain_QA( invGain_Q30, Atmp_QA, order );\r
+}\r
 \r
-        /* Update inverse gain */\r
-        /* invGain_Q30 range: [ 0 : 2^30 ] */\r
-        *invGain_Q30 = SKP_LSHIFT( SKP_SMMUL( *invGain_Q30, rc_mult1_Q30 ), 2 );\r
-        SKP_assert( *invGain_Q30 >= 0     );\r
-        SKP_assert( *invGain_Q30 <= 1<<30 );\r
+/* For input in Q24 domain */\r
+SKP_int SKP_Silk_LPC_inverse_pred_gain_Q24(   /* O:   Returns 1 if unstable, otherwise 0          */\r
+    SKP_int32           *invGain_Q30,           /* O:   Inverse prediction gain, Q30 energy domain  */\r
+    const SKP_int32     *A_Q24,                 /* I:   Prediction coefficients, Q24 [order]        */\r
+    const SKP_int       order                   /* I:   Prediction order                            */\r
+)\r
+{\r
+    SKP_int   k;\r
+    SKP_int32 Atmp_QA[ 2 ][ SKP_Silk_MAX_ORDER_LPC ];\r
+    SKP_int32 *Anew_QA;\r
 \r
-        /* Swap pointers */\r
-        Aold_QA = Anew_QA;\r
-        Anew_QA = Atmp_QA[ k & 1 ];\r
-        \r
-        /* Update AR coefficient */\r
-        headrm = SKP_Silk_CLZ32( rc_mult2_Q16 ) - 1;\r
-        rc_mult2_Q16 = SKP_LSHIFT( rc_mult2_Q16, headrm );          /* Q: 16 + headrm */\r
-        for( n = 0; n < k; n++ ) {\r
-            tmp_QA = Aold_QA[ n ] - SKP_LSHIFT( SKP_SMMUL( Aold_QA[ k - n - 1 ], rc_Q31 ), 1 );\r
-            Anew_QA[ n ] = SKP_LSHIFT( SKP_SMMUL( tmp_QA, rc_mult2_Q16 ), 16 - headrm );\r
-        }\r
-    }\r
+    Anew_QA = Atmp_QA[ order & 1 ];\r
 \r
-    /* Check for stability */\r
-    if( ( Anew_QA[ 0 ] > A_LIMIT ) || ( Anew_QA[ 0 ] < -A_LIMIT ) ) {\r
-        return 1;\r
+    /* Increase Q domain of the AR coefficients */\r
+    for( k = 0; k < order; k++ ) {\r
+        Anew_QA[ k ] = SKP_RSHIFT_ROUND( A_Q24[ k ], 24 - QA );\r
     }\r
 \r
-    /* Set RC equal to negated AR coef */\r
-    rc_Q31 = -SKP_LSHIFT( Anew_QA[ 0 ], 31 - QA );\r
-\r
-    /* Range: [ 1 : 2^30 ] */\r
-    rc_mult1_Q30 = ( SKP_int32_MAX >> 1 ) - SKP_SMMUL( rc_Q31, rc_Q31 );\r
-\r
-    /* Update inverse gain */\r
-    /* Range: [ 0 : 2^30 ] */\r
-    *invGain_Q30 = SKP_LSHIFT( SKP_SMMUL( *invGain_Q30, rc_mult1_Q30 ), 2 );\r
-    SKP_assert( *invGain_Q30 >= 0     );\r
-    SKP_assert( *invGain_Q30 <= 1<<30 );\r
-\r
-    return 0;\r
+    return LPC_inverse_pred_gain_QA( invGain_Q30, Atmp_QA, order );\r
 }\r
+\r
diff --git a/libs/silk/src/SKP_Silk_LPC_stabilize.c b/libs/silk/src/SKP_Silk_LPC_stabilize.c
deleted file mode 100644 (file)
index bd58d10..0000000
+++ /dev/null
@@ -1,132 +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_typedef.h"\r
-#include "SKP_Silk_SigProc_FIX.h"\r
-\r
-#define LPC_STABILIZE_LPC_MAX_ABS_VALUE_Q16     ( ( (SKP_int32)SKP_int16_MAX ) << 4 )\r
-\r
-/* LPC stabilizer, for a single input data vector */\r
-void SKP_Silk_LPC_stabilize(\r
-    SKP_int16       *a_Q12,         /* O    stabilized LPC vector [L]                       */\r
-    SKP_int32       *a_Q16,         /* I    LPC vector [L]                                  */\r
-    const SKP_int32  bwe_Q16,       /* I    Bandwidth expansion factor                      */\r
-    const SKP_int    L              /* I    Number of LPC parameters in the input vector    */\r
-)\r
-{\r
-    SKP_int32   maxabs, absval, sc_Q16;\r
-    SKP_int     i, idx = 0;\r
-    SKP_int32   invGain_Q30;\r
-\r
-    SKP_Silk_bwexpander_32( a_Q16, L, bwe_Q16 );\r
-\r
-    /***************************/\r
-    /* Limit range of the LPCs */\r
-    /***************************/\r
-    /* Limit the maximum absolute value of the prediction coefficients */\r
-    while( SKP_TRUE ) {\r
-        /* Find maximum absolute value and its index */\r
-        maxabs = SKP_int32_MIN;\r
-        for( i = 0; i < L; i++ ) {\r
-            absval = SKP_abs( a_Q16[ i ] );\r
-            if( absval > maxabs ) {\r
-                maxabs = absval;\r
-                idx    = i;\r
-            }\r
-        }\r
-    \r
-        if( maxabs >= LPC_STABILIZE_LPC_MAX_ABS_VALUE_Q16 ) {\r
-            /* Reduce magnitude of prediction coefficients */\r
-            sc_Q16 = SKP_DIV32( SKP_int32_MAX, SKP_RSHIFT( maxabs, 4 ) );\r
-            sc_Q16 = 65536 - sc_Q16;\r
-            sc_Q16 = SKP_DIV32( sc_Q16, idx + 1 );\r
-            sc_Q16 = 65536 - sc_Q16;\r
-            sc_Q16 = SKP_LSHIFT( SKP_SMULWB( sc_Q16, 32604 ), 1 ); // 0.995 in Q16\r
-            SKP_Silk_bwexpander_32( a_Q16, L, sc_Q16 );\r
-        } else {\r
-            break;\r
-        }\r
-    }\r
-\r
-    /* Convert to 16 bit Q12 */\r
-    for( i = 0; i < L; i++ ) {\r
-        a_Q12[ i ] = (SKP_int16)SKP_RSHIFT_ROUND( a_Q16[ i ], 4 );\r
-    }\r
-\r
-    /**********************/\r
-    /* Ensure stable LPCs */\r
-    /**********************/\r
-    while( SKP_Silk_LPC_inverse_pred_gain( &invGain_Q30, a_Q12, L ) == 1 ) {\r
-        SKP_Silk_bwexpander( a_Q12, L, 65339 ); // 0.997 in Q16\r
-    }\r
-}\r
-\r
-void SKP_Silk_LPC_fit(\r
-    SKP_int16       *a_QQ,          /* O    Stabilized LPC vector, Q(24-rshift) [L]         */\r
-    SKP_int32       *a_Q24,         /* I    LPC vector [L]                                  */\r
-    const SKP_int    QQ,            /* I    Q domain of output LPC vector                   */\r
-    const SKP_int    L              /* I    Number of LPC parameters in the input vector    */\r
-)\r
-{\r
-    SKP_int     i, rshift, idx = 0;\r
-    SKP_int32   maxabs, absval, sc_Q16;\r
-\r
-    rshift = 24 - QQ;\r
-\r
-    /***************************/\r
-    /* Limit range of the LPCs */\r
-    /***************************/\r
-    /* Limit the maximum absolute value of the prediction coefficients */\r
-    while( SKP_TRUE ) {\r
-        /* Find maximum absolute value and its index */\r
-        maxabs = SKP_int32_MIN;\r
-        for( i = 0; i < L; i++ ) {\r
-            absval = SKP_abs( a_Q24[ i ] );\r
-            if( absval > maxabs ) {\r
-                maxabs = absval;\r
-                idx    = i;\r
-            }\r
-        }\r
-    \r
-        maxabs = SKP_RSHIFT( maxabs, rshift );\r
-        if( maxabs >= SKP_int16_MAX ) {\r
-            /* Reduce magnitude of prediction coefficients */\r
-            sc_Q16 = 65470 - SKP_DIV32( SKP_MUL( 65470 >> 2, maxabs - SKP_int16_MAX ), \r
-                                        SKP_RSHIFT32( SKP_MUL( maxabs, idx + 1), 2 ) );\r
-            SKP_Silk_bwexpander_32( a_Q24, L, sc_Q16 );\r
-        } else {\r
-            break;\r
-        }\r
-    }\r
-\r
-    /* Convert to 16 bit Q(24-rshift) */\r
-    SKP_assert( rshift > 0  );\r
-    SKP_assert( rshift < 31 );\r
-    for( i = 0; i < L; i++ ) {\r
-        a_QQ[ i ] = (SKP_int16)SKP_RSHIFT_ROUND( a_Q24[ i ], rshift );\r
-    }\r
-}\r
index fff5e7001b790bd548dc5276f52c50cfb76abe1d..e5f8d24abbbbf43ace14ed99a6858d88d1d6c430 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -45,54 +45,40 @@ void SKP_Silk_LPC_synthesis_filter(
 )\r
 {\r
     SKP_int   k, j, idx, Order_half = SKP_RSHIFT( Order, 1 );\r
-    SKP_int32 SA, SB, Atmp, A_align_Q12[SigProc_MAX_ORDER_LPC >> 1], out32_Q10, out32;\r
+    SKP_int32 SA, SB, out32_Q10, out32;\r
 \r
     /* Order must be even */\r
-    SKP_assert( 2*Order_half == Order );\r
-\r
-    /* combine two A_Q12 values and ensure 32-bit alignment */\r
-    for( k = 0; k < Order_half; k++ ) {\r
-        idx = SKP_SMULBB( 2, k );\r
-        A_align_Q12[k] = (((SKP_int32)A_Q12[idx]) & 0x0000ffff) | SKP_LSHIFT( (SKP_int32)A_Q12[idx+1], 16 );\r
-    }\r
+    SKP_assert( 2 * Order_half == Order );\r
 \r
     /* S[] values are in Q14 */\r
     for( k = 0; k < len; k++ ) {\r
-        SA = S[Order-1];\r
+        SA = S[ Order - 1 ];\r
         out32_Q10 = 0;\r
-        for( j=0;j<(Order_half-1); j++ ) {\r
+        for( j = 0; j < ( Order_half - 1 ); j++ ) {\r
             idx = SKP_SMULBB( 2, j ) + 1;\r
-            /* multiply-add two prediction coefficients for each loop */\r
-            /* NOTE: the code below loads two int16 values in an int32, and multiplies each using the   */\r
-            /* SMLAWB and SMLAWT instructions. On a big-endian CPU the two int16 variables would be     */\r
-            /* loaded in reverse order and the code will give the wrong result. In that case swapping   */\r
-            /* the SMLAWB and SMLAWT instructions should solve the problem.                             */\r
-            Atmp = A_align_Q12[j];\r
-            SB = S[Order - 1 - idx];\r
-            S[Order - 1 - idx] = SA;\r
-            out32_Q10 = SKP_SMLAWB( out32_Q10, SA, Atmp );\r
-            out32_Q10 = SKP_SMLAWT( out32_Q10, SB, Atmp );\r
-            SA = S[Order - 2 - idx];\r
-            S[Order - 2 - idx] = SB;\r
+            SB = S[ Order - 1 - idx ];\r
+            S[ Order - 1 - idx ] = SA;\r
+            out32_Q10 = SKP_SMLAWB( out32_Q10, SA, A_Q12[ ( j << 1 ) ] );\r
+            out32_Q10 = SKP_SMLAWB( out32_Q10, SB, A_Q12[ ( j << 1 ) + 1 ] );\r
+            SA = S[ Order - 2 - idx ];\r
+            S[ Order - 2 - idx ] = SB;\r
         }\r
 \r
         /* unrolled loop: epilog */\r
-        Atmp = A_align_Q12[Order_half-1];\r
-        SB = S[0];\r
-        S[0] = SA;\r
-        out32_Q10 = SKP_SMLAWB( out32_Q10, SA, Atmp );\r
-        out32_Q10 = SKP_SMLAWT( out32_Q10, SB, Atmp );\r
-\r
+        SB = S[ 0 ];\r
+        S[ 0 ] = SA;\r
+        out32_Q10 = SKP_SMLAWB( out32_Q10, SA, A_Q12[ Order - 2 ] );\r
+        out32_Q10 = SKP_SMLAWB( out32_Q10, SB, A_Q12[ Order - 1 ] );\r
         /* apply gain to excitation signal and add to prediction */\r
-        out32_Q10 = SKP_ADD_SAT32( out32_Q10, SKP_SMULWB( Gain_Q26, in[k] ) );\r
+        out32_Q10 = SKP_ADD_SAT32( out32_Q10, SKP_SMULWB( Gain_Q26, in[ k ] ) );\r
 \r
         /* scale to Q0 */\r
         out32 = SKP_RSHIFT_ROUND( out32_Q10, 10 );\r
 \r
         /* saturate output */\r
-        out[k] = (SKP_int16)SKP_SAT16( out32 );\r
+        out[ k ] = ( SKP_int16 )SKP_SAT16( out32 );\r
 \r
         /* move result into delay line */\r
-        S[Order - 1] = SKP_LSHIFT_SAT32( out32_Q10, 4 );\r
+        S[ Order - 1 ] = SKP_LSHIFT_SAT32( out32_Q10, 4 );\r
     }\r
 }\r
index ec2d35857de765399dc6b643543db0678fb65585..82d8afd9cd9397c0b27ac26a20439e31aa274b57 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -43,98 +43,79 @@ void SKP_Silk_LPC_synthesis_order16(const SKP_int16 *in,          /* I:   excita
 )\r
 {\r
     SKP_int   k;\r
-    SKP_int32 SA, SB, Atmp, A_align_Q12[8], out32_Q10, out32;\r
-\r
-    /* combine two A_Q12 values and ensure 32-bit alignment */\r
-    for( k = 0; k < 8; k++ ) {\r
-        A_align_Q12[k] = (((SKP_int32)A_Q12[ 2*k ]) & 0x0000ffff) | SKP_LSHIFT( (SKP_int32)A_Q12[ 2*k + 1 ], 16 );\r
-    }\r
-\r
-    /* S[] values are in Q14 */\r
-    /* NOTE: the code below loads two int16 values in an int32, and multiplies each using the   */\r
-    /* SMLAWB and SMLAWT instructions. On a big-endian CPU the two int16 variables would be     */\r
-    /* loaded in reverse order and the code will give the wrong result. In that case swapping   */\r
-    /* the SMLAWB and SMLAWT instructions should solve the problem.                             */\r
+    SKP_int32 SA, SB, out32_Q10, out32;\r
     for( k = 0; k < len; k++ ) {\r
         /* unrolled loop: prolog */\r
         /* multiply-add two prediction coefficients per iteration */\r
-        SA = S[15];\r
-        Atmp = A_align_Q12[0];\r
-        SB = S[14];\r
-        S[14] = SA;\r
-        out32_Q10 = SKP_SMULWB(                  SA, Atmp );\r
-        out32_Q10 = SKP_SMLAWT_ovflw( out32_Q10, SB, Atmp );\r
-        SA = S[13];\r
-        S[13] = SB;\r
+        SA = S[ 15 ];\r
+        SB = S[ 14 ];\r
+        S[ 14 ] = SA;\r
+        out32_Q10 = SKP_SMULWB(                  SA, A_Q12[ 0 ] );\r
+        out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SB, A_Q12[ 1 ] );\r
+        SA = S[ 13 ];\r
+        S[ 13 ] = SB;\r
 \r
         /* unrolled loop: main loop */\r
-        Atmp = A_align_Q12[1];\r
-        SB = S[12];\r
-        S[12] = SA;\r
-        out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SA, Atmp );\r
-        out32_Q10 = SKP_SMLAWT_ovflw( out32_Q10, SB, Atmp );\r
-        SA = S[11];\r
-        S[11] = SB;\r
-\r
-        Atmp = A_align_Q12[2];\r
-        SB = S[10];\r
-        S[10] = SA;\r
-        out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SA, Atmp );\r
-        out32_Q10 = SKP_SMLAWT_ovflw( out32_Q10, SB, Atmp );\r
-        SA = S[9];\r
-        S[9] = SB;\r
-\r
-        Atmp = A_align_Q12[3];\r
-        SB = S[8];\r
-        S[8] = SA;\r
-        out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SA, Atmp );\r
-        out32_Q10 = SKP_SMLAWT_ovflw( out32_Q10, SB, Atmp );\r
-        SA = S[7];\r
-        S[7] = SB;\r
-\r
-        Atmp = A_align_Q12[4];\r
-        SB = S[6];\r
-        S[6] = SA;\r
-        out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SA, Atmp );\r
-        out32_Q10 = SKP_SMLAWT_ovflw( out32_Q10, SB, Atmp );\r
-        SA = S[5];\r
-        S[5] = SB;\r
-\r
-        Atmp = A_align_Q12[5];\r
-        SB = S[4];\r
-        S[4] = SA;\r
-        out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SA, Atmp );\r
-        out32_Q10 = SKP_SMLAWT_ovflw( out32_Q10, SB, Atmp );\r
-        SA = S[3];\r
-        S[3] = SB;\r
-\r
-        Atmp = A_align_Q12[6];\r
-        SB = S[2];\r
-        S[2] = SA;\r
-        out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SA, Atmp );\r
-        out32_Q10 = SKP_SMLAWT_ovflw( out32_Q10, SB, Atmp );\r
-        SA = S[1];\r
-        S[1] = SB;\r
+        SB = S[ 12 ];\r
+        S[ 12 ] = SA;\r
+        out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SA, A_Q12[ 2 ] );\r
+        out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SB, A_Q12[ 3 ] );\r
+        SA = S[ 11 ];\r
+        S[ 11 ] = SB;\r
+\r
+        SB = S[ 10 ];\r
+        S[ 10 ] = SA;\r
+        out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SA, A_Q12[ 4 ] );\r
+        out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SB, A_Q12[ 5 ] );\r
+        SA = S[ 9 ];\r
+        S[ 9 ] = SB;\r
+\r
+        SB = S[ 8 ];\r
+        S[ 8 ] = SA;\r
+        out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SA, A_Q12[ 6 ] );\r
+        out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SB, A_Q12[ 7 ] );\r
+        SA = S[ 7 ];\r
+        S[ 7 ] = SB;\r
+\r
+        SB = S[ 6 ];\r
+        S[ 6 ] = SA;\r
+        out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SA, A_Q12[ 8 ] );\r
+        out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SB, A_Q12[ 9 ] );\r
+        SA = S[ 5 ];\r
+        S[ 5 ] = SB;\r
+\r
+        SB = S[ 4 ];\r
+        S[ 4 ] = SA;\r
+        out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SA, A_Q12[ 10 ] );\r
+        out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SB, A_Q12[ 11 ] );\r
+        SA = S[ 3 ];\r
+        S[ 3 ] = SB;\r
+\r
+        SB = S[ 2 ];\r
+        S[ 2 ] = SA;\r
+        out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SA, A_Q12[ 12 ] );\r
+        out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SB, A_Q12[ 13 ] );\r
+        SA = S[ 1 ];\r
+        S[ 1 ] = SB;\r
 \r
         /* unrolled loop: epilog */\r
-        Atmp = A_align_Q12[7];\r
-        SB = S[0];\r
-        S[0] = SA;\r
-        out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SA, Atmp );\r
-        out32_Q10 = SKP_SMLAWT_ovflw( out32_Q10, SB, Atmp );\r
+        SB = S[ 0 ];\r
+        S[ 0 ] = SA;\r
+        out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SA, A_Q12[ 14 ] );\r
+        out32_Q10 = SKP_SMLAWB_ovflw( out32_Q10, SB, A_Q12[ 15 ] );\r
 \r
         /* unrolled loop: end */\r
         /* apply gain to excitation signal and add to prediction */\r
-        out32_Q10 = SKP_ADD_SAT32( out32_Q10, SKP_SMULWB( Gain_Q26, in[k] ) );\r
+        out32_Q10 = SKP_ADD_SAT32( out32_Q10, SKP_SMULWB( Gain_Q26, in[ k ] ) );\r
 \r
         /* scale to Q0 */\r
         out32 = SKP_RSHIFT_ROUND( out32_Q10, 10 );\r
 \r
         /* saturate output */\r
-        out[k] = (SKP_int16)SKP_SAT16( out32 );\r
+        out[ k ] = ( SKP_int16 )SKP_SAT16( out32 );\r
 \r
         /* move result into delay line */\r
-        S[15] = SKP_LSHIFT_SAT32( out32_Q10, 4 );\r
+        S[ 15 ] = SKP_LSHIFT_SAT32( out32_Q10, 4 );\r
     }\r
 }\r
 \r
index 87feef53616e47651e76db9856792f56d2046c7f..e0717431a42281d8e7e4ed7eb578b44f0ba85d3c 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -119,8 +119,8 @@ void SKP_Silk_LP_variable_cutoff(
     const SKP_int                   frame_length    /* I    Frame length                        */\r
 )\r
 {\r
-    SKP_int32   B_Q28[ TRANSITION_NB ], A_Q28[ TRANSITION_NA ];\r
-    SKP_int     fac_Q16 = 0, ind = 0;\r
+    SKP_int32   B_Q28[ TRANSITION_NB ], A_Q28[ TRANSITION_NA ], fac_Q16 = 0;\r
+    SKP_int     ind = 0;\r
 \r
     SKP_assert( psLP->transition_frame_no >= 0 );\r
     SKP_assert( ( ( ( psLP->transition_frame_no <= TRANSITION_FRAMES_DOWN ) && ( psLP->mode == 0 ) ) || \r
@@ -148,11 +148,13 @@ void SKP_Silk_LP_variable_cutoff(
                 /* Increment transition frame number for next frame */\r
                 psLP->transition_frame_no++;\r
 \r
-            } else if( psLP->transition_frame_no == TRANSITION_FRAMES_DOWN ) {\r
+            } else {\r
+                SKP_assert( psLP->transition_frame_no == TRANSITION_FRAMES_DOWN );\r
                 /* End of transition phase */\r
                 SKP_Silk_LP_interpolate_filter_taps( B_Q28, A_Q28, TRANSITION_INT_NUM - 1, 0 );\r
             }\r
-        } else if( psLP->mode == 1 ) {\r
+        } else {\r
+            SKP_assert( psLP->mode == 1 );\r
             if( psLP->transition_frame_no < TRANSITION_FRAMES_UP ) {\r
                 /* Calculate index and interpolation factor for interpolation */\r
 #if( TRANSITION_INT_STEPS_UP == 64 )\r
@@ -172,7 +174,8 @@ void SKP_Silk_LP_variable_cutoff(
                 /* Increment transition frame number for next frame */\r
                 psLP->transition_frame_no++;\r
             \r
-            } else if( psLP->transition_frame_no == TRANSITION_FRAMES_UP ) {\r
+            } else {\r
+                SKP_assert( psLP->transition_frame_no == TRANSITION_FRAMES_UP );\r
                 /* End of transition phase */\r
                 SKP_Silk_LP_interpolate_filter_taps( B_Q28, A_Q28, 0, 0 );\r
             }\r
index 099324ffa1072b11f12ea39cb136b383f8b025fe..1fc87a7af0fc4fc76e34d01e4eab64e652720fff 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
index af851c71345d0cc8e64e260ceecf875b7ab7587c..5013214d77db3119331542b724bfc724c711a40f 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -32,8 +32,7 @@ void SKP_Silk_LTP_analysis_filter_FIX(
     const SKP_int16 *x,                                 /* I:   Pointer to input signal with at least max( pitchL ) preceeding samples  */\r
     const SKP_int16 LTPCoef_Q14[ LTP_ORDER * NB_SUBFR ],/* I:   LTP_ORDER LTP coefficients for each NB_SUBFR subframe                   */\r
     const SKP_int   pitchL[ NB_SUBFR ],                 /* I:   Pitch lag, one for each subframe                                        */\r
-    const SKP_int32 invGains_Qxx[ NB_SUBFR ],           /* I:   Inverse quantization gains, one for each subframe                       */\r
-    const SKP_int   Qxx,                                /* I:   Inverse quantization gains Q domain                                     */\r
+    const SKP_int32 invGains_Q16[ NB_SUBFR ],           /* I:   Inverse quantization gains, one for each subframe                       */\r
     const SKP_int   subfr_length,                       /* I:   Length of each subframe                                                 */\r
     const SKP_int   pre_length                          /* I:   Length of the preceeding samples starting at &x[0] for each subframe    */\r
 )\r
@@ -61,18 +60,14 @@ void SKP_Silk_LTP_analysis_filter_FIX(
             LTP_est = SKP_SMULBB( x_lag_ptr[ LTP_ORDER / 2 ], Btmp_Q14[ 0 ] );\r
             for( j = 1; j < LTP_ORDER; j++ ) {\r
                 LTP_est = SKP_SMLABB_ovflw( LTP_est, x_lag_ptr[ LTP_ORDER / 2 - j ], Btmp_Q14[ j ] );\r
-            }\r
+                       }\r
             LTP_est = SKP_RSHIFT_ROUND( LTP_est, 14 ); // round and -> Q0\r
 \r
             /* Subtract long-term prediction */\r
             LTP_res_ptr[ i ] = ( SKP_int16 )SKP_SAT16( ( SKP_int32 )x_ptr[ i ] - LTP_est );\r
 \r
             /* Scale residual */\r
-            if( Qxx == 16 ) {\r
-                LTP_res_ptr[ i ] = SKP_SMULWB( invGains_Qxx[ k ], LTP_res_ptr[ i ] );\r
-            } else {\r
-                LTP_res_ptr[ i ] = ( SKP_int16 )SKP_CHECK_FIT16( SKP_RSHIFT64( SKP_SMULL( invGains_Qxx[ k ], LTP_res_ptr[ i ] ), Qxx ) );\r
-            }\r
+            LTP_res_ptr[ i ] = SKP_SMULWB( invGains_Q16[ k ], LTP_res_ptr[ i ] );\r
 \r
             x_lag_ptr++;\r
         }\r
index 4d69a8a4a0626bb542ae41963faa6ee4aa0bbf41..be4520caeadc582fb425450da62b8f6704f546fa 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -52,7 +52,7 @@ void SKP_Silk_LTP_scale_ctrl_FIX(
 \r
     /* combine input and filtered input */\r
     g_out_Q5    = SKP_RSHIFT_ROUND( SKP_RSHIFT( psEncCtrl->LTPredCodGain_Q7, 1 ) + SKP_RSHIFT( psEnc->HPLTPredCodGain_Q7, 1 ), 3 );\r
-    g_limit_Q15 = SKP_Silk_sigm_Q15( g_out_Q5 - ( 3 << 5 ) ); /* mulitplid with 0.5 */\r
+    g_limit_Q15 = SKP_Silk_sigm_Q15( g_out_Q5 - ( 3 << 5 ) );\r
             \r
     /* Default is minimum scaling */\r
     psEncCtrl->sCmn.LTP_scaleIndex = 0;\r
index cdfaca7cfacef29810ce77e22751da062935cb2c..1a12df9cff805d057c70d9eca3624482a55c5709 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -35,33 +35,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *                                                                      */\r
 #include "SKP_Silk_SigProc_FIX.h"\r
 \r
-/* Variable order MA filter */\r
-void SKP_Silk_MA(\r
-    const SKP_int16      *in,            /* I:   input signal                                */\r
-    const SKP_int16      *B,             /* I:   MA coefficients, Q13 [order+1]              */\r
-    SKP_int32            *S,             /* I/O: state vector [order]                        */\r
-    SKP_int16            *out,           /* O:   output signal                               */\r
-    const SKP_int32      len,            /* I:   signal length                               */\r
-    const SKP_int32      order           /* I:   filter order                                */\r
-)\r
-{\r
-    SKP_int   k, d, in16;\r
-    SKP_int32 out32;\r
-    \r
-    for( k = 0; k < len; k++ ) {\r
-        in16 = in[ k ];\r
-        out32 = SKP_SMLABB( S[ 0 ], in16, B[ 0 ] );\r
-        out32 = SKP_RSHIFT_ROUND( out32, 13 );\r
-        \r
-        for( d = 1; d < order; d++ ) {\r
-            S[ d - 1 ] = SKP_SMLABB( S[ d ], in16, B[ d ] );\r
-        }\r
-        S[ order - 1 ] = SKP_SMULBB( in16, B[ order ] );\r
-\r
-        /* Limit */\r
-        out[ k ] = (SKP_int16)SKP_SAT16( out32 );\r
-    }\r
-}\r
 /* Variable order MA prediction error filter */\r
 void SKP_Silk_MA_Prediction(\r
     const SKP_int16      *in,            /* I:   Input signal                                */\r
@@ -74,105 +47,23 @@ void SKP_Silk_MA_Prediction(
 {\r
     SKP_int   k, d, in16;\r
     SKP_int32 out32;\r
-    SKP_int32 B32;\r
 \r
-    if( ( order & 1 ) == 0 && (SKP_int32)( (SKP_int_ptr_size)B & 3 ) == 0 ) {\r
-        /* Even order and 4-byte aligned coefficient array */\r
-\r
-        /* NOTE: the code below loads two int16 values in an int32, and multiplies each using the    */\r
-        /* SMLABB and SMLABT instructions. On a big-endian CPU the two int16 variables would be      */\r
-        /* loaded in reverse order and the code will give the wrong result. In that case swapping    */\r
-        /* the SMLABB and SMLABT instructions should solve the problem.                              */\r
-        for( k = 0; k < len; k++ ) {\r
-            in16 = in[ k ];\r
-            out32 = SKP_LSHIFT( in16, 12 ) - S[ 0 ];\r
-            out32 = SKP_RSHIFT_ROUND( out32, 12 );\r
-            \r
-            for( d = 0; d < order - 2; d += 2 ) {\r
-                B32 = *( (SKP_int32*)&B[ d ] );                /* read two coefficients at once */\r
-                S[ d ]     = SKP_SMLABB_ovflw( S[ d + 1 ], in16, B32 );\r
-                S[ d + 1 ] = SKP_SMLABT_ovflw( S[ d + 2 ], in16, B32 );\r
-            }\r
-            B32 = *( (SKP_int32*)&B[ d ] );                    /* read two coefficients at once */\r
-            S[ order - 2 ] = SKP_SMLABB_ovflw( S[ order - 1 ], in16, B32 );\r
-            S[ order - 1 ] = SKP_SMULBT( in16, B32 );\r
-\r
-            /* Limit */\r
-            out[ k ] = (SKP_int16)SKP_SAT16( out32 );\r
+    for( k = 0; k < len; k++ ) {\r
+        in16 = in[ k ];\r
+        out32 = SKP_LSHIFT( in16, 12 ) - S[ 0 ];\r
+        out32 = SKP_RSHIFT_ROUND( out32, 12 );\r
+        \r
+        for( d = 0; d < order - 1; d++ ) {\r
+            S[ d ] = SKP_SMLABB_ovflw( S[ d + 1 ], in16, B[ d ] );\r
         }\r
-    } else {\r
-        /* Odd order or not 4-byte aligned coefficient array */\r
-        for( k = 0; k < len; k++ ) {\r
-            in16 = in[ k ];\r
-            out32 = SKP_LSHIFT( in16, 12 ) - S[ 0 ];\r
-            out32 = SKP_RSHIFT_ROUND( out32, 12 );\r
-            \r
-            for( d = 0; d < order - 1; d++ ) {\r
-                S[ d ] = SKP_SMLABB_ovflw( S[ d + 1 ], in16, B[ d ] );\r
-            }\r
-            S[ order - 1 ] = SKP_SMULBB( in16, B[ order - 1 ] );\r
+        S[ order - 1 ] = SKP_SMULBB( in16, B[ order - 1 ] );\r
 \r
-            /* Limit */\r
-            out[ k ] = (SKP_int16)SKP_SAT16( out32 );\r
-        }\r
+        /* Limit */\r
+        out[ k ] = (SKP_int16)SKP_SAT16( out32 );\r
     }\r
 }\r
 \r
-void SKP_Silk_MA_Prediction_Q13(\r
-    const SKP_int16      *in,            /* I:   input signal                                */\r
-    const SKP_int16      *B,             /* I:   MA prediction coefficients, Q13 [order]     */\r
-    SKP_int32            *S,             /* I/O: state vector [order]                        */\r
-    SKP_int16            *out,           /* O:   output signal                               */\r
-    SKP_int32            len,            /* I:   signal length                               */\r
-    SKP_int32            order           /* I:   filter order                                */\r
-)\r
-{\r
-    SKP_int   k, d, in16;\r
-    SKP_int32 out32, B32;\r
-    \r
-    if( ( order & 1 ) == 0 && (SKP_int32)( (SKP_int_ptr_size)B & 3 ) == 0 ) {\r
-        /* Even order and 4-byte aligned coefficient array */\r
-        \r
-        /* NOTE: the code below loads two int16 values in an int32, and multiplies each using the    */\r
-        /* SMLABB and SMLABT instructions. On a big-endian CPU the two int16 variables would be      */\r
-        /* loaded in reverse order and the code will give the wrong result. In that case swapping    */\r
-        /* the SMLABB and SMLABT instructions should solve the problem.                              */\r
-        for( k = 0; k < len; k++ ) {\r
-            in16 = in[ k ];\r
-            out32 = SKP_LSHIFT( in16, 13 ) - S[ 0 ];\r
-            out32 = SKP_RSHIFT_ROUND( out32, 13 );\r
-            \r
-            for( d = 0; d < order - 2; d += 2 ) {\r
-                B32 = *( (SKP_int32*)&B[ d ] );                /* read two coefficients at once */\r
-                S[ d ]     = SKP_SMLABB( S[ d + 1 ], in16, B32 );\r
-                S[ d + 1 ] = SKP_SMLABT( S[ d + 2 ], in16, B32 );\r
-            }\r
-            B32 = *( (SKP_int32*)&B[ d ] );                    /* read two coefficients at once */\r
-            S[ order - 2 ] = SKP_SMLABB( S[ order - 1 ], in16, B32 );\r
-            S[ order - 1 ] = SKP_SMULBT( in16, B32 );\r
-\r
-            /* Limit */\r
-            out[ k ] = (SKP_int16)SKP_SAT16( out32 );\r
-        }\r
-    } else {\r
-        /* Odd order or not 4-byte aligned coefficient array */\r
-        for( k = 0; k < len; k++ ) {\r
-            in16 = in[ k ];\r
-            out32 = SKP_LSHIFT( in16, 13 ) - S[ 0 ];\r
-            out32 = SKP_RSHIFT_ROUND( out32, 13 );\r
-            \r
-            for( d = 0; d < order - 1; d++ ) {\r
-                S[ d ] = SKP_SMLABB( S[ d + 1 ], in16, B[ d ] );\r
-            }\r
-            S[ order - 1 ] = SKP_SMULBB( in16, B[ order - 1 ] );\r
 \r
-            /* Limit */\r
-            out[ k ] = (SKP_int16)SKP_SAT16( out32 );\r
-        }\r
-    }\r
-}\r
-/* Variable order MA prediction error filter. */\r
-/* Inverse filter of SKP_Silk_LPC_synthesis_filter */\r
 void SKP_Silk_LPC_analysis_filter(\r
     const SKP_int16      *in,            /* I:   Input signal                                */\r
     const SKP_int16      *B,             /* I:   MA prediction coefficients, Q12 [order]     */\r
@@ -183,17 +74,11 @@ void SKP_Silk_LPC_analysis_filter(
 )\r
 {\r
     SKP_int   k, j, idx, Order_half = SKP_RSHIFT( Order, 1 );\r
-    SKP_int32 Btmp, B_align_Q12[ SigProc_MAX_ORDER_LPC >> 1 ], out32_Q12, out32;\r
+    SKP_int32 out32_Q12, out32;\r
     SKP_int16 SA, SB;\r
     /* Order must be even */\r
     SKP_assert( 2 * Order_half == Order );\r
 \r
-    /* Combine two A_Q12 values and ensure 32-bit alignment */\r
-    for( k = 0; k < Order_half; k++ ) {\r
-        idx = SKP_SMULBB( 2, k );\r
-        B_align_Q12[ k ] = ( ( (SKP_int32)B[ idx ] ) & 0x0000ffff ) | SKP_LSHIFT( (SKP_int32)B[ idx + 1 ], 16 );\r
-    }\r
-\r
     /* S[] values are in Q0 */\r
     for( k = 0; k < len; k++ ) {\r
         SA = S[ 0 ];\r
@@ -201,21 +86,19 @@ void SKP_Silk_LPC_analysis_filter(
         for( j = 0; j < ( Order_half - 1 ); j++ ) {\r
             idx = SKP_SMULBB( 2, j ) + 1;\r
             /* Multiply-add two prediction coefficients for each loop */\r
-            Btmp = B_align_Q12[ j ];\r
             SB = S[ idx ];\r
             S[ idx ] = SA;\r
-            out32_Q12 = SKP_SMLABB( out32_Q12, SA, Btmp );\r
-            out32_Q12 = SKP_SMLABT( out32_Q12, SB, Btmp );\r
+            out32_Q12 = SKP_SMLABB( out32_Q12, SA, B[ idx - 1 ] );\r
+            out32_Q12 = SKP_SMLABB( out32_Q12, SB, B[ idx ] );\r
             SA = S[ idx + 1 ];\r
             S[ idx + 1 ] = SB;\r
         }\r
 \r
         /* Unrolled loop: epilog */\r
-        Btmp = B_align_Q12[ Order_half - 1 ];\r
         SB = S[ Order - 1 ];\r
         S[ Order - 1 ] = SA;\r
-        out32_Q12 = SKP_SMLABB( out32_Q12, SA, Btmp );\r
-        out32_Q12 = SKP_SMLABT( out32_Q12, SB, Btmp );\r
+        out32_Q12 = SKP_SMLABB( out32_Q12, SA, B[ Order - 2 ] );\r
+        out32_Q12 = SKP_SMLABB( out32_Q12, SB, B[ Order - 1 ] );\r
 \r
         /* Subtract prediction */\r
         out32_Q12 = SKP_SUB_SAT32( SKP_LSHIFT( (SKP_int32)in[ k ], 12 ), out32_Q12 );\r
@@ -224,7 +107,7 @@ void SKP_Silk_LPC_analysis_filter(
         out32 = SKP_RSHIFT_ROUND( out32_Q12, 12 );\r
 \r
         /* Saturate output */\r
-        out[ k ] = (SKP_int16)SKP_SAT16( out32 );\r
+        out[ k ] = ( SKP_int16 )SKP_SAT16( out32 );\r
 \r
         /* Move input line */\r
         S[ 0 ] = in[ k ];\r
index 262b654561f4b19ff61409b44b04425d30fe78da..21f825c20e3abfab0a4b53e274f1c0d8a378c283 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -63,13 +63,13 @@ void SKP_Silk_NLSF2A(
 )\r
 {\r
     SKP_int k, i, dd;\r
-    SKP_int32 cos_LSF_Q20[SigProc_MAX_ORDER_LPC];\r
-    SKP_int32 P[SigProc_MAX_ORDER_LPC/2+1], Q[SigProc_MAX_ORDER_LPC/2+1];\r
+    SKP_int32 cos_LSF_Q20[SKP_Silk_MAX_ORDER_LPC];\r
+    SKP_int32 P[SKP_Silk_MAX_ORDER_LPC/2+1], Q[SKP_Silk_MAX_ORDER_LPC/2+1];\r
     SKP_int32 Ptmp, Qtmp;\r
     SKP_int32 f_int;\r
     SKP_int32 f_frac;\r
     SKP_int32 cos_val, delta;\r
-    SKP_int32 a_int32[SigProc_MAX_ORDER_LPC];\r
+    SKP_int32 a_int32[SKP_Silk_MAX_ORDER_LPC];\r
     SKP_int32 maxabs, absval, idx=0, sc_Q16; \r
 \r
     SKP_assert(LSF_COS_TAB_SZ_FIX == 128);\r
@@ -127,6 +127,7 @@ void SKP_Silk_NLSF2A(
     \r
         if( maxabs > SKP_int16_MAX ) {    \r
             /* Reduce magnitude of prediction coefficients */\r
+            maxabs = SKP_min( maxabs, 98369 ); // ( SKP_int32_MAX / ( 65470 >> 2 ) ) + SKP_int16_MAX = 98369 \r
             sc_Q16 = 65470 - SKP_DIV32( SKP_MUL( 65470 >> 2, maxabs - SKP_int16_MAX ), \r
                                         SKP_RSHIFT32( SKP_MUL( maxabs, idx + 1), 2 ) );\r
             SKP_Silk_bwexpander_32( a_int32, d, sc_Q16 );\r
index 05be911bc9022b2bd3b1224c1ce6e5a4e0a07cea..22e83c3a95027714f4b9563e73c916432ee1cfe3 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -42,7 +42,7 @@ void SKP_Silk_NLSF2A_stable(
     /* Ensure stable LPCs */\r
     for( i = 0; i < MAX_LPC_STABILIZE_ITERATIONS; i++ ) {\r
         if( SKP_Silk_LPC_inverse_pred_gain( &invGain_Q30, pAR_Q12, LPC_order ) == 1 ) {\r
-            SKP_Silk_bwexpander( pAR_Q12, LPC_order, 65536 - SKP_SMULBB( 66, i ) ); /* 66_Q16 = 0.001 */\r
+            SKP_Silk_bwexpander( pAR_Q12, LPC_order, 65536 - SKP_SMULBB( 10 + i, i ) );                /* 10_Q16 = 0.00015 */\r
         } else {\r
             break;\r
         }\r
@@ -50,6 +50,7 @@ void SKP_Silk_NLSF2A_stable(
 \r
     /* Reached the last iteration */\r
     if( i == MAX_LPC_STABILIZE_ITERATIONS ) {\r
+        SKP_assert( 0 );\r
         for( i = 0; i < LPC_order; i++ ) {\r
             pAR_Q12[ i ] = 0;\r
         }\r
index d5be46e99eab1f85257ba134998f4c23c6e8823e..7777c53726443595603913100903eb51ef0e4e34 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
index ba9255643e1ccdcfbc513762013b9adea510e263..e9e858e59aa897eb36e82428d589f5c65462f839 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -43,9 +43,8 @@ void SKP_Silk_NLSF_MSVQ_encode_FIX(
     const SKP_int                   deactivate_fluc_red     /* I    Deactivate fluctuation reduction        */\r
 )\r
 {\r
-    SKP_int     i, s, k, cur_survivors = 0, prev_survivors, input_index, cb_index, bestIndex;\r
+    SKP_int     i, s, k, cur_survivors = 0, prev_survivors, min_survivors, input_index, cb_index, bestIndex;\r
     SKP_int32   rateDistThreshold_Q18;\r
-    SKP_int     pNLSF_in_Q15[ MAX_LPC_ORDER ];\r
 #if( NLSF_MSVQ_FLUCTUATION_REDUCTION == 1 )\r
     SKP_int32   se_Q15, wsse_Q20, bestRateDist_Q20;\r
 #endif\r
@@ -75,14 +74,15 @@ void SKP_Silk_NLSF_MSVQ_encode_FIX(
     const SKP_int16 *pCB_element;\r
     const SKP_Silk_NLSF_CBS *pCurrentCBStage;\r
 \r
+#ifdef USE_UNQUANTIZED_LSFS\r
+    SKP_int NLSF_orig[ MAX_LPC_ORDER ];\r
+    SKP_memcpy( NLSF_orig, pNLSF_Q15, LPC_order * sizeof( SKP_int ) );\r
+#endif\r
+\r
     SKP_assert( NLSF_MSVQ_Survivors <= MAX_NLSF_MSVQ_SURVIVORS );\r
     SKP_assert( ( LOW_COMPLEXITY_ONLY == 0 ) || ( NLSF_MSVQ_Survivors <= MAX_NLSF_MSVQ_SURVIVORS_LC_MODE ) );\r
 \r
 \r
-\r
-    /* Copy the input vector */\r
-    SKP_memcpy( pNLSF_in_Q15, pNLSF_Q15, LPC_order * sizeof( SKP_int ) );\r
-\r
     /****************************************************/\r
     /* Tree search for the multi-stage vector quantizer */\r
     /****************************************************/\r
@@ -98,6 +98,9 @@ void SKP_Silk_NLSF_MSVQ_encode_FIX(
     /* Set first stage values */\r
     prev_survivors = 1;\r
 \r
+    /* Minimum number of survivors */\r
+    min_survivors = NLSF_MSVQ_Survivors / 2;\r
+\r
     /* Loop over all stages */\r
     for( s = 0; s < psNLSF_CB->nStages; s++ ) {\r
 \r
@@ -124,9 +127,10 @@ void SKP_Silk_NLSF_MSVQ_encode_FIX(
             prev_survivors * pCurrentCBStage->nVectors, cur_survivors );\r
 \r
         /* Discard survivors with rate-distortion values too far above the best one */\r
-        if( pRateDist_Q18[ 0 ] < SKP_int32_MAX / NLSF_MSVQ_SURV_MAX_REL_RD ) {\r
-            rateDistThreshold_Q18 = SKP_MUL( NLSF_MSVQ_SURV_MAX_REL_RD, pRateDist_Q18[ 0 ] );\r
-            while( pRateDist_Q18[ cur_survivors - 1 ] > rateDistThreshold_Q18 && cur_survivors > 1 ) {\r
+        if( pRateDist_Q18[ 0 ] < SKP_int32_MAX / MAX_NLSF_MSVQ_SURVIVORS ) {\r
+            rateDistThreshold_Q18 = SKP_SMLAWB( pRateDist_Q18[ 0 ], \r
+                SKP_MUL( NLSF_MSVQ_Survivors, pRateDist_Q18[ 0 ] ), SKP_FIX_CONST( NLSF_MSVQ_SURV_MAX_REL_RD, 16 ) );\r
+            while( pRateDist_Q18[ cur_survivors - 1 ] > rateDistThreshold_Q18 && cur_survivors > min_survivors ) {\r
                 cur_survivors--;\r
             }\r
         }\r
@@ -228,4 +232,8 @@ void SKP_Silk_NLSF_MSVQ_encode_FIX(
     /* Decode and stabilize the best survivor */\r
     SKP_Silk_NLSF_MSVQ_decode( pNLSF_Q15, psNLSF_CB, NLSFIndices, LPC_order );\r
 \r
+#ifdef USE_UNQUANTIZED_LSFS\r
+    SKP_memcpy( pNLSF_Q15, NLSF_orig, LPC_order * sizeof( SKP_int ) );\r
+#endif\r
+\r
 }\r
index 09e2bc717c59477fbb9ec6fe2549798dc2e88c21..6ab7bbbd008b7723e1e33fcc00e26c0114986504 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
index 7a2171ccecccc364b44f70488148a2b2672e1dd0..0ca3eb34daf3fecb5c185776525c6256e18841f2 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -27,6 +27,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 \r
 #include "SKP_Silk_main_FIX.h"\r
 \r
+\r
 /* Compute weighted quantization errors for an LPC_order element input vector, over one codebook stage */\r
 void SKP_Silk_NLSF_VQ_sum_error_FIX(\r
     SKP_int32                       *err_Q20,           /* O    Weighted quantization errors  [N*K]         */\r
@@ -77,3 +78,4 @@ void SKP_Silk_NLSF_VQ_sum_error_FIX(
     }\r
 }\r
 \r
+\r
index e7f4618c159dfbcc0ef2dc84ed40731000623d67..b6e44bc84884ffb33292d19bfd5ed1fb74e30017 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -34,6 +34,7 @@ Signal Processing, pp. 641-644, 1991.
 */\r
 \r
 #define Q_OUT                       6\r
+#define MIN_NDELTA                  3\r
 \r
 /* Laroia low complexity NLSF weights */\r
 void SKP_Silk_NLSF_VQ_weights_laroia(\r
@@ -50,28 +51,28 @@ void SKP_Silk_NLSF_VQ_weights_laroia(
     SKP_assert( ( D & 1 ) == 0 );\r
     \r
     /* First value */\r
-    tmp1_int = SKP_max_int( pNLSF_Q15[ 0 ], 1 );\r
+    tmp1_int = SKP_max_int( pNLSF_Q15[ 0 ], MIN_NDELTA );\r
     tmp1_int = SKP_DIV32_16( 1 << ( 15 + Q_OUT ), tmp1_int );\r
-    tmp2_int = SKP_max_int( pNLSF_Q15[ 1 ] - pNLSF_Q15[ 0 ], 1 );\r
+    tmp2_int = SKP_max_int( pNLSF_Q15[ 1 ] - pNLSF_Q15[ 0 ], MIN_NDELTA );\r
     tmp2_int = SKP_DIV32_16( 1 << ( 15 + Q_OUT ), tmp2_int );\r
     pNLSFW_Q6[ 0 ] = (SKP_int)SKP_min_int( tmp1_int + tmp2_int, SKP_int16_MAX );\r
     SKP_assert( pNLSFW_Q6[ 0 ] > 0 );\r
     \r
     /* Main loop */\r
     for( k = 1; k < D - 1; k += 2 ) {\r
-        tmp1_int = SKP_max_int( pNLSF_Q15[ k + 1 ] - pNLSF_Q15[ k ], 1 );\r
+        tmp1_int = SKP_max_int( pNLSF_Q15[ k + 1 ] - pNLSF_Q15[ k ], MIN_NDELTA );\r
         tmp1_int = SKP_DIV32_16( 1 << ( 15 + Q_OUT ), tmp1_int );\r
         pNLSFW_Q6[ k ] = (SKP_int)SKP_min_int( tmp1_int + tmp2_int, SKP_int16_MAX );\r
         SKP_assert( pNLSFW_Q6[ k ] > 0 );\r
 \r
-        tmp2_int = SKP_max_int( pNLSF_Q15[ k + 2 ] - pNLSF_Q15[ k + 1 ], 1 );\r
+        tmp2_int = SKP_max_int( pNLSF_Q15[ k + 2 ] - pNLSF_Q15[ k + 1 ], MIN_NDELTA );\r
         tmp2_int = SKP_DIV32_16( 1 << ( 15 + Q_OUT ), tmp2_int );\r
         pNLSFW_Q6[ k + 1 ] = (SKP_int)SKP_min_int( tmp1_int + tmp2_int, SKP_int16_MAX );\r
         SKP_assert( pNLSFW_Q6[ k + 1 ] > 0 );\r
     }\r
     \r
     /* Last value */\r
-    tmp1_int = SKP_max_int( ( 1 << 15 ) - pNLSF_Q15[ D - 1 ], 1 );\r
+    tmp1_int = SKP_max_int( ( 1 << 15 ) - pNLSF_Q15[ D - 1 ], MIN_NDELTA );\r
     tmp1_int = SKP_DIV32_16( 1 << ( 15 + Q_OUT ), tmp1_int );\r
     pNLSFW_Q6[ D - 1 ] = (SKP_int)SKP_min_int( tmp1_int + tmp2_int, SKP_int16_MAX );\r
     SKP_assert( pNLSFW_Q6[ D - 1 ] > 0 );\r
index 79325867d6fafadef2e1587e478236792fb6a729..f13eb0021d8ab212f7354e6bdb43f485c6260c45 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -106,7 +106,7 @@ void SKP_Silk_NLSF_stabilize(
             max_center_Q15 -= ( NDeltaMin_Q15[I] - SKP_RSHIFT( NDeltaMin_Q15[I], 1 ) );\r
 \r
             /* Move apart, sorted by value, keeping the same center frequency */\r
-            center_freq_Q15 = SKP_LIMIT( SKP_RSHIFT_ROUND( (SKP_int32)NLSF_Q15[I-1] + (SKP_int32)NLSF_Q15[I], 1 ),\r
+            center_freq_Q15 = SKP_LIMIT_32( SKP_RSHIFT_ROUND( (SKP_int32)NLSF_Q15[I-1] + (SKP_int32)NLSF_Q15[I], 1 ),\r
                 min_center_Q15, max_center_Q15 );\r
             NLSF_Q15[I-1] = center_freq_Q15 - SKP_RSHIFT( NDeltaMin_Q15[I], 1 );\r
             NLSF_Q15[I] = NLSF_Q15[I-1] + NDeltaMin_Q15[I];\r
@@ -137,18 +137,3 @@ void SKP_Silk_NLSF_stabilize(
     }\r
 }\r
 \r
-/* NLSF stabilizer, over multiple input column data vectors */\r
-void SKP_Silk_NLSF_stabilize_multi(\r
-          SKP_int        *NLSF_Q15,        /* I/O:  Unstable/stabilized normalized LSF vectors in Q15 [LxN]                 */\r
-    const SKP_int        *NDeltaMin_Q15,   /* I:    Normalized delta min vector in Q15, NDeltaMin_Q15[L] must be >= 1 [L+1] */\r
-    const SKP_int         N,               /* I:    Number of input vectors to be stabilized                                */\r
-    const SKP_int         L                /* I:    NLSF vector dimension                                                   */\r
-)\r
-{\r
-    SKP_int n;\r
-    \r
-    /* loop over input data */\r
-    for( n = 0; n < N; n++ ) {\r
-        SKP_Silk_NLSF_stabilize( &NLSF_Q15[n * L], NDeltaMin_Q15, L );\r
-    }\r
-}\r
index 19cb8ea652200c1540cae18f14b384785b68493d..939a9af968f8668677affc2366bafe290d0e0938 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -31,8 +31,8 @@ SKP_INLINE void SKP_Silk_nsq_scale_states(
     SKP_Silk_nsq_state  *NSQ,               /* I/O NSQ state                        */\r
     const SKP_int16     x[],                /* I input in Q0                        */\r
     SKP_int32           x_sc_Q10[],         /* O input scaled with 1/Gain           */\r
-    SKP_int             length,             /* I length of input                    */\r
-    SKP_int16           sLTP[],             /* I re-whitened LTP state in Q0        */\r
+    SKP_int             subfr_length,       /* I length of input                    */\r
+    const SKP_int16     sLTP[],             /* I re-whitened LTP state in Q0        */\r
     SKP_int32           sLTP_Q16[],         /* O LTP state matching scaled input    */\r
     SKP_int             subfr,              /* I subframe number                    */\r
     const SKP_int       LTP_scale_Q14,      /* I                                    */\r
@@ -44,7 +44,7 @@ SKP_INLINE void SKP_Silk_noise_shape_quantizer(
     SKP_Silk_nsq_state  *NSQ,               /* I/O  NSQ state                       */\r
     SKP_int             sigtype,            /* I    Signal type                     */\r
     const SKP_int32     x_sc_Q10[],         /* I                                    */\r
-    SKP_int             q[],                /* O                                    */\r
+    SKP_int8            q[],                /* O                                    */\r
     SKP_int16           xq[],               /* O                                    */\r
     SKP_int32           sLTP_Q16[],         /* I/O  LTP state                       */\r
     const SKP_int16     a_Q12[],            /* I    Short term prediction coefs     */\r
@@ -67,11 +67,11 @@ void SKP_Silk_NSQ(
     SKP_Silk_encoder_control        *psEncCtrlC,                                /* I    Encoder Control                     */\r
     SKP_Silk_nsq_state              *NSQ,                                       /* I/O  NSQ state                           */\r
     const SKP_int16                 x[],                                        /* I    prefiltered input signal            */\r
-    SKP_int                         q[],                                        /* O    quantized qulse signal              */\r
+    SKP_int8                        q[],                                        /* O    quantized qulse signal              */\r
     const SKP_int                   LSFInterpFactor_Q2,                         /* I    LSF interpolation factor in Q2      */\r
     const SKP_int16                 PredCoef_Q12[ 2 * MAX_LPC_ORDER ],          /* I    Short term prediction coefficients  */\r
     const SKP_int16                 LTPCoef_Q14[ LTP_ORDER * NB_SUBFR ],        /* I    Long term prediction coefficients   */\r
-    const SKP_int16                 AR2_Q13[ NB_SUBFR * SHAPE_LPC_ORDER_MAX ],  /* I                                        */\r
+    const SKP_int16                 AR2_Q13[ NB_SUBFR * MAX_SHAPE_LPC_ORDER ],  /* I                                        */\r
     const SKP_int                   HarmShapeGain_Q14[ NB_SUBFR ],              /* I                                        */\r
     const SKP_int                   Tilt_Q14[ NB_SUBFR ],                       /* I    Spectral tilt                       */\r
     const SKP_int32                 LF_shp_Q14[ NB_SUBFR ],                     /* I                                        */\r
@@ -113,25 +113,26 @@ void SKP_Silk_NSQ(
     for( k = 0; k < NB_SUBFR; k++ ) {\r
         A_Q12      = &PredCoef_Q12[ (( k >> 1 ) | ( 1 - LSF_interpolation_flag )) * MAX_LPC_ORDER ];\r
         B_Q14      = &LTPCoef_Q14[ k * LTP_ORDER ];\r
-        AR_shp_Q13 = &AR2_Q13[     k * SHAPE_LPC_ORDER_MAX ];\r
+        AR_shp_Q13 = &AR2_Q13[     k * MAX_SHAPE_LPC_ORDER ];\r
 \r
         /* Noise shape parameters */\r
         SKP_assert( HarmShapeGain_Q14[ k ] >= 0 );\r
-        HarmShapeFIRPacked_Q14  =                        SKP_RSHIFT( HarmShapeGain_Q14[ k ], 2 );\r
+        HarmShapeFIRPacked_Q14  =                          SKP_RSHIFT( HarmShapeGain_Q14[ k ], 2 );\r
         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
             /* Voiced */\r
             lag = psEncCtrlC->pitchL[ k ];\r
 \r
-            NSQ->rewhite_flag = 0;\r
             /* Re-whitening */\r
             if( ( k & ( 3 - SKP_LSHIFT( LSF_interpolation_flag, 1 ) ) ) == 0 ) {\r
+\r
                 /* Rewhiten with new A coefs */\r
-                \r
                 start_idx = psEncC->frame_length - lag - psEncC->predictLPCOrder - LTP_ORDER / 2;\r
-                start_idx = SKP_LIMIT( start_idx, 0, psEncC->frame_length - psEncC->predictLPCOrder ); /* Limit */\r
-                \r
+                SKP_assert( start_idx >= 0 );\r
+                SKP_assert( start_idx <= psEncC->frame_length - psEncC->predictLPCOrder );\r
+\r
                 SKP_memset( FiltState, 0, psEncC->predictLPCOrder * sizeof( SKP_int32 ) );\r
                 SKP_Silk_MA_Prediction( &NSQ->xq[ start_idx + k * ( psEncC->frame_length >> 2 ) ], \r
                     A_Q12, FiltState, sLTP + start_idx, psEncC->frame_length - start_idx, psEncC->predictLPCOrder );\r
@@ -154,14 +155,17 @@ void SKP_Silk_NSQ(
         pxq        += psEncC->subfr_length;\r
     }\r
 \r
-    /* Save scalars for this layer */\r
-    NSQ->sLF_AR_shp_Q12             = NSQ->sLF_AR_shp_Q12;\r
-    NSQ->prev_inv_gain_Q16          = NSQ->prev_inv_gain_Q16;\r
-    NSQ->lagPrev                        = psEncCtrlC->pitchL[ NB_SUBFR - 1 ];\r
+    /* Update lagPrev for next frame */\r
+    NSQ->lagPrev = psEncCtrlC->pitchL[ NB_SUBFR - 1 ];\r
+\r
     /* Save quantized speech and noise shaping signals */\r
     SKP_memcpy( NSQ->xq,           &NSQ->xq[           psEncC->frame_length ], psEncC->frame_length * sizeof( SKP_int16 ) );\r
     SKP_memcpy( NSQ->sLTP_shp_Q10, &NSQ->sLTP_shp_Q10[ psEncC->frame_length ], psEncC->frame_length * sizeof( SKP_int32 ) );\r
 \r
+#ifdef USE_UNQUANTIZED_LSFS\r
+    DEBUG_STORE_DATA( xq_unq_lsfs.pcm, NSQ->xq, psEncC->frame_length * sizeof( SKP_int16 ) );\r
+#endif\r
+\r
 }\r
 \r
 /***********************************/\r
@@ -171,7 +175,7 @@ SKP_INLINE void SKP_Silk_noise_shape_quantizer(
     SKP_Silk_nsq_state  *NSQ,               /* I/O  NSQ state                       */\r
     SKP_int             sigtype,            /* I    Signal type                     */\r
     const SKP_int32     x_sc_Q10[],         /* I                                    */\r
-    SKP_int             q[],                /* O                                    */\r
+    SKP_int8            q[],                /* O                                    */\r
     SKP_int16           xq[],               /* O                                    */\r
     SKP_int32           sLTP_Q16[],         /* I/O  LTP state                       */\r
     const SKP_int16     a_Q12[],            /* I    Short term prediction coefs     */\r
@@ -193,29 +197,22 @@ SKP_INLINE void SKP_Silk_noise_shape_quantizer(
     SKP_int32   LTP_pred_Q14, LPC_pred_Q10, n_AR_Q10, n_LTP_Q14;\r
     SKP_int32   n_LF_Q10, r_Q10, q_Q0, q_Q10;\r
     SKP_int32   thr1_Q10, thr2_Q10, thr3_Q10;\r
-    SKP_int32   Atmp, dither;\r
-    SKP_int32   exc_Q10, LPC_exc_Q10, xq_Q10;\r
-    SKP_int32   tmp, sLF_AR_shp_Q10;\r
-    SKP_int32   *psLPC_Q14;\r
-    SKP_int32   *shp_lag_ptr, *pred_lag_ptr;\r
-    SKP_int32   a_Q12_tmp[ MAX_LPC_ORDER / 2 ], AR_shp_Q13_tmp[ MAX_LPC_ORDER / 2 ];\r
+    SKP_int32   dither, exc_Q10, LPC_exc_Q10, xq_Q10;\r
+    SKP_int32   tmp1, tmp2, sLF_AR_shp_Q10;\r
+    SKP_int32   *psLPC_Q14, *shp_lag_ptr, *pred_lag_ptr;\r
 \r
     shp_lag_ptr  = &NSQ->sLTP_shp_Q10[ NSQ->sLTP_shp_buf_idx - lag + HARM_SHAPE_FIR_TAPS / 2 ];\r
     pred_lag_ptr = &sLTP_Q16[ NSQ->sLTP_buf_idx - lag + LTP_ORDER / 2 ];\r
     \r
     /* Setup short term AR state */\r
-    psLPC_Q14     = &NSQ->sLPC_Q14[ MAX_LPC_ORDER - 1 ];\r
+    psLPC_Q14 = &NSQ->sLPC_Q14[ NSQ_LPC_BUF_LENGTH - 1 ];\r
 \r
     /* Quantization thresholds */\r
-    thr1_Q10 = SKP_SUB_RSHIFT32( -1536, Lambda_Q10, 1);\r
-    thr2_Q10 = SKP_SUB_RSHIFT32( -512,  Lambda_Q10, 1);\r
+    thr1_Q10 = SKP_SUB_RSHIFT32( -1536, Lambda_Q10, 1 );\r
+    thr2_Q10 = SKP_SUB_RSHIFT32(  -512, Lambda_Q10, 1 );\r
     thr2_Q10 = SKP_ADD_RSHIFT32( thr2_Q10, SKP_SMULBB( offset_Q10, Lambda_Q10 ), 10 );\r
-    thr3_Q10 = SKP_ADD_RSHIFT32(  512,  Lambda_Q10, 1);\r
-    \r
-    /* Preload LPC coeficients to array on stack. Gives small performance gain */\r
-    SKP_memcpy( a_Q12_tmp, a_Q12, predictLPCOrder * sizeof( SKP_int16 ) );\r
-    SKP_memcpy( AR_shp_Q13_tmp, AR_shp_Q13, shapingLPCOrder * sizeof( SKP_int16 ) );\r
-    \r
+    thr3_Q10 = SKP_ADD_RSHIFT32(   512, Lambda_Q10, 1 );\r
+\r
     for( i = 0; i < length; i++ ) {\r
         /* Generate dither */\r
         NSQ->rand_seed = SKP_RAND( NSQ->rand_seed );\r
@@ -225,35 +222,23 @@ SKP_INLINE void SKP_Silk_noise_shape_quantizer(
                 \r
         /* Short-term prediction */\r
         SKP_assert( ( predictLPCOrder  & 1 ) == 0 );    /* check that order is even */\r
-        SKP_assert( ( (SKP_int64)a_Q12 & 3 ) == 0 );    /* check that array starts at 4-byte aligned address */\r
+        /* check that array starts at 4-byte aligned address */\r
+        SKP_assert( ( ( SKP_int64 )( ( SKP_int8* )a_Q12 - ( SKP_int8* )0 ) & 3 ) == 0 );\r
         SKP_assert( predictLPCOrder >= 10 );            /* check that unrolling works */\r
-\r
-        /* NOTE: the code below loads two int16 values in an int32, and multiplies each using the   */\r
-        /* SMLAWB and SMLAWT instructions. On a big-endian CPU the two int16 variables would be     */\r
-        /* loaded in reverse order and the code will give the wrong result. In that case swapping   */\r
-        /* the SMLAWB and SMLAWT instructions should solve the problem.                             */\r
         /* Partially unrolled */\r
-        Atmp = a_Q12_tmp[ 0 ];      /* read two coefficients at once */\r
-        LPC_pred_Q10 = SKP_SMULWB(               psLPC_Q14[ 0  ], Atmp );\r
-        LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psLPC_Q14[ -1 ], Atmp );\r
-        Atmp = a_Q12_tmp[ 1 ];\r
-        LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -2 ], Atmp );\r
-        LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psLPC_Q14[ -3 ], Atmp );\r
-        Atmp = a_Q12_tmp[ 2 ];\r
-        LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -4 ], Atmp );\r
-        LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psLPC_Q14[ -5 ], Atmp );\r
-        Atmp = a_Q12_tmp[ 3 ];\r
-        LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -6 ], Atmp );\r
-        LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psLPC_Q14[ -7 ], Atmp );\r
-        Atmp = a_Q12_tmp[ 4 ];\r
-        LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -8 ], Atmp );\r
-        LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psLPC_Q14[ -9 ], Atmp );\r
-        for( j = 10; j < predictLPCOrder; j += 2 ) {\r
-            Atmp = a_Q12_tmp[ j >> 1 ];     /* read two coefficients at once */\r
-            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -j     ], Atmp );\r
-            LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psLPC_Q14[ -j - 1 ], Atmp );\r
+        LPC_pred_Q10 = SKP_SMULWB(               psLPC_Q14[  0 ], a_Q12[ 0 ] );\r
+        LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -1 ], a_Q12[ 1 ] );\r
+        LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -2 ], a_Q12[ 2 ] );\r
+        LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -3 ], a_Q12[ 3 ] );\r
+        LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -4 ], a_Q12[ 4 ] );\r
+        LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -5 ], a_Q12[ 5 ] );\r
+        LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -6 ], a_Q12[ 6 ] );\r
+        LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -7 ], a_Q12[ 7 ] );\r
+        LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -8 ], a_Q12[ 8 ] );\r
+        LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -9 ], a_Q12[ 9 ] );\r
+        for( j = 10; j < predictLPCOrder; j ++ ) {\r
+            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -j ], a_Q12[ j ] );\r
         }\r
-\r
         /* Long-term prediction */\r
         if( sigtype == SIG_TYPE_VOICED ) {\r
             /* Unrolled loop */\r
@@ -268,83 +253,73 @@ SKP_INLINE void SKP_Silk_noise_shape_quantizer(
         }\r
 \r
         /* Noise shape feedback */\r
-        SKP_assert( ( shapingLPCOrder       & 1 ) == 0 );   /* check that order is even */\r
-        SKP_assert( ( (SKP_int64)AR_shp_Q13 & 3 ) == 0 );   /* check that array starts at 4-byte aligned address */\r
-        SKP_assert( shapingLPCOrder >= 12 );                /* check that unrolling works */\r
-\r
-        /* Partially unrolled */\r
-        Atmp = AR_shp_Q13_tmp[ 0 ];     /* read two coefficients at once */\r
-        n_AR_Q10 = SKP_SMULWB(           psLPC_Q14[ 0  ], Atmp );\r
-        n_AR_Q10 = SKP_SMLAWT( n_AR_Q10, psLPC_Q14[ -1 ], Atmp );\r
-        Atmp = AR_shp_Q13_tmp[ 1 ];\r
-        n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ -2 ], Atmp );\r
-        n_AR_Q10 = SKP_SMLAWT( n_AR_Q10, psLPC_Q14[ -3 ], Atmp );\r
-        Atmp = AR_shp_Q13_tmp[ 2 ];\r
-        n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ -4 ], Atmp );\r
-        n_AR_Q10 = SKP_SMLAWT( n_AR_Q10, psLPC_Q14[ -5 ], Atmp );\r
-        Atmp = AR_shp_Q13_tmp[ 3 ];\r
-        n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ -6 ], Atmp );\r
-        n_AR_Q10 = SKP_SMLAWT( n_AR_Q10, psLPC_Q14[ -7 ], Atmp );\r
-        Atmp = AR_shp_Q13_tmp[ 4 ];\r
-        n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ -8 ], Atmp );\r
-        n_AR_Q10 = SKP_SMLAWT( n_AR_Q10, psLPC_Q14[ -9 ], Atmp );\r
-        Atmp = AR_shp_Q13_tmp[ 5 ];\r
-        n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ -10 ], Atmp );\r
-        n_AR_Q10 = SKP_SMLAWT( n_AR_Q10, psLPC_Q14[ -11 ], Atmp );\r
-        for( j = 12; j < shapingLPCOrder; j += 2 ) {\r
-            Atmp = AR_shp_Q13_tmp[ j >> 1 ];        /* read two coefficients at once */\r
-            n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ -j     ], Atmp );\r
-            n_AR_Q10 = SKP_SMLAWT( n_AR_Q10, psLPC_Q14[ -j - 1 ], Atmp );\r
+        SKP_assert( ( shapingLPCOrder & 1 ) == 0 );   /* check that order is even */\r
+        tmp2 = psLPC_Q14[ 0 ];\r
+        tmp1 = NSQ->sAR2_Q14[ 0 ];\r
+        NSQ->sAR2_Q14[ 0 ] = tmp2;\r
+        n_AR_Q10 = SKP_SMULWB( tmp2, AR_shp_Q13[ 0 ] );\r
+        for( j = 2; j < shapingLPCOrder; j += 2 ) {\r
+            tmp2 = NSQ->sAR2_Q14[ j - 1 ];\r
+            NSQ->sAR2_Q14[ j - 1 ] = tmp1;\r
+            n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, tmp1, AR_shp_Q13[ j - 1 ] );\r
+            tmp1 = NSQ->sAR2_Q14[ j + 0 ];\r
+            NSQ->sAR2_Q14[ j + 0 ] = tmp2;\r
+            n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, tmp2, AR_shp_Q13[ j ] );\r
         }\r
+        NSQ->sAR2_Q14[ shapingLPCOrder - 1 ] = tmp1;\r
+        n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, tmp1, AR_shp_Q13[ shapingLPCOrder - 1 ] );\r
+\r
         n_AR_Q10 = SKP_RSHIFT( n_AR_Q10, 1 );   /* Q11 -> Q10 */\r
-        n_AR_Q10  = SKP_SMLAWB( n_AR_Q10, NSQ->sLF_AR_shp_Q12, Tilt_Q14 );\r
+        n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, NSQ->sLF_AR_shp_Q12, Tilt_Q14 );\r
 \r
-        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
+        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 || sigtype == SIG_TYPE_UNVOICED );\r
 \r
         /* Long-term shaping */\r
         if( lag > 0 ) {\r
             /* Symmetric, packed FIR coefficients */\r
             n_LTP_Q14 = SKP_SMULWB( SKP_ADD32( shp_lag_ptr[ 0 ], shp_lag_ptr[ -2 ] ), HarmShapeFIRPacked_Q14 );\r
             n_LTP_Q14 = SKP_SMLAWT( n_LTP_Q14, shp_lag_ptr[ -1 ],                     HarmShapeFIRPacked_Q14 );\r
-            shp_lag_ptr++;\r
             n_LTP_Q14 = SKP_LSHIFT( n_LTP_Q14, 6 );\r
+            shp_lag_ptr++;\r
         } else {\r
             n_LTP_Q14 = 0;\r
         }\r
 \r
         /* Input minus prediction plus noise feedback  */\r
         //r = x[ i ] - LTP_pred - LPC_pred + n_AR + n_Tilt + n_LF + n_LTP;\r
-        tmp   = SKP_SUB32( LTP_pred_Q14, n_LTP_Q14 );                       /* Add Q14 stuff */\r
-        tmp   = SKP_RSHIFT_ROUND( tmp, 4 );                                 /* round to Q10  */\r
-        tmp   = SKP_ADD32( tmp, LPC_pred_Q10 );                             /* add Q10 stuff */ \r
-        tmp   = SKP_SUB32( tmp, n_AR_Q10 );                                 /* subtract Q10 stuff */ \r
-        tmp   = SKP_SUB32( tmp, n_LF_Q10 );                                 /* subtract Q10 stuff */ \r
-        r_Q10 = SKP_SUB32( x_sc_Q10[ i ], tmp );\r
-\r
+        tmp1  = SKP_SUB32( LTP_pred_Q14, n_LTP_Q14 );                       /* Add Q14 stuff */\r
+        tmp1  = SKP_RSHIFT( tmp1, 4 );                                      /* convert to Q10  */\r
+        tmp1  = SKP_ADD32( tmp1, LPC_pred_Q10 );                            /* add Q10 stuff */ \r
+        tmp1  = SKP_SUB32( tmp1, n_AR_Q10 );                                /* subtract Q10 stuff */ \r
+        tmp1  = SKP_SUB32( tmp1, n_LF_Q10 );                                /* subtract Q10 stuff */ \r
+        r_Q10 = SKP_SUB32( x_sc_Q10[ i ], tmp1 );\r
 \r
         /* Flip sign depending on dither */\r
         r_Q10 = ( r_Q10 ^ dither ) - dither;\r
         r_Q10 = SKP_SUB32( r_Q10, offset_Q10 );\r
-        r_Q10 = SKP_LIMIT( r_Q10, -64 << 10, 64 << 10 );\r
+        r_Q10 = SKP_LIMIT_32( r_Q10, -64 << 10, 64 << 10 );\r
 \r
         /* Quantize */\r
-        if( r_Q10 < thr1_Q10 ) {\r
-            q_Q0 = SKP_RSHIFT_ROUND( SKP_ADD_RSHIFT32( r_Q10, Lambda_Q10, 1 ), 10 );\r
-            q_Q10 = SKP_LSHIFT( q_Q0, 10 );\r
-        } else if( r_Q10 < thr2_Q10 ) {\r
-            q_Q0 = -1;\r
-            q_Q10 = -1024;\r
-        } else if( r_Q10 > thr3_Q10 ) {\r
-            q_Q0 = SKP_RSHIFT_ROUND( SKP_SUB_RSHIFT32( r_Q10, Lambda_Q10, 1 ), 10 );\r
-            q_Q10 = SKP_LSHIFT( q_Q0, 10 );\r
+        q_Q0 = 0;\r
+        q_Q10 = 0;\r
+        if( r_Q10 < thr2_Q10 ) {\r
+            if( r_Q10 < thr1_Q10 ) {\r
+                q_Q0 = SKP_RSHIFT_ROUND( SKP_ADD_RSHIFT32( r_Q10, Lambda_Q10, 1 ), 10 );\r
+                q_Q10 = SKP_LSHIFT( q_Q0, 10 );\r
+            } else {\r
+                q_Q0 = -1;\r
+                q_Q10 = -1024;\r
+            }\r
         } else {\r
-            q_Q0 = 0;\r
-            q_Q10 = 0;\r
+            if( r_Q10 > thr3_Q10 ) {\r
+                q_Q0 = SKP_RSHIFT_ROUND( SKP_SUB_RSHIFT32( r_Q10, Lambda_Q10, 1 ), 10 );\r
+                q_Q10 = SKP_LSHIFT( q_Q0, 10 );\r
+            }\r
         }\r
-        q[ i ] = q_Q0;\r
+        q[ i ] = ( SKP_int8 )q_Q0; /* No saturation needed because max is 64 */\r
 \r
         /* Excitation */\r
         exc_Q10 = SKP_ADD32( q_Q10, offset_Q10 );\r
@@ -365,23 +340,24 @@ SKP_INLINE void SKP_Silk_noise_shape_quantizer(
         NSQ->sLF_AR_shp_Q12 = SKP_LSHIFT( sLF_AR_shp_Q10, 2 );\r
 \r
         NSQ->sLTP_shp_Q10[ NSQ->sLTP_shp_buf_idx ] = SKP_SUB32( sLF_AR_shp_Q10, n_LF_Q10 );\r
-        sLTP_Q16[NSQ->sLTP_buf_idx] = SKP_LSHIFT( LPC_exc_Q10, 6 );\r
+        sLTP_Q16[ NSQ->sLTP_buf_idx ] = SKP_LSHIFT( LPC_exc_Q10, 6 );\r
         NSQ->sLTP_shp_buf_idx++;\r
         NSQ->sLTP_buf_idx++;\r
 \r
         /* Make dither dependent on quantized signal */\r
         NSQ->rand_seed += q[ i ];\r
     }\r
+\r
     /* Update LPC synth buffer */\r
-    SKP_memcpy( NSQ->sLPC_Q14, &NSQ->sLPC_Q14[ length ], MAX_LPC_ORDER * sizeof( SKP_int32 ) );\r
+    SKP_memcpy( NSQ->sLPC_Q14, &NSQ->sLPC_Q14[ length ], NSQ_LPC_BUF_LENGTH * sizeof( SKP_int32 ) );\r
 }\r
 \r
 SKP_INLINE void SKP_Silk_nsq_scale_states(\r
     SKP_Silk_nsq_state  *NSQ,               /* I/O NSQ state                        */\r
     const SKP_int16     x[],                /* I input in Q0                        */\r
     SKP_int32           x_sc_Q10[],         /* O input scaled with 1/Gain           */\r
-    SKP_int             length,             /* I length of input                    */\r
-    SKP_int16           sLTP[],             /* I re-whitened LTP state in Q0        */\r
+    SKP_int             subfr_length,       /* I length of input                    */\r
+    const SKP_int16     sLTP[],             /* I re-whitened LTP state in Q0        */\r
     SKP_int32           sLTP_Q16[],         /* O LTP state matching scaled input    */\r
     SKP_int             subfr,              /* I subframe number                    */\r
     const SKP_int       LTP_scale_Q14,      /* I                                    */\r
@@ -389,14 +365,14 @@ SKP_INLINE void SKP_Silk_nsq_scale_states(
     const SKP_int       pitchL[ NB_SUBFR ]  /* I                                    */\r
 )\r
 {\r
-    SKP_int   i, scale_length, lag;\r
+    SKP_int   i, lag;\r
     SKP_int32 inv_gain_Q16, gain_adj_Q16, inv_gain_Q32;\r
 \r
-    inv_gain_Q16 = SKP_DIV32( SKP_int32_MAX, SKP_RSHIFT( Gains_Q16[ subfr ], 1) );\r
+    inv_gain_Q16 = SKP_INVERSE32_varQ( SKP_max( Gains_Q16[ subfr ], 1 ), 32 );\r
     inv_gain_Q16 = SKP_min( inv_gain_Q16, SKP_int16_MAX );\r
     lag          = pitchL[ subfr ];\r
 \r
-    /* After rewhitening the LTP state is un-scaled */\r
+    /* After rewhitening the LTP state is un-scaled, so scale with inv_gain_Q16 */\r
     if( NSQ->rewhite_flag ) {\r
         inv_gain_Q32 = SKP_LSHIFT( inv_gain_Q16, 16 );\r
         if( subfr == 0 ) {\r
@@ -404,39 +380,40 @@ SKP_INLINE void SKP_Silk_nsq_scale_states(
             inv_gain_Q32 = SKP_LSHIFT( SKP_SMULWB( inv_gain_Q32, LTP_scale_Q14 ), 2 );\r
         }\r
         for( i = NSQ->sLTP_buf_idx - lag - LTP_ORDER / 2; i < NSQ->sLTP_buf_idx; i++ ) {\r
+            SKP_assert( i < MAX_FRAME_LENGTH );\r
             sLTP_Q16[ i ] = SKP_SMULWB( inv_gain_Q32, sLTP[ i ] );\r
         }\r
     }\r
 \r
-    /* Prepare for Worst case. Next frame starts with max lag voiced */\r
-    scale_length = length * NB_SUBFR;                                           /* approx max lag */\r
-    scale_length = scale_length - SKP_SMULBB( NB_SUBFR - (subfr + 1), length ); /* subtract samples that will be too old in next frame */\r
-    scale_length = SKP_max_int( scale_length, lag + LTP_ORDER );                /* make sure to scale whole pitch period if voiced */\r
-\r
     /* Adjust for changing gain */\r
     if( inv_gain_Q16 != NSQ->prev_inv_gain_Q16 ) {\r
-        gain_adj_Q16 =  SKP_DIV32_varQ( inv_gain_Q16, NSQ->prev_inv_gain_Q16, 16 );\r
+        gain_adj_Q16 = SKP_DIV32_varQ( inv_gain_Q16, NSQ->prev_inv_gain_Q16, 16 );\r
 \r
-        for( i = NSQ->sLTP_shp_buf_idx - scale_length; i < NSQ->sLTP_shp_buf_idx; i++ ) {\r
+        /* Scale long-term shaping state */\r
+        for( i = NSQ->sLTP_shp_buf_idx - subfr_length * NB_SUBFR; i < NSQ->sLTP_shp_buf_idx; i++ ) {\r
             NSQ->sLTP_shp_Q10[ i ] = SKP_SMULWW( gain_adj_Q16, NSQ->sLTP_shp_Q10[ i ] );\r
         }\r
 \r
-        /* Scale LTP predict state */\r
+        /* Scale long-term prediction state */\r
         if( NSQ->rewhite_flag == 0 ) {\r
             for( i = NSQ->sLTP_buf_idx - lag - LTP_ORDER / 2; i < NSQ->sLTP_buf_idx; i++ ) {\r
                 sLTP_Q16[ i ] = SKP_SMULWW( gain_adj_Q16, sLTP_Q16[ i ] );\r
             }\r
         }\r
+\r
         NSQ->sLF_AR_shp_Q12 = SKP_SMULWW( gain_adj_Q16, NSQ->sLF_AR_shp_Q12 );\r
 \r
-        /* scale short term state */\r
-        for( i = 0; i < MAX_LPC_ORDER; i++ ) {\r
+        /* Scale short-term prediction and shaping states */\r
+        for( i = 0; i < NSQ_LPC_BUF_LENGTH; i++ ) {\r
             NSQ->sLPC_Q14[ i ] = SKP_SMULWW( gain_adj_Q16, NSQ->sLPC_Q14[ i ] );\r
         }\r
+        for( i = 0; i < MAX_SHAPE_LPC_ORDER; i++ ) {\r
+            NSQ->sAR2_Q14[ i ] = SKP_SMULWW( gain_adj_Q16, NSQ->sAR2_Q14[ i ] );\r
+        }\r
     }\r
 \r
     /* Scale input */\r
-    for( i = 0; i < length; i++ ) {\r
+    for( i = 0; i < subfr_length; i++ ) {\r
         x_sc_Q10[ i ] = SKP_RSHIFT( SKP_SMULBB( x[ i ], ( SKP_int16 )inv_gain_Q16 ), 6 );\r
     }\r
 \r
index 360126312f45f6258d77a88a9add4a7f2029be82..2ef9539a1d1f761256dd5df00df28de04116964b 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -28,12 +28,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "SKP_Silk_main.h"\r
 \r
 typedef struct {\r
-    SKP_int   RandState[ DECISION_DELAY ];\r
+    SKP_int32 RandState[ DECISION_DELAY ];\r
     SKP_int32 Q_Q10[     DECISION_DELAY ];\r
     SKP_int32 Xq_Q10[    DECISION_DELAY ];\r
     SKP_int32 Pred_Q16[  DECISION_DELAY ];\r
     SKP_int32 Shape_Q10[ DECISION_DELAY ];\r
     SKP_int32 Gain_Q16[  DECISION_DELAY ];\r
+    SKP_int32 sAR2_Q14[ MAX_SHAPE_LPC_ORDER ];\r
     SKP_int32 sLPC_Q14[ MAX_FRAME_LENGTH / NB_SUBFR + NSQ_LPC_BUF_LENGTH ];\r
     SKP_int32 LF_AR_Q12;\r
     SKP_int32 Seed;\r
@@ -61,8 +62,8 @@ SKP_INLINE void SKP_Silk_nsq_del_dec_scale_states(
     NSQ_del_dec_struct  psDelDec[],             /* I/O  Delayed decision states             */\r
     const SKP_int16     x[],                    /* I    Input in Q0                         */\r
     SKP_int32           x_sc_Q10[],             /* O    Input scaled with 1/Gain in Q10     */\r
-    SKP_int             length,                 /* I    Length of input                     */\r
-    SKP_int16           sLTP[],                 /* I    Re-whitened LTP state in Q0         */\r
+    SKP_int             subfr_length,           /* I    Length of input                     */\r
+    const SKP_int16     sLTP[],                 /* I    Re-whitened LTP state in Q0         */\r
     SKP_int32           sLTP_Q16[],             /* O    LTP state matching scaled input     */\r
     SKP_int             subfr,                  /* I    Subframe number                     */\r
     SKP_int             nStatesDelayedDecision, /* I    Number of del dec states            */\r
@@ -80,7 +81,7 @@ SKP_INLINE void SKP_Silk_noise_shape_quantizer_del_dec(
     NSQ_del_dec_struct  psDelDec[],             /* I/O  Delayed decision states             */\r
     SKP_int             sigtype,                /* I    Signal type                         */\r
     const SKP_int32     x_Q10[],                /* I                                        */\r
-    SKP_int             q[],                    /* O                                        */\r
+    SKP_int8            q[],                    /* O                                        */\r
     SKP_int16           xq[],                   /* O                                        */\r
     SKP_int32           sLTP_Q16[],             /* I/O  LTP filter state                    */\r
     const SKP_int16     a_Q12[],                /* I    Short term prediction coefs         */\r
@@ -96,7 +97,8 @@ SKP_INLINE void SKP_Silk_noise_shape_quantizer_del_dec(
     SKP_int             length,                 /* I    Input length                        */\r
     SKP_int             subfr,                  /* I    Subframe number                     */\r
     SKP_int             shapingLPCOrder,        /* I    Shaping LPC filter order            */\r
-    SKP_int             predictLPCOrder,        /* I    Prediction LPC filter order         */\r
+    SKP_int             predictLPCOrder,        /* I    Prediction filter order             */\r
+    SKP_int             warping_Q16,            /* I                                        */\r
     SKP_int             nStatesDelayedDecision, /* I    Number of states in decision tree   */\r
     SKP_int             *smpl_buf_idx,          /* I    Index to newest samples in buffers  */\r
     SKP_int             decisionDelay           /* I                                        */\r
@@ -107,11 +109,11 @@ void SKP_Silk_NSQ_del_dec(
     SKP_Silk_encoder_control        *psEncCtrlC,                                /* I    Encoder Control                     */\r
     SKP_Silk_nsq_state              *NSQ,                                       /* I/O  NSQ state                           */\r
     const SKP_int16                 x[],                                        /* I    Prefiltered input signal            */\r
-    SKP_int                         q[],                                        /* O    Quantized pulse signal              */\r
+    SKP_int8                        q[],                                        /* O    Quantized pulse signal              */\r
     const SKP_int                   LSFInterpFactor_Q2,                         /* I    LSF interpolation factor in Q2      */\r
     const SKP_int16                 PredCoef_Q12[ 2 * MAX_LPC_ORDER ],          /* I    Prediction coefs                    */\r
     const SKP_int16                 LTPCoef_Q14[ LTP_ORDER * NB_SUBFR ],        /* I    LT prediction coefs                 */\r
-    const SKP_int16                 AR2_Q13[ NB_SUBFR * SHAPE_LPC_ORDER_MAX ],  /* I                                        */\r
+    const SKP_int16                 AR2_Q13[ NB_SUBFR * MAX_SHAPE_LPC_ORDER ],  /* I                                        */\r
     const SKP_int                   HarmShapeGain_Q14[ NB_SUBFR ],              /* I                                        */\r
     const SKP_int                   Tilt_Q14[ NB_SUBFR ],                       /* I    Spectral tilt                       */\r
     const SKP_int32                 LF_shp_Q14[ NB_SUBFR ],                     /* I                                        */\r
@@ -130,7 +132,7 @@ void SKP_Silk_NSQ_del_dec(
     SKP_int     offset_Q10;\r
     SKP_int32   FiltState[ MAX_LPC_ORDER ], RDmin_Q10;\r
     SKP_int32   x_sc_Q10[ MAX_FRAME_LENGTH / NB_SUBFR ];\r
-    NSQ_del_dec_struct psDelDec[ DEL_DEC_STATES_MAX ];\r
+    NSQ_del_dec_struct psDelDec[ MAX_DEL_DEC_STATES ];\r
     NSQ_del_dec_struct *psDD;\r
 \r
     subfr_length = psEncC->frame_length / NB_SUBFR;\r
@@ -150,17 +152,23 @@ void SKP_Silk_NSQ_del_dec(
         psDD->LF_AR_Q12      = NSQ->sLF_AR_shp_Q12;\r
         psDD->Shape_Q10[ 0 ] = NSQ->sLTP_shp_Q10[ psEncC->frame_length - 1 ];\r
         SKP_memcpy( psDD->sLPC_Q14, NSQ->sLPC_Q14, NSQ_LPC_BUF_LENGTH * sizeof( SKP_int32 ) );\r
+        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
     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
         for( k = 0; k < NB_SUBFR; k++ ) {\r
             decisionDelay = SKP_min_int( decisionDelay, psEncCtrlC->pitchL[ k ] - LTP_ORDER / 2 - 1 );\r
         }\r
+    } else {\r
+        if( lag > 0 ) {\r
+            decisionDelay = SKP_min_int( decisionDelay, lag - LTP_ORDER / 2 - 1 );\r
+        }\r
     }\r
 \r
     if( LSFInterpFactor_Q2 == ( 1 << 2 ) ) {\r
@@ -177,7 +185,12 @@ void SKP_Silk_NSQ_del_dec(
     for( k = 0; k < NB_SUBFR; k++ ) {\r
         A_Q12      = &PredCoef_Q12[ ( ( k >> 1 ) | ( 1 - LSF_interpolation_flag ) ) * MAX_LPC_ORDER ];\r
         B_Q14      = &LTPCoef_Q14[ k * LTP_ORDER           ];\r
-        AR_shp_Q13 = &AR2_Q13[     k * SHAPE_LPC_ORDER_MAX ];\r
+        AR_shp_Q13 = &AR2_Q13[     k * MAX_SHAPE_LPC_ORDER ];\r
+\r
+        /* Noise shape parameters */\r
+        SKP_assert( HarmShapeGain_Q14[ k ] >= 0 );\r
+        HarmShapeFIRPacked_Q14  =                          SKP_RSHIFT( HarmShapeGain_Q14[ k ], 2 );\r
+        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
@@ -209,7 +222,7 @@ void SKP_Silk_NSQ_del_dec(
                     last_smple_idx = smpl_buf_idx + decisionDelay;\r
                     for( i = 0; i < decisionDelay; i++ ) {\r
                         last_smple_idx = ( last_smple_idx - 1 ) & DECISION_DELAY_MASK;\r
-                        q[   i - decisionDelay ] = ( SKP_int )SKP_RSHIFT( psDD->Q_Q10[ last_smple_idx ], 10 );\r
+                        q[   i - decisionDelay ] = ( SKP_int8 )SKP_RSHIFT( psDD->Q_Q10[ last_smple_idx ], 10 );\r
                         pxq[ i - decisionDelay ] = ( SKP_int16 )SKP_SAT16( SKP_RSHIFT_ROUND( \r
                             SKP_SMULWW( psDD->Xq_Q10[ last_smple_idx ], \r
                             psDD->Gain_Q16[ last_smple_idx ] ), 10 ) );\r
@@ -221,8 +234,9 @@ void SKP_Silk_NSQ_del_dec(
 \r
                 /* Rewhiten with new A coefs */\r
                 start_idx = psEncC->frame_length - lag - psEncC->predictLPCOrder - LTP_ORDER / 2;\r
-                start_idx = SKP_LIMIT( start_idx, 0, psEncC->frame_length - psEncC->predictLPCOrder );\r
-                \r
+                SKP_assert( start_idx >= 0 );\r
+                SKP_assert( start_idx <= psEncC->frame_length - psEncC->predictLPCOrder );\r
+\r
                 SKP_memset( FiltState, 0, psEncC->predictLPCOrder * sizeof( SKP_int32 ) );\r
                 SKP_Silk_MA_Prediction( &NSQ->xq[ start_idx + k * psEncC->subfr_length ], \r
                     A_Q12, FiltState, sLTP + start_idx, psEncC->frame_length - start_idx, psEncC->predictLPCOrder );\r
@@ -232,11 +246,6 @@ void SKP_Silk_NSQ_del_dec(
             }\r
         }\r
 \r
-        /* Noise shape parameters */\r
-        SKP_assert( HarmShapeGain_Q14[ k ] >= 0 );\r
-        HarmShapeFIRPacked_Q14  =                        SKP_RSHIFT( HarmShapeGain_Q14[ k ], 2 );\r
-        HarmShapeFIRPacked_Q14 |= SKP_LSHIFT( ( SKP_int32 )SKP_RSHIFT( HarmShapeGain_Q14[ k ], 1 ), 16 );\r
-\r
         SKP_Silk_nsq_del_dec_scale_states( NSQ, psDelDec, x, x_sc_Q10, \r
             subfr_length, sLTP, sLTP_Q16, k, psEncC->nStatesDelayedDecision, smpl_buf_idx,\r
             LTP_scale_Q14, Gains_Q16, psEncCtrlC->pitchL );\r
@@ -244,8 +253,7 @@ void SKP_Silk_NSQ_del_dec(
         SKP_Silk_noise_shape_quantizer_del_dec( NSQ, psDelDec, psEncCtrlC->sigtype, 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->nStatesDelayedDecision, &smpl_buf_idx, decisionDelay \r
-        );\r
+            psEncC->warping_Q16, psEncC->nStatesDelayedDecision, &smpl_buf_idx, decisionDelay );\r
         \r
         x   += psEncC->subfr_length;\r
         q   += psEncC->subfr_length;\r
@@ -268,24 +276,27 @@ void SKP_Silk_NSQ_del_dec(
     last_smple_idx = smpl_buf_idx + decisionDelay;\r
     for( i = 0; i < decisionDelay; i++ ) {\r
         last_smple_idx = ( last_smple_idx - 1 ) & DECISION_DELAY_MASK;\r
-        q[   i - decisionDelay ] = ( SKP_int )SKP_RSHIFT( psDD->Q_Q10[ last_smple_idx ], 10 );\r
+        q[   i - decisionDelay ] = ( SKP_int8 )SKP_RSHIFT( psDD->Q_Q10[ last_smple_idx ], 10 );\r
         pxq[ i - decisionDelay ] = ( SKP_int16 )SKP_SAT16( SKP_RSHIFT_ROUND( \r
             SKP_SMULWW( psDD->Xq_Q10[ last_smple_idx ], psDD->Gain_Q16[ last_smple_idx ] ), 10 ) );\r
         NSQ->sLTP_shp_Q10[ NSQ->sLTP_shp_buf_idx - decisionDelay + i ] = psDD->Shape_Q10[ last_smple_idx ];\r
         sLTP_Q16[          NSQ->sLTP_buf_idx     - decisionDelay + i ] = psDD->Pred_Q16[  last_smple_idx ];\r
-\r
     }\r
     SKP_memcpy( NSQ->sLPC_Q14, &psDD->sLPC_Q14[ psEncC->subfr_length ], NSQ_LPC_BUF_LENGTH * sizeof( SKP_int32 ) );\r
+    SKP_memcpy( NSQ->sAR2_Q14, psDD->sAR2_Q14, sizeof( psDD->sAR2_Q14 ) );\r
 \r
     /* Update states */\r
-    NSQ->sLF_AR_shp_Q12    = psDD->LF_AR_Q12;\r
-    NSQ->prev_inv_gain_Q16 = NSQ->prev_inv_gain_Q16;\r
-    NSQ->lagPrev           = psEncCtrlC->pitchL[ NB_SUBFR - 1 ];\r
+    NSQ->sLF_AR_shp_Q12 = psDD->LF_AR_Q12;\r
+    NSQ->lagPrev        = psEncCtrlC->pitchL[ NB_SUBFR - 1 ];\r
 \r
     /* Save quantized speech and noise shaping signals */\r
     SKP_memcpy( NSQ->xq,           &NSQ->xq[           psEncC->frame_length ], psEncC->frame_length * sizeof( SKP_int16 ) );\r
     SKP_memcpy( NSQ->sLTP_shp_Q10, &NSQ->sLTP_shp_Q10[ psEncC->frame_length ], psEncC->frame_length * sizeof( SKP_int32 ) );\r
 \r
+#ifdef USE_UNQUANTIZED_LSFS\r
+    DEBUG_STORE_DATA( xq_unq_lsfs.pcm, NSQ->xq, psEncC->frame_length * sizeof( SKP_int16 ) );\r
+#endif\r
+\r
 }\r
 \r
 /******************************************/\r
@@ -296,7 +307,7 @@ SKP_INLINE void SKP_Silk_noise_shape_quantizer_del_dec(
     NSQ_del_dec_struct  psDelDec[],             /* I/O  Delayed decision states             */\r
     SKP_int             sigtype,                /* I    Signal type                         */\r
     const SKP_int32     x_Q10[],                /* I                                        */\r
-    SKP_int             q[],                    /* O                                        */\r
+    SKP_int8            q[],                    /* O                                        */\r
     SKP_int16           xq[],                   /* O                                        */\r
     SKP_int32           sLTP_Q16[],             /* I/O  LTP filter state                    */\r
     const SKP_int16     a_Q12[],                /* I    Short term prediction coefs         */\r
@@ -312,7 +323,8 @@ SKP_INLINE void SKP_Silk_noise_shape_quantizer_del_dec(
     SKP_int             length,                 /* I    Input length                        */\r
     SKP_int             subfr,                  /* I    Subframe number                     */\r
     SKP_int             shapingLPCOrder,        /* I    Shaping LPC filter order            */\r
-    SKP_int             predictLPCOrder,        /* I    Prediction LPC filter order         */\r
+    SKP_int             predictLPCOrder,        /* I    Prediction filter order             */\r
+    SKP_int             warping_Q16,            /* I                                        */\r
     SKP_int             nStatesDelayedDecision, /* I    Number of states in decision tree   */\r
     SKP_int             *smpl_buf_idx,          /* I    Index to newest samples in buffers  */\r
     SKP_int             decisionDelay           /* I                                        */\r
@@ -321,25 +333,16 @@ SKP_INLINE void SKP_Silk_noise_shape_quantizer_del_dec(
     SKP_int     i, j, k, Winner_ind, RDmin_ind, RDmax_ind, last_smple_idx;\r
     SKP_int32   Winner_rand_state;\r
     SKP_int32   LTP_pred_Q14, LPC_pred_Q10, n_AR_Q10, n_LTP_Q14;\r
-    SKP_int32   n_LF_Q10;\r
-    SKP_int32   r_Q10, rr_Q20, rd1_Q10, rd2_Q10, RDmin_Q10, RDmax_Q10;\r
-    SKP_int32   q1_Q10, q2_Q10;\r
-    SKP_int32   Atmp, dither;\r
-    SKP_int32   exc_Q10, LPC_exc_Q10, xq_Q10;\r
-    SKP_int32   tmp, sLF_AR_shp_Q10;\r
-    SKP_int32   *pred_lag_ptr, *shp_lag_ptr;\r
-    SKP_int32   *psLPC_Q14;\r
-    SKP_int32   a_Q12_tmp[ MAX_LPC_ORDER / 2 ], AR_shp_Q13_tmp[ MAX_LPC_ORDER / 2 ];\r
-    NSQ_sample_struct  psSampleState[ DEL_DEC_STATES_MAX ][ 2 ];\r
+    SKP_int32   n_LF_Q10, r_Q10, rr_Q20, rd1_Q10, rd2_Q10, RDmin_Q10, RDmax_Q10;\r
+    SKP_int32   q1_Q10, q2_Q10, dither, exc_Q10, LPC_exc_Q10, xq_Q10;\r
+    SKP_int32   tmp1, tmp2, sLF_AR_shp_Q10;\r
+    SKP_int32   *pred_lag_ptr, *shp_lag_ptr, *psLPC_Q14;\r
+    NSQ_sample_struct  psSampleState[ MAX_DEL_DEC_STATES ][ 2 ];\r
     NSQ_del_dec_struct *psDD;\r
     NSQ_sample_struct  *psSS;\r
 \r
     shp_lag_ptr  = &NSQ->sLTP_shp_Q10[ NSQ->sLTP_shp_buf_idx - lag + HARM_SHAPE_FIR_TAPS / 2 ];\r
     pred_lag_ptr = &sLTP_Q16[ NSQ->sLTP_buf_idx - lag + LTP_ORDER / 2 ];\r
-    \r
-    /* Preload LPC coeficients to array on stack. Gives small performance gain */\r
-    SKP_memcpy( a_Q12_tmp, a_Q12, predictLPCOrder * sizeof( SKP_int16 ) );\r
-    SKP_memcpy( AR_shp_Q13_tmp, AR_shp_Q13, shapingLPCOrder * sizeof( SKP_int16 ) );\r
 \r
     for( i = 0; i < length; i++ ) {\r
         /* Perform common calculations used in all states */\r
@@ -384,85 +387,65 @@ SKP_INLINE void SKP_Silk_noise_shape_quantizer_del_dec(
             /* Pointer used in short term prediction and shaping */\r
             psLPC_Q14 = &psDD->sLPC_Q14[ NSQ_LPC_BUF_LENGTH - 1 + i ];\r
             /* Short-term prediction */\r
-            SKP_assert( ( predictLPCOrder  & 1 ) == 0 );    /* check that order is even */\r
-            SKP_assert( ( (SKP_int64)a_Q12 & 3 ) == 0 );    /* check that array starts at 4-byte aligned address */\r
             SKP_assert( predictLPCOrder >= 10 );            /* check that unrolling works */\r
-\r
+            SKP_assert( ( predictLPCOrder  & 1 ) == 0 );    /* check that order is even */\r
+            SKP_assert( ( ( ( int )( ( char* )( a_Q12 ) - ( ( char* ) 0 ) ) ) & 3 ) == 0 );    /* check that array starts at 4-byte aligned address */\r
             /* Partially unrolled */\r
-            Atmp = a_Q12_tmp[ 0 ];          /* read two coefficients at once */\r
-            LPC_pred_Q10 = SKP_SMULWB(               psLPC_Q14[ 0  ], Atmp );\r
-            LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psLPC_Q14[ -1 ], Atmp );\r
-            Atmp = a_Q12_tmp[ 1 ];\r
-            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -2 ], Atmp );\r
-            LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psLPC_Q14[ -3 ], Atmp );\r
-            Atmp = a_Q12_tmp[ 2 ];\r
-            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -4 ], Atmp );\r
-            LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psLPC_Q14[ -5 ], Atmp );\r
-            Atmp = a_Q12_tmp[ 3 ];\r
-            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -6 ], Atmp );\r
-            LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psLPC_Q14[ -7 ], Atmp );\r
-            Atmp = a_Q12_tmp[ 4 ];\r
-            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -8 ], Atmp );\r
-            LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psLPC_Q14[ -9 ], Atmp );\r
-            for( j = 10; j < predictLPCOrder; j += 2 ) {\r
-                Atmp = a_Q12_tmp[ j >> 1 ]; /* read two coefficients at once */\r
-                LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -j     ], Atmp );\r
-                LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psLPC_Q14[ -j - 1 ], Atmp );\r
+            LPC_pred_Q10 = SKP_SMULWB(               psLPC_Q14[  0 ], a_Q12[ 0 ] );\r
+            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -1 ], a_Q12[ 1 ] );\r
+            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -2 ], a_Q12[ 2 ] );\r
+            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -3 ], a_Q12[ 3 ] );\r
+            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -4 ], a_Q12[ 4 ] );\r
+            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -5 ], a_Q12[ 5 ] );\r
+            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -6 ], a_Q12[ 6 ] );\r
+            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -7 ], a_Q12[ 7 ] );\r
+            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -8 ], a_Q12[ 8 ] );\r
+            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -9 ], a_Q12[ 9 ] );\r
+            for( j = 10; j < predictLPCOrder; j ++ ) {\r
+                LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psLPC_Q14[ -j ], a_Q12[ j ] );\r
             }\r
 \r
             /* Noise shape feedback */\r
-            SKP_assert( ( shapingLPCOrder       & 1 ) == 0 );   /* check that order is even */\r
-            SKP_assert( ( (SKP_int64)AR_shp_Q13 & 3 ) == 0 );   /* check that array starts at 4-byte aligned address */\r
-            SKP_assert( shapingLPCOrder >= 12 );                /* check that unrolling works */\r
-            /* NOTE: the code below loads two int16 values in an int32, and multiplies each using the   */\r
-            /* SMLAWB and SMLAWT instructions. On a big-endian CPU the two int16 variables would be     */\r
-            /* loaded in reverse order and the code will give the wrong result. In that case swapping   */\r
-            /* the SMLAWB and SMLAWT instructions should solve the problem.                             */\r
-\r
-            /* Partially unrolled */\r
-            Atmp = AR_shp_Q13_tmp[ 0 ];         /* read two coefficients at once */\r
-            n_AR_Q10 = SKP_SMULWB(           psLPC_Q14[ 0  ], Atmp );\r
-            n_AR_Q10 = SKP_SMLAWT( n_AR_Q10, psLPC_Q14[ -1 ], Atmp );\r
-            Atmp = AR_shp_Q13_tmp[ 1 ];\r
-            n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ -2 ], Atmp );\r
-            n_AR_Q10 = SKP_SMLAWT( n_AR_Q10, psLPC_Q14[ -3 ], Atmp );\r
-            Atmp = AR_shp_Q13_tmp[ 2 ];\r
-            n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ -4 ], Atmp );\r
-            n_AR_Q10 = SKP_SMLAWT( n_AR_Q10, psLPC_Q14[ -5 ], Atmp );\r
-            Atmp = AR_shp_Q13_tmp[ 3 ];\r
-            n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ -6 ], Atmp );\r
-            n_AR_Q10 = SKP_SMLAWT( n_AR_Q10, psLPC_Q14[ -7 ], Atmp );\r
-            Atmp = AR_shp_Q13_tmp[ 4 ];\r
-            n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ -8 ], Atmp );\r
-            n_AR_Q10 = SKP_SMLAWT( n_AR_Q10, psLPC_Q14[ -9 ], Atmp );\r
-            Atmp = AR_shp_Q13_tmp[ 5 ];\r
-            n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ -10 ], Atmp );\r
-            n_AR_Q10 = SKP_SMLAWT( n_AR_Q10, psLPC_Q14[ -11 ], Atmp );\r
-            for( j = 12; j < shapingLPCOrder; j += 2 ) {\r
-                Atmp = AR_shp_Q13_tmp[ j >> 1 ];        /* read two coefficients at once */\r
-                n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, psLPC_Q14[ -j     ], Atmp );\r
-                n_AR_Q10 = SKP_SMLAWT( n_AR_Q10, psLPC_Q14[ -j - 1 ], Atmp );\r
+            SKP_assert( ( shapingLPCOrder & 1 ) == 0 );   /* check that order is even */\r
+            /* Output of lowpass section */\r
+            tmp2 = SKP_SMLAWB( psLPC_Q14[ 0 ], psDD->sAR2_Q14[ 0 ], warping_Q16 );\r
+            /* Output of allpass section */\r
+            tmp1 = SKP_SMLAWB( psDD->sAR2_Q14[ 0 ], psDD->sAR2_Q14[ 1 ] - tmp2, warping_Q16 );\r
+            psDD->sAR2_Q14[ 0 ] = tmp2;\r
+            n_AR_Q10 = SKP_SMULWB( tmp2, AR_shp_Q13[ 0 ] );\r
+            /* Loop over allpass sections */\r
+            for( j = 2; j < shapingLPCOrder; j += 2 ) {\r
+                /* Output of allpass section */\r
+                tmp2 = SKP_SMLAWB( psDD->sAR2_Q14[ j - 1 ], psDD->sAR2_Q14[ j + 0 ] - tmp1, warping_Q16 );\r
+                psDD->sAR2_Q14[ j - 1 ] = tmp1;\r
+                n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, tmp1, AR_shp_Q13[ j - 1 ] );\r
+                /* Output of allpass section */\r
+                tmp1 = SKP_SMLAWB( psDD->sAR2_Q14[ j + 0 ], psDD->sAR2_Q14[ j + 1 ] - tmp2, warping_Q16 );\r
+                psDD->sAR2_Q14[ j + 0 ] = tmp2;\r
+                n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, tmp2, AR_shp_Q13[ j ] );\r
             }\r
+            psDD->sAR2_Q14[ shapingLPCOrder - 1 ] = tmp1;\r
+            n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, tmp1, AR_shp_Q13[ shapingLPCOrder - 1 ] );\r
+\r
             n_AR_Q10 = SKP_RSHIFT( n_AR_Q10, 1 );           /* Q11 -> Q10 */\r
             n_AR_Q10 = SKP_SMLAWB( n_AR_Q10, psDD->LF_AR_Q12, Tilt_Q14 );\r
 \r
-            n_LF_Q10   = SKP_LSHIFT( SKP_SMULWB( psDD->Shape_Q10[ *smpl_buf_idx ], LF_shp_Q14 ), 2 ); \r
-            n_LF_Q10   = SKP_SMLAWT( n_LF_Q10, psDD->LF_AR_Q12, LF_shp_Q14 );       \r
+            n_LF_Q10 = SKP_LSHIFT( SKP_SMULWB( psDD->Shape_Q10[ *smpl_buf_idx ], LF_shp_Q14 ), 2 ); \r
+            n_LF_Q10 = SKP_SMLAWT( n_LF_Q10, psDD->LF_AR_Q12, LF_shp_Q14 );       \r
 \r
             /* Input minus prediction plus noise feedback                       */\r
             /* r = x[ i ] - LTP_pred - LPC_pred + n_AR + n_Tilt + n_LF + n_LTP  */\r
-            tmp   = SKP_SUB32( LTP_pred_Q14, n_LTP_Q14 );                       /* Add Q14 stuff */\r
-            tmp   = SKP_RSHIFT_ROUND( tmp, 4 );                                 /* round to Q10  */\r
-            tmp   = SKP_ADD32( tmp, LPC_pred_Q10 );                             /* add Q10 stuff */ \r
-            tmp   = SKP_SUB32( tmp, n_AR_Q10 );                                 /* subtract Q10 stuff */ \r
-            tmp   = SKP_SUB32( tmp, n_LF_Q10 );                                 /* subtract Q10 stuff */ \r
-            r_Q10 = SKP_SUB32( x_Q10[ i ], tmp );                               /* residual error Q10 */\r
+            tmp1  = SKP_SUB32( LTP_pred_Q14, n_LTP_Q14 );                       /* Add Q14 stuff */\r
+            tmp1  = SKP_RSHIFT( tmp1, 4 );                                      /* convert to Q10 */\r
+            tmp1  = SKP_ADD32( tmp1, LPC_pred_Q10 );                            /* add Q10 stuff */ \r
+            tmp1  = SKP_SUB32( tmp1, n_AR_Q10 );                                /* subtract Q10 stuff */ \r
+            tmp1  = SKP_SUB32( tmp1, n_LF_Q10 );                                /* subtract Q10 stuff */ \r
+            r_Q10 = SKP_SUB32( x_Q10[ i ], tmp1 );                              /* residual error Q10 */\r
             \r
-\r
             /* Flip sign depending on dither */\r
             r_Q10 = ( r_Q10 ^ dither ) - dither;\r
             r_Q10 = SKP_SUB32( r_Q10, offset_Q10 );\r
-            r_Q10 = SKP_LIMIT( r_Q10, -64 << 10, 64 << 10 );\r
+            r_Q10 = SKP_LIMIT_32( r_Q10, -64 << 10, 64 << 10 );\r
 \r
             /* Find two quantization level candidates and measure their rate-distortion */\r
             if( r_Q10 < -1536 ) {\r
@@ -585,7 +568,7 @@ SKP_INLINE void SKP_Silk_noise_shape_quantizer_del_dec(
         /* Write samples from winner to output and long-term filter states */\r
         psDD = &psDelDec[ Winner_ind ];\r
         if( subfr > 0 || i >= decisionDelay ) {\r
-            q[  i - decisionDelay ] = ( SKP_int )SKP_RSHIFT( psDD->Q_Q10[ last_smple_idx ], 10 );\r
+            q[  i - decisionDelay ] = ( SKP_int8 )SKP_RSHIFT( psDD->Q_Q10[ last_smple_idx ], 10 );\r
             xq[ i - decisionDelay ] = ( SKP_int16 )SKP_SAT16( SKP_RSHIFT_ROUND( \r
                 SKP_SMULWW( psDD->Xq_Q10[ last_smple_idx ], psDD->Gain_Q16[ last_smple_idx ] ), 10 ) );\r
             NSQ->sLTP_shp_Q10[ NSQ->sLTP_shp_buf_idx - decisionDelay ] = psDD->Shape_Q10[ last_smple_idx ];\r
@@ -622,8 +605,8 @@ SKP_INLINE void SKP_Silk_nsq_del_dec_scale_states(
     NSQ_del_dec_struct  psDelDec[],             /* I/O  Delayed decision states             */\r
     const SKP_int16     x[],                    /* I    Input in Q0                         */\r
     SKP_int32           x_sc_Q10[],             /* O    Input scaled with 1/Gain in Q10     */\r
-    SKP_int             length,                 /* I    Length of input                     */\r
-    SKP_int16           sLTP[],                 /* I    Re-whitened LTP state in Q0         */\r
+    SKP_int             subfr_length,           /* I    Length of input                     */\r
+    const SKP_int16     sLTP[],                 /* I    Re-whitened LTP state in Q0         */\r
     SKP_int32           sLTP_Q16[],             /* O    LTP state matching scaled input     */\r
     SKP_int             subfr,                  /* I    Subframe number                     */\r
     SKP_int             nStatesDelayedDecision, /* I    Number of del dec states            */\r
@@ -633,14 +616,15 @@ SKP_INLINE void SKP_Silk_nsq_del_dec_scale_states(
     const SKP_int       pitchL[ NB_SUBFR ]      /* I    Pitch lag                           */\r
 )\r
 {\r
-    SKP_int            i, k, scale_length, lag;\r
+    SKP_int            i, k, lag;\r
     SKP_int32          inv_gain_Q16, gain_adj_Q16, inv_gain_Q32;\r
     NSQ_del_dec_struct *psDD;\r
 \r
-    inv_gain_Q16 = SKP_DIV32( SKP_int32_MAX, SKP_RSHIFT( Gains_Q16[ subfr ], 1 ) );\r
+    inv_gain_Q16 = SKP_INVERSE32_varQ( SKP_max( Gains_Q16[ subfr ], 1 ), 32 );\r
     inv_gain_Q16 = SKP_min( inv_gain_Q16, SKP_int16_MAX );\r
     lag          = pitchL[ subfr ];\r
-    /* After rewhitening the LTP state is un-scaled. So scale with inv_gain_Q16 */\r
+\r
+    /* After rewhitening the LTP state is un-scaled, so scale with inv_gain_Q16 */\r
     if( NSQ->rewhite_flag ) {\r
         inv_gain_Q32 = SKP_LSHIFT( inv_gain_Q16, 16 );\r
         if( subfr == 0 ) {\r
@@ -657,43 +641,40 @@ SKP_INLINE void SKP_Silk_nsq_del_dec_scale_states(
     if( inv_gain_Q16 != NSQ->prev_inv_gain_Q16 ) {\r
         gain_adj_Q16 = SKP_DIV32_varQ( inv_gain_Q16, NSQ->prev_inv_gain_Q16, 16 );\r
 \r
+        /* Scale long-term shaping state */\r
+        for( i = NSQ->sLTP_shp_buf_idx - subfr_length * NB_SUBFR; i < NSQ->sLTP_shp_buf_idx; i++ ) {\r
+            NSQ->sLTP_shp_Q10[ i ] = SKP_SMULWW( gain_adj_Q16, NSQ->sLTP_shp_Q10[ i ] );\r
+        }\r
+\r
+        /* Scale long-term prediction state */\r
+        if( NSQ->rewhite_flag == 0 ) {\r
+            for( i = NSQ->sLTP_buf_idx - lag - LTP_ORDER / 2; i < NSQ->sLTP_buf_idx; i++ ) {\r
+                sLTP_Q16[ i ] = SKP_SMULWW( gain_adj_Q16, sLTP_Q16[ i ] );\r
+            }\r
+        }\r
+\r
         for( k = 0; k < nStatesDelayedDecision; k++ ) {\r
             psDD = &psDelDec[ k ];\r
             \r
             /* Scale scalar states */\r
             psDD->LF_AR_Q12 = SKP_SMULWW( gain_adj_Q16, psDD->LF_AR_Q12 );\r
             \r
-            /* scale short term state */\r
+               /* Scale short-term prediction and shaping states */\r
             for( i = 0; i < NSQ_LPC_BUF_LENGTH; i++ ) {\r
-                psDD->sLPC_Q14[ NSQ_LPC_BUF_LENGTH - i - 1 ] = SKP_SMULWW( gain_adj_Q16, psDD->sLPC_Q14[ NSQ_LPC_BUF_LENGTH - i - 1 ] );\r
+                psDD->sLPC_Q14[ i ] = SKP_SMULWW( gain_adj_Q16, psDD->sLPC_Q14[ i ] );\r
+            }\r
+            for( i = 0; i < MAX_SHAPE_LPC_ORDER; i++ ) {\r
+                psDD->sAR2_Q14[ i ] = SKP_SMULWW( gain_adj_Q16, psDD->sAR2_Q14[ i ] );\r
             }\r
             for( i = 0; i < DECISION_DELAY; i++ ) {\r
                 psDD->Pred_Q16[  i ] = SKP_SMULWW( gain_adj_Q16, psDD->Pred_Q16[  i ] );\r
                 psDD->Shape_Q10[ i ] = SKP_SMULWW( gain_adj_Q16, psDD->Shape_Q10[ i ] );\r
             }\r
         }\r
-\r
-        /* Scale long term shaping state */\r
-\r
-        /* Calculate length to be scaled, Worst case: Next frame is voiced with max lag */\r
-        scale_length = length * NB_SUBFR;                                               /* aprox max lag */\r
-        scale_length = scale_length - SKP_SMULBB( NB_SUBFR - ( subfr + 1 ), length );   /* subtract samples that will be too old in next frame */\r
-        scale_length = SKP_max_int( scale_length, lag + LTP_ORDER );                    /* make sure to scale whole pitch period if voiced */\r
-\r
-        for( i = NSQ->sLTP_shp_buf_idx - scale_length; i < NSQ->sLTP_shp_buf_idx; i++ ) {\r
-            NSQ->sLTP_shp_Q10[ i ] = SKP_SMULWW( gain_adj_Q16, NSQ->sLTP_shp_Q10[ i ] );\r
-        }\r
-\r
-        /* Scale LTP predict state */\r
-        if( NSQ->rewhite_flag == 0 ) {\r
-            for( i = NSQ->sLTP_buf_idx - lag - LTP_ORDER / 2; i < NSQ->sLTP_buf_idx; i++ ) {\r
-                sLTP_Q16[ i ] = SKP_SMULWW( gain_adj_Q16, sLTP_Q16[ i ] );\r
-            }\r
-        }\r
     }\r
 \r
     /* Scale input */\r
-    for( i = 0; i < length; i++ ) {\r
+    for( i = 0; i < subfr_length; i++ ) {\r
         x_sc_Q10[ i ] = SKP_RSHIFT( SKP_SMULBB( x[ i ], ( SKP_int16 )inv_gain_Q16 ), 6 );\r
     }\r
 \r
@@ -708,12 +689,12 @@ SKP_INLINE void SKP_Silk_copy_del_dec_state(
     SKP_int             LPC_state_idx           /* I    Index to LPC buffer                 */\r
 )\r
 {\r
-    SKP_memcpy( DD_dst->RandState, DD_src->RandState,   DECISION_DELAY * sizeof( SKP_int   ) );\r
-    SKP_memcpy( DD_dst->Q_Q10,     DD_src->Q_Q10,       DECISION_DELAY * sizeof( SKP_int32 ) );\r
-    SKP_memcpy( DD_dst->Pred_Q16,  DD_src->Pred_Q16,    DECISION_DELAY * sizeof( SKP_int32 ) );\r
-    SKP_memcpy( DD_dst->Shape_Q10, DD_src->Shape_Q10,   DECISION_DELAY * sizeof( SKP_int32 ) );\r
-    SKP_memcpy( DD_dst->Xq_Q10,    DD_src->Xq_Q10,      DECISION_DELAY * sizeof( SKP_int32 ) );\r
-\r
+    SKP_memcpy( DD_dst->RandState, DD_src->RandState, sizeof( DD_src->RandState ) );\r
+    SKP_memcpy( DD_dst->Q_Q10,     DD_src->Q_Q10,     sizeof( DD_src->Q_Q10     ) );\r
+    SKP_memcpy( DD_dst->Pred_Q16,  DD_src->Pred_Q16,  sizeof( DD_src->Pred_Q16  ) );\r
+    SKP_memcpy( DD_dst->Shape_Q10, DD_src->Shape_Q10, sizeof( DD_src->Shape_Q10 ) );\r
+    SKP_memcpy( DD_dst->Xq_Q10,    DD_src->Xq_Q10,    sizeof( DD_src->Xq_Q10    ) );\r
+    SKP_memcpy( DD_dst->sAR2_Q14,  DD_src->sAR2_Q14,  sizeof( DD_src->sAR2_Q14  ) );\r
     SKP_memcpy( &DD_dst->sLPC_Q14[ LPC_state_idx ], &DD_src->sLPC_Q14[ LPC_state_idx ], NSQ_LPC_BUF_LENGTH * sizeof( SKP_int32 ) );\r
     DD_dst->LF_AR_Q12 = DD_src->LF_AR_Q12;\r
     DD_dst->Seed      = DD_src->Seed;\r
index 746ae102dd2fbfbaae223441384e3ec99e9f13db..690ac0223e2c41d92c7675cec01641fd2fe8d9d1 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -59,6 +59,8 @@ void SKP_Silk_PLC(
         /* Generate Signal          */\r
         /****************************/\r
         SKP_Silk_PLC_conceal( psDec, psDecCtrl, signal, length );\r
+\r
+        psDec->lossCnt++;\r
     } else {\r
         /****************************/\r
         /* Update state             */\r
@@ -150,13 +152,16 @@ void SKP_Silk_PLC_conceal(
 {\r
     SKP_int   i, j, k;\r
     SKP_int16 *B_Q14, exc_buf[ MAX_FRAME_LENGTH ], *exc_buf_ptr;\r
-    SKP_int16 rand_scale_Q14, A_Q12_tmp[ MAX_LPC_ORDER ];\r
+    SKP_int16 rand_scale_Q14;\r
+    union {\r
+        SKP_int16 as_int16[ MAX_LPC_ORDER ];\r
+        SKP_int32 as_int32[ MAX_LPC_ORDER / 2 ];\r
+    } A_Q12_tmp;\r
     SKP_int32 rand_seed, harm_Gain_Q15, rand_Gain_Q15;\r
-    SKP_int   lag, idx, shift1, shift2;\r
-    SKP_int32 energy1, energy2, *rand_ptr, *pred_lag_ptr, Atmp;\r
+    SKP_int   lag, idx, sLTP_buf_idx, shift1, shift2;\r
+    SKP_int32 energy1, energy2, *rand_ptr, *pred_lag_ptr;\r
     SKP_int32 sig_Q10[ MAX_FRAME_LENGTH ], *sig_Q10_ptr, LPC_exc_Q10, LPC_pred_Q10,  LTP_pred_Q14;\r
     SKP_Silk_PLC_struct *psPLC;\r
-\r
     psPLC = &psDec->sPLC;\r
 \r
     /* Update LTP buffer */\r
@@ -179,7 +184,7 @@ void SKP_Silk_PLC_conceal(
     SKP_Silk_sum_sqr_shift( &energy1, &shift1, exc_buf,                         psDec->subfr_length );\r
     SKP_Silk_sum_sqr_shift( &energy2, &shift2, &exc_buf[ psDec->subfr_length ], psDec->subfr_length );\r
         \r
-    if( SKP_RSHIFT( energy1, shift2 ) < SKP_RSHIFT( energy1, shift2 ) ) {\r
+    if( SKP_RSHIFT( energy1, shift2 ) < SKP_RSHIFT( energy2, shift1 ) ) {\r
         /* First sub-frame has lowest energy */\r
         rand_ptr = &psDec->exc_Q10[ SKP_max_int( 0, 3 * psDec->subfr_length - RAND_BUF_SIZE ) ];\r
     } else {\r
@@ -226,9 +231,9 @@ void SKP_Silk_PLC_conceal(
         }\r
     }\r
 \r
-    rand_seed           = psPLC->rand_seed;\r
-    lag                 = SKP_RSHIFT_ROUND( psPLC->pitchL_Q8, 8 );\r
-    psDec->sLTP_buf_idx = psDec->frame_length;\r
+    rand_seed    = psPLC->rand_seed;\r
+    lag          = SKP_RSHIFT_ROUND( psPLC->pitchL_Q8, 8 );\r
+    sLTP_buf_idx = psDec->frame_length;\r
 \r
     /***************************/\r
     /* LTP synthesis filtering */\r
@@ -236,7 +241,7 @@ void SKP_Silk_PLC_conceal(
     sig_Q10_ptr = sig_Q10;\r
     for( k = 0; k < NB_SUBFR; k++ ) {\r
         /* Setup pointer */\r
-        pred_lag_ptr = &psDec->sLTP_Q16[ psDec->sLTP_buf_idx - lag + LTP_ORDER / 2 ];\r
+        pred_lag_ptr = &psDec->sLTP_Q16[ sLTP_buf_idx - lag + LTP_ORDER / 2 ];\r
         for( i = 0; i < psDec->subfr_length; i++ ) {\r
             rand_seed = SKP_RAND( rand_seed );\r
             idx = SKP_RSHIFT( rand_seed, 25 ) & RAND_BUF_MASK;\r
@@ -254,8 +259,8 @@ void SKP_Silk_PLC_conceal(
             LPC_exc_Q10 = SKP_ADD32( LPC_exc_Q10, SKP_RSHIFT_ROUND( LTP_pred_Q14, 4 ) );  /* Harmonic part */\r
             \r
             /* Update states */\r
-            psDec->sLTP_Q16[ psDec->sLTP_buf_idx ] = SKP_LSHIFT( LPC_exc_Q10, 6 );\r
-            psDec->sLTP_buf_idx++;\r
+            psDec->sLTP_Q16[ sLTP_buf_idx ] = SKP_LSHIFT( LPC_exc_Q10, 6 );\r
+            sLTP_buf_idx++;\r
                 \r
             /* Save LPC residual */\r
             sig_Q10_ptr[ i ] = LPC_exc_Q10;\r
@@ -279,32 +284,25 @@ void SKP_Silk_PLC_conceal(
     /***************************/\r
     sig_Q10_ptr = sig_Q10;\r
     /* Preload LPC coeficients to array on stack. Gives small performance gain */\r
-    SKP_memcpy( A_Q12_tmp, psPLC->prevLPC_Q12, psDec->LPC_order * sizeof( SKP_int16 ) );\r
+    SKP_memcpy( A_Q12_tmp.as_int16, psPLC->prevLPC_Q12, psDec->LPC_order * sizeof( SKP_int16 ) );\r
     SKP_assert( psDec->LPC_order >= 10 ); /* check that unrolling works */\r
     for( k = 0; k < NB_SUBFR; k++ ) {\r
         for( i = 0; i < psDec->subfr_length; i++ ){\r
-            /* unrolled */\r
-            Atmp = *( ( SKP_int32* )&A_Q12_tmp[ 0 ] );    /* read two coefficients at once */\r
-            LPC_pred_Q10 = SKP_SMULWB(               psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  1 ], Atmp );\r
-            LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  2 ], Atmp );\r
-            Atmp = *( ( SKP_int32* )&A_Q12_tmp[ 2 ] );\r
-            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  3 ], Atmp );\r
-            LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  4 ], Atmp );\r
-            Atmp = *( ( SKP_int32* )&A_Q12_tmp[ 4 ] );\r
-            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  5 ], Atmp );\r
-            LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  6 ], Atmp );\r
-            Atmp = *( ( SKP_int32* )&A_Q12_tmp[ 6 ] );\r
-            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  7 ], Atmp );\r
-            LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  8 ], Atmp );\r
-            Atmp = *( ( SKP_int32* )&A_Q12_tmp[ 8 ] );\r
-            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  9 ], Atmp );\r
-            LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 10 ], Atmp );\r
-            for( j = 10 ; j < psDec->LPC_order ; j+=2 ) {\r
-                Atmp = *( ( SKP_int32* )&A_Q12_tmp[ j ] );\r
-                LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  1 - j ], Atmp );\r
-                LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  2 - j ], Atmp );\r
+            /* partly unrolled */\r
+            LPC_pred_Q10 = SKP_SMULWB(               psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  1 ], A_Q12_tmp.as_int16[ 0 ] );\r
+            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  2 ], A_Q12_tmp.as_int16[ 1 ] );\r
+            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  3 ], A_Q12_tmp.as_int16[ 2 ] );\r
+            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  4 ], A_Q12_tmp.as_int16[ 3 ] );\r
+            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  5 ], A_Q12_tmp.as_int16[ 4 ] );\r
+            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  6 ], A_Q12_tmp.as_int16[ 5 ] );\r
+            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  7 ], A_Q12_tmp.as_int16[ 6 ] );\r
+            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  8 ], A_Q12_tmp.as_int16[ 7 ] );\r
+            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  9 ], A_Q12_tmp.as_int16[ 8 ] );\r
+            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 10 ], A_Q12_tmp.as_int16[ 9 ] );\r
+\r
+            for( j = 10; j < psDec->LPC_order; j++ ) {\r
+                LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - j - 1 ], A_Q12_tmp.as_int16[ j ] );\r
             }\r
-\r
             /* Add prediction to LPC residual */\r
             sig_Q10_ptr[ i ] = SKP_ADD32( sig_Q10_ptr[ i ], LPC_pred_Q10 );\r
                 \r
@@ -387,3 +385,4 @@ void SKP_Silk_PLC_glue_frames(
 \r
     }\r
 }\r
+\r
index 0409a24bb063511bfb109da121bea3ca65eede02..d23f994afb61034c1d9d66978beb4f8489165cb1 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -28,7 +28,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #ifndef SKP_SILK_PLC_FIX_H\r
 #define SKP_SILK_PLC_FIX_H\r
 \r
-#include "SKP_Silk_main_FIX.h"\r
+#include "SKP_Silk_main.h"\r
 \r
 #define BWE_COEF_Q16                    64880           /* 0.99 in Q16                      */\r
 #define V_PITCH_GAIN_START_MIN_Q14      11469           /* 0.7 in Q14                       */\r
@@ -38,7 +38,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #define USE_SINGLE_TAP                  1\r
 #define RAND_BUF_SIZE                   128\r
 #define RAND_BUF_MASK                   (RAND_BUF_SIZE - 1)\r
-#define LOG2_INV_LPC_GAIN_HIGH_THRES    4               /* 2^4 = 12 dB LPC gain             */\r
+#define LOG2_INV_LPC_GAIN_HIGH_THRES    3               /* 2^3 = 8 dB LPC gain              */\r
 #define LOG2_INV_LPC_GAIN_LOW_THRES     8               /* 2^8 = 24 dB LPC gain             */\r
 #define PITCH_DRIFT_FAC_Q16             655             /* 0.01 in Q16                      */\r
 \r
index 41d95f585bb774f4953118cf6060f7767af399d6..48a506731ee2ee102e408e13724a9d46b60342fd 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -33,173 +33,87 @@ extern "C"
 {\r
 #endif\r
 \r
-#define SigProc_MAX_ORDER_LPC            16                    /* max order of the LPC analysis in schur() and k2a()    */\r
-#define SigProc_MAX_CORRELATION_LENGTH   640                   /* max input length to the correlation                    */\r
+#define SKP_Silk_MAX_ORDER_LPC            16                    /* max order of the LPC analysis in schur() and k2a()    */\r
+#define SKP_Silk_MAX_CORRELATION_LENGTH   640                   /* max input length to the correlation                    */\r
 #include "SKP_Silk_typedef.h"\r
 #include <string.h>\r
 #include <stdlib.h>                                            /* for abs() */\r
-#include "SKP_Silk_macros.h"\r
-#include "SKP_Silk_resample_rom.h"\r
+#include "SKP_Silk_resampler_structs.h"\r
+\r
+#      include "SKP_Silk_macros.h"\r
+\r
 \r
 \r
-       \r
 /********************************************************************/\r
 /*                    SIGNAL PROCESSING FUNCTIONS                   */\r
 /********************************************************************/\r
 \r
-/* downsample by a factor 2 */\r
-void SKP_Silk_resample_1_2(\r
-    const SKP_int16      *in,            /* I:   16 kHz signal [2*len]    */\r
-    SKP_int32            *S,             /* I/O: State vector [6]         */\r
-    SKP_int16            *out,           /* O:   8 kHz signal [len]       */\r
-    SKP_int32            *scratch,       /* I:   Scratch memory [4*len]   */\r
-    const SKP_int32      len             /* I:   Number of OUTPUT samples */\r
-);\r
-\r
-/*! \r
- * downsample by a factor 2, coarser (good for resampling audio) \r
- */\r
-void SKP_Silk_resample_1_2_coarse(\r
-    const SKP_int16    *in,              /* I:   16 kHz signal [2*len]    */\r
-          SKP_int32    *S,               /* I/O: state vector [4]         */\r
-          SKP_int16    *out,             /* O:   8 kHz signal [len]       */\r
-          SKP_int32    *scratch,         /* I:   scratch memory [3*len]   */\r
-    const SKP_int32    len               /* I:   number of OUTPUT samples */\r
-);\r
-\r
-/*! \r
- * downsample by a factor 2, coarsest (good for signals that are already oversampled, or for analysis purposes) \r
- */\r
-void SKP_Silk_resample_1_2_coarsest(\r
-    const SKP_int16     *in,             /* I:   16 kHz signal [2*len]    */\r
-    SKP_int32           *S,              /* I/O: State vector [2]         */\r
-    SKP_int16           *out,            /* O:   8 kHz signal [len]       */\r
-    SKP_int32           *scratch,        /* I:   Scratch memory [3*len]   */\r
-    const SKP_int32     len              /* I:   Number of OUTPUT samples */\r
-);\r
-\r
-/*! \r
- * upsample by a factor 2, coarser (good for resampling audio) \r
- */\r
-void SKP_Silk_resample_2_1_coarse(\r
-    const SKP_int16      *in,            /* I:   8 kHz signal [len]      */\r
-    SKP_int32            *S,             /* I/O: State vector [4]        */\r
-    SKP_int16            *out,           /* O:   16 kHz signal [2*len]   */\r
-    SKP_int32            *scratch,       /* I:   Scratch memory [3*len]  */\r
-    const SKP_int32      len             /* I:   Number of INPUT samples */\r
-);\r
-\r
 /*!\r
- * Resamples by a factor 1/3 \r
- */\r
-void SKP_Silk_resample_1_3(\r
-    SKP_int16            *out,          /* O:   Fs_low signal  [inLen/3]              */\r
-    SKP_int32            *S,            /* I/O: State vector   [7]                    */\r
-    const SKP_int16      *in,           /* I:   Fs_high signal [inLen]                */\r
-    const SKP_int32      inLen          /* I:   Input length, must be a multiple of 3 */\r
+ * Initialize/reset the resampler state for a given pair of input/output sampling rates \r
+*/\r
+SKP_int SKP_Silk_resampler_init( \r
+       SKP_Silk_resampler_state_struct *S,                 /* I/O: Resampler state                     */\r
+       SKP_int32                                                       Fs_Hz_in,       /* I:   Input sampling rate (Hz)        */\r
+       SKP_int32                                                       Fs_Hz_out       /* I:   Output sampling rate (Hz)       */\r
 );\r
 \r
-/*!\r
- * Resamples by a factor 3/1\r
- */\r
-void SKP_Silk_resample_3_1(\r
-    SKP_int16            *out,          /* O:   Fs_high signal [inLen*3]          */\r
-    SKP_int32            *S,            /* I/O: State vector   [7]                */\r
-    const SKP_int16      *in,           /* I:   Fs_low signal  [inLen]            */\r
-    const SKP_int32      inLen          /* I:   Input length                      */\r
-);\r
-\r
-/*!\r
- * Resamples by a factor 2/3\r
- */\r
-void SKP_Silk_resample_2_3(\r
-    SKP_int16            *out,          /* O:   Fs_low signal    [inLen * 2/3]        */\r
-    SKP_int32            *S,            /* I/O: State vector    [7+4]                 */\r
-    const SKP_int16      *in,           /* I:   Fs_high signal    [inLen]             */\r
-    const SKP_int        inLen          /* I:   Input length, must be a multiple of 3 */\r
-); \r
 \r
 /*!\r
- * Resamples by a factor 3/2\r
+ * Clear the states of all resampling filters, without resetting sampling rate ratio \r
  */\r
-void SKP_Silk_resample_3_2(\r
-    SKP_int16            *out,          /*   O: Fs_high signal  [inLen*3/2]              */\r
-    SKP_int32            *S,            /* I/O: State vector    [7+4]                    */\r
-    const SKP_int16      *in,           /* I:   Fs_low signal   [inLen]                  */\r
-    SKP_int              inLen          /* I:   Input length, must be a multiple of 2    */\r
+SKP_int SKP_Silk_resampler_clear( \r
+       SKP_Silk_resampler_state_struct *S                  /* I/O: Resampler state                     */\r
 );\r
 \r
 /*!\r
- * Resamples by a factor 4/3\r
+ * Resampler: convert from one sampling rate to another\r
  */\r
-void SKP_Silk_resample_4_3(\r
-    SKP_int16            *out,          /* O:   Fs_low signal    [inLen * 4/3]           */\r
-    SKP_int32            *S,            /* I/O: State vector    [7+4+4]                  */\r
-    const SKP_int16      *in,           /* I:   Fs_high signal    [inLen]                */\r
-    const SKP_int        inLen          /* I:   input length, must be a multiple of 3    */\r
+SKP_int SKP_Silk_resampler( \r
+       SKP_Silk_resampler_state_struct *S,                 /* I/O: Resampler state                     */\r
+       SKP_int16                                                       out[],      /* O:       Output signal                           */\r
+       const SKP_int16                                         in[],       /* I:       Input signal                            */\r
+       SKP_int32                                                       inLen       /* I:       Number of input samples         */\r
 );\r
 \r
 /*!\r
- * Resamples by a factor 3/4\r
+ Upsample 2x, low quality \r
  */\r
- void SKP_Silk_resample_3_4(\r
-    SKP_int16            *out,          /* O:   Fs_high signal  [inLen*3/4]              */\r
-    SKP_int32            *S,            /* I/O: State vector    [7+2+6]                  */\r
-    const SKP_int16      *in,           /* I:   Fs_low signal   [inLen]                  */\r
-    SKP_int              inLen          /* I:   Input length, must be a multiple of 4    */\r
+void SKP_Silk_resampler_up2(\r
+    SKP_int32                           *S,         /* I/O: State vector [ 2 ]                  */\r
+    SKP_int16                           *out,       /* O:   Output signal [ 2 * len ]           */\r
+    const SKP_int16                     *in,        /* I:   Input signal [ len ]                */\r
+    SKP_int32                           len         /* I:   Number of input samples             */\r
 );\r
 \r
-/*! \r
- * resample with a factor 2/3 coarse\r
- */\r
-void SKP_Silk_resample_2_3_coarse( \r
-    SKP_int16            *out,          /* O:   Output signal                                                                 */\r
-    SKP_int16            *S,            /* I/O: Resampler state [ SigProc_Resample_2_3_coarse_NUM_FIR_COEFS - 1 ]             */\r
-    const SKP_int16      *in,           /* I:   Input signal                                                                  */\r
-    const SKP_int        frameLenIn,    /* I:   Number of input samples                                                       */\r
-    SKP_int16            *scratch       /* I:   Scratch memory [ frameLenIn + SigProc_Resample_2_3_coarse_NUM_FIR_COEFS - 1 ] */\r
-);\r
-\r
-/*! \r
- * resample with a factor 2/3 coarsest\r
- */\r
-void SKP_Silk_resample_2_3_coarsest( \r
-    SKP_int16            *out,          /* O:   Output signal                                                                   */\r
-    SKP_int16            *S,            /* I/O: Resampler state [ SigProc_Resample_2_3_coarsest_NUM_FIR_COEFS - 1 ]             */\r
-    const SKP_int16      *in,           /* I:   Input signal                                                                    */\r
-    const SKP_int        frameLenIn,    /* I:   Number of input samples                                                         */\r
-    SKP_int16            *scratch       /* I:   Scratch memory [ frameLenIn + SigProc_Resample_2_3_coarsest_NUM_FIR_COEFS - 1 ] */\r
+/*!\r
+* Downsample 2x, mediocre quality \r
+*/\r
+void SKP_Silk_resampler_down2(\r
+    SKP_int32                           *S,         /* I/O: State vector [ 2 ]                  */\r
+    SKP_int16                           *out,       /* O:   Output signal [ len ]               */\r
+    const SKP_int16                     *in,        /* I:   Input signal [ floor(len/2) ]       */\r
+    SKP_int32                           inLen       /* I:   Number of input samples             */\r
 );\r
 \r
-/*! \r
- * First order low-pass filter, with input as SKP_int16, running at 48 kHz \r
- */\r
-void SKP_Silk_lowpass_short(\r
-    const SKP_int16      *in,           /* I:   Q15 48 kHz signal; [len]    */\r
-    SKP_int32            *S,            /* I/O: Q25 state; length = 1       */\r
-    SKP_int32            *out,          /* O:   Q25 48 kHz signal; [len]    */\r
-    const SKP_int32      len            /* O:   Signal length               */\r
-);\r
 \r
-/*! \r
- * First order low-pass filter, with input as SKP_int32, running at 48 kHz \r
- */\r
-void SKP_Silk_lowpass_int(\r
-    const SKP_int32      *in,           /* I:   Q25 48 kHz signal; length = len  */\r
-    SKP_int32            *S,            /* I/O: Q25 state; length = 1            */\r
-    SKP_int32            *out,          /* O:   Q25 48 kHz signal; length = len  */\r
-    const SKP_int32      len            /* I:   Number of samples                */\r
+/*!\r
+ * Downsample by a factor 2/3, low quality\r
+*/\r
+void SKP_Silk_resampler_down2_3(\r
+    SKP_int32                           *S,         /* I/O: State vector [ 6 ]                  */\r
+    SKP_int16                           *out,       /* O:   Output signal [ floor(2*inLen/3) ]  */\r
+    const SKP_int16                     *in,        /* I:   Input signal [ inLen ]              */\r
+    SKP_int32                           inLen       /* I:   Number of input samples             */\r
 );\r
 \r
-/*! \r
- * First-order allpass filter \r
- */\r
-void SKP_Silk_allpass_int(\r
-    const SKP_int32      *in,          /* I:   Q25 input signal [len]               */\r
-    SKP_int32            *S,           /* I/O: Q25 state [1]                        */\r
-    SKP_int              A,            /* I:   Q15 coefficient    (0 <= A < 32768)  */\r
-    SKP_int32            *out,         /* O:   Q25 output signal [len]              */\r
-    const SKP_int32      len           /* I:   Number of samples                    */\r
+/*!\r
+ * Downsample by a factor 3, low quality\r
+*/\r
+void SKP_Silk_resampler_down3(\r
+    SKP_int32                           *S,         /* I/O: State vector [ 8 ]                  */\r
+    SKP_int16                           *out,       /* O:   Output signal [ floor(inLen/3) ]    */\r
+    const SKP_int16                     *in,        /* I:   Input signal [ inLen ]              */\r
+    SKP_int32                           inLen       /* I:   Number of input samples             */\r
 );\r
 \r
 /*! \r
@@ -240,15 +154,6 @@ void SKP_Silk_MA_Prediction(
     const SKP_int32      order         /* I:  Filter order                                 */\r
 );\r
 \r
-void SKP_Silk_MA_Prediction_Q13(\r
-    const SKP_int16      *in,          /* I:   input signal                                */\r
-    const SKP_int16      *B,           /* I:   MA prediction coefficients, Q13 [order]     */\r
-    SKP_int32            *S,           /* I/O: state vector [order]                        */\r
-    SKP_int16            *out,         /* O:   output signal                               */\r
-    SKP_int32            len,          /* I:   signal length                               */\r
-    SKP_int32            order         /* I:   filter order                                */\r
-);\r
-\r
 /*!\r
  * 16th order AR filter for LPC synthesis, coefficients are in Q12\r
  */\r
@@ -305,10 +210,10 @@ SKP_int SKP_Silk_LPC_inverse_pred_gain( /* O:  Returns 1 if unstable, otherwise
     const SKP_int        order          /* I:  Prediction order                            */\r
 );\r
 \r
-SKP_int SKP_Silk_LPC_inverse_pred_gain_Q13( /* O:  returns 1 if unstable, otherwise 0      */\r
-    SKP_int32            *invGain_Q30,  /* O:  Inverse prediction gain, Q30 energy domain  */\r
-    const SKP_int16      *A_Q13,        /* I:  Prediction coefficients, Q13 [order]        */\r
-    const SKP_int        order          /* I:  Prediction order                            */\r
+SKP_int SKP_Silk_LPC_inverse_pred_gain_Q24( /* O:   Returns 1 if unstable, otherwise 0      */\r
+    SKP_int32           *invGain_Q30,   /* O:   Inverse prediction gain, Q30 energy domain  */\r
+    const SKP_int32     *A_Q24,         /* I:   Prediction coefficients, Q24 [order]        */\r
+    const SKP_int       order           /* I:   Prediction order                            */\r
 );\r
 \r
 /* split signal in two decimated bands using first-order allpass filters */\r
@@ -353,12 +258,12 @@ void SKP_Silk_sum_sqr_shift(
 \r
 /* Calculates the reflection coefficients from the correlation sequence    */\r
 /* Faster than schur64(), but much less accurate.                          */\r
-/* Uses SMLAWB(), requiring armv5E and higher.                             */\r
-void SKP_Silk_schur(\r
-    SKP_int16           *rc_Q15,        /* O:  reflection coefficients [order] Q15         */\r
-    const SKP_int32     *c,             /* I:  correlations [order+1]                      */\r
-    const SKP_int32     order           /* I:  prediction order                            */\r
-);\r
+/* uses SMLAWB(), requiring armv5E and higher.                             */ \r
+SKP_int32 SKP_Silk_schur(               /* O:    Returns residual energy                   */\r
+    SKP_int16            *rc_Q15,       /* O:    reflection coefficients [order] Q15       */\r
+    const SKP_int32      *c,            /* I:    correlations [order+1]                    */\r
+    const SKP_int32      order          /* I:    prediction order                          */\r
+);;\r
 \r
 /* Calculates the reflection coefficients from the correlation sequence    */\r
 /* Slower than schur(), but more accurate.                                 */\r
@@ -385,30 +290,30 @@ void SKP_Silk_k2a_Q16(
 \r
 /* Apply sine window to signal vector.                                      */\r
 /* Window types:                                                            */\r
-/*    0 -> sine window from 0 to pi                                         */\r
 /*    1 -> sine window from 0 to pi/2                                       */\r
 /*    2 -> sine window from pi/2 to pi                                      */\r
-/* every other sample of window is linearly interpolated, for speed         */\r
-void SKP_Silk_apply_sine_window(\r
-    SKP_int16           px_win[],       /* O  Pointer to windowed signal                  */\r
-    const SKP_int16     px[],           /* I  Pointer to input signal                     */\r
-    const SKP_int       win_type,       /* I  Selects a window type                       */\r
-    const SKP_int       length          /* I  Window length, multiple of 4                */\r
+/* Every other sample is linearly interpolated, for speed.                  */\r
+/* Window length must be between 16 and 120 (incl) and a multiple of 4.     */\r
+void SKP_Silk_apply_sine_window_new(\r
+    SKP_int16                        px_win[],            /* O    Pointer to windowed signal                  */\r
+    const SKP_int16                  px[],                /* I    Pointer to input signal                     */\r
+    const SKP_int                    win_type,            /* I    Selects a window type                       */\r
+    const SKP_int                    length               /* I    Window length, multiple of 4                */\r
 );\r
 \r
 /* Compute autocorrelation */\r
 void SKP_Silk_autocorr( \r
     SKP_int32           *results,       /* O  Result (length correlationCount)            */\r
-    SKP_int32           *scale,         /* O  Scaling of the correlation vector           */\r
+    SKP_int             *scale,         /* O  Scaling of the correlation vector           */\r
     const SKP_int16     *inputData,     /* I  Input data to correlate                     */\r
     const SKP_int       inputDataSize,  /* I  Length of input                             */\r
     const SKP_int       correlationCount /* I  Number of correlation taps to compute      */\r
 );\r
 \r
 /* Pitch estimator */\r
-#define SigProc_PITCH_EST_MIN_COMPLEX        0\r
-#define SigProc_PITCH_EST_MID_COMPLEX        1\r
-#define SigProc_PITCH_EST_MAX_COMPLEX        2\r
+#define SKP_Silk_PITCH_EST_MIN_COMPLEX        0\r
+#define SKP_Silk_PITCH_EST_MID_COMPLEX        1\r
+#define SKP_Silk_PITCH_EST_MAX_COMPLEX        2\r
 \r
 void SKP_Silk_decode_pitch(\r
     SKP_int            lagIndex,        /* I                                              */\r
@@ -417,17 +322,18 @@ void SKP_Silk_decode_pitch(
     SKP_int            Fs_kHz           /* I sampling frequency (kHz)                     */\r
 );\r
 \r
-SKP_int SKP_Silk_pitch_analysis_core(     /* O    Voicing estimate: 0 voiced, 1 unvoiced                      */\r
-    const SKP_int16    *signal,           /* I    Signal of length PITCH_EST_FRAME_LENGTH_MS*Fs_kHz           */\r
-    SKP_int            *pitch_out,        /* O    4 pitch lag values                                          */\r
-    SKP_int            *lagIndex,         /* O    Lag Index                                                   */\r
-    SKP_int            *contourIndex,     /* O    Pitch contour Index                                         */\r
-    SKP_int            *LTPCorr_Q15,      /* I/O  Normalized correlation; input: value from previous frame    */\r
-    SKP_int            prevLag,           /* I    Last lag of previous frame; set to zero is unvoiced         */\r
-    const SKP_int32    search_thres1_Q16, /* I    First stage threshold for lag candidates 0 - 1              */\r
-    const SKP_int      search_thres2_Q15, /* I    Final threshold for lag candidates 0 - 1                    */\r
-    const SKP_int      Fs_kHz,            /* I    Sample frequency (kHz)                                      */\r
-    const SKP_int      complexity         /* I    Complexity setting, 0-2, where 2 is highest                 */\r
+SKP_int SKP_Silk_pitch_analysis_core(    /* O    Voicing estimate: 0 voiced, 1 unvoiced                      */\r
+    const SKP_int16  *signal,            /* I    Signal of length PITCH_EST_FRAME_LENGTH_MS*Fs_kHz           */\r
+    SKP_int          *pitch_out,         /* O    4 pitch lag values                                          */\r
+    SKP_int          *lagIndex,          /* O    Lag Index                                                   */\r
+    SKP_int          *contourIndex,      /* O    Pitch contour Index                                         */\r
+    SKP_int          *LTPCorr_Q15,       /* I/O  Normalized correlation; input: value from previous frame    */\r
+    SKP_int          prevLag,            /* I    Last lag of previous frame; set to zero is unvoiced         */\r
+    const SKP_int32  search_thres1_Q16,  /* I    First stage threshold for lag candidates 0 - 1              */\r
+    const SKP_int    search_thres2_Q15,  /* I    Final threshold for lag candidates 0 - 1                    */\r
+    const SKP_int    Fs_kHz,             /* I    Sample frequency (kHz)                                      */\r
+    const SKP_int    complexity,         /* I    Complexity setting, 0-2, where 2 is highest                 */\r
+       const SKP_int    forLJC                      /* I        1 if this function is called from LJC code, 0 otherwise.    */\r
 );\r
 \r
 /* parameter defining the size and accuracy of the piecewise linear    */\r
@@ -437,13 +343,6 @@ SKP_int SKP_Silk_pitch_analysis_core(     /* O    Voicing estimate: 0 voiced, 1
 /* rom table with cosine values */\r
 extern const SKP_int SKP_Silk_LSFCosTab_FIX_Q12[ LSF_COS_TAB_SZ_FIX + 1 ];\r
 \r
-void SKP_Silk_LPC_fit(\r
-          SKP_int16    *a_QQ,            /* O    stabilized LPC vector, Q(24-rshift) [L]         */\r
-          SKP_int32    *a_Q24,           /* I    LPC vector [L]                                  */\r
-    const SKP_int      QQ,               /* I    Q domain of output LPC vector                   */\r
-    const SKP_int      L                 /* I    Number of LPC parameters in the input vector    */\r
-);\r
-\r
 /* Compute Normalized Line Spectral Frequencies (NLSFs) from whitening filter coefficients        */\r
 /* If not all roots are found, the a_Q16 coefficients are bandwidth expanded until convergence.    */\r
 void SKP_Silk_A2NLSF(\r
@@ -466,13 +365,6 @@ void SKP_Silk_insertion_sort_increasing(
     const SKP_int        K              /* I:    Number of correctly sorted positions    */\r
 );\r
 \r
-void SKP_Silk_insertion_sort_decreasing(\r
-    SKP_int              *a,            /* I/O:  Unsorted / Sorted vector                */\r
-    SKP_int              *index,        /* O:    Index vector for the sorted elements    */\r
-    const SKP_int        L,             /* I:    Vector length                           */\r
-    const SKP_int        K              /* I:    Number of correctly sorted positions    */\r
-);\r
-\r
 void SKP_Silk_insertion_sort_decreasing_int16(\r
     SKP_int16            *a,            /* I/O:  Unsorted / Sorted vector                */\r
     SKP_int              *index,        /* O:    Index vector for the sorted elements    */\r
@@ -492,14 +384,6 @@ void SKP_Silk_NLSF_stabilize(
     const SKP_int        L               /* I:    Number of NLSF parameters in the input vector                           */\r
 );\r
 \r
-/* NLSF stabilizer, over multiple input column data vectors */\r
-void SKP_Silk_NLSF_stabilize_multi(\r
-          SKP_int        *NLSF_Q15,      /* I/O:  Unstable/stabilized normalized LSF vectors in Q15 [LxN]                 */\r
-    const SKP_int        *NDeltaMin_Q15, /* I:    Normalized delta min vector in Q15, NDeltaMin_Q15[L] must be >= 1 [L+1] */\r
-    const SKP_int        N,              /* I:    Number of input vectors to be stabilized                                */\r
-    const SKP_int        L               /* I:    NLSF vector dimension                                                   */\r
-);\r
-\r
 /* Laroia low complexity NLSF weights */\r
 void SKP_Silk_NLSF_VQ_weights_laroia(\r
     SKP_int              *pNLSFW_Q6,     /* O:    Pointer to input vector weights            [D x 1]       */\r
@@ -519,13 +403,6 @@ void SKP_Silk_burg_modified(
     const SKP_int        D                   /* I   order                                                           */\r
 );\r
 \r
-/* Multiply a vector by a constant */\r
-void SKP_Silk_scale_vector16_Q14( \r
-    SKP_int16            *data1, \r
-    SKP_int              gain_Q14,           /* Gain in Q14 */ \r
-    SKP_int              dataSize\r
-);\r
-\r
 /* Copy and multiply a vector by a constant */\r
 void SKP_Silk_scale_copy_vector16( \r
     SKP_int16            *data_out, \r
@@ -534,19 +411,6 @@ void SKP_Silk_scale_copy_vector16(
     const SKP_int        dataSize            /* I:   length        */\r
 );\r
 \r
-void SKP_Silk_scale_vector32_16_Q14( \r
-    SKP_int32            *data1,             /* I/O: Q0/Q0         */\r
-    SKP_int              gain_Q14,           /* I:   Q14           */\r
-    SKP_int              dataSize            /* I:   length        */\r
-);\r
-\r
-/* Multiply a vector by a constant, does not saturate output data */\r
-void SKP_Silk_scale_vector32_Q16( \r
-    SKP_int32            *data1,             /* I/O: Q0/Q0         */\r
-    SKP_int32            gain_Q16,           /* I:   gain in Q16 ( SKP_int16_MIN <= gain_Q16 <= SKP_int16_MAX + 65536 ) */\r
-    const SKP_int        dataSize            /* I:   length        */\r
-);\r
-\r
 /* Some for the LTP related function requires Q26 to work.*/\r
 void SKP_Silk_scale_vector32_Q26_lshift_18( \r
     SKP_int32            *data1,             /* I/O: Q0/Q18        */\r
@@ -566,31 +430,32 @@ SKP_int32 SKP_Silk_inner_prod_aligned(
     const SKP_int          len               /* I   vector lengths    */\r
 );\r
 \r
-SKP_int32 SKP_Silk_inner_prod16_aligned_sat(\r
-    const SKP_int16* const inVec1,           /* I   input vector 1  */\r
-    const SKP_int16* const inVec2,           /* I   input vector 2  */\r
-    const SKP_int          len               /* I   vector lengths  */\r
-);\r
-\r
-SKP_int64 SKP_Silk_inner_prod_aligned_64(\r
-    const SKP_int32        *inVec1,          /* I   input vector 1    */ \r
-    const SKP_int32        *inVec2,          /* I   input vector 2    */\r
-    const SKP_int          len               /* I   vector lengths    */\r
-);\r
-\r
 SKP_int64 SKP_Silk_inner_prod16_aligned_64(\r
-    const SKP_int16        *inVec1,          /* I   input vector 1    */ \r
+    const SKP_int16        *inVec1,          /* I   input vector 1    */\r
     const SKP_int16        *inVec2,          /* I   input vector 2    */\r
     const SKP_int          len               /* I   vector lengths    */\r
 );\r
 /********************************************************************/\r
-/*                                MACROS                                */\r
+/*                                MACROS                            */\r
 /********************************************************************/\r
 \r
-/* Define 4-byte aligned array of SKP_int16 */\r
-#define SKP_array_of_int16_4_byte_aligned( arrayName, nElements )    \\r
-    SKP_int32 dummy_int32 ## arrayName;                                \\r
-    SKP_int16 arrayName[ (nElements) ]\r
+/* Rotate a32 right by 'rot' bits. Negative rot values result in rotating\r
+   left. Output is 32bit int.\r
+   Note: contemporary compilers recognize the C expression below and\r
+   compile it into a 'ror' instruction if available. No need for inline ASM! */\r
+SKP_INLINE SKP_int32 SKP_ROR32( SKP_int32 a32, SKP_int rot )\r
+{\r
+    SKP_uint32 x = (SKP_uint32) a32;\r
+    SKP_uint32 r = (SKP_uint32) rot;\r
+    SKP_uint32 m = (SKP_uint32) -rot;\r
+    if(rot <= 0)\r
+        return (SKP_int32) ((x << m) | (x >> (32 - m)));\r
+    else\r
+        return (SKP_int32) ((x << (32 - r)) | (x >> r));\r
+}\r
+\r
+/* Allocate SKP_int16 alligned to 4-byte memory address */\r
+#define SKP_DWORD_ALIGN\r
 \r
 /* Useful Macros that can be adjusted to other platforms */\r
 #define SKP_memcpy(a, b, c)                memcpy((a), (b), (c))    /* Dest, Src, ByteCount */\r
@@ -607,12 +472,6 @@ SKP_int64 SKP_Silk_inner_prod16_aligned_64(
 // a32 + (b32 * c32) output have to be 32bit int\r
 #define SKP_MLA(a32, b32, c32)             SKP_ADD32((a32),((b32) * (c32)))\r
 \r
-// a32 + (b32 * c32) output have to be 32bit uint\r
-#define SKP_MLA_uint(a32, b32, c32)        SKP_MLA(a32, b32, c32)\r
-\r
-// ((a32 >> 16)  * (b32 >> 16)) output have to be 32bit int\r
-#define SKP_SMULTT(a32, b32)               (((a32) >> 16) * ((b32) >> 16))\r
-\r
 // a32 + ((a32 >> 16)  * (b32 >> 16)) output have to be 32bit int\r
 #define SKP_SMLATT(a32, b32, c32)          SKP_ADD32((a32),((b32) >> 16) * ((c32) >> 16))\r
 \r
@@ -626,70 +485,40 @@ SKP_int64 SKP_Silk_inner_prod16_aligned_64(
 #ifndef SKP_SMLABB_ovflw\r
 #    define SKP_SMLABB_ovflw(a32, b32, c32)    SKP_SMLABB(a32, b32, c32)\r
 #endif\r
-#define SKP_SMLABT_ovflw(a32, b32, c32)    SKP_SMLABT(a32, b32, c32)\r
 #define SKP_SMLATT_ovflw(a32, b32, c32)    SKP_SMLATT(a32, b32, c32)\r
 #define SKP_SMLAWB_ovflw(a32, b32, c32)    SKP_SMLAWB(a32, b32, c32)\r
 #define SKP_SMLAWT_ovflw(a32, b32, c32)    SKP_SMLAWT(a32, b32, c32)\r
 \r
-#define SKP_DIV64_32(a64, b32)             ((a64)/(b32))        /* TODO: rewrite it as a set of SKP_DIV32.*/\r
-\r
 #define SKP_DIV32_16(a32, b16)             ((SKP_int32)((a32) / (b16)))\r
 #define SKP_DIV32(a32, b32)                ((SKP_int32)((a32) / (b32)))\r
 \r
-// These macros enables checking for overflow in SKP_Silk_API_Debug.h\r
-#define SKP_ADD16(a, b)                    ((a) + (b))\r
 #define SKP_ADD32(a, b)                    ((a) + (b))\r
 #define SKP_ADD64(a, b)                    ((a) + (b))\r
 \r
-#define SKP_SUB16(a, b)                    ((a) - (b))\r
 #define SKP_SUB32(a, b)                    ((a) - (b))\r
-#define SKP_SUB64(a, b)                    ((a) - (b))\r
 \r
-#define SKP_SAT8(a)                        ((a) > SKP_int8_MAX ? SKP_int8_MAX  : \\r
-                                           ((a) < SKP_int8_MIN ? SKP_int8_MIN  : (a)))\r
 #define SKP_SAT16(a)                       ((a) > SKP_int16_MAX ? SKP_int16_MAX : \\r
                                            ((a) < SKP_int16_MIN ? SKP_int16_MIN : (a)))\r
 #define SKP_SAT32(a)                       ((a) > SKP_int32_MAX ? SKP_int32_MAX : \\r
                                            ((a) < SKP_int32_MIN ? SKP_int32_MIN : (a)))\r
 \r
-#define SKP_CHECK_FIT8(a)                  (a)\r
 #define SKP_CHECK_FIT16(a)                 (a)\r
 #define SKP_CHECK_FIT32(a)                 (a)\r
 \r
 #define SKP_ADD_SAT16(a, b)                (SKP_int16)SKP_SAT16( SKP_ADD32( (SKP_int32)(a), (b) ) )\r
-#define SKP_ADD_SAT64(a, b)                ((((a) + (b)) & 0x8000000000000000LL) == 0 ?                            \\r
-                                           ((((a) & (b)) & 0x8000000000000000LL) != 0 ? SKP_int64_MIN : (a)+(b)) :    \\r
-                                           ((((a) | (b)) & 0x8000000000000000LL) == 0 ? SKP_int64_MAX : (a)+(b)) )\r
-\r
-#define SKP_SUB_SAT16(a, b)                (SKP_int16)SKP_SAT16( SKP_SUB32( (SKP_int32)(a), (b) ) )\r
-#define SKP_SUB_SAT64(a, b)                ((((a)-(b)) & 0x8000000000000000LL) == 0 ?                                                    \\r
-                                           (( (a) & ((b)^0x8000000000000000LL) & 0x8000000000000000LL) ? SKP_int64_MIN : (a)-(b)) :    \\r
-                                           ((((a)^0x8000000000000000LL) & (b)  & 0x8000000000000000LL) ? SKP_int64_MAX : (a)-(b)) )\r
-\r
-/* Saturation for positive input values */ \r
-#define SKP_POS_SAT32(a)                   ((a) > SKP_int32_MAX ? SKP_int32_MAX : (a))\r
 \r
 /* Add with saturation for positive input values */ \r
-#define SKP_ADD_POS_SAT8(a, b)             ((((a)+(b)) & 0x80)                 ? SKP_int8_MAX  : ((a)+(b)))\r
-#define SKP_ADD_POS_SAT16(a, b)            ((((a)+(b)) & 0x8000)               ? SKP_int16_MAX : ((a)+(b)))\r
 #define SKP_ADD_POS_SAT32(a, b)            ((((a)+(b)) & 0x80000000)           ? SKP_int32_MAX : ((a)+(b)))\r
-#define SKP_ADD_POS_SAT64(a, b)            ((((a)+(b)) & 0x8000000000000000LL) ? SKP_int64_MAX : ((a)+(b)))\r
 \r
-#define SKP_LSHIFT8(a, shift)              ((a)<<(shift))                // shift >= 0, shift < 8\r
-#define SKP_LSHIFT16(a, shift)             ((a)<<(shift))                // shift >= 0, shift < 16\r
 #define SKP_LSHIFT32(a, shift)             ((a)<<(shift))                // shift >= 0, shift < 32\r
 #define SKP_LSHIFT64(a, shift)             ((a)<<(shift))                // shift >= 0, shift < 64\r
 #define SKP_LSHIFT(a, shift)               SKP_LSHIFT32(a, shift)        // shift >= 0, shift < 32\r
 \r
-#define SKP_RSHIFT8(a, shift)              ((a)>>(shift))                // shift >= 0, shift < 8\r
-#define SKP_RSHIFT16(a, shift)             ((a)>>(shift))                // shift >= 0, shift < 16\r
 #define SKP_RSHIFT32(a, shift)             ((a)>>(shift))                // shift >= 0, shift < 32\r
 #define SKP_RSHIFT64(a, shift)             ((a)>>(shift))                // shift >= 0, shift < 64\r
 #define SKP_RSHIFT(a, shift)               SKP_RSHIFT32(a, shift)        // shift >= 0, shift < 32\r
 \r
 /* saturates before shifting */\r
-#define SKP_LSHIFT_SAT16(a, shift)         (SKP_LSHIFT16( SKP_LIMIT( (a), SKP_RSHIFT16( SKP_int16_MIN, (shift) ),    \\r
-                                                                          SKP_RSHIFT16( SKP_int16_MAX, (shift) ) ), (shift) ))\r
 #define SKP_LSHIFT_SAT32(a, shift)         (SKP_LSHIFT32( SKP_LIMIT( (a), SKP_RSHIFT32( SKP_int32_MIN, (shift) ),    \\r
                                                                           SKP_RSHIFT32( SKP_int32_MAX, (shift) ) ), (shift) ))\r
 \r
@@ -699,7 +528,6 @@ SKP_int64 SKP_Silk_inner_prod16_aligned_64(
 \r
 #define SKP_ADD_LSHIFT(a, b, shift)       ((a) + SKP_LSHIFT((b), (shift)))            // shift >= 0\r
 #define SKP_ADD_LSHIFT32(a, b, shift)     SKP_ADD32((a), SKP_LSHIFT32((b), (shift)))    // shift >= 0\r
-#define SKP_ADD_LSHIFT_uint(a, b, shift)  ((a) + SKP_LSHIFT_uint((b), (shift)))        // shift >= 0\r
 #define SKP_ADD_RSHIFT(a, b, shift)       ((a) + SKP_RSHIFT((b), (shift)))            // shift >= 0\r
 #define SKP_ADD_RSHIFT32(a, b, shift)     SKP_ADD32((a), SKP_RSHIFT32((b), (shift)))    // shift >= 0\r
 #define SKP_ADD_RSHIFT_uint(a, b, shift)  ((a) + SKP_RSHIFT_uint((b), (shift)))        // shift >= 0\r
@@ -712,32 +540,23 @@ SKP_int64 SKP_Silk_inner_prod16_aligned_64(
 \r
 /* Number of rightshift required to fit the multiplication */\r
 #define SKP_NSHIFT_MUL_32_32(a, b)        ( -(31- (32-SKP_Silk_CLZ32(SKP_abs(a)) + (32-SKP_Silk_CLZ32(SKP_abs(b))))) )\r
-#define SKP_NSHIFT_MUL_16_16(a, b)        ( -(15- (16-SKP_Silk_CLZ16(SKP_abs(a)) + (16-SKP_Silk_CLZ16(SKP_abs(b))))) )\r
-\r
 \r
 #define SKP_min(a, b)                     (((a) < (b)) ? (a) : (b)) \r
 #define SKP_max(a, b)                     (((a) > (b)) ? (a) : (b))\r
 \r
 /* Macro to convert floating-point constants to fixed-point */\r
-#define SKP_FIX_CONST( C, Q )             ((SKP_int32)((C) * (1 << (Q)) + 0.5))\r
+#define SKP_FIX_CONST( C, Q )           ((SKP_int32)((C) * ((SKP_int64)1 << (Q)) + 0.5))\r
 \r
 /* SKP_min() versions with typecast in the function call */\r
 SKP_INLINE SKP_int SKP_min_int(SKP_int a, SKP_int b)\r
 {\r
     return (((a) < (b)) ? (a) : (b));\r
 }\r
-SKP_INLINE SKP_int16 SKP_min_16(SKP_int16 a, SKP_int16 b)\r
-{\r
-    return (((a) < (b)) ? (a) : (b));\r
-}\r
+\r
 SKP_INLINE SKP_int32 SKP_min_32(SKP_int32 a, SKP_int32 b)\r
 {\r
     return (((a) < (b)) ? (a) : (b));\r
 }\r
-SKP_INLINE SKP_int64 SKP_min_64(SKP_int64 a, SKP_int64 b)\r
-{\r
-    return (((a) < (b)) ? (a) : (b));\r
-}\r
 \r
 /* SKP_min() versions with typecast in the function call */\r
 SKP_INLINE SKP_int SKP_max_int(SKP_int a, SKP_int b)\r
@@ -752,24 +571,17 @@ SKP_INLINE SKP_int32 SKP_max_32(SKP_int32 a, SKP_int32 b)
 {\r
     return (((a) > (b)) ? (a) : (b));\r
 }\r
-SKP_INLINE SKP_int64 SKP_max_64(SKP_int64 a, SKP_int64 b)\r
-{\r
-    return (((a) > (b)) ? (a) : (b));\r
-}\r
 \r
 #define SKP_LIMIT( a, limit1, limit2)    ((limit1) > (limit2) ? ((a) > (limit1) ? (limit1) : ((a) < (limit2) ? (limit2) : (a))) \\r
                                                              : ((a) > (limit2) ? (limit2) : ((a) < (limit1) ? (limit1) : (a))))\r
 \r
+#define SKP_LIMIT_int SKP_LIMIT\r
+#define SKP_LIMIT_32 SKP_LIMIT\r
+\r
 //#define SKP_non_neg(a)                 ((a) & ((-(a)) >> (8 * sizeof(a) - 1)))   /* doesn't seem faster than SKP_max(0, a);\r
 \r
 #define SKP_abs(a)                       (((a) >  0)  ? (a) : -(a))            // Be careful, SKP_abs returns wrong when input equals to SKP_intXX_MIN\r
-#define SKP_abs_int(a)                   (((a) ^ ((a) >> (8 * sizeof(a) - 1))) - ((a) >> (8 * sizeof(a) - 1)))\r
 #define SKP_abs_int32(a)                 (((a) ^ ((a) >> 31)) - ((a) >> 31))\r
-#define SKP_abs_int64(a)                 (((a) >  0)  ? (a) : -(a))    \r
-\r
-#define SKP_sign(a)                      ((a) > 0 ? 1 : ( (a) < 0 ? -1 : 0 ))\r
-\r
-#define SKP_sqrt(a)                      (sqrt(a)) \r
 \r
 /* PSEUDO-RANDOM GENERATOR                                                          */\r
 /* Make sure to store the result as the seed for the next call (also in between     */\r
index 30a5aa6bc3ba5fc3a7c1a591564aec7be4db2ac6..c151663e6dd014073eb23c04d25571c05a3b48e3 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -141,7 +141,7 @@ SKP_int SKP_Silk_VAD_GetSA_Q8(                                      /* O    Retu
         for( s = 0; s < VAD_INTERNAL_SUBFRAMES; s++ ) {\r
             sumSquared = 0;\r
             for( i = 0; i < dec_subframe_length; i++ ) {\r
-                /* The energy will be less than dec_subframe_length * ( SKP_int16_MIN / 8 )^2.              */\r
+                /* The energy will be less than dec_subframe_length * ( SKP_int16_MIN / 8 ) ^ 2.            */\r
                 /* Therefore we can accumulate with no risk of overflow (unless dec_subframe_length > 128)  */\r
                 x_tmp = SKP_RSHIFT( X[ b ][ i + dec_subframe_offset ], 3 );\r
                 sumSquared = SKP_SMLABB( sumSquared, x_tmp, x_tmp );\r
@@ -150,11 +150,11 @@ SKP_int SKP_Silk_VAD_GetSA_Q8(                                      /* O    Retu
                 SKP_assert( sumSquared >= 0 );\r
             }\r
 \r
-            /* add/saturate summed energy of current subframe */\r
+            /* Add/saturate summed energy of current subframe */\r
             if( s < VAD_INTERNAL_SUBFRAMES - 1 ) {\r
                 Xnrg[ b ] = SKP_ADD_POS_SAT32( Xnrg[ b ], sumSquared );\r
             } else {\r
-                /* look-ahead subframe */\r
+                /* Look-ahead subframe */\r
                 Xnrg[ b ] = SKP_ADD_POS_SAT32( Xnrg[ b ], SKP_RSHIFT( sumSquared, 1 ) );\r
             }\r
 \r
@@ -201,7 +201,7 @@ SKP_int SKP_Silk_VAD_GetSA_Q8(                                      /* O    Retu
     }\r
 \r
     /* Mean-of-squares */\r
-    sumSquared = SKP_DIV32_16( sumSquared, VAD_N_BANDS );           /* Q14 */\r
+    sumSquared = SKP_DIV32_16( sumSquared, VAD_N_BANDS ); /* Q14 */\r
 \r
     /* Root-mean-square approximation, scale to dBs, and write to output pointer */\r
     *pSNR_dB_Q7 = ( SKP_int16 )( 3 * SKP_Silk_SQRT_APPROX( sumSquared ) );  /* Q7 */\r
@@ -240,7 +240,7 @@ SKP_int SKP_Silk_VAD_GetSA_Q8(                                      /* O    Retu
     /***********************************/\r
     /* Energy Level and SNR estimation */\r
     /***********************************/\r
-    /* smoothing coefficient */\r
+    /* Smoothing coefficient */\r
     smooth_coef_Q16 = SKP_SMULWB( VAD_SNR_SMOOTH_COEF_Q18, SKP_SMULWB( SA_Q15, SA_Q15 ) );\r
     for( b = 0; b < VAD_N_BANDS; b++ ) {\r
         /* compute smoothed energy-to-noise ratio per band */\r
index 82727d5b7c40024edf09488f72e8a444e9fa4d2c..ae780aa8482569ae58194d91daf760b7bd2e0095 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -41,60 +41,57 @@ void SKP_Silk_VQ_WMat_EC_FIX(
 {\r
     SKP_int   k;\r
     const SKP_int16 *cb_row_Q14;\r
-    SKP_int32 sum1_Q14, sum2_Q16, diff_Q14_01, diff_Q14_23, diff_Q14_4;\r
+    SKP_int16 diff_Q14[ 5 ];\r
+    SKP_int32 sum1_Q14, sum2_Q16;\r
 \r
     /* Loop over codebook */\r
     *rate_dist_Q14 = SKP_int32_MAX;\r
     cb_row_Q14 = cb_Q14;\r
     for( k = 0; k < L; k++ ) {\r
-        /* Pack pairs of int16 values per int32 */\r
-        diff_Q14_01 = (SKP_uint16)( in_Q14[ 0 ] - cb_row_Q14[ 0 ] ) | SKP_LSHIFT( ( SKP_int32 )in_Q14[ 1 ] - cb_row_Q14[ 1 ], 16 );\r
-        diff_Q14_23 = (SKP_uint16)( in_Q14[ 2 ] - cb_row_Q14[ 2 ] ) | SKP_LSHIFT( ( SKP_int32 )in_Q14[ 3 ] - cb_row_Q14[ 3 ], 16 );\r
-        diff_Q14_4  = in_Q14[ 4 ] - cb_row_Q14[ 4 ];\r
+        diff_Q14[ 0 ] = in_Q14[ 0 ] - cb_row_Q14[ 0 ];\r
+        diff_Q14[ 1 ] = in_Q14[ 1 ] - cb_row_Q14[ 1 ];\r
+        diff_Q14[ 2 ] = in_Q14[ 2 ] - cb_row_Q14[ 2 ];\r
+        diff_Q14[ 3 ] = in_Q14[ 3 ] - cb_row_Q14[ 3 ];\r
+        diff_Q14[ 4 ] = in_Q14[ 4 ] - cb_row_Q14[ 4 ];\r
 \r
         /* Weighted rate */\r
         sum1_Q14 = SKP_SMULBB( mu_Q8, cl_Q6[ k ] );\r
 \r
         SKP_assert( sum1_Q14 >= 0 );\r
 \r
-        /* Add weighted quantization error, assuming W_Q18 is symmetric */\r
-        /* NOTE: the code below loads two int16 values as one int32, and multiplies each using the  */\r
-        /* SMLAWB and SMLAWT instructions. On a big-endian CPU the two int16 variables would be     */\r
-        /* loaded in reverse order and the code will give the wrong result. In that case swapping   */\r
-        /* the SMLAWB and SMLAWT instructions should solve the problem.                             */\r
         /* first row of W_Q18 */\r
-        sum2_Q16 = SKP_SMULWT(           W_Q18[ 1 ], diff_Q14_01 );\r
-        sum2_Q16 = SKP_SMLAWB( sum2_Q16, W_Q18[ 2 ], diff_Q14_23 );\r
-        sum2_Q16 = SKP_SMLAWT( sum2_Q16, W_Q18[ 3 ], diff_Q14_23 );\r
-        sum2_Q16 = SKP_SMLAWB( sum2_Q16, W_Q18[ 4 ], diff_Q14_4  );\r
+        sum2_Q16 = SKP_SMULWB(           W_Q18[  1 ], diff_Q14[ 1 ] );\r
+        sum2_Q16 = SKP_SMLAWB( sum2_Q16, W_Q18[  2 ], diff_Q14[ 2 ] );\r
+        sum2_Q16 = SKP_SMLAWB( sum2_Q16, W_Q18[  3 ], diff_Q14[ 3 ] );\r
+        sum2_Q16 = SKP_SMLAWB( sum2_Q16, W_Q18[  4 ], diff_Q14[ 4 ] );\r
         sum2_Q16 = SKP_LSHIFT( sum2_Q16, 1 );\r
-        sum2_Q16 = SKP_SMLAWB( sum2_Q16, W_Q18[ 0 ], diff_Q14_01 );\r
-        sum1_Q14 = SKP_SMLAWB( sum1_Q14, sum2_Q16,   diff_Q14_01 );\r
+        sum2_Q16 = SKP_SMLAWB( sum2_Q16, W_Q18[  0 ], diff_Q14[ 0 ] );\r
+        sum1_Q14 = SKP_SMLAWB( sum1_Q14, sum2_Q16,    diff_Q14[ 0 ] );\r
 \r
         /* second row of W_Q18 */\r
-        sum2_Q16 = SKP_SMULWB(           W_Q18[ 7 ], diff_Q14_23 );\r
-        sum2_Q16 = SKP_SMLAWT( sum2_Q16, W_Q18[ 8 ], diff_Q14_23 );\r
-        sum2_Q16 = SKP_SMLAWB( sum2_Q16, W_Q18[ 9 ], diff_Q14_4  );\r
+        sum2_Q16 = SKP_SMULWB(           W_Q18[  7 ], diff_Q14[ 2 ] ); \r
+        sum2_Q16 = SKP_SMLAWB( sum2_Q16, W_Q18[  8 ], diff_Q14[ 3 ] );\r
+        sum2_Q16 = SKP_SMLAWB( sum2_Q16, W_Q18[  9 ], diff_Q14[ 4 ] );\r
         sum2_Q16 = SKP_LSHIFT( sum2_Q16, 1 );\r
-        sum2_Q16 = SKP_SMLAWT( sum2_Q16, W_Q18[ 6 ], diff_Q14_01 );\r
-        sum1_Q14 = SKP_SMLAWT( sum1_Q14, sum2_Q16,   diff_Q14_01 );\r
+        sum2_Q16 = SKP_SMLAWB( sum2_Q16, W_Q18[  6 ], diff_Q14[ 1 ] );\r
+        sum1_Q14 = SKP_SMLAWB( sum1_Q14, sum2_Q16,    diff_Q14[ 1 ] );\r
 \r
         /* third row of W_Q18 */\r
-        sum2_Q16 = SKP_SMULWT(           W_Q18[ 13 ], diff_Q14_23 );\r
-        sum2_Q16 = SKP_SMLAWB( sum2_Q16, W_Q18[ 14 ], diff_Q14_4  );\r
+        sum2_Q16 = SKP_SMULWB(           W_Q18[ 13 ], diff_Q14[ 3 ] ); \r
+        sum2_Q16 = SKP_SMLAWB( sum2_Q16, W_Q18[ 14 ], diff_Q14[ 4 ] );\r
         sum2_Q16 = SKP_LSHIFT( sum2_Q16, 1 );\r
-        sum2_Q16 = SKP_SMLAWB( sum2_Q16, W_Q18[ 12 ], diff_Q14_23 );\r
-        sum1_Q14 = SKP_SMLAWB( sum1_Q14, sum2_Q16,    diff_Q14_23 );\r
+        sum2_Q16 = SKP_SMLAWB( sum2_Q16, W_Q18[ 12 ], diff_Q14[ 2 ] );\r
+        sum1_Q14 = SKP_SMLAWB( sum1_Q14, sum2_Q16,    diff_Q14[ 2 ] );\r
 \r
         /* fourth row of W_Q18 */\r
-        sum2_Q16 = SKP_SMULWB(           W_Q18[ 19 ], diff_Q14_4  );\r
+        sum2_Q16 = SKP_SMULWB(           W_Q18[ 19 ], diff_Q14[ 4 ] ); \r
         sum2_Q16 = SKP_LSHIFT( sum2_Q16, 1 );\r
-        sum2_Q16 = SKP_SMLAWT( sum2_Q16, W_Q18[ 18 ], diff_Q14_23 );\r
-        sum1_Q14 = SKP_SMLAWT( sum1_Q14, sum2_Q16,    diff_Q14_23 );\r
+        sum2_Q16 = SKP_SMLAWB( sum2_Q16, W_Q18[ 18 ], diff_Q14[ 3 ] );\r
+        sum1_Q14 = SKP_SMLAWB( sum1_Q14, sum2_Q16,    diff_Q14[ 3 ] );\r
 \r
         /* last row of W_Q18 */\r
-        sum2_Q16 = SKP_SMULWB(           W_Q18[ 24 ], diff_Q14_4  );\r
-        sum1_Q14 = SKP_SMLAWB( sum1_Q14, sum2_Q16,    diff_Q14_4  );\r
+        sum2_Q16 = SKP_SMULWB(           W_Q18[ 24 ], diff_Q14[ 4 ] ); \r
+        sum1_Q14 = SKP_SMLAWB( sum1_Q14, sum2_Q16,    diff_Q14[ 4 ] );\r
 \r
         SKP_assert( sum1_Q14 >= 0 );\r
 \r
diff --git a/libs/silk/src/SKP_Silk_allpass_int.c b/libs/silk/src/SKP_Silk_allpass_int.c
deleted file mode 100644 (file)
index 20adfd5..0000000
+++ /dev/null
@@ -1,69 +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
-/*                                                                        *\r
- * SKP_Silk_allpass_int.c                                               *\r
- *                                                                        *\r
- * First-order allpass filter with                                        *\r
- * transfer function:                                                     *\r
- *                                                                        *\r
- *         A + Z^(-1)                                                     *\r
- * H(z) = ------------                                                    *\r
- *        1 + A*Z^(-1)                                                    *\r
- *                                                                        *\r
- * Implemented using minimum multiplier filter design.                    *\r
- *                                                                        *\r
- * Reference: http://www.univ.trieste.it/~ramponi/teaching/               *\r
- * DSP/materiale/Ch6(2).pdf                                               *\r
- *                                                                        *\r
- * Copyright 2007 (c), Skype Limited                                      *\r
- * Date: 070525                                                           *\r
- *                                                                        */\r
-#include "SKP_Silk_SigProc_FIX.h"\r
-\r
-\r
-/* First-order allpass filter */\r
-void SKP_Silk_allpass_int(\r
-    const SKP_int32      *in,    /* I:    Q25 input signal [len]               */\r
-    SKP_int32            *S,     /* I/O: Q25 state [1]                         */\r
-    SKP_int              A,      /* I:    Q15 coefficient    (0 <= A < 32768)  */\r
-    SKP_int32            *out,   /* O:    Q25 output signal [len]              */\r
-    const SKP_int32      len     /* I:    Number of samples                    */\r
-)\r
-{\r
-    SKP_int32    Y2, X2, S0;\r
-    SKP_int        k;\r
-\r
-    S0 = S[ 0 ];\r
-    for( k = len - 1; k >= 0; k-- ) {\r
-        Y2         = *in - S0;\r
-        X2         = ( Y2 >> 15 ) * A + ( ( ( Y2 & 0x00007FFF ) * A ) >> 15 );\r
-        ( *out++ ) = S0 + X2;\r
-        S0         = ( *in++ ) + X2;\r
-    }\r
-    S[ 0 ] = S0;\r
-}\r
index 3dd3b1bd8de0c579247e81f8fabc75e232befdee..59b8068718194ce691763e753192140d41a0fc80 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -36,38 +36,45 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "SKP_Silk_SigProc_FIX.h"\r
 \r
 /* Coefficients for 2-band filter bank based on first-order allpass filters */\r
-static SKP_int16 A_fb1_20[ 1 ] = {  5394 };\r
-static SKP_int16 A_fb1_21[ 1 ] = { 20623 };\r
+// old\r
+static SKP_int16 A_fb1_20[ 1 ] = {  5394 << 1 };\r
+static SKP_int16 A_fb1_21[ 1 ] = { 20623 << 1 };        /* wrap-around to negative number is intentional */\r
 \r
 /* Split signal into two decimated bands using first-order allpass filters */\r
 void SKP_Silk_ana_filt_bank_1(\r
-    const SKP_int16      *in,        /* I:    Input signal [N]       */\r
+    const SKP_int16      *in,        /* I:   Input signal [N]        */\r
     SKP_int32            *S,         /* I/O: State vector [2]        */\r
-    SKP_int16            *outL,      /* O:    Low band [N/2]         */\r
-    SKP_int16            *outH,      /* O:    High band [N/2]        */\r
-    SKP_int32            *scratch,   /* I:    Scratch memory [3*N/2] */\r
+    SKP_int16            *outL,      /* O:   Low band [N/2]          */\r
+    SKP_int16            *outH,      /* O:   High band [N/2]         */\r
+    SKP_int32            *scratch,   /* I:   Scratch memory [3*N/2]  */   // todo: remove - no longer used\r
     const SKP_int32      N           /* I:   Number of input samples */\r
 )\r
 {\r
-    SKP_int        k, N2 = SKP_RSHIFT( N, 1 );\r
-    SKP_int32    out_tmp;\r
+    SKP_int      k, N2 = SKP_RSHIFT( N, 1 );\r
+    SKP_int32    in32, X, Y, out_1, out_2;\r
 \r
-    /* De-interleave three allpass inputs, and convert Q15 -> Q25 */\r
+    /* Internal variables and state are in Q10 format */\r
     for( k = 0; k < N2; k++ ) {\r
-        scratch[ k + N  ] = SKP_LSHIFT( (SKP_int32)in[ 2 * k     ], 10 );\r
-        scratch[ k + N2 ] = SKP_LSHIFT( (SKP_int32)in[ 2 * k + 1 ], 10 );\r
-    }\r
+        /* Convert to Q10 */\r
+        in32 = SKP_LSHIFT( (SKP_int32)in[ 2 * k ], 10 );\r
 \r
-    /* Allpass filters */\r
-    SKP_Silk_allpass_int( scratch + N2, S+0, A_fb1_20[ 0 ], scratch,      N2 );\r
-    SKP_Silk_allpass_int( scratch + N,  S+1, A_fb1_21[ 0 ], scratch + N2, N2 );\r
+        /* All-pass section for even input sample */\r
+        Y      = SKP_SUB32( in32, S[ 0 ] );\r
+        X      = SKP_SMLAWB( Y, Y, A_fb1_21[ 0 ] );\r
+        out_1  = SKP_ADD32( S[ 0 ], X );\r
+        S[ 0 ] = SKP_ADD32( in32, X );\r
 \r
-    /* Add and subtract two allpass outputs to create bands */\r
-    for( k = 0; k < N2; k++ ) {\r
-        out_tmp   = scratch[ k ] + scratch[ k + N2 ];\r
-        outL[ k ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( out_tmp, 11 ) );\r
+        /* Convert to Q10 */\r
+        in32 = SKP_LSHIFT( (SKP_int32)in[ 2 * k + 1 ], 10 );\r
 \r
-        out_tmp   = scratch[ k ] - scratch[ k + N2 ];\r
-        outH[ k ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( out_tmp, 11 ) );\r
-    }        \r
+        /* All-pass section for odd input sample */\r
+        Y      = SKP_SUB32( in32, S[ 1 ] );\r
+        X      = SKP_SMULWB( Y, A_fb1_20[ 0 ] );\r
+        out_2  = SKP_ADD32( S[ 1 ], X );\r
+        S[ 1 ] = SKP_ADD32( in32, X );\r
+\r
+        /* Add/subtract, convert back to int16 and store to output */\r
+        outL[ k ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( SKP_ADD32( out_2, out_1 ), 11 ) );\r
+        outH[ k ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( SKP_SUB32( out_2, out_1 ), 11 ) );\r
+    }\r
 }\r
diff --git a/libs/silk/src/SKP_Silk_apply_sine_window.c b/libs/silk/src/SKP_Silk_apply_sine_window.c
deleted file mode 100644 (file)
index 5d2b569..0000000
+++ /dev/null
@@ -1,92 +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_SigProc_FIX.h"\r
-\r
-/* Apply sine window to signal vector.                                      */\r
-/* Window types:                                                            */\r
-/*    0 -> sine window from 0 to pi                                         */\r
-/*    1 -> sine window from 0 to pi/2                                       */\r
-/*    2 -> sine window from pi/2 to pi                                      */\r
-/* every other sample of window is linearly interpolated, for speed         */\r
-void SKP_Silk_apply_sine_window(\r
-    SKP_int16                        px_win[],            /* O    Pointer to windowed signal                  */\r
-    const SKP_int16                  px[],                /* I    Pointer to input signal                     */\r
-    const SKP_int                    win_type,            /* I    Selects a window type                       */\r
-    const SKP_int                    length               /* I    Window length, multiple of 4                */\r
-)\r
-{\r
-    SKP_int   k;\r
-    SKP_int32 px32, f_Q16, c_Q20, S0_Q16, S1_Q16;\r
-\r
-    /* Length must be multiple of 4 */\r
-    SKP_assert( ( length & 3 ) == 0 );\r
-\r
-    /* Input pointer must be 4-byte aligned */\r
-    SKP_assert( ( (SKP_int64)px & 3 ) == 0 );\r
-\r
-    if( win_type == 0 ) {\r
-        f_Q16 = SKP_DIV32_16( 411775, length + 1 );        // 411775 = 2 * 65536 * pi\r
-    } else {\r
-        f_Q16 = SKP_DIV32_16( 205887, length + 1 );        // 205887 = 65536 * pi\r
-    }\r
-\r
-    /* factor used for cosine approximation */\r
-    c_Q20 = -SKP_RSHIFT( SKP_MUL( f_Q16, f_Q16 ), 12 );\r
-\r
-    /* c_Q20 becomes too large if length is too small */\r
-    SKP_assert( c_Q20 >= -32768 );\r
-\r
-    /* initialize state */\r
-    if( win_type < 2 ) {\r
-        /* start from 0 */\r
-        S0_Q16 = 0;\r
-        /* approximation of sin(f) */\r
-        S1_Q16 = f_Q16;\r
-    } else {\r
-        /* start from 1 */\r
-        S0_Q16 = ( 1 << 16 );\r
-        /* approximation of cos(f) */\r
-        S1_Q16 = ( 1 << 16 ) + SKP_RSHIFT( c_Q20, 5 );\r
-    }\r
-\r
-    /* Uses the recursive equation:   sin(n*f) = 2 * cos(f) * sin((n-1)*f) - sin((n-2)*f)    */\r
-    /* 4 samples at a time */\r
-    for( k = 0; k < length; k += 4 ) {\r
-        px32 = *( (SKP_int32 *)&px[ k ] );                        /* load two values at once */\r
-        px_win[ k ]     = (SKP_int16)SKP_SMULWB( SKP_RSHIFT( S0_Q16 + S1_Q16, 1 ), px32 );\r
-        px_win[ k + 1 ] = (SKP_int16)SKP_SMULWT( S1_Q16, px32 );\r
-        S0_Q16 = SKP_RSHIFT( SKP_MUL( c_Q20, S1_Q16 ), 20 ) + SKP_LSHIFT( S1_Q16, 1 ) - S0_Q16 + 1;\r
-        S0_Q16 = SKP_min( S0_Q16, ( 1 << 16 ) );\r
-\r
-        px32 = *( (SKP_int32 *)&px[k + 2] );                    /* load two values at once */\r
-        px_win[ k + 2 ] = (SKP_int16)SKP_SMULWB( SKP_RSHIFT( S0_Q16 + S1_Q16, 1 ), px32 );\r
-        px_win[ k + 3 ] = (SKP_int16)SKP_SMULWT( S0_Q16, px32 );\r
-        S1_Q16 = SKP_RSHIFT( SKP_MUL( c_Q20, S0_Q16 ), 20 ) + SKP_LSHIFT( S0_Q16, 1 ) - S1_Q16;\r
-        S1_Q16 = SKP_min( S1_Q16, ( 1 << 16 ) );\r
-    }\r
-}\r
index 915af9feb82d5577d9d0b9de9dfd5250de07cc7e..3fd4fd30c158f237c954bff11ba1d5bf65ee7346 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -43,6 +43,7 @@ SKP_int16 SKP_Silk_int16_array_maxabs(    /* O    Maximum absolute value, max: 2
 )                    \r
 {\r
     SKP_int32 max = 0, i, lvl = 0, ind;\r
+       if( len == 0 ) return 0;\r
 \r
     ind = len - 1;\r
     max = SKP_SMULBB( vec[ ind ], vec[ ind ] );\r
@@ -55,10 +56,13 @@ SKP_int16 SKP_Silk_int16_array_maxabs(    /* O    Maximum absolute value, max: 2
     }\r
 \r
     /* Do not return 32768, as it will not fit in an int16 so may lead to problems later on */\r
-    lvl = SKP_abs( vec[ ind ] );\r
-    if( lvl > SKP_int16_MAX ) {\r
+    if( max >= 1073676289 ) { // (2^15-1)^2 = 1073676289\r
         return( SKP_int16_MAX );\r
     } else {\r
-        return( (SKP_int16)lvl );\r
+        if( vec[ ind ] < 0 ) {\r
+            return( -vec[ ind ] );\r
+        } else {\r
+            return(  vec[ ind ] );\r
+        }\r
     }\r
 }\r
index 0d3652d5af470f412d134683951af338ace66cf2..f7862b8949f4644d7be989460dd2383869128bfd 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -39,7 +39,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 /* Compute autocorrelation */\r
 void SKP_Silk_autocorr( \r
     SKP_int32        *results,                   /* O    Result (length correlationCount)            */\r
-    SKP_int32        *scale,                     /* O    Scaling of the correlation vector           */\r
+    SKP_int          *scale,                     /* O    Scaling of the correlation vector           */\r
     const SKP_int16  *inputData,                 /* I    Input data to correlate                     */\r
     const SKP_int    inputDataSize,              /* I    Length of input                             */\r
     const SKP_int    correlationCount            /* I    Number of correlation taps to compute       */\r
index 81b76f1be73e745cea734f17ae573d160a332e23..611809dc3281ed65fa506697dc4ad1cc98e4f07c 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -42,7 +42,7 @@ void SKP_Silk_biquad(
     const SKP_int16      *in,        /* I:    input signal               */\r
     const SKP_int16      *B,         /* I:    MA coefficients, Q13 [3]   */\r
     const SKP_int16      *A,         /* I:    AR coefficients, Q13 [2]   */\r
-    SKP_int32            *S,         /* I/O: state vector [2]            */\r
+    SKP_int32            *S,         /* I/O:  state vector [2]           */\r
     SKP_int16            *out,       /* O:    output signal              */\r
     const SKP_int32      len         /* I:    signal length              */\r
 )\r
index 658d4d6b8b0175386a6118ce7852065d5489ef70..c97cdeed889c4d4800df3d9f87fb4ae91f87a892 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -59,15 +59,15 @@ void SKP_Silk_biquad_alt(
         inval = in[ k ];\r
         out32_Q14 = SKP_LSHIFT( SKP_SMLAWB( S[ 0 ], B_Q28[ 0 ], inval ), 2 );\r
 \r
-        S[ 0 ] = S[1] + SKP_RSHIFT( SKP_SMULWB( out32_Q14, A0_L_Q28 ), 14 );\r
+        S[ 0 ] = S[1] + SKP_RSHIFT_ROUND( SKP_SMULWB( out32_Q14, A0_L_Q28 ), 14 );\r
         S[ 0 ] = SKP_SMLAWB( S[ 0 ], out32_Q14, A0_U_Q28 );\r
         S[ 0 ] = SKP_SMLAWB( S[ 0 ], B_Q28[ 1 ], inval);\r
 \r
-        S[ 1 ] = SKP_RSHIFT( SKP_SMULWB( out32_Q14, A1_L_Q28 ), 14 );\r
+        S[ 1 ] = SKP_RSHIFT_ROUND( SKP_SMULWB( out32_Q14, A1_L_Q28 ), 14 );\r
         S[ 1 ] = SKP_SMLAWB( S[ 1 ], out32_Q14, A1_U_Q28 );\r
         S[ 1 ] = SKP_SMLAWB( S[ 1 ], B_Q28[ 2 ], inval );\r
 \r
         /* Scale back to Q0 and saturate */\r
-        out[ k ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT( out32_Q14, 14 ) + 2 );\r
+        out[ k ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT( out32_Q14 + (1<<14) - 1, 14 ) );\r
     }\r
 }\r
index 1ac47dcf7a73631529f3a052be94bfeff13235b5..fbf9e874aa48bbd858897bca0643d1e23227ef6f 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -40,7 +40,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #define MAX_FRAME_SIZE              544 // subfr_length * nb_subfr = ( 0.005 * 24000 + 16 ) * 4 = 544\r
 #define MAX_NB_SUBFR                4\r
 \r
-#define QA                          24\r
+#define QA                          25\r
 #define N_BITS_HEAD_ROOM            2\r
 #define MIN_RSHIFTS                 -16\r
 #define MAX_RSHIFTS                 (32 - QA)\r
@@ -61,12 +61,12 @@ void SKP_Silk_burg_modified(
     SKP_int32       C0, num, nrg, rc_Q31, Atmp_QA, Atmp1, tmp1, tmp2, x1, x2;\r
     const SKP_int16 *x_ptr;\r
 \r
-    SKP_int32       C_first_row[ SigProc_MAX_ORDER_LPC ];\r
-    SKP_int32       C_last_row[  SigProc_MAX_ORDER_LPC ];\r
-    SKP_int32       Af_QA[       SigProc_MAX_ORDER_LPC ];\r
+    SKP_int32       C_first_row[ SKP_Silk_MAX_ORDER_LPC ];\r
+    SKP_int32       C_last_row[  SKP_Silk_MAX_ORDER_LPC ];\r
+    SKP_int32       Af_QA[       SKP_Silk_MAX_ORDER_LPC ];\r
 \r
-    SKP_int32       CAf[ SigProc_MAX_ORDER_LPC + 1 ];\r
-    SKP_int32       CAb[ SigProc_MAX_ORDER_LPC + 1 ];\r
+    SKP_int32       CAf[ SKP_Silk_MAX_ORDER_LPC + 1 ];\r
+    SKP_int32       CAb[ SKP_Silk_MAX_ORDER_LPC + 1 ];\r
 \r
     SKP_assert( subfr_length * nb_subfr <= MAX_FRAME_SIZE );\r
     SKP_assert( nb_subfr <= MAX_NB_SUBFR );\r
@@ -90,7 +90,7 @@ void SKP_Silk_burg_modified(
         }\r
         rshifts += rshifts_extra;\r
     }\r
-    SKP_memset( C_first_row, 0, SigProc_MAX_ORDER_LPC * sizeof( SKP_int32 ) );\r
+    SKP_memset( C_first_row, 0, SKP_Silk_MAX_ORDER_LPC * sizeof( SKP_int32 ) );\r
     if( rshifts > 0 ) {\r
         for( s = 0; s < nb_subfr; s++ ) {\r
             x_ptr = x + s * subfr_length;\r
@@ -108,7 +108,7 @@ void SKP_Silk_burg_modified(
             }\r
         }\r
     }\r
-    SKP_memcpy( C_last_row, C_first_row, SigProc_MAX_ORDER_LPC * sizeof( SKP_int32 ) );\r
+    SKP_memcpy( C_last_row, C_first_row, SKP_Silk_MAX_ORDER_LPC * sizeof( SKP_int32 ) );\r
     \r
     /* Initialize */\r
     CAb[ 0 ] = CAf[ 0 ] = C0 + SKP_SMMUL( WhiteNoiseFrac_Q32, C0 ) + 1;         // Q(-rshifts)\r
index d2f5aa66f0bc1bed03b796d3b1b334df3987d653..9cdc64a0a20093b838f3c07974ef52f540aaf6a4 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
index e4a4e986d534b45c3083f080d6b24587b5606b8f..f5f5e907adc17795a2fe7b7d1cc154a4e515359c 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
index 007a6bf4b0908a0bdb9b8c8c10e02f475bf4f9e1..e335fda678df9b519b664a94223ddd8b0378c3f1 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -36,7 +36,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 /* Encodes signs of excitation */\r
 void SKP_Silk_encode_signs(\r
     SKP_Silk_range_coder_state      *sRC,               /* I/O  Range coder state                       */\r
-    const SKP_int                   q[],                /* I    Pulse signal                            */\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
@@ -45,10 +45,12 @@ void SKP_Silk_encode_signs(
 {\r
     SKP_int i;\r
     SKP_int inData;\r
-    const SKP_uint16 *cdf;\r
+    SKP_uint16 cdf[ 3 ];\r
 \r
     i = SKP_SMULBB( N_RATE_LEVELS - 1, SKP_LSHIFT( sigtype, 1 ) + QuantOffsetType ) + RateLevelIndex;\r
-    cdf = SKP_Silk_sign_CDF[ i ];\r
+    cdf[ 0 ] = 0;\r
+    cdf[ 1 ] = SKP_Silk_sign_CDF[ i ];\r
+    cdf[ 2 ] = 65535;\r
     \r
     for( i = 0; i < length; i++ ) {\r
         if( q[ i ] != 0 ) {\r
@@ -70,10 +72,12 @@ void SKP_Silk_decode_signs(
 {\r
     SKP_int i;\r
     SKP_int data;\r
-    const SKP_uint16 *cdf;\r
+    SKP_uint16 cdf[ 3 ];\r
 \r
     i = SKP_SMULBB( N_RATE_LEVELS - 1, SKP_LSHIFT( sigtype, 1 ) + QuantOffsetType ) + RateLevelIndex;\r
-    cdf = SKP_Silk_sign_CDF[ i ];\r
+    cdf[ 0 ] = 0;\r
+    cdf[ 1 ] = SKP_Silk_sign_CDF[ i ];\r
+    cdf[ 2 ] = 65535;\r
     \r
     for( i = 0; i < length; i++ ) {\r
         if( q[ i ] > 0 ) {\r
index 2e001f42815acd608e5c02ed54ce2d97d0209b17..cf5b70222fc32592cad20c509f872ec743611aa8 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -68,9 +68,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 \r
 extern const SKP_int16 SKP_Silk_CB_lags_stage2[PITCH_EST_NB_SUBFR][PITCH_EST_NB_CBKS_STAGE2_EXT];\r
 extern const SKP_int16 SKP_Silk_CB_lags_stage3[PITCH_EST_NB_SUBFR][PITCH_EST_NB_CBKS_STAGE3_MAX];\r
-extern const SKP_int16 SKP_Silk_Lag_range_stage3[ SigProc_PITCH_EST_MAX_COMPLEX + 1 ] [ PITCH_EST_NB_SUBFR ][ 2 ];\r
-extern const SKP_int16 SKP_Silk_cbk_sizes_stage3[ SigProc_PITCH_EST_MAX_COMPLEX + 1 ];\r
-extern const SKP_int16 SKP_Silk_cbk_offsets_stage3[ SigProc_PITCH_EST_MAX_COMPLEX + 1 ];\r
+extern const SKP_int16 SKP_Silk_Lag_range_stage3[ SKP_Silk_PITCH_EST_MAX_COMPLEX + 1 ] [ PITCH_EST_NB_SUBFR ][ 2 ];\r
+extern const SKP_int16 SKP_Silk_cbk_sizes_stage3[ SKP_Silk_PITCH_EST_MAX_COMPLEX + 1 ];\r
+extern const SKP_int16 SKP_Silk_cbk_offsets_stage3[ SKP_Silk_PITCH_EST_MAX_COMPLEX + 1 ];\r
 \r
 #endif\r
 \r
index e4f64429ea607d1a61f12b19f19fb0cdc25dcbae..6b4c80dbc3dd23770f3a6973f2782e67c9dfa157 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -26,393 +26,226 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***********************************************************************/\r
 \r
 #include "SKP_Silk_main_FIX.h"\r
+#include "SKP_Silk_setup_complexity.h"\r
 \r
-/* Control encoder SNR */\r
-SKP_int SKP_Silk_control_encoder_FIX( \r
-    SKP_Silk_encoder_state_FIX  *psEnc,             /* I/O  Pointer to Silk encoder state                   */\r
-    const SKP_int               API_fs_kHz,         /* I    External (API) sampling rate (kHz)              */\r
-    const SKP_int               PacketSize_ms,      /* I    Packet length (ms)                              */\r
-    SKP_int32                   TargetRate_bps,     /* I    Target max bitrate (bps) (used if SNR_dB == 0)  */\r
-    const SKP_int               PacketLoss_perc,    /* I    Packet loss rate (in percent)                   */\r
-    const SKP_int               INBandFec_enabled,  /* I    Enable (1) / disable (0) inband FEC             */\r
-    const SKP_int               DTX_enabled,        /* I    Enable / disable DTX                            */\r
-    const SKP_int               InputFramesize_ms,  /* I    Inputframe in ms                                */\r
-    const SKP_int               Complexity          /* I    Complexity (0->low; 1->medium; 2->high)         */\r
-)\r
-{\r
-    SKP_int32 LBRRRate_thres_bps;\r
-    SKP_int   k, fs_kHz, ret = 0;\r
-    SKP_int32 frac_Q6;\r
-    const SKP_int32 *rateTable;\r
+SKP_INLINE SKP_int SKP_Silk_setup_resamplers_FIX(\r
+    SKP_Silk_encoder_state_FIX      *psEnc,             /* I/O  Pointer to Silk encoder state FIX       */\r
+    SKP_int                         fs_kHz              /* I    Internal sampling rate (kHz)            */\r
+);\r
 \r
-    /* State machine for the SWB/WB switching */\r
-    fs_kHz = psEnc->sCmn.fs_kHz;\r
-    \r
-    /* Only switch during low speech activity, when no frames are sitting in the payload buffer */\r
-    if( API_fs_kHz == 8 || fs_kHz == 0 || API_fs_kHz < fs_kHz ) {\r
-        // Switching is not possible, encoder just initialized, or internal mode higher than external\r
-        fs_kHz = API_fs_kHz;\r
-    } else {\r
-\r
-        /* Resample all valid data in x_buf. Resampling the last part gets rid of a click, 5ms after switching  */\r
-        /* this is because the same state is used when downsampling in API.c and is then up to date             */\r
-        /* the click immidiatly after switching is most of the time still there                                 */\r
+SKP_INLINE SKP_int SKP_Silk_setup_packetsize_FIX(\r
+    SKP_Silk_encoder_state_FIX      *psEnc,             /* I/O  Pointer to Silk encoder state FIX       */\r
+    SKP_int                         PacketSize_ms       /* I    Packet length (ms)                      */\r
+);\r
 \r
-        if( psEnc->sCmn.fs_kHz == 24 ) {\r
-            /* Accumulate the difference between the target rate and limit */\r
-            if( psEnc->sCmn.fs_kHz_changed == 0 ) {\r
-                psEnc->sCmn.bitrateDiff += SKP_MUL( InputFramesize_ms, TargetRate_bps - SWB2WB_BITRATE_BPS_INITIAL );\r
-            } else {\r
-                psEnc->sCmn.bitrateDiff += SKP_MUL( InputFramesize_ms, TargetRate_bps - SWB2WB_BITRATE_BPS );\r
-            }\r
-            psEnc->sCmn.bitrateDiff = SKP_min( psEnc->sCmn.bitrateDiff, 0 );\r
+SKP_INLINE SKP_int SKP_Silk_setup_fs_FIX(\r
+    SKP_Silk_encoder_state_FIX      *psEnc,             /* I/O  Pointer to Silk encoder state FIX       */\r
+    SKP_int                         fs_kHz              /* I    Internal sampling rate (kHz)            */\r
+);\r
 \r
-            /* Check if we should switch from 24 to 16 kHz */\r
-#if SWITCH_TRANSITION_FILTERING\r
-            if( ( psEnc->sCmn.sLP.transition_frame_no == 0 ) && /* Transition phase not active */\r
-                ( psEnc->sCmn.bitrateDiff <= -ACCUM_BITS_DIFF_THRESHOLD || psEnc->sCmn.sSWBdetect.WB_detected == 1 ) &&\r
-                ( psEnc->speech_activity_Q8 < 128 && psEnc->sCmn.nFramesInPayloadBuf == 0 ) ) {\r
-                psEnc->sCmn.sLP.transition_frame_no = 1; /* Begin transition phase */\r
-                psEnc->sCmn.sLP.mode = 0; /* Switch down */\r
-            }\r
+SKP_INLINE SKP_int SKP_Silk_setup_rate_FIX(\r
+    SKP_Silk_encoder_state_FIX      *psEnc,             /* I/O  Pointer to Silk encoder state FIX       */\r
+    SKP_int                         TargetRate_bps      /* I    Target max bitrate (if SNR_dB == 0)     */\r
+);\r
 \r
-            if( ( psEnc->sCmn.sLP.transition_frame_no >= TRANSITION_FRAMES_DOWN ) && ( psEnc->sCmn.sLP.mode == 0 ) && /* Transition phase complete, ready to switch */\r
-#else\r
-            if( ( psEnc->sCmn.bitrateDiff <= -ACCUM_BITS_DIFF_THRESHOLD || psEnc->sCmn.sSWBdetect.WB_detected == 1 ) &&\r
-#endif\r
-                ( psEnc->speech_activity_Q8 < 128 && psEnc->sCmn.nFramesInPayloadBuf == 0 ) ) {\r
-\r
-                    SKP_int16 x_buf[    2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ]; \r
-                    SKP_int16 x_bufout[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ];\r
-                    \r
-                    psEnc->sCmn.bitrateDiff = 0;\r
-                    fs_kHz = 16;\r
-\r
-                    SKP_memcpy( x_buf, psEnc->x_buf, ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) * sizeof( SKP_int16 ) );\r
-\r
-                    SKP_memset( psEnc->sCmn.resample24To16state, 0, sizeof( psEnc->sCmn.resample24To16state ) );\r
-                    \r
-#if LOW_COMPLEXITY_ONLY\r
-                    {\r
-                        SKP_int16 scratch[ ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) + SigProc_Resample_2_3_coarse_NUM_FIR_COEFS - 1 ];\r
-                        SKP_Silk_resample_2_3_coarse( &x_bufout[ 0 ], psEnc->sCmn.resample24To16state, &x_buf[ 0 ], SKP_LSHIFT( psEnc->sCmn.frame_length, 1 ) + psEnc->sCmn.la_shape, (SKP_int16*)scratch );\r
-                    }\r
-#else\r
-                    SKP_Silk_resample_2_3( &x_bufout[ 0 ], psEnc->sCmn.resample24To16state, &x_buf[ 0 ], SKP_LSHIFT( psEnc->sCmn.frame_length, 1 ) + psEnc->sCmn.la_shape );\r
-#endif\r
+SKP_INLINE SKP_int SKP_Silk_setup_LBRR_FIX(\r
+    SKP_Silk_encoder_state_FIX      *psEnc              /* I/O  Pointer to Silk encoder state FIX       */\r
+);\r
 \r
-                    /* set the first frame to zero, no performance difference was noticed though */\r
-                    SKP_memset( x_bufout, 0, 320 * sizeof( SKP_int16 ) );\r
-                    SKP_memcpy( psEnc->x_buf, x_bufout, ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) * sizeof( SKP_int16 ) );\r
+/* Control encoder */\r
+SKP_int SKP_Silk_control_encoder_FIX( \r
+    SKP_Silk_encoder_state_FIX  *psEnc,                 /* I/O  Pointer to Silk encoder state           */\r
+    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               DTX_enabled,            /* I    Enable / disable DTX                    */\r
+    const SKP_int               Complexity              /* I    Complexity (0->low; 1->medium; 2->high) */\r
+)\r
+{\r
+    SKP_int   fs_kHz, ret = 0;\r
 \r
-#if SWITCH_TRANSITION_FILTERING\r
-                    psEnc->sCmn.sLP.transition_frame_no = 0; /* Transition phase complete */\r
-#endif\r
-            }\r
-        } else if( psEnc->sCmn.fs_kHz == 16 ) {\r
+    if( psEnc->sCmn.controlled_since_last_payload != 0 ) {\r
+        if( psEnc->sCmn.API_fs_Hz != psEnc->sCmn.prev_API_fs_Hz && psEnc->sCmn.fs_kHz > 0 ) {\r
+            /* Change in API sampling rate in the middle of encoding a packet */\r
+            ret += SKP_Silk_setup_resamplers_FIX( psEnc, psEnc->sCmn.fs_kHz );\r
+        }\r
+        return ret;\r
+    }\r
 \r
-            /* Check if we should switch from 16 to 24 kHz */\r
-#if SWITCH_TRANSITION_FILTERING\r
-            if( ( psEnc->sCmn.sLP.transition_frame_no == 0 ) && /* No transition phase running, ready to switch */\r
-#else\r
-            if(\r
-#endif\r
-                ( API_fs_kHz > psEnc->sCmn.fs_kHz && TargetRate_bps >= WB2SWB_BITRATE_BPS && psEnc->sCmn.sSWBdetect.WB_detected == 0 ) && \r
-                ( psEnc->speech_activity_Q8 < 128 && psEnc->sCmn.nFramesInPayloadBuf == 0 ) ) {\r
+    /* Beyond this point we know that there are no previously coded frames in the payload buffer */\r
+\r
+    /********************************************/\r
+    /* Determine internal sampling rate         */\r
+    /********************************************/\r
+    fs_kHz = SKP_Silk_control_audio_bandwidth( &psEnc->sCmn, TargetRate_bps );\r
+\r
+    /********************************************/\r
+    /* Prepare resampler and buffered data      */\r
+    /********************************************/\r
+    ret += SKP_Silk_setup_resamplers_FIX( psEnc, fs_kHz );\r
+\r
+    /********************************************/\r
+    /* Set packet size                          */\r
+    /********************************************/\r
+    ret += SKP_Silk_setup_packetsize_FIX( psEnc, PacketSize_ms );\r
+\r
+    /********************************************/\r
+    /* Set internal sampling frequency          */\r
+    /********************************************/\r
+    ret += SKP_Silk_setup_fs_FIX( psEnc, fs_kHz );\r
+\r
+    /********************************************/\r
+    /* Set encoding complexity                  */\r
+    /********************************************/\r
+    ret += SKP_Silk_setup_complexity( &psEnc->sCmn, Complexity );\r
+\r
+    /********************************************/\r
+    /* Set bitrate/coding quality               */\r
+    /********************************************/\r
+    ret += SKP_Silk_setup_rate_FIX( psEnc, TargetRate_bps );\r
+\r
+    /********************************************/\r
+    /* Set packet loss rate measured by farend  */\r
+    /********************************************/\r
+    if( ( PacketLoss_perc < 0 ) || ( PacketLoss_perc > 100 ) ) {\r
+        ret = SKP_SILK_ENC_INVALID_LOSS_RATE;\r
+    }\r
+    psEnc->sCmn.PacketLoss_perc = PacketLoss_perc;\r
 \r
-                SKP_int16 x_buf[          2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ]; \r
-                SKP_int16 x_bufout[ 3 * ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) / 2 ]; \r
-                SKP_int32 resample16To24state[ 11 ];\r
+    /********************************************/\r
+    /* Set LBRR usage                           */\r
+    /********************************************/\r
+    ret += SKP_Silk_setup_LBRR_FIX( psEnc );\r
 \r
-                psEnc->sCmn.bitrateDiff = 0;\r
-                fs_kHz = 24;\r
-                \r
-                SKP_memcpy( x_buf, psEnc->x_buf, ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) * sizeof( SKP_int16 ) );\r
+    /********************************************/\r
+    /* Set DTX mode                             */\r
+    /********************************************/\r
+    if( DTX_enabled < 0 || DTX_enabled > 1 ) {\r
+        ret = SKP_SILK_ENC_INVALID_DTX_SETTING;\r
+    }\r
+    psEnc->sCmn.useDTX = DTX_enabled;\r
+    psEnc->sCmn.controlled_since_last_payload = 1;\r
 \r
-                SKP_memset( resample16To24state, 0, sizeof(resample16To24state) );\r
-                \r
-                SKP_Silk_resample_3_2( &x_bufout[ 0 ], resample16To24state, &x_buf[ 0 ], SKP_LSHIFT( psEnc->sCmn.frame_length, 1 ) + psEnc->sCmn.la_shape );\r
+    return ret;\r
+}\r
 \r
-                /* set the first frame to zero, no performance difference was noticed though */\r
-                SKP_memset( x_bufout, 0, 480 * sizeof( SKP_int16 ) );\r
-                SKP_memcpy( psEnc->x_buf, x_bufout, ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) * sizeof( SKP_int16 ) );\r
-#if SWITCH_TRANSITION_FILTERING\r
-                psEnc->sCmn.sLP.mode = 1; /* Switch up */\r
-#endif\r
-            } else { \r
-                /* accumulate the difference between the target rate and limit */\r
-                psEnc->sCmn.bitrateDiff += SKP_MUL( InputFramesize_ms, TargetRate_bps - WB2MB_BITRATE_BPS );\r
-                psEnc->sCmn.bitrateDiff = SKP_min( psEnc->sCmn.bitrateDiff, 0 );\r
+/* Control low bitrate redundancy usage */\r
+void SKP_Silk_LBRR_ctrl_FIX(\r
+    SKP_Silk_encoder_state_FIX      *psEnc,     /* I    Encoder state FIX                           */\r
+    SKP_Silk_encoder_control        *psEncCtrlC /* I/O  Encoder control                             */\r
+)\r
+{\r
+    SKP_int LBRR_usage;\r
 \r
-                /* Check if we should switch from 16 to 12 kHz */\r
-#if SWITCH_TRANSITION_FILTERING\r
-                if( ( psEnc->sCmn.sLP.transition_frame_no == 0 ) && /* Transition phase not active */\r
-                    ( psEnc->sCmn.bitrateDiff <= -ACCUM_BITS_DIFF_THRESHOLD ) &&\r
-                    ( psEnc->speech_activity_Q8 < 128 && psEnc->sCmn.nFramesInPayloadBuf == 0 ) ) {\r
-                    psEnc->sCmn.sLP.transition_frame_no = 1; /* Begin transition phase */\r
-                    psEnc->sCmn.sLP.mode = 0; /* Switch down */\r
-                }\r
-\r
-                if( ( psEnc->sCmn.sLP.transition_frame_no >= TRANSITION_FRAMES_DOWN ) && ( psEnc->sCmn.sLP.mode == 0 ) && /* Transition phase complete, ready to switch */\r
-#else\r
-                if( ( psEnc->sCmn.bitrateDiff <= -ACCUM_BITS_DIFF_THRESHOLD ) &&\r
-#endif\r
-                    ( psEnc->speech_activity_Q8 < 128 && psEnc->sCmn.nFramesInPayloadBuf == 0 ) ) {\r
+    if( psEnc->sCmn.LBRR_enabled ) {\r
+        /* Control LBRR */\r
 \r
-                    SKP_int16 x_buf[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ]; \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 ) { // nb! maybe multiply loss prob and speech activity \r
+            LBRR_usage = SKP_SILK_ADD_LBRR_TO_PLUS1;\r
+        }\r
+        psEncCtrlC->LBRR_usage = LBRR_usage;\r
+    } else {\r
+        psEncCtrlC->LBRR_usage = SKP_SILK_NO_LBRR;\r
+    }\r
+}\r
 \r
-                    SKP_memcpy( x_buf, psEnc->x_buf, ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) * sizeof( SKP_int16 ) );\r
+SKP_INLINE SKP_int SKP_Silk_setup_resamplers_FIX(\r
+    SKP_Silk_encoder_state_FIX      *psEnc,             /* I/O  Pointer to Silk encoder state FIX       */\r
+    SKP_int                         fs_kHz              /* I    Internal sampling rate (kHz)            */\r
+)\r
+{\r
+    SKP_int ret = SKP_SILK_NO_ERROR;\r
     \r
-                    psEnc->sCmn.bitrateDiff = 0;\r
-                    fs_kHz = 12;\r
-                    \r
-                    if( API_fs_kHz == 24 ) {\r
-\r
-                        /* Intermediate upsampling of x_bufFIX from 16 to 24 kHz */\r
-                        SKP_int16 x_buf24[ 3 * ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) / 2 ]; \r
-                        SKP_int32 scratch[    3 * ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) ];\r
-                        SKP_int32 resample16To24state[ 11 ];\r
-\r
-                        SKP_memset( resample16To24state, 0, sizeof( resample16To24state ) );\r
-                        SKP_Silk_resample_3_2( &x_buf24[ 0 ], resample16To24state, &x_buf[ 0 ], SKP_LSHIFT( psEnc->sCmn.frame_length, 1 ) + psEnc->sCmn.la_shape );\r
-\r
-                        /* Update the state of the resampler used in API.c, from 24 to 12 kHz */\r
-                        SKP_memset( psEnc->sCmn.resample24To12state, 0, sizeof( psEnc->sCmn.resample24To12state ) );\r
-                        SKP_Silk_resample_1_2_coarse( &x_buf24[ 0 ], psEnc->sCmn.resample24To12state, &x_buf[ 0 ], scratch, SKP_RSHIFT( SKP_SMULBB( 3, SKP_LSHIFT( psEnc->sCmn.frame_length, 1 ) + psEnc->sCmn.la_shape ), 2 ) );\r
-\r
-                        /* set the first frame to zero, no performance difference was noticed though */\r
-                        SKP_memset( x_buf, 0, 240 * sizeof( SKP_int16 ) );\r
-                        SKP_memcpy( psEnc->x_buf, x_buf, ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) * sizeof( SKP_int16 ) );\r
-\r
-                    } else if( API_fs_kHz == 16 ) {\r
-                        SKP_int16 x_bufout[ 3 * ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) / 4 ]; \r
-                        SKP_memset( psEnc->sCmn.resample16To12state, 0, sizeof( psEnc->sCmn.resample16To12state ) );\r
-                        \r
-                        SKP_Silk_resample_3_4( &x_bufout[ 0 ], psEnc->sCmn.resample16To12state, &x_buf[ 0 ], SKP_LSHIFT( psEnc->sCmn.frame_length, 1 ) + psEnc->sCmn.la_shape );\r
-                    \r
-                        /* set the first frame to zero, no performance difference was noticed though */\r
-                        SKP_memset( x_bufout, 0, 240 * sizeof( SKP_int16 ) );\r
-                        SKP_memcpy( psEnc->x_buf, x_bufout, ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) * sizeof( SKP_int16 ) );\r
-                    }\r
-#if SWITCH_TRANSITION_FILTERING\r
-                    psEnc->sCmn.sLP.transition_frame_no = 0; /* Transition phase complete */\r
-#endif\r
-                }\r
-            }\r
-        } else if( psEnc->sCmn.fs_kHz == 12 ) {\r
-        \r
-            /* Check if we should switch from 12 to 16 kHz */\r
-#if SWITCH_TRANSITION_FILTERING\r
-            if( ( psEnc->sCmn.sLP.transition_frame_no == 0 ) && /* No transition phase running, ready to switch */\r
-#else\r
-            if(\r
-#endif\r
-                ( API_fs_kHz > psEnc->sCmn.fs_kHz && TargetRate_bps >= MB2WB_BITRATE_BPS ) &&\r
-                ( psEnc->speech_activity_Q8 < 128 && psEnc->sCmn.nFramesInPayloadBuf == 0 ) ) {\r
+    if( psEnc->sCmn.fs_kHz != fs_kHz || psEnc->sCmn.prev_API_fs_Hz != psEnc->sCmn.API_fs_Hz ) {\r
 \r
-                SKP_int16 x_buf[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ]; \r
+        if( psEnc->sCmn.fs_kHz == 0 ) {\r
+            /* Initialize the resampler for enc_API.c preparing resampling from API_fs_Hz to fs_kHz */\r
+            ret += SKP_Silk_resampler_init( &psEnc->sCmn.resampler_state, psEnc->sCmn.API_fs_Hz, fs_kHz * 1000 );\r
+        } else {\r
+            /* Allocate space for worst case temporary upsampling, 8 to 48 kHz, so a factor 6 */\r
+            SKP_int16 x_buf_API_fs_Hz[ ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) * ( MAX_API_FS_KHZ / 8 ) ];\r
 \r
-                SKP_memcpy( x_buf, psEnc->x_buf, ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) * sizeof( SKP_int16 ) );\r
+            SKP_int32 nSamples_temp = SKP_LSHIFT( psEnc->sCmn.frame_length, 1 ) + LA_SHAPE_MS * psEnc->sCmn.fs_kHz;\r
 \r
-                psEnc->sCmn.bitrateDiff = 0;\r
-                fs_kHz = 16;\r
+            if( SKP_SMULBB( fs_kHz, 1000 ) < psEnc->sCmn.API_fs_Hz && psEnc->sCmn.fs_kHz != 0 ) {\r
+                /* Resample buffered data in x_buf to API_fs_Hz */\r
 \r
-                /* Reset state of the resampler to be used */\r
-                if( API_fs_kHz == 24 ) {\r
-            \r
-                    SKP_int16 x_bufout[ 2 * 2 * ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) / 3 ]; \r
+                SKP_Silk_resampler_state_struct  temp_resampler_state;\r
 \r
-                    /* Intermediate upsampling of x_bufFIX from 12 to 24 kHz */\r
-                    SKP_int16 x_buf24[ 2 * ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) ]; \r
-                    SKP_int32 scratch[    3 * ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) ];\r
-                    SKP_int32 resample12To24state[6];\r
+                /* Initialize resampler for temporary resampling of x_buf data to API_fs_Hz */\r
+                ret += SKP_Silk_resampler_init( &temp_resampler_state, SKP_SMULBB( psEnc->sCmn.fs_kHz, 1000 ), psEnc->sCmn.API_fs_Hz );\r
 \r
-                    SKP_memset( resample12To24state, 0, sizeof( resample12To24state ) );\r
-                    SKP_Silk_resample_2_1_coarse( &x_buf[ 0 ], resample12To24state, &x_buf24[ 0 ], scratch, SKP_LSHIFT( psEnc->sCmn.frame_length, 1 ) + psEnc->sCmn.la_shape );\r
+                /* Temporary resampling of x_buf data to API_fs_Hz */\r
+                ret += SKP_Silk_resampler( &temp_resampler_state, x_buf_API_fs_Hz, psEnc->x_buf, nSamples_temp );\r
 \r
-                    SKP_memset( psEnc->sCmn.resample24To16state, 0, sizeof( psEnc->sCmn.resample24To16state ) );\r
-                \r
-#if LOW_COMPLEXITY_ONLY\r
-                    SKP_assert( sizeof( SKP_int16 ) * ( 2 * ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) + SigProc_Resample_2_3_coarse_NUM_FIR_COEFS - 1 ) <= sizeof( scratch ) );\r
-                    SKP_Silk_resample_2_3_coarse( &x_bufout[ 0 ], psEnc->sCmn.resample24To16state, &x_buf24[ 0 ], SKP_LSHIFT( SKP_LSHIFT( psEnc->sCmn.frame_length, 1 ) + psEnc->sCmn.la_shape, 1 ), (SKP_int16*)scratch );\r
-#else\r
-                    SKP_Silk_resample_2_3( &x_bufout[ 0 ], psEnc->sCmn.resample24To16state, &x_buf24[ 0 ], SKP_LSHIFT( SKP_LSHIFT( psEnc->sCmn.frame_length, 1 ) + psEnc->sCmn.la_shape, 1 ) );\r
-#endif\r
-                \r
-                    /* set the first frame to zero, no performance difference was noticed though */\r
-                    SKP_memset( x_bufout, 0, 320 * sizeof( SKP_int16 ) );\r
-                    SKP_memcpy( psEnc->x_buf, x_bufout, ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) * sizeof( SKP_int16 ) );\r
-                }\r
-#if SWITCH_TRANSITION_FILTERING\r
-                psEnc->sCmn.sLP.mode = 1; /* Switch up */\r
-#endif\r
-            } else { \r
-                /* accumulate the difference between the target rate and limit */\r
-                psEnc->sCmn.bitrateDiff += SKP_MUL( InputFramesize_ms, TargetRate_bps - MB2NB_BITRATE_BPS );\r
-                psEnc->sCmn.bitrateDiff  = SKP_min( psEnc->sCmn.bitrateDiff, 0 );\r
+                /* Calculate number of samples that has been temporarily upsampled */\r
+                nSamples_temp = SKP_DIV32_16( nSamples_temp * psEnc->sCmn.API_fs_Hz, SKP_SMULBB( psEnc->sCmn.fs_kHz, 1000 ) );\r
 \r
-                /* Check if we should switch from 12 to 8 kHz */\r
-#if SWITCH_TRANSITION_FILTERING\r
-                if( ( psEnc->sCmn.sLP.transition_frame_no == 0 ) && /* Transition phase not active */\r
-                    ( psEnc->sCmn.bitrateDiff <= -ACCUM_BITS_DIFF_THRESHOLD ) &&\r
-                    ( psEnc->speech_activity_Q8 < 128 && psEnc->sCmn.nFramesInPayloadBuf == 0 ) ) {\r
-                    psEnc->sCmn.sLP.transition_frame_no = 1; /* Begin transition phase */\r
-                    psEnc->sCmn.sLP.mode = 0; /* Switch down */\r
-                }\r
-\r
-                if( ( psEnc->sCmn.sLP.transition_frame_no >= TRANSITION_FRAMES_DOWN ) && ( psEnc->sCmn.sLP.mode == 0 ) &&\r
-#else\r
-                if( ( psEnc->sCmn.bitrateDiff <= -ACCUM_BITS_DIFF_THRESHOLD ) &&\r
-#endif\r
-                    ( psEnc->speech_activity_Q8 < 128 && psEnc->sCmn.nFramesInPayloadBuf == 0 ) ) {\r
-                \r
-                    SKP_int16 x_buf[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ]; \r
-\r
-                    SKP_memcpy( x_buf, psEnc->x_buf, ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) * sizeof( SKP_int16 ) );\r
-\r
-                    psEnc->sCmn.bitrateDiff = 0;\r
-                    fs_kHz = 8;\r
-\r
-                    if( API_fs_kHz == 24 ) {\r
-\r
-                        SKP_int32 scratch[    3 * ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) ];\r
-                        /* Intermediate upsampling of x_buf from 12 to 24 kHz */\r
-                        SKP_int16 x_buf24[ 2 * ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) ];\r
-                        SKP_int32 resample12To24state[ 6 ];\r
-\r
-                        SKP_memset( resample12To24state, 0, sizeof( resample12To24state ) );\r
-                        SKP_Silk_resample_2_1_coarse( &x_buf[ 0 ], resample12To24state, &x_buf24[ 0 ], scratch, SKP_LSHIFT( psEnc->sCmn.frame_length, 1 ) + psEnc->sCmn.la_shape );\r
-\r
-                        /* Update the state of the resampler used in API.c, from 24 to 8 kHz */\r
-                        SKP_memset( psEnc->sCmn.resample24To8state, 0, sizeof( psEnc->sCmn.resample24To8state ) );\r
-                        SKP_Silk_resample_1_3( &x_buf[ 0 ], psEnc->sCmn.resample24To8state, &x_buf24[ 0 ], SKP_LSHIFT( SKP_LSHIFT( psEnc->sCmn.frame_length, 1 ) + psEnc->sCmn.la_shape, 1 ) );\r
-\r
-                        /* set the first frame to zero, no performance difference was noticed though */\r
-                        SKP_memset( x_buf, 0, 160 * sizeof( SKP_int16 ) );\r
-                        SKP_memcpy( psEnc->x_buf, x_buf, ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) * sizeof( SKP_int16 ) );\r
-\r
-                    } else if( API_fs_kHz == 16 ) {\r
-                        /* Intermediate upsampling of x_bufFIX from 12 to 16 kHz */\r
-                        SKP_int16 x_buf16[  3 * ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) / 2 ]; \r
-                        SKP_int32 resample12To16state[11];\r
-                        \r
-                        SKP_memset( resample12To16state, 0, sizeof( resample12To16state ) );\r
-                        SKP_Silk_resample_3_2( &x_buf16[ 0 ], resample12To16state, &x_buf[ 0 ], SKP_LSHIFT( psEnc->sCmn.frame_length, 1 ) + psEnc->sCmn.la_shape );\r
-                        \r
-                        /* set the first frame to zero, no performance difference was noticed though */\r
-                        SKP_memset( x_buf, 0, 160 * sizeof( SKP_int16 ) );\r
-                        SKP_memcpy( psEnc->x_buf, x_buf, ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) * sizeof( SKP_int16 ) );\r
-\r
-                    } else if( API_fs_kHz == 12 ) {\r
-                        SKP_int16 x_bufout[ 2 * ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) / 3 ]; \r
-                        SKP_memset( psEnc->sCmn.resample12To8state, 0, sizeof( psEnc->sCmn.resample12To8state ) );\r
-#if LOW_COMPLEXITY_ONLY\r
-                        {\r
-                            SKP_int16 scratch[ ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) + SigProc_Resample_2_3_coarse_NUM_FIR_COEFS - 1 ];\r
-                            SKP_Silk_resample_2_3_coarse( &x_bufout[ 0 ], psEnc->sCmn.resample12To8state, &x_buf[ 0 ], \r
-                                SKP_LSHIFT( psEnc->sCmn.frame_length, 1 ) + psEnc->sCmn.la_shape, scratch );\r
-                        }\r
-#else\r
-                        SKP_Silk_resample_2_3( &x_bufout[ 0 ], psEnc->sCmn.resample12To8state, &x_buf[ 0 ], SKP_LSHIFT( psEnc->sCmn.frame_length, 1 ) + psEnc->sCmn.la_shape );\r
-#endif\r
-                        /* set the first frame to zero, no performance difference was noticed though */\r
-                        SKP_memset( x_bufout, 0, 160 * sizeof( SKP_int16 ) );\r
-                        SKP_memcpy( psEnc->x_buf, x_bufout, ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) * sizeof( SKP_int16 ) );\r
-                    }\r
-#if SWITCH_TRANSITION_FILTERING\r
-                    psEnc->sCmn.sLP.transition_frame_no = 0; /* Transition phase complete */\r
-#endif\r
-                }\r
+                /* Initialize the resampler for enc_API.c preparing resampling from API_fs_Hz to fs_kHz */\r
+                ret += SKP_Silk_resampler_init( &psEnc->sCmn.resampler_state, psEnc->sCmn.API_fs_Hz, SKP_SMULBB( fs_kHz, 1000 ) );\r
+\r
+            } else {\r
+                /* Copy data */\r
+                SKP_memcpy( x_buf_API_fs_Hz, psEnc->x_buf, nSamples_temp * sizeof( SKP_int16 ) );\r
             }\r
-        } else if( psEnc->sCmn.fs_kHz == 8 ) {\r
 \r
-            /* Check if we should switch from 8 to 12 kHz */\r
-#if SWITCH_TRANSITION_FILTERING\r
-            if( ( psEnc->sCmn.sLP.transition_frame_no == 0 ) && /* No transition phase running, ready to switch */\r
-#else\r
-            if(\r
-#endif\r
-                ( API_fs_kHz > psEnc->sCmn.fs_kHz && TargetRate_bps >= NB2MB_BITRATE_BPS ) &&\r
-                ( psEnc->speech_activity_Q8 < 128 && psEnc->sCmn.nFramesInPayloadBuf == 0 ) ) {\r
-\r
-                SKP_int16 x_buf[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ]; \r
-\r
-                SKP_memcpy( x_buf, psEnc->x_buf, ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) * sizeof( SKP_int16 ) );\r
-\r
-                psEnc->sCmn.bitrateDiff = 0;\r
-                fs_kHz = 12;\r
-\r
-                /* Reset state of the resampler to be used */\r
-                if( API_fs_kHz == 24 ) {\r
-                    SKP_int16 x_buf24[  3 * ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) ]; \r
-                    SKP_int32 scratch[ 3 * 3 * ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) / 2 ];\r
-                    SKP_int32 resample8To24state[ 7 ];\r
-\r
-                    /* Intermediate upsampling of x_bufFIX from 8 to 24 kHz */\r
-                    SKP_memset( resample8To24state, 0, sizeof( resample8To24state ) );\r
-                    SKP_Silk_resample_3_1( &x_buf24[ 0 ], resample8To24state, &x_buf[ 0 ], SKP_LSHIFT( psEnc->sCmn.frame_length, 1 ) + psEnc->sCmn.la_shape );\r
-\r
-                    SKP_memset( psEnc->sCmn.resample24To12state, 0, sizeof( psEnc->sCmn.resample24To12state ) );\r
-                \r
-                    SKP_Silk_resample_1_2_coarse( &x_buf24[ 0 ], psEnc->sCmn.resample24To12state, &x_buf[ 0 ], scratch, SKP_RSHIFT( SKP_SMULBB( 3, SKP_LSHIFT( psEnc->sCmn.frame_length, 1 ) + psEnc->sCmn.la_shape ), 1 ) );\r
-                \r
-                    /* set the first frame to zero, no performance difference was noticed though */\r
-                    SKP_memset( x_buf, 0, 240 * sizeof( SKP_int16 ) );\r
-                    SKP_memcpy( psEnc->x_buf, x_buf, ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) * sizeof( SKP_int16 ) );\r
-                \r
-                } else if( API_fs_kHz == 16 ) {\r
-                    SKP_int16 x_buf16[ 2 * ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) ]; \r
-                    SKP_int32 scratch[ 3 * ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) ];\r
-                    SKP_int32 resample8To16state[ 6 ];\r
-\r
-                    /* Intermediate upsampling of x_bufFIX from 8 to 16 kHz */\r
-                    SKP_memset( resample8To16state, 0, sizeof( resample8To16state ) );\r
-                    SKP_Silk_resample_2_1_coarse( &x_buf[ 0 ], resample8To16state, &x_buf16[ 0 ], scratch, SKP_LSHIFT( psEnc->sCmn.frame_length, 1 ) + psEnc->sCmn.la_shape );\r
-\r
-                    SKP_memset( psEnc->sCmn.resample16To12state, 0, sizeof( psEnc->sCmn.resample16To12state ) );\r
-                \r
-                    SKP_Silk_resample_3_4( &x_buf[ 0 ], psEnc->sCmn.resample16To12state, &x_buf16[ 0 ], SKP_LSHIFT( SKP_LSHIFT( psEnc->sCmn.frame_length, 1 ) + psEnc->sCmn.la_shape, 1 ) );\r
-                \r
-                    /* set the first frame to zero, no performance difference was noticed though */\r
-                    SKP_memset( x_buf, 0, 240 * sizeof( SKP_int16 ) );\r
-                    SKP_memcpy( psEnc->x_buf, x_buf, ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) * sizeof( SKP_int16 ) );\r
-                }\r
-#if SWITCH_TRANSITION_FILTERING\r
-                psEnc->sCmn.sLP.mode = 1; /* Switch up */\r
-#endif\r
-            } \r
-        } else {\r
-            // Internal sample frequency not supported!\r
-            SKP_assert( 0 );\r
+            if( 1000 * fs_kHz != psEnc->sCmn.API_fs_Hz ) {\r
+                /* Correct resampler state (unless resampling by a factor 1) by resampling buffered data from API_fs_Hz to fs_kHz */\r
+                ret += SKP_Silk_resampler( &psEnc->sCmn.resampler_state, psEnc->x_buf, x_buf_API_fs_Hz, nSamples_temp );\r
+            }\r
         }\r
     }\r
 \r
-#if SWITCH_TRANSITION_FILTERING\r
-    /* After switching up, stop transition filter during speech inactivity */\r
-    if( ( psEnc->sCmn.sLP.mode == 1 ) &&\r
-        ( psEnc->sCmn.sLP.transition_frame_no >= TRANSITION_FRAMES_UP ) && \r
-        ( psEnc->speech_activity_Q8 < 128 ) && \r
-        ( psEnc->sCmn.nFramesInPayloadBuf == 0 ) ) {\r
-        \r
-        psEnc->sCmn.sLP.transition_frame_no = 0;\r
-\r
-        /* Reset transition filter state */\r
-        SKP_memset( psEnc->sCmn.sLP.In_LP_State, 0, 2 * sizeof( SKP_int32 ) );\r
-    }\r
-#endif\r
+    psEnc->sCmn.prev_API_fs_Hz = psEnc->sCmn.API_fs_Hz;\r
 \r
+    return(ret);\r
+}\r
 \r
+SKP_INLINE SKP_int SKP_Silk_setup_packetsize_FIX(\r
+    SKP_Silk_encoder_state_FIX      *psEnc,             /* I/O  Pointer to Silk encoder state FIX       */\r
+    SKP_int                         PacketSize_ms       /* I    Packet length (ms)                      */\r
+)\r
+{\r
+    SKP_int ret = SKP_SILK_NO_ERROR;\r
+\r
+    /* Set packet size */\r
+    if( ( PacketSize_ms !=  20 ) && \r
+        ( PacketSize_ms !=  40 ) && \r
+        ( PacketSize_ms !=  60 ) && \r
+        ( PacketSize_ms !=  80 ) && \r
+        ( PacketSize_ms != 100 ) ) {\r
+        ret = SKP_SILK_ENC_PACKET_SIZE_NOT_SUPPORTED;\r
+    } else {\r
+        if( PacketSize_ms != psEnc->sCmn.PacketSize_ms ) {\r
+            psEnc->sCmn.PacketSize_ms = PacketSize_ms;\r
+\r
+            /* Packet length changes. Reset LBRR buffer */\r
+            SKP_Silk_LBRR_reset( &psEnc->sCmn );\r
+        }\r
+    }\r
+    return(ret);\r
+}\r
+\r
+SKP_INLINE SKP_int SKP_Silk_setup_fs_FIX(\r
+    SKP_Silk_encoder_state_FIX      *psEnc,             /* I/O  Pointer to Silk encoder state FIX       */\r
+    SKP_int                         fs_kHz              /* I    Internal sampling rate (kHz)            */\r
+)\r
+{\r
+    SKP_int ret = SKP_SILK_NO_ERROR;\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->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->sCmn.LBRR_buffer, 0,           MAX_LBRR_DELAY * sizeof( SKP_SILK_LBRR_struct ) );\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
@@ -427,7 +260,7 @@ SKP_int SKP_Silk_control_encoder_FIX(
         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
+        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
@@ -436,10 +269,11 @@ SKP_int SKP_Silk_control_encoder_FIX(
         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
-        psEnc->sNSQ.lagPrev                = 100;\r
-        psEnc->sNSQ.prev_inv_gain_Q16      = 65536;\r
-        psEnc->sNSQ_LBRR.prev_inv_gain_Q16 = 65536;\r
+        psEnc->sShape.LastGainIndex         = 1;\r
+        psEnc->sNSQ.lagPrev                 = 100;\r
+        psEnc->sNSQ.prev_inv_gain_Q16       = 65536;\r
+        psEnc->sNSQ_LBRR.prev_inv_gain_Q16  = 65536;\r
+\r
         psEnc->sCmn.fs_kHz = fs_kHz;\r
         if( psEnc->sCmn.fs_kHz == 8 ) {\r
             psEnc->sCmn.predictLPCOrder = MIN_LPC_ORDER;\r
@@ -453,88 +287,48 @@ SKP_int SKP_Silk_control_encoder_FIX(
         psEnc->sCmn.frame_length   = SKP_SMULBB( FRAME_LENGTH_MS, fs_kHz );\r
         psEnc->sCmn.subfr_length   = SKP_DIV32_16( psEnc->sCmn.frame_length, NB_SUBFR );\r
         psEnc->sCmn.la_pitch       = SKP_SMULBB( LA_PITCH_MS, fs_kHz );\r
-        psEnc->sCmn.la_shape       = SKP_SMULBB( LA_SHAPE_MS, fs_kHz );\r
         psEnc->sPred.min_pitch_lag = SKP_SMULBB(  3, fs_kHz );\r
         psEnc->sPred.max_pitch_lag = SKP_SMULBB( 18, fs_kHz );\r
         psEnc->sPred.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS, fs_kHz );\r
         if( psEnc->sCmn.fs_kHz == 24 ) {\r
-            psEnc->mu_LTP_Q8 = MU_LTP_QUANT_SWB_Q8;\r
+            psEnc->mu_LTP_Q8 = SKP_FIX_CONST( MU_LTP_QUANT_SWB, 8 );\r
+            psEnc->sCmn.bitrate_threshold_up   = SKP_int32_MAX;\r
+            psEnc->sCmn.bitrate_threshold_down = SWB2WB_BITRATE_BPS; \r
         } else if( psEnc->sCmn.fs_kHz == 16 ) {\r
-            psEnc->mu_LTP_Q8 = MU_LTP_QUANT_WB_Q8;\r
+            psEnc->mu_LTP_Q8 = SKP_FIX_CONST( MU_LTP_QUANT_WB, 8 );\r
+            psEnc->sCmn.bitrate_threshold_up   = WB2SWB_BITRATE_BPS;\r
+            psEnc->sCmn.bitrate_threshold_down = WB2MB_BITRATE_BPS; \r
         } else if( psEnc->sCmn.fs_kHz == 12 ) {\r
-            psEnc->mu_LTP_Q8 = MU_LTP_QUANT_MB_Q8;\r
+            psEnc->mu_LTP_Q8 = SKP_FIX_CONST( MU_LTP_QUANT_MB, 8 );\r
+            psEnc->sCmn.bitrate_threshold_up   = MB2WB_BITRATE_BPS;\r
+            psEnc->sCmn.bitrate_threshold_down = MB2NB_BITRATE_BPS;\r
         } else {\r
-            psEnc->mu_LTP_Q8 = MU_LTP_QUANT_NB_Q8;\r
+            psEnc->mu_LTP_Q8 = SKP_FIX_CONST( MU_LTP_QUANT_NB, 8 );\r
+            psEnc->sCmn.bitrate_threshold_up   = NB2MB_BITRATE_BPS;\r
+            psEnc->sCmn.bitrate_threshold_down = 0;\r
         }\r
         psEnc->sCmn.fs_kHz_changed = 1;\r
-        \r
+\r
         /* Check that settings are valid */\r
         SKP_assert( ( psEnc->sCmn.subfr_length * NB_SUBFR ) == psEnc->sCmn.frame_length );\r
-    } \r
-   \r
-    /* Set encoding complexity */\r
-    if( Complexity == 0 || LOW_COMPLEXITY_ONLY ) {\r
-        /* Low complexity */\r
-        psEnc->sCmn.Complexity                  = 0;\r
-        psEnc->sCmn.pitchEstimationComplexity   = PITCH_EST_COMPLEXITY_LC_MODE;\r
-        psEnc->pitchEstimationThreshold_Q16     = FIND_PITCH_CORRELATION_THRESHOLD_Q16_LC_MODE;\r
-        psEnc->sCmn.pitchEstimationLPCOrder     = 8;\r
-        psEnc->sCmn.shapingLPCOrder             = 12;\r
-        psEnc->sCmn.nStatesDelayedDecision      = 1;\r
-        psEnc->NoiseShapingQuantizer            = SKP_Silk_NSQ;\r
-        psEnc->sCmn.useInterpolatedNLSFs        = 0;\r
-        psEnc->sCmn.LTPQuantLowComplexity       = 1;\r
-        psEnc->sCmn.NLSF_MSVQ_Survivors         = MAX_NLSF_MSVQ_SURVIVORS_LC_MODE;\r
-    } else if( Complexity == 1 ) {\r
-        /* Medium complexity */\r
-        psEnc->sCmn.Complexity                  = 1;\r
-        psEnc->sCmn.pitchEstimationComplexity   = PITCH_EST_COMPLEXITY_MC_MODE;\r
-        psEnc->pitchEstimationThreshold_Q16     = FIND_PITCH_CORRELATION_THRESHOLD_Q16_MC_MODE;\r
-        psEnc->sCmn.pitchEstimationLPCOrder     = 12;\r
-        psEnc->sCmn.shapingLPCOrder             = 16;\r
-        psEnc->sCmn.nStatesDelayedDecision      = 2;\r
-        psEnc->NoiseShapingQuantizer            = SKP_Silk_NSQ_del_dec;\r
-        psEnc->sCmn.useInterpolatedNLSFs        = 0;\r
-        psEnc->sCmn.LTPQuantLowComplexity       = 0;\r
-        psEnc->sCmn.NLSF_MSVQ_Survivors         = MAX_NLSF_MSVQ_SURVIVORS_MC_MODE;\r
-    } else if( Complexity == 2 ) {\r
-        /* High complexity */\r
-        psEnc->sCmn.Complexity                  = 2;\r
-        psEnc->sCmn.pitchEstimationComplexity   = PITCH_EST_COMPLEXITY_HC_MODE;\r
-        psEnc->pitchEstimationThreshold_Q16     = FIND_PITCH_CORRELATION_THRESHOLD_Q16_HC_MODE;\r
-        psEnc->sCmn.pitchEstimationLPCOrder     = 16;\r
-        psEnc->sCmn.shapingLPCOrder             = 16;\r
-        psEnc->sCmn.nStatesDelayedDecision      = 4;\r
-        psEnc->NoiseShapingQuantizer            = SKP_Silk_NSQ_del_dec;\r
-        psEnc->sCmn.useInterpolatedNLSFs        = 1;\r
-        psEnc->sCmn.LTPQuantLowComplexity       = 0;\r
-        psEnc->sCmn.NLSF_MSVQ_Survivors         = MAX_NLSF_MSVQ_SURVIVORS;\r
-    } else {\r
-        ret = SKP_SILK_ENC_WRONG_COMPLEXITY_SETTING;\r
     }\r
+    return( ret );\r
+}\r
 \r
-    /* Dont have higher Pitch estimation LPC order than predict LPC order */\r
-    psEnc->sCmn.pitchEstimationLPCOrder = SKP_min_int( psEnc->sCmn.pitchEstimationLPCOrder, psEnc->sCmn.predictLPCOrder );\r
-\r
-    SKP_assert( psEnc->sCmn.pitchEstimationLPCOrder <= FIND_PITCH_LPC_ORDER_MAX );\r
-    SKP_assert( psEnc->sCmn.shapingLPCOrder         <= SHAPE_LPC_ORDER_MAX );\r
-    SKP_assert( psEnc->sCmn.nStatesDelayedDecision  <= DEL_DEC_STATES_MAX );\r
+SKP_INLINE SKP_int SKP_Silk_setup_rate_FIX(\r
+    SKP_Silk_encoder_state_FIX      *psEnc,             /* I/O  Pointer to Silk encoder state FIX       */\r
+    SKP_int                         TargetRate_bps      /* I    Target max bitrate (if SNR_dB == 0)     */\r
+)\r
+{\r
+    SKP_int k, ret = SKP_SILK_NO_ERROR;\r
+    SKP_int32 frac_Q6;\r
+    const SKP_int32 *rateTable;\r
 \r
     /* Set bitrate/coding quality */\r
-    TargetRate_bps = SKP_min( TargetRate_bps, 100000 );\r
-    if( psEnc->sCmn.fs_kHz == 8 ) {\r
-        TargetRate_bps = SKP_max( TargetRate_bps, MIN_TARGET_RATE_NB_BPS );\r
-    } else if( psEnc->sCmn.fs_kHz == 12 ) {\r
-        TargetRate_bps = SKP_max( TargetRate_bps, MIN_TARGET_RATE_MB_BPS );\r
-    } else if( psEnc->sCmn.fs_kHz == 16 ) {\r
-        TargetRate_bps = SKP_max( TargetRate_bps, MIN_TARGET_RATE_WB_BPS );\r
-    } else {\r
-        TargetRate_bps = SKP_max( TargetRate_bps, MIN_TARGET_RATE_SWB_BPS );\r
-    }\r
     if( TargetRate_bps != psEnc->sCmn.TargetRate_bps ) {\r
         psEnc->sCmn.TargetRate_bps = TargetRate_bps;\r
 \r
-        /* if new TargetRate_bps, translate to SNR_dB value */\r
+        /* If new TargetRate_bps, translate to SNR_dB value */\r
         if( psEnc->sCmn.fs_kHz == 8 ) {\r
             rateTable = TargetRate_table_NB;\r
         } else if( psEnc->sCmn.fs_kHz == 12 ) {\r
@@ -545,112 +339,65 @@ SKP_int SKP_Silk_control_encoder_FIX(
             rateTable = TargetRate_table_SWB;\r
         }\r
         for( k = 1; k < TARGET_RATE_TAB_SZ; k++ ) {\r
-            /* find bitrate interval in table and interpolate */\r
+            /* Find bitrate interval in table and interpolate */\r
             if( TargetRate_bps < rateTable[ k ] ) {\r
-                frac_Q6 = SKP_DIV32( SKP_LSHIFT( TargetRate_bps - rateTable[ k - 1 ], 6 ), rateTable[ k ] - rateTable[ k - 1 ] );\r
+                frac_Q6 = SKP_DIV32( SKP_LSHIFT( TargetRate_bps - rateTable[ k - 1 ], 6 ), \r
+                                                 rateTable[ k ] - rateTable[ k - 1 ] );\r
                 psEnc->SNR_dB_Q7 = SKP_LSHIFT( SNR_table_Q1[ k - 1 ], 6 ) + SKP_MUL( frac_Q6, SNR_table_Q1[ k ] - SNR_table_Q1[ k - 1 ] );\r
                 break;\r
             }\r
         }\r
     }\r
+    return( ret );\r
+}\r
 \r
-    /* Set packet size */\r
-    if( ( PacketSize_ms !=  20 ) && \r
-        ( PacketSize_ms !=  40 ) && \r
-        ( PacketSize_ms !=  60 ) && \r
-        ( PacketSize_ms !=  80 ) && \r
-        ( PacketSize_ms != 100 ) ) {\r
-        ret = SKP_SILK_ENC_PACKET_SIZE_NOT_SUPPORTED;\r
-    } else {\r
-        if( PacketSize_ms != psEnc->sCmn.PacketSize_ms ) {\r
-            psEnc->sCmn.PacketSize_ms = PacketSize_ms;\r
-\r
-            /* Packet length changes. Reset LBRR buffer */\r
-            SKP_Silk_LBRR_reset( &psEnc->sCmn );\r
-        }\r
-    }\r
-\r
-    /* Set packet loss rate measured by farend */\r
-    if( ( PacketLoss_perc < 0 ) || ( PacketLoss_perc > 100 ) ) {\r
-        ret = SKP_SILK_ENC_WRONG_LOSS_RATE;\r
-    }\r
-    psEnc->sCmn.PacketLoss_perc = PacketLoss_perc;\r
-\r
+SKP_INLINE SKP_int SKP_Silk_setup_LBRR_FIX(\r
+    SKP_Silk_encoder_state_FIX      *psEnc              /* I/O  Pointer to Silk encoder state FIX       */\r
+)\r
+{\r
+    SKP_int   ret = SKP_SILK_NO_ERROR;\r
 #if USE_LBRR\r
-    if( INBandFec_enabled < 0 || INBandFec_enabled > 1 ) {\r
-        ret = SKP_SILK_ENC_WRONG_INBAND_FEC_SETTING;\r
+    SKP_int32 LBRRRate_thres_bps;\r
+\r
+    if( psEnc->sCmn.useInBandFEC < 0 || psEnc->sCmn.useInBandFEC > 1 ) {\r
+        ret = SKP_SILK_ENC_INVALID_INBAND_FEC_SETTING;\r
     }\r
     \r
-    /* Only change settings if first frame in packet */\r
-    if( psEnc->sCmn.nFramesInPayloadBuf == 0 ) {\r
-        \r
-        psEnc->sCmn.LBRR_enabled = INBandFec_enabled;\r
-        if( psEnc->sCmn.fs_kHz == 8 ) {\r
-            LBRRRate_thres_bps = INBAND_FEC_MIN_RATE_BPS - 9000;\r
-        } else if( psEnc->sCmn.fs_kHz == 12 ) {\r
-            LBRRRate_thres_bps = INBAND_FEC_MIN_RATE_BPS - 6000;;\r
-        } else if( psEnc->sCmn.fs_kHz == 16 ) {\r
-            LBRRRate_thres_bps = INBAND_FEC_MIN_RATE_BPS - 3000;\r
-        } else {\r
-            LBRRRate_thres_bps = INBAND_FEC_MIN_RATE_BPS;\r
-        }\r
+    psEnc->sCmn.LBRR_enabled = psEnc->sCmn.useInBandFEC;\r
+    if( psEnc->sCmn.fs_kHz == 8 ) {\r
+        LBRRRate_thres_bps = INBAND_FEC_MIN_RATE_BPS - 9000;\r
+    } else if( psEnc->sCmn.fs_kHz == 12 ) {\r
+        LBRRRate_thres_bps = INBAND_FEC_MIN_RATE_BPS - 6000;;\r
+    } else if( psEnc->sCmn.fs_kHz == 16 ) {\r
+        LBRRRate_thres_bps = INBAND_FEC_MIN_RATE_BPS - 3000;\r
+    } else {\r
+        LBRRRate_thres_bps = INBAND_FEC_MIN_RATE_BPS;\r
+    }\r
 \r
-        if( psEnc->sCmn.TargetRate_bps >= LBRRRate_thres_bps ) {\r
-            /* Set gain increase / rate reduction for LBRR usage */\r
-            /* Coarse tuned with pesq for now. */\r
-            /* Linear regression coefs G = 8 - 0.5 * loss */\r
-            /* Meaning that at 16% loss main rate and redundant rate is the same, -> G = 0 */\r
-            psEnc->sCmn.LBRR_GainIncreases = SKP_max_int( 8 - SKP_RSHIFT( psEnc->sCmn.PacketLoss_perc, 1 ), 0 );\r
-\r
-            /* Set main stream rate compensation */\r
-            if( psEnc->sCmn.LBRR_enabled && psEnc->sCmn.PacketLoss_perc > LBRR_LOSS_THRES ) {\r
-                /* Tuned to give aprox same mean / weighted bitrate as no inband FEC */\r
-                psEnc->inBandFEC_SNR_comp_Q8 = ( 6 << 8 ) - SKP_LSHIFT( psEnc->sCmn.LBRR_GainIncreases, 7 );\r
-            } else {\r
-                psEnc->inBandFEC_SNR_comp_Q8 = 0;\r
-                psEnc->sCmn.LBRR_enabled     = 0;\r
-            }\r
+    if( psEnc->sCmn.TargetRate_bps >= LBRRRate_thres_bps ) {\r
+        /* Set gain increase / rate reduction for LBRR usage */\r
+        /* Coarsely tuned with PESQ for now. */\r
+        /* Linear regression coefs G = 8 - 0.5 * loss */\r
+        /* Meaning that at 16% loss main rate and redundant rate is the same, -> G = 0 */\r
+        psEnc->sCmn.LBRR_GainIncreases = SKP_max_int( 8 - SKP_RSHIFT( psEnc->sCmn.PacketLoss_perc, 1 ), 0 );\r
+\r
+        /* Set main stream rate compensation */\r
+        if( psEnc->sCmn.LBRR_enabled && psEnc->sCmn.PacketLoss_perc > LBRR_LOSS_THRES ) {\r
+            /* Tuned to give approx same mean / weighted bitrate as no inband FEC */\r
+            psEnc->inBandFEC_SNR_comp_Q8 = SKP_FIX_CONST( 6.0f, 8 ) - SKP_LSHIFT( psEnc->sCmn.LBRR_GainIncreases, 7 );\r
         } else {\r
-            psEnc->inBandFEC_SNR_comp_Q8     = 0;\r
-            psEnc->sCmn.LBRR_enabled         = 0;\r
+            psEnc->inBandFEC_SNR_comp_Q8 = 0;\r
+            psEnc->sCmn.LBRR_enabled     = 0;\r
         }\r
+    } else {\r
+        psEnc->inBandFEC_SNR_comp_Q8     = 0;\r
+        psEnc->sCmn.LBRR_enabled         = 0;\r
     }\r
 #else\r
+    if( INBandFEC_enabled != 0 ) {\r
+        ret = SKP_SILK_ENC_INVALID_INBAND_FEC_SETTING;\r
+    }\r
     psEnc->sCmn.LBRR_enabled = 0;\r
 #endif\r
-\r
-    /* Set DTX mode */\r
-    if( DTX_enabled < 0 || DTX_enabled > 1 ) {\r
-        ret = SKP_SILK_ENC_WRONG_DTX_SETTING;\r
-    }\r
-    psEnc->sCmn.useDTX = DTX_enabled;\r
-    \r
     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_FIX    *psEncCtrl  /* 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 > LBRR_SPEECH_ACTIVITY_THRES_Q8 && psEnc->sCmn.PacketLoss_perc > LBRR_LOSS_THRES ) { // nb! maybe multiply loss prob and speech activity \r
-            //if( psEnc->PacketLoss_burst > BURST_THRES )\r
-            //  psEncCtrl->LBRR_usage = SKP_SILK_ADD_LBRR_TO_PLUS2;\r
-            //} else {\r
-                LBRR_usage = SKP_SILK_ADD_LBRR_TO_PLUS1;//SKP_SILK_NO_LBRR\r
-            //}\r
-        }\r
-        psEncCtrl->sCmn.LBRR_usage = LBRR_usage;\r
-    } else {\r
-        psEncCtrl->sCmn.LBRR_usage = SKP_SILK_NO_LBRR;\r
-    }\r
-}\r
index 8d41874f4015a9a5fb9622d17cc7657631a01856..240270c1f28c880c7e61cd67a989c250ea859a71 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -72,6 +72,7 @@ void SKP_Silk_corrMatrix_FIX(
     const SKP_int16                 *x,         /* I    x vector [L + order - 1] used to form data matrix X */\r
     const SKP_int                   L,          /* I    Length of vectors                                   */\r
     const SKP_int                   order,      /* I    Max lag for correlation                             */\r
+    const SKP_int                   head_room,  /* I    Desired headroom                                    */\r
     SKP_int32                       *XX,        /* O    Pointer to X'*X correlation matrix [ order x order ]*/\r
     SKP_int                         *rshifts    /* I/O  Right shifts of correlations                        */\r
 )\r
@@ -82,9 +83,9 @@ void SKP_Silk_corrMatrix_FIX(
 \r
     /* Calculate energy to find shift used to fit in 32 bits */\r
     SKP_Silk_sum_sqr_shift( &energy, &rshifts_local, x, L + order - 1 );\r
-    /* Add shifts to get the wanted head room */\r
 \r
-    head_room_rshifts = SKP_max( LTP_CORRS_HEAD_ROOM - SKP_Silk_CLZ32( energy ), 0 );\r
+    /* Add shifts to get the desired head room */\r
+    head_room_rshifts = SKP_max( head_room - SKP_Silk_CLZ32( energy ), 0 );\r
     \r
     energy = SKP_RSHIFT32( energy, head_room_rshifts );\r
     rshifts_local += head_room_rshifts;\r
index 9669cf8b0f641634bf74d6e3c7d60c4bb239091d..e8380066572552a73c851c21df18a3547179b33d 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -47,8 +47,6 @@ SKP_int SKP_Silk_init_decoder(
     SKP_Silk_CNG_Reset( psDec );\r
 \r
     SKP_Silk_PLC_Reset( psDec );\r
-\r
-    psDec->bitstream_v = USE_BIT_STREAM_V;\r
     \r
     return(0);\r
 }\r
index 70f7d31e6d70520f78946c41153bfb4f8428fb44..35090d427d1e4ad98a6fe6f629d6642b06ceb240 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***********************************************************************/\r
 \r
 #include "SKP_Silk_SDK_API.h"\r
-#include "SKP_Silk_main_FIX.h"\r
+#include "SKP_Silk_main.h"\r
 \r
 /*********************/\r
 /* Decoder functions */\r
@@ -69,9 +69,17 @@ SKP_int SKP_Silk_SDK_Decode(
 {\r
     SKP_int ret = 0, used_bytes, prev_fs_kHz;\r
     SKP_Silk_decoder_state *psDec;\r
+    SKP_int16 samplesOutInternal[ MAX_API_FS_KHZ * FRAME_LENGTH_MS ];\r
+    SKP_int16 *pSamplesOutInternal;\r
 \r
     psDec = (SKP_Silk_decoder_state *)decState;\r
 \r
+    /* We need this buffer to have room for an internal frame */\r
+    pSamplesOutInternal = samplesOut;\r
+    if( psDec->fs_kHz * 1000 > decControl->API_sampleRate ) {\r
+        pSamplesOutInternal = samplesOutInternal;\r
+    }\r
+\r
     /**********************************/\r
     /* Test if first frame in payload */\r
     /**********************************/\r
@@ -92,7 +100,7 @@ SKP_int SKP_Silk_SDK_Decode(
     prev_fs_kHz = psDec->fs_kHz;\r
     \r
     /* Call decoder for one frame */\r
-    ret += SKP_Silk_decode_frame( psDec, samplesOut, nSamplesOut, inData, nBytesIn, \r
+    ret += SKP_Silk_decode_frame( psDec, pSamplesOutInternal, nSamplesOut, inData, nBytesIn, \r
             lostFlag, &used_bytes );\r
     \r
     if( used_bytes ) { /* Only Call if not a packet loss */\r
@@ -122,48 +130,38 @@ SKP_int SKP_Silk_SDK_Decode(
         }\r
     }\r
 \r
-    if( psDec->fs_kHz * 1000 > decControl->sampleRate ) {\r
-        ret = SKP_SILK_DEC_WRONG_SAMPLING_FREQUENCY;\r
+    if( MAX_API_FS_KHZ * 1000 < decControl->API_sampleRate ||\r
+        8000       > decControl->API_sampleRate ) {\r
+        ret = SKP_SILK_DEC_INVALID_SAMPLING_FREQUENCY;\r
+        return( ret );\r
     }\r
 \r
-    /* Do any resampling if needed */\r
-    if( psDec->fs_kHz * 1000 != decControl->sampleRate ) { \r
-        SKP_int16 samplesOut_tmp[ 2 * MAX_FRAME_LENGTH ];\r
-        SKP_int32 scratch[        3 * MAX_FRAME_LENGTH ];\r
+    /* Resample if needed */\r
+    if( psDec->fs_kHz * 1000 != decControl->API_sampleRate ) { \r
+        SKP_int16 samplesOut_tmp[ MAX_API_FS_KHZ * FRAME_LENGTH_MS ];\r
+        SKP_assert( psDec->fs_kHz <= MAX_API_FS_KHZ );\r
 \r
-        /* Copy to a tmpbuffer as the resampling writes to samplesOut */\r
-        memcpy( samplesOut_tmp, samplesOut, *nSamplesOut * sizeof( SKP_int16 ) ); \r
+        /* Copy to a tmp buffer as the resampling writes to samplesOut */\r
+        SKP_memcpy( samplesOut_tmp, pSamplesOutInternal, *nSamplesOut * sizeof( SKP_int16 ) );\r
 \r
-        /* Clear resampler state when switching internal sampling frequency */\r
-        if( prev_fs_kHz != psDec->fs_kHz ) {\r
-            SKP_memset( psDec->resampleState, 0, sizeof( psDec->resampleState ) );\r
+        /* (Re-)initialize resampler state when switching internal sampling frequency */\r
+        if( prev_fs_kHz != psDec->fs_kHz || psDec->prev_API_sampleRate != decControl->API_sampleRate ) {\r
+            ret = SKP_Silk_resampler_init( &psDec->resampler_state, SKP_SMULBB( psDec->fs_kHz, 1000 ), decControl->API_sampleRate );\r
         }\r
 \r
-        if( psDec->fs_kHz == 16 && decControl->sampleRate == 24000 ) { \r
-            /* Resample from 16 kHz to 24 kHz */\r
-            SKP_Silk_resample_3_2( samplesOut, psDec->resampleState, samplesOut_tmp, *nSamplesOut );\r
-        } else if( psDec->fs_kHz == 12 && decControl->sampleRate == 24000 ) { \r
-            /* Resample from 12 kHz to 24 kHz */\r
-            SKP_Silk_resample_2_1_coarse( samplesOut_tmp, psDec->resampleState, samplesOut, scratch, *nSamplesOut );\r
-        } else if( psDec->fs_kHz == 8 && decControl->sampleRate == 24000 ) { \r
-            /* Resample from 8 kHz to 24 kHz */\r
-            SKP_Silk_resample_3_1( samplesOut, psDec->resampleState, samplesOut_tmp, *nSamplesOut );\r
-        } else if( psDec->fs_kHz == 12 && decControl->sampleRate == 16000 ) { \r
-            /* Resample from 12 kHz to 16 kHz */\r
-            SKP_Silk_resample_4_3( samplesOut, psDec->resampleState, samplesOut_tmp, *nSamplesOut );\r
-        } else if( psDec->fs_kHz == 8 && decControl->sampleRate == 16000 ) { \r
-            /* Resample from 8 kHz to 16 kHz */\r
-            SKP_Silk_resample_2_1_coarse( samplesOut_tmp, psDec->resampleState, samplesOut, scratch, *nSamplesOut );\r
-        } else if( psDec->fs_kHz == 8 && decControl->sampleRate == 12000 ) { \r
-            /* Resample from 8 kHz to 12 kHz */\r
-            SKP_Silk_resample_3_2( samplesOut, psDec->resampleState, samplesOut_tmp, *nSamplesOut );\r
-        }\r
+        /* Resample the output to API_sampleRate */\r
+        ret += SKP_Silk_resampler( &psDec->resampler_state, samplesOut, samplesOut_tmp, *nSamplesOut );\r
 \r
-        *nSamplesOut = SKP_DIV32( ( SKP_int32 )*nSamplesOut * decControl->sampleRate, psDec->fs_kHz * 1000 );\r
+        /* Update the number of output samples */\r
+        *nSamplesOut = SKP_DIV32( ( SKP_int32 )*nSamplesOut * decControl->API_sampleRate, psDec->fs_kHz * 1000 );\r
+    } else if( prev_fs_kHz * 1000 > decControl->API_sampleRate ) { \r
+        SKP_memcpy( samplesOut, pSamplesOutInternal, *nSamplesOut * sizeof( SKP_int16 ) );\r
     }\r
 \r
+    psDec->prev_API_sampleRate = decControl->API_sampleRate;\r
+\r
     /* Copy all parameters that are needed out of internal structure to the control stucture */\r
-    decControl->frameSize                 = ( SKP_int )psDec->frame_length;\r
+    decControl->frameSize                 = (SKP_uint16)( decControl->API_sampleRate / 50 ) ;\r
     decControl->framesPerPacket           = ( SKP_int )psDec->nFramesInPacket;\r
     decControl->inBandFECOffset           = ( SKP_int )psDec->inband_FEC_offset;\r
     decControl->moreInternalDecoderFrames = ( SKP_int )psDec->moreInternalDecoderFrames;\r
@@ -173,20 +171,16 @@ SKP_int SKP_Silk_SDK_Decode(
 \r
 /* Function to find LBRR information in a packet */\r
 void SKP_Silk_SDK_search_for_LBRR(\r
-    void                                       *decState,      /* I:   Decoder state, to select bitstream version only */\r
     const SKP_uint8                     *inData,        /* I:   Encoded input vector                            */\r
-    const SKP_int16                     nBytesIn,       /* I:   Number of input Bytes                           */\r
+    const SKP_int                       nBytesIn,       /* I:   Number of input Bytes                           */\r
     SKP_int                             lost_offset,    /* I:   Offset from lost packet                         */\r
     SKP_uint8                           *LBRRData,      /* O:   LBRR payload                                    */\r
     SKP_int16                           *nLBRRBytes     /* O:   Number of LBRR Bytes                            */\r
 )\r
 {\r
-    SKP_Silk_decoder_state   *psDec;\r
     SKP_Silk_decoder_state   sDec; // Local decoder state to avoid interfering with running decoder */\r
     SKP_Silk_decoder_control sDecCtrl;\r
-    SKP_int i, TempQ[ MAX_FRAME_LENGTH ];\r
-\r
-    psDec = ( SKP_Silk_decoder_state * )decState;\r
+    SKP_int TempQ[ MAX_FRAME_LENGTH ];\r
 \r
     if( lost_offset < 1 || lost_offset > MAX_LBRR_DELAY ) {\r
         /* No useful FEC in this packet */\r
@@ -196,138 +190,80 @@ void SKP_Silk_SDK_search_for_LBRR(
 \r
     sDec.nFramesDecoded = 0;\r
     sDec.fs_kHz         = 0; /* Force update parameters LPC_order etc */\r
+       sDec.lossCnt        = 0; /* Avoid running bw expansion of the LPC parameters when searching for LBRR data */\r
     SKP_memset( sDec.prevNLSF_Q15, 0, MAX_LPC_ORDER * sizeof( SKP_int ) );\r
     SKP_Silk_range_dec_init( &sDec.sRC, inData, ( SKP_int32 )nBytesIn );\r
-\r
-    if( psDec->bitstream_v == BIT_STREAM_V4 ) { /* Silk_v4 payload */\r
-        /* Decode all parameter indices for the whole packet*/\r
-        SKP_Silk_decode_indices_v4( &sDec );\r
-\r
-        /* Is there usable LBRR in this packet */\r
-        *nLBRRBytes = 0;\r
+    \r
+    while(1) {\r
+        SKP_Silk_decode_parameters( &sDec, &sDecCtrl, TempQ, 0 );\r
+    \r
+        if( sDec.sRC.error ) {\r
+            /* Corrupt stream */\r
+            *nLBRRBytes = 0;\r
+            return;\r
+        };\r
         if( ( sDec.FrameTermination - 1 ) & lost_offset && sDec.FrameTermination > 0 && sDec.nBytesLeft >= 0 ) {\r
             /* The wanted FEC is present in the packet */\r
-            for( i = 0; i < sDec.nFramesInPacket; i++ ) {\r
-                SKP_Silk_decode_parameters_v4( &sDec, &sDecCtrl, TempQ, 0 );\r
-                \r
-                if( sDec.nBytesLeft <= 0 || sDec.sRC.error ) {\r
-                    /* Corrupt stream */\r
-                    LBRRData = NULL;\r
-                    *nLBRRBytes = 0;\r
-                    break;\r
-                } else {\r
-                    sDec.nFramesDecoded++;\r
-                }\r
-            }\r
-        \r
-            if( LBRRData != NULL ) {\r
-                /* The wanted FEC is present in the packet */\r
-                *nLBRRBytes = sDec.nBytesLeft;\r
-                SKP_memcpy( LBRRData, &inData[ nBytesIn - sDec.nBytesLeft ], sDec.nBytesLeft * sizeof( SKP_uint8 ) );\r
-            }\r
+            *nLBRRBytes = sDec.nBytesLeft;\r
+            SKP_memcpy( LBRRData, &inData[ nBytesIn - sDec.nBytesLeft ], sDec.nBytesLeft * sizeof( SKP_uint8 ) );\r
+            break;\r
         }\r
-    } else { /* Silk_v3 payload */\r
-        while(1) {\r
-            SKP_Silk_decode_parameters( &sDec, &sDecCtrl, TempQ, 0 );\r
-\r
-            if( sDec.sRC.error ) {\r
-                /* Corrupt stream */\r
-                *nLBRRBytes = 0;\r
-                return;\r
-            };\r
-\r
-            if( ( sDec.FrameTermination - 1 ) & lost_offset && sDec.FrameTermination > 0 && sDec.nBytesLeft >= 0 ) {\r
-                /* The wanted FEC is present in the packet */\r
-                *nLBRRBytes = sDec.nBytesLeft;\r
-                SKP_memcpy( LBRRData, &inData[ nBytesIn - sDec.nBytesLeft ], sDec.nBytesLeft * sizeof( SKP_uint8 ) );\r
-                break;\r
-            }\r
-            if( sDec.nBytesLeft > 0 && sDec.FrameTermination == SKP_SILK_MORE_FRAMES ) {\r
-                sDec.nFramesDecoded++;\r
-            } else {\r
-                LBRRData = NULL;\r
-                *nLBRRBytes = 0;\r
-                break;\r
-            }\r
+        if( sDec.nBytesLeft > 0 && sDec.FrameTermination == SKP_SILK_MORE_FRAMES ) {\r
+            sDec.nFramesDecoded++;\r
+        } else {\r
+            LBRRData = NULL;\r
+            *nLBRRBytes = 0;\r
+            break;\r
         }\r
     }\r
 }\r
 \r
 /* Getting type of content for a packet */\r
 void SKP_Silk_SDK_get_TOC(\r
-    void                                *decState,      /* I/O: Decoder state, to select bitstream version only */\r
     const SKP_uint8                     *inData,        /* I:   Encoded input vector                            */\r
-    const SKP_int16                     nBytesIn,       /* I:   Number of input bytes                           */\r
+    const SKP_int                       nBytesIn,       /* I:   Number of input bytes                           */\r
     SKP_Silk_TOC_struct                 *Silk_TOC       /* O:   Type of content                                 */\r
 )\r
 {\r
-    SKP_Silk_decoder_state      *psDec;\r
     SKP_Silk_decoder_state      sDec; // Local Decoder state to avoid interfering with running decoder */\r
     SKP_Silk_decoder_control    sDecCtrl;\r
-    SKP_int i, TempQ[ MAX_FRAME_LENGTH ];\r
-\r
-    psDec = (SKP_Silk_decoder_state *)decState;\r
+    SKP_int TempQ[ MAX_FRAME_LENGTH ];\r
 \r
     sDec.nFramesDecoded = 0;\r
     sDec.fs_kHz         = 0; /* Force update parameters LPC_order etc */\r
     SKP_Silk_range_dec_init( &sDec.sRC, inData, ( SKP_int32 )nBytesIn );\r
 \r
-    if( psDec->bitstream_v == BIT_STREAM_V4 ) { /* Silk_v4 payload */\r
-        /* Decode all parameter indices for the whole packet*/\r
-        SKP_Silk_decode_indices_v4( &sDec );\r
+    Silk_TOC->corrupt = 0;\r
+    while( 1 ) {\r
+        SKP_Silk_decode_parameters( &sDec, &sDecCtrl, TempQ, 0 );\r
         \r
-        if( sDec.nFramesInPacket > SILK_MAX_FRAMES_PER_PACKET || sDec.sRC.error ) {\r
-            /* Corrupt packet */\r
-            SKP_memset( Silk_TOC, 0, sizeof( SKP_Silk_TOC_struct ) );\r
+        Silk_TOC->vadFlags[     sDec.nFramesDecoded ] = sDec.vadFlag;\r
+        Silk_TOC->sigtypeFlags[ sDec.nFramesDecoded ] = sDecCtrl.sigtype;\r
+    \r
+        if( sDec.sRC.error ) {\r
+            /* Corrupt stream */\r
             Silk_TOC->corrupt = 1;\r
+            break;\r
+        };\r
+    \r
+        if( sDec.nBytesLeft > 0 && sDec.FrameTermination == SKP_SILK_MORE_FRAMES ) {\r
+            sDec.nFramesDecoded++;\r
         } else {\r
-            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
-            } else {\r
-                Silk_TOC->inbandLBRR = sDec.FrameTermination - 1;\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
-            }\r
+            break;\r
         }\r
-    } else { /* Silk_v3 payload */\r
-        Silk_TOC->corrupt = 0;\r
-        while( 1 ) {\r
-            SKP_Silk_decode_parameters( &sDec, &sDecCtrl, TempQ, 0 );\r
-            \r
-            Silk_TOC->vadFlags[     sDec.nFramesDecoded ] = sDec.vadFlag;\r
-            Silk_TOC->sigtypeFlags[ sDec.nFramesDecoded ] = sDecCtrl.sigtype;\r
-\r
-            if( sDec.sRC.error ) {\r
-                /* Corrupt stream */\r
-                Silk_TOC->corrupt = 1;\r
-                break;\r
-            };\r
-\r
-            if( sDec.nBytesLeft > 0 && sDec.FrameTermination == SKP_SILK_MORE_FRAMES ) {\r
-                sDec.nFramesDecoded++;\r
-            } else {\r
-                break;\r
-            }\r
-        }\r
-        if( Silk_TOC->corrupt || sDec.FrameTermination == SKP_SILK_MORE_FRAMES || \r
-            sDec.nFramesInPacket > SILK_MAX_FRAMES_PER_PACKET ) {\r
-            /* Corrupt packet */\r
-            SKP_memset( Silk_TOC, 0, sizeof( SKP_Silk_TOC_struct ) );\r
-            Silk_TOC->corrupt = 1;\r
+    }\r
+    if( Silk_TOC->corrupt || sDec.FrameTermination == SKP_SILK_MORE_FRAMES || \r
+        sDec.nFramesInPacket > SILK_MAX_FRAMES_PER_PACKET ) {\r
+        /* Corrupt packet */\r
+        SKP_memset( Silk_TOC, 0, sizeof( SKP_Silk_TOC_struct ) );\r
+        Silk_TOC->corrupt = 1;\r
+    } else {\r
+        Silk_TOC->framesInPacket = sDec.nFramesDecoded + 1;\r
+        Silk_TOC->fs_kHz         = sDec.fs_kHz;\r
+        if( sDec.FrameTermination == SKP_SILK_LAST_FRAME ) {\r
+            Silk_TOC->inbandLBRR = sDec.FrameTermination;\r
         } else {\r
-            Silk_TOC->framesInPacket = sDec.nFramesDecoded;\r
-            Silk_TOC->fs_kHz         = sDec.fs_kHz;\r
-            if( sDec.FrameTermination == SKP_SILK_LAST_FRAME ) {\r
-                Silk_TOC->inbandLBRR = sDec.FrameTermination;\r
-            } else {\r
-                Silk_TOC->inbandLBRR = sDec.FrameTermination - 1;\r
-            }\r
+            Silk_TOC->inbandLBRR = sDec.FrameTermination - 1;\r
         }\r
     }\r
 }\r
@@ -338,6 +274,6 @@ void SKP_Silk_SDK_get_TOC(
 /* Return a pointer to string specifying the version */ \r
 const char *SKP_Silk_SDK_get_version()\r
 {\r
-    static const char version[] = "1.0.2";\r
+    static const char version[] = "1.0.8";\r
     return version;\r
 }\r
index fec15a2d4c14a6c0788d1b59a8f7c9d8fe36ddac..440d0c9affffd3acb9229ddef3ebc140036c5d77 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -27,6 +27,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 \r
 #include "SKP_Silk_main.h"\r
 \r
+\r
+void SKP_Silk_decode_short_term_prediction(\r
+SKP_int32      *vec_Q10,\r
+SKP_int32      *pres_Q10,\r
+SKP_int32      *sLPC_Q14,\r
+SKP_int16      *A_Q12_tmp, \r
+SKP_int                LPC_order,\r
+SKP_int                subfr_length\r
+);\r
+\r
+\r
 /**********************************************************/\r
 /* Core decoder. Performs inverse NSQ operation LTP + LPC */\r
 /**********************************************************/\r
@@ -37,13 +48,14 @@ void SKP_Silk_decode_core(
     const SKP_int               q[ MAX_FRAME_LENGTH ]               /* I    Pulse signal                */\r
 )\r
 {\r
-    SKP_int     i, k, lag = 0, start_idx, NLSF_interpolation_flag, sigtype, LTP_scale_Q14;\r
-    SKP_int16   *A_Q12, *B_Q14, *pxq, A_Q12_tmp[ MAX_LPC_ORDER ];\r
-    SKP_int16   sLTP[ MAX_FRAME_LENGTH ];\r
-    SKP_int32   Gain_Q16, *pred_lag_ptr, *pexc_Q10, *pres_Q10, LTP_pred_Q14, LPC_pred_Q10;\r
-    SKP_int32   rand_seed, offset_Q10, dither;\r
-    SKP_int32   vec_Q10[ MAX_FRAME_LENGTH / NB_SUBFR ], Atmp;\r
-    SKP_int32   inv_gain_Q16, inv_gain_Q32, gain_adj_Q16, FiltState[ MAX_LPC_ORDER ];\r
+    SKP_int   i, k, lag = 0, start_idx, sLTP_buf_idx, NLSF_interpolation_flag, sigtype, LTP_scale_Q14;\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, Gain_Q16, inv_gain_Q16, inv_gain_Q32, gain_adj_Q16, rand_seed, offset_Q10, dither;\r
+    SKP_int32 *pred_lag_ptr, *pexc_Q10, *pres_Q10;\r
+    SKP_int32 vec_Q10[ MAX_FRAME_LENGTH / NB_SUBFR ];\r
+    SKP_int32 FiltState[ MAX_LPC_ORDER ];\r
+\r
     SKP_assert( psDec->prev_inv_gain_Q16 != 0 );\r
     \r
     offset_Q10 = SKP_Silk_Quantization_Offsets_Q10[ psDecCtrl->sigtype ][ psDecCtrl->QuantOffsetType ];\r
@@ -72,7 +84,7 @@ void SKP_Silk_decode_core(
     pexc_Q10 = psDec->exc_Q10;\r
     pres_Q10 = psDec->res_Q10;\r
     pxq      = &psDec->outBuf[ psDec->frame_length ];\r
-    psDec->sLTP_buf_idx = psDec->frame_length;\r
+    sLTP_buf_idx = psDec->frame_length;\r
     /* Loop over subframes */\r
     for( k = 0; k < NB_SUBFR; k++ ) {\r
         A_Q12 = psDecCtrl->PredCoef_Q12[ k >> 1 ];\r
@@ -84,8 +96,8 @@ void SKP_Silk_decode_core(
         LTP_scale_Q14 = psDecCtrl->LTP_scale_Q14;\r
         sigtype       = psDecCtrl->sigtype;\r
 \r
-        inv_gain_Q16  = SKP_DIV32( SKP_int32_MAX, SKP_RSHIFT( Gain_Q16, 1 ) );\r
-        inv_gain_Q16  = SKP_min( inv_gain_Q16, SKP_int16_MAX );\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
 \r
         /* Calculate Gain adjustment factor */\r
         gain_adj_Q16 = ( SKP_int32 )1 << 16;\r
@@ -104,6 +116,7 @@ void SKP_Silk_decode_core(
             psDecCtrl->pitchL[ k ] = psDec->lagPrev;\r
             LTP_scale_Q14 = ( SKP_int )1 << 14;\r
         }\r
+\r
         if( sigtype == SIG_TYPE_VOICED ) {\r
             /* Voiced */\r
             \r
@@ -112,8 +125,10 @@ void SKP_Silk_decode_core(
             if( ( k & ( 3 - SKP_LSHIFT( NLSF_interpolation_flag, 1 ) ) ) == 0 ) {\r
                 /* Rewhiten with new A coefs */\r
                 start_idx = psDec->frame_length - lag - psDec->LPC_order - LTP_ORDER / 2;\r
-                start_idx = SKP_LIMIT( start_idx, 0, psDec->frame_length - psDec->LPC_order );\r
+                SKP_assert( start_idx >= 0 );\r
+                SKP_assert( start_idx <= psDec->frame_length - psDec->LPC_order );\r
 \r
+                SKP_memset( FiltState, 0, psDec->LPC_order * sizeof( SKP_int32 ) ); /* Not really necessary, but Valgrind and Coverity will complain otherwise */\r
                 SKP_Silk_MA_Prediction( &psDec->outBuf[ start_idx + k * ( psDec->frame_length >> 2 ) ], \r
                     A_Q12, FiltState, sLTP + start_idx, psDec->frame_length - start_idx, psDec->LPC_order );\r
 \r
@@ -124,13 +139,13 @@ void SKP_Silk_decode_core(
                     inv_gain_Q32 = SKP_LSHIFT( SKP_SMULWB( inv_gain_Q32, psDecCtrl->LTP_scale_Q14 ), 2 );\r
                 }\r
                 for( i = 0; i < (lag + LTP_ORDER/2); i++ ) {\r
-                    psDec->sLTP_Q16[ psDec->sLTP_buf_idx - i - 1 ] = SKP_SMULWB( inv_gain_Q32, sLTP[ psDec->frame_length - i - 1 ] );\r
+                    psDec->sLTP_Q16[ sLTP_buf_idx - i - 1 ] = SKP_SMULWB( inv_gain_Q32, sLTP[ psDec->frame_length - i - 1 ] );\r
                 }\r
             } else {\r
                 /* Update LTP state when Gain changes */\r
                 if( gain_adj_Q16 != ( SKP_int32 )1 << 16 ) {\r
                     for( i = 0; i < ( lag + LTP_ORDER / 2 ); i++ ) {\r
-                        psDec->sLTP_Q16[ psDec->sLTP_buf_idx - i - 1 ] = SKP_SMULWW( gain_adj_Q16, psDec->sLTP_Q16[ psDec->sLTP_buf_idx - i - 1 ] );\r
+                        psDec->sLTP_Q16[ sLTP_buf_idx - i - 1 ] = SKP_SMULWW( gain_adj_Q16, psDec->sLTP_Q16[ sLTP_buf_idx - i - 1 ] );\r
                     }\r
                 }\r
             }\r
@@ -145,11 +160,10 @@ void SKP_Silk_decode_core(
         SKP_assert( inv_gain_Q16 != 0 );\r
         psDec->prev_inv_gain_Q16 = inv_gain_Q16;\r
 \r
-\r
         /* Long-term prediction */\r
         if( sigtype == SIG_TYPE_VOICED ) {\r
             /* Setup pointer */\r
-            pred_lag_ptr = &psDec->sLTP_Q16[ psDec->sLTP_buf_idx - lag + LTP_ORDER / 2 ];\r
+            pred_lag_ptr = &psDec->sLTP_Q16[ sLTP_buf_idx - lag + LTP_ORDER / 2 ];\r
             for( i = 0; i < psDec->subfr_length; i++ ) {\r
                 /* Unrolled loop */\r
                 LTP_pred_Q14 = SKP_SMULWB(               pred_lag_ptr[  0 ], B_Q14[ 0 ] );\r
@@ -163,80 +177,14 @@ void SKP_Silk_decode_core(
                 pres_Q10[ i ] = SKP_ADD32( pexc_Q10[ i ], SKP_RSHIFT_ROUND( LTP_pred_Q14, 4 ) );\r
             \r
                 /* Update states */\r
-                psDec->sLTP_Q16[ psDec->sLTP_buf_idx ] = SKP_LSHIFT( pres_Q10[ i ], 6 );\r
-                psDec->sLTP_buf_idx++;\r
+                psDec->sLTP_Q16[ sLTP_buf_idx ] = SKP_LSHIFT( pres_Q10[ i ], 6 );\r
+                sLTP_buf_idx++;\r
             }\r
         } else {\r
             SKP_memcpy( pres_Q10, pexc_Q10, psDec->subfr_length * sizeof( SKP_int32 ) );\r
         }\r
 \r
-\r
-        /* Short term prediction */\r
-        /* NOTE: the code below loads two int16 values in an int32, and multiplies each using the   */\r
-        /* SMLAWB and SMLAWT instructions. On a big-endian CPU the two int16 variables would be     */\r
-        /* loaded in reverse order and the code will give the wrong result. In that case swapping   */\r
-        /* the SMLAWB and SMLAWT instructions should solve the problem.                             */\r
-        if( psDec->LPC_order == 16 ) {\r
-            for( i = 0; i < psDec->subfr_length; i++ ) {\r
-                /* unrolled */\r
-                Atmp = *( ( SKP_int32* )&A_Q12_tmp[ 0 ] );    /* read two coefficients at once */\r
-                LPC_pred_Q10 = SKP_SMULWB(               psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  1 ], Atmp );\r
-                LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  2 ], Atmp );\r
-                Atmp = *( ( SKP_int32* )&A_Q12_tmp[ 2 ] );\r
-                LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  3 ], Atmp );\r
-                LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  4 ], Atmp );\r
-                Atmp = *( ( SKP_int32* )&A_Q12_tmp[ 4 ] );\r
-                LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  5 ], Atmp );\r
-                LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  6 ], Atmp );\r
-                Atmp = *( ( SKP_int32* )&A_Q12_tmp[ 6 ] );\r
-                LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  7 ], Atmp );\r
-                LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  8 ], Atmp );\r
-                Atmp = *( ( SKP_int32* )&A_Q12_tmp[ 8 ] );\r
-                LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  9 ], Atmp );\r
-                LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 10 ], Atmp );\r
-                Atmp = *( ( SKP_int32* )&A_Q12_tmp[ 10 ] );\r
-                LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 11 ], Atmp );\r
-                LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 12 ], Atmp );\r
-                Atmp = *( ( SKP_int32* )&A_Q12_tmp[ 12 ] );\r
-                LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 13 ], Atmp );\r
-                LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 14 ], Atmp );\r
-                Atmp = *( ( SKP_int32* )&A_Q12_tmp[ 14 ] );\r
-                LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 15 ], Atmp );\r
-                LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 16 ], Atmp );\r
-                \r
-                /* Add prediction to LPC residual */\r
-                vec_Q10[ i ] = SKP_ADD32( pres_Q10[ i ], LPC_pred_Q10 );\r
-                \r
-                /* Update states */\r
-                psDec->sLPC_Q14[ MAX_LPC_ORDER + i ] = SKP_LSHIFT( vec_Q10[ i ], 4 );\r
-            }\r
-        } else {\r
-            SKP_assert( psDec->LPC_order == 10 );\r
-            for( i = 0; i < psDec->subfr_length; i++ ) {\r
-                /* unrolled */\r
-                Atmp = *( ( SKP_int32* )&A_Q12_tmp[ 0 ] );    /* read two coefficients at once */\r
-                LPC_pred_Q10 = SKP_SMULWB(               psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  1 ], Atmp );\r
-                LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  2 ], Atmp );\r
-                Atmp = *( ( SKP_int32* )&A_Q12_tmp[ 2 ] );\r
-                LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  3 ], Atmp );\r
-                LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  4 ], Atmp );\r
-                Atmp = *( ( SKP_int32* )&A_Q12_tmp[ 4 ] );\r
-                LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  5 ], Atmp );\r
-                LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  6 ], Atmp );\r
-                Atmp = *( ( SKP_int32* )&A_Q12_tmp[ 6 ] );\r
-                LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  7 ], Atmp );\r
-                LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  8 ], Atmp );\r
-                Atmp = *( ( SKP_int32* )&A_Q12_tmp[ 8 ] );\r
-                LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i -  9 ], Atmp );\r
-                LPC_pred_Q10 = SKP_SMLAWT( LPC_pred_Q10, psDec->sLPC_Q14[ MAX_LPC_ORDER + i - 10 ], Atmp );\r
-                \r
-                /* Add prediction to LPC residual */\r
-                vec_Q10[ i ] = SKP_ADD32( pres_Q10[ i ], LPC_pred_Q10 );\r
-                \r
-                /* Update states */\r
-                psDec->sLPC_Q14[ MAX_LPC_ORDER + i ] = SKP_LSHIFT( vec_Q10[ i ], 4 );\r
-            }\r
-        }\r
+       SKP_Silk_decode_short_term_prediction(vec_Q10, pres_Q10, psDec->sLPC_Q14,A_Q12_tmp,psDec->LPC_order,psDec->subfr_length);\r
 \r
         /* Scale with Gain */\r
         for( i = 0; i < psDec->subfr_length; i++ ) {\r
@@ -254,3 +202,43 @@ void SKP_Silk_decode_core(
     SKP_memcpy( xq, &psDec->outBuf[ psDec->frame_length ], psDec->frame_length * sizeof( SKP_int16 ) );\r
 \r
 }\r
+\r
+void SKP_Silk_decode_short_term_prediction(\r
+SKP_int32      *vec_Q10,\r
+SKP_int32      *pres_Q10,\r
+SKP_int32      *sLPC_Q14,\r
+SKP_int16      *A_Q12_tmp, \r
+SKP_int                LPC_order,\r
+SKP_int                subfr_length\r
+)\r
+{\r
+  SKP_int      i;\r
+  SKP_int32    LPC_pred_Q10;\r
+    SKP_int j;\r
+        for( i = 0; i < subfr_length; i++ ) {\r
+            /* Partially unrolled */\r
+            LPC_pred_Q10 = SKP_SMULWB(               sLPC_Q14[ MAX_LPC_ORDER + i -  1 ], A_Q12_tmp[ 0 ] );\r
+            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, sLPC_Q14[ MAX_LPC_ORDER + i -  2 ], A_Q12_tmp[ 1 ] );\r
+            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, sLPC_Q14[ MAX_LPC_ORDER + i -  3 ], A_Q12_tmp[ 2 ] );\r
+            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, sLPC_Q14[ MAX_LPC_ORDER + i -  4 ], A_Q12_tmp[ 3 ] );\r
+            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, sLPC_Q14[ MAX_LPC_ORDER + i -  5 ], A_Q12_tmp[ 4 ] );\r
+            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, sLPC_Q14[ MAX_LPC_ORDER + i -  6 ], A_Q12_tmp[ 5 ] );\r
+            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, sLPC_Q14[ MAX_LPC_ORDER + i -  7 ], A_Q12_tmp[ 6 ] );\r
+            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, sLPC_Q14[ MAX_LPC_ORDER + i -  8 ], A_Q12_tmp[ 7 ] );\r
+            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, sLPC_Q14[ MAX_LPC_ORDER + i -  9 ], A_Q12_tmp[ 8 ] );\r
+            LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, sLPC_Q14[ MAX_LPC_ORDER + i - 10 ], A_Q12_tmp[ 9 ] );\r
+\r
+            for( j = 10; j < LPC_order; j ++ ) {\r
+                LPC_pred_Q10 = SKP_SMLAWB( LPC_pred_Q10, sLPC_Q14[ MAX_LPC_ORDER + i - j - 1 ], A_Q12_tmp[ j ] );\r
+            }\r
+\r
+            /* Add prediction to LPC residual */\r
+            vec_Q10[ i ] = SKP_ADD32( pres_Q10[ i ], LPC_pred_Q10 );\r
+            \r
+            /* Update states */\r
+            sLPC_Q14[ MAX_LPC_ORDER + i ] = SKP_LSHIFT( vec_Q10[ i ], 4 );\r
+        }\r
+}\r
+\r
+\r
+\r
index 279179b070d991cb9d01fa9972f4831d821600c0..48382a5ee6ed7be95a7fc519110749dd86e8bd63 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -66,30 +66,20 @@ SKP_int SKP_Silk_decode_frame(
         if( psDec->nFramesDecoded == 0 ) {\r
             /* Initialize range decoder state */\r
             SKP_Silk_range_dec_init( &psDec->sRC, pCode, nBytes );\r
-        \r
-            if( psDec->bitstream_v == BIT_STREAM_V4 ) {\r
-                SKP_Silk_decode_indices_v4( psDec );\r
-            }\r
         }\r
 \r
         /********************************************/\r
         /* Decode parameters and pulse signal       */\r
         /********************************************/\r
-        if( psDec->bitstream_v == BIT_STREAM_V4 ) {\r
-            SKP_Silk_decode_parameters_v4( psDec, &sDecCtrl, Pulses, 1 );\r
-        } else {\r
-            SKP_Silk_decode_parameters( psDec, &sDecCtrl, Pulses, 1 );\r
-        }\r
+        SKP_Silk_decode_parameters( psDec, &sDecCtrl, Pulses, 1 );\r
 \r
 \r
         if( psDec->sRC.error ) {\r
             psDec->nBytesLeft = 0;\r
 \r
             action              = 1; /* PLC operation */\r
-            psDec->fs_kHz       = fs_Khz_old;    /* revert fs if changed in decode_parameters */\r
-            psDec->LPC_order    = LPC_order_old; /* revert lpc_order if changed in decode_parameters */\r
-            psDec->frame_length = fs_Khz_old * FRAME_LENGTH_MS;\r
-            psDec->subfr_length = fs_Khz_old * FRAME_LENGTH_MS / NB_SUBFR;\r
+            /* revert fs if changed in decode_parameters */\r
+            SKP_Silk_decoder_set_fs( psDec, fs_Khz_old );\r
 \r
             /* Avoid crashing */\r
             *decBytes = psDec->sRC.bufferLength;\r
@@ -124,13 +114,11 @@ SKP_int SKP_Silk_decode_frame(
         }\r
     }\r
     /*************************************************************/\r
-    /* Generate Concealment Frame if packet is lost, or corrupt  */\r
+    /* Generate Concealment frame if packet is lost, or corrupt  */\r
     /*************************************************************/\r
     if( action == 1 ) {\r
         /* Handle packet loss by extrapolation */\r
         SKP_Silk_PLC( psDec, &sDecCtrl, pOut, L, action );\r
-        psDec->lossCnt++;\r
-    \r
     }\r
 \r
     /*************************/\r
@@ -163,5 +151,6 @@ SKP_int SKP_Silk_decode_frame(
     /* Update some decoder state variables */\r
     psDec->lagPrev = sDecCtrl.pitchL[ NB_SUBFR - 1 ];\r
 \r
+\r
     return ret;\r
 }\r
diff --git a/libs/silk/src/SKP_Silk_decode_indices_v4.c b/libs/silk/src/SKP_Silk_decode_indices_v4.c
deleted file mode 100644 (file)
index b86d1f5..0000000
+++ /dev/null
@@ -1,195 +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
-/* Decode indices from payload */\r
-void SKP_Silk_decode_indices_v4(\r
-    SKP_Silk_decoder_state      *psDec            /* I/O    State                              */\r
-)\r
-{\r
-    SKP_int   i, k, Ix, fs_kHz_dec, FrameIndex = 0, FrameTermination;\r
-    SKP_int   sigtype, QuantOffsetType, seed_int, nBytesUsed;\r
-    SKP_int   decode_absolute_lagIndex, delta_lagIndex, prev_lagIndex = 0;\r
-    const SKP_Silk_NLSF_CB_struct *psNLSF_CB = NULL;\r
-    SKP_Silk_range_coder_state  *psRC = &psDec->sRC;\r
-    /************************/\r
-    /* Decode sampling rate */\r
-    /************************/\r
-    /* only done for first frame of packet */\r
-    if( psDec->nFramesDecoded == 0 ) {\r
-        SKP_Silk_range_decoder( &Ix, psRC, SKP_Silk_SamplingRates_CDF, SKP_Silk_SamplingRates_offset );\r
-\r
-        /* check that sampling rate is supported */\r
-        if( Ix < 0 || Ix > 3 ) {\r
-            psRC->error = RANGE_CODER_ILLEGAL_SAMPLING_RATE;\r
-            return;\r
-        }\r
-        fs_kHz_dec = SKP_Silk_SamplingRates_table[ Ix ];\r
-        SKP_Silk_decoder_set_fs( psDec, fs_kHz_dec );\r
-    \r
-        FrameIndex       = 0;\r
-        FrameTermination = SKP_SILK_MORE_FRAMES;\r
-    }\r
-\r
-    while( FrameTermination == SKP_SILK_MORE_FRAMES ) {\r
-        /*******************/\r
-        /* Decode VAD flag */\r
-        /*******************/\r
-        SKP_Silk_range_decoder( &psDec->vadFlagBuf[ FrameIndex ], psRC, SKP_Silk_vadflag_CDF, SKP_Silk_vadflag_offset );\r
-\r
-        /*******************************************/\r
-        /* Decode signal type and quantizer offset */\r
-        /*******************************************/\r
-        if( FrameIndex == 0 ) {\r
-            /* first frame in packet: independent coding */\r
-            SKP_Silk_range_decoder( &Ix, psRC, SKP_Silk_type_offset_CDF, SKP_Silk_type_offset_CDF_offset );\r
-        } else {\r
-            /* condidtional coding */\r
-            SKP_Silk_range_decoder( &Ix, psRC, SKP_Silk_type_offset_joint_CDF[ psDec->typeOffsetPrev ], \r
-                    SKP_Silk_type_offset_CDF_offset );\r
-        }\r
-        sigtype               = SKP_RSHIFT( Ix, 1 );\r
-        QuantOffsetType       = Ix & 1;\r
-        psDec->typeOffsetPrev = Ix;\r
-\r
-        /****************/\r
-        /* Decode gains */\r
-        /****************/\r
-        /* first subframe */    \r
-        if( FrameIndex == 0 ) {\r
-            /* first frame in packet: independent coding */\r
-            SKP_Silk_range_decoder( &psDec->GainsIndices[ FrameIndex ][ 0 ], psRC, SKP_Silk_gain_CDF[ sigtype ], SKP_Silk_gain_CDF_offset );\r
-        } else {\r
-            /* condidtional coding */\r
-            SKP_Silk_range_decoder( &psDec->GainsIndices[ FrameIndex ][ 0 ], psRC, SKP_Silk_delta_gain_CDF, SKP_Silk_delta_gain_CDF_offset );\r
-        }\r
-\r
-        /* remaining subframes */\r
-        for( i = 1; i < NB_SUBFR; i++ ) {\r
-            SKP_Silk_range_decoder( &psDec->GainsIndices[ FrameIndex ][ i ], psRC, SKP_Silk_delta_gain_CDF, SKP_Silk_delta_gain_CDF_offset );\r
-        }\r
-        \r
-        /**********************/\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
-\r
-        /* Arithmetically decode NLSF path */\r
-        SKP_Silk_range_decoder_multi( psDec->NLSFIndices[ FrameIndex ], psRC, psNLSF_CB->StartPtr, psNLSF_CB->MiddleIx, psNLSF_CB->nStages );\r
-        \r
-        /***********************************/\r
-        /* Decode LSF interpolation factor */\r
-        /***********************************/\r
-        SKP_Silk_range_decoder( &psDec->NLSFInterpCoef_Q2[ FrameIndex ], psRC, SKP_Silk_NLSF_interpolation_factor_CDF, \r
-            SKP_Silk_NLSF_interpolation_factor_offset );\r
-        \r
-        if( sigtype == SIG_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
-                /* Decode Delta index */\r
-                SKP_Silk_range_decoder( &delta_lagIndex,psRC, SKP_Silk_pitch_delta_CDF,  SKP_Silk_pitch_delta_CDF_offset );\r
-                if( delta_lagIndex < ( MAX_DELTA_LAG << 1 ) + 1 ) {\r
-                    delta_lagIndex = delta_lagIndex - MAX_DELTA_LAG;\r
-                    psDec->lagIndex[ FrameIndex ] = prev_lagIndex + delta_lagIndex;\r
-                    decode_absolute_lagIndex = 0;\r
-                }\r
-            }\r
-            if( decode_absolute_lagIndex ) {\r
-                /* Absolute decoding */\r
-                if( psDec->fs_kHz == 8 ) {\r
-                    SKP_Silk_range_decoder( &psDec->lagIndex[ FrameIndex ], psRC, SKP_Silk_pitch_lag_NB_CDF,  SKP_Silk_pitch_lag_NB_CDF_offset );\r
-                } else if( psDec->fs_kHz == 12 ) {\r
-                    SKP_Silk_range_decoder( &psDec->lagIndex[ FrameIndex ], psRC, SKP_Silk_pitch_lag_MB_CDF,  SKP_Silk_pitch_lag_MB_CDF_offset );\r
-                } else if( psDec->fs_kHz == 16 ) {\r
-                    SKP_Silk_range_decoder( &psDec->lagIndex[ FrameIndex ], psRC, SKP_Silk_pitch_lag_WB_CDF,  SKP_Silk_pitch_lag_WB_CDF_offset );\r
-                } else {\r
-                    SKP_Silk_range_decoder( &psDec->lagIndex[ FrameIndex ], psRC, SKP_Silk_pitch_lag_SWB_CDF, SKP_Silk_pitch_lag_SWB_CDF_offset );\r
-                }\r
-            }\r
-            prev_lagIndex = psDec->lagIndex[ FrameIndex ];\r
-\r
-            /* Get countour index */\r
-            if( psDec->fs_kHz == 8 ) {\r
-                /* Less codevectors used in 8 khz mode */\r
-                SKP_Silk_range_decoder( &psDec->contourIndex[ FrameIndex ], psRC, SKP_Silk_pitch_contour_NB_CDF, SKP_Silk_pitch_contour_NB_CDF_offset );\r
-            } else {\r
-                /* Joint for 12, 16, and 24 khz */\r
-                SKP_Silk_range_decoder( &psDec->contourIndex[ FrameIndex ], psRC, SKP_Silk_pitch_contour_CDF, SKP_Silk_pitch_contour_CDF_offset );\r
-            }\r
-            \r
-            /********************/\r
-            /* Decode LTP gains */\r
-            /********************/\r
-            /* Decode PERIndex value */\r
-            SKP_Silk_range_decoder( &psDec->PERIndex[ FrameIndex ], psRC, SKP_Silk_LTP_per_index_CDF, SKP_Silk_LTP_per_index_CDF_offset );\r
-            \r
-            for( k = 0; k < NB_SUBFR; k++ ) {\r
-                SKP_Silk_range_decoder( &psDec->LTPIndex[ FrameIndex ][ k ], psRC, SKP_Silk_LTP_gain_CDF_ptrs[ psDec->PERIndex[ FrameIndex ] ], \r
-                    SKP_Silk_LTP_gain_CDF_offsets[ psDec->PERIndex[ FrameIndex ] ] );\r
-            }\r
-\r
-            /**********************/\r
-            /* Decode LTP scaling */\r
-            /**********************/\r
-            SKP_Silk_range_decoder( &psDec->LTP_scaleIndex[ FrameIndex ], psRC, SKP_Silk_LTPscale_CDF, SKP_Silk_LTPscale_offset );\r
-        }\r
-\r
-        /***************/\r
-        /* Decode seed */\r
-        /***************/\r
-        SKP_Silk_range_decoder( &seed_int, psRC, SKP_Silk_Seed_CDF, SKP_Silk_Seed_offset );\r
-        psDec->Seed[ FrameIndex ] = ( SKP_int32 )seed_int;\r
-        /**************************************/\r
-        /* Decode Frame termination indicator */\r
-        /**************************************/\r
-        SKP_Silk_range_decoder( &FrameTermination, psRC, SKP_Silk_FrameTermination_v4_CDF, SKP_Silk_FrameTermination_v4_offset );\r
-\r
-        psDec->sigtype[ FrameIndex ]         = sigtype;\r
-        psDec->QuantOffsetType[ FrameIndex ] = QuantOffsetType;\r
-\r
-        FrameIndex++;\r
-    }\r
-\r
-    /****************************************/\r
-    /* get number of bytes used so far      */\r
-    /****************************************/\r
-    SKP_Silk_range_coder_get_length( psRC, &nBytesUsed );\r
-    psDec->nBytesLeft = psRC->bufferLength - nBytesUsed;\r
-    if( psDec->nBytesLeft < 0 ) {\r
-        psRC->error = RANGE_CODER_READ_BEYOND_BUFFER;\r
-    }\r
-\r
-    psDec->nFramesInPacket  = FrameIndex;\r
-    psDec->FrameTermination = FrameTermination;\r
-}\r
index d58539591b66c94d91bccaeba492a6b035fc08e1..3a3516427d7ef31dc450b2e33bfff6a6f2709be5 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -100,7 +100,7 @@ void SKP_Silk_decode_parameters(
     /* Set pointer to NLSF VQ CB for the current signal type */\r
     psNLSF_CB = psDec->psNLSF_CB[ psDecCtrl->sigtype ];\r
 \r
-    /* Arithmetically decode NLSF path */\r
+    /* Range decode NLSF path */\r
     SKP_Silk_range_decoder_multi( NLSFIndices, psRC, psNLSF_CB->StartPtr, psNLSF_CB->MiddleIx, psNLSF_CB->nStages );\r
 \r
     /* From the NLSF path, decode an NLSF vector */\r
@@ -182,14 +182,14 @@ void SKP_Silk_decode_parameters(
                 SKP_Silk_LTP_per_index_CDF_offset );\r
 \r
         /* Decode Codebook Index */\r
-        cbk_ptr_Q14 = SKP_Silk_LTP_vq_ptrs_Q14[ psDecCtrl->PERIndex ]; // set pointer to start of codebook\r
-        \r
+        cbk_ptr_Q14 = SKP_Silk_LTP_vq_ptrs_Q14[ psDecCtrl->PERIndex ]; /* set pointer to start of codebook */\r
+\r
         for( k = 0; k < NB_SUBFR; k++ ) {\r
             SKP_Silk_range_decoder( &Ix, psRC, SKP_Silk_LTP_gain_CDF_ptrs[ psDecCtrl->PERIndex ], \r
                 SKP_Silk_LTP_gain_CDF_offsets[ psDecCtrl->PERIndex ] );\r
 \r
             for( i = 0; i < LTP_ORDER; i++ ) {\r
-                psDecCtrl->LTPCoef_Q14[ SKP_SMULBB( k, LTP_ORDER ) + i ] = cbk_ptr_Q14[ SKP_SMULBB( Ix, LTP_ORDER ) + i ];\r
+                psDecCtrl->LTPCoef_Q14[ k * LTP_ORDER + i ] = cbk_ptr_Q14[ Ix * LTP_ORDER + i ];\r
             }\r
         }\r
 \r
@@ -199,8 +199,9 @@ void SKP_Silk_decode_parameters(
         SKP_Silk_range_decoder( &Ix, psRC, SKP_Silk_LTPscale_CDF, SKP_Silk_LTPscale_offset );\r
         psDecCtrl->LTP_scale_Q14 = SKP_Silk_LTPScales_table_Q14[ Ix ];\r
     } else {\r
-        SKP_memset( psDecCtrl->pitchL,      0, NB_SUBFR * sizeof( SKP_int ) );\r
-        SKP_memset( psDecCtrl->LTPCoef_Q14, 0, NB_SUBFR * LTP_ORDER * sizeof( SKP_int16 ) );\r
+        SKP_assert( psDecCtrl->sigtype == SIG_TYPE_UNVOICED );\r
+        SKP_memset( psDecCtrl->pitchL,      0,             NB_SUBFR * sizeof( SKP_int   ) );\r
+        SKP_memset( psDecCtrl->LTPCoef_Q14, 0, LTP_ORDER * NB_SUBFR * sizeof( SKP_int16 ) );\r
         psDecCtrl->PERIndex      = 0;\r
         psDecCtrl->LTP_scale_Q14 = 0;\r
     }\r
diff --git a/libs/silk/src/SKP_Silk_decode_parameters_v4.c b/libs/silk/src/SKP_Silk_decode_parameters_v4.c
deleted file mode 100644 (file)
index 2770b1b..0000000
+++ /dev/null
@@ -1,157 +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
-/* Decode parameters from payload */\r
-void SKP_Silk_decode_parameters_v4(\r
-    SKP_Silk_decoder_state      *psDec,                                 /* I/O  State                                    */\r
-    SKP_Silk_decoder_control    *psDecCtrl,                             /* I/O  Decoder control                          */\r
-    SKP_int                     q[ MAX_FRAME_LENGTH ],                  /* O    Excitation signal                        */\r
-    const SKP_int               fullDecoding                            /* I    Flag to tell if only arithmetic decoding */\r
-)\r
-{\r
-    SKP_int   i, k, Ix, nBytesUsed;\r
-    SKP_int   pNLSF_Q15[ MAX_LPC_ORDER ], pNLSF0_Q15[ MAX_LPC_ORDER ];\r
-    const SKP_int16 *cbk_ptr_Q14;\r
-    const SKP_Silk_NLSF_CB_struct *psNLSF_CB = NULL;\r
-    SKP_Silk_range_coder_state  *psRC = &psDec->sRC;\r
-    \r
-    psDec->FrameTermination       = SKP_SILK_MORE_FRAMES;\r
-    psDecCtrl->sigtype            = psDec->sigtype[ psDec->nFramesDecoded ];\r
-    psDecCtrl->QuantOffsetType    = psDec->QuantOffsetType[ psDec->nFramesDecoded ];\r
-    psDec->vadFlag                = psDec->vadFlagBuf[ psDec->nFramesDecoded ];\r
-    psDecCtrl->NLSFInterpCoef_Q2  = psDec->NLSFInterpCoef_Q2[ psDec->nFramesDecoded ];\r
-    psDecCtrl->Seed               = psDec->Seed[ psDec->nFramesDecoded ];\r
-\r
-    /* Dequant Gains */\r
-    SKP_Silk_gains_dequant( psDecCtrl->Gains_Q16, psDec->GainsIndices[ psDec->nFramesDecoded ], &psDec->LastGainIndex, psDec->nFramesDecoded );\r
-    /****************/\r
-    /* Decode NLSFs */\r
-    /****************/\r
-\r
-    /* Set pointer to NLSF VQ CB for the current signal type */\r
-    psNLSF_CB = psDec->psNLSF_CB[ psDecCtrl->sigtype ];\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
-\r
-    /* Convert NLSF parameters to AR prediction filter coefficients */\r
-    SKP_Silk_NLSF2A_stable( psDecCtrl->PredCoef_Q12[ 1 ], pNLSF_Q15, psDec->LPC_order );\r
-    \r
-    /* If just reset, e.g., because internal Fs changed, do not allow interpolation */\r
-    /* improves the case of packet loss in the first frame after a switch           */\r
-    if( psDec->first_frame_after_reset == 1 ) {\r
-        psDecCtrl->NLSFInterpCoef_Q2 = 4;\r
-    }\r
-\r
-    if( psDecCtrl->NLSFInterpCoef_Q2 < 4 ) {\r
-        /* Calculation of the interpolated NLSF0 vector from the interpolation factor, */ \r
-        /* the previous NLSF1, and the current NLSF1                                   */\r
-        for( i = 0; i < psDec->LPC_order; i++ ) {\r
-            pNLSF0_Q15[ i ] = psDec->prevNLSF_Q15[ i ] + SKP_RSHIFT( SKP_MUL( psDecCtrl->NLSFInterpCoef_Q2, \r
-                ( pNLSF_Q15[ i ] - psDec->prevNLSF_Q15[ i ] ) ), 2 );\r
-        }\r
-\r
-        /* Convert NLSF parameters to AR prediction filter coefficients */\r
-        SKP_Silk_NLSF2A_stable( psDecCtrl->PredCoef_Q12[ 0 ], pNLSF0_Q15, psDec->LPC_order );\r
-    } else {\r
-        /* Copy LPC coefficients for first half from second half */\r
-        SKP_memcpy( psDecCtrl->PredCoef_Q12[ 0 ], psDecCtrl->PredCoef_Q12[ 1 ], \r
-            psDec->LPC_order * sizeof( SKP_int16 ) );\r
-    }\r
-\r
-    SKP_memcpy( psDec->prevNLSF_Q15, pNLSF_Q15, psDec->LPC_order * sizeof( SKP_int ) );\r
-\r
-    /* After a packet loss do BWE of LPC coefs */\r
-    if( psDec->lossCnt ) {\r
-        SKP_Silk_bwexpander( psDecCtrl->PredCoef_Q12[ 0 ], psDec->LPC_order, BWE_AFTER_LOSS_Q16 );\r
-        SKP_Silk_bwexpander( psDecCtrl->PredCoef_Q12[ 1 ], psDec->LPC_order, BWE_AFTER_LOSS_Q16 );\r
-    }\r
-\r
-    if( psDecCtrl->sigtype == SIG_TYPE_VOICED ) {\r
-        /*********************/\r
-        /* Decode pitch lags */\r
-        /*********************/\r
-        \r
-        /* Decode pitch values */\r
-        SKP_Silk_decode_pitch( psDec->lagIndex[ psDec->nFramesDecoded ], \r
-            psDec->contourIndex[ psDec->nFramesDecoded ], psDecCtrl->pitchL, psDec->fs_kHz );\r
-\r
-        /********************/\r
-        /* Decode LTP gains */\r
-        /********************/\r
-        psDecCtrl->PERIndex = psDec->PERIndex[ psDec->nFramesDecoded ];\r
-        \r
-        /* Decode Codebook Index */\r
-        cbk_ptr_Q14 = SKP_Silk_LTP_vq_ptrs_Q14[ psDecCtrl->PERIndex ]; /* set pointer to start of codebook */\r
-\r
-        for( k = 0; k < NB_SUBFR; k++ ) {\r
-            Ix = psDec->LTPIndex[ psDec->nFramesDecoded ][ k ];\r
-            for( i = 0; i < LTP_ORDER; i++ ) {\r
-                psDecCtrl->LTPCoef_Q14[ SKP_SMULBB( k, LTP_ORDER ) + i ] = cbk_ptr_Q14[ SKP_SMULBB( Ix, LTP_ORDER ) + i ];\r
-            }\r
-        }\r
-\r
-        /**********************/\r
-        /* Decode LTP scaling */\r
-        /**********************/\r
-        Ix = psDec->LTP_scaleIndex[ psDec->nFramesDecoded ];\r
-        psDecCtrl->LTP_scale_Q14 = SKP_Silk_LTPScales_table_Q14[ Ix ];\r
-    } else {\r
-        SKP_memset( psDecCtrl->pitchL,      0, NB_SUBFR * sizeof( SKP_int ) );\r
-        SKP_memset( psDecCtrl->LTPCoef_Q14, 0, NB_SUBFR * LTP_ORDER * sizeof( SKP_int16 ) );\r
-        psDecCtrl->PERIndex      = 0;\r
-        psDecCtrl->LTP_scale_Q14 = 0;\r
-    }\r
-\r
-    /*********************************************/\r
-    /* Decode quantization indices of excitation */\r
-    /*********************************************/\r
-    SKP_Silk_decode_pulses( psRC, psDecCtrl, q, psDec->frame_length );\r
-\r
-    /****************************************/\r
-    /* get number of bytes used so far      */\r
-    /****************************************/\r
-    SKP_Silk_range_coder_get_length( psRC, &nBytesUsed );\r
-    psDec->nBytesLeft = psRC->bufferLength - nBytesUsed;\r
-    if( psDec->nBytesLeft < 0 ) {\r
-        psRC->error = RANGE_CODER_READ_BEYOND_BUFFER;\r
-    }\r
-\r
-    /****************************************/\r
-    /* check remaining bits in last byte    */\r
-    /****************************************/\r
-    if( psDec->nBytesLeft == 0 ) {\r
-        SKP_Silk_range_coder_check_after_decoding( psRC );\r
-    }\r
-\r
-    if( psDec->nFramesInPacket == (psDec->nFramesDecoded + 1)) {\r
-        /* To indicate the packet has been fully decoded */\r
-        psDec->FrameTermination = SKP_SILK_LAST_FRAME;\r
-    }\r
-}\r
index 402228ab8127378575477d416380b4cebf568c72..5b092169bf1659d67cf727212cbf73176e9e9e02 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
index 824a84b30e01efdcd3913081d225462cbf7eca61..c093d9aa3809adf982f8a336bee808c9f6e1fad5 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -47,11 +47,10 @@ void SKP_Silk_decoder_set_fs(
             psDec->psNLSF_CB[ 1 ] = &SKP_Silk_NLSF_CB1_16;\r
         }\r
         /* Reset part of the decoder state */\r
-        SKP_memset( psDec->sLPC_Q14,     0, MAX_LPC_ORDER      * sizeof( SKP_int32 ) );\r
-        SKP_memset( psDec->outBuf,       0, MAX_FRAME_LENGTH   * sizeof( SKP_int16 ) );\r
-        SKP_memset( psDec->prevNLSF_Q15, 0, MAX_LPC_ORDER      * sizeof( SKP_int )   );\r
+        SKP_memset( psDec->sLPC_Q14,     0, MAX_LPC_ORDER    * sizeof( SKP_int32 ) );\r
+        SKP_memset( psDec->outBuf,       0, MAX_FRAME_LENGTH * sizeof( SKP_int16 ) );\r
+        SKP_memset( psDec->prevNLSF_Q15, 0, MAX_LPC_ORDER    * sizeof( SKP_int )   );\r
 \r
-        psDec->sLTP_buf_idx            = 0;\r
         psDec->lagPrev                 = 100;\r
         psDec->LastGainIndex           = 1;\r
         psDec->prev_sigtype            = 0;\r
index 27d20ca1a1858cd219eea4d9088da0c9b87caef5..d7ed59295388e17db874d08981e563aebeae22bc 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -38,26 +38,18 @@ extern "C"
 \r
 \r
 #define MAX_FRAMES_PER_PACKET                   5\r
-#define BIT_STREAM_V3                           3\r
-#define BIT_STREAM_V4                           4\r
-#define USE_BIT_STREAM_V                        BIT_STREAM_V3 // Should be moved to a API call\r
 \r
 \r
-/* MAX DELTA LAG used for multiframe packets */\r
-#define MAX_DELTA_LAG                           10\r
 \r
-/* Lower limit on bitrate for each mode */\r
-#define MIN_TARGET_RATE_NB_BPS                  5000\r
-#define MIN_TARGET_RATE_MB_BPS                  7000\r
-#define MIN_TARGET_RATE_WB_BPS                  8000\r
-#define MIN_TARGET_RATE_SWB_BPS                 20000\r
+/* Limits on bitrate */\r
+#define MIN_TARGET_RATE_BPS                     5000\r
+#define MAX_TARGET_RATE_BPS                     100000\r
 \r
 /* Transition bitrates between modes */\r
-#define SWB2WB_BITRATE_BPS                      30000\r
-#define SWB2WB_BITRATE_BPS_INITIAL              25000\r
-#define WB2SWB_BITRATE_BPS                      35000\r
-#define WB2MB_BITRATE_BPS                       15000\r
-#define MB2WB_BITRATE_BPS                       20000\r
+#define SWB2WB_BITRATE_BPS                      25000\r
+#define WB2SWB_BITRATE_BPS                      30000\r
+#define WB2MB_BITRATE_BPS                       14000\r
+#define MB2WB_BITRATE_BPS                       18000\r
 #define MB2NB_BITRATE_BPS                       10000\r
 #define NB2MB_BITRATE_BPS                       14000\r
 \r
@@ -80,7 +72,7 @@ extern "C"
 #define LBRR_IDX_MASK                           1\r
 \r
 #define INBAND_FEC_MIN_RATE_BPS                 18000  /* Dont use inband FEC below this total target rate  */\r
-#define LBRR_LOSS_THRES                         2   /* Start adding LBRR at this loss rate (needs tuning)   */\r
+#define LBRR_LOSS_THRES                         1   /* Start adding LBRR at this loss rate                  */\r
 \r
 /* LBRR usage defines */\r
 #define SKP_SILK_NO_LBRR                        0   /* No LBRR information for this packet                  */\r
@@ -101,28 +93,17 @@ extern "C"
 #define WB_DETECT_ACTIVE_SPEECH_MS_THRES        15000       /* ms of active speech needed for WB detection  */\r
 \r
 /* Low complexity setting */\r
-#ifdef EMBEDDED_OPT\r
-#   define LOW_COMPLEXITY_ONLY                  1\r
-#else\r
-#   define LOW_COMPLEXITY_ONLY                  0\r
-#endif\r
+#define LOW_COMPLEXITY_ONLY                     0\r
 \r
 /* Activate bandwidth transition filtering for mode switching */\r
-#ifdef EMBEDDED_OPT\r
-#   define SWITCH_TRANSITION_FILTERING          0\r
-#else\r
-#ifndef FORCE_FS_KHZ \r
-#   define SWITCH_TRANSITION_FILTERING          1\r
-#else\r
-#   define SWITCH_TRANSITION_FILTERING          0\r
-#endif\r
-#endif\r
+#define SWITCH_TRANSITION_FILTERING             1\r
 \r
 /* Decoder Parameters */\r
 #define DEC_HP_ORDER                            2\r
 \r
-/* Maximum sampling frequency, should be 16 for embedded */\r
+/* Maximum sampling frequency, should be 16 for some embedded platforms */\r
 #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
@@ -132,29 +113,31 @@ extern "C"
 #define NO_VOICE_ACTIVITY                       0\r
 #define VOICE_ACTIVITY                          1\r
 \r
-/* number of samples per frame */ \r
-#define FRAME_LENGTH_MS                         20 /* 20 ms */\r
-#define MAX_FRAME_LENGTH                        (FRAME_LENGTH_MS * MAX_FS_KHZ)\r
+/* Number of samples per frame */ \r
+#define FRAME_LENGTH_MS                         20\r
+#define MAX_FRAME_LENGTH                        ( FRAME_LENGTH_MS * MAX_FS_KHZ )\r
 \r
-/* number of lookahead samples for pitch analysis */\r
-#define LA_PITCH_MS                             3\r
-#define LA_PITCH_MAX                            (LA_PITCH_MS * MAX_FS_KHZ)\r
+/* Milliseconds of lookahead for pitch analysis */\r
+#define LA_PITCH_MS                             2\r
+#define LA_PITCH_MAX                            ( LA_PITCH_MS * MAX_FS_KHZ )\r
 \r
-/* number of lookahead samples for noise shape analysis */\r
-#define LA_SHAPE_MS                             5\r
-#define LA_SHAPE_MAX                            (LA_SHAPE_MS * MAX_FS_KHZ)\r
+/* Length of LPC window used in find pitch */\r
+#define FIND_PITCH_LPC_WIN_MS                   ( 20 + (LA_PITCH_MS << 1) )\r
+#define FIND_PITCH_LPC_WIN_MAX                  ( FIND_PITCH_LPC_WIN_MS * MAX_FS_KHZ )\r
 \r
 /* Order of LPC used in find pitch */\r
-#define FIND_PITCH_LPC_ORDER_MAX                16\r
+#define MAX_FIND_PITCH_LPC_ORDER                16\r
 \r
-/* Length of LPC window used in find pitch */\r
-#define FIND_PITCH_LPC_WIN_MS                   (30 + (LA_PITCH_MS << 1))\r
-#define FIND_PITCH_LPC_WIN_MAX                  (FIND_PITCH_LPC_WIN_MS * MAX_FS_KHZ)\r
+#define PITCH_EST_COMPLEXITY_HC_MODE            SKP_Silk_PITCH_EST_MAX_COMPLEX\r
+#define PITCH_EST_COMPLEXITY_MC_MODE            SKP_Silk_PITCH_EST_MID_COMPLEX\r
+#define PITCH_EST_COMPLEXITY_LC_MODE            SKP_Silk_PITCH_EST_MIN_COMPLEX\r
 \r
-#define PITCH_EST_COMPLEXITY_HC_MODE            SigProc_PITCH_EST_MAX_COMPLEX\r
-#define PITCH_EST_COMPLEXITY_MC_MODE            SigProc_PITCH_EST_MID_COMPLEX\r
-#define PITCH_EST_COMPLEXITY_LC_MODE            SigProc_PITCH_EST_MIN_COMPLEX\r
+/* Milliseconds of lookahead for noise shape analysis */\r
+#define LA_SHAPE_MS                             5\r
+#define LA_SHAPE_MAX                            ( LA_SHAPE_MS * MAX_FS_KHZ )\r
 \r
+/* Max length of LPC window used in noise shape analysis */\r
+#define SHAPE_LPC_WIN_MAX                       ( 15 * MAX_FS_KHZ )\r
 \r
 /* Max number of bytes in payload output buffer (may contain multiple frames) */\r
 #define MAX_ARITHM_BYTES                        1024\r
@@ -204,18 +187,12 @@ extern "C"
 #define USE_HARM_SHAPING                        1\r
 \r
 /* Max LPC order of noise shaping filters */\r
-#define SHAPE_LPC_ORDER_MAX                     16\r
+#define MAX_SHAPE_LPC_ORDER                     16\r
 \r
 #define HARM_SHAPE_FIR_TAPS                     3\r
 \r
-/* Length of LPC window used in noise shape analysis */\r
-#define SHAPE_LPC_WIN_MS                        15\r
-#define SHAPE_LPC_WIN_16_KHZ                    (SHAPE_LPC_WIN_MS * 16)\r
-#define SHAPE_LPC_WIN_24_KHZ                    (SHAPE_LPC_WIN_MS * 24)\r
-#define SHAPE_LPC_WIN_MAX                       (SHAPE_LPC_WIN_MS * MAX_FS_KHZ)\r
-\r
 /* Maximum number of delayed decision states */\r
-#define DEL_DEC_STATES_MAX                      4\r
+#define MAX_DEL_DEC_STATES                      4\r
 \r
 #define LTP_BUF_LENGTH                          512\r
 #define LTP_MASK                                (LTP_BUF_LENGTH - 1)\r
@@ -249,12 +226,12 @@ extern "C"
 /***************************/\r
 /* Voice activity detector */\r
 /***************************/\r
-#define VAD_N_BANDS                             4       /* 0-1, 1-2, 2-4, and 4-8 kHz                       */\r
+#define VAD_N_BANDS                             4\r
 \r
 #define VAD_INTERNAL_SUBFRAMES_LOG2             2\r
 #define VAD_INTERNAL_SUBFRAMES                  (1 << VAD_INTERNAL_SUBFRAMES_LOG2)\r
     \r
-#define VAD_NOISE_LEVEL_SMOOTH_COEF_Q16         1024    /* Must be <  4096                                  */\r
+#define VAD_NOISE_LEVEL_SMOOTH_COEF_Q16         1024    /* Must be < 4096                                   */\r
 #define VAD_NOISE_LEVELS_BIAS                   50 \r
 \r
 /* Sigmoid settings */\r
@@ -267,15 +244,9 @@ extern "C"
 /******************/\r
 /* NLSF quantizer */\r
 /******************/\r
-#ifdef NLSF_TRAINING\r
-#   define NLSF_MSVQ_MAX_CB_STAGES                      30 \r
-#   define NLSF_MSVQ_MAX_VECTORS_IN_STAGE               256\r
-#   define NLSF_MSVQ_MAX_VECTORS_IN_STAGE_TWO_TO_END    128\r
-#else\r
 #   define NLSF_MSVQ_MAX_CB_STAGES                      10  /* Update manually when changing codebooks      */\r
 #   define NLSF_MSVQ_MAX_VECTORS_IN_STAGE               128 /* Update manually when changing codebooks      */\r
 #   define NLSF_MSVQ_MAX_VECTORS_IN_STAGE_TWO_TO_END    16  /* Update manually when changing codebooks      */\r
-#endif\r
 \r
 #define NLSF_MSVQ_FLUCTUATION_REDUCTION         1\r
 #define MAX_NLSF_MSVQ_SURVIVORS                 16\r
@@ -295,19 +266,19 @@ extern "C"
 #   define NLSF_MSVQ_TREE_SEARCH_MAX_VECTORS_EVALUATED  MAX_NLSF_MSVQ_SURVIVORS * NLSF_MSVQ_MAX_VECTORS_IN_STAGE_TWO_TO_END\r
 #endif\r
 \r
-#define NLSF_MSVQ_SURV_MAX_REL_RD               4\r
+#define NLSF_MSVQ_SURV_MAX_REL_RD               0.1f    /* Must be < 0.5                                    */\r
 \r
 /* Transition filtering for mode switching */\r
 #if SWITCH_TRANSITION_FILTERING\r
-#  define TRANSITION_TIME_UP_MS             5120 // 5120 = 64 * FRAME_LENGTH_MS * ( TRANSITION_INT_NUM - 1 ) = 64*(20*4)\r
-#  define TRANSITION_TIME_DOWN_MS           2560 // 2560 = 32 * FRAME_LENGTH_MS * ( TRANSITION_INT_NUM - 1 ) = 32*(20*4)\r
-#  define TRANSITION_NB                     3 /* Hardcoded in tables */\r
-#  define TRANSITION_NA                     2 /* Hardcoded in tables */\r
-#  define TRANSITION_INT_NUM                5 /* Hardcoded in tables */\r
-#  define TRANSITION_FRAMES_UP          ( TRANSITION_TIME_UP_MS   / FRAME_LENGTH_MS )\r
-#  define TRANSITION_FRAMES_DOWN        ( TRANSITION_TIME_DOWN_MS / FRAME_LENGTH_MS )\r
-#  define TRANSITION_INT_STEPS_UP       ( TRANSITION_FRAMES_UP    / ( TRANSITION_INT_NUM - 1 )  )\r
-#  define TRANSITION_INT_STEPS_DOWN     ( TRANSITION_FRAMES_DOWN  / ( TRANSITION_INT_NUM - 1 )  )\r
+#  define TRANSITION_TIME_UP_MS                 5120 // 5120 = 64 * FRAME_LENGTH_MS * ( TRANSITION_INT_NUM - 1 ) = 64*(20*4)\r
+#  define TRANSITION_TIME_DOWN_MS               2560 // 2560 = 32 * FRAME_LENGTH_MS * ( TRANSITION_INT_NUM - 1 ) = 32*(20*4)\r
+#  define TRANSITION_NB                         3 /* Hardcoded in tables */\r
+#  define TRANSITION_NA                         2 /* Hardcoded in tables */\r
+#  define TRANSITION_INT_NUM                    5 /* Hardcoded in tables */\r
+#  define TRANSITION_FRAMES_UP                  ( TRANSITION_TIME_UP_MS   / FRAME_LENGTH_MS )\r
+#  define TRANSITION_FRAMES_DOWN                ( TRANSITION_TIME_DOWN_MS / FRAME_LENGTH_MS )\r
+#  define TRANSITION_INT_STEPS_UP               ( TRANSITION_FRAMES_UP    / ( TRANSITION_INT_NUM - 1 )  )\r
+#  define TRANSITION_INT_STEPS_DOWN             ( TRANSITION_FRAMES_DOWN  / ( TRANSITION_INT_NUM - 1 )  )\r
 #endif\r
 \r
 /* Row based */\r
@@ -321,7 +292,12 @@ extern "C"
 #define matrix_c_adr(Matrix_base_adr, row, column, M)        (Matrix_base_adr + ((row)+(M)*(column)))\r
 \r
 /* BWE factors to apply after packet loss */\r
-#define BWE_AFTER_LOSS_Q16                              63570\r
+#define BWE_AFTER_LOSS_Q16                      63570\r
+\r
+/* Defines for CN generation */\r
+#define CNG_BUF_MASK_MAX                        255             /* 2^floor(log2(MAX_FRAME_LENGTH))-1    */\r
+#define CNG_GAIN_SMTH_Q16                       4634            /* 0.25^(1/4)                           */\r
+#define CNG_NLSF_SMTH_Q16                       16348           /* 0.25                                 */\r
 \r
 #ifdef __cplusplus\r
 }\r
diff --git a/libs/silk/src/SKP_Silk_define_FIX.h b/libs/silk/src/SKP_Silk_define_FIX.h
deleted file mode 100644 (file)
index ff42ace..0000000
+++ /dev/null
@@ -1,97 +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
-#ifndef SKP_SILK_DEFINE_FIX_H\r
-#define SKP_SILK_DEFINE_FIX_H\r
-\r
-#ifdef __cplusplus\r
-extern "C"\r
-{\r
-#endif\r
-\r
-/* Head room for correlations                           */\r
-#define LTP_CORRS_HEAD_ROOM                             2\r
-#define LPC_CORRS_HEAD_ROOM                             10\r
-\r
-#define WB_DETECT_ACTIVE_SPEECH_LEVEL_THRES_Q8          179     // 179.2_Q8 = 0.7f required speech activity for counting frame as active\r
-\r
-/* DTX settings */\r
-#define SPEECH_ACTIVITY_DTX_THRES_Q8                    26      // 25.60_Q8 = 0.1f\r
-\r
-#define LBRR_SPEECH_ACTIVITY_THRES_Q8                   128\r
-\r
-/* level of noise floor for whitening filter LPC analysis in pitch analysis */\r
-#define FIND_PITCH_WHITE_NOISE_FRACTION_Q16             66\r
-\r
-/* bandwdith expansion for whitening filter in pitch analysis */\r
-#define FIND_PITCH_BANDWITH_EXPANSION_Q16               64881\r
-\r
-/* Threshold used by pitch estimator for early escape */\r
-#define FIND_PITCH_CORRELATION_THRESHOLD_Q16_HC_MODE    45875       // 0.7\r
-#define FIND_PITCH_CORRELATION_THRESHOLD_Q16_MC_MODE    49152       // 0.75\r
-#define FIND_PITCH_CORRELATION_THRESHOLD_Q16_LC_MODE    52429       // 0.8\r
-\r
-/* Regualarization factor for correlation matrix. Equivalent to adding noise at -50 dB */\r
-#define FIND_LTP_COND_FAC_Q31                           21475\r
-#define FIND_LPC_COND_FAC_Q32                           257698       // 6e-5\r
-\r
-/* Find Pred Coef defines */\r
-#define INACTIVE_BWExp_Q16                              64225       // 0.98\r
-#define ACTIVE_BWExp_Q16                                65470       // 0.999\r
-#define LTP_DAMPING_Q16                                 66\r
-#define LTP_SMOOTHING_Q26                               6710886\r
-\r
-/* LTP quantization settings */\r
-#define MU_LTP_QUANT_NB_Q8                              8\r
-#define MU_LTP_QUANT_MB_Q8                              6\r
-#define MU_LTP_QUANT_WB_Q8                              5\r
-#define MU_LTP_QUANT_SWB_Q8                             4\r
-\r
-/***********************/\r
-/* High pass filtering */\r
-/***********************/\r
-/* Smoothing parameters for low end of pitch frequency range estimation */\r
-#define VARIABLE_HP_SMTH_COEF1_Q16                      6554    // 0.1\r
-#define VARIABLE_HP_SMTH_COEF2_Q16                      983     // 0.015\r
-\r
-/* Min and max values for low end of pitch frequency range estimation */\r
-#define VARIABLE_HP_MIN_FREQ_Q0                         80\r
-#define VARIABLE_HP_MAX_FREQ_Q0                         150\r
-\r
-/* Max absolute difference between log2 of pitch frequency and smoother state, to enter the smoother */\r
-#define VARIABLE_HP_MAX_DELTA_FREQ_Q7                   51      // 0.4 in Q7\r
-\r
-/* Defines for CN generation */\r
-#define CNG_BUF_MASK_MAX                                255             /* 2^floor(log2(MAX_FRAME_LENGTH))  */\r
-#define CNG_GAIN_SMTH_Q16                               4634            /* 0.25^(1/4)                       */\r
-#define CNG_NLSF_SMTH_Q16                               16348           /* 0.25                             */\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-#endif\r
index c251cea8ff4e4e2e32dbe85019a85e1bb4bf2e9b..bab84509e2c73cfcf7599c94fba6d13f2fa4cb63 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -37,9 +37,9 @@ void SKP_Silk_detect_SWB_input(
     SKP_int                     nSamplesIn      /* (I) length of input */\r
 )\r
 {\r
-    SKP_int     HP_8_kHz_len, i;\r
+    SKP_int     HP_8_kHz_len, i, shift;\r
     SKP_int16   in_HP_8_kHz[ MAX_FRAME_LENGTH ];\r
-    SKP_int32   energy_32, shift;\r
+    SKP_int32   energy_32;\r
     \r
     /* High pass filter with cutoff at 8 khz */\r
     HP_8_kHz_len = SKP_min_int( nSamplesIn, MAX_FRAME_LENGTH );\r
index 0bf6038cf9e54eb4527d8b3b451aa681a3fac4e1..232e31aa5ff88c90f18ce5cbda5a27e22ef25f76 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -38,7 +38,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 /* Encoder functions                    */\r
 /****************************************/\r
 \r
-SKP_int SKP_Silk_SDK_Get_Encoder_Size( SKP_int *encSizeBytes )\r
+SKP_int SKP_Silk_SDK_Get_Encoder_Size( SKP_int32 *encSizeBytes )\r
 {\r
     SKP_int ret = 0;\r
     \r
@@ -57,16 +57,18 @@ SKP_int SKP_Silk_SDK_QueryEncoder(
 )\r
 {\r
     SKP_Silk_encoder_state_FIX *psEnc;\r
-    SKP_int ret = 0;    \r
+    SKP_int ret = 0;\r
 \r
     psEnc = ( SKP_Silk_encoder_state_FIX* )encState;\r
 \r
-    encStatus->sampleRate = ( unsigned short )SKP_SMULBB( psEnc->sCmn.fs_kHz, 1000 );                       /* convert kHz -> Hz */ \r
-    encStatus->packetSize = ( unsigned short )SKP_SMULBB( psEnc->sCmn.fs_kHz, psEnc->sCmn.PacketSize_ms );  /* convert samples -> ms */\r
-    encStatus->bitRate    = ( unsigned short )psEnc->sCmn.TargetRate_bps;\r
-    encStatus->packetLossPercentage = psEnc->sCmn.PacketLoss_perc;\r
-    encStatus->complexity           = psEnc->sCmn.Complexity;\r
-\r
+    encStatus->API_sampleRate        = psEnc->sCmn.API_fs_Hz;\r
+    encStatus->maxInternalSampleRate = SKP_SMULBB( psEnc->sCmn.maxInternal_fs_kHz, 1000 );\r
+    encStatus->packetSize            = ( SKP_int )SKP_DIV32_16( psEnc->sCmn.API_fs_Hz * psEnc->sCmn.PacketSize_ms, 1000 );  /* convert samples -> ms */\r
+    encStatus->bitRate               = psEnc->sCmn.TargetRate_bps;\r
+    encStatus->packetLossPercentage  = psEnc->sCmn.PacketLoss_perc;\r
+    encStatus->complexity            = psEnc->sCmn.Complexity;\r
+    encStatus->useInBandFEC          = psEnc->sCmn.useInBandFEC;\r
+    encStatus->useDTX                = psEnc->sCmn.useDTX;\r
     return ret;\r
 }\r
 \r
@@ -89,7 +91,7 @@ SKP_int SKP_Silk_SDK_InitEncoder(
         SKP_assert( 0 );\r
     }\r
 \r
-    /* Read Control structure */\r
+    /* Read control structure */\r
     if( ret += SKP_Silk_SDK_QueryEncoder( encState, encStatus ) ) {\r
         SKP_assert( 0 );\r
     }\r
@@ -110,131 +112,101 @@ SKP_int SKP_Silk_SDK_Encode(
     SKP_int16                           *nBytesOut      /* I/O: Number of bytes in outData (input: Max bytes)   */\r
 )\r
 {\r
-    SKP_int   API_fs_kHz, PacketSize_ms, PacketLoss_perc, UseInBandFec, UseDTX, ret = 0;\r
-    SKP_int   nSamplesToBuffer, Complexity, input_ms, nSamplesFromInput = 0;\r
-    SKP_int32 TargetRate_bps;\r
+    SKP_int   max_internal_fs_kHz, PacketSize_ms, PacketLoss_perc, UseInBandFEC, UseDTX, ret = 0;\r
+    SKP_int   nSamplesToBuffer, Complexity, input_10ms, nSamplesFromInput = 0;\r
+    SKP_int32 TargetRate_bps, API_fs_Hz;\r
     SKP_int16 MaxBytesOut;\r
     SKP_Silk_encoder_state_FIX *psEnc = ( SKP_Silk_encoder_state_FIX* )encState;\r
 \r
-\r
     SKP_assert( encControl != NULL );\r
 \r
     /* Check sampling frequency first, to avoid divide by zero later */\r
-    if( ( encControl->sampleRate !=  8000 ) && ( encControl->sampleRate != 12000 ) && \r
-        ( encControl->sampleRate != 16000 ) && ( encControl->sampleRate != 24000 ) ) {\r
+    if( ( ( encControl->API_sampleRate        !=  8000 ) &&\r
+          ( encControl->API_sampleRate        != 12000 ) &&\r
+          ( encControl->API_sampleRate        != 16000 ) &&\r
+          ( encControl->API_sampleRate        != 24000 ) && \r
+          ( encControl->API_sampleRate        != 32000 ) &&\r
+          ( encControl->API_sampleRate        != 44100 ) &&\r
+          ( encControl->API_sampleRate        != 48000 ) ) ||\r
+        ( ( encControl->maxInternalSampleRate !=  8000 ) &&\r
+          ( encControl->maxInternalSampleRate != 12000 ) &&\r
+          ( encControl->maxInternalSampleRate != 16000 ) &&\r
+          ( encControl->maxInternalSampleRate != 24000 ) ) ) {\r
         ret = SKP_SILK_ENC_FS_NOT_SUPPORTED;\r
         SKP_assert( 0 );\r
         return( ret );\r
     }\r
 \r
-    /* Set Encoder parameters from Control structure */\r
-    API_fs_kHz      = SKP_DIV32_16( ( SKP_int )encControl->sampleRate, 1000 );          /* convert Hz -> kHz */\r
-    PacketSize_ms   = SKP_DIV32_16( ( SKP_int )encControl->packetSize, API_fs_kHz );    /* convert samples -> ms */\r
-    TargetRate_bps  =             ( SKP_int32 )encControl->bitRate;\r
-    PacketLoss_perc =               ( SKP_int )encControl->packetLossPercentage;\r
-    UseInBandFec    =               ( SKP_int )encControl->useInBandFEC;\r
-    Complexity      =               ( SKP_int )encControl->complexity;\r
-    UseDTX          =               ( SKP_int )encControl->useDTX;\r
-\r
-    /* Only accept input lengths that are multiplum of 10 ms */\r
-    input_ms = SKP_DIV32_16( nSamplesIn, API_fs_kHz );\r
-    if( ( input_ms % 10) != 0 || nSamplesIn < 0 ) {\r
+    /* Set encoder parameters from control structure */\r
+    API_fs_Hz           =                            encControl->API_sampleRate;\r
+    max_internal_fs_kHz =                 (SKP_int)( encControl->maxInternalSampleRate >> 10 ) + 1;   /* convert Hz -> kHz */\r
+    PacketSize_ms       = SKP_DIV32( 1000 * (SKP_int)encControl->packetSize, API_fs_Hz );\r
+    TargetRate_bps      =                            encControl->bitRate;\r
+    PacketLoss_perc     =                            encControl->packetLossPercentage;\r
+    UseInBandFEC        =                            encControl->useInBandFEC;\r
+    Complexity          =                            encControl->complexity;\r
+    UseDTX              =                            encControl->useDTX;\r
+\r
+    /* Save values in state */\r
+    psEnc->sCmn.API_fs_Hz          = API_fs_Hz;\r
+    psEnc->sCmn.maxInternal_fs_kHz = max_internal_fs_kHz;\r
+    psEnc->sCmn.useInBandFEC       = UseInBandFEC;\r
+\r
+    /* Only accept input lengths that are a multiple of 10 ms */\r
+    input_10ms = SKP_DIV32( 100 * nSamplesIn, API_fs_Hz );\r
+    if( input_10ms * API_fs_Hz != 100 * nSamplesIn || nSamplesIn < 0 ) {\r
         ret = SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES;\r
         SKP_assert( 0 );\r
         return( ret );\r
     }\r
 \r
-    /* Make sure no more than one packet can be produced */\r
-    if( nSamplesIn > SKP_SMULBB( psEnc->sCmn.PacketSize_ms, API_fs_kHz ) ) {\r
-        ret = SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES;\r
+    TargetRate_bps = SKP_LIMIT( TargetRate_bps, MIN_TARGET_RATE_BPS, MAX_TARGET_RATE_BPS );\r
+    if( ( ret = SKP_Silk_control_encoder_FIX( psEnc, PacketSize_ms, TargetRate_bps, \r
+                        PacketLoss_perc, UseDTX, Complexity) ) != 0 ) {\r
         SKP_assert( 0 );\r
         return( ret );\r
     }\r
 \r
-    if( ( ret = SKP_Silk_control_encoder_FIX( psEnc, API_fs_kHz, PacketSize_ms, TargetRate_bps, \r
-                    PacketLoss_perc, UseInBandFec, UseDTX, input_ms, Complexity ) ) != 0 ) {\r
+    /* Make sure no more than one packet can be produced */\r
+    if( 1000 * (SKP_int32)nSamplesIn > psEnc->sCmn.PacketSize_ms * API_fs_Hz ) {\r
+        ret = SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES;\r
         SKP_assert( 0 );\r
         return( ret );\r
     }\r
 \r
+#if MAX_FS_KHZ > 16\r
     /* Detect energy above 8 kHz */\r
-    if( encControl->sampleRate == 24000 && psEnc->sCmn.sSWBdetect.SWB_detected == 0 && psEnc->sCmn.sSWBdetect.WB_detected == 0 ) {\r
+    if( SKP_min( API_fs_Hz, 1000 * max_internal_fs_kHz ) == 24000 && \r
+            psEnc->sCmn.sSWBdetect.SWB_detected == 0 && \r
+            psEnc->sCmn.sSWBdetect.WB_detected == 0 ) {\r
         SKP_Silk_detect_SWB_input( &psEnc->sCmn.sSWBdetect, samplesIn, ( SKP_int )nSamplesIn );\r
     }\r
+#endif\r
 \r
     /* Input buffering/resampling and encoding */\r
     MaxBytesOut = 0;                    /* return 0 output bytes if no encoder called */\r
     while( 1 ) {\r
-        /* Resample/buffer */\r
         nSamplesToBuffer = psEnc->sCmn.frame_length - psEnc->sCmn.inputBufIx;\r
-        if( encControl->sampleRate == SKP_SMULBB( psEnc->sCmn.fs_kHz, 1000 ) ) { \r
-            /* Same sample frequency - copy the data */\r
+        if( API_fs_Hz == SKP_SMULBB( 1000, psEnc->sCmn.fs_kHz ) ) { \r
             nSamplesToBuffer  = SKP_min_int( nSamplesToBuffer, nSamplesIn );\r
             nSamplesFromInput = nSamplesToBuffer;\r
-            SKP_memcpy( &psEnc->sCmn.inputBuf[ psEnc->sCmn.inputBufIx ], samplesIn, SKP_SMULBB( nSamplesToBuffer, sizeof( SKP_int16 ) ) );\r
-        } else if( encControl->sampleRate == 24000 && psEnc->sCmn.fs_kHz == 16 ) {\r
-            /* Resample the data from 24 kHz to 16 kHz */\r
-            nSamplesToBuffer  = SKP_min_int( nSamplesToBuffer, SKP_SMULWB( SKP_LSHIFT( nSamplesIn, 1 ), 21846 ) ); // 21846 = ceil(2/3)*2^15\r
-            nSamplesFromInput = SKP_RSHIFT( SKP_SMULBB( nSamplesToBuffer, 3 ), 1 );\r
-#if LOW_COMPLEXITY_ONLY\r
-            {\r
-                SKP_int16 scratch[ MAX_FRAME_LENGTH + SigProc_Resample_2_3_coarse_NUM_FIR_COEFS - 1 ];\r
-                SKP_assert( nSamplesFromInput <= MAX_FRAME_LENGTH );\r
-                SKP_Silk_resample_2_3_coarse( &psEnc->sCmn.inputBuf[ psEnc->sCmn.inputBufIx ], psEnc->sCmn.resample24To16state, \r
-                    samplesIn, nSamplesFromInput, scratch );\r
-            }\r
-#else\r
-            SKP_Silk_resample_2_3( &psEnc->sCmn.inputBuf[ psEnc->sCmn.inputBufIx ], psEnc->sCmn.resample24To16state, \r
-                samplesIn, nSamplesFromInput );\r
-#endif\r
-        } else if( encControl->sampleRate == 24000 && psEnc->sCmn.fs_kHz == 12 ) {\r
-            SKP_int32 scratch[ 3 * MAX_FRAME_LENGTH ];\r
-            /* Resample the data from 24 kHz to 12 kHz */\r
-            nSamplesToBuffer  = SKP_min_int( nSamplesToBuffer, SKP_RSHIFT( nSamplesIn, 1 ) );\r
-            nSamplesFromInput = SKP_LSHIFT16( nSamplesToBuffer, 1 );\r
-            SKP_Silk_resample_1_2_coarse( samplesIn, psEnc->sCmn.resample24To12state, \r
-                &psEnc->sCmn.inputBuf[ psEnc->sCmn.inputBufIx ], scratch, nSamplesToBuffer );\r
-        } else if( encControl->sampleRate == 24000 && psEnc->sCmn.fs_kHz == 8 ) {\r
-            /* Resample the data from 24 kHz to 8 kHz */\r
-            nSamplesToBuffer  = SKP_min_int( nSamplesToBuffer, SKP_DIV32_16( nSamplesIn, 3 ) );\r
-            nSamplesFromInput = SKP_SMULBB( nSamplesToBuffer, 3 );\r
-            SKP_Silk_resample_1_3( &psEnc->sCmn.inputBuf[ psEnc->sCmn.inputBufIx ], psEnc->sCmn.resample24To8state, \r
-                samplesIn, nSamplesFromInput);\r
-        } else if( encControl->sampleRate == 16000 && psEnc->sCmn.fs_kHz == 12 ) {\r
-            /* Resample the data from 16 kHz to 12 kHz */\r
-            nSamplesToBuffer  = SKP_min_int( nSamplesToBuffer, SKP_RSHIFT( SKP_SMULBB( nSamplesIn, 3 ), 2 ) );\r
-            nSamplesFromInput = SKP_SMULWB( SKP_LSHIFT16( nSamplesToBuffer, 2 ), 21846 ); // 21846 = ceil((1/3)*2^16)\r
-            SKP_Silk_resample_3_4( &psEnc->sCmn.inputBuf[ psEnc->sCmn.inputBufIx ], psEnc->sCmn.resample16To12state, \r
-                samplesIn, nSamplesFromInput );\r
-        } else if( encControl->sampleRate == 16000 && psEnc->sCmn.fs_kHz == 8 ) {\r
-            SKP_int32 scratch[ 3 * MAX_FRAME_LENGTH ];\r
-            /* Resample the data from 16 kHz to 8 kHz */\r
-            nSamplesToBuffer  = SKP_min_int( nSamplesToBuffer, SKP_RSHIFT( nSamplesIn, 1 ) );\r
-            nSamplesFromInput = SKP_LSHIFT16( nSamplesToBuffer, 1 );\r
-            SKP_Silk_resample_1_2_coarse( samplesIn, psEnc->sCmn.resample16To8state, \r
-                &psEnc->sCmn.inputBuf[ psEnc->sCmn.inputBufIx ], scratch, nSamplesToBuffer );\r
-        } else if( encControl->sampleRate == 12000 && psEnc->sCmn.fs_kHz == 8 ) {\r
-            /* Resample the data from 12 kHz to 8 kHz */\r
-            nSamplesToBuffer  = SKP_min_int( nSamplesToBuffer, SKP_SMULWB( SKP_LSHIFT( nSamplesIn, 1 ), 21846 ) );\r
-            nSamplesFromInput = SKP_RSHIFT( SKP_SMULBB( nSamplesToBuffer, 3 ), 1 );\r
-#if LOW_COMPLEXITY_ONLY\r
-            {\r
-                SKP_int16 scratch[ MAX_FRAME_LENGTH + SigProc_Resample_2_3_coarse_NUM_FIR_COEFS - 1 ];\r
-                SKP_assert( nSamplesFromInput <= MAX_FRAME_LENGTH );\r
-                SKP_Silk_resample_2_3_coarse( &psEnc->sCmn.inputBuf[ psEnc->sCmn.inputBufIx ], psEnc->sCmn.resample12To8state, \r
-                    samplesIn, nSamplesFromInput, scratch );\r
-            }\r
-#else\r
-            SKP_Silk_resample_2_3( &psEnc->sCmn.inputBuf[ psEnc->sCmn.inputBufIx ], psEnc->sCmn.resample12To8state, \r
-                samplesIn, nSamplesFromInput );\r
-#endif\r
-        }\r
-        samplesIn  += nSamplesFromInput;\r
-        nSamplesIn -= nSamplesFromInput;\r
+            /* Copy to buffer */\r
+            SKP_memcpy( &psEnc->sCmn.inputBuf[ psEnc->sCmn.inputBufIx ], samplesIn, nSamplesFromInput * sizeof( SKP_int16 ) );\r
+        } else {  \r
+            nSamplesToBuffer  = SKP_min( nSamplesToBuffer, 10 * input_10ms * psEnc->sCmn.fs_kHz );\r
+            nSamplesFromInput = SKP_DIV32_16( nSamplesToBuffer * API_fs_Hz, psEnc->sCmn.fs_kHz * 1000 );\r
+            /* Resample and write to buffer */\r
+            ret += SKP_Silk_resampler( &psEnc->sCmn.resampler_state, \r
+                &psEnc->sCmn.inputBuf[ psEnc->sCmn.inputBufIx ], samplesIn, nSamplesFromInput );\r
+        } \r
+        samplesIn              += nSamplesFromInput;\r
+        nSamplesIn             -= nSamplesFromInput;\r
         psEnc->sCmn.inputBufIx += nSamplesToBuffer;\r
 \r
         /* Silk encoder */\r
         if( psEnc->sCmn.inputBufIx >= psEnc->sCmn.frame_length ) {\r
+            SKP_assert( psEnc->sCmn.inputBufIx == psEnc->sCmn.frame_length );\r
+\r
             /* Enough data in input buffer, so encode */\r
             if( MaxBytesOut == 0 ) {\r
                 /* No payload obtained so far */\r
@@ -251,6 +223,11 @@ SKP_int SKP_Silk_SDK_Encode(
                 SKP_assert( *nBytesOut == 0 );\r
             }\r
             psEnc->sCmn.inputBufIx = 0;\r
+            psEnc->sCmn.controlled_since_last_payload = 0;\r
+\r
+            if( nSamplesIn == 0 ) {\r
+                break;\r
+            }\r
         } else {\r
             break;\r
         }\r
@@ -258,7 +235,7 @@ SKP_int SKP_Silk_SDK_Encode(
 \r
     *nBytesOut = MaxBytesOut;\r
     if( psEnc->sCmn.useDTX && psEnc->sCmn.inDTX ) {\r
-        /* Dtx simulation */\r
+        /* DTX simulation */\r
         *nBytesOut = 0;\r
     }\r
 \r
@@ -266,3 +243,4 @@ SKP_int SKP_Silk_SDK_Encode(
     return ret;\r
 }\r
 \r
+\r
index 4f97ec5f3778818d7e00a39980ec684cbc0f55b6..44d2a8646da72876d9fb36d4aac9e53b84f3c004 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -26,6 +26,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***********************************************************************/\r
 \r
 #include "SKP_Silk_main_FIX.h"\r
+#include "SKP_Silk_tuning_parameters.h"\r
+\r
 /****************/\r
 /* Encode frame */\r
 /****************/\r
@@ -38,22 +40,19 @@ SKP_int SKP_Silk_encode_frame_FIX(
 )\r
 {\r
     SKP_Silk_encoder_control_FIX sEncCtrl;\r
-    SKP_int     i, nBytes, ret = 0;\r
+    SKP_int     nBytes, ret = 0;\r
     SKP_int16   *x_frame, *res_pitch_frame;\r
     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
     const SKP_uint16 *FrameTermination_CDF;\r
-\r
     /* Low bitrate redundancy parameters */\r
     SKP_uint8   LBRRpayload[ MAX_ARITHM_BYTES ];\r
     SKP_int16   nBytesLBRR;\r
 \r
-    //SKP_int32   Seed[ MAX_LAYERS ];\r
-    sEncCtrl.sCmn.Seed = psEnc->sCmn.frameCounter++ & 3;\r
-\r
 \r
+    sEncCtrl.sCmn.Seed = psEnc->sCmn.frameCounter++ & 3;\r
     /**************************************************************/\r
     /* Setup Input Pointers, and insert frame in input buffer    */\r
     /*************************************************************/\r
@@ -74,14 +73,14 @@ SKP_int SKP_Silk_encode_frame_FIX(
     /* Variable high-pass filter */\r
     SKP_Silk_HP_variable_cutoff_FIX( psEnc, &sEncCtrl, pIn_HP, pIn );\r
 #else\r
-    SKP_memcpy( pIn_HP, pIn,psEnc->sCmn.frame_length * sizeof( SKP_int16 ) );\r
+    SKP_memcpy( pIn_HP, pIn, psEnc->sCmn.frame_length * sizeof( SKP_int16 ) );\r
 #endif\r
 \r
 #if SWITCH_TRANSITION_FILTERING\r
     /* Ensure smooth bandwidth transitions */\r
-    SKP_Silk_LP_variable_cutoff( &psEnc->sCmn.sLP, x_frame + psEnc->sCmn.la_shape, pIn_HP, psEnc->sCmn.frame_length );\r
+    SKP_Silk_LP_variable_cutoff( &psEnc->sCmn.sLP, x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, pIn_HP, psEnc->sCmn.frame_length );\r
 #else\r
-    SKP_memcpy( x_frame + psEnc->sCmn.la_shape, pIn_HP,psEnc->sCmn.frame_length * sizeof( SKP_int16 ) );\r
+    SKP_memcpy( x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, pIn_HP,psEnc->sCmn.frame_length * sizeof( SKP_int16 ) );\r
 #endif\r
     \r
     /*****************************************/\r
@@ -92,14 +91,13 @@ SKP_int SKP_Silk_encode_frame_FIX(
     /************************/\r
     /* Noise shape analysis */\r
     /************************/\r
-    SKP_Silk_noise_shape_analysis_FIX( psEnc, &sEncCtrl, res_pitch_frame, x_frame );    \r
+    SKP_Silk_noise_shape_analysis_FIX( psEnc, &sEncCtrl, res_pitch_frame, x_frame );\r
 \r
     /*****************************************/\r
     /* Prefiltering for noise shaper         */\r
     /*****************************************/\r
     SKP_Silk_prefilter_FIX( psEnc, &sEncCtrl, xfw, x_frame );\r
 \r
-\r
     /***************************************************/\r
     /* Find linear prediction coefficients (LPC + LTP) */\r
     /***************************************************/\r
@@ -109,10 +107,8 @@ SKP_int SKP_Silk_encode_frame_FIX(
     /* Process gains                        */\r
     /****************************************/\r
     SKP_Silk_process_gains_FIX( psEnc, &sEncCtrl );\r
\r
-    psEnc->sCmn.sigtype[         psEnc->sCmn.nFramesInPayloadBuf ] = sEncCtrl.sCmn.sigtype;\r
-    psEnc->sCmn.QuantOffsetType[ psEnc->sCmn.nFramesInPayloadBuf ] = sEncCtrl.sCmn.QuantOffsetType;\r
-\r
+    \r
+    \r
     /****************************************/\r
     /* Low Bitrate Redundant Encoding       */\r
     /****************************************/\r
@@ -122,16 +118,24 @@ SKP_int SKP_Silk_encode_frame_FIX(
     /*****************************************/\r
     /* Noise shaping quantization            */\r
     /*****************************************/\r
-    psEnc->NoiseShapingQuantizer( &psEnc->sCmn, &sEncCtrl.sCmn, &psEnc->sNSQ, xfw, \r
-        &psEnc->sCmn.q[ psEnc->sCmn.nFramesInPayloadBuf *psEnc->sCmn.frame_length ], sEncCtrl.sCmn.NLSFInterpCoef_Q2, \r
-        sEncCtrl.PredCoef_Q12[ 0 ], sEncCtrl.LTPCoef_Q14, sEncCtrl.AR2_Q13, sEncCtrl.HarmShapeGain_Q14, \r
-        sEncCtrl.Tilt_Q14, sEncCtrl.LF_shp_Q14, sEncCtrl.Gains_Q16, sEncCtrl.Lambda_Q10, \r
-        sEncCtrl.LTP_scale_Q14 );\r
+    if( psEnc->sCmn.nStatesDelayedDecision > 1 || psEnc->sCmn.warping_Q16 > 0 ) {\r
+        SKP_Silk_NSQ_del_dec( &psEnc->sCmn, &sEncCtrl.sCmn, &psEnc->sNSQ, xfw,\r
+            psEnc->sCmn.q, sEncCtrl.sCmn.NLSFInterpCoef_Q2, \r
+            sEncCtrl.PredCoef_Q12[ 0 ], sEncCtrl.LTPCoef_Q14, sEncCtrl.AR2_Q13, sEncCtrl.HarmShapeGain_Q14, \r
+            sEncCtrl.Tilt_Q14, sEncCtrl.LF_shp_Q14, sEncCtrl.Gains_Q16, sEncCtrl.Lambda_Q10, \r
+            sEncCtrl.LTP_scale_Q14 );\r
+    } else {\r
+        SKP_Silk_NSQ( &psEnc->sCmn, &sEncCtrl.sCmn, &psEnc->sNSQ, xfw, \r
+            psEnc->sCmn.q, sEncCtrl.sCmn.NLSFInterpCoef_Q2, \r
+            sEncCtrl.PredCoef_Q12[ 0 ], sEncCtrl.LTPCoef_Q14, sEncCtrl.AR2_Q13, sEncCtrl.HarmShapeGain_Q14, \r
+            sEncCtrl.Tilt_Q14, sEncCtrl.LF_shp_Q14, sEncCtrl.Gains_Q16, sEncCtrl.Lambda_Q10, \r
+            sEncCtrl.LTP_scale_Q14 );\r
+    }\r
 \r
     /**************************************************/\r
     /* Convert speech activity into VAD and DTX flags */\r
     /**************************************************/\r
-    if( psEnc->speech_activity_Q8 < SPEECH_ACTIVITY_DTX_THRES_Q8 ) {\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
@@ -148,7 +152,7 @@ SKP_int SKP_Silk_encode_frame_FIX(
     }\r
 \r
     /****************************************/\r
-    /* Initialize arithmetic coder          */\r
+    /* Initialize range coder               */\r
     /****************************************/\r
     if( psEnc->sCmn.nFramesInPayloadBuf == 0 ) {\r
         SKP_Silk_range_enc_init( &psEnc->sCmn.sRC );\r
@@ -158,35 +162,30 @@ SKP_int SKP_Silk_encode_frame_FIX(
     /****************************************/\r
     /* Encode Parameters                    */\r
     /****************************************/\r
-    if( psEnc->sCmn.bitstream_v == BIT_STREAM_V4 ) {\r
-        SKP_Silk_encode_parameters_v4( &psEnc->sCmn, &sEncCtrl.sCmn, &psEnc->sCmn.sRC );\r
-        FrameTermination_CDF = SKP_Silk_FrameTermination_v4_CDF;\r
-    } else {\r
-        SKP_Silk_encode_parameters( &psEnc->sCmn, &sEncCtrl.sCmn, &psEnc->sCmn.sRC, \r
-            &psEnc->sCmn.q[ psEnc->sCmn.nFramesInPayloadBuf *psEnc->sCmn.frame_length ] );\r
-        FrameTermination_CDF = SKP_Silk_FrameTermination_CDF;\r
-    }\r
+    SKP_Silk_encode_parameters( &psEnc->sCmn, &sEncCtrl.sCmn, &psEnc->sCmn.sRC, psEnc->sCmn.q );\r
+    FrameTermination_CDF = SKP_Silk_FrameTermination_CDF;\r
 \r
     /****************************************/\r
     /* Update Buffers and State             */\r
     /****************************************/\r
-    /* Update Input buffer */\r
-    SKP_memmove( psEnc->x_buf, &psEnc->x_buf[ psEnc->sCmn.frame_length ], ( psEnc->sCmn.frame_length + psEnc->sCmn.la_shape ) * sizeof( SKP_int16 ) );\r
+    /* Update input buffer */\r
+    SKP_memmove( psEnc->x_buf, &psEnc->x_buf[ psEnc->sCmn.frame_length ], \r
+        ( psEnc->sCmn.frame_length + LA_SHAPE_MS * psEnc->sCmn.fs_kHz ) * sizeof( SKP_int16 ) );\r
     \r
-    /* parameters needed for next frame */\r
+    /* Parameters needed for next frame */\r
     psEnc->sCmn.prev_sigtype            = sEncCtrl.sCmn.sigtype;\r
     psEnc->sCmn.prevLag                 = sEncCtrl.sCmn.pitchL[ NB_SUBFR - 1];\r
     psEnc->sCmn.first_frame_after_reset = 0;\r
 \r
     if( psEnc->sCmn.sRC.error ) {\r
-        /* encoder returned error: clear payload buffer */\r
+        /* Encoder returned error: clear payload buffer */\r
         psEnc->sCmn.nFramesInPayloadBuf = 0;\r
     } else {\r
         psEnc->sCmn.nFramesInPayloadBuf++;\r
     }\r
 \r
     /****************************************/\r
-    /* finalize payload and copy to output  */\r
+    /* Finalize payload and copy to output  */\r
     /****************************************/\r
     if( psEnc->sCmn.nFramesInPayloadBuf * FRAME_LENGTH_MS >= psEnc->sCmn.PacketSize_ms ) {\r
 \r
@@ -201,20 +200,14 @@ SKP_int SKP_Silk_encode_frame_FIX(
             frame_terminator = SKP_SILK_LBRR_VER2;\r
             LBRR_idx = psEnc->sCmn.oldest_LBRR_idx;\r
         }\r
+\r
         /* Add the frame termination info to stream */\r
         SKP_Silk_range_encoder( &psEnc->sCmn.sRC, frame_terminator, FrameTermination_CDF );\r
 \r
-        if( psEnc->sCmn.bitstream_v == BIT_STREAM_V4 ) {\r
-            /* Code excitation signal */\r
-            for( i = 0; i <psEnc->sCmn.nFramesInPayloadBuf; i++ ) {\r
-                SKP_Silk_encode_pulses( &psEnc->sCmn.sRC, psEnc->sCmn.sigtype[ 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
+        /* Payload length so far */\r
         SKP_Silk_range_coder_get_length( &psEnc->sCmn.sRC, &nBytes );\r
 \r
-        /* check that there is enough space in external output buffer, and move data */\r
+        /* Check that there is enough space in external output buffer, and move data */\r
         if( *pnBytesOut >= nBytes ) {\r
             SKP_Silk_range_enc_wrap_up( &psEnc->sCmn.sRC );\r
             SKP_memcpy( pCode, psEnc->sCmn.sRC.buffer, nBytes * sizeof( SKP_uint8 ) );\r
@@ -227,42 +220,37 @@ SKP_int SKP_Silk_encode_frame_FIX(
                     psEnc->sCmn.LBRR_buffer[ LBRR_idx ].nBytes * sizeof( SKP_uint8 ) );\r
                 nBytes += psEnc->sCmn.LBRR_buffer[ LBRR_idx ].nBytes;\r
             }\r
-                        \r
+\r
             *pnBytesOut = nBytes;\r
-        \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
-            /* This line tells describes how FEC should be used */\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
-            /* Reset number of frames in payload buffer */\r
-            psEnc->sCmn.nFramesInPayloadBuf = 0;\r
         } else {\r
             /* Not enough space: Payload will be discarded */\r
             *pnBytesOut = 0;\r
             nBytes      = 0;\r
-            psEnc->sCmn.nFramesInPayloadBuf = 0;\r
             ret = SKP_SILK_ENC_PAYLOAD_BUF_TOO_SHORT;\r
         }\r
+\r
+        /* Reset the number of frames in payload buffer */\r
+        psEnc->sCmn.nFramesInPayloadBuf = 0;\r
     } else {\r
-        /* no payload for you this time */\r
+        /* No payload this time */\r
         *pnBytesOut = 0;\r
 \r
         /* Encode that more frames follows */\r
         frame_terminator = SKP_SILK_MORE_FRAMES;\r
         SKP_Silk_range_encoder( &psEnc->sCmn.sRC, frame_terminator, FrameTermination_CDF );\r
 \r
-        /* payload length so far */\r
+        /* Payload length so far */\r
         SKP_Silk_range_coder_get_length( &psEnc->sCmn.sRC, &nBytes );\r
         \r
-        if( psEnc->sCmn.bitstream_v == BIT_STREAM_V4 ) {\r
-            /* Take into account the q signal that isnt in the bitstream yet */\r
-            nBytes +=  SKP_Silk_pulses_to_bytes( &psEnc->sCmn, \r
-                &psEnc->sCmn.q[ (psEnc->sCmn.nFramesInPayloadBuf - 1) * psEnc->sCmn.frame_length ] );\r
-        }\r
     }\r
 \r
     /* Check for arithmetic coder errors */\r
@@ -270,16 +258,16 @@ SKP_int SKP_Silk_encode_frame_FIX(
         ret = SKP_SILK_ENC_INTERNAL_ERROR;\r
     }\r
 \r
-    /* simulate number of ms buffered in channel because of exceeding TargetRate */\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
     SKP_assert( psEnc->sCmn.TargetRate_bps > 0 );\r
-    psEnc->BufferedInChannel_ms   += SKP_DIV32( 8 * 1000 * ( nBytes -psEnc->sCmn.nBytesInPayloadBuf ),psEnc->sCmn.TargetRate_bps );\r
+    psEnc->BufferedInChannel_ms   += SKP_DIV32( 8 * 1000 * ( nBytes - psEnc->sCmn.nBytesInPayloadBuf ), psEnc->sCmn.TargetRate_bps );\r
     psEnc->BufferedInChannel_ms   -= FRAME_LENGTH_MS;\r
-    psEnc->BufferedInChannel_ms    = SKP_LIMIT( psEnc->BufferedInChannel_ms, 0, 100 );\r
+    psEnc->BufferedInChannel_ms    = SKP_LIMIT_int( psEnc->BufferedInChannel_ms, 0, 100 );\r
     psEnc->sCmn.nBytesInPayloadBuf = nBytes;\r
 \r
-    if( psEnc->speech_activity_Q8 > WB_DETECT_ACTIVE_SPEECH_LEVEL_THRES_Q8 ) {\r
+    if( psEnc->speech_activity_Q8 > SKP_FIX_CONST( WB_DETECT_ACTIVE_SPEECH_LEVEL_THRES, 8 ) ) {\r
         psEnc->sCmn.sSWBdetect.ActiveSpeech_ms = SKP_ADD_POS_SAT32( psEnc->sCmn.sSWBdetect.ActiveSpeech_ms, FRAME_LENGTH_MS ); \r
     }\r
 \r
@@ -296,19 +284,19 @@ void SKP_Silk_LBRR_encode_FIX(
     SKP_int16                       xfw[]           /* I    Input signal                            */\r
 )\r
 {\r
-    SKP_int     i, TempGainsIndices[ NB_SUBFR ], frame_terminator;\r
+    SKP_int     TempGainsIndices[ NB_SUBFR ], frame_terminator;\r
     SKP_int     nBytes, nFramesInPayloadBuf;\r
     SKP_int32   TempGains_Q16[ NB_SUBFR ];\r
     SKP_int     typeOffset, LTP_scaleIndex, Rate_only_parameters = 0;\r
     /*******************************************/\r
     /* Control use of inband LBRR              */\r
     /*******************************************/\r
-    SKP_Silk_LBRR_ctrl_FIX( psEnc, psEncCtrl );\r
+    SKP_Silk_LBRR_ctrl_FIX( psEnc, &psEncCtrl->sCmn );\r
 \r
     if( psEnc->sCmn.LBRR_enabled ) {\r
-        /* Save original Gains */\r
+        /* Save original gains */\r
         SKP_memcpy( TempGainsIndices, psEncCtrl->sCmn.GainsIndices, NB_SUBFR * sizeof( SKP_int   ) );\r
-        SKP_memcpy( TempGains_Q16,    psEncCtrl->Gains_Q16,    NB_SUBFR * sizeof( SKP_int32 ) );\r
+        SKP_memcpy( TempGains_Q16,    psEncCtrl->Gains_Q16,         NB_SUBFR * sizeof( SKP_int32 ) );\r
 \r
         typeOffset     = psEnc->sCmn.typeOffsetPrev; // Temp save as cannot be overwritten\r
         LTP_scaleIndex = psEncCtrl->sCmn.LTP_scaleIndex;\r
@@ -328,29 +316,35 @@ void SKP_Silk_LBRR_encode_FIX(
 \r
         if( psEnc->sCmn.Complexity > 0 && psEnc->sCmn.TargetRate_bps > Rate_only_parameters ) {\r
             if( psEnc->sCmn.nFramesInPayloadBuf == 0 ) {\r
-                /* First frame in packet copy Everything */\r
+                /* First frame in packet; copy everything */\r
                 SKP_memcpy( &psEnc->sNSQ_LBRR, &psEnc->sNSQ, sizeof( SKP_Silk_nsq_state ) );\r
-            \r
+\r
                 psEnc->sCmn.LBRRprevLastGainIndex = psEnc->sShape.LastGainIndex;\r
                 /* Increase Gains to get target LBRR rate */\r
                 psEncCtrl->sCmn.GainsIndices[ 0 ] = psEncCtrl->sCmn.GainsIndices[ 0 ] + psEnc->sCmn.LBRR_GainIncreases;\r
-                psEncCtrl->sCmn.GainsIndices[ 0 ] = SKP_LIMIT( psEncCtrl->sCmn.GainsIndices[ 0 ], 0, N_LEVELS_QGAIN - 1 );\r
+                psEncCtrl->sCmn.GainsIndices[ 0 ] = SKP_LIMIT_int( psEncCtrl->sCmn.GainsIndices[ 0 ], 0, N_LEVELS_QGAIN - 1 );\r
             }\r
-            /* Decode to get Gains in sync with decoder         */\r
+            /* Decode to get gains in sync with decoder         */\r
             /* Overwrite unquantized gains with quantized gains */\r
             SKP_Silk_gains_dequant( psEncCtrl->Gains_Q16, psEncCtrl->sCmn.GainsIndices, \r
                 &psEnc->sCmn.LBRRprevLastGainIndex, psEnc->sCmn.nFramesInPayloadBuf );\r
+\r
             /*****************************************/\r
             /* Noise shaping quantization            */\r
             /*****************************************/\r
-            psEnc->NoiseShapingQuantizer( &psEnc->sCmn, &psEncCtrl->sCmn,\r
-                &psEnc->sNSQ_LBRR, xfw, &psEnc->sCmn.q_LBRR[ psEnc->sCmn.nFramesInPayloadBuf * psEnc->sCmn.frame_length ], \r
-                psEncCtrl->sCmn.NLSFInterpCoef_Q2, psEncCtrl->PredCoef_Q12[ 0 ], psEncCtrl->LTPCoef_Q14, \r
-                psEncCtrl->AR2_Q13, psEncCtrl->HarmShapeGain_Q14, psEncCtrl->Tilt_Q14, psEncCtrl->LF_shp_Q14, \r
-                psEncCtrl->Gains_Q16, psEncCtrl->Lambda_Q10, psEncCtrl->LTP_scale_Q14 );\r
+            if( psEnc->sCmn.nStatesDelayedDecision > 1 || psEnc->sCmn.warping_Q16 > 0 ) {\r
+                SKP_Silk_NSQ_del_dec( &psEnc->sCmn, &psEncCtrl->sCmn, &psEnc->sNSQ_LBRR, xfw, psEnc->sCmn.q_LBRR, \r
+                    psEncCtrl->sCmn.NLSFInterpCoef_Q2, psEncCtrl->PredCoef_Q12[ 0 ], psEncCtrl->LTPCoef_Q14, \r
+                    psEncCtrl->AR2_Q13, psEncCtrl->HarmShapeGain_Q14, psEncCtrl->Tilt_Q14, psEncCtrl->LF_shp_Q14, \r
+                    psEncCtrl->Gains_Q16, psEncCtrl->Lambda_Q10, psEncCtrl->LTP_scale_Q14 );\r
+            } else {\r
+                SKP_Silk_NSQ( &psEnc->sCmn, &psEncCtrl->sCmn, &psEnc->sNSQ_LBRR, xfw, psEnc->sCmn.q_LBRR, \r
+                    psEncCtrl->sCmn.NLSFInterpCoef_Q2, psEncCtrl->PredCoef_Q12[ 0 ], psEncCtrl->LTPCoef_Q14, \r
+                    psEncCtrl->AR2_Q13, psEncCtrl->HarmShapeGain_Q14, psEncCtrl->Tilt_Q14, psEncCtrl->LF_shp_Q14, \r
+                    psEncCtrl->Gains_Q16, psEncCtrl->Lambda_Q10, psEncCtrl->LTP_scale_Q14 );\r
+            }\r
         } else {\r
-            SKP_memset( &psEnc->sCmn.q_LBRR[ psEnc->sCmn.nFramesInPayloadBuf *psEnc->sCmn.frame_length ], 0,\r
-                psEnc->sCmn.frame_length * sizeof( SKP_int ) );\r
+            SKP_memset( psEnc->sCmn.q_LBRR, 0, psEnc->sCmn.frame_length * sizeof( SKP_int8 ) );\r
             psEncCtrl->sCmn.LTP_scaleIndex = 0;\r
         }\r
         /****************************************/\r
@@ -364,22 +358,18 @@ void SKP_Silk_LBRR_encode_FIX(
         /****************************************/\r
         /* Encode Parameters                    */\r
         /****************************************/\r
-        if( psEnc->sCmn.bitstream_v == BIT_STREAM_V4 ) {\r
-            SKP_Silk_encode_parameters_v4( &psEnc->sCmn, &psEncCtrl->sCmn, &psEnc->sCmn.sRC_LBRR );\r
-        } else {\r
-            SKP_Silk_encode_parameters( &psEnc->sCmn, &psEncCtrl->sCmn, &psEnc->sCmn.sRC_LBRR, \r
-                &psEnc->sCmn.q_LBRR[ psEnc->sCmn.nFramesInPayloadBuf * psEnc->sCmn.frame_length] );\r
-        }\r
+        SKP_Silk_encode_parameters( &psEnc->sCmn, &psEncCtrl->sCmn, \r
+            &psEnc->sCmn.sRC_LBRR, psEnc->sCmn.q_LBRR );\r
 \r
         if( psEnc->sCmn.sRC_LBRR.error ) {\r
-            /* encoder returned error: clear payload buffer */\r
+            /* Encoder returned error: clear payload buffer */\r
             nFramesInPayloadBuf = 0;\r
         } else {\r
             nFramesInPayloadBuf = psEnc->sCmn.nFramesInPayloadBuf + 1;\r
         }\r
 \r
         /****************************************/\r
-        /* finalize payload and copy to output  */\r
+        /* Finalize payload and copy to output  */\r
         /****************************************/\r
         if( SKP_SMULBB( nFramesInPayloadBuf, FRAME_LENGTH_MS ) >= psEnc->sCmn.PacketSize_ms ) {\r
 \r
@@ -388,32 +378,23 @@ void SKP_Silk_LBRR_encode_FIX(
 \r
             /* Add the frame termination info to stream */\r
             SKP_Silk_range_encoder( &psEnc->sCmn.sRC_LBRR, frame_terminator, SKP_Silk_FrameTermination_CDF );\r
-            \r
-            if( psEnc->sCmn.bitstream_v == BIT_STREAM_V4 ) {\r
-                /*********************************************/\r
-                /* 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
-                        &psEnc->sCmn.q_LBRR[ i * psEnc->sCmn.frame_length ], psEnc->sCmn.frame_length );\r
-                }\r
-            }\r
-            /* payload length so far */\r
+\r
+            /* Payload length so far */\r
             SKP_Silk_range_coder_get_length( &psEnc->sCmn.sRC_LBRR, &nBytes );\r
 \r
-            /* check that there is enough space in external output buffer, and move data */\r
+            /* Check that there is enough space in external output buffer and move data */\r
             if( *pnBytesOut >= nBytes ) {\r
                 SKP_Silk_range_enc_wrap_up( &psEnc->sCmn.sRC_LBRR );\r
                 SKP_memcpy( pCode, psEnc->sCmn.sRC_LBRR.buffer, nBytes * sizeof( SKP_uint8 ) );\r
-                \r
+\r
                 *pnBytesOut = nBytes;\r
             } else {\r
-                /* not enough space: payload will be discarded */\r
+                /* Not enough space: payload will be discarded */\r
                 *pnBytesOut = 0;\r
                 SKP_assert( 0 );\r
             }\r
         } else {\r
-            /* no payload for you this time */\r
+            /* No payload this time */\r
             *pnBytesOut = 0;\r
 \r
             /* Encode that more frames follows */\r
@@ -423,7 +404,7 @@ void SKP_Silk_LBRR_encode_FIX(
 \r
         /* Restore original Gains */\r
         SKP_memcpy( psEncCtrl->sCmn.GainsIndices, TempGainsIndices, NB_SUBFR * sizeof( SKP_int   ) );\r
-        SKP_memcpy( psEncCtrl->Gains_Q16,  TempGains_Q16,    NB_SUBFR * sizeof( SKP_int32 ) );\r
+        SKP_memcpy( psEncCtrl->Gains_Q16,         TempGains_Q16,    NB_SUBFR * sizeof( SKP_int32 ) );\r
     \r
         /* Restore LTP scale index and typeoffset */\r
         psEncCtrl->sCmn.LTP_scaleIndex = LTP_scaleIndex;\r
index 4af3551f5233d8dd1babd582879ab116173c3d85..d19d0c52cbfd4cab60cf493eab1c279be494275b 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -34,7 +34,7 @@ void SKP_Silk_encode_parameters(
     SKP_Silk_encoder_state          *psEncC,        /* I/O  Encoder state                   */\r
     SKP_Silk_encoder_control        *psEncCtrlC,    /* I/O  Encoder control                 */\r
     SKP_Silk_range_coder_state      *psRC,          /* I/O  Range encoder state             */\r
-    const SKP_int                   *q              /* I    Quantization indices            */\r
+    const SKP_int8                  *q              /* I    Quantization indices            */\r
 )\r
 {\r
     SKP_int   i, k, typeOffset;\r
@@ -46,11 +46,6 @@ void SKP_Silk_encode_parameters(
     /************************/\r
     /* only done for first frame in packet */\r
     if( psEncC->nFramesInPayloadBuf == 0 ) {\r
-        \r
-        /* Initialize arithmetic coder */\r
-        SKP_Silk_range_enc_init( &psEncC->sRC );\r
-        psEncC->nBytesInPayloadBuf = 0;\r
-\r
         /* get sampling rate index */\r
         for( i = 0; i < 3; i++ ) {\r
             if( SKP_Silk_SamplingRates_table[ i ] == psEncC->fs_kHz ) {\r
diff --git a/libs/silk/src/SKP_Silk_encode_parameters_v4.c b/libs/silk/src/SKP_Silk_encode_parameters_v4.c
deleted file mode 100644 (file)
index c6786b8..0000000
+++ /dev/null
@@ -1,179 +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
-/*******************************************/\r
-/* Encode parameters to create the payload */\r
-/*******************************************/\r
-void SKP_Silk_encode_parameters_v4(\r
-    SKP_Silk_encoder_state          *psEncC,        /* I/O  Encoder state                   */\r
-    SKP_Silk_encoder_control        *psEncCtrlC,    /* I/O  Encoder control                 */\r
-    SKP_Silk_range_coder_state      *psRC           /* I/O  Range encoder state             */\r
-)\r
-{\r
-    SKP_int   i, k, typeOffset;\r
-    SKP_int   encode_absolute_lagIndex, delta_lagIndex;\r
-    const SKP_Silk_NLSF_CB_struct *psNLSF_CB;\r
-\r
-\r
-    /************************/\r
-    /* Encode sampling rate */\r
-    /************************/\r
-    /* only done for first frame in packet */\r
-    if( psEncC->nFramesInPayloadBuf == 0 ) {\r
-        \r
-        /* Initialize arithmetic coder */\r
-        SKP_Silk_range_enc_init( &psEncC->sRC );\r
-        psEncC->nBytesInPayloadBuf = 0;\r
-\r
-        /* get sampling rate index */\r
-        for( i = 0; i < 3; i++ ) {\r
-            if( SKP_Silk_SamplingRates_table[ i ] == psEncC->fs_kHz ) {\r
-                break;\r
-            }\r
-        }\r
-        SKP_Silk_range_encoder( psRC, i, SKP_Silk_SamplingRates_CDF );\r
-    }\r
-\r
-    /*********************************************/\r
-    /* Encode VAD flag                           */\r
-    /*********************************************/\r
-    SKP_Silk_range_encoder( psRC, psEncC->vadFlag, SKP_Silk_vadflag_CDF );\r
-\r
-    /*******************************************/\r
-    /* Encode signal type and quantizer offset */\r
-    /*******************************************/\r
-    typeOffset = 2 * psEncCtrlC->sigtype + psEncCtrlC->QuantOffsetType;\r
-    if( psEncC->nFramesInPayloadBuf == 0 ) {\r
-        /* first frame in packet: independent coding */\r
-        SKP_Silk_range_encoder( psRC, typeOffset, SKP_Silk_type_offset_CDF );\r
-    } else {\r
-        /* condidtional coding */\r
-        SKP_Silk_range_encoder( psRC, typeOffset, SKP_Silk_type_offset_joint_CDF[ psEncC->typeOffsetPrev ] );\r
-    }\r
-    psEncC->typeOffsetPrev = typeOffset;\r
-\r
-    /****************/\r
-    /* Encode gains */\r
-    /****************/\r
-    /* first subframe */\r
-    if( psEncC->nFramesInPayloadBuf == 0 ) {\r
-        /* first frame in packet: independent coding */\r
-        SKP_Silk_range_encoder( psRC, psEncCtrlC->GainsIndices[ 0 ], SKP_Silk_gain_CDF[ psEncCtrlC->sigtype ] );\r
-    } else {\r
-        /* condidtional coding */\r
-        SKP_Silk_range_encoder( psRC, psEncCtrlC->GainsIndices[ 0 ], SKP_Silk_delta_gain_CDF );\r
-    }\r
-\r
-    /* remaining subframes */\r
-    for( i = 1; i < NB_SUBFR; i++ ) {\r
-        SKP_Silk_range_encoder( psRC, psEncCtrlC->GainsIndices[ i ], SKP_Silk_delta_gain_CDF );\r
-    }\r
-\r
-\r
-    /****************/\r
-    /* Encode NLSFs */\r
-    /****************/\r
-    /* Range encoding of the NLSF path */\r
-    psNLSF_CB = psEncC->psNLSF_CB[ psEncCtrlC->sigtype ];\r
-    SKP_Silk_range_encoder_multi( psRC, psEncCtrlC->NLSFIndices, psNLSF_CB->StartPtr, psNLSF_CB->nStages );\r
-\r
-    /* Encode NLSF interpolation factor */\r
-    SKP_assert( psEncC->useInterpolatedNLSFs == 1 || psEncCtrlC->NLSFInterpCoef_Q2 == ( 1 << 2 ) );\r
-    SKP_Silk_range_encoder( psRC, psEncCtrlC->NLSFInterpCoef_Q2, SKP_Silk_NLSF_interpolation_factor_CDF );\r
-\r
-\r
-    if( psEncCtrlC->sigtype == SIG_TYPE_VOICED ) {\r
-        /*********************/\r
-        /* Encode pitch lags */\r
-        /*********************/\r
-\r
-\r
-        /* lag index */\r
-        encode_absolute_lagIndex = 1;\r
-        if( psEncC->nFramesInPayloadBuf > 0 && psEncC->prev_sigtype == SIG_TYPE_VOICED ) {\r
-            /* Delta Encoding */\r
-            delta_lagIndex = psEncCtrlC->lagIndex - psEncC->prev_lagIndex;\r
-            if( delta_lagIndex > MAX_DELTA_LAG ) {\r
-                delta_lagIndex = ( MAX_DELTA_LAG << 1 ) + 1;\r
-            } else if ( delta_lagIndex < -MAX_DELTA_LAG ) {\r
-                delta_lagIndex = ( MAX_DELTA_LAG << 1 ) + 1;\r
-            } else {\r
-                delta_lagIndex = delta_lagIndex + MAX_DELTA_LAG;\r
-                encode_absolute_lagIndex = 0; /* Only use delta */\r
-            }\r
-            SKP_Silk_range_encoder( psRC, delta_lagIndex, SKP_Silk_pitch_delta_CDF );\r
-        }\r
-        if( encode_absolute_lagIndex ) {\r
-            /* Absolute encoding */\r
-            if( psEncC->fs_kHz == 8 ) {\r
-                SKP_Silk_range_encoder( psRC, psEncCtrlC->lagIndex, SKP_Silk_pitch_lag_NB_CDF );\r
-            } else if( psEncC->fs_kHz == 12 ) {\r
-                SKP_Silk_range_encoder( psRC, psEncCtrlC->lagIndex, SKP_Silk_pitch_lag_MB_CDF );\r
-            } else if( psEncC->fs_kHz == 16 ) {\r
-                SKP_Silk_range_encoder( psRC, psEncCtrlC->lagIndex, SKP_Silk_pitch_lag_WB_CDF );\r
-            } else {\r
-                SKP_Silk_range_encoder( psRC, psEncCtrlC->lagIndex, SKP_Silk_pitch_lag_SWB_CDF );\r
-            }\r
-        }\r
-        psEncC->prev_lagIndex = psEncCtrlC->lagIndex;\r
-\r
-\r
-        /* countour index */\r
-        if( psEncC->fs_kHz == 8 ) {\r
-            /* Less codevectors used in 8 khz mode */\r
-            SKP_Silk_range_encoder( psRC, psEncCtrlC->contourIndex, SKP_Silk_pitch_contour_NB_CDF );\r
-        } else {\r
-            /* Joint for 12, 16, 24 khz */\r
-            SKP_Silk_range_encoder( psRC, psEncCtrlC->contourIndex, SKP_Silk_pitch_contour_CDF );\r
-        }\r
-\r
-        /********************/\r
-        /* Encode LTP gains */\r
-        /********************/\r
-\r
-        /* PERIndex value */\r
-        SKP_Silk_range_encoder( psRC, psEncCtrlC->PERIndex, SKP_Silk_LTP_per_index_CDF );\r
-\r
-        /* Codebook Indices */\r
-        for( k = 0; k < NB_SUBFR; k++ ) {\r
-            SKP_Silk_range_encoder( psRC, psEncCtrlC->LTPIndex[ k ], SKP_Silk_LTP_gain_CDF_ptrs[ psEncCtrlC->PERIndex ] );\r
-        }\r
-\r
-        /**********************/\r
-        /* Encode LTP scaling */\r
-        /**********************/\r
-        SKP_Silk_range_encoder( psRC, psEncCtrlC->LTP_scaleIndex, SKP_Silk_LTPscale_CDF );\r
-    }\r
-\r
-\r
-    /***************/\r
-    /* Encode seed */\r
-    /***************/\r
-    SKP_Silk_range_encoder( psRC, psEncCtrlC->Seed, SKP_Silk_Seed_CDF );\r
-}\r
index d64900367410c7c736e05478f85f762e2e03d947..f25ff76277541872ac077235e8c65f8aaea49a2a 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -56,7 +56,7 @@ void SKP_Silk_encode_pulses(
     SKP_Silk_range_coder_state      *psRC,          /* I/O  Range coder state               */\r
     const SKP_int                   sigtype,        /* I    Sigtype                         */\r
     const SKP_int                   QuantOffsetType,/* I    QuantOffsetType                 */\r
-    const SKP_int                   q[],            /* I    quantization indices            */\r
+    const SKP_int8                  q[],            /* I    quantization indices            */\r
     const SKP_int                   frame_length    /* I    Frame length                    */\r
 )\r
 {\r
@@ -64,10 +64,10 @@ void SKP_Silk_encode_pulses(
     SKP_int32 abs_q, minSumBits_Q6, sumBits_Q6;\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   nRshifts[   MAX_NB_SHELL_BLOCKS ];\r
     SKP_int   pulses_comb[ 8 ];\r
     SKP_int   *abs_pulses_ptr;\r
-    const SKP_int *pulses_ptr;\r
+    const SKP_int8 *pulses_ptr;\r
     const SKP_uint16 *cdf_ptr;\r
     const SKP_int16 *nBits_ptr;\r
 \r
@@ -177,7 +177,7 @@ void SKP_Silk_encode_pulses(
             pulses_ptr = &q[ i * SHELL_CODEC_FRAME_LENGTH ];\r
             nLS = nRshifts[ i ] - 1;\r
             for( k = 0; k < SHELL_CODEC_FRAME_LENGTH; k++ ) {\r
-                abs_q = SKP_abs( pulses_ptr[ k ] );\r
+                abs_q = (SKP_int8)SKP_abs( pulses_ptr[ k ] );\r
                 for( j = nLS; j > 0; j-- ) {\r
                     bit = SKP_RSHIFT( abs_q, j ) & 1;\r
                     SKP_Silk_range_encoder( psRC, bit, SKP_Silk_lsb_CDF );\r
index d45506cacbd6fc3351d14cd30eee304c793b4caa..95308ff315ebf3109ed6b561a0aac39f873f6b1a 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -26,6 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***********************************************************************/\r
 \r
 #include "SKP_Silk_main_FIX.h"\r
+#include "SKP_Silk_tuning_parameters.h"\r
 \r
 /* Finds LPC vector from correlations, and converts to NLSF */\r
 void SKP_Silk_find_LPC_FIX(\r
@@ -40,7 +41,6 @@ void SKP_Silk_find_LPC_FIX(
 {\r
     SKP_int     k;\r
     SKP_int32   a_Q16[ MAX_LPC_ORDER ];\r
-\r
     SKP_int     isInterpLower, shift;\r
     SKP_int16   S[ MAX_LPC_ORDER ];\r
     SKP_int32   res_nrg0, res_nrg1;\r
@@ -57,13 +57,17 @@ void SKP_Silk_find_LPC_FIX(
     *interpIndex = 4;\r
 \r
     /* Burg AR analysis for the full frame */\r
-    SKP_Silk_burg_modified( &res_nrg, &res_nrg_Q, a_Q16, x, subfr_length, NB_SUBFR, FIND_LPC_COND_FAC_Q32, LPC_order );\r
+    SKP_Silk_burg_modified( &res_nrg, &res_nrg_Q, a_Q16, x, subfr_length, NB_SUBFR, SKP_FIX_CONST( FIND_LPC_COND_FAC, 32 ), LPC_order );\r
+\r
+    SKP_Silk_bwexpander_32( a_Q16, LPC_order, SKP_FIX_CONST( FIND_LPC_CHIRP, 16 ) );\r
 \r
     if( useInterpolatedNLSFs == 1 ) {\r
 \r
         /* Optimal solution for last 10 ms */\r
         SKP_Silk_burg_modified( &res_tmp_nrg, &res_tmp_nrg_Q, a_tmp_Q16, x + ( NB_SUBFR >> 1 ) * subfr_length, \r
-            subfr_length, ( NB_SUBFR >> 1 ), FIND_LPC_COND_FAC_Q32, LPC_order );\r
+            subfr_length, ( NB_SUBFR >> 1 ), SKP_FIX_CONST( FIND_LPC_COND_FAC, 32 ), LPC_order );\r
+\r
+        SKP_Silk_bwexpander_32( a_tmp_Q16, LPC_order, SKP_FIX_CONST( FIND_LPC_CHIRP, 16 ) );\r
 \r
         /* subtract residual energy here, as that's easier than adding it to the    */\r
         /* residual energy of the first 10 ms in each iteration of the search below */\r
index c8ac22d164ab50bb5f088833b0b39be380d23ad8..35ac03f9ddd5434657f2294951870ff20a8752bc 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -26,6 +26,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***********************************************************************/\r
 \r
 #include "SKP_Silk_main_FIX.h"\r
+#include "SKP_Silk_tuning_parameters.h"\r
+\r
+/* Head room for correlations                           */\r
+#define LTP_CORRS_HEAD_ROOM                             2\r
 \r
 void SKP_Silk_fit_LTP(\r
     SKP_int32 LTP_coefs_Q16[ LTP_ORDER ],\r
@@ -71,22 +75,27 @@ void SKP_Silk_find_LTP_FIX(
         lag_ptr = r_ptr - ( lag[ k ] + LTP_ORDER / 2 );\r
 \r
         SKP_Silk_sum_sqr_shift( &rr[ k ], &rr_shifts, r_ptr, subfr_length ); /* rr[ k ] in Q( -rr_shifts ) */\r
+\r
         /* Assure headroom */\r
         LZs = SKP_Silk_CLZ32( rr[k] );\r
         if( LZs < LTP_CORRS_HEAD_ROOM ) {\r
             rr[ k ] = SKP_RSHIFT_ROUND( rr[ k ], LTP_CORRS_HEAD_ROOM - LZs );\r
-            rr_shifts += (LTP_CORRS_HEAD_ROOM - LZs);\r
+            rr_shifts += ( LTP_CORRS_HEAD_ROOM - LZs );\r
         }\r
         corr_rshifts[ k ] = rr_shifts;\r
-        SKP_Silk_corrMatrix_FIX( lag_ptr, subfr_length, LTP_ORDER, WLTP_ptr, &corr_rshifts[ k ] );     /* WLTP_fix_ptr in Q( -corr_rshifts[ k ] ) */\r
-        /* The correlation vector always have lower max abs value than rr and/or RR so head room is assured */\r
-        SKP_Silk_corrVector_FIX( lag_ptr, r_ptr, subfr_length, LTP_ORDER, Rr, corr_rshifts[ k ] ); /* Rr_fix_ptr   in Q( -corr_rshifts[ k ] ) */\r
+        SKP_Silk_corrMatrix_FIX( lag_ptr, subfr_length, LTP_ORDER, LTP_CORRS_HEAD_ROOM, WLTP_ptr, &corr_rshifts[ k ] );  /* WLTP_fix_ptr in Q( -corr_rshifts[ k ] ) */\r
+\r
+        /* The correlation vector always has lower max abs value than rr and/or RR so head room is assured */\r
+        SKP_Silk_corrVector_FIX( lag_ptr, r_ptr, subfr_length, LTP_ORDER, Rr, corr_rshifts[ k ] );  /* Rr_fix_ptr   in Q( -corr_rshifts[ k ] ) */\r
         if( corr_rshifts[ k ] > rr_shifts ) {\r
             rr[ k ] = SKP_RSHIFT( rr[ k ], corr_rshifts[ k ] - rr_shifts ); /* rr[ k ] in Q( -corr_rshifts[ k ] ) */\r
         }\r
         SKP_assert( rr[ k ] >= 0 );\r
 \r
-        regu = SKP_SMULWB( rr[ k ] + 1, LTP_DAMPING_Q16 );\r
+        regu = 1;\r
+        regu = SKP_SMLAWB( regu, rr[ k ], SKP_FIX_CONST( LTP_DAMPING/3, 16 ) );\r
+        regu = SKP_SMLAWB( regu, matrix_ptr( WLTP_ptr, 0, 0, LTP_ORDER ), SKP_FIX_CONST( LTP_DAMPING/3, 16 ) );\r
+        regu = SKP_SMLAWB( regu, matrix_ptr( WLTP_ptr, LTP_ORDER-1, LTP_ORDER-1, LTP_ORDER ), SKP_FIX_CONST( LTP_DAMPING/3, 16 ) );\r
         SKP_Silk_regularize_correlations_FIX( WLTP_ptr, &rr[k], regu, LTP_ORDER );\r
 \r
         SKP_Silk_solve_LDL_FIX( WLTP_ptr, LTP_ORDER, Rr, b_Q16 ); /* WLTP_fix_ptr and Rr_fix_ptr both in Q(-corr_rshifts[k]) */\r
@@ -99,12 +108,12 @@ void SKP_Silk_find_LTP_FIX(
 \r
         /* temp = Wght[ k ] / ( nrg[ k ] * Wght[ k ] + 0.01f * subfr_length ); */\r
         extra_shifts = SKP_min_int( corr_rshifts[ k ], LTP_CORRS_HEAD_ROOM );\r
-        denom32 = SKP_LSHIFT_SAT32( SKP_SMULWB( nrg[ k ], Wght_Q15[ k ] ), 1 + extra_shifts ) +  /* Q( -corr_rshifts[ k ] + extra_shifts ) */\r
-            SKP_RSHIFT( SKP_SMULWB( subfr_length, 655 ), corr_rshifts[ k ] - extra_shifts );     /* Q( -corr_rshifts[ k ] + extra_shifts ) */\r
+        denom32 = SKP_LSHIFT_SAT32( SKP_SMULWB( nrg[ k ], Wght_Q15[ k ] ), 1 + extra_shifts ) + /* Q( -corr_rshifts[ k ] + extra_shifts ) */\r
+            SKP_RSHIFT( SKP_SMULWB( subfr_length, 655 ), corr_rshifts[ k ] - extra_shifts );    /* Q( -corr_rshifts[ k ] + extra_shifts ) */\r
         denom32 = SKP_max( denom32, 1 );\r
-        SKP_assert( ((SKP_int64)Wght_Q15[ k ] << 16 ) < SKP_int32_MAX ); /* Wght always < 0.5 in Q0 */\r
-        temp32 = SKP_DIV32( SKP_LSHIFT( ( SKP_int32 )Wght_Q15[ k ], 16 ), denom32 );  /* Q( 15 + 16 + corr_rshifts[k] - extra_shifts ) */\r
-        temp32 = SKP_RSHIFT( temp32, 31 + corr_rshifts[ k ] - extra_shifts - 26 );  /* Q26 */\r
+        SKP_assert( ((SKP_int64)Wght_Q15[ k ] << 16 ) < SKP_int32_MAX );                        /* Wght always < 0.5 in Q0 */\r
+        temp32 = SKP_DIV32( SKP_LSHIFT( ( SKP_int32 )Wght_Q15[ k ], 16 ), denom32 );            /* Q( 15 + 16 + corr_rshifts[k] - extra_shifts ) */\r
+        temp32 = SKP_RSHIFT( temp32, 31 + corr_rshifts[ k ] - extra_shifts - 26 );              /* Q26 */\r
         \r
         /* Limit temp such that the below scaling never wraps around */\r
         WLTP_max = 0;\r
@@ -132,7 +141,7 @@ void SKP_Silk_find_LTP_FIX(
         maxRshifts = SKP_max_int( corr_rshifts[ k ], maxRshifts );\r
     }\r
 \r
-    /* compute LTP coding gain */\r
+    /* Compute LTP coding gain */\r
     if( LTPredCodGain_Q7 != NULL ) {\r
         LPC_LTP_res_nrg = 0;\r
         LPC_res_nrg     = 0;\r
@@ -204,8 +213,8 @@ void SKP_Silk_find_LTP_FIX(
 \r
         g_Q26 = SKP_MUL( \r
             SKP_DIV32( \r
-                LTP_SMOOTHING_Q26\r
-                SKP_RSHIFT( LTP_SMOOTHING_Q26, 10 ) + temp32 ),                                       /* Q10 */ \r
+                SKP_FIX_CONST( LTP_SMOOTHING, 26 )\r
+                SKP_RSHIFT( SKP_FIX_CONST( LTP_SMOOTHING, 26 ), 10 ) + temp32 ),                                       /* Q10 */ \r
             SKP_LSHIFT_SAT32( SKP_SUB_SAT32( ( SKP_int32 )m_Q12, SKP_RSHIFT( d_Q14[ k ], 2 ) ), 4 ) );  /* Q16 */\r
 \r
         temp32 = 0;\r
@@ -215,7 +224,7 @@ void SKP_Silk_find_LTP_FIX(
         }\r
         temp32 = SKP_DIV32( g_Q26, temp32 ); /* Q14->Q12 */\r
         for( i = 0; i < LTP_ORDER; i++ ) {\r
-            b_Q14_ptr[ i ] = SKP_LIMIT( ( SKP_int32 )b_Q14_ptr[ i ] + SKP_SMULWB( SKP_LSHIFT_SAT32( temp32, 4 ), delta_b_Q14[ i ] ), -16000, 28000 );\r
+            b_Q14_ptr[ i ] = SKP_LIMIT_32( ( SKP_int32 )b_Q14_ptr[ i ] + SKP_SMULWB( SKP_LSHIFT_SAT32( temp32, 4 ), delta_b_Q14[ i ] ), -16000, 28000 );\r
         }\r
         b_Q14_ptr += LTP_ORDER;\r
     }\r
index dc7b2d3284943143ba91856e67aa10983c98c7b3..c290e9de714079e1164476d8770bb0248bb21bc3 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -26,6 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***********************************************************************/\r
 \r
 #include "SKP_Silk_main_FIX.h"\r
+#include "SKP_Silk_tuning_parameters.h"\r
 \r
 /* Find pitch lags */\r
 void SKP_Silk_find_pitch_lags_FIX(\r
@@ -36,19 +37,18 @@ void SKP_Silk_find_pitch_lags_FIX(
 )\r
 {\r
     SKP_Silk_predict_state_FIX *psPredSt = &psEnc->sPred;\r
-    SKP_int   buf_len, i;\r
-    SKP_int32 scale;\r
-    SKP_int32 thrhld_Q15;\r
+    SKP_int   buf_len, i, scale;\r
+    SKP_int32 thrhld_Q15, res_nrg;\r
     const SKP_int16 *x_buf, *x_buf_ptr;\r
     SKP_int16 Wsig[      FIND_PITCH_LPC_WIN_MAX ], *Wsig_ptr;\r
-    SKP_int32 auto_corr[ FIND_PITCH_LPC_ORDER_MAX + 1 ];\r
-    SKP_int16 rc_Q15[    FIND_PITCH_LPC_ORDER_MAX ];\r
-    SKP_int32 A_Q24[     FIND_PITCH_LPC_ORDER_MAX ];\r
-    SKP_int32 FiltState[ FIND_PITCH_LPC_ORDER_MAX ];\r
-    SKP_int16 A_Q12[     FIND_PITCH_LPC_ORDER_MAX ];\r
+    SKP_int32 auto_corr[ MAX_FIND_PITCH_LPC_ORDER + 1 ];\r
+    SKP_int16 rc_Q15[    MAX_FIND_PITCH_LPC_ORDER ];\r
+    SKP_int32 A_Q24[     MAX_FIND_PITCH_LPC_ORDER ];\r
+    SKP_int32 FiltState[ MAX_FIND_PITCH_LPC_ORDER ];\r
+    SKP_int16 A_Q12[     MAX_FIND_PITCH_LPC_ORDER ];\r
 \r
     /******************************************/\r
-    /* Setup buffer lengths etc based of Fs.  */\r
+    /* Setup buffer lengths etc based on Fs   */\r
     /******************************************/\r
     buf_len = SKP_ADD_LSHIFT( psEnc->sCmn.la_pitch, psEnc->sCmn.frame_length, 1 );\r
 \r
@@ -58,7 +58,7 @@ void SKP_Silk_find_pitch_lags_FIX(
     x_buf = x - psEnc->sCmn.frame_length;\r
 \r
     /*************************************/\r
-    /* Estimate LPC AR coeficients */\r
+    /* Estimate LPC AR coefficients      */\r
     /*************************************/\r
     \r
     /* Calculate windowed signal */\r
@@ -66,7 +66,7 @@ void SKP_Silk_find_pitch_lags_FIX(
     /* First LA_LTP samples */\r
     x_buf_ptr = x_buf + buf_len - psPredSt->pitch_LPC_win_length;\r
     Wsig_ptr  = Wsig;\r
-    SKP_Silk_apply_sine_window( Wsig_ptr, x_buf_ptr, 1, psEnc->sCmn.la_pitch );\r
+    SKP_Silk_apply_sine_window_new( Wsig_ptr, x_buf_ptr, 1, psEnc->sCmn.la_pitch );\r
 \r
     /* Middle un - windowed samples */\r
     Wsig_ptr  += psEnc->sCmn.la_pitch;\r
@@ -76,18 +76,21 @@ void SKP_Silk_find_pitch_lags_FIX(
     /* Last LA_LTP samples */\r
     Wsig_ptr  += psPredSt->pitch_LPC_win_length - SKP_LSHIFT( psEnc->sCmn.la_pitch, 1 );\r
     x_buf_ptr += psPredSt->pitch_LPC_win_length - SKP_LSHIFT( psEnc->sCmn.la_pitch, 1 );\r
-    SKP_Silk_apply_sine_window( Wsig_ptr, x_buf_ptr, 2, psEnc->sCmn.la_pitch );\r
+    SKP_Silk_apply_sine_window_new( Wsig_ptr, x_buf_ptr, 2, psEnc->sCmn.la_pitch );\r
 \r
     /* Calculate autocorrelation sequence */\r
     SKP_Silk_autocorr( auto_corr, &scale, Wsig, psPredSt->pitch_LPC_win_length, psEnc->sCmn.pitchEstimationLPCOrder + 1 ); \r
         \r
-    /* add white noise, as fraction of energy */\r
-    auto_corr[ 0 ] = SKP_SMLAWB( auto_corr[ 0 ], auto_corr[ 0 ], FIND_PITCH_WHITE_NOISE_FRACTION_Q16 );\r
+    /* Add white noise, as fraction of energy */\r
+    auto_corr[ 0 ] = SKP_SMLAWB( auto_corr[ 0 ], auto_corr[ 0 ], SKP_FIX_CONST( FIND_PITCH_WHITE_NOISE_FRACTION, 16 ) );\r
 \r
-    /* calculate the reflection coefficients using schur */\r
-    SKP_Silk_schur( rc_Q15, auto_corr, psEnc->sCmn.pitchEstimationLPCOrder );\r
+    /* Calculate the reflection coefficients using schur */\r
+    res_nrg = SKP_Silk_schur( rc_Q15, auto_corr, psEnc->sCmn.pitchEstimationLPCOrder );\r
 \r
-    /* convert reflection coefficients to prediction coefficients */\r
+    /* Prediction gain */\r
+    psEncCtrl->predGain_Q16 = SKP_DIV32_varQ( auto_corr[ 0 ], SKP_max_int( res_nrg, 1 ), 16 );\r
+\r
+    /* Convert reflection coefficients to prediction coefficients */\r
     SKP_Silk_k2a( A_Q24, rc_Q15, psEnc->sCmn.pitchEstimationLPCOrder );\r
     \r
     /* Convert From 32 bit Q24 to 16 bit Q12 coefs */\r
@@ -96,27 +99,27 @@ void SKP_Silk_find_pitch_lags_FIX(
     }\r
 \r
     /* Do BWE */\r
-    SKP_Silk_bwexpander( A_Q12, psEnc->sCmn.pitchEstimationLPCOrder, FIND_PITCH_BANDWITH_EXPANSION_Q16 );\r
+    SKP_Silk_bwexpander( A_Q12, psEnc->sCmn.pitchEstimationLPCOrder, SKP_FIX_CONST( FIND_PITCH_BANDWITH_EXPANSION, 16 ) );\r
     \r
     /*****************************************/\r
     /* LPC analysis filtering                */\r
     /*****************************************/\r
-    SKP_memset( FiltState, 0, psEnc->sCmn.pitchEstimationLPCOrder * sizeof( SKP_int16 ) );\r
+    SKP_memset( FiltState, 0, psEnc->sCmn.pitchEstimationLPCOrder * sizeof( SKP_int32 ) ); /* Not really necessary, but Valgrind will complain otherwise */\r
     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 = ( 1 << 14 ); // 0.5f in Q15\r
-    thrhld_Q15 = SKP_SMLABB( thrhld_Q15, -131, psEnc->sCmn.pitchEstimationLPCOrder );\r
-    thrhld_Q15 = SKP_SMLABB( thrhld_Q15,  -13, ( SKP_int16 )SKP_Silk_SQRT_APPROX( SKP_LSHIFT( ( SKP_int32 )psEnc->speech_activity_Q8, 8 ) ) );\r
-    thrhld_Q15 = SKP_SMLABB( thrhld_Q15, 4587, psEnc->sCmn.prev_sigtype );\r
-    thrhld_Q15 = SKP_MLA(    thrhld_Q15,  -31, SKP_RSHIFT( psEncCtrl->input_tilt_Q15, 8 ) );\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
 \r
     /*****************************************/\r
-    /* Call Pitch estimator */\r
+    /* Call pitch estimator                  */\r
     /*****************************************/\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->pitchEstimationThreshold_Q16, \r
-        ( SKP_int16 )thrhld_Q15, psEnc->sCmn.fs_kHz, psEnc->sCmn.pitchEstimationComplexity );\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, SKP_FALSE );\r
 }\r
index 57b091ed98730b6d47ee32290235de4835c02239..cce22c589fd1fa7a02555a48dfac631a571fe08b 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -28,9 +28,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "SKP_Silk_main_FIX.h"\r
 \r
 \r
-#define VARQ        1 // EXPERIMENTAL\r
-#define Qx          0 // EXPERIMENTAL\r
-\r
 void SKP_Silk_find_pred_coefs_FIX(\r
     SKP_Silk_encoder_state_FIX      *psEnc,         /* I/O  encoder state                               */\r
     SKP_Silk_encoder_control_FIX    *psEncCtrl,     /* I/O  encoder control                             */\r
@@ -39,15 +36,11 @@ void SKP_Silk_find_pred_coefs_FIX(
 {\r
     SKP_int         i;\r
     SKP_int32       WLTP[ NB_SUBFR * LTP_ORDER * LTP_ORDER ];\r
-    SKP_int32       invGains_Q16[ NB_SUBFR ], local_gains_Qx[ NB_SUBFR ], Wght_Q15[ NB_SUBFR ];\r
+    SKP_int32       invGains_Q16[ NB_SUBFR ], local_gains[ NB_SUBFR ], Wght_Q15[ NB_SUBFR ];\r
     SKP_int         NLSF_Q15[ MAX_LPC_ORDER ];\r
     const SKP_int16 *x_ptr;\r
     SKP_int16       *x_pre_ptr, LPC_in_pre[ NB_SUBFR * MAX_LPC_ORDER + MAX_FRAME_LENGTH ];\r
-\r
     SKP_int32       tmp, min_gain_Q16;\r
-#if !VARQ\r
-    SKP_int         LZ;\r
-#endif\r
     SKP_int         LTP_corrs_rshift[ NB_SUBFR ];\r
 \r
 \r
@@ -56,20 +49,11 @@ void SKP_Silk_find_pred_coefs_FIX(
     for( i = 0; i < NB_SUBFR; i++ ) {\r
         min_gain_Q16 = SKP_min( min_gain_Q16, psEncCtrl->Gains_Q16[ i ] );\r
     }\r
-#if !VARQ\r
-    LZ = SKP_Silk_CLZ32( min_gain_Q16 ) - 1;\r
-    LZ = SKP_LIMIT( LZ, 0, 16 );\r
-    min_gain_Q16 = SKP_RSHIFT( min_gain_Q16, 2 ); /* Ensure that maximum invGains_Q16 is within range of a 16 bit int */\r
-#endif\r
     for( i = 0; i < NB_SUBFR; i++ ) {\r
         /* Divide to Q16 */\r
         SKP_assert( psEncCtrl->Gains_Q16[ i ] > 0 );\r
-#if VARQ\r
         /* Invert and normalize gains, and ensure that maximum invGains_Q16 is within range of a 16 bit int */\r
         invGains_Q16[ i ] = SKP_DIV32_varQ( min_gain_Q16, psEncCtrl->Gains_Q16[ i ], 16 - 2 );\r
-#else\r
-        invGains_Q16[ i ] = SKP_DIV32( SKP_LSHIFT( min_gain_Q16, LZ ), SKP_RSHIFT( psEncCtrl->Gains_Q16[ i ], 16 - LZ ) );\r
-#endif\r
 \r
         /* Ensure Wght_Q15 a minimum value 1 */\r
         invGains_Q16[ i ] = SKP_max( invGains_Q16[ i ], 363 ); \r
@@ -80,7 +64,7 @@ void SKP_Silk_find_pred_coefs_FIX(
         Wght_Q15[ i ] = SKP_RSHIFT( tmp, 1 );\r
 \r
         /* Invert the inverted and normalized gains */\r
-        local_gains_Qx[ i ] = SKP_DIV32( ( 1 << ( 16 + Qx ) ), invGains_Q16[ i ] );\r
+        local_gains[ i ] = SKP_DIV32( ( 1 << 16 ), invGains_Q16[ i ] );\r
     }\r
 \r
     if( psEncCtrl->sCmn.sigtype == SIG_TYPE_VOICED ) {\r
@@ -104,7 +88,7 @@ void SKP_Silk_find_pred_coefs_FIX(
 \r
         /* Create LTP residual */\r
         SKP_Silk_LTP_analysis_filter_FIX( LPC_in_pre, psEnc->x_buf + psEnc->sCmn.frame_length - psEnc->sCmn.predictLPCOrder, \r
-            psEncCtrl->LTPCoef_Q14, psEncCtrl->sCmn.pitchL, invGains_Q16, 16, psEnc->sCmn.subfr_length, psEnc->sCmn.predictLPCOrder );\r
+            psEncCtrl->LTPCoef_Q14, psEncCtrl->sCmn.pitchL, invGains_Q16, psEnc->sCmn.subfr_length, psEnc->sCmn.predictLPCOrder );\r
 \r
     } else {\r
         /************/\r
@@ -138,7 +122,7 @@ void SKP_Silk_find_pred_coefs_FIX(
     TOC(PROCESS_LSFS)\r
 \r
     /* Calculate residual energy using quantized LPC coefficients */\r
-    SKP_Silk_residual_energy_FIX( psEncCtrl->ResNrg, psEncCtrl->ResNrgQ, LPC_in_pre, psEncCtrl->PredCoef_Q12, local_gains_Qx, Qx,\r
+    SKP_Silk_residual_energy_FIX( psEncCtrl->ResNrg, psEncCtrl->ResNrgQ, LPC_in_pre, psEncCtrl->PredCoef_Q12, local_gains,\r
         psEnc->sCmn.subfr_length, psEnc->sCmn.predictLPCOrder );\r
 \r
     /* Copy to prediction struct for use in next frame for fluctuation reduction */\r
index 6e1fb4bb406649fa80bec8b13511f87a1f8d09ec..0285c444ae35210cd57707d0cc0d56ec4f3e1e59 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -53,12 +53,12 @@ void SKP_Silk_gains_quant(
         /* Compute delta indices and limit */\r
         if( k == 0 && conditional == 0 ) {\r
             /* Full index */\r
-            ind[ k ] = SKP_LIMIT( ind[ k ], 0, N_LEVELS_QGAIN - 1 );\r
+            ind[ k ] = SKP_LIMIT_int( ind[ k ], 0, N_LEVELS_QGAIN - 1 );\r
             ind[ k ] = SKP_max_int( ind[ k ], *prev_ind + MIN_DELTA_GAIN_QUANT );\r
             *prev_ind = ind[ k ];\r
         } else {\r
             /* Delta index */\r
-            ind[ k ] = SKP_LIMIT( ind[ k ] - *prev_ind, MIN_DELTA_GAIN_QUANT, MAX_DELTA_GAIN_QUANT );\r
+            ind[ k ] = SKP_LIMIT_int( ind[ k ] - *prev_ind, MIN_DELTA_GAIN_QUANT, MAX_DELTA_GAIN_QUANT );\r
             /* Accumulate deltas */\r
             *prev_ind += ind[ k ];\r
             /* Shift to make non-negative */\r
index 457c37b1bbc9344473dea706453fcbc277cafbe8..9a3617063b6cb1db5cabad0557e46a61328e93a1 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -31,16 +31,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 /* Initialize Silk Encoder state */\r
 /*********************************/\r
 SKP_int SKP_Silk_init_encoder_FIX(\r
-    SKP_Silk_encoder_state_FIX  *psEnc          /* I/O  Pointer to Silk encoder state               */\r
-)\r
-{\r
+    SKP_Silk_encoder_state_FIX  *psEnc                  /* I/O  Pointer to Silk FIX encoder state       */\r
+) {\r
     SKP_int ret = 0;\r
     /* Clear the entire encoder state */\r
     SKP_memset( psEnc, 0, sizeof( SKP_Silk_encoder_state_FIX ) );\r
 \r
-    /* Initialize to 24 kHz sampling, 20 ms packets, 25 kbps, 0% packet loss, and init non-zero values */\r
-    ret = SKP_Silk_control_encoder_FIX( psEnc, 24, 20, 25, 0, 0, 0, 10, 1 );\r
-\r
 #if HIGH_PASS_INPUT\r
     psEnc->variable_HP_smth1_Q15 = 200844; /* = SKP_Silk_log2(70)_Q0; */\r
     psEnc->variable_HP_smth2_Q15 = 200844; /* = SKP_Silk_log2(70)_Q0; */\r
@@ -48,17 +44,13 @@ SKP_int SKP_Silk_init_encoder_FIX(
 \r
     /* Used to deactivate e.g. LSF interpolation and fluctuation reduction */\r
     psEnc->sCmn.first_frame_after_reset = 1;\r
-    psEnc->sCmn.fs_kHz_changed          = 0;\r
-    psEnc->sCmn.LBRR_enabled            = 0;\r
 \r
     /* Initialize Silk VAD */\r
     ret += SKP_Silk_VAD_Init( &psEnc->sCmn.sVAD );\r
 \r
     /* Initialize NSQ */\r
-    psEnc->sNSQ.prev_inv_gain_Q16      = 65536; /* 1.0 in Q16 */\r
-    psEnc->sNSQ_LBRR.prev_inv_gain_Q16 = 65536; /* 1.0 in Q16 */\r
-\r
-    psEnc->sCmn.bitstream_v     = USE_BIT_STREAM_V;\r
+    psEnc->sNSQ.prev_inv_gain_Q16      = 65536;\r
+    psEnc->sNSQ_LBRR.prev_inv_gain_Q16 = 65536;\r
 \r
     return( ret );\r
 }\r
index 3ade172e170af4322c33ab49b6b82c8a74686e4a..940160183a51dde9dd440a9051aba263e6ad1541 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -28,8 +28,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 /*                                                                                *\r
  * SKP_Silk_inner_prod_aligned.c                                                *\r
  *                                                                                *\r
- *                                                                                *\r
- * Copyright 2008 (c), Skype Limited                                              *\r
+ *                                                                                *\r
+ * Copyright 2008-2010 (c), Skype Limited                                              *\r
  * Date: 080601                                                                   *\r
  *                                                                                */\r
 #include "SKP_Silk_SigProc_FIX.h"\r
@@ -54,19 +54,6 @@ SKP_int32 SKP_Silk_inner_prod_aligned(
     return sum;\r
 }\r
 \r
-SKP_int64 SKP_Silk_inner_prod_aligned_64(\r
-    const SKP_int32 *inVec1,        /*    I input vector 1    */ \r
-    const SKP_int32 *inVec2,        /*    I input vector 2    */\r
-    const SKP_int   len             /*    I vector lengths    */\r
-)\r
-{\r
-    SKP_int   i; \r
-    SKP_int64 sum = 0;\r
-    for( i = 0; i < len; i++ ) {\r
-        sum = SKP_SMLAL( sum, inVec1[ i ], inVec2[ i ] );\r
-    }\r
-    return sum;\r
-}\r
 SKP_int64 SKP_Silk_inner_prod16_aligned_64(\r
     const SKP_int16 *inVec1,        /*    I input vector 1    */ \r
     const SKP_int16 *inVec2,        /*    I input vector 2    */\r
@@ -80,17 +67,3 @@ SKP_int64 SKP_Silk_inner_prod16_aligned_64(
     }\r
     return sum;\r
 }\r
-\r
-SKP_int32 SKP_Silk_inner_prod16_aligned_sat(\r
-    const SKP_int16* const inVec1,  /*    I input vector 1  */ \r
-    const SKP_int16* const inVec2,  /*    I input vector 2  */\r
-    const SKP_int    len            /*    I vector lengths  */ \r
-)\r
-{\r
-    SKP_int   i; \r
-    SKP_int32 sum = 0;\r
-    for( i = 0; i < len; i++ ) {\r
-        sum = SKP_ADD_SAT32( sum, SKP_SMULBB( inVec1[ i ], inVec2[ i ] ) );\r
-    }\r
-    return sum;\r
-}\r
index b12778f9f86e7f84ab53ee95cc11951746088271..f3adcbedab7516990b8860ffc4de9a57db7aa954 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
index 0f9c34151d7f278a03a2df17c93b7016fb488e13..0cb5482a6d30c77559034976b25a6de71ae458e6 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -44,7 +44,7 @@ void SKP_Silk_k2a(
 )\r
 {\r
     SKP_int   k, n;\r
-    SKP_int32 Atmp[ SigProc_MAX_ORDER_LPC ];\r
+    SKP_int32 Atmp[ SKP_Silk_MAX_ORDER_LPC ];\r
 \r
     for( k = 0; k < order; k++ ) {\r
         for( n = 0; n < k; n++ ) {\r
index bc8e78c32287dd9e97b2f6f3d411b8142e1982a2..c59719de6450e7573314e8e3fc00ef6b77468c99 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -44,7 +44,7 @@ void SKP_Silk_k2a_Q16(
 )\r
 {\r
     SKP_int   k, n;\r
-    SKP_int32 Atmp[ SigProc_MAX_ORDER_LPC ];\r
+    SKP_int32 Atmp[ SKP_Silk_MAX_ORDER_LPC ];\r
 \r
     for( k = 0; k < order; k++ ) {\r
         for( n = 0; n < k; n++ ) {\r
index 6b3e7ed63d35bf394c9fb6eab039c95edc227010..31cb05bffc525869ad62e71dd7d07bb0964bd4bc 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
index b06ce303f813b509fc831c8aaa5df4c00ab63d8e..258627cf328952a55ea3fabac05f6b09c36a058a 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
diff --git a/libs/silk/src/SKP_Silk_lowpass_int.c b/libs/silk/src/SKP_Silk_lowpass_int.c
deleted file mode 100644 (file)
index fbe9bda..0000000
+++ /dev/null
@@ -1,61 +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
-/*                                                                      *\r
- * SKP_Silk_lowpass_int.c                                             *\r
- *                                                                      *\r
- * First order low-pass filter, with input as SKP_int32, running at     *\r
- * 48 kHz                                                               *\r
- *                                                                      *\r
- * Copyright 2006 (c), Skype Limited                                    *\r
- * Date: 060221                                                         *\r
- *                                                                      */\r
-#include "SKP_Silk_SigProc_FIX.h"\r
-\r
-/* First order low-pass filter, with input as SKP_int32, running at 48 kHz        */\r
-void SKP_Silk_lowpass_int(\r
-    const SKP_int32      *in,            /* I:    Q25 48 kHz signal; length = len */\r
-    SKP_int32            *S,             /* I/O: Q25 state; length = 1            */\r
-    SKP_int32            *out,           /* O:    Q25 48 kHz signal; length = len */\r
-    const SKP_int32      len             /* I:    Number of samples               */\r
-)\r
-{\r
-    SKP_int        k;\r
-    SKP_int32    in_tmp, out_tmp, state;\r
-    \r
-    state = S[ 0 ];\r
-    for( k = len; k > 0; k-- ) {    \r
-        in_tmp  = *in++;\r
-        in_tmp -= SKP_RSHIFT( in_tmp, 2 );              /* multiply by 0.75 */\r
-        out_tmp = state + in_tmp;                       /* zero at nyquist  */\r
-        state   = in_tmp - SKP_RSHIFT( out_tmp, 1 );    /* pole             */\r
-        *out++  = out_tmp;\r
-    }\r
-    S[ 0 ] = state;\r
-}\r
-\r
-\r
diff --git a/libs/silk/src/SKP_Silk_lowpass_short.c b/libs/silk/src/SKP_Silk_lowpass_short.c
deleted file mode 100644 (file)
index f8bfcf6..0000000
+++ /dev/null
@@ -1,61 +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
-/*                                                                      *\r
- * SKP_Silk_lowpass_short.c                                           *\r
- *                                                                      *\r
- * First order low-pass filter, with input as SKP_int16, running at     *\r
- * 48 kHz                                                               *\r
- *                                                                      *\r
- * Copyright 2006 (c), Skype Limited                                    *\r
- * Date: 060221                                                         *\r
- *                                                                      */\r
-#include "SKP_Silk_SigProc_FIX.h"\r
-\r
-\r
-/* First order low-pass filter, with input as SKP_int16, running at 48 kHz   */\r
-void SKP_Silk_lowpass_short(\r
-    const SKP_int16          *in,        /* I:   Q15 48 kHz signal; [len]    */\r
-    SKP_int32                *S,         /* I/O: Q25 state; length = 1       */\r
-    SKP_int32                *out,       /* O:   Q25 48 kHz signal; [len]    */\r
-    const SKP_int32          len         /* O:   Signal length               */\r
-)\r
-{\r
-    SKP_int        k;\r
-    SKP_int32    in_tmp, out_tmp, state;\r
-    \r
-    state = S[ 0 ];\r
-    for( k = 0; k < len; k++ ) {    \r
-        in_tmp   = SKP_MUL( 768, (SKP_int32)in[k] );    /* multiply by 0.75, going from Q15 to Q25 */\r
-        out_tmp  = state + in_tmp;                      /* zero at nyquist                         */\r
-        state    = in_tmp - SKP_RSHIFT( out_tmp, 1 );   /* pole                                    */\r
-        out[ k ] = out_tmp;\r
-    }\r
-    S[ 0 ] = state;\r
-}\r
-\r
-\r
index c42aa76e17086f6cb095c161a5d00b961e31e2fa..53b0a17fc72a68c425cfa63990e043f0a2454ebb 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -31,91 +31,91 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 // This is an inline header file for general platform.\r
 \r
 // (a32 * (SKP_int32)((SKP_int16)(b32))) >> 16 output have to be 32bit int\r
-#define SKP_SMULWB(a32, b32)                   ((((a32) >> 16) * (SKP_int32)((SKP_int16)(b32))) + ((((a32) & 0x0000FFFF) * (SKP_int32)((SKP_int16)(b32))) >> 16))\r
+#define SKP_SMULWB(a32, b32)            ((((a32) >> 16) * (SKP_int32)((SKP_int16)(b32))) + ((((a32) & 0x0000FFFF) * (SKP_int32)((SKP_int16)(b32))) >> 16))\r
 \r
 // a32 + (b32 * (SKP_int32)((SKP_int16)(c32))) >> 16 output have to be 32bit int\r
-#define SKP_SMLAWB(a32, b32, c32)              ((a32) + ((((b32) >> 16) * (SKP_int32)((SKP_int16)(c32))) + ((((b32) & 0x0000FFFF) * (SKP_int32)((SKP_int16)(c32))) >> 16)))\r
+#define SKP_SMLAWB(a32, b32, c32)       ((a32) + ((((b32) >> 16) * (SKP_int32)((SKP_int16)(c32))) + ((((b32) & 0x0000FFFF) * (SKP_int32)((SKP_int16)(c32))) >> 16)))\r
 \r
 // (a32 * (b32 >> 16)) >> 16\r
-#define SKP_SMULWT(a32, b32)                   (((a32) >> 16) * ((b32) >> 16) + ((((a32) & 0x0000FFFF) * ((b32) >> 16)) >> 16))\r
+#define SKP_SMULWT(a32, b32)            (((a32) >> 16) * ((b32) >> 16) + ((((a32) & 0x0000FFFF) * ((b32) >> 16)) >> 16))\r
 \r
 // a32 + (b32 * (c32 >> 16)) >> 16\r
-#define SKP_SMLAWT(a32, b32, c32)              ((a32) + (((b32) >> 16) * ((c32) >> 16)) + ((((b32) & 0x0000FFFF) * ((c32) >> 16)) >> 16))\r
+#define SKP_SMLAWT(a32, b32, c32)       ((a32) + (((b32) >> 16) * ((c32) >> 16)) + ((((b32) & 0x0000FFFF) * ((c32) >> 16)) >> 16))\r
 \r
 // (SKP_int32)((SKP_int16)(a3))) * (SKP_int32)((SKP_int16)(b32)) output have to be 32bit int\r
-#define SKP_SMULBB(a32, b32)                   ((SKP_int32)((SKP_int16)(a32)) * (SKP_int32)((SKP_int16)(b32)))\r
+#define SKP_SMULBB(a32, b32)            ((SKP_int32)((SKP_int16)(a32)) * (SKP_int32)((SKP_int16)(b32)))\r
 \r
 // a32 + (SKP_int32)((SKP_int16)(b32)) * (SKP_int32)((SKP_int16)(c32)) output have to be 32bit int\r
-#define SKP_SMLABB(a32, b32, c32)              ((a32) + ((SKP_int32)((SKP_int16)(b32))) * (SKP_int32)((SKP_int16)(c32)))\r
+#define SKP_SMLABB(a32, b32, c32)       ((a32) + ((SKP_int32)((SKP_int16)(b32))) * (SKP_int32)((SKP_int16)(c32)))\r
 \r
 // (SKP_int32)((SKP_int16)(a32)) * (b32 >> 16)\r
-#define SKP_SMULBT(a32, b32)                   ((SKP_int32)((SKP_int16)(a32)) * ((b32) >> 16))\r
+#define SKP_SMULBT(a32, b32)            ((SKP_int32)((SKP_int16)(a32)) * ((b32) >> 16))\r
 \r
 // a32 + (SKP_int32)((SKP_int16)(b32)) * (c32 >> 16)\r
-#define SKP_SMLABT(a32, b32, c32)              ((a32) + ((SKP_int32)((SKP_int16)(b32))) * ((c32) >> 16))\r
+#define SKP_SMLABT(a32, b32, c32)       ((a32) + ((SKP_int32)((SKP_int16)(b32))) * ((c32) >> 16))\r
 \r
 // a64 + (b32 * c32)\r
-#define SKP_SMLAL(a64, b32, c32)               (SKP_ADD64((a64), ((SKP_int64)(b32) * (SKP_int64)(c32))))\r
+#define SKP_SMLAL(a64, b32, c32)        (SKP_ADD64((a64), ((SKP_int64)(b32) * (SKP_int64)(c32))))\r
 \r
 // (a32 * b32) >> 16\r
-#define SKP_SMULWW(a32, b32)                   SKP_MLA(SKP_SMULWB((a32), (b32)), (a32), SKP_RSHIFT_ROUND((b32), 16))\r
+#define SKP_SMULWW(a32, b32)            SKP_MLA(SKP_SMULWB((a32), (b32)), (a32), SKP_RSHIFT_ROUND((b32), 16))\r
 \r
 // a32 + ((b32 * c32) >> 16)\r
-#define SKP_SMLAWW(a32, b32, c32)              SKP_MLA(SKP_SMLAWB((a32), (b32), (c32)), (b32), SKP_RSHIFT_ROUND((c32), 16))\r
+#define SKP_SMLAWW(a32, b32, c32)       SKP_MLA(SKP_SMLAWB((a32), (b32), (c32)), (b32), SKP_RSHIFT_ROUND((c32), 16))\r
 \r
 /* add/subtract with output saturated */\r
-#define SKP_ADD_SAT32(a, b)                            ((((a) + (b)) & 0x80000000) == 0 ?                                                              \\r
-                                                                               ((((a) & (b)) & 0x80000000) != 0 ? SKP_int32_MIN : (a)+(b)) :   \\r
-                                                                               ((((a) | (b)) & 0x80000000) == 0 ? SKP_int32_MAX : (a)+(b)) )\r
-\r
-#define SKP_SUB_SAT32(a, b)                            ((((a)-(b)) & 0x80000000) == 0 ?                                                                                \\r
-                                                                               (( (a) & ((b)^0x80000000) & 0x80000000) ? SKP_int32_MIN : (a)-(b)) :    \\r
-                                                                               ((((a)^0x80000000) & (b)  & 0x80000000) ? SKP_int32_MAX : (a)-(b)) )\r
-       \r
+#define SKP_ADD_SAT32(a, b)             ((((a) + (b)) & 0x80000000) == 0 ?                              \\r
+                                        ((((a) & (b)) & 0x80000000) != 0 ? SKP_int32_MIN : (a)+(b)) :   \\r
+                                        ((((a) | (b)) & 0x80000000) == 0 ? SKP_int32_MAX : (a)+(b)) )\r
+\r
+#define SKP_SUB_SAT32(a, b)             ((((a)-(b)) & 0x80000000) == 0 ?                                        \\r
+                                        (( (a) & ((b)^0x80000000) & 0x80000000) ? SKP_int32_MIN : (a)-(b)) :    \\r
+                                        ((((a)^0x80000000) & (b)  & 0x80000000) ? SKP_int32_MAX : (a)-(b)) )\r
+    \r
 SKP_INLINE SKP_int32 SKP_Silk_CLZ16(SKP_int16 in16)\r
 {\r
-       SKP_int32 out32 = 0;\r
-       if( in16 == 0 ) {\r
-               return 16;\r
-       }\r
-       /* test nibbles */\r
-       if( in16 & 0xFF00 ) {\r
-               if( in16 & 0xF000 )     {\r
-                       in16 >>= 12;\r
-               } else {\r
-                       out32 += 4;\r
-                       in16 >>= 8;\r
-               }\r
-       } else {\r
-               if( in16 & 0xFFF0 )     {\r
-                       out32 += 8;\r
-                       in16 >>= 4;\r
-               } else {\r
-                       out32 += 12;\r
-               }\r
-       }\r
-       /* test bits and return */\r
-       if( in16 & 0xC ) {\r
-               if( in16 & 0x8 )\r
-                       return out32 + 0;\r
-               else\r
-                       return out32 + 1;\r
-       } else {\r
-               if( in16 & 0xE )\r
-                       return out32 + 2;\r
-               else\r
-                       return out32 + 3;\r
-       }\r
+    SKP_int32 out32 = 0;\r
+    if( in16 == 0 ) {\r
+        return 16;\r
+    }\r
+    /* test nibbles */\r
+    if( in16 & 0xFF00 ) {\r
+        if( in16 & 0xF000 ) {\r
+            in16 >>= 12;\r
+        } else {\r
+            out32 += 4;\r
+            in16 >>= 8;\r
+        }\r
+    } else {\r
+        if( in16 & 0xFFF0 ) {\r
+            out32 += 8;\r
+            in16 >>= 4;\r
+        } else {\r
+            out32 += 12;\r
+        }\r
+    }\r
+    /* test bits and return */\r
+    if( in16 & 0xC ) {\r
+        if( in16 & 0x8 )\r
+            return out32 + 0;\r
+        else\r
+            return out32 + 1;\r
+    } else {\r
+        if( in16 & 0xE )\r
+            return out32 + 2;\r
+        else\r
+            return out32 + 3;\r
+    }\r
 }\r
 \r
 SKP_INLINE SKP_int32 SKP_Silk_CLZ32(SKP_int32 in32)\r
 {\r
-       /* test highest 16 bits and convert to SKP_int16 */\r
-       if( in32 & 0xFFFF0000 ) {\r
-               return SKP_Silk_CLZ16((SKP_int16)(in32 >> 16));\r
-       } else {\r
-               return SKP_Silk_CLZ16((SKP_int16)in32) + 16;\r
-       }\r
+    /* test highest 16 bits and convert to SKP_int16 */\r
+    if( in32 & 0xFFFF0000 ) {\r
+        return SKP_Silk_CLZ16((SKP_int16)(in32 >> 16));\r
+    } else {\r
+        return SKP_Silk_CLZ16((SKP_int16)in32) + 16;\r
+    }\r
 }\r
 \r
 #endif //_SKP_SILK_API_C_H_\r
index d5b0a7340a69a2b2e06378554210ac88384a096e..55b7057a009625a0933a431cffe25c6f75658a7b 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -28,21 +28,22 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #ifndef SKP_SILK_MAIN_H\r
 #define SKP_SILK_MAIN_H\r
 \r
+#ifdef __cplusplus\r
+extern "C"\r
+{\r
+#endif\r
+\r
 #include "SKP_Silk_SigProc_FIX.h"\r
 #include "SKP_Silk_define.h"\r
 #include "SKP_Silk_structs.h"\r
 #include "SKP_Silk_tables.h"\r
 #include "SKP_Silk_PLC.h"\r
 \r
-#ifdef __cplusplus\r
-extern "C"\r
-{\r
-#endif\r
 \r
 /* Encodes signs of excitation */\r
 void SKP_Silk_encode_signs(\r
     SKP_Silk_range_coder_state  *psRC,              /* I/O  Range coder state                           */\r
-    const SKP_int               q[],                /* I    pulse signal                                */\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
@@ -59,6 +60,12 @@ void SKP_Silk_decode_signs(
     const SKP_int               RateLevelIndex      /* I    Rate Level Index                            */\r
 );\r
 \r
+/* Control internal sampling rate */\r
+SKP_int SKP_Silk_control_audio_bandwidth(\r
+    SKP_Silk_encoder_state      *psEncC,            /* I/O  Pointer to Silk encoder state               */\r
+    const SKP_int32             TargetRate_bps      /* I    Target max bitrate (bps)                    */\r
+);\r
+\r
 /***************/\r
 /* Shell coder */\r
 /***************/\r
@@ -68,7 +75,7 @@ void SKP_Silk_encode_pulses(
     SKP_Silk_range_coder_state  *psRC,              /* I/O  Range coder state                           */\r
     const SKP_int               sigtype,            /* I    Sigtype                                     */\r
     const SKP_int               QuantOffsetType,    /* I    QuantOffsetType                             */\r
-    const SKP_int               q[],                /* I    quantization indices                        */\r
+    const SKP_int8              q[],                /* I    quantization indices                        */\r
     const SKP_int               frame_length        /* I    Frame length                                */\r
 );\r
 \r
@@ -188,11 +195,11 @@ void SKP_Silk_NSQ(
     SKP_Silk_encoder_control        *psEncCtrlC,                                /* I    Encoder Control                     */\r
     SKP_Silk_nsq_state              *NSQ,                                       /* I/O  NSQ state                           */\r
     const SKP_int16                 x[],                                        /* I    prefiltered input signal            */\r
-    SKP_int                         q[],                                        /* O    quantized qulse signal              */\r
+    SKP_int8                        q[],                                        /* O    quantized qulse signal              */\r
     const SKP_int                   LSFInterpFactor_Q2,                         /* I    LSF interpolation factor in Q2      */\r
     const SKP_int16                 PredCoef_Q12[ 2 * MAX_LPC_ORDER ],          /* I    Short term prediction coefficients  */\r
     const SKP_int16                 LTPCoef_Q14[ LTP_ORDER * NB_SUBFR ],        /* I    Long term prediction coefficients   */\r
-    const SKP_int16                 AR2_Q13[ NB_SUBFR * SHAPE_LPC_ORDER_MAX ],  /* I                                        */\r
+    const SKP_int16                 AR2_Q13[ NB_SUBFR * MAX_SHAPE_LPC_ORDER ],  /* I                                        */\r
     const SKP_int                   HarmShapeGain_Q14[ NB_SUBFR ],              /* I                                        */\r
     const SKP_int                   Tilt_Q14[ NB_SUBFR ],                       /* I    Spectral tilt                       */\r
     const SKP_int32                 LF_shp_Q14[ NB_SUBFR ],                     /* I                                        */\r
@@ -207,11 +214,11 @@ void SKP_Silk_NSQ_del_dec(
     SKP_Silk_encoder_control        *psEncCtrlC,                                /* I    Encoder Control                     */\r
     SKP_Silk_nsq_state              *NSQ,                                       /* I/O  NSQ state                           */\r
     const SKP_int16                 x[],                                        /* I    Prefiltered input signal            */\r
-    SKP_int                         q[],                                        /* O    Quantized pulse signal              */\r
+    SKP_int8                        q[],                                        /* O    Quantized pulse signal              */\r
     const SKP_int                   LSFInterpFactor_Q2,                         /* I    LSF interpolation factor in Q2      */\r
     const SKP_int16                 PredCoef_Q12[ 2 * MAX_LPC_ORDER ],          /* I    Prediction coefs                    */\r
     const SKP_int16                 LTPCoef_Q14[ LTP_ORDER * NB_SUBFR ],        /* I    LT prediction coefs                 */\r
-    const SKP_int16                 AR2_Q13[ NB_SUBFR * SHAPE_LPC_ORDER_MAX ],  /* I                                        */\r
+    const SKP_int16                 AR2_Q13[ NB_SUBFR * MAX_SHAPE_LPC_ORDER ],  /* I                                        */\r
     const SKP_int                   HarmShapeGain_Q14[ NB_SUBFR ],              /* I                                        */\r
     const SKP_int                   Tilt_Q14[ NB_SUBFR ],                       /* I    Spectral tilt                       */\r
     const SKP_int32                 LF_shp_Q14[ NB_SUBFR ],                     /* I                                        */\r
@@ -306,19 +313,6 @@ void SKP_Silk_decode_parameters(
     const SKP_int               fullDecoding        /* I    Flag to tell if only arithmetic decoding    */\r
 );\r
 \r
-/* Decode indices from payload v4 Bitstream */\r
-void SKP_Silk_decode_indices_v4(\r
-    SKP_Silk_decoder_state      *psDec              /* I/O  State                                       */\r
-);\r
-\r
-/* Decode parameters from payload v4 Bitstream */\r
-void SKP_Silk_decode_parameters_v4(\r
-    SKP_Silk_decoder_state      *psDec,                                 /* I/O  State                                    */\r
-    SKP_Silk_decoder_control    *psDecCtrl,                             /* I/O  Decoder control                          */\r
-    SKP_int                     q[ MAX_FRAME_LENGTH ],                  /* O    Excitation signal                        */\r
-    const SKP_int               fullDecoding                            /* I    Flag to tell if only arithmetic decoding */\r
-);\r
-\r
 /* Core decoder. Performs inverse NSQ operation LTP + LPC */\r
 void SKP_Silk_decode_core(\r
     SKP_Silk_decoder_state      *psDec,                             /* I/O  Decoder state               */\r
@@ -369,14 +363,7 @@ void SKP_Silk_encode_parameters(
     SKP_Silk_encoder_state      *psEncC,            /* I/O  Encoder state                               */\r
     SKP_Silk_encoder_control    *psEncCtrlC,        /* I/O  Encoder control                             */\r
     SKP_Silk_range_coder_state  *psRC,              /* I/O  Range coder state                           */\r
-    const SKP_int               *q                  /* I    Quantization indices                        */\r
-);\r
-\r
-/* Encoding of various parameters */\r
-void SKP_Silk_encode_parameters_v4(\r
-    SKP_Silk_encoder_state      *psEncC,            /* I/O  Encoder state                               */\r
-    SKP_Silk_encoder_control    *psEncCtrlC,        /* I/O  Encoder control                             */\r
-    SKP_Silk_range_coder_state  *psRC               /* I/O  Range encoder state                         */\r
+    const SKP_int8               *q                 /* I    Quantization indices                        */\r
 );\r
 \r
 /* Extract lowest layer encoding */\r
@@ -392,11 +379,6 @@ void SKP_Silk_LBRR_reset(
     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
-    SKP_int                     q[]                 /* I     Pulse signal */\r
-);\r
 \r
 #ifdef __cplusplus\r
 }\r
index ff28f9a13b9d185f9ef4bfb1d189bc60da47d558..935e6c74378a13259674f3cbea7c21235dc8f7e1 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -32,7 +32,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "SKP_Silk_SigProc_FIX.h"\r
 #include "SKP_Silk_structs_FIX.h"\r
 #include "SKP_Silk_main.h"\r
-#include "SKP_Silk_define_FIX.h"\r
 #include "SKP_Silk_PLC.h"\r
 #define TIC(TAG_NAME)\r
 #define TOC(TAG_NAME)\r
@@ -50,20 +49,17 @@ extern "C"
 \r
 /* Initializes the Silk encoder state */\r
 SKP_int SKP_Silk_init_encoder_FIX(\r
-    SKP_Silk_encoder_state_FIX  *psEnc              /* I/O  Pointer to Silk FIX encoder state           */\r
+    SKP_Silk_encoder_state_FIX  *psEnc                  /* I/O  Pointer to Silk FIX encoder state       */\r
 );\r
 \r
 /* Control the Silk encoder */\r
 SKP_int SKP_Silk_control_encoder_FIX( \r
-    SKP_Silk_encoder_state_FIX  *psEnc,             /* I/O  Pointer to Silk FIX encoder state               */\r
-    const SKP_int               API_fs_kHz,         /* I    External (API) sampling rate (kHz)              */\r
-    const SKP_int               PacketSize_ms,      /* I    Packet length (ms)                              */\r
-    SKP_int32                   TargetRate_bps,     /* I    Target max bitrate (bps) (used if SNR_dB == 0)  */\r
-    const SKP_int               PacketLoss_perc,    /* I    Packet loss rate (in percent)                   */\r
-    const SKP_int               INBandFec_enabled,  /* I    Enable (1) / disable (0) inband FEC             */\r
-    const SKP_int               DTX_enabled,        /* I    Enable / disable DTX                            */\r
-    const SKP_int               InputFramesize_ms,  /* I    Inputframe in ms                                */\r
-    const SKP_int               Complexity          /* I    Complexity (0->low; 1->medium; 2->high)         */\r
+    SKP_Silk_encoder_state_FIX  *psEnc,                 /* I/O  Pointer to Silk encoder state           */\r
+    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               DTX_enabled,            /* I    Enable / disable DTX                    */\r
+    const SKP_int               Complexity              /* I    Complexity (0->low; 1->medium; 2->high) */\r
 );\r
 \r
 /* Encoder main function */\r
@@ -106,10 +102,20 @@ void SKP_Silk_prefilter_FIX(
 /* Compute noise shaping coefficients and initial gain values */\r
 /**************************************************************/\r
 void SKP_Silk_noise_shape_analysis_FIX(\r
-    SKP_Silk_encoder_state_FIX      *psEnc,         /* I/O  Encoder state                               */\r
-    SKP_Silk_encoder_control_FIX    *psEncCtrl,     /* I/O  Encoder control                             */\r
+    SKP_Silk_encoder_state_FIX      *psEnc,         /* I/O  Encoder state FIX                           */\r
+    SKP_Silk_encoder_control_FIX    *psEncCtrl,     /* I/O  Encoder control FIX                         */\r
     const SKP_int16                 *pitch_res,     /* I    LPC residual from pitch analysis            */\r
-    const SKP_int16                 *x              /* I    Input signal [ 2 * frame_length + la_shape ]*/\r
+    const SKP_int16                 *x              /* I    Input signal [ frame_length + la_shape ]    */\r
+);\r
+\r
+/* Autocorrelations for a warped frequency axis */\r
+void SKP_Silk_warped_autocorrelation_FIX(\r
+          SKP_int32                 *corr,              /* O    Result [order + 1]                      */\r
+          SKP_int                   *scale,             /* O    Scaling of the correlation vector       */\r
+    const SKP_int16                 *input,             /* I    Input data to correlate                 */\r
+    const SKP_int16                 warping_Q16,        /* I    Warping coefficient                     */\r
+    const SKP_int                   length,             /* I    Length of input                         */\r
+    const SKP_int                   order               /* I    Correlation order (even)                */\r
 );\r
 \r
 /* Processing of gains */\r
@@ -118,11 +124,10 @@ void SKP_Silk_process_gains_FIX(
     SKP_Silk_encoder_control_FIX    *psEncCtrl      /* I/O  Encoder control                             */\r
 );\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_FIX    *psEncCtrl      /* I/O  encoder control                             */\r
+    SKP_Silk_encoder_control        *psEncCtrlC     /* I/O  encoder control                             */\r
 );\r
 \r
 /* Calculation of LTP state scaling */\r
@@ -150,9 +155,9 @@ void SKP_Silk_find_pred_coefs_FIX(
 );\r
 \r
 void SKP_Silk_find_LPC_FIX(\r
-    SKP_int             NLSF_Q15[],             /* O    LSFs                                                                        */\r
-    SKP_int             *interpIndex,           /* O    LSF interpolation index, only used for LSF interpolation                    */\r
-    const SKP_int       prev_NLSFq_Q15[],       /* I    previous LSFs, only used for LSF interpolation                              */\r
+    SKP_int             NLSF_Q15[],             /* O    NLSFs                                                                       */\r
+    SKP_int             *interpIndex,           /* O    NLSF interpolation index, only used for NLSF interpolation                  */\r
+    const SKP_int       prev_NLSFq_Q15[],       /* I    previous NLSFs, only used for NLSF interpolation                            */\r
     const SKP_int       useInterpolatedLSFs,    /* I    Flag                                                                        */\r
     const SKP_int       LPC_order,              /* I    LPC order                                                                   */\r
     const SKP_int16     x[],                    /* I    Input signal                                                                */\r
@@ -164,8 +169,7 @@ void SKP_Silk_LTP_analysis_filter_FIX(
     const SKP_int16 *x,                                 /* I:   Pointer to input signal with at least max( pitchL ) preceeding samples  */\r
     const SKP_int16 LTPCoef_Q14[ LTP_ORDER * NB_SUBFR ],/* I:   LTP_ORDER LTP coefficients for each NB_SUBFR subframe                   */\r
     const SKP_int   pitchL[ NB_SUBFR ],                 /* I:   Pitch lag, one for each subframe                                        */\r
-    const SKP_int32 invGains_Qxx[ NB_SUBFR ],           /* I:   Inverse quantization gains, one for each subframe                       */\r
-    const SKP_int   Qxx,                                /* I:   Inverse quantization gains Q domain                                     */\r
+    const SKP_int32 invGains_Q16[ NB_SUBFR ],           /* I:   Inverse quantization gains, one for each subframe                       */\r
     const SKP_int   subfr_length,                       /* I:   Length of each subframe                                                 */\r
     const SKP_int   pre_length                          /* I:   Length of the preceeding samples starting at &x[0] for each subframe    */\r
 );\r
@@ -205,7 +209,7 @@ void SKP_Silk_process_NLSFs_FIX(
     SKP_int                         *pNLSF_Q15  /* I/O  Normalized LSFs (quant out) (0 - (2^15-1))  */\r
 );\r
 \r
-/* LSF vector encoder */\r
+/* NLSF vector encoder */\r
 void SKP_Silk_NLSF_MSVQ_encode_FIX(\r
           SKP_int                   *NLSFIndices,           /* O    Codebook path vector [ CB_STAGES ]      */\r
           SKP_int                   *pNLSF_Q15,             /* I/O  Quantized NLSF vector [ LPC_ORDER ]     */\r
@@ -263,6 +267,7 @@ void SKP_Silk_corrMatrix_FIX(
     const SKP_int16                 *x,         /* I    x vector [L + order - 1] used to form data matrix X */\r
     const SKP_int                   L,          /* I    Length of vectors                                   */\r
     const SKP_int                   order,      /* I    Max lag for correlation                             */\r
+    const SKP_int                   head_room,  /* I    Desired headroom                                    */\r
     SKP_int32                       *XX,        /* O    Pointer to X'*X correlation matrix [ order x order ]*/\r
     SKP_int                         *rshifts    /* I/O  Right shifts of correlations                        */\r
 );\r
@@ -270,7 +275,7 @@ void SKP_Silk_corrMatrix_FIX(
 /* Calculates correlation vector X'*t */\r
 void SKP_Silk_corrVector_FIX(\r
     const SKP_int16                 *x,         /* I    x vector [L + order - 1] used to form data matrix X */\r
-    const SKP_int16                 *t,         /* I    target vector [L]                                   */\r
+    const SKP_int16                 *t,         /* I    Target vector [L]                                   */\r
     const SKP_int                   L,          /* I    Length of vectors                                   */\r
     const SKP_int                   order,      /* I    Max lag for correlation                             */\r
     SKP_int32                       *Xt,        /* O    Pointer to X'*t correlation vector [order]          */\r
@@ -309,9 +314,8 @@ void SKP_Silk_residual_energy_FIX(
           SKP_int32 nrgs[ NB_SUBFR ],           /* O    Residual energy per subframe    */\r
           SKP_int   nrgsQ[ NB_SUBFR ],          /* O    Q value per subframe            */\r
     const SKP_int16 x[],                        /* I    Input signal                    */\r
-    const SKP_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ],/* I    AR coefs for each frame half    */\r
-    const SKP_int32 gains_Qx[ NB_SUBFR ],       /* I    Quantization gains in Qx        */\r
-    const SKP_int   Qx,                         /* I    Quantization gains Q value      */\r
+          SKP_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ],/* I    AR coefs for each frame half    */\r
+    const SKP_int32 gains[ NB_SUBFR ],          /* I    Quantization gains              */\r
     const SKP_int   subfr_length,               /* I    Subframe length                 */\r
     const SKP_int   LPC_order                   /* I    LPC order                       */\r
 );\r
index b0f8849585431c65798287eea2510476ed3b6e25..c7aa416afdebecc7f9c4bc31a18a12bbb7d5ce4c 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -26,8 +26,110 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***********************************************************************/\r
 \r
 #include "SKP_Silk_main_FIX.h"\r
-#include "SKP_Silk_perceptual_parameters_FIX.h"\r
+#include "SKP_Silk_tuning_parameters.h"\r
+\r
+/* Compute gain to make warped filter coefficients have a zero mean log frequency response on a     */\r
+/* non-warped frequency scale. (So that it can be implemented with a minimum-phase monic filter.)   */\r
+SKP_INLINE SKP_int32 warped_gain( // gain in Q16\r
+    const SKP_int32     *coefs_Q24, \r
+    SKP_int             lambda_Q16, \r
+    SKP_int             order \r
+) {\r
+    SKP_int   i;\r
+    SKP_int32 gain_Q24;\r
+\r
+    lambda_Q16 = -lambda_Q16;\r
+    gain_Q24 = coefs_Q24[ order - 1 ];\r
+    for( i = order - 2; i >= 0; i-- ) {\r
+        gain_Q24 = SKP_SMLAWB( coefs_Q24[ i ], gain_Q24, lambda_Q16 );\r
+    }\r
+    gain_Q24  = SKP_SMLAWB( SKP_FIX_CONST( 1.0, 24 ), gain_Q24, -lambda_Q16 );\r
+    return SKP_INVERSE32_varQ( gain_Q24, 40 );\r
+}\r
+\r
+/* Convert warped filter coefficients to monic pseudo-warped coefficients and limit maximum     */\r
+/* amplitude of monic warped coefficients by using bandwidth expansion on the true coefficients */\r
+SKP_INLINE void limit_warped_coefs( \r
+    SKP_int32           *coefs_syn_Q24,\r
+    SKP_int32           *coefs_ana_Q24,\r
+    SKP_int             lambda_Q16,\r
+    SKP_int32           limit_Q24,\r
+    SKP_int             order\r
+) {\r
+    SKP_int   i, iter, ind = 0;\r
+    SKP_int32 tmp, maxabs_Q24, chirp_Q16, gain_syn_Q16, gain_ana_Q16;\r
+    SKP_int32 nom_Q16, den_Q24;\r
+\r
+    /* Convert to monic coefficients */\r
+    lambda_Q16 = -lambda_Q16;\r
+    for( i = order - 1; i > 0; i-- ) {\r
+        coefs_syn_Q24[ i - 1 ] = SKP_SMLAWB( coefs_syn_Q24[ i - 1 ], coefs_syn_Q24[ i ], lambda_Q16 );\r
+        coefs_ana_Q24[ i - 1 ] = SKP_SMLAWB( coefs_ana_Q24[ i - 1 ], coefs_ana_Q24[ i ], lambda_Q16 );\r
+    }\r
+    lambda_Q16 = -lambda_Q16;\r
+    nom_Q16  = SKP_SMLAWB( SKP_FIX_CONST( 1.0, 16 ), -lambda_Q16,        lambda_Q16 );\r
+    den_Q24  = SKP_SMLAWB( SKP_FIX_CONST( 1.0, 24 ), coefs_syn_Q24[ 0 ], lambda_Q16 );\r
+    gain_syn_Q16 = SKP_DIV32_varQ( nom_Q16, den_Q24, 24 );\r
+    den_Q24  = SKP_SMLAWB( SKP_FIX_CONST( 1.0, 24 ), coefs_ana_Q24[ 0 ], lambda_Q16 );\r
+    gain_ana_Q16 = SKP_DIV32_varQ( nom_Q16, den_Q24, 24 );\r
+    for( i = 0; i < order; i++ ) {\r
+        coefs_syn_Q24[ i ] = SKP_SMULWW( gain_syn_Q16, coefs_syn_Q24[ i ] );\r
+        coefs_ana_Q24[ i ] = SKP_SMULWW( gain_ana_Q16, coefs_ana_Q24[ i ] );\r
+    }\r
+\r
+    for( iter = 0; iter < 10; iter++ ) {\r
+        /* Find maximum absolute value */\r
+        maxabs_Q24 = -1;\r
+        for( i = 0; i < order; i++ ) {\r
+            tmp = SKP_max( SKP_abs_int32( coefs_syn_Q24[ i ] ), SKP_abs_int32( coefs_ana_Q24[ i ] ) );\r
+            if( tmp > maxabs_Q24 ) {\r
+                maxabs_Q24 = tmp;\r
+                ind = i;\r
+            }\r
+        }\r
+        if( maxabs_Q24 <= limit_Q24 ) {\r
+            /* Coefficients are within range - done */\r
+            return;\r
+        }\r
+\r
+        /* Convert back to true warped coefficients */\r
+        for( i = 1; i < order; i++ ) {\r
+            coefs_syn_Q24[ i - 1 ] = SKP_SMLAWB( coefs_syn_Q24[ i - 1 ], coefs_syn_Q24[ i ], lambda_Q16 );\r
+            coefs_ana_Q24[ i - 1 ] = SKP_SMLAWB( coefs_ana_Q24[ i - 1 ], coefs_ana_Q24[ i ], lambda_Q16 );\r
+        }\r
+        gain_syn_Q16 = SKP_INVERSE32_varQ( gain_syn_Q16, 32 );\r
+        gain_ana_Q16 = SKP_INVERSE32_varQ( gain_ana_Q16, 32 );\r
+        for( i = 0; i < order; i++ ) {\r
+            coefs_syn_Q24[ i ] = SKP_SMULWW( gain_syn_Q16, coefs_syn_Q24[ i ] );\r
+            coefs_ana_Q24[ i ] = SKP_SMULWW( gain_ana_Q16, coefs_ana_Q24[ i ] );\r
+        }\r
 \r
+        /* Apply bandwidth expansion */\r
+        chirp_Q16 = SKP_FIX_CONST( 0.99, 16 ) - SKP_DIV32_varQ(\r
+            SKP_SMULWB( maxabs_Q24 - limit_Q24, SKP_SMLABB( SKP_FIX_CONST( 0.8, 10 ), SKP_FIX_CONST( 0.1, 10 ), iter ) ), \r
+            SKP_MUL( maxabs_Q24, ind + 1 ), 22 );\r
+        SKP_Silk_bwexpander_32( coefs_syn_Q24, order, chirp_Q16 );\r
+        SKP_Silk_bwexpander_32( coefs_ana_Q24, order, chirp_Q16 );\r
+\r
+        /* Convert to monic warped coefficients */\r
+        lambda_Q16 = -lambda_Q16;\r
+        for( i = order - 1; i > 0; i-- ) {\r
+            coefs_syn_Q24[ i - 1 ] = SKP_SMLAWB( coefs_syn_Q24[ i - 1 ], coefs_syn_Q24[ i ], lambda_Q16 );\r
+            coefs_ana_Q24[ i - 1 ] = SKP_SMLAWB( coefs_ana_Q24[ i - 1 ], coefs_ana_Q24[ i ], lambda_Q16 );\r
+        }\r
+        lambda_Q16 = -lambda_Q16;\r
+        nom_Q16  = SKP_SMLAWB( SKP_FIX_CONST( 1.0, 16 ), -lambda_Q16,        lambda_Q16 );\r
+        den_Q24  = SKP_SMLAWB( SKP_FIX_CONST( 1.0, 24 ), coefs_syn_Q24[ 0 ], lambda_Q16 );\r
+        gain_syn_Q16 = SKP_DIV32_varQ( nom_Q16, den_Q24, 24 );\r
+        den_Q24  = SKP_SMLAWB( SKP_FIX_CONST( 1.0, 24 ), coefs_ana_Q24[ 0 ], lambda_Q16 );\r
+        gain_ana_Q16 = SKP_DIV32_varQ( nom_Q16, den_Q24, 24 );\r
+        for( i = 0; i < order; i++ ) {\r
+            coefs_syn_Q24[ i ] = SKP_SMULWW( gain_syn_Q16, coefs_syn_Q24[ i ] );\r
+            coefs_ana_Q24[ i ] = SKP_SMULWW( gain_ana_Q16, coefs_ana_Q24[ i ] );\r
+        }\r
+    }\r
+       SKP_assert( 0 );\r
+}\r
 \r
 /**************************************************************/\r
 /* Compute noise shaping coefficients and initial gain values */\r
@@ -36,33 +138,35 @@ void SKP_Silk_noise_shape_analysis_FIX(
     SKP_Silk_encoder_state_FIX      *psEnc,         /* I/O  Encoder state FIX                           */\r
     SKP_Silk_encoder_control_FIX    *psEncCtrl,     /* I/O  Encoder control FIX                         */\r
     const SKP_int16                 *pitch_res,     /* I    LPC residual from pitch analysis            */\r
-    const SKP_int16                 *x              /* I    Input signal [ 2 * frame_length + la_shape ]*/\r
+    const SKP_int16                 *x              /* I    Input signal [ frame_length + la_shape ]    */\r
 )\r
 {\r
     SKP_Silk_shape_state_FIX *psShapeSt = &psEnc->sShape;\r
-    SKP_int     k, nSamples, lz, Qnrg, b_Q14, scale = 0, sz;\r
+    SKP_int     k, i, nSamples, Qnrg, b_Q14, warping_Q16, scale = 0;\r
     SKP_int32   SNR_adj_dB_Q7, HarmBoost_Q16, HarmShapeGain_Q16, Tilt_Q16, tmp32;\r
     SKP_int32   nrg, pre_nrg_Q30, log_energy_Q7, log_energy_prev_Q7, energy_variation_Q7;\r
     SKP_int32   delta_Q16, BWExp1_Q16, BWExp2_Q16, gain_mult_Q16, gain_add_Q16, strength_Q16, b_Q8;\r
-    SKP_int32   auto_corr[     SHAPE_LPC_ORDER_MAX + 1 ];\r
-    SKP_int32   refl_coef_Q16[ SHAPE_LPC_ORDER_MAX ];\r
-    SKP_int32   AR_Q24[        SHAPE_LPC_ORDER_MAX ];\r
+    SKP_int32   auto_corr[     MAX_SHAPE_LPC_ORDER + 1 ];\r
+    SKP_int32   refl_coef_Q16[ MAX_SHAPE_LPC_ORDER ];\r
+    SKP_int32   AR1_Q24[       MAX_SHAPE_LPC_ORDER ];\r
+    SKP_int32   AR2_Q24[       MAX_SHAPE_LPC_ORDER ];\r
     SKP_int16   x_windowed[    SHAPE_LPC_WIN_MAX ];\r
     const SKP_int16 *x_ptr, *pitch_res_ptr;\r
 \r
     SKP_int32   sqrt_nrg[ NB_SUBFR ], Qnrg_vec[ NB_SUBFR ];\r
 \r
     /* Point to start of first LPC analysis block */\r
-    x_ptr = x + psEnc->sCmn.la_shape - SKP_SMULBB( SHAPE_LPC_WIN_MS, psEnc->sCmn.fs_kHz ) + psEnc->sCmn.frame_length / NB_SUBFR;\r
+    x_ptr = x - psEnc->sCmn.la_shape;\r
 \r
     /****************/\r
     /* CONTROL SNR  */\r
     /****************/\r
     /* Reduce SNR_dB values if recent bitstream has exceeded TargetRate */\r
-    psEncCtrl->current_SNR_dB_Q7 = psEnc->SNR_dB_Q7 - SKP_SMULWB( SKP_LSHIFT( ( SKP_int32 )psEnc->BufferedInChannel_ms, 7 ), 3277 );\r
+    psEncCtrl->current_SNR_dB_Q7 = psEnc->SNR_dB_Q7 - SKP_SMULWB( SKP_LSHIFT( ( SKP_int32 )psEnc->BufferedInChannel_ms, 7 ), \r
+        SKP_FIX_CONST( 0.05, 16 ) );\r
 \r
     /* Reduce SNR_dB if inband FEC used */\r
-    if( psEnc->speech_activity_Q8 > LBRR_SPEECH_ACTIVITY_THRES_Q8 ) {\r
+    if( psEnc->speech_activity_Q8 > SKP_FIX_CONST( LBRR_SPEECH_ACTIVITY_THRES, 8 ) ) {\r
         psEncCtrl->current_SNR_dB_Q7 -= SKP_RSHIFT( psEnc->inBandFEC_SNR_comp_Q8, 1 );\r
     }\r
 \r
@@ -72,24 +176,26 @@ void SKP_Silk_noise_shape_analysis_FIX(
     /* Input quality is the average of the quality in the lowest two VAD bands */\r
     psEncCtrl->input_quality_Q14 = ( SKP_int )SKP_RSHIFT( ( SKP_int32 )psEncCtrl->input_quality_bands_Q15[ 0 ] \r
         + psEncCtrl->input_quality_bands_Q15[ 1 ], 2 );\r
+\r
     /* Coding quality level, between 0.0_Q0 and 1.0_Q0, but in Q14 */\r
-    psEncCtrl->coding_quality_Q14 = SKP_RSHIFT( SKP_Silk_sigm_Q15( SKP_RSHIFT_ROUND( psEncCtrl->current_SNR_dB_Q7 - ( 18 << 7 ), 4 ) ), 1 );\r
+    psEncCtrl->coding_quality_Q14 = SKP_RSHIFT( SKP_Silk_sigm_Q15( SKP_RSHIFT_ROUND( psEncCtrl->current_SNR_dB_Q7 - \r
+        SKP_FIX_CONST( 18.0, 7 ), 4 ) ), 1 );\r
 \r
     /* Reduce coding SNR during low speech activity */\r
-    b_Q8 = ( 1 << 8 ) - psEnc->speech_activity_Q8;\r
+    b_Q8 = SKP_FIX_CONST( 1.0, 8 ) - psEnc->speech_activity_Q8;\r
     b_Q8 = SKP_SMULWB( SKP_LSHIFT( b_Q8, 8 ), b_Q8 );\r
     SNR_adj_dB_Q7 = SKP_SMLAWB( psEncCtrl->current_SNR_dB_Q7,\r
-        SKP_SMULBB( -BG_SNR_DECR_dB_Q7 >> ( 4 + 1 ), b_Q8 ),                                            // Q11\r
-        SKP_SMULWB( ( 1 << 14 ) + psEncCtrl->input_quality_Q14, psEncCtrl->coding_quality_Q14 ) );      // Q12\r
+        SKP_SMULBB( SKP_FIX_CONST( -BG_SNR_DECR_dB, 7 ) >> ( 4 + 1 ), b_Q8 ),                                       // Q11\r
+        SKP_SMULWB( SKP_FIX_CONST( 1.0, 14 ) + psEncCtrl->input_quality_Q14, psEncCtrl->coding_quality_Q14 ) );     // Q12\r
 \r
     if( psEncCtrl->sCmn.sigtype == SIG_TYPE_VOICED ) {\r
         /* Reduce gains for periodic signals */\r
-        SNR_adj_dB_Q7 = SKP_SMLAWB( SNR_adj_dB_Q7, HARM_SNR_INCR_dB_Q7 << 1, psEnc->LTPCorr_Q15 );\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
         /* For unvoiced signals and low-quality input, adjust the quality slower than SNR_dB setting */\r
         SNR_adj_dB_Q7 = SKP_SMLAWB( SNR_adj_dB_Q7, \r
-            SKP_SMLAWB( 6 << ( 7 + 2 ), -104856, psEncCtrl->current_SNR_dB_Q7 ),    //-104856_Q18 = -0.4_Q0, Q9\r
-            ( 1 << 14 ) - psEncCtrl->input_quality_Q14 );                           // Q14\r
+            SKP_SMLAWB( SKP_FIX_CONST( 6.0, 9 ), -SKP_FIX_CONST( 0.4, 18 ), psEncCtrl->current_SNR_dB_Q7 ),\r
+            SKP_FIX_CONST( 1.0, 14 ) - psEncCtrl->input_quality_Q14 );\r
     }\r
 \r
     /*************************/\r
@@ -118,74 +224,77 @@ void SKP_Silk_noise_shape_analysis_FIX(
             pitch_res_ptr += nSamples;\r
         }\r
 \r
-        psEncCtrl->sparseness_Q8 = SKP_RSHIFT( SKP_Silk_sigm_Q15( SKP_SMULWB( energy_variation_Q7 - ( 5 << 7 ), 6554 ) ), 7 );    // 6554_Q16 = 0.1_Q0\r
+        psEncCtrl->sparseness_Q8 = SKP_RSHIFT( SKP_Silk_sigm_Q15( SKP_SMULWB( energy_variation_Q7 - \r
+            SKP_FIX_CONST( 5.0, 7 ), SKP_FIX_CONST( 0.1, 16 ) ) ), 7 );\r
 \r
         /* Set quantization offset depending on sparseness measure */\r
-        if( psEncCtrl->sparseness_Q8 > SPARSENESS_THRESHOLD_QNT_OFFSET_Q8 ) {\r
+        if( psEncCtrl->sparseness_Q8 > SKP_FIX_CONST( SPARSENESS_THRESHOLD_QNT_OFFSET, 8 ) ) {\r
             psEncCtrl->sCmn.QuantOffsetType = 0;\r
         } else {\r
             psEncCtrl->sCmn.QuantOffsetType = 1;\r
         }\r
         \r
         /* Increase coding SNR for sparse signals */\r
-        SNR_adj_dB_Q7 = SKP_SMLAWB( SNR_adj_dB_Q7, SPARSE_SNR_INCR_dB_Q7 << 8, psEncCtrl->sparseness_Q8 - ( 1 << 7 ) );\r
+        SNR_adj_dB_Q7 = SKP_SMLAWB( SNR_adj_dB_Q7, SKP_FIX_CONST( SPARSE_SNR_INCR_dB, 15 ), psEncCtrl->sparseness_Q8 - SKP_FIX_CONST( 0.5, 8 ) );\r
     }\r
 \r
     /*******************************/\r
     /* Control bandwidth expansion */\r
     /*******************************/\r
-    delta_Q16  = SKP_SMULWB( ( 1 << 16 ) - SKP_SMULBB( 3, psEncCtrl->coding_quality_Q14 ), LOW_RATE_BANDWIDTH_EXPANSION_DELTA_Q16 );\r
-    BWExp1_Q16 = BANDWIDTH_EXPANSION_Q16 - delta_Q16;\r
-    BWExp2_Q16 = BANDWIDTH_EXPANSION_Q16 + delta_Q16;\r
-    if( psEnc->sCmn.fs_kHz == 24 ) {\r
-        /* Less bandwidth expansion for super wideband */\r
-        BWExp1_Q16 = ( 1 << 16 ) - SKP_SMULWB( SWB_BANDWIDTH_EXPANSION_REDUCTION_Q16, ( 1 << 16 ) - BWExp1_Q16 );\r
-        BWExp2_Q16 = ( 1 << 16 ) - SKP_SMULWB( SWB_BANDWIDTH_EXPANSION_REDUCTION_Q16, ( 1 << 16 ) - BWExp2_Q16 );\r
-    }\r
+    /* More BWE for signals with high prediction gain */\r
+    strength_Q16 = SKP_SMULWB( psEncCtrl->predGain_Q16, SKP_FIX_CONST( FIND_PITCH_WHITE_NOISE_FRACTION, 16 ) );\r
+    BWExp1_Q16 = BWExp2_Q16 = SKP_DIV32_varQ( SKP_FIX_CONST( BANDWIDTH_EXPANSION, 16 ), \r
+        SKP_SMLAWW( SKP_FIX_CONST( 1.0, 16 ), strength_Q16, strength_Q16 ), 16 );\r
+    delta_Q16  = SKP_SMULWB( SKP_FIX_CONST( 1.0, 16 ) - SKP_SMULBB( 3, psEncCtrl->coding_quality_Q14 ), \r
+        SKP_FIX_CONST( LOW_RATE_BANDWIDTH_EXPANSION_DELTA, 16 ) );\r
+    BWExp1_Q16 = SKP_SUB32( BWExp1_Q16, delta_Q16 );\r
+    BWExp2_Q16 = SKP_ADD32( BWExp2_Q16, delta_Q16 );\r
     /* BWExp1 will be applied after BWExp2, so make it relative */\r
     BWExp1_Q16 = SKP_DIV32_16( SKP_LSHIFT( BWExp1_Q16, 14 ), SKP_RSHIFT( BWExp2_Q16, 2 ) );\r
 \r
+    if( psEnc->sCmn.warping_Q16 > 0 ) {\r
+        /* Slightly more warping in analysis will move quantization noise up in frequency, where it's better masked */\r
+        warping_Q16 = SKP_SMLAWB( psEnc->sCmn.warping_Q16, psEncCtrl->coding_quality_Q14, SKP_FIX_CONST( 0.01, 18 ) );\r
+    } else {\r
+        warping_Q16 = 0;\r
+    }\r
+\r
     /********************************************/\r
     /* Compute noise shaping AR coefs and gains */\r
     /********************************************/\r
-    sz = ( SKP_int )SKP_SMULBB( SHAPE_LPC_WIN_MS, psEnc->sCmn.fs_kHz );\r
     for( k = 0; k < NB_SUBFR; k++ ) {\r
-        /* Apply window */\r
-        SKP_Silk_apply_sine_window( x_windowed, x_ptr, 0, SHAPE_LPC_WIN_MS * psEnc->sCmn.fs_kHz );\r
-\r
+        /* Apply window: sine slope followed by flat part followed by cosine slope */\r
+        SKP_int shift, slope_part, flat_part;\r
+        flat_part = psEnc->sCmn.fs_kHz * 5;\r
+        slope_part = SKP_RSHIFT( psEnc->sCmn.shapeWinLength - flat_part, 1 );\r
+\r
+        SKP_Silk_apply_sine_window_new( x_windowed, x_ptr, 1, slope_part );\r
+        shift = slope_part;\r
+        SKP_memcpy( x_windowed + shift, x_ptr + shift, flat_part * sizeof(SKP_int16) );\r
+        shift += flat_part;\r
+        SKP_Silk_apply_sine_window_new( x_windowed + shift, x_ptr + shift, 2, slope_part );\r
+        \r
         /* Update pointer: next LPC analysis block */\r
-        x_ptr += psEnc->sCmn.frame_length / NB_SUBFR;\r
+        x_ptr += psEnc->sCmn.subfr_length;\r
 \r
-        /* Calculate auto correlation */\r
-        SKP_Silk_autocorr( auto_corr, &scale, x_windowed, sz, psEnc->sCmn.shapingLPCOrder + 1 );\r
+        if( psEnc->sCmn.warping_Q16 > 0 ) {\r
+            /* Calculate warped auto correlation */\r
+            SKP_Silk_warped_autocorrelation_FIX( auto_corr, &scale, x_windowed, warping_Q16, psEnc->sCmn.shapeWinLength, psEnc->sCmn.shapingLPCOrder ); \r
+        } else {\r
+            /* Calculate regular auto correlation */\r
+            SKP_Silk_autocorr( auto_corr, &scale, x_windowed, psEnc->sCmn.shapeWinLength, psEnc->sCmn.shapingLPCOrder + 1 );\r
+        }\r
 \r
         /* Add white noise, as a fraction of energy */\r
-        auto_corr[0] = SKP_ADD32( auto_corr[0], SKP_max_32( SKP_SMULWB( SKP_RSHIFT( auto_corr[ 0 ], 4 ), SHAPE_WHITE_NOISE_FRACTION_Q20 ), 1 ) ); \r
+        auto_corr[0] = SKP_ADD32( auto_corr[0], SKP_max_32( SKP_SMULWB( SKP_RSHIFT( auto_corr[ 0 ], 4 ), \r
+            SKP_FIX_CONST( SHAPE_WHITE_NOISE_FRACTION, 20 ) ), 1 ) ); \r
 \r
         /* Calculate the reflection coefficients using schur */\r
         nrg = SKP_Silk_schur64( refl_coef_Q16, auto_corr, psEnc->sCmn.shapingLPCOrder );\r
+        SKP_assert( nrg >= 0 );\r
 \r
         /* Convert reflection coefficients to prediction coefficients */\r
-        SKP_Silk_k2a_Q16( AR_Q24, refl_coef_Q16, psEnc->sCmn.shapingLPCOrder );\r
-\r
-        /* Bandwidth expansion for synthesis filter shaping */\r
-        SKP_Silk_bwexpander_32( AR_Q24, psEnc->sCmn.shapingLPCOrder, BWExp2_Q16 );\r
-\r
-        /* Make sure to fit in Q13 SKP_int16 */\r
-        SKP_Silk_LPC_fit( &psEncCtrl->AR2_Q13[ k * SHAPE_LPC_ORDER_MAX ], AR_Q24, 13, psEnc->sCmn.shapingLPCOrder );\r
-\r
-        /* Compute noise shaping filter coefficients */\r
-        SKP_memcpy(\r
-            &psEncCtrl->AR1_Q13[ k * SHAPE_LPC_ORDER_MAX ], \r
-            &psEncCtrl->AR2_Q13[ k * SHAPE_LPC_ORDER_MAX ], \r
-            psEnc->sCmn.shapingLPCOrder * sizeof( SKP_int16 ) );\r
-\r
-        /* Bandwidth expansion for analysis filter shaping */\r
-        SKP_assert( BWExp1_Q16 <= ( 1 << 16 ) ); // If ever breaking, use LPC_stabilize() in these cases to stay within range\r
-        SKP_Silk_bwexpander( &psEncCtrl->AR1_Q13[ k * SHAPE_LPC_ORDER_MAX ], psEnc->sCmn.shapingLPCOrder, BWExp1_Q16 );\r
-\r
-        /* Increase residual energy */\r
-        nrg = SKP_SMLAWB( nrg, SKP_RSHIFT( auto_corr[ 0 ], 8 ), SHAPE_MIN_ENERGY_RATIO_Q24 );\r
+        SKP_Silk_k2a_Q16( AR2_Q24, refl_coef_Q16, psEnc->sCmn.shapingLPCOrder );\r
 \r
         Qnrg = -scale;          // range: -12...30\r
         SKP_assert( Qnrg >= -12 );\r
@@ -204,30 +313,61 @@ void SKP_Silk_noise_shape_analysis_FIX(
         Qnrg_vec[ k ] = Qnrg;\r
 \r
         psEncCtrl->Gains_Q16[ k ] = SKP_LSHIFT_SAT32( tmp32, 16 - Qnrg );\r
+\r
+        if( psEnc->sCmn.warping_Q16 > 0 ) {\r
+            /* Adjust gain for warping */\r
+            gain_mult_Q16 = warped_gain( AR2_Q24, warping_Q16, psEnc->sCmn.shapingLPCOrder );\r
+            SKP_assert( psEncCtrl->Gains_Q16[ k ] >= 0 );\r
+            psEncCtrl->Gains_Q16[ k ] = SKP_SMULWW( psEncCtrl->Gains_Q16[ k ], gain_mult_Q16 );\r
+            if( psEncCtrl->Gains_Q16[ k ] < 0 ) {\r
+                psEncCtrl->Gains_Q16[ k ] = SKP_int32_MAX;\r
+            }\r
+        }\r
+\r
+        /* Bandwidth expansion for synthesis filter shaping */\r
+        SKP_Silk_bwexpander_32( AR2_Q24, psEnc->sCmn.shapingLPCOrder, BWExp2_Q16 );\r
+\r
+        /* Compute noise shaping filter coefficients */\r
+        SKP_memcpy( AR1_Q24, AR2_Q24, psEnc->sCmn.shapingLPCOrder * sizeof( SKP_int32 ) );\r
+\r
+        /* Bandwidth expansion for analysis filter shaping */\r
+        SKP_assert( BWExp1_Q16 <= SKP_FIX_CONST( 1.0, 16 ) );\r
+        SKP_Silk_bwexpander_32( AR1_Q24, psEnc->sCmn.shapingLPCOrder, BWExp1_Q16 );\r
+\r
         /* Ratio of prediction gains, in energy domain */\r
-        SKP_Silk_LPC_inverse_pred_gain_Q13( &pre_nrg_Q30, &psEncCtrl->AR2_Q13[ k * SHAPE_LPC_ORDER_MAX ], psEnc->sCmn.shapingLPCOrder );\r
-        SKP_Silk_LPC_inverse_pred_gain_Q13( &nrg,         &psEncCtrl->AR1_Q13[ k * SHAPE_LPC_ORDER_MAX ], psEnc->sCmn.shapingLPCOrder );\r
+        SKP_Silk_LPC_inverse_pred_gain_Q24( &pre_nrg_Q30, AR2_Q24, psEnc->sCmn.shapingLPCOrder );\r
+        SKP_Silk_LPC_inverse_pred_gain_Q24( &nrg,         AR1_Q24, psEnc->sCmn.shapingLPCOrder );\r
+\r
+        //psEncCtrl->GainsPre[ k ] = 1.0f - 0.7f * ( 1.0f - pre_nrg / nrg ) = 0.3f + 0.7f * pre_nrg / nrg;\r
+        pre_nrg_Q30 = SKP_LSHIFT32( SKP_SMULWB( pre_nrg_Q30, SKP_FIX_CONST( 0.7, 15 ) ), 1 );\r
+        psEncCtrl->GainsPre_Q14[ k ] = ( SKP_int ) SKP_FIX_CONST( 0.3, 14 ) + SKP_DIV32_varQ( pre_nrg_Q30, nrg, 14 );\r
+\r
+        /* Convert to monic warped prediction coefficients and limit absolute values */\r
+        limit_warped_coefs( AR2_Q24, AR1_Q24, warping_Q16, SKP_FIX_CONST( 3.999, 24 ), psEnc->sCmn.shapingLPCOrder );\r
 \r
-        lz = SKP_min_32( SKP_Silk_CLZ32( pre_nrg_Q30 ) - 1, 19 );\r
-        pre_nrg_Q30 = SKP_DIV32( SKP_LSHIFT( pre_nrg_Q30, lz ), SKP_RSHIFT( nrg, 20 - lz ) + 1 ); // Q20\r
-        pre_nrg_Q30 = SKP_RSHIFT( SKP_LSHIFT_SAT32( pre_nrg_Q30, 9 ), 1 );  /* Q28 */\r
-        psEncCtrl->GainsPre_Q14[ k ] = ( SKP_int )SKP_Silk_SQRT_APPROX( pre_nrg_Q30 );\r
+        /* Convert from Q24 to Q13 and store in int16 */\r
+        for( i = 0; i < psEnc->sCmn.shapingLPCOrder; i++ ) {\r
+            psEncCtrl->AR1_Q13[ k * MAX_SHAPE_LPC_ORDER + i ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( AR1_Q24[ i ], 11 ) );\r
+            psEncCtrl->AR2_Q13[ k * MAX_SHAPE_LPC_ORDER + i ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( AR2_Q24[ i ], 11 ) );\r
+        }\r
     }\r
 \r
     /*****************/\r
     /* Gain tweaking */\r
     /*****************/\r
     /* Increase gains during low speech activity and put lower limit on gains */\r
-    gain_mult_Q16 = SKP_Silk_log2lin( -SKP_SMLAWB( -16 << 7, SNR_adj_dB_Q7,           10486 ) ); // 10486_Q16 = 0.16_Q0\r
-    gain_add_Q16  = SKP_Silk_log2lin(  SKP_SMLAWB(  16 << 7, NOISE_FLOOR_dB_Q7,       10486 ) ); // 10486_Q16 = 0.16_Q0\r
-    tmp32         = SKP_Silk_log2lin(  SKP_SMLAWB(  16 << 7, RELATIVE_MIN_GAIN_dB_Q7, 10486 ) ); // 10486_Q16 = 0.16_Q0\r
+    gain_mult_Q16 = SKP_Silk_log2lin( -SKP_SMLAWB( -SKP_FIX_CONST( 16.0, 7 ), SNR_adj_dB_Q7,                            SKP_FIX_CONST( 0.16, 16 ) ) );\r
+    gain_add_Q16  = SKP_Silk_log2lin(  SKP_SMLAWB(  SKP_FIX_CONST( 16.0, 7 ), SKP_FIX_CONST( NOISE_FLOOR_dB, 7 ),       SKP_FIX_CONST( 0.16, 16 ) ) );\r
+    tmp32         = SKP_Silk_log2lin(  SKP_SMLAWB(  SKP_FIX_CONST( 16.0, 7 ), SKP_FIX_CONST( RELATIVE_MIN_GAIN_dB, 7 ), SKP_FIX_CONST( 0.16, 16 ) ) );\r
     tmp32 = SKP_SMULWW( psEnc->avgGain_Q16, tmp32 );\r
     gain_add_Q16 = SKP_ADD_SAT32( gain_add_Q16, tmp32 );\r
     SKP_assert( gain_mult_Q16 >= 0 );\r
 \r
     for( k = 0; k < NB_SUBFR; k++ ) {\r
         psEncCtrl->Gains_Q16[ k ] = SKP_SMULWW( psEncCtrl->Gains_Q16[ k ], gain_mult_Q16 );\r
-        SKP_assert( psEncCtrl->Gains_Q16[ k ] >= 0 );\r
+        if( psEncCtrl->Gains_Q16[ k ] < 0 ) {\r
+            psEncCtrl->Gains_Q16[ k ] = SKP_int32_MAX;\r
+        }\r
     }\r
 \r
     for( k = 0; k < NB_SUBFR; k++ ) {\r
@@ -236,27 +376,28 @@ void SKP_Silk_noise_shape_analysis_FIX(
             psEnc->avgGain_Q16, \r
             SKP_SMULWB(\r
                 psEncCtrl->Gains_Q16[ k ] - psEnc->avgGain_Q16, \r
-                SKP_RSHIFT_ROUND( SKP_SMULBB( psEnc->speech_activity_Q8, GAIN_SMOOTHING_COEF_Q10 ), 2 ) \r
+                SKP_RSHIFT_ROUND( SKP_SMULBB( psEnc->speech_activity_Q8, SKP_FIX_CONST( GAIN_SMOOTHING_COEF, 10 ) ), 2 ) \r
             ) );\r
     }\r
 \r
     /************************************************/\r
     /* Decrease level during fricatives (de-essing) */\r
     /************************************************/\r
-    gain_mult_Q16 = ( 1 << 16 ) + SKP_RSHIFT_ROUND( SKP_MLA( INPUT_TILT_Q26, psEncCtrl->coding_quality_Q14, HIGH_RATE_INPUT_TILT_Q12 ), 10 );\r
+    gain_mult_Q16 = SKP_FIX_CONST( 1.0, 16 ) + SKP_RSHIFT_ROUND( SKP_MLA( SKP_FIX_CONST( INPUT_TILT, 26 ), \r
+        psEncCtrl->coding_quality_Q14, SKP_FIX_CONST( HIGH_RATE_INPUT_TILT, 12 ) ), 10 );\r
 \r
     if( psEncCtrl->input_tilt_Q15 <= 0 && psEncCtrl->sCmn.sigtype == SIG_TYPE_UNVOICED ) {\r
         if( psEnc->sCmn.fs_kHz == 24 ) {\r
             SKP_int32 essStrength_Q15 = SKP_SMULWW( -psEncCtrl->input_tilt_Q15, \r
-                SKP_SMULBB( psEnc->speech_activity_Q8, ( 1 << 8 ) - psEncCtrl->sparseness_Q8 ) );\r
-            tmp32 = SKP_Silk_log2lin( ( 16 << 7 ) - SKP_SMULWB( essStrength_Q15, \r
-                SKP_SMULWB( DE_ESSER_COEF_SWB_dB_Q7, 20972 ) ) ); // 20972_Q17 = 0.16_Q0\r
+                SKP_SMULBB( psEnc->speech_activity_Q8, SKP_FIX_CONST( 1.0, 8 ) - psEncCtrl->sparseness_Q8 ) );\r
+            tmp32 = SKP_Silk_log2lin( SKP_FIX_CONST( 16.0, 7 ) - SKP_SMULWB( essStrength_Q15, \r
+                SKP_SMULWB( SKP_FIX_CONST( DE_ESSER_COEF_SWB_dB, 7 ), SKP_FIX_CONST( 0.16, 17 ) ) ) );\r
             gain_mult_Q16 = SKP_SMULWW( gain_mult_Q16, tmp32 );\r
         } else if( psEnc->sCmn.fs_kHz == 16 ) {\r
             SKP_int32 essStrength_Q15 = SKP_SMULWW(-psEncCtrl->input_tilt_Q15, \r
-                SKP_SMULBB( psEnc->speech_activity_Q8, ( 1 << 8 ) - psEncCtrl->sparseness_Q8 ));\r
-            tmp32 = SKP_Silk_log2lin( ( 16 << 7 ) - SKP_SMULWB( essStrength_Q15, \r
-                SKP_SMULWB( DE_ESSER_COEF_WB_dB_Q7, 20972 ) ) ); // 20972_Q17 = 0.16_Q0\r
+                SKP_SMULBB( psEnc->speech_activity_Q8, SKP_FIX_CONST( 1.0, 8 ) - psEncCtrl->sparseness_Q8 ));\r
+            tmp32 = SKP_Silk_log2lin( SKP_FIX_CONST( 16.0, 7 ) - SKP_SMULWB( essStrength_Q15, \r
+                SKP_SMULWB( SKP_FIX_CONST( DE_ESSER_COEF_WB_dB, 7 ), SKP_FIX_CONST( 0.16, 17 ) ) ) );\r
             gain_mult_Q16 = SKP_SMULWW( gain_mult_Q16, tmp32 );\r
         } else {\r
             SKP_assert( psEnc->sCmn.fs_kHz == 12 || psEnc->sCmn.fs_kHz == 8 );\r
@@ -271,47 +412,50 @@ void SKP_Silk_noise_shape_analysis_FIX(
     /* Control low-frequency shaping and noise tilt */\r
     /************************************************/\r
     /* Less low frequency shaping for noisy inputs */\r
-    strength_Q16 = SKP_MUL( LOW_FREQ_SHAPING_Q0, ( 1 << 16 ) + SKP_SMULBB( LOW_QUALITY_LOW_FREQ_SHAPING_DECR_Q1, psEncCtrl->input_quality_bands_Q15[ 0 ] - ( 1 << 15 ) ) );\r
+    strength_Q16 = SKP_MUL( SKP_FIX_CONST( LOW_FREQ_SHAPING, 0 ), SKP_FIX_CONST( 1.0, 16 ) + \r
+        SKP_SMULBB( SKP_FIX_CONST( LOW_QUALITY_LOW_FREQ_SHAPING_DECR, 1 ), psEncCtrl->input_quality_bands_Q15[ 0 ] - SKP_FIX_CONST( 1.0, 15 ) ) );\r
     if( psEncCtrl->sCmn.sigtype == SIG_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( 3277, psEnc->sCmn.fs_kHz );      // 0.2_Q0 = 3277_Q14\r
+        SKP_int fs_kHz_inv = SKP_DIV32_16( SKP_FIX_CONST( 0.2, 14 ), psEnc->sCmn.fs_kHz );\r
         for( k = 0; k < NB_SUBFR; k++ ) {\r
-            b_Q14 = fs_kHz_inv + SKP_DIV32_16( ( 3 << 14 ), psEncCtrl->sCmn.pitchL[ k ] ); \r
+            b_Q14 = fs_kHz_inv + SKP_DIV32_16( SKP_FIX_CONST( 3.0, 14 ), psEncCtrl->sCmn.pitchL[ k ] ); \r
             /* Pack two coefficients in one int32 */\r
-            psEncCtrl->LF_shp_Q14[ k ]  = SKP_LSHIFT( ( 1 << 14 ) - b_Q14 - SKP_SMULWB( strength_Q16, b_Q14 ), 16 );\r
-            psEncCtrl->LF_shp_Q14[ k ] |= (SKP_uint16)( b_Q14 - ( 1 << 14 ) );\r
+            psEncCtrl->LF_shp_Q14[ k ]  = SKP_LSHIFT( SKP_FIX_CONST( 1.0, 14 ) - b_Q14 - SKP_SMULWB( strength_Q16, b_Q14 ), 16 );\r
+            psEncCtrl->LF_shp_Q14[ k ] |= (SKP_uint16)( b_Q14 - SKP_FIX_CONST( 1.0, 14 ) );\r
         }\r
-        SKP_assert( HARM_HP_NOISE_COEF_Q24 < ( 1 << 23 ) ); // Guarantees that second argument to SMULWB() is within range of an SKP_int16\r
-        Tilt_Q16 = - HP_NOISE_COEF_Q16 - \r
-            SKP_SMULWB( ( 1 << 16 ) - HP_NOISE_COEF_Q16, SKP_SMULWB( HARM_HP_NOISE_COEF_Q24, psEnc->speech_activity_Q8 ) );\r
+        SKP_assert( SKP_FIX_CONST( HARM_HP_NOISE_COEF, 24 ) < SKP_FIX_CONST( 0.5, 24 ) ); // Guarantees that second argument to SMULWB() is within range of an SKP_int16\r
+        Tilt_Q16 = - SKP_FIX_CONST( HP_NOISE_COEF, 16 ) - \r
+            SKP_SMULWB( SKP_FIX_CONST( 1.0, 16 ) - SKP_FIX_CONST( HP_NOISE_COEF, 16 ), \r
+                SKP_SMULWB( SKP_FIX_CONST( HARM_HP_NOISE_COEF, 24 ), psEnc->speech_activity_Q8 ) );\r
     } else {\r
         b_Q14 = SKP_DIV32_16( 21299, psEnc->sCmn.fs_kHz ); // 1.3_Q0 = 21299_Q14\r
         /* Pack two coefficients in one int32 */\r
-        psEncCtrl->LF_shp_Q14[ 0 ]  = SKP_LSHIFT( ( 1 << 14 ) - b_Q14 - SKP_SMULWB( strength_Q16, SKP_SMULWB( 39322, b_Q14 ) ), 16 ); // 0.6_Q0 = 39322_Q16\r
-        psEncCtrl->LF_shp_Q14[ 0 ] |= (SKP_uint16)( b_Q14 - ( 1 << 14 ) );\r
+        psEncCtrl->LF_shp_Q14[ 0 ]  = SKP_LSHIFT( SKP_FIX_CONST( 1.0, 14 ) - b_Q14 - \r
+            SKP_SMULWB( strength_Q16, SKP_SMULWB( SKP_FIX_CONST( 0.6, 16 ), b_Q14 ) ), 16 );\r
+        psEncCtrl->LF_shp_Q14[ 0 ] |= (SKP_uint16)( b_Q14 - SKP_FIX_CONST( 1.0, 14 ) );\r
         for( k = 1; k < NB_SUBFR; k++ ) {\r
-            psEncCtrl->LF_shp_Q14[ k ] = psEncCtrl->LF_shp_Q14[ k - 1 ];\r
+            psEncCtrl->LF_shp_Q14[ k ] = psEncCtrl->LF_shp_Q14[ 0 ];\r
         }\r
-        Tilt_Q16 = -HP_NOISE_COEF_Q16;\r
+        Tilt_Q16 = -SKP_FIX_CONST( HP_NOISE_COEF, 16 );\r
     }\r
 \r
     /****************************/\r
     /* HARMONIC SHAPING CONTROL */\r
     /****************************/\r
     /* Control boosting of harmonic frequencies */\r
-    HarmBoost_Q16 = SKP_SMULWB( SKP_SMULWB( ( 1 << 17 ) - SKP_LSHIFT( psEncCtrl->coding_quality_Q14, 3 ), \r
-        psEnc->LTPCorr_Q15 ), LOW_RATE_HARMONIC_BOOST_Q16 );\r
+    HarmBoost_Q16 = SKP_SMULWB( SKP_SMULWB( SKP_FIX_CONST( 1.0, 17 ) - SKP_LSHIFT( psEncCtrl->coding_quality_Q14, 3 ), \r
+        psEnc->LTPCorr_Q15 ), SKP_FIX_CONST( LOW_RATE_HARMONIC_BOOST, 16 ) );\r
 \r
     /* More harmonic boost for noisy input signals */\r
     HarmBoost_Q16 = SKP_SMLAWB( HarmBoost_Q16, \r
-        ( 1 << 16 ) - SKP_LSHIFT( psEncCtrl->input_quality_Q14, 2 ), LOW_INPUT_QUALITY_HARMONIC_BOOST_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
         /* More harmonic noise shaping for high bitrates or noisy input */\r
-        HarmShapeGain_Q16 = SKP_SMLAWB( HARMONIC_SHAPING_Q16\r
-                ( 1 << 16 ) - SKP_SMULWB( ( 1 << 18 ) - SKP_LSHIFT( psEncCtrl->coding_quality_Q14, 4 ),\r
-                psEncCtrl->input_quality_Q14 ), HIGH_RATE_OR_LOW_QUALITY_HARMONIC_SHAPING_Q16 );\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
+                psEncCtrl->input_quality_Q14 ), SKP_FIX_CONST( HIGH_RATE_OR_LOW_QUALITY_HARMONIC_SHAPING, 16 ) );\r
 \r
         /* Less harmonic noise shaping for less periodic signals */\r
         HarmShapeGain_Q16 = SKP_SMULWB( SKP_LSHIFT( HarmShapeGain_Q16, 1 ), \r
@@ -325,11 +469,11 @@ void SKP_Silk_noise_shape_analysis_FIX(
     /*************************/\r
     for( k = 0; k < NB_SUBFR; k++ ) {\r
         psShapeSt->HarmBoost_smth_Q16 =\r
-            SKP_SMLAWB( psShapeSt->HarmBoost_smth_Q16,     HarmBoost_Q16     - psShapeSt->HarmBoost_smth_Q16,     SUBFR_SMTH_COEF_Q16 );\r
+            SKP_SMLAWB( psShapeSt->HarmBoost_smth_Q16,     HarmBoost_Q16     - psShapeSt->HarmBoost_smth_Q16,     SKP_FIX_CONST( SUBFR_SMTH_COEF, 16 ) );\r
         psShapeSt->HarmShapeGain_smth_Q16 =\r
-            SKP_SMLAWB( psShapeSt->HarmShapeGain_smth_Q16, HarmShapeGain_Q16 - psShapeSt->HarmShapeGain_smth_Q16, SUBFR_SMTH_COEF_Q16 );\r
+            SKP_SMLAWB( psShapeSt->HarmShapeGain_smth_Q16, HarmShapeGain_Q16 - psShapeSt->HarmShapeGain_smth_Q16, SKP_FIX_CONST( SUBFR_SMTH_COEF, 16 ) );\r
         psShapeSt->Tilt_smth_Q16 =\r
-            SKP_SMLAWB( psShapeSt->Tilt_smth_Q16,          Tilt_Q16          - psShapeSt->Tilt_smth_Q16,          SUBFR_SMTH_COEF_Q16 );\r
+            SKP_SMLAWB( psShapeSt->Tilt_smth_Q16,          Tilt_Q16          - psShapeSt->Tilt_smth_Q16,          SKP_FIX_CONST( SUBFR_SMTH_COEF, 16 ) );\r
 \r
         psEncCtrl->HarmBoost_Q14[ k ]     = ( SKP_int )SKP_RSHIFT_ROUND( psShapeSt->HarmBoost_smth_Q16,     2 );\r
         psEncCtrl->HarmShapeGain_Q14[ k ] = ( SKP_int )SKP_RSHIFT_ROUND( psShapeSt->HarmShapeGain_smth_Q16, 2 );\r
diff --git a/libs/silk/src/SKP_Silk_perceptual_parameters_FIX.h b/libs/silk/src/SKP_Silk_perceptual_parameters_FIX.h
deleted file mode 100644 (file)
index dfa7c45..0000000
+++ /dev/null
@@ -1,121 +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
-#ifndef SKP_SILK_PERCEPTUAL_PARAMETERS_FIX_H\r
-#define SKP_SILK_PERCEPTUAL_PARAMETERS_FIX_H\r
-\r
-#ifdef __cplusplus\r
-extern "C"\r
-{\r
-#endif\r
-\r
-/* reduction in coding SNR during low speech activity */\r
-#define BG_SNR_DECR_dB_Q7                               (3<<7)\r
-\r
-/* factor for reducing quantization noise during voiced speech */\r
-#define HARM_SNR_INCR_dB_Q7                             (2<<7)\r
-\r
-/* factor for reducing quantization noise for unvoiced sparse signals */\r
-#define SPARSE_SNR_INCR_dB_Q7                           (2<<7)\r
-\r
-/* threshold for sparseness measure above which to use lower quantization offset during unvoiced */\r
-#define SPARSENESS_THRESHOLD_QNT_OFFSET_Q8              (3<<6) // 0.75\r
-\r
-\r
-/* noise shaping filter chirp factor */\r
-#define BANDWIDTH_EXPANSION_Q16                         61604 // 0.94\r
-\r
-/* difference between chirp factors for analysis and synthesis noise shaping filters at low bitrates */\r
-#define LOW_RATE_BANDWIDTH_EXPANSION_DELTA_Q16          655 //0.01f\r
-\r
-/* factor to reduce all bandwidth expansion coefficients for super wideband, relative to wideband */\r
-#define SWB_BANDWIDTH_EXPANSION_REDUCTION_Q16           (1<<16) // 1.0f;\r
-\r
-/* gain reduction for fricatives */\r
-#define DE_ESSER_COEF_SWB_dB_Q7                         (2 << 7)\r
-#define DE_ESSER_COEF_WB_dB_Q7                          (1 << 7)\r
-\r
-\r
-/* extra harmonic boosting (signal shaping) at low bitrates */\r
-#define LOW_RATE_HARMONIC_BOOST_Q16                     6554 // 0.1\r
-\r
-/* extra harmonic boosting (signal shaping) for noisy input signals */\r
-#define LOW_INPUT_QUALITY_HARMONIC_BOOST_Q16            6554 // 0.1\r
-\r
-/* harmonic noise shaping */\r
-#define HARMONIC_SHAPING_Q16                            19661 // 0.3\r
-\r
-/* extra harmonic noise shaping for high bitrates or noisy input */\r
-#define HIGH_RATE_OR_LOW_QUALITY_HARMONIC_SHAPING_Q16   13107 // 0.2\r
-\r
-\r
-/* parameter for shaping noise towards higher frequencies */\r
-#define HP_NOISE_COEF_Q16                               19661 // 0.3\r
-\r
-/* parameter for shaping noise extra towards higher frequencies during voiced speech */\r
-#define HARM_HP_NOISE_COEF_Q24                          7549747 // 0.45\r
-\r
-/* parameter for applying a high-pass tilt to the input signal */\r
-#define INPUT_TILT_Q26                                  2684355 // 0.04\r
-\r
-/* parameter for extra high-pass tilt to the input signal at high rates */\r
-#define HIGH_RATE_INPUT_TILT_Q12                        246 // 0.06\r
-\r
-/* parameter for reducing noise at the very low frequencies */\r
-#define LOW_FREQ_SHAPING_Q0                             3\r
-\r
-/* less reduction of noise at the very low frequencies for signals with low SNR at low frequencies */\r
-#define LOW_QUALITY_LOW_FREQ_SHAPING_DECR_Q1            1 // 0.5_Q0\r
-\r
-/* fraction added to first autocorrelation value */\r
-#define SHAPE_WHITE_NOISE_FRACTION_Q20                  50 // 50_Q20 = 4.7684e-5\r
-\r
-/* fraction of first autocorrelation value added to residual energy value; limits prediction gain */\r
-#define SHAPE_MIN_ENERGY_RATIO_Q24                      256\r
-\r
-/* noise floor to put a low limit on the quantization step size */\r
-#define NOISE_FLOOR_dB_Q7                               (4 << 7)\r
-\r
-/* noise floor relative to active speech gain level */\r
-#define RELATIVE_MIN_GAIN_dB_Q7                         -6400 // -50_Q0 = -6400_Q7\r
-\r
-/* subframe smoothing coefficient for determining active speech gain level (lower -> more smoothing) */\r
-#define GAIN_SMOOTHING_COEF_Q10                         1 // 1e-3_Q0 = 1.024_Q10\r
-\r
-/* subframe smoothing coefficient for HarmBoost, HarmShapeGain, Tilt (lower -> more smoothing) */\r
-#define SUBFR_SMTH_COEF_Q16                             26214 // 0.4\r
-\r
-#define NOISE_GAIN_VL_Q16                               7864\r
-#define NOISE_GAIN_VH_Q16                               7864\r
-#define NOISE_GAIN_UVL_Q16                              6554\r
-#define NOISE_GAIN_UVH_Q16                              9830\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-#endif //SKP_SILK_PERCEPTUAL_PARAMETERS_FIX_H\r
index 6d68c1a24fb19a1ead857829e6e0d71eff2617ab..f62d222fcca3fd31f9d186a64de14d9d7743f3a7 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -30,7 +30,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ********************************************************** */\r
 #include "SKP_Silk_SigProc_FIX.h"\r
 #include "SKP_Silk_pitch_est_defines.h"\r
-#include "SKP_Silk_resample_rom.h"\r
+#include "SKP_Silk_common_pitch_est_defines.h"\r
 \r
 #define SCRATCH_SIZE    22\r
 \r
@@ -59,31 +59,6 @@ SKP_int32 SKP_FIX_P_Ana_find_scaling(
     const SKP_int    sum_sqr_len\r
 );\r
 \r
-void SKP_Silk_decode_pitch(\r
-    SKP_int          lagIndex,                        /* I                             */\r
-    SKP_int          contourIndex,                    /* O                             */\r
-    SKP_int          pitch_lags[],                    /* O 4 pitch values              */\r
-    SKP_int          Fs_kHz                           /* I sampling frequency (kHz)    */\r
-)\r
-{\r
-    SKP_int lag, i, min_lag;\r
-\r
-    min_lag = SKP_SMULBB( PITCH_EST_MIN_LAG_MS, Fs_kHz );\r
-\r
-    /* Only for 24 / 16 kHz version for now */\r
-    lag = min_lag + lagIndex;\r
-    if( Fs_kHz == 8 ) {\r
-        /* Only a small codebook for 8 khz */\r
-        for( i = 0; i < PITCH_EST_NB_SUBFR; i++ ) {\r
-            pitch_lags[ i ] = lag + SKP_Silk_CB_lags_stage2[ i ][ contourIndex ];\r
-        }\r
-    } else {\r
-        for( i = 0; i < PITCH_EST_NB_SUBFR; i++ ) {\r
-            pitch_lags[ i ] = lag + SKP_Silk_CB_lags_stage3[ i ][ contourIndex ];\r
-        }\r
-    }\r
-}\r
-\r
 /*************************************************************/\r
 /*      FIXED POINT CORE PITCH ANALYSIS FUNCTION             */\r
 /*************************************************************/\r
@@ -97,7 +72,8 @@ SKP_int SKP_Silk_pitch_analysis_core(  /* O    Voicing estimate: 0 voiced, 1 unv
     const SKP_int32  search_thres1_Q16,  /* I    First stage threshold for lag candidates 0 - 1              */\r
     const SKP_int    search_thres2_Q15,  /* I    Final threshold for lag candidates 0 - 1                    */\r
     const SKP_int    Fs_kHz,             /* I    Sample frequency (kHz)                                      */\r
-    const SKP_int    complexity          /* I    Complexity setting, 0-2, where 2 is highest                 */\r
+    const SKP_int    complexity,         /* I   Complexity setting, 0-2, where 2 is highest                 */\r
+       const SKP_int    forLJC                      /* I        1 if this function is called from LJC code, 0 otherwise.  */\r
 )\r
 {\r
     SKP_int16 signal_8kHz[ PITCH_EST_MAX_FRAME_LENGTH_ST_2 ];\r
@@ -131,8 +107,8 @@ SKP_int SKP_Silk_pitch_analysis_core(  /* O    Voicing estimate: 0 voiced, 1 unv
     SKP_assert( Fs_kHz == 8 || Fs_kHz == 12 || Fs_kHz == 16 || Fs_kHz == 24 );\r
 \r
     /* Check for valid complexity setting */\r
-    SKP_assert( complexity >= SigProc_PITCH_EST_MIN_COMPLEX );\r
-    SKP_assert( complexity <= SigProc_PITCH_EST_MAX_COMPLEX );\r
+    SKP_assert( complexity >= SKP_Silk_PITCH_EST_MIN_COMPLEX );\r
+    SKP_assert( complexity <= SKP_Silk_PITCH_EST_MAX_COMPLEX );\r
 \r
     SKP_assert( search_thres1_Q16 >= 0 && search_thres1_Q16 <= (1<<16) );\r
     SKP_assert( search_thres2_Q15 >= 0 && search_thres2_Q15 <= (1<<15) );\r
@@ -154,50 +130,24 @@ SKP_int SKP_Silk_pitch_analysis_core(  /* O    Voicing estimate: 0 voiced, 1 unv
     SKP_memset( C, 0, sizeof( SKP_int16 ) * PITCH_EST_NB_SUBFR * ( ( PITCH_EST_MAX_LAG >> 1 ) + 5) );\r
     \r
     /* Resample from input sampled at Fs_kHz to 8 kHz */\r
-    if( Fs_kHz == 12 ) {\r
-        SKP_int16 R23[ SigProc_Resample_2_3_coarsest_NUM_FIR_COEFS - 1 ];\r
-        SKP_memset( R23, 0, ( SigProc_Resample_2_3_coarsest_NUM_FIR_COEFS - 1 ) * sizeof( SKP_int16 ) );\r
-        \r
-        SKP_Silk_resample_2_3_coarsest( signal_8kHz, R23, signal, \r
-            PITCH_EST_FRAME_LENGTH_MS * 12, (SKP_int16*)scratch_mem );\r
-    } else if( Fs_kHz == 16 ) {\r
-        if( complexity == SigProc_PITCH_EST_MAX_COMPLEX ) {\r
-            SKP_assert( 4 <= PITCH_EST_MAX_DECIMATE_STATE_LENGTH );\r
-            SKP_memset( filt_state, 0, 4 * sizeof( SKP_int32 ) );\r
-\r
-            SKP_Silk_resample_1_2_coarse( signal, filt_state, signal_8kHz,\r
-                scratch_mem, frame_length_8kHz );\r
-        } else {\r
-            SKP_assert( 2 <= PITCH_EST_MAX_DECIMATE_STATE_LENGTH );\r
-            SKP_memset( filt_state, 0, 2 * sizeof( SKP_int32 ) );\r
-            \r
-            SKP_Silk_resample_1_2_coarsest( signal, filt_state, signal_8kHz,\r
-                scratch_mem, frame_length_8kHz );\r
-        }\r
+    if( Fs_kHz == 16 ) {\r
+        SKP_memset( filt_state, 0, 2 * sizeof( SKP_int32 ) );\r
+        SKP_Silk_resampler_down2( filt_state, signal_8kHz, signal, frame_length );\r
+    } else if ( Fs_kHz == 12 ) {\r
+        SKP_int32 R23[ 6 ];\r
+        SKP_memset( R23, 0, 6 * sizeof( SKP_int32 ) );\r
+        SKP_Silk_resampler_down2_3( R23, signal_8kHz, signal, PITCH_EST_FRAME_LENGTH_MS * 12 );\r
     } else if( Fs_kHz == 24 ) {\r
-        /* Resample to 24 -> 8 khz */\r
-        SKP_assert( 7 <= PITCH_EST_MAX_DECIMATE_STATE_LENGTH );\r
-        SKP_memset( filt_state, 0, 7 * sizeof( SKP_int32 ) );\r
-\r
-        SKP_Silk_resample_1_3( signal_8kHz, filt_state, signal, 24 * PITCH_EST_FRAME_LENGTH_MS );\r
-    \r
+        SKP_int32 filt_state_fix[ 8 ];\r
+        SKP_memset( filt_state_fix, 0, 8 * sizeof(SKP_int32) );\r
+        SKP_Silk_resampler_down3( filt_state_fix, signal_8kHz, signal, 24 * PITCH_EST_FRAME_LENGTH_MS );\r
     } else {\r
         SKP_assert( Fs_kHz == 8 );\r
-        SKP_memcpy( signal_8kHz, signal, frame_length_8kHz * sizeof( SKP_int16 ) );\r
-    }\r
-\r
-    /* Decimate again to 4 kHz. Set mem to zero */\r
-    if( complexity == SigProc_PITCH_EST_MAX_COMPLEX ) {\r
-        SKP_assert( 4 <= PITCH_EST_MAX_DECIMATE_STATE_LENGTH );\r
-        SKP_memset( filt_state, 0, 4 * sizeof( SKP_int32 ) );    \r
-        SKP_Silk_resample_1_2_coarse( signal_8kHz, filt_state,\r
-            signal_4kHz, scratch_mem, frame_length_4kHz );\r
-    } else {\r
-        SKP_assert( 2 <= PITCH_EST_MAX_DECIMATE_STATE_LENGTH );\r
-        SKP_memset( filt_state, 0, 2 * sizeof( SKP_int32 ) );    \r
-        SKP_Silk_resample_1_2_coarsest( signal_8kHz, filt_state,\r
-            signal_4kHz, scratch_mem, frame_length_4kHz );\r
+        SKP_memcpy( signal_8kHz, signal, frame_length_8kHz * sizeof(SKP_int16) );\r
     }\r
+    /* Decimate again to 4 kHz */\r
+    SKP_memset( filt_state, 0, 2 * sizeof( SKP_int32 ) );/* Set state to zero */\r
+    SKP_Silk_resampler_down2( filt_state, signal_4kHz, signal_8kHz, frame_length_8kHz );\r
 \r
     /* Low-pass filter */\r
     for( i = frame_length_4kHz - 1; i > 0; i-- ) {\r
@@ -238,7 +188,7 @@ SKP_int SKP_Silk_pitch_analysis_core(  /* O    Voicing estimate: 0 voiced, 1 unv
         /* Calculate first vector products before loop */\r
         cross_corr = SKP_Silk_inner_prod_aligned( target_ptr, basis_ptr, sf_length_8kHz );\r
         normalizer = SKP_Silk_inner_prod_aligned( basis_ptr,  basis_ptr, sf_length_8kHz );\r
-        normalizer = SKP_ADD_SAT32( normalizer, 1000 );\r
+        normalizer = SKP_ADD_SAT32( normalizer, SKP_SMULBB( sf_length_8kHz, 4000 ) );\r
 \r
         temp32 = SKP_DIV32( cross_corr, SKP_Silk_SQRT_APPROX( normalizer ) + 1 );\r
         C[ k ][ min_lag_4kHz ] = (SKP_int16)SKP_SAT16( temp32 );        /* Q0 */\r
@@ -277,14 +227,14 @@ SKP_int SKP_Silk_pitch_analysis_core(  /* O    Voicing estimate: 0 voiced, 1 unv
     }\r
 \r
     /* Sort */\r
-    length_d_srch = 5 + complexity;\r
-    SKP_assert( length_d_srch <= PITCH_EST_D_SRCH_LENGTH );\r
+    length_d_srch = 4 + 2 * complexity;\r
+    SKP_assert( 3 * length_d_srch <= PITCH_EST_D_SRCH_LENGTH );\r
     SKP_Silk_insertion_sort_decreasing_int16( &C[ 0 ][ min_lag_4kHz ], d_srch, max_lag_4kHz - min_lag_4kHz + 1, length_d_srch );\r
 \r
     /* Escape if correlation is very low already here */\r
     target_ptr = &signal_4kHz[ SKP_RSHIFT( frame_length_4kHz, 1 ) ];\r
     energy = SKP_Silk_inner_prod_aligned( target_ptr, target_ptr, SKP_RSHIFT( frame_length_4kHz, 1 ) );\r
-    energy = SKP_ADD_SAT32( energy, 1000 );                                  /* Q0 */\r
+    energy = SKP_ADD_POS_SAT32( energy, 1000 );                              /* Q0 */\r
     Cmax = (SKP_int)C[ 0 ][ min_lag_4kHz ];                                  /* Q-1 */\r
     threshold = SKP_SMULBB( Cmax, Cmax );                                    /* Q-2 */\r
     /* Compare in Q-2 domain */\r
@@ -383,13 +333,13 @@ SKP_int SKP_Silk_pitch_analysis_core(  /* O    Voicing estimate: 0 voiced, 1 unv
             if( cross_corr > 0 ) {\r
                 energy = SKP_max( energy_target, energy_basis ); /* Find max to make sure first division < 1.0 */\r
                 lz = SKP_Silk_CLZ32( cross_corr );\r
-                lshift = SKP_LIMIT( lz - 1, 0, 15 );\r
+                lshift = SKP_LIMIT_32( lz - 1, 0, 15 );\r
                 temp32 = SKP_DIV32( SKP_LSHIFT( cross_corr, lshift ), SKP_RSHIFT( energy, 15 - lshift ) + 1 ); /* Q15 */\r
                 SKP_assert( temp32 == SKP_SAT16( temp32 ) );\r
                 temp32 = SKP_SMULWB( cross_corr, temp32 ); /* Q(-1), cc * ( cc / max(b, t) ) */\r
                 temp32 = SKP_ADD_SAT32( temp32, temp32 );  /* Q(0) */\r
                 lz = SKP_Silk_CLZ32( temp32 );\r
-                lshift = SKP_LIMIT( lz - 1, 0, 15 );\r
+                lshift = SKP_LIMIT_32( lz - 1, 0, 15 );\r
                 energy = SKP_min( energy_target, energy_basis );\r
                 C[ k ][ d ] = SKP_DIV32( SKP_LSHIFT( temp32, lshift ), SKP_RSHIFT( energy, 15 - lshift ) + 1 ); // Q15\r
             } else {\r
@@ -424,7 +374,7 @@ SKP_int SKP_Silk_pitch_analysis_core(  /* O    Voicing estimate: 0 voiced, 1 unv
     corr_thres_Q15 = SKP_RSHIFT( SKP_SMULBB( search_thres2_Q15, search_thres2_Q15 ), 13 );\r
 \r
     /* If input is 8 khz use a larger codebook here because it is last stage */\r
-    if( Fs_kHz == 8 && complexity > SigProc_PITCH_EST_MIN_COMPLEX ) {\r
+    if( Fs_kHz == 8 && complexity > SKP_Silk_PITCH_EST_MIN_COMPLEX ) {\r
         nb_cbks_stage2 = PITCH_EST_NB_CBKS_STAGE2_EXT;    \r
     } else {\r
         nb_cbks_stage2 = PITCH_EST_NB_CBKS_STAGE2;\r
@@ -451,10 +401,15 @@ SKP_int SKP_Silk_pitch_analysis_core(  /* O    Voicing estimate: 0 voiced, 1 unv
 \r
         /* Bias towards shorter lags */\r
         lag_log2_Q7 = SKP_Silk_lin2log( (SKP_int32)d ); /* Q7 */\r
-        SKP_assert( lag_log2_Q7 == SKP_SAT16( lag_log2_Q7 ) );\r
-        SKP_assert( PITCH_EST_NB_SUBFR * PITCH_EST_SHORTLAG_BIAS_Q15 == SKP_SAT16( PITCH_EST_NB_SUBFR * PITCH_EST_SHORTLAG_BIAS_Q15 ) );\r
-        CCmax_new_b = CCmax_new - SKP_RSHIFT( SKP_SMULBB( PITCH_EST_NB_SUBFR * PITCH_EST_SHORTLAG_BIAS_Q15, lag_log2_Q7 ), 7 ); /* Q15 */\r
-\r
+           SKP_assert( lag_log2_Q7 == SKP_SAT16( lag_log2_Q7 ) );\r
+               SKP_assert( PITCH_EST_NB_SUBFR * PITCH_EST_SHORTLAG_BIAS_Q15 == SKP_SAT16( PITCH_EST_NB_SUBFR * PITCH_EST_SHORTLAG_BIAS_Q15 ) );\r
+\r
+               if (forLJC) {\r
+                       CCmax_new_b = CCmax_new;\r
+               } else {\r
+                       CCmax_new_b = CCmax_new - SKP_RSHIFT( SKP_SMULBB( PITCH_EST_NB_SUBFR * PITCH_EST_SHORTLAG_BIAS_Q15, lag_log2_Q7 ), 7 ); /* Q15 */\r
+               }\r
+               \r
         /* Bias towards previous lag */\r
         SKP_assert( PITCH_EST_NB_SUBFR * PITCH_EST_PREVLAG_BIAS_Q15 == SKP_SAT16( PITCH_EST_NB_SUBFR * PITCH_EST_PREVLAG_BIAS_Q15 ) );\r
         if( prevLag > 0 ) {\r
@@ -466,7 +421,10 @@ SKP_int SKP_Silk_pitch_analysis_core(  /* O    Voicing estimate: 0 voiced, 1 unv
             CCmax_new_b -= prev_lag_bias_Q15; /* Q15 */\r
         }\r
 \r
-        if( CCmax_new_b > CCmax_b && CCmax_new > corr_thres_Q15 ) {\r
+        if ( CCmax_new_b > CCmax_b                                          &&              /* Find maximum biased correlation                  */\r
+              CCmax_new > corr_thres_Q15                                    &&              /* Correlation needs to be high enough to be voiced */\r
+             SKP_Silk_CB_lags_stage2[ 0 ][ CBimax_new ] <= min_lag_8kHz                   /* Lag must be in range                             */\r
+            ) {\r
             CCmax_b = CCmax_new_b;\r
             CCmax   = CCmax_new;\r
             lag     = d;\r
@@ -515,7 +473,7 @@ SKP_int SKP_Silk_pitch_analysis_core(  /* O    Voicing estimate: 0 voiced, 1 unv
             lag = SKP_SMULBB( lag, 3 );\r
         }\r
 \r
-        lag = SKP_LIMIT( lag, min_lag, max_lag );\r
+        lag = SKP_LIMIT_int( lag, min_lag, max_lag );\r
         start_lag = SKP_max_int( lag - 2, min_lag );\r
         end_lag   = SKP_min_int( lag + 2, max_lag );\r
         lag_new   = lag;                                    /* to avoid undefined lag */\r
@@ -554,7 +512,7 @@ SKP_int SKP_Silk_pitch_analysis_core(  /* O    Voicing estimate: 0 voiced, 1 unv
                     /* Divide cross_corr / energy and get result in Q15 */\r
                     lz = SKP_Silk_CLZ32( cross_corr );\r
                     /* Divide with result in Q13, cross_corr could be larger than energy */\r
-                    lshift = SKP_LIMIT( lz - 1, 0, 13 );\r
+                    lshift = SKP_LIMIT_32( lz - 1, 0, 13 );\r
                     CCmax_new = SKP_DIV32( SKP_LSHIFT( cross_corr, lshift ), SKP_RSHIFT( energy, 13 - lshift ) + 1 );\r
                     CCmax_new = SKP_SAT16( CCmax_new );\r
                     CCmax_new = SKP_SMULWB( cross_corr, CCmax_new );\r
@@ -574,7 +532,9 @@ SKP_int SKP_Silk_pitch_analysis_core(  /* O    Voicing estimate: 0 voiced, 1 unv
                     CCmax_new = 0;\r
                 }\r
 \r
-                if( CCmax_new > CCmax ) {\r
+                if( CCmax_new > CCmax                                               && \r
+                   ( d + (SKP_int)SKP_Silk_CB_lags_stage3[ 0 ][ j ] ) <= max_lag  \r
+                   ) {\r
                     CCmax   = CCmax_new;\r
                     lag_new = d;\r
                     CBimax  = j;\r
@@ -621,8 +581,8 @@ void SKP_FIX_P_Ana_calc_corr_st3(
     SKP_int        cbk_offset, cbk_size, delta, idx;\r
     SKP_int32    scratch_mem[ SCRATCH_SIZE ];\r
 \r
-    SKP_assert( complexity >= SigProc_PITCH_EST_MIN_COMPLEX );\r
-    SKP_assert( complexity <= SigProc_PITCH_EST_MAX_COMPLEX );\r
+    SKP_assert( complexity >= SKP_Silk_PITCH_EST_MIN_COMPLEX );\r
+    SKP_assert( complexity <= SKP_Silk_PITCH_EST_MAX_COMPLEX );\r
 \r
     cbk_offset = SKP_Silk_cbk_offsets_stage3[ complexity ];\r
     cbk_size   = SKP_Silk_cbk_sizes_stage3[   complexity ];\r
@@ -673,8 +633,8 @@ void SKP_FIX_P_Ana_calc_energy_st3(
     SKP_int        cbk_offset, cbk_size, delta, idx;\r
     SKP_int32    scratch_mem[ SCRATCH_SIZE ];\r
 \r
-    SKP_assert( complexity >= SigProc_PITCH_EST_MIN_COMPLEX );\r
-    SKP_assert( complexity <= SigProc_PITCH_EST_MAX_COMPLEX );\r
+    SKP_assert( complexity >= SKP_Silk_PITCH_EST_MIN_COMPLEX );\r
+    SKP_assert( complexity <= SKP_Silk_PITCH_EST_MAX_COMPLEX );\r
 \r
     cbk_offset = SKP_Silk_cbk_offsets_stage3[ complexity ];\r
     cbk_size   = SKP_Silk_cbk_sizes_stage3[   complexity ];\r
index 97dd0a95e9685680cb842e22fae2281d92b7db86..5f1c456958a1e3eaca78df34a6c240b2cfad45d7 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -28,16 +28,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #ifndef SIGPROCFIX_PITCH_EST_DEFINES_H\r
 #define SIGPROCFIX_PITCH_EST_DEFINES_H\r
 \r
-#include "SKP_Silk_SigProc_FIX.h"\r
-#include "SKP_Silk_common_pitch_est_defines.h"\r
-\r
 /************************************************************/\r
-/* Definitions For Fix pitch estimator                                         */\r
+/* Definitions For Fix pitch estimator                      */\r
 /************************************************************/\r
 \r
-#define PITCH_EST_SHORTLAG_BIAS_Q15                    6554    /* 0.2f. for logarithmic weighting      */\r
-#define PITCH_EST_PREVLAG_BIAS_Q15                     6554    /* Prev lag bias        */\r
-#define PITCH_EST_FLATCONTOUR_BIAS_Q20         52429   /* 0.05f */\r
+#define PITCH_EST_SHORTLAG_BIAS_Q15         6554    /* 0.2f. for logarithmic weighting    */\r
+#define PITCH_EST_PREVLAG_BIAS_Q15          6554    /* Prev lag bias    */\r
+#define PITCH_EST_FLATCONTOUR_BIAS_Q20      52429   /* 0.05f */\r
 \r
 #endif\r
 \r
index c15181928a7bb607845fcb742bcf49be2e97261c..6ff96a77177f0b46017a349b4f28ecc9a47dd3b8 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***********************************************************************/\r
 \r
 #include "SKP_Silk_typedef.h"\r
-#include "SKP_Silk_pitch_est_defines.h"\r
+#include "SKP_Silk_common_pitch_est_defines.h"\r
 \r
 /********************************************************/\r
 /* Auto Generated File from generate_pitch_est_tables.m */\r
@@ -48,7 +48,7 @@ const SKP_int16 SKP_Silk_CB_lags_stage3[PITCH_EST_NB_SUBFR][PITCH_EST_NB_CBKS_ST
     { 9, 8, 6, 5, 6, 5, 4, 4, 3, 3, 2, 2, 2, 1, 0, 1, 1, 0, 0, 0,-1,-1,-1,-2,-2,-2,-3,-3,-4,-4,-5,-5,-6,-7}\r
  };\r
 \r
-const SKP_int16 SKP_Silk_Lag_range_stage3[ SigProc_PITCH_EST_MAX_COMPLEX + 1 ] [ PITCH_EST_NB_SUBFR ][ 2 ] =\r
+const SKP_int16 SKP_Silk_Lag_range_stage3[ SKP_Silk_PITCH_EST_MAX_COMPLEX + 1 ] [ PITCH_EST_NB_SUBFR ][ 2 ] =\r
 {\r
     /* Lags to search for low number of stage3 cbks */\r
     {\r
@@ -73,14 +73,14 @@ const SKP_int16 SKP_Silk_Lag_range_stage3[ SigProc_PITCH_EST_MAX_COMPLEX + 1 ] [
     }\r
 };\r
 \r
-const SKP_int16 SKP_Silk_cbk_sizes_stage3[SigProc_PITCH_EST_MAX_COMPLEX + 1] = \r
+const SKP_int16 SKP_Silk_cbk_sizes_stage3[SKP_Silk_PITCH_EST_MAX_COMPLEX + 1] = \r
 {\r
     PITCH_EST_NB_CBKS_STAGE3_MIN,\r
     PITCH_EST_NB_CBKS_STAGE3_MID,\r
     PITCH_EST_NB_CBKS_STAGE3_MAX\r
 };\r
 \r
-const SKP_int16 SKP_Silk_cbk_offsets_stage3[SigProc_PITCH_EST_MAX_COMPLEX + 1] = \r
+const SKP_int16 SKP_Silk_cbk_offsets_stage3[SKP_Silk_PITCH_EST_MAX_COMPLEX + 1] = \r
 {\r
     ((PITCH_EST_NB_CBKS_STAGE3_MAX - PITCH_EST_NB_CBKS_STAGE3_MIN) >> 1),\r
     ((PITCH_EST_NB_CBKS_STAGE3_MAX - PITCH_EST_NB_CBKS_STAGE3_MID) >> 1),\r
index d4c98b6803cbec1e76ceef5e2dfd0510cfabc8a2..d3fd9c5297a44b220b5e70efce95bab326349fa0 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***********************************************************************/\r
 \r
 #include "SKP_Silk_main_FIX.h"\r
-#include "SKP_Silk_perceptual_parameters_FIX.h"\r
+#include "SKP_Silk_tuning_parameters.h"\r
 \r
 /* SKP_Silk_prefilter. Prefilter for finding Quantizer input signal */\r
 SKP_INLINE void SKP_Silk_prefilt_FIX(\r
@@ -39,6 +39,46 @@ SKP_INLINE void SKP_Silk_prefilt_FIX(
     SKP_int     lag,                                    /* I Lag for harmonic shaping         */\r
     SKP_int     length                                  /* I Length of signals                */\r
 );\r
+void SKP_Silk_warped_LPC_analysis_filter_FIX(\r
+          SKP_int32                 state[],            /* I/O  State [order + 1]                       */\r
+          SKP_int16                 res[],              /* O    Residual signal [length]                */\r
+    const SKP_int16                 coef_Q13[],         /* I    Coefficients [order]                    */\r
+    const SKP_int16                 input[],            /* I    Input signal [length]                   */\r
+    const SKP_int16                 lambda_Q16,         /* I    Warping factor                          */\r
+    const SKP_int                   length,             /* I    Length of input signal                  */\r
+    const SKP_int                   order               /* I    Filter order (even)                     */\r
+)\r
+{\r
+    SKP_int     n, i;\r
+    SKP_int32   acc_Q11, tmp1, tmp2;\r
+\r
+    /* Order must be even */\r
+    SKP_assert( ( order & 1 ) == 0 );\r
+\r
+    for( n = 0; n < length; n++ ) {\r
+        /* Output of lowpass section */  \r
+        tmp2 = SKP_SMLAWB( state[ 0 ], state[ 1 ], lambda_Q16 );\r
+        state[ 0 ] = SKP_LSHIFT( input[ n ], 14 );\r
+        /* Output of allpass section */\r
+        tmp1 = SKP_SMLAWB( state[ 1 ], state[ 2 ] - tmp2, lambda_Q16 );\r
+        state[ 1 ] = tmp2;\r
+        acc_Q11 = SKP_SMULWB( tmp2, coef_Q13[ 0 ] );\r
+        /* Loop over allpass sections */\r
+        for( i = 2; i < order; i += 2 ) {\r
+            /* Output of allpass section */\r
+            tmp2 = SKP_SMLAWB( state[ i ], state[ i + 1 ] - tmp1, lambda_Q16 );\r
+            state[ i ] = tmp1;\r
+            acc_Q11 = SKP_SMLAWB( acc_Q11, tmp1, coef_Q13[ i - 1 ] );\r
+            /* Output of allpass section */\r
+            tmp1 = SKP_SMLAWB( state[ i + 1 ], state[ i + 2 ] - tmp2, lambda_Q16 );\r
+            state[ i + 1 ] = tmp2;\r
+            acc_Q11 = SKP_SMLAWB( acc_Q11, tmp2, coef_Q13[ i ] );\r
+        }\r
+        state[ order ] = tmp1;\r
+        acc_Q11 = SKP_SMLAWB( acc_Q11, tmp1, coef_Q13[ order - 1 ] );\r
+        res[ n ] = ( SKP_int16 )SKP_SAT16( ( SKP_int32 )input[ n ] - SKP_RSHIFT_ROUND( acc_Q11, 11 ) );\r
+    }\r
+}\r
 \r
 void SKP_Silk_prefilter_FIX(\r
     SKP_Silk_encoder_state_FIX          *psEnc,         /* I/O  Encoder state FIX                           */\r
@@ -49,14 +89,15 @@ void SKP_Silk_prefilter_FIX(
 {\r
     SKP_Silk_prefilter_state_FIX *P = &psEnc->sPrefilt;\r
     SKP_int   j, k, lag;\r
-    SKP_int32 tmp_32, B_Q12;\r
+    SKP_int32 tmp_32;\r
     const SKP_int16 *AR1_shp_Q13;\r
     const SKP_int16 *px;\r
-    SKP_int16 *pxw, *pst_res;\r
-    SKP_int   HarmShapeGain_Q12, Tilt_Q14, LF_shp_Q14;\r
-    SKP_int32 HarmShapeFIRPacked_Q12;\r
-    SKP_int32 x_filt_Q12[ MAX_FRAME_LENGTH / NB_SUBFR ], filterState[ MAX_LPC_ORDER ];\r
-    SKP_int16 st_res[ ( MAX_FRAME_LENGTH / NB_SUBFR ) + MAX_LPC_ORDER ];\r
+    SKP_int16 *pxw;\r
+    SKP_int   HarmShapeGain_Q12, Tilt_Q14;\r
+    SKP_int32 HarmShapeFIRPacked_Q12, LF_shp_Q14;\r
+    SKP_int32 x_filt_Q12[ MAX_FRAME_LENGTH / NB_SUBFR ];\r
+    SKP_int16 st_res[ ( MAX_FRAME_LENGTH / NB_SUBFR ) + MAX_SHAPE_LPC_ORDER ];\r
+    SKP_int16 B_Q12[ 2 ];\r
 \r
     /* Setup pointers */\r
     px  = x;\r
@@ -71,36 +112,29 @@ void SKP_Silk_prefilter_FIX(
         /* Noise shape parameters */\r
         HarmShapeGain_Q12 = SKP_SMULWB( psEncCtrl->HarmShapeGain_Q14[ k ], 16384 - psEncCtrl->HarmBoost_Q14[ k ] );\r
         SKP_assert( HarmShapeGain_Q12 >= 0 );\r
-        HarmShapeFIRPacked_Q12  =                        SKP_RSHIFT( HarmShapeGain_Q12, 2 );\r
+        HarmShapeFIRPacked_Q12  =                          SKP_RSHIFT( HarmShapeGain_Q12, 2 );\r
         HarmShapeFIRPacked_Q12 |= SKP_LSHIFT( ( SKP_int32 )SKP_RSHIFT( HarmShapeGain_Q12, 1 ), 16 );\r
         Tilt_Q14    = psEncCtrl->Tilt_Q14[   k ];\r
         LF_shp_Q14  = psEncCtrl->LF_shp_Q14[ k ];\r
-        AR1_shp_Q13 = &psEncCtrl->AR1_Q13[   k * SHAPE_LPC_ORDER_MAX ];\r
+        AR1_shp_Q13 = &psEncCtrl->AR1_Q13[   k * MAX_SHAPE_LPC_ORDER ];\r
 \r
         /* Short term FIR filtering*/\r
-        SKP_memset( filterState, 0, psEnc->sCmn.shapingLPCOrder * sizeof( SKP_int32 ) );\r
-        SKP_Silk_MA_Prediction_Q13( px - psEnc->sCmn.shapingLPCOrder, AR1_shp_Q13, filterState, \r
-            st_res, psEnc->sCmn.subfr_length + psEnc->sCmn.shapingLPCOrder, psEnc->sCmn.shapingLPCOrder );\r
-\r
-        pst_res = st_res + psEnc->sCmn.shapingLPCOrder; /* Point to first sample */\r
+        SKP_Silk_warped_LPC_analysis_filter_FIX( P->sAR_shp, st_res, AR1_shp_Q13, px, \r
+            psEnc->sCmn.warping_Q16, psEnc->sCmn.subfr_length, psEnc->sCmn.shapingLPCOrder );\r
 \r
         /* reduce (mainly) low frequencies during harmonic emphasis */\r
-        B_Q12 = SKP_RSHIFT_ROUND( psEncCtrl->GainsPre_Q14[ k ], 2 );\r
-        tmp_32 = SKP_SMLABB( INPUT_TILT_Q26, psEncCtrl->HarmBoost_Q14[ k ], HarmShapeGain_Q12 ); /* Q26 */\r
-        tmp_32 = SKP_SMLABB( tmp_32, psEncCtrl->coding_quality_Q14, HIGH_RATE_INPUT_TILT_Q12 );  /* Q26 */\r
-        tmp_32 = SKP_SMULWB( tmp_32, -psEncCtrl->GainsPre_Q14[ k ] );                            /* Q24 */\r
-        tmp_32 = SKP_RSHIFT_ROUND( tmp_32, 12 );                                                 /* Q12 */\r
-        B_Q12 |= SKP_LSHIFT( SKP_SAT16( tmp_32 ), 16 );\r
-\r
-        /* NOTE: the code below loads two int16 values in an int32, and multiplies each using the   */\r
-        /* SMLABB and SMLABT instructions. On a big-endian CPU the two int16 variables would be     */\r
-        /* loaded in reverse order and the code will give the wrong result. In that case swapping   */\r
-        /* the SMLABB and SMLABT instructions should solve the problem.                             */\r
-        x_filt_Q12[ 0 ] = SKP_SMLABT( SKP_SMULBB( pst_res[ 0 ], B_Q12 ), P->sHarmHP, B_Q12 );\r
+        B_Q12[ 0 ] = SKP_RSHIFT_ROUND( psEncCtrl->GainsPre_Q14[ k ], 2 );\r
+        tmp_32 = SKP_SMLABB( SKP_FIX_CONST( INPUT_TILT, 26 ), psEncCtrl->HarmBoost_Q14[ k ], HarmShapeGain_Q12 );   /* Q26 */\r
+        tmp_32 = SKP_SMLABB( tmp_32, psEncCtrl->coding_quality_Q14, SKP_FIX_CONST( HIGH_RATE_INPUT_TILT, 12 ) );    /* Q26 */\r
+        tmp_32 = SKP_SMULWB( tmp_32, -psEncCtrl->GainsPre_Q14[ k ] );                                               /* Q24 */\r
+        tmp_32 = SKP_RSHIFT_ROUND( tmp_32, 12 );                                                                    /* Q12 */\r
+        B_Q12[ 1 ]= SKP_SAT16( tmp_32 );\r
+\r
+        x_filt_Q12[ 0 ] = SKP_SMLABB( SKP_SMULBB( st_res[ 0 ], B_Q12[ 0 ] ), P->sHarmHP, B_Q12[ 1 ] );\r
         for( j = 1; j < psEnc->sCmn.subfr_length; j++ ) {\r
-            x_filt_Q12[ j ] = SKP_SMLABT( SKP_SMULBB( pst_res[ j ], B_Q12 ), pst_res[ j - 1 ], B_Q12 );\r
+            x_filt_Q12[ j ] = SKP_SMLABB( SKP_SMULBB( st_res[ j ], B_Q12[ 0 ] ), st_res[ j - 1 ], B_Q12[ 1 ] );\r
         }\r
-        P->sHarmHP = pst_res[ psEnc->sCmn.subfr_length - 1 ];\r
+        P->sHarmHP = st_res[ psEnc->sCmn.subfr_length - 1 ];\r
 \r
         SKP_Silk_prefilt_FIX( P, x_filt_Q12, pxw, HarmShapeFIRPacked_Q12, Tilt_Q14, \r
             LF_shp_Q14, lag, psEnc->sCmn.subfr_length );\r
@@ -130,10 +164,10 @@ SKP_INLINE void SKP_Silk_prefilt_FIX(
     SKP_int16 *LTP_shp_buf;\r
 \r
     /* To speed up use temp variables instead of using the struct */\r
-    LTP_shp_buf     = P->sLTP_shp1;\r
-    LTP_shp_buf_idx = P->sLTP_shp_buf_idx1;\r
-    sLF_AR_shp_Q12  = P->sLF_AR_shp1_Q12;\r
-    sLF_MA_shp_Q12  = P->sLF_MA_shp1_Q12;\r
+    LTP_shp_buf     = P->sLTP_shp;\r
+    LTP_shp_buf_idx = P->sLTP_shp_buf_idx;\r
+    sLF_AR_shp_Q12  = P->sLF_AR_shp_Q12;\r
+    sLF_MA_shp_Q12  = P->sLF_MA_shp_Q12;\r
 \r
     for( i = 0; i < length; i++ ) {\r
         if( lag > 0 ) {\r
@@ -147,20 +181,20 @@ SKP_INLINE void SKP_Silk_prefilt_FIX(
             n_LTP_Q12 = 0;\r
         }\r
 \r
-        n_LF_Q10   = SKP_SMLAWB( SKP_SMULWT( sLF_AR_shp_Q12, LF_shp_Q14 ), sLF_MA_shp_Q12, LF_shp_Q14 );\r
         n_Tilt_Q10 = SKP_SMULWB( sLF_AR_shp_Q12, Tilt_Q14 );\r
+        n_LF_Q10   = SKP_SMLAWB( SKP_SMULWT( sLF_AR_shp_Q12, LF_shp_Q14 ), sLF_MA_shp_Q12, LF_shp_Q14 );\r
 \r
         sLF_AR_shp_Q12 = SKP_SUB32( st_res_Q12[ i ], SKP_LSHIFT( n_Tilt_Q10, 2 ) );\r
         sLF_MA_shp_Q12 = SKP_SUB32( sLF_AR_shp_Q12,  SKP_LSHIFT( n_LF_Q10,   2 ) );\r
 \r
-        LTP_shp_buf_idx                = ( LTP_shp_buf_idx - 1 ) & LTP_MASK;\r
+        LTP_shp_buf_idx = ( LTP_shp_buf_idx - 1 ) & LTP_MASK;\r
         LTP_shp_buf[ LTP_shp_buf_idx ] = ( SKP_int16 )SKP_SAT16( SKP_RSHIFT_ROUND( sLF_MA_shp_Q12, 12 ) );\r
 \r
         xw[i] = ( SKP_int16 )SKP_SAT16( SKP_RSHIFT_ROUND( SKP_SUB32( sLF_MA_shp_Q12, n_LTP_Q12 ), 12 ) );\r
     }\r
 \r
     /* Copy temp variable back to state */\r
-    P->sLF_AR_shp1_Q12   = sLF_AR_shp_Q12;\r
-    P->sLF_MA_shp1_Q12   = sLF_MA_shp_Q12;\r
-    P->sLTP_shp_buf_idx1 = LTP_shp_buf_idx;\r
+    P->sLF_AR_shp_Q12   = sLF_AR_shp_Q12;\r
+    P->sLF_MA_shp_Q12   = sLF_MA_shp_Q12;\r
+    P->sLTP_shp_buf_idx = LTP_shp_buf_idx;\r
 }\r
index 6bff532933b68bf835119cc058390d52227316fa..84b8a885662ef3cb6a42fdd3ecc2cebf543871ac 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
index e6400aa376db5b51559cd53e655fb957ae0c6b8f..2e0853c5cebde914458f2aeeee7c2cec2a53e827 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -26,6 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***********************************************************************/\r
 \r
 #include "SKP_Silk_main_FIX.h"\r
+#include "SKP_Silk_tuning_parameters.h"\r
 \r
 /* Processing of gains */\r
 void SKP_Silk_process_gains_FIX(\r
@@ -35,21 +36,20 @@ void SKP_Silk_process_gains_FIX(
 {\r
     SKP_Silk_shape_state_FIX    *psShapeSt = &psEnc->sShape;\r
     SKP_int     k;\r
-    SKP_int32   s_Q16, InvMaxSqrVal_Q16, gain, gain_squared, ResNrg, ResNrgPart;\r
+    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
         /*s = -0.5f * SKP_sigmoid( 0.25f * ( psEncCtrl->LTPredCodGain - 12.0f ) ); */\r
-        s_Q16 = -SKP_Silk_sigm_Q15( SKP_RSHIFT_ROUND( psEncCtrl->LTPredCodGain_Q7 - (12 << 7), 4 ) );\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 < NB_SUBFR; k++ ) {\r
             psEncCtrl->Gains_Q16[ k ] = SKP_SMLAWB( psEncCtrl->Gains_Q16[ k ], psEncCtrl->Gains_Q16[ k ], s_Q16 );\r
         }\r
     }\r
 \r
     /* Limit the quantized signal */\r
-    /*  69 = 21.0f + 16/0.33    */\r
     InvMaxSqrVal_Q16 = SKP_DIV32_16( SKP_Silk_log2lin( \r
-        SKP_SMULWB( (69 << 7) - psEncCtrl->current_SNR_dB_Q7, SKP_FIX_CONST( 0.33, 16 )) ), psEnc->sCmn.subfr_length );\r
+        SKP_SMULWB( SKP_FIX_CONST( 70.0, 7 ) - psEncCtrl->current_SNR_dB_Q7, SKP_FIX_CONST( 0.33, 16 ) ) ), psEnc->sCmn.subfr_length );\r
 \r
     for( k = 0; k < NB_SUBFR; k++ ) {\r
         /* Soft limit on ratio residual energy and squared gains */\r
@@ -87,7 +87,7 @@ void SKP_Silk_process_gains_FIX(
         &psShapeSt->LastGainIndex, psEnc->sCmn.nFramesInPayloadBuf );\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->LTPredCodGain_Q7 + SKP_RSHIFT( psEncCtrl->input_tilt_Q15, 8 ) > ( 1 << 7 ) ) {\r
+        if( psEncCtrl->LTPredCodGain_Q7 + SKP_RSHIFT( psEncCtrl->input_tilt_Q15, 8 ) > SKP_FIX_CONST( 1.0, 7 ) ) {\r
             psEncCtrl->sCmn.QuantOffsetType = 0;\r
         } else {\r
             psEncCtrl->sCmn.QuantOffsetType = 1;\r
@@ -95,20 +95,14 @@ void SKP_Silk_process_gains_FIX(
     }\r
 \r
     /* Quantizer boundary adjustment */\r
-    if( psEncCtrl->sCmn.sigtype == SIG_TYPE_VOICED ) {\r
-        psEncCtrl->Lambda_Q10 = SKP_FIX_CONST( 1.3, 10 )\r
-                  - SKP_SMULWB( SKP_FIX_CONST( 0.5, 18 ), psEnc->speech_activity_Q8       )\r
-                  - SKP_SMULWB( SKP_FIX_CONST( 0.3, 12 ), psEncCtrl->input_quality_Q14    )\r
-                  + SKP_SMULBB( SKP_FIX_CONST( 0.2, 10 ), psEncCtrl->sCmn.QuantOffsetType )\r
-                  - SKP_SMULWB( SKP_FIX_CONST( 0.1, 12 ), psEncCtrl->coding_quality_Q14   );\r
-    } else {\r
-        psEncCtrl->Lambda_Q10 = SKP_FIX_CONST( 1.3, 10 )\r
-                  - SKP_SMULWB( SKP_FIX_CONST( 0.5, 18 ), psEnc->speech_activity_Q8       )\r
-                  - SKP_SMULWB( SKP_FIX_CONST( 0.4, 12 ), psEncCtrl->input_quality_Q14    )\r
-                  + SKP_SMULBB( SKP_FIX_CONST( 0.4, 10 ), psEncCtrl->sCmn.QuantOffsetType )\r
-                  - SKP_SMULWB( SKP_FIX_CONST( 0.1, 12 ), psEncCtrl->coding_quality_Q14   );\r
-    }\r
-    SKP_assert( psEncCtrl->Lambda_Q10 >= 0 );\r
+    quant_offset_Q10 = SKP_Silk_Quantization_Offsets_Q10[ psEncCtrl->sCmn.sigtype ][ 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
+                          + SKP_SMULWB( SKP_FIX_CONST( LAMBDA_INPUT_QUALITY,     12 ), psEncCtrl->input_quality_Q14       )\r
+                          + SKP_SMULWB( SKP_FIX_CONST( LAMBDA_CODING_QUALITY,    12 ), psEncCtrl->coding_quality_Q14      )\r
+                          + SKP_SMULWB( SKP_FIX_CONST( LAMBDA_QUANT_OFFSET,      16 ), quant_offset_Q10                   );\r
+\r
+    SKP_assert( psEncCtrl->Lambda_Q10 > 0 );\r
     SKP_assert( psEncCtrl->Lambda_Q10 < SKP_FIX_CONST( 2, 10 ) );\r
-    \r
 }\r
diff --git a/libs/silk/src/SKP_Silk_pulses_to_bytes.c b/libs/silk/src/SKP_Silk_pulses_to_bytes.c
deleted file mode 100644 (file)
index 85c5e7e..0000000
+++ /dev/null
@@ -1,77 +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
-/*\r
- * File Name:   SKP_Silk_pulses_to_bytes.c\r
- */\r
-\r
-#include <stdlib.h>\r
-#include "SKP_Silk_main.h"\r
-\r
-/* nBytes = sum_over_shell_blocks( POLY_FIT_0 + POLY_FIT_1 * sum_abs_val + POLY_FIT_2 * sum_abs_val^2 ) */\r
-#define POLY_FIT_0_Q15     12520\r
-#define POLY_FIT_1_Q15     15862\r
-#define POLY_FIT_2_Q20     -9222 // ToDo better training with \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
-    SKP_int                         q[]             /* I    Pulse signal  */\r
-)\r
-{\r
-    SKP_int i, j, iter, *q_ptr;\r
-    SKP_int32 sum_abs_val, nBytes, acc_nBytes;\r
-    /* Take the absolute value of the pulses */\r
-    iter = psEncC->frame_length / SHELL_CODEC_FRAME_LENGTH;\r
-    \r
-    /* Calculate rate as a nonlinaer mapping of sum abs value of each Shell block */\r
-    q_ptr      = q;\r
-    acc_nBytes = 0;\r
-    for( j = 0; j < iter; j++ ) {\r
-        sum_abs_val = 0;\r
-        for(i = 0; i < SHELL_CODEC_FRAME_LENGTH; i+=4){\r
-            sum_abs_val += SKP_abs( q_ptr[ i + 0 ] );\r
-            sum_abs_val += SKP_abs( q_ptr[ i + 1 ] );\r
-            sum_abs_val += SKP_abs( q_ptr[ i + 2 ] );\r
-            sum_abs_val += SKP_abs( q_ptr[ i + 3 ] );\r
-        }\r
-        /* Calculate nBytes used for thi sshell frame */\r
-        nBytes = SKP_SMULWB( SKP_SMULBB( sum_abs_val, sum_abs_val ), POLY_FIT_2_Q20 );  // Q4\r
-        nBytes = SKP_LSHIFT_SAT32( nBytes, 11 );                                        // Q15\r
-        nBytes += SKP_SMULBB( sum_abs_val, POLY_FIT_1_Q15 );                            // Q15\r
-        nBytes += POLY_FIT_0_Q15;                                                       // Q15\r
-\r
-        acc_nBytes += nBytes;\r
-\r
-        q_ptr += SHELL_CODEC_FRAME_LENGTH; /* update pointer */\r
-    }\r
-\r
-    acc_nBytes = SKP_RSHIFT_ROUND( acc_nBytes, 15 );                                    // Q0\r
-    acc_nBytes = SKP_SAT16( acc_nBytes ); // just to be sure                            // Q0\r
-    \r
-    return(( SKP_int )acc_nBytes);\r
-}\r
index 63c5a0f1a97dd64c8c254a2933bf67f4276ef031..d0c4055d702f6d5de1b1d729a922393be739001c 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
index b42fa42ec0e9d290ecd8b9abac791a75fbb37012..b3aad5b3091ada1fdc6ae42475b30d6ad0aa59a8 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -292,7 +292,7 @@ SKP_int SKP_Silk_range_coder_get_length(                /* O    returns number o
 {\r
     SKP_int nBits;\r
 \r
-    /* Number of additional bits (1..9) required to be stored to stream */\r
+    /* Number of bits in stream */\r
     nBits = SKP_LSHIFT( psRC->bufferIx, 3 ) + SKP_Silk_CLZ32( psRC->range_Q16 - 1 ) - 14;\r
 \r
     *nBytes = SKP_RSHIFT( nBits + 7, 3 );\r
index fa2e8cd58235d2031749ffa564a086895b17f3cb..f30f631cf8f76b413ec217da9a11330e059ad437 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
diff --git a/libs/silk/src/SKP_Silk_resample_1_2.c b/libs/silk/src/SKP_Silk_resample_1_2.c
deleted file mode 100644 (file)
index 712e32d..0000000
+++ /dev/null
@@ -1,77 +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
-/*                                                                      *\r
- * SKP_Silk_resample_1_2                                              *\r
- *                                                                      *\r
- * Downsample by a factor 2                                             *\r
- *                                                                      *\r
- * Copyright 2006 (c), Skype Limited                                    *\r
- * Date: 060221                                                         *\r
- *                                                                      */\r
-#include "SKP_Silk_SigProc_FIX.h"\r
-\r
-/* Coefficients for 2-fold resampling */\r
-static SKP_int16 A20_Resample_1_2[ 3 ] = { 1254, 10102, 22898 };\r
-static SKP_int16 A21_Resample_1_2[ 3 ] = { 4810, 16371, 29374 };\r
-\r
-\r
-/* Downsample by a factor 2 */\r
-void SKP_Silk_resample_1_2(\r
-    const SKP_int16      *in,            /* I:   16 kHz signal [2*len]   */\r
-    SKP_int32            *S,             /* I/O: State vector [6]        */\r
-    SKP_int16            *out,           /* O:   8 kHz signal [len]      */\r
-    SKP_int32            *scratch,       /* I:   Scratch memory [4*len]  */\r
-    const SKP_int32      len             /* I:   Number of OUTPUT samples*/\r
-)\r
-{\r
-    SKP_int32    k, idx;\r
-\r
-    /* De-interleave allpass inputs, and convert Q15 -> Q25 */\r
-    for( k = 0; k < len; k++ ) {\r
-        idx = SKP_LSHIFT( k, 1 );\r
-        scratch[ k ]       = SKP_LSHIFT( (SKP_int32)in[ idx     ], 10 );\r
-        scratch[ k + len ] = SKP_LSHIFT( (SKP_int32)in[ idx + 1 ], 10 );\r
-    }\r
-\r
-    idx = SKP_LSHIFT( len, 1 );\r
-\r
-    /* Allpass filters */\r
-    SKP_Silk_allpass_int( scratch,             S,     A21_Resample_1_2[ 0 ], scratch + idx,       len );\r
-    SKP_Silk_allpass_int( scratch + idx,       S + 1, A21_Resample_1_2[ 1 ], scratch + idx + len, len );\r
-    SKP_Silk_allpass_int( scratch + idx + len, S + 2, A21_Resample_1_2[ 2 ], scratch,             len );\r
-\r
-    SKP_Silk_allpass_int( scratch + len,       S + 3, A20_Resample_1_2[ 0 ], scratch + idx,       len );\r
-    SKP_Silk_allpass_int( scratch + idx,       S + 4, A20_Resample_1_2[ 1 ], scratch + idx + len, len );\r
-    SKP_Silk_allpass_int( scratch + idx + len, S + 5, A20_Resample_1_2[ 2 ], scratch + len,       len );\r
-\r
-    /* Add two allpass outputs */\r
-    for( k = 0; k < len; k++ ) {\r
-        out[ k ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( scratch[ k ] + scratch[ k + len ], 11 ) );\r
-    }\r
-}\r
-\r
diff --git a/libs/silk/src/SKP_Silk_resample_1_2_coarse.c b/libs/silk/src/SKP_Silk_resample_1_2_coarse.c
deleted file mode 100644 (file)
index f90b059..0000000
+++ /dev/null
@@ -1,74 +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
-/*                                                                      *\r
- * SKP_Silk_resample_1_2_coarse.c                                     *\r
- *                                                                      *\r
- * Downsample by a factor 2, coarser                                    *\r
- *                                                                      *\r
- * Copyright 2006 (c), Skype Limited                                    *\r
- * Date: 060221                                                         *\r
- *                                                                      */\r
-#include "SKP_Silk_SigProc_FIX.h"\r
-\r
-/* downsample by a factor 2, coarser */\r
-void SKP_Silk_resample_1_2_coarse(\r
-    const SKP_int16      *in,            /* I:   16 kHz signal [2*len]   */\r
-    SKP_int32            *S,             /* I/O: State vector [4]        */\r
-    SKP_int16            *out,           /* O:   8 kHz signal [len]      */\r
-    SKP_int32            *scratch,       /* I:   Scratch memory [3*len]  */\r
-    const SKP_int32      len             /* I:   Number of OUTPUT samples*/\r
-)\r
-{\r
-    SKP_int32 k, idx;\r
-    \r
-    /* Coefficients for coarser 2-fold resampling */\r
-    const SKP_int16 A20c[ 2 ] = { 2119, 16663 };\r
-    const SKP_int16 A21c[ 2 ] = { 8050, 26861 };\r
-\r
-    /* De-interleave allpass inputs, and convert Q15 -> Q25 */\r
-    for( k = 0; k < len; k++ ) {\r
-        idx = SKP_LSHIFT( k, 1 );\r
-        scratch[ k ]       = SKP_LSHIFT( (SKP_int32)in[ idx     ], 10 );\r
-        scratch[ k + len ] = SKP_LSHIFT( (SKP_int32)in[ idx + 1 ], 10 );\r
-    }\r
-\r
-    idx = SKP_LSHIFT( len, 1 );\r
-    /* Allpass filters */\r
-    SKP_Silk_allpass_int( scratch,       S,     A21c[ 0 ], scratch + idx, len );\r
-    SKP_Silk_allpass_int( scratch + idx, S + 1, A21c[ 1 ], scratch,       len );\r
-\r
-    SKP_Silk_allpass_int( scratch + len, S + 2, A20c[ 0 ], scratch + idx, len );\r
-    SKP_Silk_allpass_int( scratch + idx, S + 3, A20c[ 1 ], scratch + len, len );\r
-\r
-    /* Add two allpass outputs */\r
-    for( k = 0; k < len; k++ ) {\r
-        out[ k ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( scratch[ k ] + scratch[ k + len ], 11 ) );\r
-    }\r
-}\r
-\r
-\r
diff --git a/libs/silk/src/SKP_Silk_resample_1_2_coarsest.c b/libs/silk/src/SKP_Silk_resample_1_2_coarsest.c
deleted file mode 100644 (file)
index 8e72965..0000000
+++ /dev/null
@@ -1,71 +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
-/*                                                                      *\r
- * SKP_Silk_resample_1_2_coarsest.c                                   *\r
- *                                                                      *\r
- * Downsample by a factor 2, coarsest                                   *\r
- *                                                                      *\r
- * Copyright 2006 (c), Skype Limited                                    *\r
- * Date: 060221                                                         *\r
- *                                                                      */\r
-#include "SKP_Silk_SigProc_FIX.h"\r
-\r
-\r
-/* Coefficients for coarsest 2-fold resampling */\r
-static SKP_int16 A20cst[ 1 ] = {  3786 };\r
-static SKP_int16 A21cst[ 1 ] = { 17908 };\r
-\r
-/* Downsample by a factor 2, coarsest */\r
-void SKP_Silk_resample_1_2_coarsest(\r
-    const SKP_int16     *in,                /* I:   16 kHz signal [2*len]   */\r
-    SKP_int32           *S,                 /* I/O: State vector [2]        */\r
-    SKP_int16           *out,               /* O:   8 kHz signal [len]      */\r
-    SKP_int32           *scratch,           /* I:   Scratch memory [3*len]  */\r
-    const SKP_int32     len                 /* I:   Number of OUTPUT samples*/\r
-)\r
-{\r
-    SKP_int32 k, idx;\r
-\r
-    /* De-interleave allpass inputs, and convert Q15 -> Q25 */\r
-    for( k = 0; k < len; k++ ) {\r
-        idx = SKP_LSHIFT( k, 1 );\r
-        scratch[ k ]       = SKP_LSHIFT( (SKP_int32)in[ idx     ], 10 );\r
-        scratch[ k + len ] = SKP_LSHIFT( (SKP_int32)in[ idx + 1 ], 10 );\r
-    }\r
-\r
-    idx = SKP_LSHIFT( len, 1 );\r
-    /* Allpass filters */\r
-    SKP_Silk_allpass_int( scratch,       S,     A21cst[ 0 ], scratch + idx, len );\r
-    SKP_Silk_allpass_int( scratch + len, S + 1, A20cst[ 0 ], scratch,       len );\r
-\r
-    /* Add two allpass outputs */\r
-    for( k = 0; k < len; k++ ) {\r
-        out[ k ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( scratch[ k ] + scratch[ k + idx ], 11 ) );\r
-    }\r
-}\r
-\r
diff --git a/libs/silk/src/SKP_Silk_resample_1_3.c b/libs/silk/src/SKP_Silk_resample_1_3.c
deleted file mode 100644 (file)
index 0f77412..0000000
+++ /dev/null
@@ -1,101 +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
-/*                                                                      *\r
- * SKP_Silk_resample_1_3.c                                            *\r
- *                                                                      *\r
- * Downsamples by a factor 3                                            *\r
- *                                                                      *\r
- * Copyright 2008 (c), Skype Limited                                    *\r
- * Date: 081113                                                         *\r
- *                                                                      */\r
-#include "SKP_Silk_SigProc_FIX.h"\r
-\r
-#define OUT_SUBFR_LEN        80\r
-\r
-/* Downsamples by a factor 3 */\r
-void SKP_Silk_resample_1_3(\r
-    SKP_int16            *out,       /* O:   Fs_low signal  [inLen/3]                */\r
-    SKP_int32            *S,         /* I/O: State vector   [7]                      */\r
-    const SKP_int16      *in,        /* I:   Fs_high signal [inLen]                  */\r
-    const SKP_int32      inLen       /* I:   Input length, must be a multiple of 3   */\r
-)\r
-{\r
-    SKP_int      k, outLen, LSubFrameIn, LSubFrameOut;\r
-    SKP_int32    out_tmp, limit = 102258000; // (102258000 + 1560) * 21 * 2^(-16) = 32767.5\r
-    SKP_int32    scratch0[ 3 * OUT_SUBFR_LEN ];\r
-    SKP_int32    scratch10[ OUT_SUBFR_LEN ], scratch11[ OUT_SUBFR_LEN ], scratch12[ OUT_SUBFR_LEN ];\r
-    /* coefficients for 3-fold resampling */\r
-    const SKP_int16 A30[ 2 ] = {  1773, 17818 };\r
-    const SKP_int16 A31[ 2 ] = {  4942, 25677 };\r
-    const SKP_int16 A32[ 2 ] = { 11786, 29304 };\r
-\r
-    /* Check that input is multiple of 3 */\r
-    SKP_assert( inLen % 3 == 0 );\r
-\r
-    outLen = SKP_DIV32_16( inLen, 3 );\r
-    while( outLen > 0 ) {\r
-        LSubFrameOut = SKP_min_int( OUT_SUBFR_LEN, outLen );\r
-        LSubFrameIn  = SKP_SMULBB( 3, LSubFrameOut );\r
-\r
-        /* Low-pass filter, Q15 -> Q25 */\r
-        SKP_Silk_lowpass_short( in, S, scratch0, LSubFrameIn );\r
-\r
-        /* De-interleave three allpass inputs */\r
-        for( k = 0; k < LSubFrameOut; k++ ) {\r
-            scratch10[ k ] = scratch0[ 3 * k     ];\r
-            scratch11[ k ] = scratch0[ 3 * k + 1 ];\r
-            scratch12[ k ] = scratch0[ 3 * k + 2 ];\r
-        }\r
-\r
-        /* Allpass filters */\r
-        SKP_Silk_allpass_int( scratch10, S + 1, A32[ 0 ], scratch0,  LSubFrameOut );\r
-        SKP_Silk_allpass_int( scratch0,  S + 2, A32[ 1 ], scratch10, LSubFrameOut );\r
-\r
-        SKP_Silk_allpass_int( scratch11, S + 3, A31[ 0 ], scratch0,  LSubFrameOut );\r
-        SKP_Silk_allpass_int( scratch0,  S + 4, A31[ 1 ], scratch11, LSubFrameOut );\r
-\r
-        SKP_Silk_allpass_int( scratch12, S + 5, A30[ 0 ], scratch0,  LSubFrameOut );\r
-        SKP_Silk_allpass_int( scratch0,  S + 6, A30[ 1 ], scratch12, LSubFrameOut );\r
-\r
-        /* Add three allpass outputs */\r
-        for( k = 0; k < LSubFrameOut; k++ ) {\r
-            out_tmp = scratch10[ k ] + scratch11[ k ] + scratch12[ k ];\r
-            if( out_tmp - limit > 0 ) {\r
-                out[ k ] = SKP_int16_MAX;\r
-            } else if( out_tmp + limit < 0 ) {\r
-                out[ k ] = SKP_int16_MIN;\r
-            } else {\r
-                out[ k ] = (SKP_int16) SKP_SMULWB( out_tmp + 1560, 21 );\r
-            }\r
-        }\r
-\r
-        in     += LSubFrameIn;\r
-        out    += LSubFrameOut;\r
-        outLen -= LSubFrameOut;\r
-    }\r
-}\r
diff --git a/libs/silk/src/SKP_Silk_resample_2_1_coarse.c b/libs/silk/src/SKP_Silk_resample_2_1_coarse.c
deleted file mode 100644 (file)
index f01fbe9..0000000
+++ /dev/null
@@ -1,73 +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
-/*                                                                      *\r
- * SKP_Silk_resample_2_1_coarse.c                                     *\r
- *                                                                      *\r
- * Upsample by a factor 2, coarser                                      *\r
- *                                                                      *\r
- * Copyright 2006 (c), Skype Limited                                    *\r
- * Date: 060221                                                         *\r
- *                                                                      */\r
-#include "SKP_Silk_SigProc_FIX.h"\r
-\r
-/* Upsample by a factor 2, coarser */\r
-void SKP_Silk_resample_2_1_coarse(\r
-    const SKP_int16      *in,            /* I:   8 kHz signal [len]      */\r
-    SKP_int32            *S,             /* I/O: State vector [4]        */\r
-    SKP_int16            *out,           /* O:   16 kHz signal [2*len]   */\r
-    SKP_int32            *scratch,       /* I:   Scratch memory [3*len]  */\r
-    const SKP_int32      len             /* I:   Number of INPUT samples */\r
-)\r
-{\r
-    SKP_int32 k, idx;\r
-    \r
-    /* Coefficients for coarser 2-fold resampling */\r
-    const SKP_int16 A20c[ 2 ] = { 2119, 16663 };\r
-    const SKP_int16 A21c[ 2 ] = { 8050, 26861 };\r
-\r
-    /* Convert Q15 -> Q25 */\r
-    for( k = 0; k < len; k++ ) {\r
-        scratch[ k ] = SKP_LSHIFT( (SKP_int32)in[ k ], 10 );\r
-    }\r
-       \r
-    idx = SKP_LSHIFT( len, 1 );\r
-    \r
-    /* Allpass filters */\r
-    SKP_Silk_allpass_int( scratch,       S,     A20c[ 0 ], scratch + idx, len );\r
-    SKP_Silk_allpass_int( scratch + idx, S + 1, A20c[ 1 ], scratch + len, len );\r
-\r
-    SKP_Silk_allpass_int( scratch,       S + 2, A21c[ 0 ], scratch + idx, len );\r
-    SKP_Silk_allpass_int( scratch + idx, S + 3, A21c[ 1 ], scratch,       len );\r
-\r
-    /* Interleave two allpass outputs */\r
-    for( k = 0; k < len; k++ ) {\r
-        idx = SKP_LSHIFT( k, 1 );\r
-        out[ idx     ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( scratch[ k + len ], 10 ) );\r
-        out[ idx + 1 ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( scratch[ k ],       10 ) );\r
-    }\r
-}\r
diff --git a/libs/silk/src/SKP_Silk_resample_2_3.c b/libs/silk/src/SKP_Silk_resample_2_3.c
deleted file mode 100644 (file)
index dbb16fe..0000000
+++ /dev/null
@@ -1,74 +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
-/*                                                                      *\r
- * File Name:    SKP_Silk_resample_2_3.c                              *\r
- *                                                                      *\r
- * Resamples by a factor 2/3                                            *\r
- *                                                                      *\r
- * Copyright 2008 (c), Skype Limited                                    *\r
- * All rights reserved.                                                 *\r
- *                                                                      *\r
- * Date: 081113                                                         *\r
- *                                                                      */\r
-\r
-#include "SKP_Silk_SigProc_FIX.h"\r
-\r
-#define OUT_SUBFR_LEN        80\r
-\r
-/* Resamples by a factor 2/3 */\r
-void SKP_Silk_resample_2_3(\r
-    SKP_int16            *out,       /* O:   Fs_low signal    [inLen * 2/3]           */\r
-    SKP_int32            *S,         /* I/O: State vector     [7+4]                   */\r
-    const SKP_int16      *in,        /* I:   Fs_high signal   [inLen]                 */\r
-    const SKP_int        inLen       /* I:   Input length, must be a multiple of 3    */\r
-)\r
-{\r
-    SKP_int      outLen, LSubFrameIn, LSubFrameOut;\r
-    SKP_int16    outH[      3 * OUT_SUBFR_LEN ];\r
-    SKP_int32    scratch[ ( 9 * OUT_SUBFR_LEN ) / 2 ];\r
-\r
-    /* Check that input length is multiple of 3 */\r
-    SKP_assert( inLen % 3 == 0 );\r
-\r
-    outLen = SKP_DIV32_16( SKP_LSHIFT( inLen, 1 ), 3 );\r
-    while( outLen > 0 ) {\r
-        LSubFrameOut = SKP_min_int( OUT_SUBFR_LEN, outLen );\r
-        LSubFrameIn  = SKP_SMULWB( 98304, LSubFrameOut ); /* 98304_Q16 = 3/2_Q0 */\r
-            \r
-        /* Upsample by a factor 2 */\r
-        /* Scratch size needs to be: 3 * LSubFrameIn * sizeof( SKP_int32 ) */\r
-        SKP_Silk_resample_2_1_coarse( in, &S[ 0 ], outH, scratch, LSubFrameIn );\r
-\r
-        /* Downsample by a factor 3 */\r
-        SKP_Silk_resample_1_3( out, &S[ 4 ], outH, SKP_LSHIFT( LSubFrameIn, 1 ) );\r
-\r
-        in     += LSubFrameIn;\r
-        out    += LSubFrameOut;\r
-        outLen -= LSubFrameOut;\r
-    }\r
-}\r
diff --git a/libs/silk/src/SKP_Silk_resample_2_3_coarse.c b/libs/silk/src/SKP_Silk_resample_2_3_coarse.c
deleted file mode 100644 (file)
index 76c597b..0000000
+++ /dev/null
@@ -1,112 +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
-/*                                                                      *\r
- * File Name:   SKP_Silk_resample_2_3_coarse.c                        *\r
- *                                                                      *\r
- * Description: Linear phase FIR polyphase implementation of resampling *\r
- *                                                                      *\r
- * Copyright 2009 (c), Skype Limited                                    *\r
- * All rights reserved.                                                 *\r
- *                                                                      *\r
- * Date: 090423                                                         *\r
- *                                                                      */\r
-\r
-#include "SKP_Silk_SigProc_FIX.h"\r
-#include "SKP_Silk_resample_rom.h"\r
-\r
-/* Resamples input data with a factor 2/3 */\r
-void SKP_Silk_resample_2_3_coarse( \r
-    SKP_int16           *out,           /* O:   Output signal                                                                   */\r
-    SKP_int16           *S,             /* I/O: Resampler state [ SigProc_Resample_2_3_coarse_NUM_FIR_COEFS - 1 ]               */\r
-    const SKP_int16     *in,            /* I:   Input signal                                                                    */\r
-    const SKP_int       frameLenIn,     /* I:   Number of input samples                                                         */\r
-    SKP_int16           *scratch        /* I:   Scratch memory [ frameLenIn + SigProc_Resample_2_3_coarse_NUM_FIR_COEFS - 1 ]   */\r
-)\r
-{\r
-    SKP_int32 n, ind, interpol_ind, tmp, index_Q16;\r
-    SKP_int16 *in_ptr;\r
-    SKP_int   frameLenOut;\r
-    const SKP_int16 *interpol_ptr;\r
-\r
-    /* Copy buffered samples to start of scratch */\r
-    SKP_memcpy( scratch, S, ( SigProc_Resample_2_3_coarse_NUM_FIR_COEFS - 1 ) * sizeof( SKP_int16 ) );\r
-    \r
-    /* Then append by the input signal */\r
-    SKP_memcpy( &scratch[ SigProc_Resample_2_3_coarse_NUM_FIR_COEFS - 1 ], in, frameLenIn * sizeof( SKP_int16 ) ); \r
-\r
-    frameLenOut = SKP_DIV32_16( SKP_MUL( 2, frameLenIn ), 3 );\r
-    index_Q16 = 0;\r
-\r
-    SKP_assert( frameLenIn == ( ( frameLenOut * 3 ) / 2 ) );\r
-    \r
-    /* Interpolate */\r
-    for( n = frameLenOut; n > 0; n-- ) {\r
-\r
-        /* Integer part */\r
-        ind = SKP_RSHIFT( index_Q16, 16 );\r
-\r
-        /* Pointer to buffered input */\r
-        in_ptr = scratch + ind;\r
-\r
-        /* Fractional part */\r
-        interpol_ind = ( SKP_SMULWB( index_Q16, SigProc_Resample_2_3_coarse_NUM_INTERPOLATORS ) & \r
-                       ( SigProc_Resample_2_3_coarse_NUM_INTERPOLATORS - 1 ) );\r
-\r
-        /* Pointer to FIR taps */\r
-        interpol_ptr = SigProc_Resample_2_3_coarse_INTERPOL[ interpol_ind ];\r
-\r
-        /* Interpolate */\r
-        /* Hardcoded for 32 FIR taps */\r
-        SKP_assert( SigProc_Resample_2_3_coarse_NUM_FIR_COEFS == 32 );\r
-        tmp = (SKP_int32)interpol_ptr[  0 ] * in_ptr[  0 ] + (SKP_int32)interpol_ptr[  1 ] * in_ptr[  1 ] +\r
-              (SKP_int32)interpol_ptr[  2 ] * in_ptr[  2 ] + (SKP_int32)interpol_ptr[  3 ] * in_ptr[  3 ] +\r
-              (SKP_int32)interpol_ptr[  4 ] * in_ptr[  4 ] + (SKP_int32)interpol_ptr[  5 ] * in_ptr[  5 ] +\r
-              (SKP_int32)interpol_ptr[  6 ] * in_ptr[  6 ] + (SKP_int32)interpol_ptr[  7 ] * in_ptr[  7 ] +\r
-              (SKP_int32)interpol_ptr[  8 ] * in_ptr[  8 ] + (SKP_int32)interpol_ptr[  9 ] * in_ptr[  9 ] +\r
-              (SKP_int32)interpol_ptr[ 10 ] * in_ptr[ 10 ] + (SKP_int32)interpol_ptr[ 11 ] * in_ptr[ 11 ] +\r
-              (SKP_int32)interpol_ptr[ 12 ] * in_ptr[ 12 ] + (SKP_int32)interpol_ptr[ 13 ] * in_ptr[ 13 ] +\r
-              (SKP_int32)interpol_ptr[ 14 ] * in_ptr[ 14 ] + (SKP_int32)interpol_ptr[ 15 ] * in_ptr[ 15 ] +\r
-              (SKP_int32)interpol_ptr[ 16 ] * in_ptr[ 16 ] + (SKP_int32)interpol_ptr[ 17 ] * in_ptr[ 17 ] +\r
-              (SKP_int32)interpol_ptr[ 18 ] * in_ptr[ 18 ] + (SKP_int32)interpol_ptr[ 19 ] * in_ptr[ 19 ] +\r
-              (SKP_int32)interpol_ptr[ 20 ] * in_ptr[ 20 ] + (SKP_int32)interpol_ptr[ 21 ] * in_ptr[ 21 ] +\r
-              (SKP_int32)interpol_ptr[ 22 ] * in_ptr[ 22 ] + (SKP_int32)interpol_ptr[ 23 ] * in_ptr[ 23 ] +\r
-              (SKP_int32)interpol_ptr[ 24 ] * in_ptr[ 24 ] + (SKP_int32)interpol_ptr[ 25 ] * in_ptr[ 25 ] +\r
-              (SKP_int32)interpol_ptr[ 26 ] * in_ptr[ 26 ] + (SKP_int32)interpol_ptr[ 27 ] * in_ptr[ 27 ] +\r
-              (SKP_int32)interpol_ptr[ 28 ] * in_ptr[ 28 ] + (SKP_int32)interpol_ptr[ 29 ] * in_ptr[ 29 ];\r
-\r
-        /* Round, saturate and store to output array */\r
-        *out++ = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( tmp, 15 ) );\r
-\r
-        /* Update index */\r
-        index_Q16 += ( ( 1 << 16 ) + ( 1 << 15 ) ); // (3/2)_Q0;\r
-    }\r
-\r
-    /* Move last part of input signal to the sample buffer to prepare for the next call */\r
-    SKP_memcpy( S, &in[ frameLenIn - ( SigProc_Resample_2_3_coarse_NUM_FIR_COEFS - 1 ) ],\r
-                ( SigProc_Resample_2_3_coarse_NUM_FIR_COEFS - 1 ) * sizeof( SKP_int16 ) );\r
-}\r
diff --git a/libs/silk/src/SKP_Silk_resample_2_3_coarsest.c b/libs/silk/src/SKP_Silk_resample_2_3_coarsest.c
deleted file mode 100644 (file)
index 6a57eaa..0000000
+++ /dev/null
@@ -1,131 +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
-/*                                                                      *\r
- * File Name:   SKP_Silk_resample_2_3_coarsest.c                      *\r
- *                                                                      *\r
- * Description: Linear phase FIR polyphase implementation of resampling *\r
- *                                                                      *\r
- * Copyright 2009 (c), Skype Limited                                    *\r
- * All rights reserved.                                                 *\r
- *                                                                      *\r
- * Date: 090423                                                         *\r
- *                                                                      */\r
-\r
-#include "SKP_Silk_SigProc_FIX.h"\r
-#include "SKP_Silk_resample_rom.h"\r
-\r
-/* Resamples input data with a factor 2/3 */\r
-void SKP_Silk_resample_2_3_coarsest( \r
-    SKP_int16           *out,           /* O:   Output signal                                                                   */\r
-    SKP_int16           *S,             /* I/O: Resampler state [ SigProc_Resample_2_3_coarsest_NUM_FIR_COEFS - 1 ]             */\r
-    const SKP_int16     *in,            /* I:   Input signal                                                                    */\r
-    const SKP_int       frameLenIn,     /* I:   Number of input samples                                                         */\r
-    SKP_int16           *scratch        /* I:   Scratch memory [ frameLenIn + SigProc_Resample_2_3_coarsest_NUM_FIR_COEFS - 1 ] */\r
-)\r
-{\r
-    SKP_int32 n, ind, interpol_ind, tmp, index_Q16;\r
-    SKP_int16 *in_ptr;\r
-    SKP_int   frameLenOut;\r
-    const SKP_int16 *interpol_ptr;\r
-#if ( EMBEDDED_ARM>=6 ) && defined (__GNUC__)\r
-    SKP_int32   in_val, interpol_val;\r
-#endif\r
-\r
-    /* Copy buffered samples to start of scratch */\r
-    SKP_memcpy( scratch, S, ( SigProc_Resample_2_3_coarsest_NUM_FIR_COEFS - 1 ) * sizeof( SKP_int16 ) );    \r
-    \r
-    /* Then append by the input signal */\r
-    SKP_memcpy( &scratch[ SigProc_Resample_2_3_coarsest_NUM_FIR_COEFS - 1 ], in, frameLenIn * sizeof( SKP_int16 ) ); \r
-\r
-    frameLenOut = SKP_SMULWB( SKP_LSHIFT( (SKP_int32)frameLenIn, 1 ), 21846 ); // 21846_Q15 = (2/3)_Q0 rounded _up_\r
-    index_Q16 = 0;\r
-\r
-    SKP_assert( frameLenIn == ( ( frameLenOut * 3 ) / 2 ) );\r
-    \r
-    /* Interpolate */\r
-    for( n = frameLenOut; n > 0; n-- ) {\r
-\r
-        /* Integer part */\r
-        ind = SKP_RSHIFT( index_Q16, 16 );\r
-\r
-        /* Pointer to buffered input */\r
-        in_ptr = scratch + ind;\r
-\r
-        /* Fractional part */\r
-        interpol_ind = ( SKP_SMULWB( index_Q16, SigProc_Resample_2_3_coarsest_NUM_INTERPOLATORS ) & \r
-                       ( SigProc_Resample_2_3_coarsest_NUM_INTERPOLATORS - 1 ) );\r
-\r
-        /* Pointer to FIR taps */\r
-        interpol_ptr = SigProc_Resample_2_3_coarsest_INTERPOL[ interpol_ind ];\r
-\r
-        /* Interpolate: Hardcoded for 10 FIR taps */\r
-#if ( EMBEDDED_ARM>=6 ) && defined (__GNUC__)       /*It doesn't improve efficiency on iphone.*/\r
-        /*tmp = SKP_SMUAD(    *((SKP_int32 *)interpol_ptr)++, *((SKP_int32 *)in_ptr)++);\r
-        tmp = SKP_SMLAD( tmp, *((SKP_int32 *)interpol_ptr)++, *((SKP_int32 *)in_ptr)++);\r
-        tmp = SKP_SMLAD( tmp, *((SKP_int32 *)interpol_ptr),   *((SKP_int32 *)in_ptr)  );*/\r
-        __asm__ __volatile__ (  "ldr    %1, [%3], #4 \n\t"\r
-                                "ldr    %2, [%4], #4 \n\t"\r
-                                "smuad  %0, %1, %2 \n\t"\r
-                                "ldr    %1, [%3], #4 \n\t"\r
-                                "ldr    %2, [%4], #4 \n\t"\r
-                                "smlad  %0, %1, %2, %0\n\t"\r
-                                "ldr    %1, [%3], #4 \n\t"\r
-                                "ldr    %2, [%4], #4 \n\t"\r
-                                "smlad  %0, %1, %2, %0\n\t"\r
-                                "ldr    %1, [%3], #4 \n\t"\r
-                                "ldr    %2, [%4], #4 \n\t"\r
-                                "smlad  %0, %1, %2, %0\n\t"\r
-                                "ldr    %1, [%3] \n\t"\r
-                                "ldr    %2, [%4] \n\t"\r
-                                "smlad  %0, %1, %2, %0\n\t"\r
-                                : "=r" (tmp), "=r" (interpol_val), "=r" (in_val), "=r" (interpol_ptr), "=r" (in_ptr) \r
-                                : "3" (interpol_ptr), "4" (in_ptr));    \r
-#else\r
-        SKP_assert( SigProc_Resample_2_3_coarsest_NUM_FIR_COEFS == 10 );\r
-        tmp = SKP_SMULBB(      interpol_ptr[ 0 ], in_ptr[ 0 ] );\r
-        tmp = SKP_SMLABB( tmp, interpol_ptr[ 1 ], in_ptr[ 1 ] ); \r
-        tmp = SKP_SMLABB( tmp, interpol_ptr[ 2 ], in_ptr[ 2 ] );    \r
-        tmp = SKP_SMLABB( tmp, interpol_ptr[ 3 ], in_ptr[ 3 ] );    \r
-        tmp = SKP_SMLABB( tmp, interpol_ptr[ 4 ], in_ptr[ 4 ] );    \r
-        tmp = SKP_SMLABB( tmp, interpol_ptr[ 5 ], in_ptr[ 5 ] );    \r
-        tmp = SKP_SMLABB( tmp, interpol_ptr[ 6 ], in_ptr[ 6 ] );    \r
-        tmp = SKP_SMLABB( tmp, interpol_ptr[ 7 ], in_ptr[ 7 ] );    \r
-        tmp = SKP_SMLABB( tmp, interpol_ptr[ 8 ], in_ptr[ 8 ] );    \r
-        tmp = SKP_SMLABB( tmp, interpol_ptr[ 9 ], in_ptr[ 9 ] );\r
-#endif\r
-        /* Round, saturate and store to output array */\r
-        *out++ = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( tmp, 15 ) );\r
-\r
-        /* Update index */\r
-        index_Q16 += ( ( 1 << 16 ) + ( 1 << 15 ) ); // (3/2)_Q0;\r
-    }\r
-\r
-    /* Move last part of input signal to the sample buffer to prepare for the next call */\r
-    SKP_memcpy( S, &in[ frameLenIn - ( SigProc_Resample_2_3_coarsest_NUM_FIR_COEFS - 1 ) ],\r
-                ( SigProc_Resample_2_3_coarsest_NUM_FIR_COEFS - 1 ) * sizeof( SKP_int16 ) );\r
-}\r
diff --git a/libs/silk/src/SKP_Silk_resample_2_3_rom.c b/libs/silk/src/SKP_Silk_resample_2_3_rom.c
deleted file mode 100644 (file)
index 2c396a9..0000000
+++ /dev/null
@@ -1,50 +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
-/*                                                                      *\r
- * File Name:    SKP_Silk_resample_2_3_rom.c                          *\r
- *                                                                      *\r
- * Description: Filter coefficients for FIR polyphase resampling        *\r
- *                                                                      *\r
- * Copyright 2009 (c), Skype Limited                                    *\r
- * All rights reserved.                                                 *\r
- *                                                                      *\r
- * Date: 090424                                                         *\r
- *                                                                      */\r
-\r
-#include "SKP_Silk_resample_rom.h"\r
-\r
-const SKP_int16 SigProc_Resample_2_3_coarse_INTERPOL[ SigProc_Resample_2_3_coarse_NUM_INTERPOLATORS ][ SigProc_Resample_2_3_coarse_NUM_FIR_COEFS ] = {\r
-    {    0,   -74,   109,     0,  -234,   329,     0,  -610,   813,     0, -1437,  1954,     0, -4358,  8953, 21845,  8953, -4358,     0,  1954, -1437,     0,   813,  -610,     0,   329,  -234,     0,   109,   -74,     0,    45 },\r
-    {   48,   -62,     0,   133,  -195,     0,   386,  -526,     0,   936, -1243,     0,  2311, -3417,     0, 18026, 18026,     0, -3417,  2311,     0, -1243,   936,     0,  -526,   386,     0,  -195,   133,     0,   -62,    48 },\r
-};\r
-\r
-const SKP_int16 SigProc_Resample_2_3_coarsest_INTERPOL[ SigProc_Resample_2_3_coarsest_NUM_INTERPOLATORS ][ SigProc_Resample_2_3_coarsest_NUM_FIR_COEFS ] = {\r
-    {  379,     0, -3081,  8239, 21845,  8239, -3081,     0,   379,  -145 },\r
-    {    0,   696, -1951,     0, 17659, 17659,     0, -1951,   696,     0 },\r
-};\r
-\r
diff --git a/libs/silk/src/SKP_Silk_resample_3_1.c b/libs/silk/src/SKP_Silk_resample_3_1.c
deleted file mode 100644 (file)
index 5272bb8..0000000
+++ /dev/null
@@ -1,100 +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
-/*                                                                      *\r
- * SKP_Silk_resample_3_1.c                                            *\r
- *                                                                      *\r
- * Upsamples by a factor 3                                              *\r
- *                                                                      *\r
- * Copyright 2008 (c), Skype Limited                                    *\r
- * Date: 081113                                                         *\r
- *                                                                      */\r
-#include "SKP_Silk_SigProc_FIX.h"\r
-\r
-#define IN_SUBFR_LEN_RESAMPLE_3_1       40\r
-\r
-/* Resamples by a factor 3/1 */\r
-void SKP_Silk_resample_3_1(\r
-    SKP_int16           *out,       /* O:   Fs_high signal [inLen*3]        */\r
-    SKP_int32           *S,         /* I/O: State vector   [7]              */\r
-    const SKP_int16     *in,        /* I:   Fs_low signal  [inLen]          */\r
-    const SKP_int32     inLen       /* I:   Input length                    */\r
-)\r
-{\r
-    SKP_int     k, LSubFrameIn, LSubFrameOut;\r
-    SKP_int32   out_tmp, idx, inLenTmp = inLen;\r
-    SKP_int32   scratch00[    IN_SUBFR_LEN_RESAMPLE_3_1 ];\r
-    SKP_int32   scratch0[ 3 * IN_SUBFR_LEN_RESAMPLE_3_1 ];\r
-    SKP_int32   scratch1[ 3 * IN_SUBFR_LEN_RESAMPLE_3_1 ];\r
-    \r
-    /* Coefficients for 3-fold resampling */\r
-    const SKP_int16 A30[ 2 ] = {  1773, 17818 };\r
-    const SKP_int16 A31[ 2 ] = {  4942, 25677 };\r
-    const SKP_int16 A32[ 2 ] = { 11786, 29304 };\r
-\r
-    while( inLenTmp > 0 ) {\r
-        LSubFrameIn  = SKP_min_int( IN_SUBFR_LEN_RESAMPLE_3_1, inLenTmp );\r
-        LSubFrameOut = SKP_SMULBB( 3, LSubFrameIn );\r
-\r
-        /* Convert Q15 -> Q25 */\r
-        for( k = 0; k < LSubFrameIn; k++ ) {\r
-            scratch00[k] = SKP_LSHIFT( (SKP_int32)in[ k ], 10 );\r
-        }\r
-\r
-        /* Allpass filtering */\r
-        /* Scratch size: 2 * 3* LSubFrame * sizeof(SKP_int32) */\r
-        SKP_Silk_allpass_int( scratch00, S + 1, A30[ 0 ], scratch1, LSubFrameIn );\r
-        SKP_Silk_allpass_int( scratch1,  S + 2, A30[ 1 ], scratch0, LSubFrameIn );\r
-\r
-        SKP_Silk_allpass_int( scratch00, S + 3, A31[ 0 ], scratch1, LSubFrameIn );\r
-        SKP_Silk_allpass_int( scratch1,  S + 4, A31[ 1 ], scratch0 +     IN_SUBFR_LEN_RESAMPLE_3_1, LSubFrameIn );\r
-\r
-        SKP_Silk_allpass_int( scratch00, S + 5, A32[ 0 ], scratch1, LSubFrameIn );\r
-        SKP_Silk_allpass_int( scratch1,  S + 6, A32[ 1 ], scratch0 + 2 * IN_SUBFR_LEN_RESAMPLE_3_1, LSubFrameIn );\r
-\r
-        /* Interleave three allpass outputs */\r
-        for( k = 0; k < LSubFrameIn; k++ ) {\r
-            idx = SKP_SMULBB( 3, k );\r
-            scratch1[ idx     ] = scratch0[ k ];\r
-            scratch1[ idx + 1 ] = scratch0[ k +     IN_SUBFR_LEN_RESAMPLE_3_1 ];\r
-            scratch1[ idx + 2 ] = scratch0[ k + 2 * IN_SUBFR_LEN_RESAMPLE_3_1 ];\r
-        }\r
-\r
-        /* Low-pass filtering */\r
-        SKP_Silk_lowpass_int( scratch1, S, scratch0, LSubFrameOut );\r
-\r
-        /* Saturate and convert to SKP_int16 */\r
-        for( k = 0; k < LSubFrameOut; k++ ) {\r
-            out_tmp  = scratch0[ k ];\r
-            out[ k ] = (SKP_int16) SKP_SAT16( SKP_RSHIFT_ROUND( out_tmp, 10 ) );\r
-        }\r
-\r
-        in       += LSubFrameIn;\r
-        inLenTmp -= LSubFrameIn;\r
-        out      += LSubFrameOut;\r
-    }\r
-}\r
diff --git a/libs/silk/src/SKP_Silk_resample_3_2.c b/libs/silk/src/SKP_Silk_resample_3_2.c
deleted file mode 100644 (file)
index 53fe509..0000000
+++ /dev/null
@@ -1,73 +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
-/*                                                                      *\r
- * File Name:   SKP_Silk_resample_3_2.c                               *\r
- *                                                                      *\r
- * Resamples by a factor 3/2                                            *\r
- *                                                                      *\r
- * Copyright 2008 (c), Skype Limited                                    *\r
- * All rights reserved.                                                 *\r
- *                                                                      *\r
- * Date: 081113                                                         *\r
- *                                                                      */\r
-\r
-#include "SKP_Silk_SigProc_FIX.h"\r
-\r
-#define IN_SUBFR_LEN_RESAMPLE_3_2       80\r
-\r
-/* Resamples by a factor 3/2 */\r
-void SKP_Silk_resample_3_2(\r
-    SKP_int16           *out,       /*   O: Fs_high signal  [inLen*3/2]             */\r
-    SKP_int32           *S,         /* I/O: State vector    [7+4]                   */\r
-    const SKP_int16     *in,        /* I:   Fs_low signal   [inLen]                 */\r
-    SKP_int             inLen       /* I:   Input length, must be a multiple of 2   */\r
-)\r
-{\r
-    SKP_int     LSubFrameIn, LSubFrameOut;\r
-    SKP_int16   outH[      3 * IN_SUBFR_LEN_RESAMPLE_3_2 ];\r
-    SKP_int32   scratch[ ( 9 * IN_SUBFR_LEN_RESAMPLE_3_2 ) / 2 ];\r
-\r
-    /* Check that input is multiple of 2 */\r
-    SKP_assert( inLen % 2 == 0 );\r
-\r
-    while( inLen > 0 ) {\r
-        LSubFrameIn  = SKP_min_int( IN_SUBFR_LEN_RESAMPLE_3_2, inLen );\r
-        LSubFrameOut = SKP_SMULWB( 98304, LSubFrameIn );\r
-\r
-        /* Upsample by a factor 3 */\r
-        SKP_Silk_resample_3_1( outH, &S[ 0 ], in, LSubFrameIn );\r
-        \r
-        /* Downsample by a factor 2 */\r
-        /* Scratch size needs to be: 3 * LSubFrameOut * sizeof( SKP_int32 ) */\r
-        SKP_Silk_resample_1_2_coarse( outH, &S[ 7 ], out, scratch, LSubFrameOut );\r
-\r
-        in    += LSubFrameIn;\r
-        out   += LSubFrameOut;\r
-        inLen -= LSubFrameIn;\r
-    }\r
-}\r
diff --git a/libs/silk/src/SKP_Silk_resample_3_2_rom.c b/libs/silk/src/SKP_Silk_resample_3_2_rom.c
deleted file mode 100644 (file)
index 3710604..0000000
+++ /dev/null
@@ -1,46 +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
-/*                                                                      *\r
- * File Name:   SKP_Silk_resample_3_2_rom.c                           *\r
- *                                                                      *\r
- * Description: Filter coefficients for FIR polyphase resampling        *\r
- *                                                                      *\r
- * Copyright 2009 (c), Skype Limited                                    *\r
- * All rights reserved.                                                 *\r
- *                                                                      *\r
- * Date: 090424                                                         *\r
- *                                                                      */\r
-\r
-#include "SKP_Silk_resample_rom.h"\r
-\r
-const SKP_int16 SigProc_Resample_3_2_coarse_INTERPOL[ SigProc_Resample_3_2_coarse_NUM_INTERPOLATORS ][ SigProc_Resample_3_2_coarse_NUM_FIR_COEFS ] = {\r
-    {    0,     0,     0, 32768,     0,     0,     0,     0 },\r
-    { -384,  1630, -5217, 26674, 12714, -3572,  1050,  -236 },\r
-    { -236,  1050, -3572, 12714, 26674, -5217,  1630,  -384 },\r
-};\r
-\r
diff --git a/libs/silk/src/SKP_Silk_resample_3_4.c b/libs/silk/src/SKP_Silk_resample_3_4.c
deleted file mode 100644 (file)
index 4b83a7a..0000000
+++ /dev/null
@@ -1,79 +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
-/*                                                                      *\r
- * File Name:    SKP_Silk_resample_3_4.c                              *\r
- *                                                                      *\r
- * Resamples by a factor 3/4                                            *\r
- *                                                                      *\r
- * Copyright 2009 (c), Skype Limited                                    *\r
- * All rights reserved.                                                 *\r
- *                                                                      *\r
- * Date: 090408                                                         *\r
- *                                                                      */\r
-\r
-#include "SKP_Silk_SigProc_FIX.h"\r
-\r
-#define IN_SUBFR_LEN_RESAMPLE_3_4        80\r
-\r
-/* Resamples by a factor 3/4 */\r
-void SKP_Silk_resample_3_4(\r
-    SKP_int16            *out,       /* O:   Fs_high signal  [inLen*3/4]              */\r
-    SKP_int32            *S,         /* I/O: State vector    [7+2+6]                  */\r
-    const SKP_int16      *in,        /* I:   Fs_low signal   [inLen]                  */\r
-    SKP_int              inLen       /* I:   Input length, must be a multiple of 4    */\r
-)\r
-{\r
-    SKP_int      LSubFrameIn, LSubFrameOut;\r
-    SKP_int16    outH[      3 * IN_SUBFR_LEN_RESAMPLE_3_4 ];\r
-    SKP_int16    outL[    ( 3 * IN_SUBFR_LEN_RESAMPLE_3_4 ) / 2 ];\r
-    SKP_int32    scratch[ ( 9 * IN_SUBFR_LEN_RESAMPLE_3_4 ) / 2 ];\r
-\r
-    /* Check that input is multiple of 4 */\r
-    SKP_assert( inLen % 4 == 0 );\r
-\r
-    while( inLen > 0 ) {\r
-        LSubFrameIn  = SKP_min_int( IN_SUBFR_LEN_RESAMPLE_3_4, inLen );\r
-        LSubFrameOut = SKP_SMULWB( 49152, LSubFrameIn );\r
-\r
-        /* Upsample by a factor 3 */\r
-        SKP_Silk_resample_3_1( outH, &S[ 0 ], in, LSubFrameIn );\r
-        \r
-        /* Downsample by a factor 2 twice */\r
-        /* Scratch size needs to be: 3 * 2 * LSubFrameOut * sizeof( SKP_int32 ) */\r
-        /* I: state vector [2], scratch memory [3*len] */\r
-        SKP_Silk_resample_1_2_coarsest( outH, &S[ 7 ], outL, scratch, SKP_LSHIFT( LSubFrameOut, 1 ) ); \r
-        \r
-        /* Scratch size needs to be: 3 * LSubFrameOut * sizeof( SKP_int32 ) */\r
-        /* I: state vector [6], scratch memory [3*len]    */\r
-        SKP_Silk_resample_1_2_coarse( outL, &S[ 9 ], out, scratch, LSubFrameOut );\r
-\r
-        in    += LSubFrameIn;\r
-        out   += LSubFrameOut;\r
-        inLen -= LSubFrameIn;\r
-    }\r
-}\r
diff --git a/libs/silk/src/SKP_Silk_resample_4_3.c b/libs/silk/src/SKP_Silk_resample_4_3.c
deleted file mode 100644 (file)
index f5c4f4d..0000000
+++ /dev/null
@@ -1,77 +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
-/*                                                                      *\r
- * File Name:    SKP_Silk_resample_4_3.c                              *\r
- *                                                                      *\r
- * Resamples by a factor 4/3                                            *\r
- *                                                                      *\r
- * Copyright 2009 (c), Skype Limited                                    *\r
- * All rights reserved.                                                 *\r
- *                                                                      *\r
- * Date: 090407                                                         *\r
- *                                                                      */\r
-\r
-#include "SKP_Silk_SigProc_FIX.h"\r
-\r
-#define OUT_SUBFR_LEN        80\r
-\r
-/* Resamples by a factor 4/3 */\r
-void SKP_Silk_resample_4_3(\r
-    SKP_int16            *out,       /* O:   Fs_low signal    [inLen * 4/3]           */\r
-    SKP_int32            *S,         /* I/O: State vector    [7+4+4]                  */\r
-    const SKP_int16      *in,        /* I:   Fs_high signal    [inLen]                */\r
-    const SKP_int        inLen       /* I:   input length, must be a multiple of 3    */\r
-) \r
-{\r
-    SKP_int      outLen, LSubFrameIn, LSubFrameOut;\r
-    SKP_int16    outH[    3 * OUT_SUBFR_LEN ];\r
-    SKP_int16    outHH[   6 * OUT_SUBFR_LEN ];\r
-    SKP_int32    scratch[ 9 * OUT_SUBFR_LEN / 2 ];\r
-\r
-    /* Check that input is multiple of 3 */\r
-    SKP_assert( inLen % 3 == 0 );\r
-\r
-    outLen = SKP_DIV32_16( SKP_LSHIFT( inLen, 2 ), 3 );\r
-    while( outLen > 0 ) {\r
-        LSubFrameOut = SKP_min_int( OUT_SUBFR_LEN, outLen );\r
-        LSubFrameIn  = SKP_SMULWB( 49152, LSubFrameOut );\r
-\r
-        /* Upsample two times by a factor 2 */\r
-        /* Scratch size needs to be: 3 * LSubFrameIn * sizeof( SKP_int32 ) */\r
-        SKP_Silk_resample_2_1_coarse( in,   &S[ 0 ], outH,  scratch,             LSubFrameIn      );\r
-        /* Scratch size needs to be: 6 * LSubFrameIn * sizeof( SKP_int32 ) */\r
-        SKP_Silk_resample_2_1_coarse( outH, &S[ 4 ], outHH, scratch, SKP_LSHIFT( LSubFrameIn, 1 ) );\r
-        \r
-        /* Downsample by a factor 3 */\r
-        SKP_Silk_resample_1_3( out, &S[ 8 ], outHH, SKP_LSHIFT( LSubFrameIn, 2 ) );\r
-\r
-        in     += LSubFrameIn;\r
-        out    += LSubFrameOut;\r
-        outLen -= LSubFrameOut;\r
-    }\r
-}\r
diff --git a/libs/silk/src/SKP_Silk_resample_rom.h b/libs/silk/src/SKP_Silk_resample_rom.h
deleted file mode 100644 (file)
index 9a32648..0000000
+++ /dev/null
@@ -1,107 +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
-/*                                                                                                                                             *\r
- * File Name:  SKP_Silk_resample_rom.h                                                         *\r
- *                                                                                                                                             *\r
- * Description: Header file for FIR resampling of                                              *\r
- *                             32 and 44 kHz input                                                                     *\r
- *                                                                      *\r
- * Copyright 2007 (c), Skype Limited                                    *\r
- * All rights reserved.                                                                                                        *\r
- *                                                                                                                                             *\r
- * Date: 070807                                                         *\r
- *                                                                      */\r
-\r
-#ifndef _SKP_SILK_FIX_RESAMPLE_ROM_H_\r
-#define _SKP_SILK_FIX_RESAMPLE_ROM_H_\r
-\r
-#include "SKP_Silk_typedef.h"\r
-\r
-#ifdef  __cplusplus\r
-extern "C"\r
-{\r
-#endif\r
-\r
-#define SigProc_Resample_bw_1_4_NUM_INTERPOLATORS_LOG2                         7\r
-#define SigProc_Resample_bw_1_4_NUM_INTERPOLATORS                                      (1 << SigProc_Resample_bw_1_4_NUM_INTERPOLATORS_LOG2)\r
-#define SigProc_Resample_bw_1_4_NUM_FIR_COEFS                                          6 \r
-\r
-extern const SKP_int16 SigProc_Resample_bw_1_4_INTERPOL[SigProc_Resample_bw_1_4_NUM_INTERPOLATORS][SigProc_Resample_bw_1_4_NUM_FIR_COEFS];\r
-\r
-\r
-#define SigProc_Resample_bw_80_441_NUM_INTERPOLATORS_LOG2                      6\r
-#define SigProc_Resample_bw_80_441_NUM_INTERPOLATORS                           (1 << SigProc_Resample_bw_80_441_NUM_INTERPOLATORS_LOG2)\r
-#define SigProc_Resample_bw_80_441_NUM_FIR_COEFS                                       4 \r
-\r
-extern const SKP_int16 SigProc_Resample_bw_80_441_INTERPOL[SigProc_Resample_bw_80_441_NUM_INTERPOLATORS][SigProc_Resample_bw_80_441_NUM_FIR_COEFS];\r
-\r
-#define SigProc_Resample_2_3_coarse_NUM_INTERPOLATORS                           2\r
-#define SigProc_Resample_2_3_coarse_NUM_FIR_COEFS                                      32\r
-\r
-extern const SKP_int16 SigProc_Resample_2_3_coarse_INTERPOL[SigProc_Resample_2_3_coarse_NUM_INTERPOLATORS][SigProc_Resample_2_3_coarse_NUM_FIR_COEFS];\r
-\r
-#define SigProc_Resample_2_3_coarsest_NUM_INTERPOLATORS                                 2\r
-#define SigProc_Resample_2_3_coarsest_NUM_FIR_COEFS                                    10\r
-\r
-extern const SKP_int16 SigProc_Resample_2_3_coarsest_INTERPOL[SigProc_Resample_2_3_coarsest_NUM_INTERPOLATORS][SigProc_Resample_2_3_coarsest_NUM_FIR_COEFS];\r
-\r
-#define SigProc_Resample_3_2_coarse_NUM_INTERPOLATORS                           3\r
-#define SigProc_Resample_3_2_coarse_NUM_FIR_COEFS                                       8\r
-\r
-extern const SKP_int16 SigProc_Resample_3_2_coarse_INTERPOL[SigProc_Resample_3_2_coarse_NUM_INTERPOLATORS][SigProc_Resample_3_2_coarse_NUM_FIR_COEFS];\r
-\r
-#define SigProc_Resample_147_40_NUM_INTERPOLATORS                                       147\r
-#define SigProc_Resample_147_40_NUM_FIR_COEFS                                           20\r
-\r
-extern const SKP_int16 SigProc_Resample_147_40_INTERPOL[SigProc_Resample_147_40_NUM_INTERPOLATORS][SigProc_Resample_147_40_NUM_FIR_COEFS];\r
-\r
-#define SigProc_Resample_147_40_alt_NUM_INTERPOLATORS                           147\r
-#define SigProc_Resample_147_40_alt_NUM_FIR_COEFS                                       10\r
-\r
-extern const SKP_int16 SigProc_Resample_147_40_alt_INTERPOL[SigProc_Resample_147_40_alt_NUM_INTERPOLATORS][SigProc_Resample_147_40_alt_NUM_FIR_COEFS];\r
-\r
-#define SigProc_Resample_147_40_coarse_NUM_INTERPOLATORS                        147\r
-#define SigProc_Resample_147_40_coarse_NUM_FIR_COEFS                            16\r
-\r
-extern const SKP_int16 SigProc_Resample_147_40_coarse_INTERPOL[SigProc_Resample_147_40_coarse_NUM_INTERPOLATORS][SigProc_Resample_147_40_coarse_NUM_FIR_COEFS];\r
-\r
-#define SigProc_Resample_40_147_NUM_INTERPOLATORS                                       40\r
-#define SigProc_Resample_40_147_NUM_FIR_COEFS                                           60\r
-\r
-extern const SKP_int16 SigProc_Resample_40_147_INTERPOL[SigProc_Resample_40_147_NUM_INTERPOLATORS][SigProc_Resample_40_147_NUM_FIR_COEFS];\r
-\r
-#define SigProc_Resample_40_147_coarse_NUM_INTERPOLATORS                        40\r
-#define SigProc_Resample_40_147_coarse_NUM_FIR_COEFS                            30\r
-\r
-extern const SKP_int16 SigProc_Resample_40_147_coarse_INTERPOL[SigProc_Resample_40_147_coarse_NUM_INTERPOLATORS][SigProc_Resample_40_147_coarse_NUM_FIR_COEFS];\r
-\r
-#ifdef  __cplusplus\r
-}\r
-#endif\r
-\r
-#endif // _SKP_SILK_FIX_RESAMPLE_ROM_H_\r
index 223ad14636c8f8e7c142e3294aa2189aaf7121a3..b559ce61ab5b38e1966494f5e8f1724b46e1eff0 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
index 640bcc245f411964433c40e095ce7d9133b84921..19921ef0d8480b04c9822fd732a9da600345a2ae 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -33,9 +33,8 @@ void SKP_Silk_residual_energy_FIX(
           SKP_int32 nrgs[ NB_SUBFR ],           /* O    Residual energy per subframe    */\r
           SKP_int   nrgsQ[ NB_SUBFR ],          /* O    Q value per subframe            */\r
     const SKP_int16 x[],                        /* I    Input signal                    */\r
-    const SKP_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ],/* I    AR coefs for each frame half    */\r
-    const SKP_int32 gains_Qx[ NB_SUBFR ],       /* I    Quantization gains in Qx        */\r
-    const SKP_int   Qx,                         /* I    Quantization gains Q value      */\r
+          SKP_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ],/* I    AR coefs for each frame half    */\r
+    const SKP_int32 gains[ NB_SUBFR ],          /* I    Quantization gains              */\r
     const SKP_int   subfr_length,               /* I    Subframe length                 */\r
     const SKP_int   LPC_order                   /* I    LPC order                       */\r
 )\r
@@ -74,16 +73,16 @@ void SKP_Silk_residual_energy_FIX(
     /* Apply the squared subframe gains */\r
     for( i = 0; i < NB_SUBFR; i++ ) {\r
         /* Fully upscale gains and energies */\r
-        lz1 = SKP_Silk_CLZ32( nrgs[ i ] ) - 1; \r
-        lz2 = SKP_Silk_CLZ32( gains_Qx[ i ] ) - 1; \r
+        lz1 = SKP_Silk_CLZ32( nrgs[  i ] ) - 1; \r
+        lz2 = SKP_Silk_CLZ32( gains[ i ] ) - 1; \r
         \r
-        tmp32 = SKP_LSHIFT32( gains_Qx[ i ], lz2 );\r
+        tmp32 = SKP_LSHIFT32( gains[ i ], lz2 );\r
 \r
         /* Find squared gains */\r
-        tmp32 = SKP_SMMUL( tmp32, tmp32 ); // Q( 2 * ( Qx + lz2 ) - 32 )\r
+        tmp32 = SKP_SMMUL( tmp32, tmp32 ); // Q( 2 * lz2 - 32 )\r
 \r
         /* Scale energies */\r
-        nrgs[ i ] = SKP_SMMUL( tmp32, SKP_LSHIFT32( nrgs[ i ], lz1 ) ); // Q( nrgsQ[ i ] + lz1 + 2 * ( Qx + lz2 ) - 32 - 32 )\r
-        nrgsQ[ i ] += lz1 + 2 * ( Qx + lz2 ) - 32 - 32;\r
+        nrgs[ i ] = SKP_SMMUL( tmp32, SKP_LSHIFT32( nrgs[ i ], lz1 ) ); // Q( nrgsQ[ i ] + lz1 + 2 * lz2 - 32 - 32 )\r
+        nrgsQ[ i ] += lz1 + 2 * lz2 - 32 - 32;\r
     }\r
 }\r
index 56057723c274582343d7a24c9734abce84410efe..2fa4bf6218b12e155e3e4602dd62e7d2b2c15ed0 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
index 78f4e1346890aad5b12522e44c146d1d7687559c..f596a441471b3d3a71eb00c3595cada9822ca151 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -27,40 +27,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 \r
 #include "SKP_Silk_SigProc_FIX.h"\r
 \r
-/* Multiply a vector by a constant */\r
-void SKP_Silk_scale_vector16_Q14( \r
-    SKP_int16           *data1, \r
-    SKP_int             gain_Q14,       /* Gain in Q14 */ \r
-    SKP_int             dataSize\r
-)\r
-{\r
-    SKP_int   i;\r
-    SKP_int32 data32, gain_Q16;\r
-\r
-    SKP_assert( gain_Q14 <   32768 );\r
-    SKP_assert( gain_Q14 >= -32768 );\r
-\r
-    gain_Q16 = SKP_LSHIFT( gain_Q14, 2 );\r
-\r
-    if( (SKP_int32)( (SKP_int_ptr_size)data1 & 3 ) != 0 ) {\r
-        /* Input is not 4-byte aligned */\r
-        data1[ 0 ] = SKP_SMULWB( gain_Q16, data1[ 0 ] );\r
-        i = 1;\r
-    } else {\r
-        i = 0;\r
-    }\r
-    dataSize--;\r
-    for( ; i < dataSize; i += 2 ) {\r
-        data32 = *( (SKP_int32 *)&data1[ i ] );                     /* load two values at once */\r
-        data1[ i     ] = SKP_SMULWB( gain_Q16, data32 );\r
-        data1[ i + 1 ] = SKP_SMULWT( gain_Q16, data32 );\r
-    }\r
-    if( i == dataSize ) {\r
-        /* One sample left to process */\r
-        data1[ i ] = SKP_SMULWB( gain_Q16, data1[ i ] );\r
-    }\r
-}\r
-\r
 /* Multiply a vector by a constant */\r
 void SKP_Silk_scale_vector32_Q26_lshift_18( \r
     SKP_int32           *data1,                     /* (I/O): Q0/Q18        */\r
@@ -75,48 +41,3 @@ void SKP_Silk_scale_vector32_Q26_lshift_18(
     }\r
 }\r
 \r
-/* Multiply a vector by a constant */\r
-void SKP_Silk_scale_vector32_16_Q14( \r
-    SKP_int32           *data1,                     /* (I/O): Q0/Q0         */\r
-    SKP_int             gain_Q14,                   /* (I):   Q14           */\r
-    SKP_int             dataSize                    /* (I):   length        */\r
-)\r
-{\r
-    SKP_int  i, gain_Q16;\r
-\r
-    if( gain_Q14 < ( SKP_int16_MAX >> 2 ) ) {\r
-        gain_Q16 = SKP_LSHIFT( gain_Q14, 2 );\r
-        for( i = 0; i < dataSize; i++ ) {\r
-            data1[ i ] = SKP_SMULWB( data1[ i ], gain_Q16 );\r
-        }\r
-    } else {\r
-        SKP_assert( gain_Q14 >= SKP_int16_MIN );\r
-        for( i = 0; i < dataSize; i++ ) {\r
-            data1[ i ] = SKP_LSHIFT( SKP_SMULWB( data1[ i ], gain_Q14 ), 2 );\r
-        }\r
-    }\r
-}\r
-\r
-/* Multiply a vector by a constant, does not saturate output data */\r
-void SKP_Silk_scale_vector32_Q16( \r
-    SKP_int32           *data1,                     /* (I/O): Q0/Q0         */\r
-    SKP_int32           gain_Q16,                   /* (I):   gain in Q16 ( SKP_int16_MIN <= gain_Q16 <= SKP_int16_MAX + 65536 ) */\r
-    const SKP_int       dataSize                    /* (I):   length        */\r
-)\r
-{\r
-    SKP_int     i;\r
-\r
-    SKP_assert( gain_Q16 <= SKP_int16_MAX + 65536 );\r
-    SKP_assert( gain_Q16 >= SKP_int16_MIN );\r
-\r
-    if( gain_Q16 > SKP_int16_MAX ) {\r
-        gain_Q16 -= 65536;\r
-        for( i = 0; i < dataSize; i++ ) {\r
-            data1[ i ] = SKP_SMLAWB( data1[ i ], data1[ i ], gain_Q16 );\r
-        }\r
-    } else {\r
-        for( i = 0; i < dataSize; i++ ) {\r
-            data1[ i ] = SKP_SMULWB( data1[ i ], gain_Q16 );\r
-        }\r
-    }\r
-}\r
index c2da483c94691c5d40cf0930b5cd0f668c4895d5..5fced358359a99d84573b6d6981fb40fe814e35b 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -37,14 +37,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 \r
 /* Faster than schur64(), but much less accurate.                       */\r
 /* uses SMLAWB(), requiring armv5E and higher.                          */ \r
-void SKP_Silk_schur(\r
-    SKP_int16            *rc_Q15,                /* O:    reflection coefficients [order] Q15         */\r
-    const SKP_int32      *c,                     /* I:    correlations [order+1]                      */\r
-    const SKP_int32      order                   /* I:    prediction order                            */\r
+SKP_int32 SKP_Silk_schur(                     /* O:    Returns residual energy                     */\r
+    SKP_int16            *rc_Q15,               /* O:    reflection coefficients [order] Q15         */\r
+    const SKP_int32      *c,                    /* I:    correlations [order+1]                      */\r
+    const SKP_int32      order                  /* I:    prediction order                            */\r
 )\r
 {\r
     SKP_int        k, n, lz;\r
-    SKP_int32    C[ SigProc_MAX_ORDER_LPC + 1 ][ 2 ];\r
+    SKP_int32    C[ SKP_Silk_MAX_ORDER_LPC + 1 ][ 2 ];\r
     SKP_int32    Ctmp1, Ctmp2, rc_tmp_Q15;\r
 \r
     /* Get number of leading zeros */\r
@@ -88,4 +88,7 @@ void SKP_Silk_schur(
             C[ n ][ 1 ]         = SKP_SMLAWB( Ctmp2, SKP_LSHIFT( Ctmp1, 1 ), rc_tmp_Q15 );\r
         }\r
     }\r
+\r
+    /* return residual energy */\r
+    return C[0][1];\r
 }\r
index 048b684ca2af78207e55e7a51cc5cdafcc1a0361..bb869c0020cf4c335cfd383720bcf266acdcfe78 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -45,7 +45,7 @@ SKP_int32 SKP_Silk_schur64(                    /* O:    Returns residual energy
 )\r
 {\r
     SKP_int   k, n;\r
-    SKP_int32 C[ SigProc_MAX_ORDER_LPC + 1 ][ 2 ];\r
+    SKP_int32 C[ SKP_Silk_MAX_ORDER_LPC + 1 ][ 2 ];\r
     SKP_int32 Ctmp1_Q30, Ctmp2_Q30, rc_tmp_Q31;\r
 \r
     /* Check for invalid input */\r
@@ -76,5 +76,5 @@ SKP_int32 SKP_Silk_schur64(                    /* O:    Returns residual energy
         }\r
     }\r
 \r
-    return( C[ 0 ][ 1 ] );\r
+    return C[ 0 ][ 1 ];\r
 }\r
index 8e395822ba9aa09007c978818923c677108d4de8..f8bdf1ff34e277a3ae57b3e1a02a1c1a5dd55bab 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
index 95c056343ebd355d57208b8cbc59ab5e7059d250..5b4168c16e09ae98769666dc7b17eae7673b201d 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
index 23c0c9c842c0369eb3d6d54f625ee0641a91e918..256841855e98678175777d4eef86a273814f8cc4 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -26,6 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ***********************************************************************/\r
 \r
 #include "SKP_Silk_main_FIX.h"\r
+#include "SKP_Silk_tuning_parameters.h"\r
 \r
 /*****************************/\r
 /* Internal function headers */\r
@@ -120,7 +121,7 @@ SKP_INLINE void SKP_Silk_LDL_factorize_FIX(
     SKP_assert( M <= MAX_MATRIX_SIZE );\r
 \r
     status = 1;\r
-    diag_min_value = SKP_max_32( SKP_SMMUL( SKP_ADD_SAT32( A[ 0 ], A[ SKP_SMULBB( M, M ) - 1 ] ), FIND_LTP_COND_FAC_Q31 ), 1 << 9 );\r
+    diag_min_value = SKP_max_32( SKP_SMMUL( SKP_ADD_SAT32( A[ 0 ], A[ SKP_SMULBB( M, M ) - 1 ] ), SKP_FIX_CONST( FIND_LTP_COND_FAC, 31 ) ), 1 << 9 );\r
     for( loop_count = 0; loop_count < M && status == 1; loop_count++ ) {\r
         status = 0;\r
         for( j = 0; j < M; j++ ) {\r
index 70930b57c85c22928719c06096ab4e1410423928..b81e01e15131a35ca53b5b5d6731baa9c2f2f5d1 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -29,7 +29,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 /* Best case:  O(n)   for an already sorted array            */\r
 /* Worst case: O(n^2) for an inversely sorted array          */\r
 /*                                                           */\r
-/* To be implemented:                                        */\r
 /* Shell short:    http://en.wikipedia.org/wiki/Shell_sort   */\r
 \r
 #include "SKP_Silk_SigProc_FIX.h"\r
@@ -38,7 +37,7 @@ void SKP_Silk_insertion_sort_increasing(
     SKP_int32           *a,             /* I/O:  Unsorted / Sorted vector               */\r
     SKP_int             *index,         /* O:    Index vector for the sorted elements   */\r
     const SKP_int       L,              /* I:    Vector length                          */\r
-    const SKP_int       K               /* I:    Number of correctly sorted positions   */\r
+    const SKP_int       K               /* I:    Number of correctly sorted output positions   */\r
 )\r
 {\r
     SKP_int32    value;\r
@@ -65,7 +64,7 @@ void SKP_Silk_insertion_sort_increasing(
         index[ j + 1 ] = i;     /* Write index */\r
     }\r
 \r
-    /* If less than L values are asked check the remaining values,      */\r
+    /* If less than L values are asked for, check the remaining values, */\r
     /* but only spend CPU to ensure that the K first values are correct */\r
     for( i = K; i < L; i++ ) {\r
         value = a[ i ];\r
@@ -80,57 +79,11 @@ void SKP_Silk_insertion_sort_increasing(
     }\r
 }\r
 \r
-void SKP_Silk_insertion_sort_decreasing(\r
-    SKP_int             *a,             /* I/O: Unsorted / Sorted vector                */\r
-    SKP_int             *index,         /* O:   Index vector for the sorted elements    */\r
-    const SKP_int       L,              /* I:   Vector length                           */\r
-    const SKP_int       K               /* I:   Number of correctly sorted positions    */\r
-)\r
-{\r
-    SKP_int    value;\r
-    SKP_int    i, j;\r
-\r
-    /* Safety checks */\r
-    SKP_assert( K >  0 );\r
-    SKP_assert( L >  0 );\r
-    SKP_assert( L >= K );\r
-\r
-    /* Write start indices in index vector */\r
-    for( i = 0; i < K; i++ ) {\r
-        index[ i ] = i;\r
-    }\r
-\r
-    /* Sort vector elements by value, decreasing order */\r
-    for( i = 1; i < K; i++ ) {\r
-        value = a[ i ];\r
-        for( j = i - 1; ( j >= 0 ) && ( value > a[ j ] ); j-- ) {\r
-            a[ j + 1 ]     = a[ j ];     /* Shift value */\r
-            index[ j + 1 ] = index[ j ]; /* Shift index */\r
-        }\r
-        a[ j + 1 ]     = value; /* Write value */\r
-        index[ j + 1 ] = i;     /* Write index */\r
-    }\r
-\r
-    /* If less than L values are asked check the remaining values,      */\r
-    /* but only spend CPU to ensure that the K first values are correct */\r
-    for( i = K; i < L; i++ ) {\r
-        value = a[ i ];\r
-        if( value > a[ K - 1 ] ) {\r
-            for( j = K - 2; ( j >= 0 ) && ( value > a[ j ] ); j-- ) {\r
-                a[ j + 1 ]     = a[ j ];     /* Shift value */\r
-                index[ j + 1 ] = index[ j ]; /* Shift index */\r
-            }\r
-            a[ j + 1 ]     = value; /* Write value */\r
-            index[ j + 1 ] = i;     /* Write index */\r
-        }\r
-    }\r
-}\r
-\r
 void SKP_Silk_insertion_sort_decreasing_int16(\r
     SKP_int16           *a,             /* I/O: Unsorted / Sorted vector                */\r
     SKP_int             *index,         /* O:   Index vector for the sorted elements    */\r
     const SKP_int       L,              /* I:   Vector length                           */\r
-    const SKP_int       K               /* I:   Number of correctly sorted positions    */\r
+    const SKP_int       K               /* I:   Number of correctly sorted output positions    */\r
 )\r
 {\r
     SKP_int i, j;\r
@@ -157,7 +110,7 @@ void SKP_Silk_insertion_sort_decreasing_int16(
         index[ j + 1 ] = i;     /* Write index */\r
     }\r
 \r
-    /* If less than L values are asked check the remaining values,        */\r
+    /* If less than L values are asked for, check the remaining values, */\r
     /* but only spend CPU to ensure that the K first values are correct */\r
     for( i = K; i < L; i++ ) {\r
         value = a[ i ];\r
index ce96e2202fda151cb8bfb23317b5ba1ca039bcdb..f436ffaa16d52871caac1f78996b5c55f1c4d1ee 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -44,7 +44,8 @@ extern "C"
 typedef struct {\r
     SKP_int16   xq[           2 * MAX_FRAME_LENGTH ]; /* Buffer for quantized output signal */\r
     SKP_int32   sLTP_shp_Q10[ 2 * MAX_FRAME_LENGTH ];\r
-    SKP_int32   sLPC_Q14[ MAX_FRAME_LENGTH / NB_SUBFR + MAX_LPC_ORDER ];\r
+    SKP_int32   sLPC_Q14[ MAX_FRAME_LENGTH / NB_SUBFR + NSQ_LPC_BUF_LENGTH ];\r
+    SKP_int32   sAR2_Q14[ MAX_SHAPE_LPC_ORDER ];\r
     SKP_int32   sLF_AR_shp_Q12;\r
     SKP_int     lagPrev;\r
     SKP_int     sLTP_buf_idx;\r
@@ -147,12 +148,16 @@ typedef struct {
     SKP_int                         typeOffsetPrev;                 /* Previous signal type and quantization offset                         */\r
     SKP_int                         prevLag;\r
     SKP_int                         prev_lagIndex;\r
-    SKP_int                         fs_kHz;                         /* Sampling frequency (kHz)                                             */\r
+    SKP_int32                       API_fs_Hz;                      /* API sampling frequency (Hz)                                          */\r
+    SKP_int32                       prev_API_fs_Hz;                 /* Previous API sampling frequency (Hz)                                 */\r
+    SKP_int                         maxInternal_fs_kHz;             /* Maximum internal sampling frequency (kHz)                            */\r
+    SKP_int                         fs_kHz;                         /* Internal sampling frequency (kHz)                                    */\r
     SKP_int                         fs_kHz_changed;                 /* Did we switch yet?                                                   */\r
     SKP_int                         frame_length;                   /* Frame length (samples)                                               */\r
     SKP_int                         subfr_length;                   /* Subframe length (samples)                                            */\r
     SKP_int                         la_pitch;                       /* Look-ahead for pitch analysis (samples)                              */\r
     SKP_int                         la_shape;                       /* Look-ahead for noise shape analysis (samples)                        */\r
+    SKP_int                         shapeWinLength;                 /* Window length for noise shape analysis (samples)                     */\r
     SKP_int32                       TargetRate_bps;                 /* Target bitrate (bps)                                                 */\r
     SKP_int                         PacketSize_ms;                  /* Number of milliseconds to put in each packet                         */\r
     SKP_int                         PacketLoss_perc;                /* Packet loss rate measured by farend                                  */\r
@@ -164,9 +169,12 @@ typedef struct {
     SKP_int                         predictLPCOrder;                /* Filter order for prediction filters                                  */\r
     SKP_int                         pitchEstimationComplexity;      /* Complexity level for pitch estimator                                 */\r
     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                         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
+       SKP_int                         warping_Q16;                    /* Warping parameter for warped noise shaping                           */\r
 \r
     /* Input/output buffering */\r
     SKP_int16                       inputBuf[ MAX_FRAME_LENGTH ];   /* buffer containin input signal                                        */\r
@@ -182,28 +190,16 @@ typedef struct {
     /* Struct for Inband LBRR */ \r
     SKP_SILK_LBRR_struct            LBRR_buffer[ MAX_LBRR_DELAY ];\r
     SKP_int                         oldest_LBRR_idx;\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
 \r
     /* Bitrate control */\r
-    SKP_int32                       bitrateDiff;                    /* accumulated diff. between the target bitrate and the SWB/WB limits   */\r
+    SKP_int32                       bitrateDiff;                    /* Accumulated diff. between the target bitrate and the switch bitrates */\r
+    SKP_int32                       bitrate_threshold_up;           /* Threshold for switching to a higher internal sample frequency        */\r
+    SKP_int32                       bitrate_threshold_down;         /* Threshold for switching to a lower internal sample frequency         */\r
 \r
-#if LOW_COMPLEXITY_ONLY\r
-    /* state for downsampling from 24 to 16 kHz in low complexity mode */\r
-    SKP_int16                       resample24To16state[ SigProc_Resample_2_3_coarse_NUM_FIR_COEFS - 1 ];\r
-#else\r
-    SKP_int32                       resample24To16state[ 11 ];      /* state for downsampling from 24 to 16 kHz                             */\r
-#endif\r
-    SKP_int32                       resample24To12state[ 6 ];       /* state for downsampling from 24 to 12 kHz                             */\r
-    SKP_int32                       resample24To8state[ 7 ];        /* state for downsampling from 24 to  8 kHz                             */\r
-    SKP_int32                       resample16To12state[ 15 ];      /* state for downsampling from 16 to 12 kHz                             */\r
-    SKP_int32                       resample16To8state[ 6 ];        /* state for downsampling from 16 to  8 kHz                             */\r
-#if LOW_COMPLEXITY_ONLY\r
-    /* state for downsampling from 12 to 8 kHz in low complexity mode */\r
-    SKP_int16                       resample12To8state[ SigProc_Resample_2_3_coarse_NUM_FIR_COEFS - 1 ];    \r
-#else\r
-    SKP_int32                       resample12To8state[ 11 ];       /* state for downsampling from 12 to  8 kHz                             */\r
-#endif\r
+    SKP_Silk_resampler_state_struct  resampler_state;\r
 \r
     /* DTX */\r
     SKP_int                         noSpeechCounter;                /* Counts concecutive nonactive frames, used by DTX                     */\r
@@ -215,15 +211,10 @@ typedef struct {
     SKP_Silk_detect_SWB_state       sSWBdetect;\r
 \r
 \r
-    /********************************************/\r
-    /* Buffers etc used by the new bitstream V4 */\r
-    /********************************************/\r
-    SKP_int                         q[ MAX_FRAME_LENGTH * MAX_FRAMES_PER_PACKET ];      /* pulse signal buffer */\r
-    SKP_int                         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                         extension_layer;                                    /* Add extension layer      */\r
-    SKP_int                         bitstream_v;                                        /* Holds bitstream version  */\r
+    /* Buffers */\r
+    SKP_int8                        q[ MAX_FRAME_LENGTH ];      /* pulse signal buffer */\r
+    SKP_int8                        q_LBRR[ MAX_FRAME_LENGTH ]; /* pulse signal buffer */\r
+\r
 } SKP_Silk_encoder_state;\r
 \r
 \r
@@ -287,7 +278,6 @@ typedef struct {
     SKP_int32       exc_Q10[ MAX_FRAME_LENGTH ];\r
     SKP_int32       res_Q10[ MAX_FRAME_LENGTH ];\r
     SKP_int16       outBuf[ 2 * MAX_FRAME_LENGTH ];             /* Buffer for output signal                                             */\r
-    SKP_int         sLTP_buf_idx;                               /* LTP_buf_index                                                        */\r
     SKP_int         lagPrev;                                    /* Previous Lag                                                         */\r
     SKP_int         LastGainIndex;                              /* Previous gain index                                                  */\r
     SKP_int         LastGainIndex_EnhLayer;                     /* Previous gain index                                                  */\r
@@ -296,6 +286,7 @@ typedef struct {
     const SKP_int16 *HP_A;                                      /* HP filter AR coefficients                                            */\r
     const SKP_int16 *HP_B;                                      /* HP filter MA coefficients                                            */\r
     SKP_int         fs_kHz;                                     /* Sampling frequency in kHz                                            */\r
+    SKP_int32       prev_API_sampleRate;                        /* Previous API sample frequency (Hz)                                   */\r
     SKP_int         frame_length;                               /* Frame length (samples)                                               */\r
     SKP_int         subfr_length;                               /* Subframe length (samples)                                            */\r
     SKP_int         LPC_order;                                  /* LPC order                                                            */\r
@@ -309,24 +300,10 @@ typedef struct {
     SKP_int         moreInternalDecoderFrames;\r
     SKP_int         FrameTermination;\r
 \r
-    SKP_int32       resampleState[ 15 ];\r
+    SKP_Silk_resampler_state_struct  resampler_state;\r
 \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         GainsIndices[          MAX_FRAMES_PER_PACKET ][ NB_SUBFR ];\r
-    SKP_int         GainsIndices_EnhLayer[ MAX_FRAMES_PER_PACKET ][ NB_SUBFR ];\r
-    SKP_int         NLSFIndices[           MAX_FRAMES_PER_PACKET ][ NLSF_MSVQ_MAX_CB_STAGES ];\r
-    SKP_int         NLSFInterpCoef_Q2[     MAX_FRAMES_PER_PACKET ];\r
-    SKP_int         lagIndex[              MAX_FRAMES_PER_PACKET ];\r
-    SKP_int         contourIndex[          MAX_FRAMES_PER_PACKET ];\r
-    SKP_int         PERIndex[              MAX_FRAMES_PER_PACKET ];\r
-    SKP_int         LTPIndex[              MAX_FRAMES_PER_PACKET ][ 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
     SKP_int         no_FEC_counter;                             /* Counts number of frames wo inband FEC                                */\r
@@ -336,21 +313,13 @@ typedef struct {
     SKP_Silk_CNG_struct sCNG;\r
 \r
     /* Stuff used for PLC */\r
-    SKP_Silk_PLC_struct sPLC;\r
     SKP_int         lossCnt;\r
     SKP_int         prev_sigtype;                               /* Previous sigtype                                                     */\r
-#ifdef USE_INTERPOLATION_PLC\r
-    SKP_int16       prevQuant[ MAX_FRAME_LENGTH ];\r
-    SKP_int         prevPitchL[ NB_SUBFR ];                     /* Previous Lags used                                                   */\r
-    SKP_int16       prevLTPCoef_Q14[ NB_SUBFR * LTP_ORDER ];    /* Previous LTCoefs used                                                */\r
-    SKP_int16       prevAR_Q12[ MAX_LPC_ORDER ];\r
-    SKP_int         interpolDistance;                           /* Number of frames between old and new recieved packet                 */\r
-#endif\r
 \r
+    SKP_Silk_PLC_struct sPLC;\r
 \r
 \r
 \r
-    SKP_int                 bitstream_v;                        /* Holds bitstream version                                              */\r
 } SKP_Silk_decoder_state;\r
 \r
 /************************/\r
@@ -362,7 +331,7 @@ typedef struct {
     SKP_int32           Gains_Q16[ NB_SUBFR ];\r
     SKP_int32           Seed;\r
     /* holds interpolated and final coefficients, 4-byte aligned */\r
-    SKP_array_of_int16_4_byte_aligned( PredCoef_Q12[ 2 ], MAX_LPC_ORDER );\r
+    SKP_DWORD_ALIGN SKP_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ];\r
     SKP_int16           LTPCoef_Q14[ LTP_ORDER * NB_SUBFR ];\r
     SKP_int             LTP_scale_Q14;\r
 \r
index d38bea719acbfe39af73cb4064490cb3330bfa08..36518651060631b9ced4f15650655ef51201001e 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -29,13 +29,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #define SKP_SILK_STRUCTS_FIX_H\r
 \r
 #include "SKP_Silk_typedef.h"\r
-#include "SKP_Silk_define_FIX.h"\r
 #include "SKP_Silk_main.h"\r
 #include "SKP_Silk_structs.h"\r
 \r
-#if LOW_COMPLEXITY_ONLY\r
-#include "SKP_Silk_resample_rom.h"\r
-#endif\r
 \r
 #ifdef __cplusplus\r
 extern "C"\r
@@ -56,16 +52,11 @@ typedef struct {
 /* Prefilter state              */\r
 /********************************/\r
 typedef struct {\r
-    SKP_int16   sLTP_shp1[ LTP_BUF_LENGTH ];\r
-    SKP_int32   sAR_shp2_Q14[ SHAPE_LPC_ORDER_MAX ];\r
-    SKP_int16   sLTP_shp2_FIX[ LTP_BUF_LENGTH ];\r
-    SKP_int     sLTP_shp_buf_idx1;\r
-    SKP_int     sAR_shp_buf_idx2;\r
-    SKP_int     sLTP_shp_buf_idx2;\r
-    SKP_int32   sLF_AR_shp1_Q12;\r
-    SKP_int32   sLF_MA_shp1_Q12;\r
-    SKP_int32   sLF_AR_shp2_Q12;\r
-    SKP_int32   sLF_MA_shp2_Q12;\r
+    SKP_int16   sLTP_shp[ LTP_BUF_LENGTH ];\r
+    SKP_int32   sAR_shp[ MAX_SHAPE_LPC_ORDER + 1 ];\r
+    SKP_int     sLTP_shp_buf_idx;\r
+    SKP_int32   sLF_AR_shp_Q12;\r
+    SKP_int32   sLF_MA_shp_Q12;\r
     SKP_int     sHarmHP;\r
     SKP_int32   rand_seed;\r
     SKP_int     lagPrev;\r
@@ -78,33 +69,9 @@ typedef struct {
     SKP_int   pitch_LPC_win_length;\r
     SKP_int   min_pitch_lag;                                        /* Lowest possible pitch lag (samples)  */\r
     SKP_int   max_pitch_lag;                                        /* Highest possible pitch lag (samples) */\r
-    SKP_int   prev_NLSFq_Q15[ MAX_LPC_ORDER ];                      /* Prev. quant. normalized LSF vector   */\r
+    SKP_int   prev_NLSFq_Q15[ MAX_LPC_ORDER ];                      /* Previously quantized NLSF vector     */\r
 } SKP_Silk_predict_state_FIX;\r
 \r
-#if( defined( SAVE_ALL_INTERNAL_DATA ) || defined( USE_FLT2FIX_WRAPPER ) )\r
-/*******************************************/\r
-/* Structure containing NLSF MSVQ codebook */\r
-/*******************************************/\r
-/* structure for one stage of MSVQ */\r
-typedef struct {\r
-    const SKP_int32     nVectors;\r
-    const SKP_float     *CB;\r
-    const SKP_float     *Rates;\r
-} SKP_Silk_NLSF_CBS_FLP_TMP;\r
-\r
-typedef struct {\r
-    const SKP_int32                 nStages;\r
-\r
-    /* fields for (de)quantizing */\r
-    const SKP_Silk_NLSF_CBS_FLP_TMP *CBStages;\r
-    const SKP_float                 *NDeltaMin;\r
-\r
-    /* fields for arithmetic (de)coding */\r
-    const SKP_uint16                *CDF;\r
-    const SKP_uint16 * const        *StartPtr;\r
-    const SKP_int                   *MiddleIx;\r
-} SKP_Silk_NLSF_CB_struct_FLP_TMP;\r
-#endif\r
 \r
 /********************************/\r
 /* Encoder state FIX            */\r
@@ -121,15 +88,9 @@ typedef struct {
     SKP_Silk_predict_state_FIX      sPred;                          /* Prediction state                                                     */\r
     SKP_Silk_nsq_state              sNSQ;                           /* Noise Shape Quantizer State                                          */\r
     SKP_Silk_nsq_state              sNSQ_LBRR;                      /* Noise Shape Quantizer State ( for low bitrate redundancy )           */\r
-    \r
-    /* Function pointer to noise shaping quantizer (will be set to SKP_Silk_NSQ or SKP_Silk_NSQ_del_dec) */\r
-    void    (* NoiseShapingQuantizer)( SKP_Silk_encoder_state *, SKP_Silk_encoder_control *, SKP_Silk_nsq_state *, const SKP_int16 *, \r
-                                        SKP_int *, const SKP_int, const SKP_int16 *, const SKP_int16 *, const SKP_int16 *, const SKP_int *, \r
-                                        const SKP_int *, const SKP_int32 *, const SKP_int32 *, SKP_int, const SKP_int\r
-    );\r
 \r
     /* Buffer for find pitch and noise shape analysis */\r
-    SKP_array_of_int16_4_byte_aligned( x_buf, 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX );    \r
+    SKP_DWORD_ALIGN SKP_int16 x_buf[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ];\r
     SKP_int                         LTPCorr_Q15;                    /* Normalized correlation from pitch lag estimator                      */\r
     SKP_int                         mu_LTP_Q8;                      /* Rate-distortion tradeoff in LTP quantization                         */\r
     SKP_int32                       SNR_dB_Q7;                      /* Quality setting                                                      */\r
@@ -137,17 +98,13 @@ typedef struct {
     SKP_int32                       avgGain_Q16_one_bit_per_sample; /* average gain during active speech                                    */\r
     SKP_int                         BufferedInChannel_ms;           /* Simulated number of ms buffer because of exceeded TargetRate_bps     */\r
     SKP_int                         speech_activity_Q8;             /* Speech activity in Q8                                                */\r
-    SKP_int32                       pitchEstimationThreshold_Q16;   /* Threshold for pitch estimator                                        */\r
-    \r
+\r
     /* Parameters For LTP scaling Control */\r
     SKP_int                         prevLTPredCodGain_Q7;\r
     SKP_int                         HPLTPredCodGain_Q7;\r
 \r
     SKP_int32                       inBandFEC_SNR_comp_Q8;          /* Compensation to SNR_dB when using inband FEC Voiced      */\r
 \r
-#ifdef USE_FLT2FIX_WRAPPER\r
-    const SKP_Silk_NLSF_CB_struct_FLP_TMP *psNLSF_CB_FLP[ 2 ];      /* Pointers to voiced/unvoiced NLSF codebooks */    \r
-#endif\r
 } SKP_Silk_encoder_state_FIX;\r
 \r
 /************************/\r
@@ -158,14 +115,14 @@ typedef struct {
 \r
     /* Prediction and coding parameters */\r
     SKP_int32                   Gains_Q16[ NB_SUBFR ];\r
-    SKP_array_of_int16_4_byte_aligned( PredCoef_Q12[ 2 ], MAX_LPC_ORDER );\r
+    SKP_DWORD_ALIGN SKP_int16   PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ];\r
     SKP_int16                   LTPCoef_Q14[ LTP_ORDER * NB_SUBFR ];\r
     SKP_int                     LTP_scale_Q14;\r
 \r
     /* Noise shaping parameters */\r
     /* Testing */\r
-    SKP_array_of_int16_4_byte_aligned( AR1_Q13, NB_SUBFR * SHAPE_LPC_ORDER_MAX );\r
-    SKP_array_of_int16_4_byte_aligned( AR2_Q13, NB_SUBFR * SHAPE_LPC_ORDER_MAX );\r
+    SKP_DWORD_ALIGN SKP_int16 AR1_Q13[ NB_SUBFR * MAX_SHAPE_LPC_ORDER ];\r
+    SKP_DWORD_ALIGN SKP_int16 AR2_Q13[ NB_SUBFR * MAX_SHAPE_LPC_ORDER ];\r
     SKP_int32   LF_shp_Q14[        NB_SUBFR ];          /* Packs two int16 coefficients per int32 value             */\r
     SKP_int     GainsPre_Q14[      NB_SUBFR ];\r
     SKP_int     HarmBoost_Q14[     NB_SUBFR ];\r
@@ -179,6 +136,7 @@ typedef struct {
 \r
     /* measures */\r
     SKP_int     sparseness_Q8;\r
+    SKP_int32   predGain_Q16;\r
     SKP_int     LTPredCodGain_Q7;\r
     SKP_int     input_quality_bands_Q15[ VAD_N_BANDS ];\r
     SKP_int     input_tilt_Q15;\r
index 4904f8af8b27d8e4a7f0ffb2592880c3bd7152ee..a7cd6915425e1eb10080630811547ffaf055912d 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -56,11 +56,12 @@ void SKP_Silk_sum_sqr_shift(
     }\r
     shft = 0;\r
     len--;\r
-    for( ; i < len; i += 2 ) {\r
+    while( i < len ) {\r
         /* Load two values at once */\r
         in32 = *( (SKP_int32 *)&x[ i ] );\r
         nrg = SKP_SMLABB_ovflw( nrg, in32, in32 );\r
         nrg = SKP_SMLATT_ovflw( nrg, in32, in32 );\r
+        i += 2;\r
         if( nrg < 0 ) {\r
             /* Scale down */\r
             nrg = (SKP_int32)SKP_RSHIFT_uint( (SKP_uint32)nrg, 2 );\r
@@ -96,3 +97,4 @@ void SKP_Silk_sum_sqr_shift(
     *shift  = shft;\r
     *energy = nrg;\r
 }\r
+\r
index b23b8d95fb0549623c1b2183f354904c1a876326..543a0f47f5909bc28a8f45ad1d881615c8e27143 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -83,7 +83,7 @@ extern const SKP_uint16 SKP_Silk_shell_code_table_offsets[ 19 ];
 \r
 extern const SKP_uint16 SKP_Silk_lsb_CDF[ 3 ];                                                      /*   3 */\r
 \r
-extern const SKP_uint16 SKP_Silk_sign_CDF[ 36 ][ 3 ];                                               /* 108 */\r
+extern const SKP_uint16 SKP_Silk_sign_CDF[ 36 ];                                                    /*  36 */\r
 \r
 extern const SKP_uint16 SKP_Silk_LTP_per_index_CDF[ 4 ];                                            /*   4 */\r
 extern const SKP_int    SKP_Silk_LTP_per_index_CDF_offset;\r
@@ -148,9 +148,6 @@ extern const SKP_int16  SKP_Silk_Dec_B_HP_8[ DEC_HP_ORDER + 1 ];
 extern const SKP_uint16 SKP_Silk_FrameTermination_CDF[ 5 ];\r
 extern const SKP_int    SKP_Silk_FrameTermination_offset;\r
 \r
-extern const SKP_uint16 SKP_Silk_FrameTermination_v4_CDF[ 6 ];\r
-extern const SKP_int    SKP_Silk_FrameTermination_v4_offset;\r
-\r
 /* Table for random seed */\r
 extern const SKP_uint16 SKP_Silk_Seed_CDF[ 5 ];\r
 extern const SKP_int    SKP_Silk_Seed_offset;\r
index ea52fe3ef2e1cf8d758c8a8cfe4a3a59cc6e03bd..6de21b9308f83079175cd5d12f503f885eee1400 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
index 3f9cadbf22015efd05d42c81f6c1bc674dd11e34..8606b133c131d8c82ed135014bc2feb3cc4aa407 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -28,11 +28,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 /**********************************************/\r
 /* This file has been automatically generated */\r
 /*                                            */\r
-/* ROM usage:   138+1331 Words                */\r
+/* ROM usage:  0.29 + 2.66 kB                 */\r
 /**********************************************/\r
 \r
 #include "SKP_Silk_structs.h"\r
 #include "SKP_Silk_tables_NLSF_CB0_10.h"\r
+#include "SKP_Silk_tables.h"\r
 \r
 const SKP_uint16 SKP_Silk_NLSF_MSVQ_CB0_10_CDF[ NLSF_MSVQ_CB0_10_VECTORS + NLSF_MSVQ_CB0_10_STAGES ] =\r
 {\r
index 4aae58386b0191c953af18e534ed638895e6eea7..6a72cba3e94b9a1b67f0b13ded59588780ae03c0 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
index 895b346252592bda60ec4adc1aa41083bff8b50e..2491ec9d83390c49b4645d5cf5acc147b0bdff48 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -28,11 +28,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 /**********************************************/\r
 /* This file has been automatically generated */\r
 /*                                            */\r
-/* ROM usage:   246+3689 Words                */\r
+/* ROM usage:  0.51 + 7.38 kB                 */\r
 /**********************************************/\r
 \r
 #include "SKP_Silk_structs.h"\r
 #include "SKP_Silk_tables_NLSF_CB0_16.h"\r
+#include "SKP_Silk_tables.h"\r
 \r
 const SKP_uint16 SKP_Silk_NLSF_MSVQ_CB0_16_CDF[ NLSF_MSVQ_CB0_16_VECTORS + NLSF_MSVQ_CB0_16_STAGES ] =\r
 {\r
index b0dd766f972ed9e0b3cf1c613677dea3878de696..1581e5a372e0387e66fbb6bd77ab84c9331e044c 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
index 8c9abe409843549ddf8194c6db7c93425f1eece2..73e043028e55164bebcd6078df5781281643616f 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -28,11 +28,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 /**********************************************/\r
 /* This file has been automatically generated */\r
 /*                                            */\r
-/* ROM usage:    90+803 Words                 */\r
+/* ROM usage:  0.19 + 1.61 kB                 */\r
 /**********************************************/\r
 \r
 #include "SKP_Silk_structs.h"\r
 #include "SKP_Silk_tables_NLSF_CB1_10.h"\r
+#include "SKP_Silk_tables.h"\r
 \r
 const SKP_uint16 SKP_Silk_NLSF_MSVQ_CB1_10_CDF[ NLSF_MSVQ_CB1_10_VECTORS + NLSF_MSVQ_CB1_10_STAGES ] =\r
 {\r
index cdac82cb83396cb2a816685268e4cedc1d9c5469..7d110ff1f60a6dd3a458f9e3b56e78e68a0385c4 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
index 0780b2d044cd19fa90d923e62bdafc89b8f7a786..4d727ff7461685db710edf9cd34af64772a42d23 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -28,11 +28,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 /**********************************************/\r
 /* This file has been automatically generated */\r
 /*                                            */\r
-/* ROM usage:   134+1785 Words                */\r
+/* ROM usage:  0.29 + 3.57 kB                 */\r
 /**********************************************/\r
 \r
 #include "SKP_Silk_structs.h"\r
 #include "SKP_Silk_tables_NLSF_CB1_16.h"\r
+#include "SKP_Silk_tables.h"\r
 \r
 const SKP_uint16 SKP_Silk_NLSF_MSVQ_CB1_16_CDF[ NLSF_MSVQ_CB1_16_VECTORS + NLSF_MSVQ_CB1_16_STAGES ] =\r
 {\r
index 00d39286f69838b8e0eefcfdd50d7a7488fa89b2..f0539d398813f9c8aceef7c646fbe9fe9b9631d5 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
index 673d8378d00d88e4328fb9c193c7ffc2ad880222..f04ba36dea52200121659885268042826c6515df 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
index 48f57cbfd51e793389c8cbfe33be4e10440a1072..45213c4df57573ce91e5919473269df867b41662 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -35,19 +35,19 @@ extern "C"
 \r
 /* Piece-wise linear mapping from bitrate in kbps to coding quality in dB SNR */\r
 const SKP_int32 TargetRate_table_NB[ TARGET_RATE_TAB_SZ ] = {\r
-    0,      8000,   9000,   11000,  13000,  16000,  22000,  100000\r
+    0,      8000,   9000,   11000,  13000,  16000,  22000,  MAX_TARGET_RATE_BPS\r
 };\r
 const SKP_int32 TargetRate_table_MB[ TARGET_RATE_TAB_SZ ] = {\r
-    0,      10000,  12000,  14000,  17000,  21000,  28000,  100000\r
+    0,      10000,  12000,  14000,  17000,  21000,  28000,  MAX_TARGET_RATE_BPS\r
 };\r
 const SKP_int32 TargetRate_table_WB[ TARGET_RATE_TAB_SZ ] = {\r
-    0,      11000,  14000,  17000,  21000,  26000,  36000,  100000\r
+    0,      11000,  14000,  17000,  21000,  26000,  36000,  MAX_TARGET_RATE_BPS\r
 };\r
 const SKP_int32 TargetRate_table_SWB[ TARGET_RATE_TAB_SZ ] = {\r
-    0,      13000,  16000,  19000,  25000,  32000,  46000,  100000\r
+    0,      13000,  16000,  19000,  25000,  32000,  46000,  MAX_TARGET_RATE_BPS\r
 };\r
 const SKP_int32 SNR_table_Q1[ TARGET_RATE_TAB_SZ ] = {\r
-    19,     31,     35,     39,     43,     47,     54,     59\r
+    19,     31,     35,     39,     43,     47,     54,     64\r
 };\r
 \r
 const SKP_int32 SNR_table_one_bit_per_sample_Q7[ 4 ] = {\r
@@ -104,9 +104,6 @@ const SKP_int    SKP_Silk_NLSF_interpolation_factor_offset   = 4;
 const SKP_uint16 SKP_Silk_FrameTermination_CDF[ 5 ] = {0, 20000, 45000, 56000, 65535};\r
 const SKP_int    SKP_Silk_FrameTermination_offset   = 2;\r
 \r
-const SKP_uint16 SKP_Silk_FrameTermination_v4_CDF[ 6 ] = {0,   13107,   26214,   39321,   52428,   65535};\r
-const SKP_int    SKP_Silk_FrameTermination_v4_offset   = 4;\r
-\r
 /* Table for random seed */\r
 const SKP_uint16 SKP_Silk_Seed_CDF[ 5 ] = {0, 16384, 32768, 49152, 65535};\r
 const SKP_int    SKP_Silk_Seed_offset   = 2;\r
index 7f33fb96a9146bc05cf12f7130839ae16ffe07c5..fcf28d863094bc22f30b0751968bd181d5601e9b 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
index f97865199df3218afd2bc7556a8cdd186fdea497..263611e6127da608b99a4dabcd0f8b0d3148e817 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
index 5ada010c84548688953ce1f91142a0314bb2c2fa..f2aa0793f9099ffdfe1b944417596e7988b4e785 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -27,115 +27,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 \r
 #include "SKP_Silk_tables.h"\r
 \r
-const SKP_uint16 SKP_Silk_sign_CDF[ 36 ][ 3 ] = \r
-{\r
-{\r
-         0,  37840,  65535\r
-},\r
-{\r
-         0,  36944,  65535\r
-},\r
-{\r
-         0,  36251,  65535\r
-},\r
-{\r
-         0,  35304,  65535\r
-},\r
-{\r
-         0,  34715,  65535\r
-},\r
-{\r
-         0,  35503,  65535\r
-},\r
-{\r
-         0,  34529,  65535\r
-},\r
-{\r
-         0,  34296,  65535\r
-},\r
-{\r
-         0,  34016,  65535\r
-},\r
-{\r
-         0,  47659,  65535\r
-},\r
-{\r
-         0,  44945,  65535\r
-},\r
-{\r
-         0,  42503,  65535\r
-},\r
-{\r
-         0,  40235,  65535\r
-},\r
-{\r
-         0,  38569,  65535\r
-},\r
-{\r
-         0,  40254,  65535\r
-},\r
-{\r
-         0,  37851,  65535\r
-},\r
-{\r
-         0,  37243,  65535\r
-},\r
-{\r
-         0,  36595,  65535\r
-},\r
-{\r
-         0,  43410,  65535\r
-},\r
-{\r
-         0,  44121,  65535\r
-},\r
-{\r
-         0,  43127,  65535\r
-},\r
-{\r
-         0,  40978,  65535\r
-},\r
-{\r
-         0,  38845,  65535\r
-},\r
-{\r
-         0,  40433,  65535\r
-},\r
-{\r
-         0,  38252,  65535\r
-},\r
-{\r
-         0,  37795,  65535\r
-},\r
-{\r
-         0,  36637,  65535\r
-},\r
-{\r
-         0,  59159,  65535\r
-},\r
-{\r
-         0,  55630,  65535\r
-},\r
-{\r
-         0,  51806,  65535\r
-},\r
-{\r
-         0,  48073,  65535\r
-},\r
-{\r
-         0,  45036,  65535\r
-},\r
-{\r
-         0,  48416,  65535\r
-},\r
-{\r
-         0,  43857,  65535\r
-},\r
-{\r
-         0,  42678,  65535\r
-},\r
-{\r
-         0,  41146,  65535\r
-}\r
+const SKP_uint16 SKP_Silk_sign_CDF[ 36 ] = \r
+{\r
+         37840,  36944,  36251,  35304,\r
+         34715,  35503,  34529,  34296,\r
+         34016,  47659,  44945,  42503,\r
+         40235,  38569,  40254,  37851,\r
+         37243,  36595,  43410,  44121,\r
+         43127,  40978,  38845,  40433,\r
+         38252,  37795,  36637,  59159,\r
+         55630,  51806,  48073,  45036,\r
+         48416,  43857,  42678,  41146,\r
 };\r
 \r
index 5a50756370a25f1ce644d731d93a4b1e54d824f3..93cf454c33b31e8a1d80e9cb095ca6deccfef7c4 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
diff --git a/libs/silk/src/Silk_FIX.2008.vcproj b/libs/silk/src/Silk_FIX.2008.vcproj
deleted file mode 100644 (file)
index 5368179..0000000
+++ /dev/null
@@ -1,837 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>\r
-<VisualStudioProject\r
-       ProjectType="Visual C++"\r
-       Version="9.00"\r
-       Name="Silk_FIX"\r
-       ProjectGUID="{56B91D01-9150-4BBF-AFA1-5B68AB991B76}"\r
-       RootNamespace="Silk"\r
-       Keyword="Win32Proj"\r
-       TargetFrameworkVersion="131072"\r
-       >\r
-       <Platforms>\r
-               <Platform\r
-                       Name="Win32"\r
-               />\r
-               <Platform\r
-                       Name="x64"\r
-               />\r
-       </Platforms>\r
-       <ToolFiles>\r
-       </ToolFiles>\r
-       <Configurations>\r
-               <Configuration\r
-                       Name="Debug|Win32"\r
-                       OutputDirectory="$(ConfigurationName)"\r
-                       IntermediateDirectory="$(ConfigurationName)"\r
-                       ConfigurationType="4"\r
-                       CharacterSet="1"\r
-                       >\r
-                       <Tool\r
-                               Name="VCPreBuildEventTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCCustomBuildTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCXMLDataGeneratorTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCWebServiceProxyGeneratorTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCMIDLTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCCLCompilerTool"\r
-                               Optimization="0"\r
-                               FavorSizeOrSpeed="0"\r
-                               AdditionalIncludeDirectories="../interface"\r
-                               PreprocessorDefinitions="WIN32;_DEBUG;_LIB;"\r
-                               MinimalRebuild="true"\r
-                               BasicRuntimeChecks="3"\r
-                               RuntimeLibrary="1"\r
-                               FloatingPointModel="2"\r
-                               UsePrecompiledHeader="0"\r
-                               WarningLevel="3"\r
-                               Detect64BitPortabilityProblems="true"\r
-                               DebugInformationFormat="4"\r
-                       />\r
-                       <Tool\r
-                               Name="VCManagedResourceCompilerTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCResourceCompilerTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCPreLinkEventTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCLibrarianTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCALinkTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCXDCMakeTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCBscMakeTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCFxCopTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCPostBuildEventTool"\r
-                               CommandLine=""\r
-                       />\r
-               </Configuration>\r
-               <Configuration\r
-                       Name="Release|Win32"\r
-                       OutputDirectory="$(ConfigurationName)"\r
-                       IntermediateDirectory="$(ConfigurationName)"\r
-                       ConfigurationType="4"\r
-                       CharacterSet="1"\r
-                       WholeProgramOptimization="1"\r
-                       >\r
-                       <Tool\r
-                               Name="VCPreBuildEventTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCCustomBuildTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCXMLDataGeneratorTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCWebServiceProxyGeneratorTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCMIDLTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCCLCompilerTool"\r
-                               Optimization="2"\r
-                               InlineFunctionExpansion="0"\r
-                               FavorSizeOrSpeed="0"\r
-                               AdditionalIncludeDirectories="../interface"\r
-                               PreprocessorDefinitions="WIN32;NDEBUG;_LIB"\r
-                               GeneratePreprocessedFile="0"\r
-                               RuntimeLibrary="0"\r
-                               FloatingPointModel="2"\r
-                               UsePrecompiledHeader="0"\r
-                               WarningLevel="3"\r
-                               Detect64BitPortabilityProblems="true"\r
-                               DebugInformationFormat="3"\r
-                       />\r
-                       <Tool\r
-                               Name="VCManagedResourceCompilerTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCResourceCompilerTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCPreLinkEventTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCLibrarianTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCALinkTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCXDCMakeTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCBscMakeTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCFxCopTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCPostBuildEventTool"\r
-                               CommandLine=""\r
-                       />\r
-               </Configuration>\r
-               <Configuration\r
-                       Name="Debug|x64"\r
-                       OutputDirectory="$(PlatformName)\$(ConfigurationName)"\r
-                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"\r
-                       ConfigurationType="4"\r
-                       CharacterSet="1"\r
-                       >\r
-                       <Tool\r
-                               Name="VCPreBuildEventTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCCustomBuildTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCXMLDataGeneratorTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCWebServiceProxyGeneratorTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCMIDLTool"\r
-                               TargetEnvironment="3"\r
-                       />\r
-                       <Tool\r
-                               Name="VCCLCompilerTool"\r
-                               Optimization="0"\r
-                               FavorSizeOrSpeed="0"\r
-                               AdditionalIncludeDirectories="../interface"\r
-                               PreprocessorDefinitions="WIN32;_DEBUG;_LIB;"\r
-                               MinimalRebuild="true"\r
-                               BasicRuntimeChecks="3"\r
-                               RuntimeLibrary="1"\r
-                               FloatingPointModel="2"\r
-                               UsePrecompiledHeader="0"\r
-                               WarningLevel="3"\r
-                               Detect64BitPortabilityProblems="true"\r
-                               DebugInformationFormat="3"\r
-                       />\r
-                       <Tool\r
-                               Name="VCManagedResourceCompilerTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCResourceCompilerTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCPreLinkEventTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCLibrarianTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCALinkTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCXDCMakeTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCBscMakeTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCFxCopTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCPostBuildEventTool"\r
-                               CommandLine=""\r
-                       />\r
-               </Configuration>\r
-               <Configuration\r
-                       Name="Release|x64"\r
-                       OutputDirectory="$(PlatformName)\$(ConfigurationName)"\r
-                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"\r
-                       ConfigurationType="4"\r
-                       CharacterSet="1"\r
-                       WholeProgramOptimization="1"\r
-                       >\r
-                       <Tool\r
-                               Name="VCPreBuildEventTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCCustomBuildTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCXMLDataGeneratorTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCWebServiceProxyGeneratorTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCMIDLTool"\r
-                               TargetEnvironment="3"\r
-                       />\r
-                       <Tool\r
-                               Name="VCCLCompilerTool"\r
-                               Optimization="2"\r
-                               InlineFunctionExpansion="0"\r
-                               FavorSizeOrSpeed="0"\r
-                               AdditionalIncludeDirectories="../interface"\r
-                               PreprocessorDefinitions="WIN32;NDEBUG;_LIB"\r
-                               GeneratePreprocessedFile="0"\r
-                               RuntimeLibrary="0"\r
-                               FloatingPointModel="2"\r
-                               UsePrecompiledHeader="0"\r
-                               WarningLevel="3"\r
-                               Detect64BitPortabilityProblems="true"\r
-                               DebugInformationFormat="3"\r
-                       />\r
-                       <Tool\r
-                               Name="VCManagedResourceCompilerTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCResourceCompilerTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCPreLinkEventTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCLibrarianTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCALinkTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCXDCMakeTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCBscMakeTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCFxCopTool"\r
-                       />\r
-                       <Tool\r
-                               Name="VCPostBuildEventTool"\r
-                               CommandLine=""\r
-                       />\r
-               </Configuration>\r
-       </Configurations>\r
-       <References>\r
-       </References>\r
-       <Files>\r
-               <Filter\r
-                       Name="Source Files"\r
-                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"\r
-                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
-                       >\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_A2NLSF.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_allpass_int.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_ana_filt_bank_1.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_apply_sine_window.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_array_maxabs.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_autocorr.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_biquad.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_biquad_alt.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_burg_modified.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_bwexpander.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_bwexpander_32.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_CNG.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_code_signs.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_control_codec_FIX.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_corrMatrix_FIX.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_create_init_destroy.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_dec_API.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_decode_core.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_decode_frame.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_decode_indices_v4.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_decode_parameters.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_decode_parameters_v4.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_decode_pulses.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_decoder_set_fs.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_detect_SWB_input.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_enc_API.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_encode_frame_FIX.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_encode_parameters.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_encode_parameters_v4.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_encode_pulses.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_find_LPC_FIX.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_find_LTP_FIX.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_find_pitch_lags_FIX.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_find_pred_coefs_FIX.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_gain_quant.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_HP_variable_cutoff_FIX.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_init_encoder_FIX.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_inner_prod_aligned.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_interpolate.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_k2a.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_k2a_Q16.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_LBRR_reset.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_lin2log.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_log2lin.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_lowpass_int.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_lowpass_short.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_LP_variable_cutoff.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_LPC_inv_pred_gain.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_LPC_stabilize.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_LPC_synthesis_filter.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_LPC_synthesis_order16.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_LSF_cos_table.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_LTP_analysis_filter_FIX.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_LTP_scale_ctrl_FIX.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_MA.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_NLSF2A.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_NLSF2A_stable.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_NLSF_MSVQ_decode.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_NLSF_MSVQ_encode_FIX.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_NLSF_stabilize.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_NLSF_VQ_rate_distortion_FIX.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_NLSF_VQ_sum_error_FIX.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_NLSF_VQ_weights_laroia.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_noise_shape_analysis_FIX.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_NSQ.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_NSQ_del_dec.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_pitch_analysis_core.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_pitch_est_tables.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_PLC.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_prefilter_FIX.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_process_gains_FIX.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_process_NLSFs_FIX.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_pulses_to_bytes.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_quant_LTP_gains_FIX.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_range_coder.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_regularize_correlations_FIX.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_resample_1_2.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_resample_1_2_coarse.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_resample_1_2_coarsest.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_resample_1_3.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_resample_2_1_coarse.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_resample_2_3.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_resample_2_3_coarse.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_resample_2_3_coarsest.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_resample_2_3_rom.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_resample_3_1.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_resample_3_2.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_resample_3_2_rom.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_resample_3_4.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_resample_4_3.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_residual_energy16_FIX.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_residual_energy_FIX.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_scale_copy_vector16.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_scale_vector.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_schur.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_schur64.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_shell_coder.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_sigm_Q15.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_solve_LS_FIX.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_sort.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_sum_sqr_shift.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_tables_gain.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_tables_LTP.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_tables_NLSF_CB0_10.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_tables_NLSF_CB0_16.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_tables_NLSF_CB1_10.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_tables_NLSF_CB1_16.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_tables_other.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_tables_pitch_lag.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_tables_pulses_per_block.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_tables_sign.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_tables_type_offset.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_VAD.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_VQ_nearest_neighbor_FIX.c"\r
-                               >\r
-                       </File>\r
-               </Filter>\r
-               <Filter\r
-                       Name="Header Files"\r
-                       Filter="h;hpp;hxx;hm;inl;inc;xsd"\r
-                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"\r
-                       >\r
-                       <File\r
-                               RelativePath="..\interface\SKP_Silk_control.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_define.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_define_FIX.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath="..\interface\SKP_Silk_errors.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_Inlines.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_macros.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_main.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_main_FIX.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_perceptual_parameters_FIX.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_pitch_est_defines.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_PLC.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_resample_rom.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath="..\interface\SKP_Silk_SDK_API.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_SigProc_FIX.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_structs.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_structs_FIX.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_tables.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath="..\interface\SKP_Silk_typedef.h"\r
-                               >\r
-                       </File>\r
-               </Filter>\r
-       </Files>\r
-       <Globals>\r
-       </Globals>\r
-</VisualStudioProject>\r
diff --git a/libs/silk/src/Silk_FIX.2010.vcxproj b/libs/silk/src/Silk_FIX.2010.vcxproj
deleted file mode 100644 (file)
index a08d735..0000000
+++ /dev/null
@@ -1,272 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>\r
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
-  <ItemGroup Label="ProjectConfigurations">\r
-    <ProjectConfiguration Include="Debug|Win32">\r
-      <Configuration>Debug</Configuration>\r
-      <Platform>Win32</Platform>\r
-    </ProjectConfiguration>\r
-    <ProjectConfiguration Include="Debug|x64">\r
-      <Configuration>Debug</Configuration>\r
-      <Platform>x64</Platform>\r
-    </ProjectConfiguration>\r
-    <ProjectConfiguration Include="Release|Win32">\r
-      <Configuration>Release</Configuration>\r
-      <Platform>Win32</Platform>\r
-    </ProjectConfiguration>\r
-    <ProjectConfiguration Include="Release|x64">\r
-      <Configuration>Release</Configuration>\r
-      <Platform>x64</Platform>\r
-    </ProjectConfiguration>\r
-  </ItemGroup>\r
-  <PropertyGroup Label="Globals">\r
-    <ProjectName>Silk_FIX</ProjectName>\r
-    <ProjectGuid>{56B91D01-9150-4BBF-AFA1-5B68AB991B76}</ProjectGuid>\r
-    <RootNamespace>Silk</RootNamespace>\r
-    <Keyword>Win32Proj</Keyword>\r
-  </PropertyGroup>\r
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\r
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">\r
-    <ConfigurationType>StaticLibrary</ConfigurationType>\r
-    <CharacterSet>Unicode</CharacterSet>\r
-    <WholeProgramOptimization>true</WholeProgramOptimization>\r
-  </PropertyGroup>\r
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">\r
-    <ConfigurationType>StaticLibrary</ConfigurationType>\r
-    <CharacterSet>Unicode</CharacterSet>\r
-  </PropertyGroup>\r
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">\r
-    <ConfigurationType>StaticLibrary</ConfigurationType>\r
-    <CharacterSet>Unicode</CharacterSet>\r
-    <WholeProgramOptimization>true</WholeProgramOptimization>\r
-  </PropertyGroup>\r
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">\r
-    <ConfigurationType>StaticLibrary</ConfigurationType>\r
-    <CharacterSet>Unicode</CharacterSet>\r
-  </PropertyGroup>\r
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\r
-  <ImportGroup Label="ExtensionSettings">\r
-  </ImportGroup>\r
-  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">\r
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
-    <Import Project="..\..\..\w32\extlib.props" />\r
-  </ImportGroup>\r
-  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">\r
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
-    <Import Project="..\..\..\w32\extlib.props" />\r
-  </ImportGroup>\r
-  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">\r
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
-    <Import Project="..\..\..\w32\extlib.props" />\r
-  </ImportGroup>\r
-  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">\r
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
-    <Import Project="..\..\..\w32\extlib.props" />\r
-  </ImportGroup>\r
-  <PropertyGroup Label="UserMacros" />\r
-  <PropertyGroup>\r
-    <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>\r
-  </PropertyGroup>\r
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
-    <ClCompile>\r
-      <Optimization>Disabled</Optimization>\r
-      <FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>\r
-      <AdditionalIncludeDirectories>../interface;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
-      <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
-      <MinimalRebuild>true</MinimalRebuild>\r
-      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r
-      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\r
-      <FloatingPointModel>Fast</FloatingPointModel>\r
-      <WarningLevel>Level3</WarningLevel>\r
-    </ClCompile>\r
-  </ItemDefinitionGroup>\r
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
-    <ClCompile>\r
-      <Optimization>MaxSpeed</Optimization>\r
-      <InlineFunctionExpansion>Default</InlineFunctionExpansion>\r
-      <FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>\r
-      <AdditionalIncludeDirectories>../interface;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
-      <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
-      <PreprocessToFile>false</PreprocessToFile>\r
-      <PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>\r
-      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\r
-      <FloatingPointModel>Fast</FloatingPointModel>\r
-      <WarningLevel>Level3</WarningLevel>\r
-    </ClCompile>\r
-  </ItemDefinitionGroup>\r
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
-    <Midl>\r
-      <TargetEnvironment>X64</TargetEnvironment>\r
-    </Midl>\r
-    <ClCompile>\r
-      <Optimization>Disabled</Optimization>\r
-      <FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>\r
-      <AdditionalIncludeDirectories>../interface;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
-      <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
-      <MinimalRebuild>true</MinimalRebuild>\r
-      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r
-      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\r
-      <FloatingPointModel>Fast</FloatingPointModel>\r
-      <WarningLevel>Level3</WarningLevel>\r
-    </ClCompile>\r
-    <PostBuildEvent>\r
-      <Command>\r
-      </Command>\r
-    </PostBuildEvent>\r
-  </ItemDefinitionGroup>\r
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
-    <Midl>\r
-      <TargetEnvironment>X64</TargetEnvironment>\r
-    </Midl>\r
-    <ClCompile>\r
-      <Optimization>MaxSpeed</Optimization>\r
-      <InlineFunctionExpansion>Default</InlineFunctionExpansion>\r
-      <FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>\r
-      <AdditionalIncludeDirectories>../interface;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
-      <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
-      <PreprocessToFile>false</PreprocessToFile>\r
-      <PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>\r
-      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\r
-      <FloatingPointModel>Fast</FloatingPointModel>\r
-      <WarningLevel>Level3</WarningLevel>\r
-    </ClCompile>\r
-  </ItemDefinitionGroup>\r
-  <ItemGroup>\r
-    <ClCompile Include="SKP_Silk_A2NLSF.c" />\r
-    <ClCompile Include="SKP_Silk_allpass_int.c" />\r
-    <ClCompile Include="SKP_Silk_ana_filt_bank_1.c" />\r
-    <ClCompile Include="SKP_Silk_apply_sine_window.c" />\r
-    <ClCompile Include="SKP_Silk_array_maxabs.c" />\r
-    <ClCompile Include="SKP_Silk_autocorr.c" />\r
-    <ClCompile Include="SKP_Silk_biquad.c" />\r
-    <ClCompile Include="SKP_Silk_biquad_alt.c" />\r
-    <ClCompile Include="SKP_Silk_burg_modified.c" />\r
-    <ClCompile Include="SKP_Silk_bwexpander.c" />\r
-    <ClCompile Include="SKP_Silk_bwexpander_32.c" />\r
-    <ClCompile Include="SKP_Silk_CNG.c" />\r
-    <ClCompile Include="SKP_Silk_code_signs.c" />\r
-    <ClCompile Include="SKP_Silk_control_codec_FIX.c" />\r
-    <ClCompile Include="SKP_Silk_corrMatrix_FIX.c" />\r
-    <ClCompile Include="SKP_Silk_create_init_destroy.c" />\r
-    <ClCompile Include="SKP_Silk_dec_API.c" />\r
-    <ClCompile Include="SKP_Silk_decode_core.c" />\r
-    <ClCompile Include="SKP_Silk_decode_frame.c" />\r
-    <ClCompile Include="SKP_Silk_decode_indices_v4.c" />\r
-    <ClCompile Include="SKP_Silk_decode_parameters.c" />\r
-    <ClCompile Include="SKP_Silk_decode_parameters_v4.c" />\r
-    <ClCompile Include="SKP_Silk_decode_pulses.c" />\r
-    <ClCompile Include="SKP_Silk_decoder_set_fs.c" />\r
-    <ClCompile Include="SKP_Silk_detect_SWB_input.c" />\r
-    <ClCompile Include="SKP_Silk_enc_API.c" />\r
-    <ClCompile Include="SKP_Silk_encode_frame_FIX.c" />\r
-    <ClCompile Include="SKP_Silk_encode_parameters.c" />\r
-    <ClCompile Include="SKP_Silk_encode_parameters_v4.c" />\r
-    <ClCompile Include="SKP_Silk_encode_pulses.c" />\r
-    <ClCompile Include="SKP_Silk_find_LPC_FIX.c" />\r
-    <ClCompile Include="SKP_Silk_find_LTP_FIX.c" />\r
-    <ClCompile Include="SKP_Silk_find_pitch_lags_FIX.c" />\r
-    <ClCompile Include="SKP_Silk_find_pred_coefs_FIX.c" />\r
-    <ClCompile Include="SKP_Silk_gain_quant.c" />\r
-    <ClCompile Include="SKP_Silk_HP_variable_cutoff_FIX.c" />\r
-    <ClCompile Include="SKP_Silk_init_encoder_FIX.c" />\r
-    <ClCompile Include="SKP_Silk_inner_prod_aligned.c" />\r
-    <ClCompile Include="SKP_Silk_interpolate.c" />\r
-    <ClCompile Include="SKP_Silk_k2a.c" />\r
-    <ClCompile Include="SKP_Silk_k2a_Q16.c" />\r
-    <ClCompile Include="SKP_Silk_LBRR_reset.c" />\r
-    <ClCompile Include="SKP_Silk_lin2log.c" />\r
-    <ClCompile Include="SKP_Silk_log2lin.c" />\r
-    <ClCompile Include="SKP_Silk_lowpass_int.c" />\r
-    <ClCompile Include="SKP_Silk_lowpass_short.c" />\r
-    <ClCompile Include="SKP_Silk_LP_variable_cutoff.c" />\r
-    <ClCompile Include="SKP_Silk_LPC_inv_pred_gain.c" />\r
-    <ClCompile Include="SKP_Silk_LPC_stabilize.c" />\r
-    <ClCompile Include="SKP_Silk_LPC_synthesis_filter.c" />\r
-    <ClCompile Include="SKP_Silk_LPC_synthesis_order16.c" />\r
-    <ClCompile Include="SKP_Silk_LSF_cos_table.c" />\r
-    <ClCompile Include="SKP_Silk_LTP_analysis_filter_FIX.c" />\r
-    <ClCompile Include="SKP_Silk_LTP_scale_ctrl_FIX.c" />\r
-    <ClCompile Include="SKP_Silk_MA.c" />\r
-    <ClCompile Include="SKP_Silk_NLSF2A.c" />\r
-    <ClCompile Include="SKP_Silk_NLSF2A_stable.c" />\r
-    <ClCompile Include="SKP_Silk_NLSF_MSVQ_decode.c" />\r
-    <ClCompile Include="SKP_Silk_NLSF_MSVQ_encode_FIX.c" />\r
-    <ClCompile Include="SKP_Silk_NLSF_stabilize.c" />\r
-    <ClCompile Include="SKP_Silk_NLSF_VQ_rate_distortion_FIX.c" />\r
-    <ClCompile Include="SKP_Silk_NLSF_VQ_sum_error_FIX.c" />\r
-    <ClCompile Include="SKP_Silk_NLSF_VQ_weights_laroia.c" />\r
-    <ClCompile Include="SKP_Silk_noise_shape_analysis_FIX.c" />\r
-    <ClCompile Include="SKP_Silk_NSQ.c" />\r
-    <ClCompile Include="SKP_Silk_NSQ_del_dec.c" />\r
-    <ClCompile Include="SKP_Silk_pitch_analysis_core.c" />\r
-    <ClCompile Include="SKP_Silk_pitch_est_tables.c" />\r
-    <ClCompile Include="SKP_Silk_PLC.c" />\r
-    <ClCompile Include="SKP_Silk_prefilter_FIX.c" />\r
-    <ClCompile Include="SKP_Silk_process_gains_FIX.c" />\r
-    <ClCompile Include="SKP_Silk_process_NLSFs_FIX.c" />\r
-    <ClCompile Include="SKP_Silk_pulses_to_bytes.c" />\r
-    <ClCompile Include="SKP_Silk_quant_LTP_gains_FIX.c" />\r
-    <ClCompile Include="SKP_Silk_range_coder.c" />\r
-    <ClCompile Include="SKP_Silk_regularize_correlations_FIX.c" />\r
-    <ClCompile Include="SKP_Silk_resample_1_2.c" />\r
-    <ClCompile Include="SKP_Silk_resample_1_2_coarse.c" />\r
-    <ClCompile Include="SKP_Silk_resample_1_2_coarsest.c" />\r
-    <ClCompile Include="SKP_Silk_resample_1_3.c" />\r
-    <ClCompile Include="SKP_Silk_resample_2_1_coarse.c" />\r
-    <ClCompile Include="SKP_Silk_resample_2_3.c" />\r
-    <ClCompile Include="SKP_Silk_resample_2_3_coarse.c" />\r
-    <ClCompile Include="SKP_Silk_resample_2_3_coarsest.c" />\r
-    <ClCompile Include="SKP_Silk_resample_2_3_rom.c" />\r
-    <ClCompile Include="SKP_Silk_resample_3_1.c" />\r
-    <ClCompile Include="SKP_Silk_resample_3_2.c" />\r
-    <ClCompile Include="SKP_Silk_resample_3_2_rom.c" />\r
-    <ClCompile Include="SKP_Silk_resample_3_4.c" />\r
-    <ClCompile Include="SKP_Silk_resample_4_3.c" />\r
-    <ClCompile Include="SKP_Silk_residual_energy16_FIX.c" />\r
-    <ClCompile Include="SKP_Silk_residual_energy_FIX.c" />\r
-    <ClCompile Include="SKP_Silk_scale_copy_vector16.c" />\r
-    <ClCompile Include="SKP_Silk_scale_vector.c" />\r
-    <ClCompile Include="SKP_Silk_schur.c" />\r
-    <ClCompile Include="SKP_Silk_schur64.c" />\r
-    <ClCompile Include="SKP_Silk_shell_coder.c" />\r
-    <ClCompile Include="SKP_Silk_sigm_Q15.c" />\r
-    <ClCompile Include="SKP_Silk_solve_LS_FIX.c" />\r
-    <ClCompile Include="SKP_Silk_sort.c" />\r
-    <ClCompile Include="SKP_Silk_sum_sqr_shift.c" />\r
-    <ClCompile Include="SKP_Silk_tables_gain.c" />\r
-    <ClCompile Include="SKP_Silk_tables_LTP.c" />\r
-    <ClCompile Include="SKP_Silk_tables_NLSF_CB0_10.c" />\r
-    <ClCompile Include="SKP_Silk_tables_NLSF_CB0_16.c" />\r
-    <ClCompile Include="SKP_Silk_tables_NLSF_CB1_10.c" />\r
-    <ClCompile Include="SKP_Silk_tables_NLSF_CB1_16.c" />\r
-    <ClCompile Include="SKP_Silk_tables_other.c" />\r
-    <ClCompile Include="SKP_Silk_tables_pitch_lag.c" />\r
-    <ClCompile Include="SKP_Silk_tables_pulses_per_block.c" />\r
-    <ClCompile Include="SKP_Silk_tables_sign.c" />\r
-    <ClCompile Include="SKP_Silk_tables_type_offset.c" />\r
-    <ClCompile Include="SKP_Silk_VAD.c" />\r
-    <ClCompile Include="SKP_Silk_VQ_nearest_neighbor_FIX.c" />\r
-  </ItemGroup>\r
-  <ItemGroup>\r
-    <ClInclude Include="..\interface\SKP_Silk_control.h" />\r
-    <ClInclude Include="SKP_Silk_define.h" />\r
-    <ClInclude Include="SKP_Silk_define_FIX.h" />\r
-    <ClInclude Include="..\interface\SKP_Silk_errors.h" />\r
-    <ClInclude Include="SKP_Silk_Inlines.h" />\r
-    <ClInclude Include="SKP_Silk_macros.h" />\r
-    <ClInclude Include="SKP_Silk_main.h" />\r
-    <ClInclude Include="SKP_Silk_main_FIX.h" />\r
-    <ClInclude Include="SKP_Silk_perceptual_parameters_FIX.h" />\r
-    <ClInclude Include="SKP_Silk_pitch_est_defines.h" />\r
-    <ClInclude Include="SKP_Silk_PLC.h" />\r
-    <ClInclude Include="SKP_Silk_resample_rom.h" />\r
-    <ClInclude Include="..\interface\SKP_Silk_SDK_API.h" />\r
-    <ClInclude Include="SKP_Silk_SigProc_FIX.h" />\r
-    <ClInclude Include="SKP_Silk_structs.h" />\r
-    <ClInclude Include="SKP_Silk_structs_FIX.h" />\r
-    <ClInclude Include="SKP_Silk_tables.h" />\r
-    <ClInclude Include="..\interface\SKP_Silk_typedef.h" />\r
-  </ItemGroup>\r
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
-  <ImportGroup Label="ExtensionTargets">\r
-  </ImportGroup>\r
-</Project>
\ No newline at end of file
diff --git a/libs/silk/src/Silk_FIX.2010.vcxproj.filters b/libs/silk/src/Silk_FIX.2010.vcxproj.filters
deleted file mode 100644 (file)
index 2e9c4ec..0000000
+++ /dev/null
@@ -1,413 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>\r
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
-  <ItemGroup>\r
-    <Filter Include="Source Files">\r
-      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\r
-      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\r
-    </Filter>\r
-    <Filter Include="Header Files">\r
-      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r
-      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>\r
-    </Filter>\r
-  </ItemGroup>\r
-  <ItemGroup>\r
-    <ClCompile Include="SKP_Silk_A2NLSF.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_allpass_int.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_ana_filt_bank_1.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_apply_sine_window.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_array_maxabs.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_autocorr.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_biquad.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_biquad_alt.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_burg_modified.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_bwexpander.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_bwexpander_32.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_CNG.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_code_signs.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_control_codec_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_corrMatrix_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_create_init_destroy.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_dec_API.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_decode_core.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_decode_frame.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_decode_indices_v4.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_decode_parameters.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_decode_parameters_v4.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_decode_pulses.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_decoder_set_fs.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_detect_SWB_input.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_enc_API.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_encode_frame_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_encode_parameters.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_encode_parameters_v4.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_encode_pulses.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_find_LPC_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_find_LTP_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_find_pitch_lags_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_find_pred_coefs_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_gain_quant.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_HP_variable_cutoff_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_init_encoder_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_inner_prod_aligned.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_interpolate.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_k2a.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_k2a_Q16.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_LBRR_reset.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_lin2log.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_log2lin.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_lowpass_int.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_lowpass_short.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_LP_variable_cutoff.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_LPC_inv_pred_gain.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_LPC_stabilize.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_LPC_synthesis_filter.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_LPC_synthesis_order16.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_LSF_cos_table.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_LTP_analysis_filter_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_LTP_scale_ctrl_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_MA.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_NLSF2A.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_NLSF2A_stable.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_NLSF_MSVQ_decode.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_NLSF_MSVQ_encode_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_NLSF_stabilize.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_NLSF_VQ_rate_distortion_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_NLSF_VQ_sum_error_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_NLSF_VQ_weights_laroia.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_noise_shape_analysis_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_NSQ.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_NSQ_del_dec.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_pitch_analysis_core.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_pitch_est_tables.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_PLC.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_prefilter_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_process_gains_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_process_NLSFs_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_pulses_to_bytes.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_quant_LTP_gains_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_range_coder.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_regularize_correlations_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_resample_1_2.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_resample_1_2_coarse.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_resample_1_2_coarsest.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_resample_1_3.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_resample_2_1_coarse.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_resample_2_3.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_resample_2_3_coarse.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_resample_2_3_coarsest.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_resample_2_3_rom.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_resample_3_1.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_resample_3_2.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_resample_3_2_rom.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_resample_3_4.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_resample_4_3.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_residual_energy16_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_residual_energy_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_scale_copy_vector16.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_scale_vector.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_schur.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_schur64.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_shell_coder.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_sigm_Q15.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_solve_LS_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_sort.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_sum_sqr_shift.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_tables_gain.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_tables_LTP.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_tables_NLSF_CB0_10.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_tables_NLSF_CB0_16.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_tables_NLSF_CB1_10.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_tables_NLSF_CB1_16.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_tables_other.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_tables_pitch_lag.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_tables_pulses_per_block.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_tables_sign.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_tables_type_offset.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_VAD.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="SKP_Silk_VQ_nearest_neighbor_FIX.c">\r
-      <Filter>Source Files</Filter>\r
-    </ClCompile>\r
-  </ItemGroup>\r
-  <ItemGroup>\r
-    <ClInclude Include="..\interface\SKP_Silk_control.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
-    <ClInclude Include="SKP_Silk_define.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
-    <ClInclude Include="SKP_Silk_define_FIX.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
-    <ClInclude Include="..\interface\SKP_Silk_errors.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
-    <ClInclude Include="SKP_Silk_Inlines.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
-    <ClInclude Include="SKP_Silk_macros.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
-    <ClInclude Include="SKP_Silk_main.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
-    <ClInclude Include="SKP_Silk_main_FIX.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
-    <ClInclude Include="SKP_Silk_perceptual_parameters_FIX.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
-    <ClInclude Include="SKP_Silk_pitch_est_defines.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
-    <ClInclude Include="SKP_Silk_PLC.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
-    <ClInclude Include="SKP_Silk_resample_rom.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
-    <ClInclude Include="..\interface\SKP_Silk_SDK_API.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
-    <ClInclude Include="SKP_Silk_SigProc_FIX.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
-    <ClInclude Include="SKP_Silk_structs.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
-    <ClInclude Include="SKP_Silk_structs_FIX.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
-    <ClInclude Include="SKP_Silk_tables.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
-    <ClInclude Include="..\interface\SKP_Silk_typedef.h">\r
-      <Filter>Header Files</Filter>\r
-    </ClInclude>\r
-  </ItemGroup>\r
-</Project>
\ No newline at end of file
index 2e76109bb11acfc246e5649c5b84dcfb633e00b1..c60578a6ad67b6303a4035291beec3043738fa73 100644 (file)
                                RelativePath=".\SKP_Silk_A2NLSF.c"\r
                                >\r
                        </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_allpass_int.c"\r
-                               >\r
-                       </File>\r
                        <File\r
                                RelativePath=".\SKP_Silk_ana_filt_bank_1.c"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\SKP_Silk_apply_sine_window.c"\r
+                               RelativePath=".\SKP_Silk_apply_sine_window_new.c"\r
                                >\r
                        </File>\r
                        <File\r
                                RelativePath=".\SKP_Silk_code_signs.c"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath=".\SKP_Silk_control_audio_bandwidth.c"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath=".\SKP_Silk_control_codec_FIX.c"\r
                                >\r
                                RelativePath=".\SKP_Silk_decode_frame.c"\r
                                >\r
                        </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_decode_indices_v4.c"\r
-                               >\r
-                       </File>\r
                        <File\r
                                RelativePath=".\SKP_Silk_decode_parameters.c"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\SKP_Silk_decode_parameters_v4.c"\r
+                               RelativePath=".\SKP_Silk_decode_pitch.c"\r
                                >\r
                        </File>\r
                        <File\r
                                RelativePath=".\SKP_Silk_encode_parameters.c"\r
                                >\r
                        </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_encode_parameters_v4.c"\r
-                               >\r
-                       </File>\r
                        <File\r
                                RelativePath=".\SKP_Silk_encode_pulses.c"\r
                                >\r
                                RelativePath=".\SKP_Silk_log2lin.c"\r
                                >\r
                        </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_lowpass_int.c"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_lowpass_short.c"\r
-                               >\r
-                       </File>\r
                        <File\r
                                RelativePath=".\SKP_Silk_LP_variable_cutoff.c"\r
                                >\r
                                RelativePath=".\SKP_Silk_LPC_inv_pred_gain.c"\r
                                >\r
                        </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_LPC_stabilize.c"\r
-                               >\r
-                       </File>\r
                        <File\r
                                RelativePath=".\SKP_Silk_LPC_synthesis_filter.c"\r
                                >\r
                                RelativePath=".\SKP_Silk_process_NLSFs_FIX.c"\r
                                >\r
                        </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_pulses_to_bytes.c"\r
-                               >\r
-                       </File>\r
                        <File\r
                                RelativePath=".\SKP_Silk_quant_LTP_gains_FIX.c"\r
                                >\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\SKP_Silk_resample_1_2.c"\r
+                               RelativePath=".\SKP_Silk_resampler.c"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\SKP_Silk_resample_1_2_coarse.c"\r
+                               RelativePath=".\SKP_Silk_resampler_down2.c"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\SKP_Silk_resample_1_2_coarsest.c"\r
+                               RelativePath=".\SKP_Silk_resampler_down2_3.c"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\SKP_Silk_resample_1_3.c"\r
+                               RelativePath=".\SKP_Silk_resampler_down3.c"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\SKP_Silk_resample_2_1_coarse.c"\r
+                               RelativePath=".\SKP_Silk_resampler_private_AR2.c"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\SKP_Silk_resample_2_3.c"\r
+                               RelativePath=".\SKP_Silk_resampler_private_ARMA4.c"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\SKP_Silk_resample_2_3_coarse.c"\r
+                               RelativePath=".\SKP_Silk_resampler_private_copy.c"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\SKP_Silk_resample_2_3_coarsest.c"\r
+                               RelativePath=".\SKP_Silk_resampler_private_down4.c"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\SKP_Silk_resample_2_3_rom.c"\r
+                               RelativePath=".\SKP_Silk_resampler_private_down_FIR.c"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\SKP_Silk_resample_3_1.c"\r
+                               RelativePath=".\SKP_Silk_resampler_private_IIR_FIR.c"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\SKP_Silk_resample_3_2.c"\r
+                               RelativePath=".\SKP_Silk_resampler_private_up2_HQ.c"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\SKP_Silk_resample_3_2_rom.c"\r
+                               RelativePath=".\SKP_Silk_resampler_private_up4.c"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\SKP_Silk_resample_3_4.c"\r
+                               RelativePath=".\SKP_Silk_resampler_rom.c"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\SKP_Silk_resample_4_3.c"\r
+                               RelativePath=".\SKP_Silk_resampler_up2.c"\r
                                >\r
                        </File>\r
                        <File\r
                                RelativePath=".\SKP_Silk_VQ_nearest_neighbor_FIX.c"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath=".\SKP_Silk_warped_autocorrelation_FIX.c"\r
+                               >\r
+                       </File>\r
                </Filter>\r
                <Filter\r
                        Name="Header Files"\r
                        UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"\r
                        >\r
                        <File\r
-                               RelativePath="..\interface\SKP_Silk_control.h"\r
+                               RelativePath=".\SKP_Silk_common_pitch_est_defines.h"\r
                                >\r
                        </File>\r
                        <File\r
                                RelativePath=".\SKP_Silk_define.h"\r
                                >\r
                        </File>\r
-                       <File\r
-                               RelativePath=".\SKP_Silk_define_FIX.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
-                               RelativePath="..\interface\SKP_Silk_errors.h"\r
-                               >\r
-                       </File>\r
                        <File\r
                                RelativePath=".\SKP_Silk_Inlines.h"\r
                                >\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\SKP_Silk_perceptual_parameters_FIX.h"\r
+                               RelativePath=".\SKP_Silk_pitch_est_defines.h"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\SKP_Silk_pitch_est_defines.h"\r
+                               RelativePath=".\SKP_Silk_PLC.h"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\SKP_Silk_PLC.h"\r
+                               RelativePath=".\SKP_Silk_resampler_private.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\SKP_Silk_resampler_rom.h"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\SKP_Silk_resample_rom.h"\r
+                               RelativePath=".\SKP_Silk_resampler_structs.h"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\interface\SKP_Silk_SDK_API.h"\r
+                               RelativePath=".\SKP_Silk_setup_complexity.h"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\interface\SKP_Silk_typedef.h"\r
+                               RelativePath=".\SKP_Silk_tables_NLSF_CB0_10.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\SKP_Silk_tables_NLSF_CB0_16.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\SKP_Silk_tables_NLSF_CB1_10.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\SKP_Silk_tables_NLSF_CB1_16.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\SKP_Silk_tuning_parameters.h"\r
                                >\r
                        </File>\r
                </Filter>\r
index 6c0605e1ebfb424b810a6cb786af5e721d906d6d..b17f79655c2f5e200972384cae1d7b5ef9e3d4fb 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -25,6 +25,7 @@ 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
 /* Silk decoder test program */\r
 /*****************************/\r
@@ -43,37 +44,62 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #define MAX_BYTES_PER_FRAME     1024\r
 #define MAX_INPUT_FRAMES        5\r
 #define MAX_FRAME_LENGTH        480\r
+#define FRAME_LENGTH_MS         20\r
+#define MAX_API_FS_KHZ          48\r
 #define MAX_LBRR_DELAY          2\r
 \r
+#ifdef _SYSTEM_IS_BIG_ENDIAN\r
+/* Function to convert a little endian int16 to a */\r
+/* big endian int16 or vica verca                 */\r
+void swap_endian(\r
+    SKP_int16       vec[],\r
+    SKP_int         len\r
+)\r
+{\r
+    SKP_int i;\r
+    SKP_int16 tmp;\r
+    SKP_uint8 *p1, *p2;\r
+\r
+    for( i = 0; i < len; i++ ){\r
+        tmp = vec[ i ];\r
+        p1 = (SKP_uint8 *)&vec[ i ]; p2 = (SKP_uint8 *)&tmp;\r
+        p1[ 0 ] = p2[ 1 ]; p1[ 1 ] = p2[ 0 ];\r
+    }\r
+}\r
+#endif\r
+\r
+/* Seed for the random number generator, which is used for simulating packet loss */\r
+static SKP_int32 rand_seed = 1;\r
+\r
 static void print_usage(char* argv[]) {\r
     printf( "\nusage: %s in.bit out.pcm [settings]\n", argv[ 0 ] );\r
-    printf( "\nin.bit        : Bitstream input to decoder" );\r
-    printf( "\nout.pcm       : Speech output from decoder" );\r
+    printf( "\nstream.bit   : Bitstream input to decoder" );\r
+    printf( "\nout.pcm      : Speech output from decoder" );\r
     printf( "\n   settings:" );\r
-    printf( "\n-fs <kHz>     : Sampling rate of output signal in kHz; default: 24" );\r
-    printf( "\n-loss <perc>  : Simulated packet loss percentage (0-100); default: 0" );\r
+    printf( "\n-Fs_API <Hz> : Sampling rate of output signal in Hz; default: 24000" );\r
+    printf( "\n-loss <perc> : Simulated packet loss percentage (0-100); default: 0" );\r
     printf( "\n" );\r
 }\r
 \r
 int main( int argc, char* argv[] )\r
 {\r
     size_t    counter;\r
-    SKP_int   args, totPackets, i, k;\r
+    SKP_int32 args, totPackets, i, k;\r
     SKP_int16 ret, len, tot_len;\r
     SKP_int16 nBytes;\r
     SKP_uint8 payload[    MAX_BYTES_PER_FRAME * MAX_INPUT_FRAMES * ( MAX_LBRR_DELAY + 1 ) ];\r
-    SKP_uint8 FECpayload[ MAX_BYTES_PER_FRAME * MAX_INPUT_FRAMES ], *payloadPtr;\r
     SKP_uint8 *payloadEnd = NULL, *payloadToDec = NULL;\r
+    SKP_uint8 FECpayload[ MAX_BYTES_PER_FRAME * MAX_INPUT_FRAMES ], *payloadPtr;\r
     SKP_int16 nBytesFEC;\r
     SKP_int16 nBytesPerPacket[ MAX_LBRR_DELAY + 1 ], totBytes;\r
-    SKP_int16 out[ ( MAX_FRAME_LENGTH << 1 ) * MAX_INPUT_FRAMES ], *outPtr;\r
+    SKP_int16 out[ ( ( FRAME_LENGTH_MS * MAX_API_FS_KHZ ) << 1 ) * MAX_INPUT_FRAMES ], *outPtr;\r
     char      speechOutFileName[ 150 ], bitInFileName[ 150 ];\r
     FILE      *bitInFile, *speechOutFile;\r
-    SKP_int   Fs_kHz = 0;\r
+    SKP_int32 API_Fs_Hz = 0;\r
     SKP_int32 decSizeBytes;\r
     void      *psDec;\r
     float     loss_prob;\r
-    SKP_int   frames, lost, quiet;\r
+    SKP_int32 frames, lost, quiet;\r
     SKP_SILK_SDK_DecControlStruct DecControl;\r
 \r
     if( argc < 3 ) {\r
@@ -95,8 +121,8 @@ int main( int argc, char* argv[] )
         if( SKP_STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-loss" ) == 0 ) {\r
             sscanf( argv[ args + 1 ], "%f", &loss_prob );\r
             args += 2;\r
-        } else if( SKP_STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-fs" ) == 0 ) {\r
-            sscanf( argv[ args + 1 ], "%d", &Fs_kHz );\r
+        } else if( SKP_STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-Fs_API" ) == 0 ) {\r
+            sscanf( argv[ args + 1 ], "%d", &API_Fs_Hz );\r
             args += 2;\r
         } else if( SKP_STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-quiet" ) == 0 ) {\r
             quiet = 1;\r
@@ -121,19 +147,35 @@ int main( int argc, char* argv[] )
         printf( "Error: could not open input file %s\n", bitInFileName );\r
         exit( 0 );\r
     } \r
+\r
+    /* Check Silk header */\r
+    {\r
+        char header_buf[ 50 ];\r
+        counter = fread( header_buf, sizeof( char ), strlen( "#!SILK_V3" ), bitInFile );\r
+        header_buf[ strlen( "#!SILK_V3" ) ] = ( char )0; /* Terminate with a null character */\r
+        if( strcmp( header_buf, "#!SILK_V3" ) != 0 ) { \r
+            /* Non-equal strings */\r
+            printf( "Error: Wrong Header %s\n", header_buf );\r
+            exit( 0 );\r
+        }\r
+    }\r
+\r
     speechOutFile = fopen( speechOutFileName, "wb" );\r
     if( speechOutFile == NULL ) {\r
         printf( "Error: could not open output file %s\n", speechOutFileName );\r
         exit( 0 );\r
     }\r
 \r
-       /* Set the samplingrate that is requested for the output */\r
-    if( Fs_kHz == 0 ) {\r
-        DecControl.sampleRate = 24000;\r
+    /* Set the samplingrate that is requested for the output */\r
+    if( API_Fs_Hz == 0 ) {\r
+        DecControl.API_sampleRate = 24000;\r
     } else {\r
-        DecControl.sampleRate = Fs_kHz * 1000;\r
+        DecControl.API_sampleRate = API_Fs_Hz;\r
     }\r
 \r
+    /* Initialize to one frame per packet, for proper concealment before first packet arrives */\r
+    DecControl.framesPerPacket = 1;\r
+\r
     /* Create decoder */\r
     ret = SKP_Silk_SDK_Get_Decoder_Size( &decSizeBytes );\r
     if( ret ) {\r
@@ -154,10 +196,13 @@ int main( int argc, char* argv[] )
     for( i = 0; i < MAX_LBRR_DELAY; i++ ) {\r
         /* Read payload size */\r
         counter = fread( &nBytes, sizeof( SKP_int16 ), 1, bitInFile );\r
+#ifdef _SYSTEM_IS_BIG_ENDIAN\r
+        swap_endian( &nBytes, 1 );\r
+#endif\r
         /* Read payload */\r
         counter = fread( payloadEnd, sizeof( SKP_uint8 ), nBytes, bitInFile );\r
 \r
-        if( (SKP_int16)counter < nBytes ) {\r
+        if( ( SKP_int16 )counter < nBytes ) {\r
             break;\r
         }\r
         nBytesPerPacket[ i ] = nBytes;\r
@@ -167,18 +212,22 @@ int main( int argc, char* argv[] )
     while( 1 ) {\r
         /* Read payload size */\r
         counter = fread( &nBytes, sizeof( SKP_int16 ), 1, bitInFile );\r
+#ifdef _SYSTEM_IS_BIG_ENDIAN\r
+        swap_endian( &nBytes, 1 );\r
+#endif\r
         if( nBytes < 0 || counter < 1 ) {\r
             break;\r
         }\r
         \r
         /* Read payload */\r
         counter = fread( payloadEnd, sizeof( SKP_uint8 ), nBytes, bitInFile );\r
-        if( (SKP_int16)counter < nBytes ) {\r
+        if( ( SKP_int16 )counter < nBytes ) {\r
             break;\r
         }\r
 \r
         /* Simulate losses */\r
-        if( ( (float)rand() / (float)RAND_MAX >= loss_prob / 100 ) && counter > 0 ) {\r
+        rand_seed = SKP_RAND( rand_seed );\r
+        if( ( ( ( float )( ( rand_seed >> 16 ) + ( 1 << 15 ) ) ) / 65535.0f >= ( loss_prob / 100.0f ) ) && ( counter > 0 ) ) {\r
             nBytesPerPacket[ MAX_LBRR_DELAY ] = nBytes;\r
             payloadEnd                       += nBytes;\r
         } else {\r
@@ -193,7 +242,7 @@ int main( int argc, char* argv[] )
             payloadPtr = payload;\r
             for( i = 0; i < MAX_LBRR_DELAY; i++ ) {\r
                 if( nBytesPerPacket[ i + 1 ] > 0 ) {\r
-                    SKP_Silk_SDK_search_for_LBRR( psDec, payloadPtr, nBytesPerPacket[ i + 1 ], i + 1, FECpayload, &nBytesFEC );\r
+                    SKP_Silk_SDK_search_for_LBRR( payloadPtr, nBytesPerPacket[ i + 1 ], i + 1, FECpayload, &nBytesFEC );\r
                     if( nBytesFEC > 0 ) {\r
                         payloadToDec = FECpayload;\r
                         nBytes = nBytesFEC;\r
@@ -249,6 +298,9 @@ int main( int argc, char* argv[] )
         totPackets++;\r
 \r
         /* Write output to file */\r
+#ifdef _SYSTEM_IS_BIG_ENDIAN   \r
+        swap_endian( out, tot_len );\r
+#endif\r
         fwrite( out, sizeof( SKP_int16 ), tot_len, speechOutFile );\r
 \r
         /* Update buffer */\r
@@ -261,7 +313,7 @@ int main( int argc, char* argv[] )
         SKP_memmove( nBytesPerPacket, &nBytesPerPacket[ 1 ], MAX_LBRR_DELAY * sizeof( SKP_int16 ) );\r
 \r
         if( !quiet ) {\r
-            fprintf( stderr, "\rFrames decoded:              %d", totPackets );\r
+            fprintf( stderr, "\rPackets decoded:             %d", totPackets );\r
         }\r
     }\r
 \r
@@ -275,7 +327,7 @@ int main( int argc, char* argv[] )
             payloadPtr = payload;\r
             for( i = 0; i < MAX_LBRR_DELAY; i++ ) {\r
                 if( nBytesPerPacket[ i + 1 ] > 0 ) {\r
-                    SKP_Silk_SDK_search_for_LBRR( psDec, payloadPtr, nBytesPerPacket[ i + 1 ], i + 1, FECpayload, &nBytesFEC );\r
+                    SKP_Silk_SDK_search_for_LBRR( payloadPtr, nBytesPerPacket[ i + 1 ], i + 1, FECpayload, &nBytesFEC );\r
                     if( nBytesFEC > 0 ) {\r
                         payloadToDec = FECpayload;\r
                         nBytes = nBytesFEC;\r
@@ -332,6 +384,9 @@ int main( int argc, char* argv[] )
         totPackets++;\r
 \r
         /* Write output to file */\r
+#ifdef _SYSTEM_IS_BIG_ENDIAN   \r
+        swap_endian( out, tot_len );\r
+#endif\r
         fwrite( out, sizeof( SKP_int16 ), tot_len, speechOutFile );\r
 \r
         /* Update Buffer */\r
index 0e4dd1c6b297a43f77acb64a509b36d8ab2b9ea6..5595af5d8ce67bc6230cd0f68d75d5247ccf2704 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -25,6 +25,7 @@ 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
 /* Silk encoder test program */\r
 /*****************************/\r
@@ -44,43 +45,70 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #define MAX_INPUT_FRAMES        5\r
 #define MAX_LBRR_DELAY          2\r
 #define MAX_FRAME_LENGTH        480\r
+#define FRAME_LENGTH_MS         20\r
+#define MAX_API_FS_KHZ          48\r
+\r
+#ifdef _SYSTEM_IS_BIG_ENDIAN\r
+/* Function to convert a little endian int16 to a */\r
+/* big endian int16 or vica verca                 */\r
+void swap_endian(\r
+    SKP_int16       vec[],              /*  I/O array of */\r
+    SKP_int         len                 /*  I   length      */\r
+)\r
+{\r
+    SKP_int i;\r
+    SKP_int16 tmp;\r
+    SKP_uint8 *p1, *p2;\r
+\r
+    for( i = 0; i < len; i++ ){\r
+        tmp = vec[ i ];\r
+        p1 = (SKP_uint8 *)&vec[ i ]; p2 = (SKP_uint8 *)&tmp;\r
+        p1[ 0 ] = p2[ 1 ]; p1[ 1 ] = p2[ 0 ];\r
+    }\r
+}\r
+#endif\r
 \r
 static void print_usage( char* argv[] ) {\r
     printf( "\nusage: %s in.pcm out.bit [settings]\n", argv[ 0 ] );\r
-    printf( "\nin.pcm              : Speech input to encoder" );\r
-    printf( "\nout.bit             : Bitstream output from encoder" );\r
+    printf( "\nin.pcm               : Speech input to encoder" );\r
+    printf( "\nstream.bit           : Bitstream output from encoder" );\r
     printf( "\n   settings:" );\r
-    printf( "\n-fs <kHz>           : Sampling rate in kHz, default: 24" );\r
-    printf( "\n-packetlength <ms>  : Packet interval in ms, default: 20" );\r
-    printf( "\n-rate <bps>         : Target bitrate; default: 25000" );\r
-    printf( "\n-loss <perc>        : Uplink loss estimate, in percent (0-100); default: 0" );\r
-    printf( "\n-inbandFEC <flag>   : Enable inband FEC usage (0/1); default: 0" );\r
-    printf( "\n-complexity <comp>  : Set complexity, 0: low, 1: medium, 2: high; default: 2" );\r
-    printf( "\n-DTX <flag>         : Enable DTX (0/1); default: 0" );\r
-    printf( "\n-quiet              : Print only some basic values" );\r
+    printf( "\n-Fs_API <Hz>         : API sampling rate in Hz, default: 24000" );\r
+    printf( "\n-Fs_maxInternal <Hz> : Maximum internal sampling rate in Hz, default: 24000" ); \r
+    printf( "\n-packetlength <ms>   : Packet interval in ms, default: 20" );\r
+    printf( "\n-rate <bps>          : Target bitrate; default: 25000" );\r
+    printf( "\n-loss <perc>         : Uplink loss estimate, in percent (0-100); default: 0" );\r
+    printf( "\n-inbandFEC <flag>    : Enable inband FEC usage (0/1); default: 0" );\r
+    printf( "\n-complexity <comp>   : Set complexity, 0: low, 1: medium, 2: high; default: 2" );\r
+    printf( "\n-DTX <flag>          : Enable DTX (0/1); default: 0" );\r
+    printf( "\n-quiet               : Print only some basic values" );\r
     printf( "\n");\r
 }\r
 \r
 int main( int argc, char* argv[] )\r
 {\r
     size_t    counter;\r
-    SKP_int   k, args, totPackets, totActPackets, ret;\r
+    SKP_int32 k, args, totPackets, totActPackets, ret;\r
     SKP_int16 nBytes;\r
-    double    sumBytes, sumWBytes, sumActBytes, avg_rate, act_rate, wght_rate, nrg;\r
+    double    sumBytes, sumActBytes, avg_rate, act_rate, nrg;\r
     SKP_uint8 payload[ MAX_BYTES_PER_FRAME * MAX_INPUT_FRAMES ];\r
-    SKP_int16 in[ MAX_FRAME_LENGTH * MAX_INPUT_FRAMES ];\r
+    SKP_int16 in[ FRAME_LENGTH_MS * MAX_API_FS_KHZ * MAX_INPUT_FRAMES ];\r
     char      speechInFileName[ 150 ], bitOutFileName[ 150 ];\r
     FILE      *bitOutFile, *speechInFile;\r
     SKP_int32 encSizeBytes;\r
     void      *psEnc;\r
+#ifdef _SYSTEM_IS_BIG_ENDIAN\r
+    SKP_int16 nBytes_LE;\r
+#endif\r
 \r
     /* default settings */\r
-    SKP_int   fs_kHz = 24;\r
-    SKP_int   targetRate_bps = 25000;\r
-    SKP_int   packetSize_ms = 20;\r
-    SKP_int   frameSizeReadFromFile_ms = 20;\r
-    SKP_int   packetLoss_perc = 0, complexity_mode = 2, smplsSinceLastPacket;\r
-    SKP_int   INBandFec_enabled = 0, DTX_enabled = 0, quiet = 0;\r
+    SKP_int32 API_fs_Hz = 24000;\r
+    SKP_int32 max_internal_fs_Hz = 0;\r
+    SKP_int32 targetRate_bps = 25000;\r
+    SKP_int32 packetSize_ms = 20;\r
+    SKP_int32 frameSizeReadFromFile_ms = 20;\r
+    SKP_int32 packetLoss_perc = 0, complexity_mode = 2, smplsSinceLastPacket;\r
+    SKP_int32 INBandFEC_enabled = 0, DTX_enabled = 0, quiet = 0;\r
     SKP_SILK_SDK_EncControlStruct encControl; // Struct for input to encoder\r
         \r
     if( argc < 3 ) {\r
@@ -95,8 +123,11 @@ int main( int argc, char* argv[] )
     strcpy( bitOutFileName,   argv[ args ] );\r
     args++;\r
     while( args < argc ) {\r
-        if( SKP_STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-fs" ) == 0 ) {\r
-            sscanf( argv[ args + 1 ], "%d", &fs_kHz );\r
+        if( SKP_STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-Fs_API" ) == 0 ) {\r
+            sscanf( argv[ args + 1 ], "%d", &API_fs_Hz );\r
+            args += 2;\r
+        } else if( SKP_STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-Fs_maxInternal" ) == 0 ) {\r
+            sscanf( argv[ args + 1 ], "%d", &max_internal_fs_Hz );\r
             args += 2;\r
         } else if( SKP_STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-packetlength" ) == 0 ) {\r
             sscanf( argv[ args + 1 ], "%d", &packetSize_ms );\r
@@ -111,7 +142,7 @@ int main( int argc, char* argv[] )
             sscanf( argv[ args + 1 ], "%d", &complexity_mode );\r
             args += 2;\r
         } else if( SKP_STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-inbandFEC" ) == 0 ) {\r
-            sscanf( argv[ args + 1 ], "%d", &INBandFec_enabled );\r
+            sscanf( argv[ args + 1 ], "%d", &INBandFEC_enabled );\r
             args += 2;\r
         } else if( SKP_STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-DTX") == 0 ) {\r
             sscanf( argv[ args + 1 ], "%d", &DTX_enabled );\r
@@ -126,18 +157,27 @@ int main( int argc, char* argv[] )
         }\r
     }\r
 \r
+    /* If no max internal is specified, set to minimum of API fs and 24 kHz */\r
+    if( max_internal_fs_Hz == 0 ) {\r
+        max_internal_fs_Hz = 24000;\r
+        if( API_fs_Hz < max_internal_fs_Hz ) {\r
+            max_internal_fs_Hz = API_fs_Hz;\r
+        }\r
+    }\r
+\r
     /* Print options */\r
     if( !quiet ) {\r
         printf("******************* Silk Encoder v %s ****************\n", SKP_Silk_SDK_get_version());\r
         printf("******************* Compiled for %d bit cpu ********* \n", (int)sizeof(void*) * 8 );\r
-        printf( "Input:                       %s\n",        speechInFileName );\r
-        printf( "Output:                      %s\n",        bitOutFileName );\r
-        printf( "Sampling rate:               %d kHz\n",    fs_kHz);\r
-        printf( "Packet interval:             %d ms\n",     packetSize_ms);\r
-        printf( "Inband FEC used:             %d\n",        INBandFec_enabled);\r
-        printf( "DTX used:                    %d\n",        DTX_enabled);\r
-        printf( "Complexity:                  %d\n",        complexity_mode);\r
-        printf( "Target bitrate:              %d bps\n",    targetRate_bps);\r
+        printf( "Input:                          %s\n",     speechInFileName );\r
+        printf( "Output:                         %s\n",     bitOutFileName );\r
+        printf( "API sampling rate:              %d Hz\n",  API_fs_Hz );\r
+        printf( "Maximum internal sampling rate: %d Hz\n",  max_internal_fs_Hz );\r
+        printf( "Packet interval:                %d ms\n",  packetSize_ms );\r
+        printf( "Inband FEC used:                %d\n",     INBandFEC_enabled );\r
+        printf( "DTX used:                       %d\n",     DTX_enabled );\r
+        printf( "Complexity:                     %d\n",     complexity_mode );\r
+        printf( "Target bitrate:                 %d bps\n", targetRate_bps );\r
     }\r
 \r
     /* Open files */\r
@@ -152,6 +192,12 @@ int main( int argc, char* argv[] )
         exit( 0 );\r
     }\r
 \r
+    /* Add Silk header to stream */\r
+    {\r
+        static const char Silk_header[] = "#!SILK_V3";\r
+        fwrite( Silk_header, sizeof( char ), strlen( Silk_header ), bitOutFile );\r
+    }\r
+\r
     /* Create Encoder */\r
     ret = SKP_Silk_SDK_Get_Encoder_Size( &encSizeBytes );\r
     if( ret ) {\r
@@ -159,7 +205,7 @@ int main( int argc, char* argv[] )
     }\r
 \r
     psEnc = malloc( encSizeBytes );\r
-    \r
+\r
     /* Reset Encoder */\r
     ret = SKP_Silk_SDK_InitEncoder( psEnc, &encControl );\r
     if( ret ) {\r
@@ -167,16 +213,17 @@ int main( int argc, char* argv[] )
     }\r
     \r
     /* Set Encoder parameters */\r
-    encControl.sampleRate           = fs_kHz * 1000;\r
-    encControl.packetSize           = packetSize_ms * fs_kHz;\r
-    encControl.packetLossPercentage = packetLoss_perc;\r
-    encControl.useInBandFEC         = INBandFec_enabled;\r
-    encControl.useDTX               = DTX_enabled;\r
-    encControl.complexity           = complexity_mode;\r
-    encControl.bitRate              = targetRate_bps;\r
+    encControl.API_sampleRate        = API_fs_Hz;\r
+    encControl.maxInternalSampleRate = max_internal_fs_Hz;\r
+    encControl.packetSize            = ( packetSize_ms * API_fs_Hz ) / 1000;\r
+    encControl.packetLossPercentage  = packetLoss_perc;\r
+    encControl.useInBandFEC          = INBandFEC_enabled;\r
+    encControl.useDTX                = DTX_enabled;\r
+    encControl.complexity            = complexity_mode;\r
+    encControl.bitRate               = ( targetRate_bps > 0 ? targetRate_bps : 0 );\r
 \r
-    if( fs_kHz > 24 || fs_kHz < 0 ) {\r
-        printf( "\nError: Sampling rate = %d out of range, valid range 8 - 24 \n \n", fs_kHz );\r
+    if( API_fs_Hz > MAX_API_FS_KHZ * 1000 || API_fs_Hz < 0 ) {\r
+        printf( "\nError: API sampling rate = %d out of range, valid range 8000 - 48000 \n \n", API_fs_Hz );\r
         exit( 0 );\r
     }\r
 \r
@@ -185,12 +232,14 @@ int main( int argc, char* argv[] )
     smplsSinceLastPacket = 0;\r
     sumBytes             = 0.0;\r
     sumActBytes          = 0.0;\r
-    sumWBytes            = 0.0;\r
     \r
     while( 1 ) {\r
-        /* Read input to file */\r
-        counter = fread( in, sizeof( SKP_int16 ), frameSizeReadFromFile_ms * fs_kHz, speechInFile );\r
-        if( (SKP_int)counter < frameSizeReadFromFile_ms * fs_kHz ) {\r
+        /* Read input from file */\r
+        counter = fread( in, sizeof( SKP_int16 ), ( frameSizeReadFromFile_ms * API_fs_Hz ) / 1000, speechInFile );\r
+#ifdef _SYSTEM_IS_BIG_ENDIAN\r
+        swap_endian( in, counter );\r
+#endif\r
+        if( (SKP_int)counter < ( ( frameSizeReadFromFile_ms * API_fs_Hz ) / 1000 ) ) {\r
             break;\r
         }\r
 \r
@@ -205,28 +254,33 @@ int main( int argc, char* argv[] )
         }\r
 \r
         /* Get packet size */\r
-        packetSize_ms = (SKP_int)( 1000 * encControl.packetSize ) / encControl.sampleRate;\r
+        packetSize_ms = ( SKP_int )( ( 1000 * ( SKP_int32 )encControl.packetSize ) / encControl.API_sampleRate );\r
 \r
-        smplsSinceLastPacket += (SKP_int)counter;\r
+        smplsSinceLastPacket += ( SKP_int )counter;\r
         \r
-        if( ( smplsSinceLastPacket / fs_kHz ) == packetSize_ms ) {\r
+        if( ( ( 1000 * smplsSinceLastPacket ) / API_fs_Hz ) == packetSize_ms ) {\r
             /* Sends a dummy zero size packet in case of DTX period  */\r
             /* to make it work with the decoder test program.        */\r
             /* In practice should be handled by RTP sequence numbers */\r
             totPackets++;\r
             sumBytes  += nBytes;\r
-            sumWBytes += pow( (double)nBytes, 10.0 );\r
             nrg = 0.0;\r
-            for( k = 0; k < (SKP_int)counter; k++ ) {\r
+            for( k = 0; k < ( SKP_int )counter; k++ ) {\r
                 nrg += in[ k ] * (double)in[ k ];\r
             }\r
-            if( ( nrg / (SKP_int)counter ) > 1e3 ) {\r
+            if( ( nrg / ( SKP_int )counter ) > 1e3 ) {\r
                 sumActBytes += nBytes;\r
                 totActPackets++;\r
             }\r
 \r
             /* Write payload size */\r
+#ifdef _SYSTEM_IS_BIG_ENDIAN\r
+            nBytes_LE = nBytes;\r
+            swap_endian( &nBytes_LE, 1 );\r
+            fwrite( &nBytes_LE, sizeof( SKP_int16 ), 1, bitOutFile );\r
+#else\r
             fwrite( &nBytes, sizeof( SKP_int16 ), 1, bitOutFile );\r
+#endif\r
 \r
             /* Write payload */\r
             fwrite( payload, sizeof( SKP_uint8 ), nBytes, bitOutFile );\r
@@ -244,9 +298,6 @@ int main( int argc, char* argv[] )
     /* Write payload size */\r
     fwrite( &nBytes, sizeof( SKP_int16 ), 1, bitOutFile );\r
 \r
-    /* Query encoder */\r
-    packetSize_ms = (SKP_int)( 1000 * encControl.packetSize ) / encControl.sampleRate;\r
-\r
     /* Free Encoder */\r
     free( psEnc );\r
 \r
@@ -255,15 +306,13 @@ int main( int argc, char* argv[] )
 \r
     avg_rate  = 8.0 / packetSize_ms * sumBytes       / totPackets;\r
     act_rate  = 8.0 / packetSize_ms * sumActBytes    / totActPackets;\r
-    wght_rate = 8.0 / packetSize_ms * pow( sumWBytes / totPackets, 0.1 );\r
     if( !quiet ) {\r
         printf( "\nAverage bitrate:             %.3f kbps", avg_rate  );\r
         printf( "\nActive bitrate:              %.3f kbps", act_rate  );\r
-        printf( "\nWeighted bitrate:            %.3f kbps", wght_rate );\r
         printf( "\n\n" );\r
     } else {\r
-        /* print average and weighted bitrates */\r
-        printf( "%.3f %.3f %.3f \n", avg_rate, act_rate, wght_rate );\r
+        /* print average and active bitrates */\r
+        printf( "%.3f %.3f \n", avg_rate, act_rate );\r
     }\r
     return 0;\r
 }\r
index adf960acb78b30f07d4c74f004714a21c9275496..162769788b0e48f117e5d4743ce31b31be57b82d 100644 (file)
@@ -61,7 +61,7 @@
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
-                               OutputFile="SignalCompare_debug.exe"\r
+                               OutputFile="$(SolutionDir)SignalCompare_debug.exe"\r
                                LinkIncremental="2"\r
                                AdditionalLibraryDirectories=""\r
                                IgnoreAllDefaultLibraries="false"\r
index 04445848920b62562d3f80c09cce6b89db64f3ab..d0eb34dd7124f9a4f48f6745d9c0b5f6f16237fe 100644 (file)
@@ -1,5 +1,5 @@
 /***********************************************************************\r
-Copyright (c) 2006-2010, Skype Limited. All rights reserved. \r
+Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
 Redistribution and use in source and binary forms, with or without \r
 modification, (subject to the limitations in the disclaimer below) \r
 are permitted provided that the following conditions are met:\r
@@ -30,7 +30,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */\r
 \r
 #ifdef _WIN32\r
-#define _CRT_SECURE_NO_DEPRECATE       1\r
+#define _CRT_SECURE_NO_DEPRECATE    1\r
 #endif\r
 \r
 #include <stdio.h>\r
@@ -40,12 +40,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 \r
 #include "SKP_Silk_SigProc_FIX.h"\r
 \r
-#define FRAME_LENGTH_MS                        10\r
-#define WIN_LENGTH_MS                  20\r
-#define BW_EXPANSION                   0.7f\r
+#define FRAME_LENGTH_MS         10\r
+#define WIN_LENGTH_MS           20\r
+#define BW_EXPANSION            0.7f\r
 \r
-#define MAX_FS_KHZ                             24\r
-#define LPC_ORDER                              10\r
+#define MAX_FS_KHZ              48\r
+#define LPC_ORDER               10\r
+#define SNR_THRESHOLD           15.0\r
 \r
 #ifdef  __cplusplus\r
 extern "C"\r
@@ -53,30 +54,30 @@ extern "C"
 #endif\r
 /* Internally used functions */\r
 void Autocorrelation( \r
-       SKP_float *results,                                     /* o    result (length correlationCount)                        */\r
-       const SKP_float *inputData,                     /* i    input data to correlate                                         */\r
-       SKP_int inputDataSize,                          /* i    length of input                                                         */\r
-       SKP_int correlationCount                        /* i    number of correlation taps to compute           */\r
+    SKP_float *results,                 /* o    result (length correlationCount)            */\r
+    const SKP_float *inputData,         /* i    input data to correlate                     */\r
+    SKP_int inputDataSize,              /* i    length of input                             */\r
+    SKP_int correlationCount            /* i    number of correlation taps to compute       */\r
 );\r
 \r
 /* inner product of two SKP_float arrays, with result as double */\r
 double Inner_product( \r
-       const SKP_float         *data1, \r
-       const SKP_float         *data2, \r
-       SKP_int                         dataSize\r
+    const SKP_float     *data1, \r
+    const SKP_float     *data2, \r
+    SKP_int             dataSize\r
 );\r
 /* Solve the normal equations using the Levinson-Durbin recursion */\r
-SKP_float Levinsondurbin(                              /* O    prediction error energy                                         */\r
-       SKP_float               A[],                            /* O    prediction coefficients [order]                         */\r
-       const SKP_float corr[],                         /* I    input auto-correlations [order + 1]                     */\r
-       const SKP_int   order                           /* I    prediction order                                                        */\r
+SKP_float Levinsondurbin(               /* O    prediction error energy                     */\r
+    SKP_float       A[],                /* O    prediction coefficients [order]             */\r
+    const SKP_float corr[],             /* I    input auto-correlations [order + 1]         */\r
+    const SKP_int   order               /* I    prediction order                            */\r
 );\r
 \r
 /* Chirp (bw expand) LP AR filter */\r
 void Bwexpander( \r
-       SKP_float *ar,                                          /* io   AR filter to be expanded (without leading 1)   */\r
-       const SKP_int d,                                        /* i    length of ar                                                                    */\r
-       const SKP_float chirp                           /* i    chirp factor (typically in range (0..1) )               */\r
+    SKP_float *ar,                      /* io   AR filter to be expanded (without leading 1)    */\r
+    const SKP_int d,                    /* i    length of ar                                    */\r
+    const SKP_float chirp               /* i    chirp factor (typically in range (0..1) )       */\r
 );\r
 \r
 #ifdef  __cplusplus\r
@@ -84,283 +85,292 @@ void Bwexpander(
 #endif\r
 \r
 static void print_usage(char* argv[]) {\r
-       printf("\nusage: %s ref.pcm test.pcm [settings]\n", argv[ 0 ]);\r
-       printf("\nref.pcm       : Reference file");\r
-       printf("\ntest.pcm      : File to be tested, should be of same length as ref.pcm");\r
-       printf("\n   settings:");\r
-       printf("\n-diff         : Only determine bit-exactness");\r
-       printf("\n-fs <kHz>     : Sampling rate in kHz, max: %d; default: 24", MAX_FS_KHZ);\r
-       printf("\n");\r
+    printf("\nusage: %s ref.pcm test.pcm [settings]\n", argv[ 0 ]);\r
+    printf("\nref.pcm       : Reference file");\r
+    printf("\ntest.pcm      : File to be tested, should be of same length as ref.pcm");\r
+    printf("\n   settings:");\r
+    printf("\n-diff         : Only determine bit-exactness");\r
+    printf("\n-fs <Hz>      : Sampling rate in Hz, max: %d; default: 48000", MAX_FS_KHZ * 1000 );\r
+    printf("\n");\r
 }\r
 \r
+\r
 int main(int argc, char* argv[])\r
 {\r
-       SKP_int   args, n, i, counterRef, counterTest;\r
-       char      testInFileName[150], refInFileName[150];\r
-       FILE      *refInFile, *testInFile;\r
-       SKP_int   nFrames = 0, isUnequal = 0;\r
-       SKP_int   diff = 0, Fs_kHz = 24;                /* defaults */\r
-       SKP_float c, refWhtnd, testWhtnd, refNrg, diffNrg;\r
-       double    SNR = 0.0;\r
-       SKP_int16 refIn[WIN_LENGTH_MS * MAX_FS_KHZ], testIn[WIN_LENGTH_MS * MAX_FS_KHZ];\r
-       SKP_float refWin[WIN_LENGTH_MS * MAX_FS_KHZ], testWin[WIN_LENGTH_MS * MAX_FS_KHZ];\r
-       SKP_float autoCorr[LPC_ORDER + 1], LPC_Coef[LPC_ORDER];\r
-\r
-       if (argc < 3) {\r
-               print_usage(argv);\r
-               exit(0);\r
-       } \r
-\r
-       /* get arguments */\r
-       args = 1;\r
-       strcpy(refInFileName, argv[args]);\r
-       args++;\r
-       strcpy(testInFileName, argv[args]);\r
-       args++;\r
-       while(args < argc ) {\r
-               if (SKP_STR_CASEINSENSITIVE_COMPARE(argv[args], "-diff") == 0) {\r
-                       diff = 1;\r
-                       args++;\r
-               }else if (SKP_STR_CASEINSENSITIVE_COMPARE(argv[args], "-fs") == 0) {\r
-                       sscanf(argv[args+1], "%d", &Fs_kHz);\r
-                       args += 2;\r
-               } else {\r
-                       printf("Error: unrecognized setting: %s\n\n", argv[args]);\r
-                       print_usage(argv);\r
-                       exit(0);\r
-               }\r
-       }\r
-\r
-       if( Fs_kHz > MAX_FS_KHZ ) {\r
-               printf("Error: sampling rate too high: %d\n\n", Fs_kHz);\r
-               print_usage(argv);\r
-               exit(0);\r
-       }\r
-\r
-       printf("Reference:  %s\n", refInFileName);\r
-       //printf("Test:       %s\n", testInFileName);\r
-\r
-       /* open files */\r
-       refInFile = fopen(refInFileName, "rb");\r
-       if (refInFile==NULL) {\r
-               printf("Error: could not open input file %s\n", refInFileName);\r
-               exit(0);\r
-       } \r
-       testInFile = fopen(testInFileName, "rb");\r
-       if (testInFile==NULL) {\r
-               printf("Error: could not open input file %s\n", testInFileName);\r
-               exit(0);\r
-       }\r
-\r
-       SKP_memset( refIn,  0, sizeof(refIn) );\r
-       SKP_memset( testIn, 0, sizeof(testIn) );\r
-\r
-       while(1) {\r
-               /* Read inputs */\r
-               counterRef  = (SKP_int)fread(&refIn[(WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz], \r
-                       sizeof(SKP_int16), FRAME_LENGTH_MS * Fs_kHz, refInFile);\r
-               counterTest = (SKP_int)fread(&testIn[(WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz], \r
-                       sizeof(SKP_int16), FRAME_LENGTH_MS * Fs_kHz, testInFile);\r
-               if(counterRef != FRAME_LENGTH_MS * Fs_kHz || counterTest != FRAME_LENGTH_MS * Fs_kHz){\r
-                       break;\r
-               }\r
-\r
-               /* test for bit-exactness */\r
-               for( n = 0; n < FRAME_LENGTH_MS * Fs_kHz; n++ ) {\r
-                       if( refIn[(WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz + n] != \r
-                               testIn[(WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz + n] ) {\r
-                                       isUnequal = 1;\r
-                                       break;\r
-                       }\r
-               }\r
-\r
-               /* apply sine window */\r
-               for( n = 0; n < WIN_LENGTH_MS * Fs_kHz; n++ ) {\r
-                       c = (SKP_float)sin( 3.14159265 * (n + 1) / (WIN_LENGTH_MS * Fs_kHz + 1) );\r
-                       refWin[n]  = refIn[n]  * c;\r
-                       testWin[n] = testIn[n] * c;\r
-               }\r
-\r
-               /* LPC analysis on reference signal */\r
-\r
-               /* Calculate auto correlation */\r
-               Autocorrelation(autoCorr, refWin, WIN_LENGTH_MS * Fs_kHz, LPC_ORDER + 1);\r
-\r
-               /* Add white noise */\r
-               autoCorr[ 0 ] += autoCorr[ 0 ] * 1e-6f + 1.0f; \r
-\r
-               /* Convert correlations to prediction coefficients */\r
-               Levinsondurbin(LPC_Coef, autoCorr, LPC_ORDER);\r
-\r
-               /* Bandwdith expansion */\r
-               Bwexpander(LPC_Coef, LPC_ORDER, BW_EXPANSION);\r
-\r
-               /* Filter both signals */\r
-               refNrg = 1.0f;\r
-               diffNrg = 1e-10f;\r
-               for( n = (WIN_LENGTH_MS - FRAME_LENGTH_MS) / 2 * Fs_kHz; \r
-                        n < (WIN_LENGTH_MS + FRAME_LENGTH_MS) / 2 * Fs_kHz; n++ ) {\r
-                               refWhtnd = refIn[n];\r
-                               testWhtnd = testIn[n];\r
-                               for( i = 0; i < LPC_ORDER; i++ ) {\r
-                                       refWhtnd  -= LPC_Coef[ i ] * refIn[n - i - 1];\r
-                                       testWhtnd -= LPC_Coef[ i ] * testIn[n - i - 1];\r
-                               }\r
-                               refNrg += refWhtnd * refWhtnd;\r
-                               diffNrg += (refWhtnd - testWhtnd) * (refWhtnd - testWhtnd);\r
-               }\r
-\r
-               /* weighted SNR */\r
-               if( refNrg > FRAME_LENGTH_MS * Fs_kHz ) {\r
-                       SNR += 10.0 * log10( refNrg / diffNrg );\r
-                       nFrames++;\r
-               }\r
-\r
-               /* Update Buffer */\r
-               SKP_memmove( refIn,  &refIn[FRAME_LENGTH_MS * Fs_kHz],  (WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz * sizeof(SKP_int16));\r
-               SKP_memmove( testIn, &testIn[FRAME_LENGTH_MS * Fs_kHz], (WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz * sizeof(SKP_int16));\r
-       }\r
-\r
-       if( diff ) {\r
-               if( isUnequal ) {\r
-                       printf("Signals     DIFFER\n");\r
-               } else {\r
-                       if(counterRef != counterTest){\r
-                               printf("Warning: signals differ in length\n");\r
-                       }\r
-                       printf("Signals     BIT-EXACT\n");\r
-               }\r
-       } else {\r
-               if( nFrames == 0 ) {\r
-                       printf("At least one signal too short or not loud enough\n");\r
-                       exit(0);\r
-               }\r
-               if(counterRef != counterTest){\r
-                       printf("Warning: signals differ in length\n");\r
-               }\r
-               if( isUnequal == 0 ) {\r
-                       printf("Signals     BIT-EXACT\n");\r
-               } else {\r
-                       printf("AVERAGE WEIGHTED SNR: %4.1f dB\n", SNR / nFrames);\r
-               }\r
-       }\r
-       printf("\n");\r
-\r
-       /* Close Files */\r
-       fclose(refInFile);\r
-       fclose(testInFile);\r
-\r
-       return 0;\r
+    SKP_int   args, n, i, counterRef, counterTest;\r
+    char      testInFileName[150], refInFileName[150];\r
+    FILE      *refInFile, *testInFile;\r
+    SKP_int   nFrames = 0, isUnequal = 0;\r
+    SKP_int   diff = 0, Fs_kHz;\r
+    SKP_int32 Fs_Hz = 24000;\r
+    SKP_float c, refWhtnd, testWhtnd, refNrg, diffNrg;\r
+    double    SNR = 0.0;\r
+    SKP_int16 refIn[WIN_LENGTH_MS * MAX_FS_KHZ], testIn[WIN_LENGTH_MS * MAX_FS_KHZ];\r
+    SKP_float refWin[WIN_LENGTH_MS * MAX_FS_KHZ], testWin[WIN_LENGTH_MS * MAX_FS_KHZ];\r
+    SKP_float autoCorr[LPC_ORDER + 1], LPC_Coef[LPC_ORDER];\r
+\r
+    if (argc < 3) {\r
+        print_usage(argv);\r
+        exit(0);\r
+    } \r
+\r
+    /* get arguments */\r
+    args = 1;\r
+    strcpy(refInFileName, argv[args]);\r
+    args++;\r
+    strcpy(testInFileName, argv[args]);\r
+    args++;\r
+    while(args < argc ) {\r
+        if (SKP_STR_CASEINSENSITIVE_COMPARE(argv[args], "-diff") == 0) {\r
+            diff = 1;\r
+            args++;\r
+        }else if (SKP_STR_CASEINSENSITIVE_COMPARE(argv[args], "-fs") == 0) {\r
+            sscanf(argv[args+1], "%d", &Fs_Hz);\r
+            args += 2;\r
+        } else {\r
+            printf("Error: unrecognized setting: %s\n\n", argv[args]);\r
+            print_usage(argv);\r
+            exit(0);\r
+        }\r
+    }\r
+\r
+    Fs_kHz = SKP_DIV32_16( Fs_Hz, 1000 );\r
+\r
+    if( Fs_kHz > MAX_FS_KHZ ) {\r
+        printf("Error: sampling rate too high: %d\n\n", Fs_kHz);\r
+        print_usage(argv);\r
+        exit(0);\r
+    }\r
+\r
+    printf("Reference:  %s\n", refInFileName);\r
+    //printf("Test:       %s\n", testInFileName);\r
+\r
+    /* open files */\r
+    refInFile = fopen(refInFileName, "rb");\r
+    if (refInFile==NULL) {\r
+        printf("Error: could not open input file %s\n", refInFileName);\r
+        exit(0);\r
+    } \r
+    testInFile = fopen(testInFileName, "rb");\r
+    if (testInFile==NULL) {\r
+        printf("Error: could not open input file %s\n", testInFileName);\r
+        exit(0);\r
+    }\r
+\r
+    SKP_memset( refIn,  0, sizeof(refIn) );\r
+    SKP_memset( testIn, 0, sizeof(testIn) );\r
+\r
+    while(1) {\r
+        /* Read inputs */\r
+        counterRef  = (SKP_int)fread(&refIn[(WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz], \r
+            sizeof(SKP_int16), FRAME_LENGTH_MS * Fs_kHz, refInFile);\r
+        counterTest = (SKP_int)fread(&testIn[(WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz], \r
+            sizeof(SKP_int16), FRAME_LENGTH_MS * Fs_kHz, testInFile);\r
+        if(counterRef != FRAME_LENGTH_MS * Fs_kHz || counterTest != FRAME_LENGTH_MS * Fs_kHz){\r
+            break;\r
+        }\r
+\r
+        /* test for bit-exactness */\r
+        for( n = 0; n < FRAME_LENGTH_MS * Fs_kHz; n++ ) {\r
+            if( refIn[(WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz + n] != \r
+                testIn[(WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz + n] ) {\r
+                    isUnequal = 1;\r
+                    break;\r
+            }\r
+        }\r
+\r
+        /* apply sine window */\r
+        for( n = 0; n < WIN_LENGTH_MS * Fs_kHz; n++ ) {\r
+            c = (SKP_float)sin( 3.14159265 * (n + 1) / (WIN_LENGTH_MS * Fs_kHz + 1) );\r
+            refWin[n]  = refIn[n]  * c;\r
+            testWin[n] = testIn[n] * c;\r
+        }\r
+\r
+        /* LPC analysis on reference signal */\r
+\r
+        /* Calculate auto correlation */\r
+        Autocorrelation(autoCorr, refWin, WIN_LENGTH_MS * Fs_kHz, LPC_ORDER + 1);\r
+\r
+        /* Add white noise */\r
+        autoCorr[ 0 ] += autoCorr[ 0 ] * 1e-6f + 1.0f; \r
+\r
+        /* Convert correlations to prediction coefficients */\r
+        Levinsondurbin(LPC_Coef, autoCorr, LPC_ORDER);\r
+\r
+        /* Bandwdith expansion */\r
+        Bwexpander(LPC_Coef, LPC_ORDER, BW_EXPANSION);\r
+\r
+        /* Filter both signals */\r
+        refNrg = 1.0f;\r
+        diffNrg = 1e-10f;\r
+        for( n = (WIN_LENGTH_MS - FRAME_LENGTH_MS) / 2 * Fs_kHz; \r
+             n < (WIN_LENGTH_MS + FRAME_LENGTH_MS) / 2 * Fs_kHz; n++ ) {\r
+                refWhtnd = refIn[n];\r
+                testWhtnd = testIn[n];\r
+                for( i = 0; i < LPC_ORDER; i++ ) {\r
+                    refWhtnd  -= LPC_Coef[ i ] * refIn[n - i - 1];\r
+                    testWhtnd -= LPC_Coef[ i ] * testIn[n - i - 1];\r
+                }\r
+                refNrg += refWhtnd * refWhtnd;\r
+                diffNrg += (refWhtnd - testWhtnd) * (refWhtnd - testWhtnd);\r
+        }\r
+\r
+        /* weighted SNR */\r
+        if( refNrg > FRAME_LENGTH_MS * Fs_kHz ) {\r
+            SNR += 10.0 * log10( refNrg / diffNrg );\r
+            nFrames++;\r
+        }\r
+\r
+        /* Update Buffer */\r
+        SKP_memmove( refIn,  &refIn[FRAME_LENGTH_MS * Fs_kHz],  (WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz * sizeof(SKP_int16));\r
+        SKP_memmove( testIn, &testIn[FRAME_LENGTH_MS * Fs_kHz], (WIN_LENGTH_MS - FRAME_LENGTH_MS) * Fs_kHz * sizeof(SKP_int16));\r
+    }\r
+\r
+    if( diff ) {\r
+        if( isUnequal ) {\r
+            printf("Signals differ\n");\r
+        } else {\r
+            if(counterRef != counterTest){\r
+                printf("Warning: signals differ in length\n");\r
+            }\r
+            printf("Signals are bit-exact          PASS\n");\r
+        }\r
+    } else {\r
+        if( nFrames == 0 ) {\r
+            printf("At least one signal too short or not loud enough\n");\r
+            exit(0);\r
+        }\r
+        if(counterRef != counterTest){\r
+            printf("Warning: signals differ in length\n");\r
+        }\r
+        if( isUnequal == 0 ) {\r
+            printf("Signals are bit-exact          PASS\n");\r
+        } else {\r
+            printf("Average weighted SNR: %4.1f dB  ", SNR / nFrames);\r
+            if( SNR / nFrames < SNR_THRESHOLD ) {\r
+                printf("FAIL\n");\r
+            } else {\r
+                printf("PASS\n");\r
+            }\r
+        }\r
+    }\r
+    printf("\n");\r
+\r
+    /* Close Files */\r
+    fclose(refInFile);\r
+    fclose(testInFile);\r
+\r
+    return 0;\r
 }\r
 \r
 /* compute autocorrelation */\r
 void Autocorrelation( \r
-       SKP_float *results,                                     /* o    result (length correlationCount)                        */\r
-       const SKP_float *inputData,                     /* i    input data to correlate                                         */\r
-       SKP_int inputDataSize,                          /* i    length of input                                                         */\r
-       SKP_int correlationCount                        /* i    number of correlation taps to compute           */\r
+    SKP_float *results,                 /* o    result (length correlationCount)            */\r
+    const SKP_float *inputData,         /* i    input data to correlate                     */\r
+    SKP_int inputDataSize,              /* i    length of input                             */\r
+    SKP_int correlationCount            /* i    number of correlation taps to compute       */\r
 )\r
 {\r
-       SKP_int i;\r
+    SKP_int i;\r
 \r
-       if (correlationCount > inputDataSize) {\r
-               correlationCount = inputDataSize;\r
-       }\r
+    if (correlationCount > inputDataSize) {\r
+        correlationCount = inputDataSize;\r
+    }\r
 \r
-       for( i = 0; i < correlationCount; i++ ) {\r
-               results[ i ] =  (SKP_float)Inner_product( inputData, inputData + i, inputDataSize - i );\r
-       }\r
+    for( i = 0; i < correlationCount; i++ ) {\r
+        results[ i ] =  (SKP_float)Inner_product( inputData, inputData + i, inputDataSize - i );\r
+    }\r
 }\r
 \r
 /* inner product of two SKP_float arrays, with result as double */\r
 double Inner_product( \r
-       const SKP_float         *data1, \r
-       const SKP_float         *data2, \r
-       SKP_int                         dataSize\r
+    const SKP_float     *data1, \r
+    const SKP_float     *data2, \r
+    SKP_int             dataSize\r
 )\r
 {\r
-       SKP_int  i, dataSize4;\r
-       double   result;\r
-\r
-       /* 4x unrolled loop */\r
-       result = 0.0f;\r
-       dataSize4 = dataSize & 0xFFFC;\r
-       for( i = 0; i < dataSize4; i += 4 ) {\r
-               result += data1[ i + 0 ] * data2[ i + 0 ] + \r
-                                 data1[ i + 1 ] * data2[ i + 1 ] +\r
-                                 data1[ i + 2 ] * data2[ i + 2 ] +\r
-                                 data1[ i + 3 ] * data2[ i + 3 ];\r
-       }\r
-\r
-       /* add any remaining products */\r
-       for( ; i < dataSize; i++ ) {\r
-               result += data1[ i ] * data2[ i ];\r
-       }\r
-\r
-       return result;\r
+    SKP_int  i, dataSize4;\r
+    double   result;\r
+\r
+    /* 4x unrolled loop */\r
+    result = 0.0f;\r
+    dataSize4 = dataSize & 0xFFFC;\r
+    for( i = 0; i < dataSize4; i += 4 ) {\r
+        result += data1[ i + 0 ] * data2[ i + 0 ] + \r
+                  data1[ i + 1 ] * data2[ i + 1 ] +\r
+                  data1[ i + 2 ] * data2[ i + 2 ] +\r
+                  data1[ i + 3 ] * data2[ i + 3 ];\r
+    }\r
+\r
+    /* add any remaining products */\r
+    for( ; i < dataSize; i++ ) {\r
+        result += data1[ i ] * data2[ i ];\r
+    }\r
+\r
+    return result;\r
 }\r
 \r
 /* Solve the normal equations using the Levinson-Durbin recursion */\r
-SKP_float Levinsondurbin(                              /* O    prediction error energy                                         */\r
-       SKP_float               A[],                            /* O    prediction coefficients [order]                         */\r
-       const SKP_float corr[],                         /* I    input auto-correlations [order + 1]                     */\r
-       const SKP_int   order                           /* I    prediction order                                                        */\r
+SKP_float Levinsondurbin(               /* O    prediction error energy                     */\r
+    SKP_float       A[],                /* O    prediction coefficients [order]             */\r
+    const SKP_float corr[],             /* I    input auto-correlations [order + 1]         */\r
+    const SKP_int   order               /* I    prediction order                            */\r
 )\r
 {\r
-       SKP_int   i, mHalf, m;\r
-       SKP_float min_nrg, nrg, t, km, Atmp1, Atmp2;\r
-       \r
-       min_nrg = 1e-12f * corr[ 0 ] + 1e-9f;\r
-       nrg = corr[ 0 ];\r
-       nrg = SKP_max(min_nrg, nrg);\r
-       A[ 0 ] = corr[ 1 ] / nrg;\r
-       nrg -= A[ 0 ] * corr[ 1 ];\r
-       nrg = SKP_max(min_nrg, nrg);\r
-\r
-       for( m = 1; m < order; m++ )\r
-       {\r
-               t = corr[ m + 1 ];\r
-               for( i = 0; i < m; i++ ) {\r
-                       t -= A[ i ] * corr[ m - i ];\r
-               }\r
-\r
-               /* reflection coefficient */\r
-               km = t / nrg;\r
-\r
-               /* residual energy */\r
-               nrg -= km * t;\r
-               nrg = SKP_max(min_nrg, nrg);\r
-\r
-               mHalf = m >> 1;\r
-               for( i = 0; i < mHalf; i++ ) {\r
-                       Atmp1 = A[ i ];\r
-                       Atmp2 = A[ m - i - 1 ];\r
-                       A[ m - i - 1 ] -= km * Atmp1;\r
-                       A[ i ]         -= km * Atmp2;\r
-               }\r
-               if( m & 1 ) {\r
-                       A[ mHalf ]     -= km * A[ mHalf ];\r
-               }\r
-               A[ m ] = km;\r
-       }\r
-\r
-       /* return the residual energy */\r
-       return nrg;\r
+    SKP_int   i, mHalf, m;\r
+    SKP_float min_nrg, nrg, t, km, Atmp1, Atmp2;\r
+    \r
+    min_nrg = 1e-12f * corr[ 0 ] + 1e-9f;\r
+    nrg = corr[ 0 ];\r
+    nrg = SKP_max(min_nrg, nrg);\r
+    A[ 0 ] = corr[ 1 ] / nrg;\r
+    nrg -= A[ 0 ] * corr[ 1 ];\r
+    nrg = SKP_max(min_nrg, nrg);\r
+\r
+    for( m = 1; m < order; m++ )\r
+    {\r
+        t = corr[ m + 1 ];\r
+        for( i = 0; i < m; i++ ) {\r
+            t -= A[ i ] * corr[ m - i ];\r
+        }\r
+\r
+        /* reflection coefficient */\r
+        km = t / nrg;\r
+\r
+        /* residual energy */\r
+        nrg -= km * t;\r
+        nrg = SKP_max(min_nrg, nrg);\r
+\r
+        mHalf = m >> 1;\r
+        for( i = 0; i < mHalf; i++ ) {\r
+            Atmp1 = A[ i ];\r
+            Atmp2 = A[ m - i - 1 ];\r
+            A[ m - i - 1 ] -= km * Atmp1;\r
+            A[ i ]         -= km * Atmp2;\r
+        }\r
+        if( m & 1 ) {\r
+            A[ mHalf ]     -= km * A[ mHalf ];\r
+        }\r
+        A[ m ] = km;\r
+    }\r
+\r
+    /* return the residual energy */\r
+    return nrg;\r
 }\r
 \r
 /* Chirp (bw expand) LP AR filter */\r
 void Bwexpander( \r
-       SKP_float *ar,                                          /* io   AR filter to be expanded (without leading 1)   */\r
-       const SKP_int d,                                        /* i    length of ar                                                                    */\r
-       const SKP_float chirp                           /* i    chirp factor (typically in range (0..1) )               */\r
+    SKP_float *ar,                      /* io   AR filter to be expanded (without leading 1)    */\r
+    const SKP_int d,                    /* i    length of ar                                    */\r
+    const SKP_float chirp               /* i    chirp factor (typically in range (0..1) )       */\r
 )\r
 {\r
-       SKP_int   i;\r
-       SKP_float cfac = chirp;\r
-\r
-       for( i = 0; i < d - 1; i++ ) {\r
-               ar[ i ] *=  cfac;\r
-               cfac    *=  chirp;\r
-       }\r
-       ar[ d - 1 ] *=  cfac;\r
+    SKP_int   i;\r
+    SKP_float cfac = chirp;\r
+\r
+    for( i = 0; i < d - 1; i++ ) {\r
+        ar[ i ] *=  cfac;\r
+        cfac    *=  chirp;\r
+    }\r
+    ar[ d - 1 ] *=  cfac;\r
 }\r