From 103302b3752609e28cb6ba4f706a6f6e49ffef68 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Thu, 19 May 2011 17:17:44 -0400 Subject: [PATCH] Squashed commit of the following: commit 5b64cf7c4d67af9050bc959996ef976ce6326888 Author: Jean-Marc Valin Date: Thu May 19 16:40:35 2011 -0400 Fixes a few bugs introduced in the latest update commit b91eb86025d2de3c4cf04f4fb1aa48a28ad676a3 Author: Timothy B. Terriberry Date: Thu May 19 16:12:02 2011 -0400 build_draft.sh fixes commit 0b10c30db7ad60ff7d4bfc1139bdb86e0543c035 Author: Jean-Marc Valin Date: Thu May 19 15:30:21 2011 -0400 Fixes the draft build commit 164424cded5978e657105104e171ac202dde5e5b Author: Jean-Marc Valin Date: Thu May 19 15:00:23 2011 -0400 Updated build system commit 188d9fcba8c3a1b1ad67c67c430e1b37e3658a40 Author: Koen Vos Date: Thu May 19 17:14:57 2011 -0400 SILK/Opus update --- doc/build_draft.sh | 11 +- libcelt/celt_header.h | 66 ---- libcelt/libcelt.vcxproj | 2 - libcelt/libcelt.vcxproj.filters | 6 - opus.sln | 18 + silk/SKP_Silk_stereo_LR_to_MS.c | 107 ------ silk/SKP_Silk_tables.h | 117 ------- ...r_FIX.c => silk_LTP_analysis_filter_FIX.c} | 4 +- ...e_ctrl_FIX.c => silk_LTP_scale_ctrl_FIX.c} | 14 +- ...corrMatrix_FIX.c => silk_corrMatrix_FIX.c} | 14 +- ...de_frame_FIX.c => silk_encode_frame_FIX.c} | 102 +++--- ...ilk_find_LPC_FIX.c => silk_find_LPC_FIX.c} | 32 +- ...ilk_find_LTP_FIX.c => silk_find_LTP_FIX.c} | 52 +-- ..._lags_FIX.c => silk_find_pitch_lags_FIX.c} | 40 +-- ...coefs_FIX.c => silk_find_pred_coefs_FIX.c} | 26 +- silk/fixed/silk_fixed.vcxproj | 38 ++- silk/fixed/silk_fixed.vcxproj.filters | 42 ++- .../{SKP_Silk_main_FIX.h => silk_main_FIX.h} | 105 +++--- ..._FIX.c => silk_noise_shape_analysis_FIX.c} | 176 +++++----- ...k_prefilter_FIX.c => silk_prefilter_FIX.c} | 34 +- ...s_gains_FIX.c => silk_process_gains_FIX.c} | 44 +-- ...X.c => silk_regularize_correlations_FIX.c} | 4 +- ...y16_FIX.c => silk_residual_energy16_FIX.c} | 8 +- ...nergy_FIX.c => silk_residual_energy_FIX.c} | 14 +- ...ilk_solve_LS_FIX.c => silk_solve_LS_FIX.c} | 34 +- ..._Silk_structs_FIX.h => silk_structs_FIX.h} | 36 +- ...IX.c => silk_warped_autocorrelation_FIX.c} | 6 +- ...r_FLP.c => silk_LPC_analysis_filter_FLP.c} | 28 +- ...ain_FLP.c => silk_LPC_inv_pred_gain_FLP.c} | 18 +- ...r_FLP.c => silk_LTP_analysis_filter_FLP.c} | 4 +- ...e_ctrl_FLP.c => silk_LTP_scale_ctrl_FLP.c} | 12 +- ..._Silk_SigProc_FLP.h => silk_SigProc_FLP.h} | 64 ++-- ...dow_FLP.c => silk_apply_sine_window_FLP.c} | 4 +- ...ation_FLP.c => silk_autocorrelation_FLP.c} | 8 +- ...odified_FLP.c => silk_burg_modified_FLP.c} | 28 +- ...bwexpander_FLP.c => silk_bwexpander_FLP.c} | 4 +- ...corrMatrix_FLP.c => silk_corrMatrix_FLP.c} | 12 +- ...de_frame_FLP.c => silk_encode_frame_FLP.c} | 96 +++--- ...KP_Silk_energy_FLP.c => silk_energy_FLP.c} | 4 +- ...ilk_find_LPC_FLP.c => silk_find_LPC_FLP.c} | 30 +- ...ilk_find_LTP_FLP.c => silk_find_LTP_FLP.c} | 22 +- ..._lags_FLP.c => silk_find_pitch_lags_FLP.c} | 26 +- ...coefs_FLP.c => silk_find_pred_coefs_FLP.c} | 24 +- silk/float/silk_float.vcxproj | 68 ++-- silk/float/silk_float.vcxproj.filters | 80 ++--- ...product_FLP.c => silk_inner_product_FLP.c} | 4 +- .../{SKP_Silk_k2a_FLP.c => silk_k2a_FLP.c} | 15 +- ...durbin_FLP.c => silk_levinsondurbin_FLP.c} | 4 +- .../{SKP_Silk_main_FLP.h => silk_main_FLP.h} | 132 ++++---- ..._FLP.c => silk_noise_shape_analysis_FLP.c} | 38 +-- ...e_FLP.c => silk_pitch_analysis_core_FLP.c} | 87 +++-- ...k_prefilter_FLP.c => silk_prefilter_FLP.c} | 30 +- ...s_gains_FLP.c => silk_process_gains_FLP.c} | 18 +- ...P.c => silk_regularize_correlations_FLP.c} | 4 +- ...nergy_FLP.c => silk_residual_energy_FLP.c} | 22 +- ...tor_FLP.c => silk_scale_copy_vector_FLP.c} | 4 +- ...e_vector_FLP.c => silk_scale_vector_FLP.c} | 4 +- ...{SKP_Silk_schur_FLP.c => silk_schur_FLP.c} | 15 +- ...ilk_solve_LS_FLP.c => silk_solve_LS_FLP.c} | 24 +- .../{SKP_Silk_sort_FLP.c => silk_sort_FLP.c} | 26 +- ..._Silk_structs_FLP.h => silk_structs_FLP.h} | 37 ++- ...LP.c => silk_warped_autocorrelation_FLP.c} | 4 +- ...ilk_wrappers_FLP.c => silk_wrappers_FLP.c} | 34 +- silk/{SKP_Silk_A2NLSF.c => silk_A2NLSF.c} | 59 ++-- silk/{SKP_Silk_SDK_API.h => silk_API.h} | 49 ++- silk/{SKP_Silk_CNG.c => silk_CNG.c} | 26 +- ...ble_cutoff.c => silk_HP_variable_cutoff.c} | 83 +++-- silk/{SKP_Silk_Inlines.h => silk_Inlines.h} | 63 +--- ...is_filter.c => silk_LPC_analysis_filter.c} | 4 +- ...v_pred_gain.c => silk_LPC_inv_pred_gain.c} | 30 +- ...k_LPC_stabilize.c => silk_LPC_stabilize.c} | 18 +- ...s_filter.c => silk_LPC_synthesis_filter.c} | 6 +- ...order16.c => silk_LPC_synthesis_order16.c} | 6 +- ...ble_cutoff.c => silk_LP_variable_cutoff.c} | 44 +-- ...KP_Silk_MacroCount.h => silk_MacroCount.h} | 0 ...KP_Silk_MacroDebug.h => silk_MacroDebug.h} | 0 silk/{SKP_Silk_NLSF2A.c => silk_NLSF2A.c} | 25 +- ...k_NLSF2A_stable.c => silk_NLSF2A_stable.c} | 10 +- silk/{SKP_Silk_NLSF_VQ.c => silk_NLSF_VQ.c} | 4 +- ...laroia.c => silk_NLSF_VQ_weights_laroia.c} | 4 +- ..._Silk_NLSF_decode.c => silk_NLSF_decode.c} | 22 +- ..._dec_quant.c => silk_NLSF_del_dec_quant.c} | 16 +- ..._Silk_NLSF_encode.c => silk_NLSF_encode.c} | 34 +- ...NLSF_stabilize.c => silk_NLSF_stabilize.c} | 6 +- ..._Silk_NLSF_unpack.c => silk_NLSF_unpack.c} | 6 +- silk/{SKP_Silk_NSQ.c => silk_NSQ.c} | 42 +-- ..._Silk_NSQ_del_dec.c => silk_NSQ_del_dec.c} | 40 +-- silk/{SKP_Silk_PLC.c => silk_PLC.c} | 60 ++-- silk/{SKP_Silk_PLC.h => silk_PLC.h} | 34 +- ..._Silk_SigProc_FIX.h => silk_SigProc_FIX.h} | 155 ++++----- silk/{SKP_Silk_VAD.c => silk_VAD.c} | 44 +-- ...KP_Silk_VQ_WMat_EC.c => silk_VQ_WMat_EC.c} | 4 +- ...a_filt_bank_1.c => silk_ana_filt_bank_1.c} | 12 +- ...sine_window.c => silk_apply_sine_window.c} | 4 +- ...ilk_array_maxabs.c => silk_array_maxabs.c} | 13 +- silk/{SKP_Silk_autocorr.c => silk_autocorr.c} | 12 +- ...KP_Silk_biquad_alt.c => silk_biquad_alt.c} | 6 +- ...k_burg_modified.c => silk_burg_modified.c} | 40 +-- ...KP_Silk_bwexpander.c => silk_bwexpander.c} | 4 +- ...k_bwexpander_32.c => silk_bwexpander_32.c} | 4 +- ...rol_input.c => silk_check_control_input.c} | 36 +- ...KP_Silk_code_signs.c => silk_code_signs.c} | 10 +- silk/silk_common.vcxproj | 234 ++++++------- silk/silk_common.vcxproj.filters | 314 +++++++++--------- silk/{SKP_Silk_control.h => silk_control.h} | 33 +- ..._Silk_control_SNR.c => silk_control_SNR.c} | 25 +- ...width.c => silk_control_audio_bandwidth.c} | 8 +- ...k_control_codec.c => silk_control_codec.c} | 194 ++++++----- ...t_destroy.c => silk_create_init_destroy.c} | 12 +- silk/{SKP_Silk_debug.c => silk_debug.c} | 119 +++---- silk/{SKP_debug.h => silk_debug.h} | 170 +++++----- silk/{SKP_Silk_dec_API.c => silk_dec_API.c} | 201 +++++------ ..._Silk_decode_core.c => silk_decode_core.c} | 18 +- ...ilk_decode_frame.c => silk_decode_frame.c} | 26 +- ...decode_indices.c => silk_decode_indices.c} | 38 +-- ..._parameters.c => silk_decode_parameters.c} | 26 +- ...ilk_decode_pitch.c => silk_decode_pitch.c} | 14 +- ...k_decode_pulses.c => silk_decode_pulses.c} | 16 +- ...decoder_set_fs.c => silk_decoder_set_fs.c} | 24 +- silk/{SKP_Silk_define.h => silk_define.h} | 25 +- silk/{SKP_Silk_enc_API.c => silk_enc_API.c} | 253 +++++++------- ...encode_indices.c => silk_encode_indices.c} | 38 +-- ...k_encode_pulses.c => silk_encode_pulses.c} | 34 +- silk/{SKP_Silk_errors.h => silk_errors.h} | 36 +- ...KP_Silk_gain_quant.c => silk_gain_quant.c} | 13 +- ...ilk_init_encoder.c => silk_init_encoder.c} | 25 +- ...od_aligned.c => silk_inner_prod_aligned.c} | 8 +- ..._Silk_interpolate.c => silk_interpolate.c} | 4 +- silk/{SKP_Silk_k2a.c => silk_k2a.c} | 6 +- silk/{SKP_Silk_k2a_Q16.c => silk_k2a_Q16.c} | 6 +- silk/{SKP_Silk_lin2log.c => silk_lin2log.c} | 6 +- silk/{SKP_Silk_log2lin.c => silk_log2lin.c} | 6 +- silk/{SKP_Silk_macros.h => silk_macros.h} | 14 +- silk/{SKP_Silk_main.h => silk_main.h} | 206 ++++++------ ...ysis_core.c => silk_pitch_analysis_core.c} | 140 ++++---- ...est_defines.h => silk_pitch_est_defines.h} | 20 +- ...h_est_tables.c => silk_pitch_est_tables.c} | 18 +- ...k_process_NLSFs.c => silk_process_NLSFs.c} | 26 +- ...ant_LTP_gains.c => silk_quant_LTP_gains.c} | 16 +- ...{SKP_Silk_resampler.c => silk_resampler.c} | 97 +++--- ...sampler_down2.c => silk_resampler_down2.c} | 22 +- ...ler_down2_3.c => silk_resampler_down2_3.c} | 34 +- ...sampler_down3.c => silk_resampler_down3.c} | 24 +- ...ler_private.h => silk_resampler_private.h} | 40 +-- ...ate_AR2.c => silk_resampler_private_AR2.c} | 14 +- ...ARMA4.c => silk_resampler_private_ARMA4.c} | 15 +- ...FIR.c => silk_resampler_private_IIR_FIR.c} | 34 +- ...e_copy.c => silk_resampler_private_copy.c} | 15 +- ...down4.c => silk_resampler_private_down4.c} | 22 +- ...IR.c => silk_resampler_private_down_FIR.c} | 30 +- ...2_HQ.c => silk_resampler_private_up2_HQ.c} | 44 +-- ...ate_up4.c => silk_resampler_private_up4.c} | 14 +- ...k_resampler_rom.c => silk_resampler_rom.c} | 57 ++-- ...k_resampler_rom.h => silk_resampler_rom.h} | 50 +-- ...ler_structs.h => silk_resampler_structs.h} | 30 +- ...k_resampler_up2.c => silk_resampler_up2.c} | 22 +- ..._vector16.c => silk_scale_copy_vector16.c} | 4 +- ...ilk_scale_vector.c => silk_scale_vector.c} | 4 +- silk/{SKP_Silk_schur.c => silk_schur.c} | 16 +- silk/{SKP_Silk_schur64.c => silk_schur64.c} | 8 +- ..._Silk_shell_coder.c => silk_shell_coder.c} | 70 ++-- silk/{SKP_Silk_sigm_Q15.c => silk_sigm_Q15.c} | 18 +- silk/{SKP_Silk_sort.c => silk_sort.c} | 48 +-- silk/silk_stereo_LR_to_MS.c | 177 ++++++++++ ...ereo_MS_to_LR.c => silk_stereo_MS_to_LR.c} | 41 ++- ...ecode_pred.c => silk_stereo_decode_pred.c} | 30 +- silk/silk_stereo_encode_pred.c | 51 +++ ...edictor.c => silk_stereo_find_predictor.c} | 45 ++- ...encode_pred.c => silk_stereo_quant_pred.c} | 38 +-- silk/{SKP_Silk_structs.h => silk_structs.h} | 94 +++--- ...k_sum_sqr_shift.c => silk_sum_sqr_shift.c} | 4 +- ...k_LSF_cos_table.c => silk_table_LSF_cos.c} | 7 +- silk/silk_tables.h | 120 +++++++ ...KP_Silk_tables_LTP.c => silk_tables_LTP.c} | 50 +-- ...CB_NB_MB.c => silk_tables_NLSF_CB_NB_MB.c} | 36 +- ..._NLSF_CB_WB.c => silk_tables_NLSF_CB_WB.c} | 36 +- ..._Silk_tables_gain.c => silk_tables_gain.c} | 6 +- ...ilk_tables_other.c => silk_tables_other.c} | 64 ++-- ...es_pitch_lag.c => silk_tables_pitch_lag.c} | 14 +- ...block.c => silk_tables_pulses_per_block.c} | 24 +- ..._parameters.h => silk_tuning_parameters.h} | 33 +- silk/{SKP_Silk_typedef.h => silk_typedef.h} | 4 +- silk_headers.txt | 50 +-- silk_sources.mk | 287 ++++++++-------- src/opus.h | 5 + src/opus.vcxproj | 2 +- src/opus.vcxproj.filters | 4 +- src/opus_decoder.c | 23 +- src/opus_decoder.h | 5 +- src/opus_encoder.c | 105 ++++-- src/opus_encoder.h | 20 +- src/test_opus.c | 15 +- 192 files changed, 3849 insertions(+), 3866 deletions(-) delete mode 100644 libcelt/celt_header.h delete mode 100644 silk/SKP_Silk_stereo_LR_to_MS.c delete mode 100644 silk/SKP_Silk_tables.h rename silk/fixed/{SKP_Silk_LTP_analysis_filter_FIX.c => silk_LTP_analysis_filter_FIX.c} (96%) rename silk/fixed/{SKP_Silk_LTP_scale_ctrl_FIX.c => silk_LTP_scale_ctrl_FIX.c} (82%) rename silk/fixed/{SKP_Silk_corrMatrix_FIX.c => silk_corrMatrix_FIX.c} (93%) rename silk/fixed/{SKP_Silk_encode_frame_FIX.c => silk_encode_frame_FIX.c} (80%) rename silk/fixed/{SKP_Silk_find_LPC_FIX.c => silk_find_LPC_FIX.c} (81%) rename silk/fixed/{SKP_Silk_find_LTP_FIX.c => silk_find_LTP_FIX.c} (81%) rename silk/fixed/{SKP_Silk_find_pitch_lags_FIX.c => silk_find_pitch_lags_FIX.c} (74%) rename silk/fixed/{SKP_Silk_find_pred_coefs_FIX.c => silk_find_pred_coefs_FIX.c} (82%) rename silk/fixed/{SKP_Silk_main_FIX.h => silk_main_FIX.h} (83%) rename silk/fixed/{SKP_Silk_noise_shape_analysis_FIX.c => silk_noise_shape_analysis_FIX.c} (65%) rename silk/fixed/{SKP_Silk_prefilter_FIX.c => silk_prefilter_FIX.c} (88%) rename silk/fixed/{SKP_Silk_process_gains_FIX.c => silk_process_gains_FIX.c} (67%) rename silk/fixed/{SKP_Silk_regularize_correlations_FIX.c => silk_regularize_correlations_FIX.c} (95%) rename silk/fixed/{SKP_Silk_residual_energy16_FIX.c => silk_residual_energy16_FIX.c} (92%) rename silk/fixed/{SKP_Silk_residual_energy_FIX.c => silk_residual_energy_FIX.c} (88%) rename silk/fixed/{SKP_Silk_solve_LS_FIX.c => silk_solve_LS_FIX.c} (89%) rename silk/fixed/{SKP_Silk_structs_FIX.h => silk_structs_FIX.h} (78%) rename silk/fixed/{SKP_Silk_warped_autocorrelation_FIX.c => silk_warped_autocorrelation_FIX.c} (95%) rename silk/float/{SKP_Silk_LPC_analysis_filter_FLP.c => silk_LPC_analysis_filter_FLP.c} (91%) rename silk/float/{SKP_Silk_LPC_inv_pred_gain_FLP.c => silk_LPC_inv_pred_gain_FLP.c} (76%) rename silk/float/{SKP_Silk_LTP_analysis_filter_FLP.c => silk_LTP_analysis_filter_FLP.c} (96%) rename silk/float/{SKP_Silk_LTP_scale_ctrl_FLP.c => silk_LTP_scale_ctrl_FLP.c} (83%) rename silk/float/{SKP_Silk_SigProc_FLP.h => silk_SigProc_FLP.h} (84%) rename silk/float/{SKP_Silk_apply_sine_window_FLP.c => silk_apply_sine_window_FLP.c} (96%) rename silk/float/{SKP_Silk_autocorrelation_FLP.c => silk_autocorrelation_FLP.c} (90%) rename silk/float/{SKP_Silk_burg_modified_FLP.c => silk_burg_modified_FLP.c} (80%) rename silk/float/{SKP_Silk_bwexpander_FLP.c => silk_bwexpander_FLP.c} (95%) rename silk/float/{SKP_Silk_corrMatrix_FLP.c => silk_corrMatrix_FLP.c} (92%) rename silk/float/{SKP_Silk_encode_frame_FLP.c => silk_encode_frame_FLP.c} (78%) rename silk/float/{SKP_Silk_energy_FLP.c => silk_energy_FLP.c} (95%) rename silk/float/{SKP_Silk_find_LPC_FLP.c => silk_find_LPC_FLP.c} (80%) rename silk/float/{SKP_Silk_find_LTP_FLP.c => silk_find_LTP_FLP.c} (85%) rename silk/float/{SKP_Silk_find_pitch_lags_FLP.c => silk_find_pitch_lags_FLP.c} (82%) rename silk/float/{SKP_Silk_find_pred_coefs_FLP.c => silk_find_pred_coefs_FLP.c} (82%) rename silk/float/{SKP_Silk_inner_product_FLP.c => silk_inner_product_FLP.c} (94%) rename silk/float/{SKP_Silk_k2a_FLP.c => silk_k2a_FLP.c} (74%) rename silk/float/{SKP_Silk_levinsondurbin_FLP.c => silk_levinsondurbin_FLP.c} (93%) rename silk/float/{SKP_Silk_main_FLP.h => silk_main_FLP.h} (83%) rename silk/float/{SKP_Silk_noise_shape_analysis_FLP.c => silk_noise_shape_analysis_FLP.c} (89%) rename silk/float/{SKP_Silk_pitch_analysis_core_FLP.c => silk_pitch_analysis_core_FLP.c} (87%) rename silk/float/{SKP_Silk_prefilter_FLP.c => silk_prefilter_FLP.c} (87%) rename silk/float/{SKP_Silk_process_gains_FLP.c => silk_process_gains_FLP.c} (84%) rename silk/float/{SKP_Silk_regularize_correlations_FLP.c => silk_regularize_correlations_FLP.c} (95%) rename silk/float/{SKP_Silk_residual_energy_FLP.c => silk_residual_energy_FLP.c} (83%) rename silk/float/{SKP_Silk_scale_copy_vector_FLP.c => silk_scale_copy_vector_FLP.c} (95%) rename silk/float/{SKP_Silk_scale_vector_FLP.c => silk_scale_vector_FLP.c} (95%) rename silk/float/{SKP_Silk_schur_FLP.c => silk_schur_FLP.c} (78%) rename silk/float/{SKP_Silk_solve_LS_FLP.c => silk_solve_LS_FLP.c} (91%) rename silk/float/{SKP_Silk_sort_FLP.c => silk_sort_FLP.c} (80%) rename silk/float/{SKP_Silk_structs_FLP.h => silk_structs_FLP.h} (78%) rename silk/float/{SKP_Silk_warped_autocorrelation_FLP.c => silk_warped_autocorrelation_FLP.c} (95%) rename silk/float/{SKP_Silk_wrappers_FLP.c => silk_wrappers_FLP.c} (87%) rename silk/{SKP_Silk_A2NLSF.c => silk_A2NLSF.c} (83%) rename silk/{SKP_Silk_SDK_API.h => silk_API.h} (77%) rename silk/{SKP_Silk_CNG.c => silk_CNG.c} (86%) rename silk/{SKP_Silk_HP_variable_cutoff.c => silk_HP_variable_cutoff.c} (50%) rename silk/{SKP_Silk_Inlines.h => silk_Inlines.h} (76%) rename silk/{SKP_Silk_LPC_analysis_filter.c => silk_LPC_analysis_filter.c} (96%) rename silk/{SKP_Silk_LPC_inv_pred_gain.c => silk_LPC_inv_pred_gain.c} (80%) rename silk/{SKP_Silk_LPC_stabilize.c => silk_LPC_stabilize.c} (90%) rename silk/{SKP_Silk_LPC_synthesis_filter.c => silk_LPC_synthesis_filter.c} (94%) rename silk/{SKP_Silk_LPC_synthesis_order16.c => silk_LPC_synthesis_order16.c} (94%) rename silk/{SKP_Silk_LP_variable_cutoff.c => silk_LP_variable_cutoff.c} (72%) rename silk/{SKP_Silk_MacroCount.h => silk_MacroCount.h} (100%) rename silk/{SKP_Silk_MacroDebug.h => silk_MacroDebug.h} (100%) rename silk/{SKP_Silk_NLSF2A.c => silk_NLSF2A.c} (87%) rename silk/{SKP_Silk_NLSF2A_stable.c => silk_NLSF2A_stable.c} (87%) rename silk/{SKP_Silk_NLSF_VQ.c => silk_NLSF_VQ.c} (96%) rename silk/{SKP_Silk_NLSF_VQ_weights_laroia.c => silk_NLSF_VQ_weights_laroia.c} (96%) rename silk/{SKP_Silk_NLSF_decode.c => silk_NLSF_decode.c} (80%) rename silk/{SKP_Silk_NLSF_del_dec_quant.c => silk_NLSF_del_dec_quant.c} (92%) rename silk/{SKP_Silk_NLSF_encode.c => silk_NLSF_encode.c} (83%) rename silk/{SKP_Silk_NLSF_stabilize.c => silk_NLSF_stabilize.c} (95%) rename silk/{SKP_Silk_NLSF_unpack.c => silk_NLSF_unpack.c} (92%) rename silk/{SKP_Silk_NSQ.c => silk_NSQ.c} (92%) rename silk/{SKP_Silk_NSQ_del_dec.c => silk_NSQ_del_dec.c} (94%) rename silk/{SKP_Silk_PLC.c => silk_PLC.c} (87%) rename silk/{SKP_Silk_PLC.h => silk_PLC.h} (75%) rename silk/{SKP_Silk_SigProc_FIX.h => silk_SigProc_FIX.h} (87%) rename silk/{SKP_Silk_VAD.c => silk_VAD.c} (84%) rename silk/{SKP_Silk_VQ_WMat_EC.c => silk_VQ_WMat_EC.c} (97%) rename silk/{SKP_Silk_ana_filt_bank_1.c => silk_ana_filt_bank_1.c} (82%) rename silk/{SKP_Silk_apply_sine_window.c => silk_apply_sine_window.c} (96%) rename silk/{SKP_Silk_array_maxabs.c => silk_array_maxabs.c} (75%) rename silk/{SKP_Silk_autocorr.c => silk_autocorr.c} (87%) rename silk/{SKP_Silk_biquad_alt.c => silk_biquad_alt.c} (95%) rename silk/{SKP_Silk_burg_modified.c => silk_burg_modified.c} (87%) rename silk/{SKP_Silk_bwexpander.c => silk_bwexpander.c} (96%) rename silk/{SKP_Silk_bwexpander_32.c => silk_bwexpander_32.c} (95%) rename silk/{SKP_Silk_check_control_input.c => silk_check_control_input.c} (77%) rename silk/{SKP_Silk_code_signs.c => silk_code_signs.c} (95%) rename silk/{SKP_Silk_control.h => silk_control.h} (89%) rename silk/{SKP_Silk_control_SNR.c => silk_control_SNR.c} (78%) rename silk/{SKP_Silk_control_audio_bandwidth.c => silk_control_audio_bandwidth.c} (93%) rename silk/{SKP_Silk_control_codec.c => silk_control_codec.c} (68%) rename silk/{SKP_Silk_create_init_destroy.c => silk_create_init_destroy.c} (86%) rename silk/{SKP_Silk_debug.c => silk_debug.c} (52%) rename silk/{SKP_debug.h => silk_debug.h} (66%) rename silk/{SKP_Silk_dec_API.c => silk_dec_API.c} (52%) rename silk/{SKP_Silk_decode_core.c => silk_decode_core.c} (91%) rename silk/{SKP_Silk_decode_frame.c => silk_decode_frame.c} (85%) rename silk/{SKP_Silk_decode_indices.c => silk_decode_indices.c} (82%) rename silk/{SKP_Silk_decode_parameters.c => silk_decode_parameters.c} (77%) rename silk/{SKP_Silk_decode_pitch.c => silk_decode_pitch.c} (88%) rename silk/{SKP_Silk_decode_pulses.c => silk_decode_pulses.c} (86%) rename silk/{SKP_Silk_decoder_set_fs.c => silk_decoder_set_fs.c} (80%) rename silk/{SKP_Silk_define.h => silk_define.h} (92%) rename silk/{SKP_Silk_enc_API.c => silk_enc_API.c} (56%) rename silk/{SKP_Silk_encode_indices.c => silk_encode_indices.c} (86%) rename silk/{SKP_Silk_encode_pulses.c => silk_encode_pulses.c} (84%) rename silk/{SKP_Silk_errors.h => silk_errors.h} (71%) rename silk/{SKP_Silk_gain_quant.c => silk_gain_quant.c} (90%) rename silk/{SKP_Silk_init_encoder.c => silk_init_encoder.c} (75%) rename silk/{SKP_Silk_inner_prod_aligned.c => silk_inner_prod_aligned.c} (93%) rename silk/{SKP_Silk_interpolate.c => silk_interpolate.c} (96%) rename silk/{SKP_Silk_k2a.c => silk_k2a.c} (94%) rename silk/{SKP_Silk_k2a_Q16.c => silk_k2a_Q16.c} (94%) rename silk/{SKP_Silk_lin2log.c => silk_lin2log.c} (90%) rename silk/{SKP_Silk_log2lin.c => silk_log2lin.c} (90%) rename silk/{SKP_Silk_macros.h => silk_macros.h} (93%) rename silk/{SKP_Silk_main.h => silk_main.h} (79%) rename silk/{SKP_Silk_pitch_analysis_core.c => silk_pitch_analysis_core.c} (84%) rename silk/{SKP_Silk_pitch_est_defines.h => silk_pitch_est_defines.h} (81%) rename silk/{SKP_Silk_pitch_est_tables.c => silk_pitch_est_tables.c} (79%) rename silk/{SKP_Silk_process_NLSFs.c => silk_process_NLSFs.c} (80%) rename silk/{SKP_Silk_quant_LTP_gains.c => silk_quant_LTP_gains.c} (90%) rename silk/{SKP_Silk_resampler.c => silk_resampler.c} (76%) rename silk/{SKP_Silk_resampler_down2.c => silk_resampler_down2.c} (77%) rename silk/{SKP_Silk_resampler_down2_3.c => silk_resampler_down2_3.c} (69%) rename silk/{SKP_Silk_resampler_down3.c => silk_resampler_down3.c} (77%) rename silk/{SKP_Silk_resampler_private.h => silk_resampler_private.h} (82%) rename silk/{SKP_Silk_resampler_private_AR2.c => silk_resampler_private_AR2.c} (81%) rename silk/{SKP_Silk_resampler_private_ARMA4.c => silk_resampler_private_ARMA4.c} (85%) rename silk/{SKP_Silk_resampler_private_IIR_FIR.c => silk_resampler_private_IIR_FIR.c} (69%) rename silk/{SKP_Silk_resampler_private_copy.c => silk_resampler_private_copy.c} (77%) rename silk/{SKP_Silk_resampler_private_down4.c => silk_resampler_private_down4.c} (78%) rename silk/{SKP_Silk_resampler_private_down_FIR.c => silk_resampler_private_down_FIR.c} (82%) rename silk/{SKP_Silk_resampler_private_up2_HQ.c => silk_resampler_private_up2_HQ.c} (72%) rename silk/{SKP_Silk_resampler_private_up4.c => silk_resampler_private_up4.c} (88%) rename silk/{SKP_Silk_resampler_rom.c => silk_resampler_rom.c} (71%) rename silk/{SKP_Silk_resampler_rom.h => silk_resampler_rom.h} (59%) rename silk/{SKP_Silk_resampler_structs.h => silk_resampler_structs.h} (72%) rename silk/{SKP_Silk_resampler_up2.c => silk_resampler_up2.c} (77%) rename silk/{SKP_Silk_scale_copy_vector16.c => silk_scale_copy_vector16.c} (95%) rename silk/{SKP_Silk_scale_vector.c => silk_scale_vector.c} (94%) rename silk/{SKP_Silk_schur.c => silk_schur.c} (80%) rename silk/{SKP_Silk_schur64.c => silk_schur64.c} (90%) rename silk/{SKP_Silk_shell_coder.c => silk_shell_coder.c} (69%) rename silk/{SKP_Silk_sigm_Q15.c => silk_sigm_Q15.c} (78%) rename silk/{SKP_Silk_sort.c => silk_sort.c} (77%) create mode 100644 silk/silk_stereo_LR_to_MS.c rename silk/{SKP_Silk_stereo_MS_to_LR.c => silk_stereo_MS_to_LR.c} (67%) rename silk/{SKP_Silk_stereo_decode_pred.c => silk_stereo_decode_pred.c} (69%) create mode 100644 silk/silk_stereo_encode_pred.c rename silk/{SKP_Silk_stereo_find_predictor.c => silk_stereo_find_predictor.c} (55%) rename silk/{SKP_Silk_stereo_encode_pred.c => silk_stereo_quant_pred.c} (68%) rename silk/{SKP_Silk_structs.h => silk_structs.h} (86%) rename silk/{SKP_Silk_sum_sqr_shift.c => silk_sum_sqr_shift.c} (96%) rename silk/{SKP_Silk_LSF_cos_table.c => silk_table_LSF_cos.c} (94%) create mode 100644 silk/silk_tables.h rename silk/{SKP_Silk_tables_LTP.c => silk_tables_LTP.c} (78%) rename silk/{SKP_Silk_tables_NLSF_CB_NB_MB.c => silk_tables_NLSF_CB_NB_MB.c} (89%) rename silk/{SKP_Silk_tables_NLSF_CB_WB.c => silk_tables_NLSF_CB_WB.c} (91%) rename silk/{SKP_Silk_tables_gain.c => silk_tables_gain.c} (90%) rename silk/{SKP_Silk_tables_other.c => silk_tables_other.c} (62%) rename silk/{SKP_Silk_tables_pitch_lag.c => silk_tables_pitch_lag.c} (85%) rename silk/{SKP_Silk_tables_pulses_per_block.c => silk_tables_pulses_per_block.c} (90%) rename silk/{SKP_Silk_tuning_parameters.h => silk_tuning_parameters.h} (86%) rename silk/{SKP_Silk_typedef.h => silk_typedef.h} (96%) diff --git a/doc/build_draft.sh b/doc/build_draft.sh index 35ceeb48..3035adc9 100755 --- a/doc/build_draft.sh +++ b/doc/build_draft.sh @@ -11,16 +11,23 @@ destdir="opus_source" echo packaging source code rm -rf "${destdir}" mkdir "${destdir}" +mkdir "${destdir}/src" +mkdir "${destdir}/silk" +mkdir "${destdir}/silk/float" +mkdir "${destdir}/silk/fixed" +mkdir "${destdir}/libcelt" for f in `cat "${toplevel}"/opus_sources.mk "${toplevel}"/celt_sources.mk \ "${toplevel}"/silk_sources.mk "${toplevel}"/opus_headers.txt \ "${toplevel}"/celt_headers.txt "${toplevel}"/silk_headers.txt \ | grep '\.[ch]' | sed -e 's/^.*=//' -e 's/\\\\//'` ; do - cp -a "${toplevel}/${f}" "${destdir}" + cp -a "${toplevel}/${f}" "${destdir}/${f}" done +cp -a "${toplevel}"/src/test_opus.c "${destdir}"/src/ cp -a "${toplevel}"/Makefile.draft "${destdir}"/Makefile cp -a "${toplevel}"/opus_sources.mk "${destdir}"/ cp -a "${toplevel}"/celt_sources.mk "${destdir}"/ -cp -a "${toplevel}"/silk_sources.mk "${destdir}"/ +cat "${toplevel}"/silk_sources.mk | sed 's/^if /ifdef /' \ + > "${destdir}"/silk_sources.mk cp -a "${toplevel}"/README.draft "${destdir}"/README cp -a "${toplevel}"/COPYING "${destdir}"/COPYING diff --git a/libcelt/celt_header.h b/libcelt/celt_header.h deleted file mode 100644 index 3777484f..00000000 --- a/libcelt/celt_header.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright (c) 2007 CSIRO - Copyright (c) 2007-2008 Xiph.Org Foundation - Written by Jean-Marc Valin */ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef CELT_HEADER_H -#define CELT_HEADER_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "celt.h" -#include "celt_types.h" - -/** Header data to be used for Ogg files (or possibly other encapsulation) - @brief Header data - */ -typedef struct { - char codec_id[8]; /**< MUST be "CELT " (four spaces) */ - char codec_version[20]; /**< Version used (as string) */ - celt_int32 version_id; /**< Version id (negative for until stream is frozen) */ - celt_int32 header_size; /**< Size of this header */ - celt_int32 sample_rate; /**< Sampling rate of the original audio */ - celt_int32 nb_channels; /**< Number of channels */ - celt_int32 frame_size; /**< Samples per frame (per channel) */ - celt_int32 overlap; /**< Overlapping samples (per channel) */ - celt_int32 bytes_per_packet; /**< Number of bytes per compressed packet (0 if unknown) */ - celt_int32 extra_headers; /**< Number of additional headers that follow this header */ -} CELTHeader; - -/** Creates a basic header struct */ -EXPORT int celt_header_init(CELTHeader *header, const CELTMode *m, int frame_size, int channels); - -EXPORT int celt_header_to_packet(const CELTHeader *header, unsigned char *packet, celt_uint32 size); - -EXPORT int celt_header_from_packet(const unsigned char *packet, celt_uint32 size, CELTHeader *header); - -#ifdef __cplusplus -} -#endif - -#endif /* CELT_HEADER_H */ diff --git a/libcelt/libcelt.vcxproj b/libcelt/libcelt.vcxproj index fe04999e..6be1813d 100644 --- a/libcelt/libcelt.vcxproj +++ b/libcelt/libcelt.vcxproj @@ -75,7 +75,6 @@ - @@ -109,7 +108,6 @@ - diff --git a/libcelt/libcelt.vcxproj.filters b/libcelt/libcelt.vcxproj.filters index 5c53e5c8..4e650b91 100644 --- a/libcelt/libcelt.vcxproj.filters +++ b/libcelt/libcelt.vcxproj.filters @@ -93,9 +93,6 @@ Header Files - - Header Files - Header Files @@ -119,9 +116,6 @@ Source Files - - Source Files - Source Files diff --git a/opus.sln b/opus.sln index 2df4309e..c248b95f 100644 --- a/opus.sln +++ b/opus.sln @@ -2,12 +2,30 @@ Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "silk_common", "silk\silk_common.vcxproj", "{C303D2FC-FF97-49B8-9DDD-467B4C9A0B16}" + ProjectSection(ProjectDependencies) = postProject + {245603E3-F580-41A5-9632-B25FE3372CBF} = {245603E3-F580-41A5-9632-B25FE3372CBF} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "opus", "src\opus.vcxproj", "{219EC965-228A-1824-174D-96449D05F88A}" + ProjectSection(ProjectDependencies) = postProject + {8484C90D-1561-402F-A91D-2DB10F8C5171} = {8484C90D-1561-402F-A91D-2DB10F8C5171} + {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782} = {9C4961D2-5DDB-40C7-9BE8-CA918DC4E782} + {245603E3-F580-41A5-9632-B25FE3372CBF} = {245603E3-F580-41A5-9632-B25FE3372CBF} + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16} = {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "silk_fixed", "silk\fixed\silk_fixed.vcxproj", "{8484C90D-1561-402F-A91D-2DB10F8C5171}" + ProjectSection(ProjectDependencies) = postProject + {245603E3-F580-41A5-9632-B25FE3372CBF} = {245603E3-F580-41A5-9632-B25FE3372CBF} + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16} = {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "silk_float", "silk\float\silk_float.vcxproj", "{9C4961D2-5DDB-40C7-9BE8-CA918DC4E782}" + ProjectSection(ProjectDependencies) = postProject + {8484C90D-1561-402F-A91D-2DB10F8C5171} = {8484C90D-1561-402F-A91D-2DB10F8C5171} + {245603E3-F580-41A5-9632-B25FE3372CBF} = {245603E3-F580-41A5-9632-B25FE3372CBF} + {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16} = {C303D2FC-FF97-49B8-9DDD-467B4C9A0B16} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcelt", "libcelt\libcelt.vcxproj", "{245603E3-F580-41A5-9632-B25FE3372CBF}" EndProject diff --git a/silk/SKP_Silk_stereo_LR_to_MS.c b/silk/SKP_Silk_stereo_LR_to_MS.c deleted file mode 100644 index 190d95f4..00000000 --- a/silk/SKP_Silk_stereo_LR_to_MS.c +++ /dev/null @@ -1,107 +0,0 @@ -/*********************************************************************** -Copyright (c) 2006-2011, Skype Limited. All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, (subject to the limitations in the disclaimer below) -are permitted provided that the following conditions are met: -- Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. -- Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. -- Neither the name of Skype Limited, nor the names of specific -contributors, may be used to endorse or promote products derived from -this software without specific prior written permission. -NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED -BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, -BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -***********************************************************************/ - -#include "SKP_Silk_main.h" - -/* Convert Left/Right stereo signal to adaptive Mid/Side representation */ -void SKP_Silk_stereo_LR_to_MS( - ec_enc *psRangeEnc, /* I/O Compressor data structure */ - stereo_state *state, /* I/O State */ - SKP_int16 x1[], /* I/O Left input signal, becomes mid signal */ - SKP_int16 x2[], /* I/O Right input signal, becomes side signal */ - SKP_int fs_kHz, /* I Samples rate (kHz) */ - SKP_int frame_length /* I Number of samples */ -) -{ - SKP_int n, denom_Q16, delta0_Q13, delta1_Q13; - SKP_int32 sum, diff, pred_Q13[ 2 ], pred0_Q13, pred1_Q13; - SKP_int16 mid[ MAX_FRAME_LENGTH + 2 ], side[ MAX_FRAME_LENGTH + 2 ]; - SKP_int16 LP_mid[ MAX_FRAME_LENGTH ], HP_mid[ MAX_FRAME_LENGTH ]; - SKP_int16 LP_side[ MAX_FRAME_LENGTH ], HP_side[ MAX_FRAME_LENGTH ]; - - /* Convert to basic mid/side signals */ - for( n = 0; n < frame_length; n++ ) { - sum = x1[ n ] + (SKP_int32)x2[ n ]; - diff = x1[ n ] - (SKP_int32)x2[ n ]; - mid[ n + 2 ] = (SKP_int16)SKP_RSHIFT_ROUND( sum, 1 ); - side[ n + 2 ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( diff, 1 ) ); - } - - /* Buffering */ - SKP_memcpy( mid, state->sMid, 2 * sizeof( SKP_int16 ) ); - SKP_memcpy( side, state->sSide, 2 * sizeof( SKP_int16 ) ); - SKP_memcpy( state->sMid, &mid[ frame_length ], 2 * sizeof( SKP_int16 ) ); - SKP_memcpy( state->sSide, &side[ frame_length ], 2 * sizeof( SKP_int16 ) ); - - /* LP and HP filter mid signal */ - for( n = 0; n < frame_length; n++ ) { - sum = SKP_RSHIFT_ROUND( SKP_ADD_LSHIFT( mid[ n ] + mid[ n + 2 ], mid[ n + 1 ], 1 ), 2 ); - LP_mid[ n ] = sum; - HP_mid[ n ] = mid[ n + 1 ] - sum; - } - - /* LP and HP filter side signal */ - for( n = 0; n < frame_length; n++ ) { - sum = SKP_RSHIFT_ROUND( SKP_ADD_LSHIFT( side[ n ] + side[ n + 2 ], side[ n + 1 ], 1 ), 2 ); - LP_side[ n ] = sum; - HP_side[ n ] = side[ n + 1 ] - sum; - } - - /* Find predictors */ - pred_Q13[ 0 ] = SKP_Silk_stereo_find_predictor( LP_mid, LP_side, frame_length ); - pred_Q13[ 1 ] = SKP_Silk_stereo_find_predictor( HP_mid, HP_side, frame_length ); - - /* Quantize and encode predictors */ - SKP_Silk_stereo_encode_pred( psRangeEnc, pred_Q13 ); - - /* Interpolate predictors and subtract prediction from side channel */ - pred0_Q13 = -state->pred_prev_Q13[ 0 ]; - pred1_Q13 = -state->pred_prev_Q13[ 1 ]; - denom_Q16 = SKP_DIV32_16( 1 << 16, STEREO_INTERP_LEN_MS * fs_kHz ); - delta0_Q13 = -SKP_RSHIFT_ROUND( SKP_SMULBB( pred_Q13[ 0 ] - state->pred_prev_Q13[ 0 ], denom_Q16 ), 16 ); - delta1_Q13 = -SKP_RSHIFT_ROUND( SKP_SMULBB( pred_Q13[ 1 ] - state->pred_prev_Q13[ 1 ], denom_Q16 ), 16 ); - for( n = 0; n < STEREO_INTERP_LEN_MS * fs_kHz; n++ ) { - pred0_Q13 += delta0_Q13; - pred1_Q13 += delta1_Q13; - sum = SKP_LSHIFT( SKP_ADD_LSHIFT( mid[ n ] + mid[ n + 2 ], mid[ n + 1 ], 1 ), 9 ); /* Q11 */ - sum = SKP_SMLAWB( SKP_LSHIFT( ( SKP_int32 )side[ n + 1 ], 8 ), sum, pred0_Q13 ); /* Q8 */ - sum = SKP_SMLAWB( sum, SKP_LSHIFT( ( SKP_int32 )mid[ n + 1 ], 11 ), pred1_Q13 ); /* Q8 */ - x2[ n ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( sum, 8 ) ); - } - pred0_Q13 = -pred_Q13[ 0 ]; - pred1_Q13 = -pred_Q13[ 1 ]; - for( n = STEREO_INTERP_LEN_MS * fs_kHz; n < frame_length; n++ ) { - sum = SKP_LSHIFT( SKP_ADD_LSHIFT( mid[ n ] + mid[ n + 2 ], mid[ n + 1 ], 1 ), 9 ); /* Q11 */ - sum = SKP_SMLAWB( SKP_LSHIFT( ( SKP_int32 )side[ n + 1 ], 8 ), sum, pred0_Q13 ); /* Q8 */ - sum = SKP_SMLAWB( sum, SKP_LSHIFT( ( SKP_int32 )mid[ n + 1 ], 11 ), pred1_Q13 ); /* Q8 */ - x2[ n ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( sum, 8 ) ); - } - state->pred_prev_Q13[ 0 ] = pred_Q13[ 0 ]; - state->pred_prev_Q13[ 1 ] = pred_Q13[ 1 ]; - - SKP_memcpy( x1, mid + 1, frame_length * sizeof( SKP_int16 ) ); -} diff --git a/silk/SKP_Silk_tables.h b/silk/SKP_Silk_tables.h deleted file mode 100644 index 7cb5ac95..00000000 --- a/silk/SKP_Silk_tables.h +++ /dev/null @@ -1,117 +0,0 @@ -/*********************************************************************** -Copyright (c) 2006-2011, Skype Limited. All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, (subject to the limitations in the disclaimer below) -are permitted provided that the following conditions are met: -- Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. -- Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. -- Neither the name of Skype Limited, nor the names of specific -contributors, may be used to endorse or promote products derived from -this software without specific prior written permission. -NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED -BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND -CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, -BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -***********************************************************************/ - -#ifndef SKP_SILK_TABLES_H -#define SKP_SILK_TABLES_H - -#include "SKP_Silk_define.h" -#include "SKP_Silk_structs.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* entropy coding tables */ -extern const SKP_uint8 SKP_Silk_gain_iCDF[ 3 ][ N_LEVELS_QGAIN / 8 ]; /* 24 */ -extern const SKP_uint8 SKP_Silk_delta_gain_iCDF[ MAX_DELTA_GAIN_QUANT - MIN_DELTA_GAIN_QUANT + 1 ]; /* 41 */ - -extern const SKP_uint8 SKP_Silk_pitch_lag_iCDF[ 2 * ( PITCH_EST_MAX_LAG_MS - PITCH_EST_MIN_LAG_MS ) ]; /* 32 */ -extern const SKP_uint8 SKP_Silk_pitch_delta_iCDF[ 21 ]; /* 21 */ -extern const SKP_uint8 SKP_Silk_pitch_contour_iCDF[ 34 ]; /* 34 */ -extern const SKP_uint8 SKP_Silk_pitch_contour_NB_iCDF[ 11 ]; /* 11 */ -extern const SKP_uint8 SKP_Silk_pitch_contour_10_ms_iCDF[ 12 ]; /* 12 */ -extern const SKP_uint8 SKP_Silk_pitch_contour_10_ms_NB_iCDF[ 3 ]; /* 3 */ - -extern const SKP_uint8 SKP_Silk_pulses_per_block_iCDF[ N_RATE_LEVELS ][ MAX_PULSES + 2 ]; /* 180 */ -extern const SKP_uint8 SKP_Silk_pulses_per_block_BITS_Q5[ N_RATE_LEVELS - 1 ][ MAX_PULSES + 2 ]; /* 162 */ - -extern const SKP_uint8 SKP_Silk_rate_levels_iCDF[ 2 ][ N_RATE_LEVELS - 1 ]; /* 18 */ -extern const SKP_uint8 SKP_Silk_rate_levels_BITS_Q5[ 2 ][ N_RATE_LEVELS - 1 ]; /* 18 */ - -extern const SKP_uint8 SKP_Silk_max_pulses_table[ 4 ]; /* 4 */ - -extern const SKP_uint8 SKP_Silk_shell_code_table0[ 44 ]; /* 44 */ -extern const SKP_uint8 SKP_Silk_shell_code_table1[ 65 ]; /* 65 */ -extern const SKP_uint8 SKP_Silk_shell_code_table2[ 90 ]; /* 90 */ -extern const SKP_uint8 SKP_Silk_shell_code_table3[ 152 ]; /* 152 */ -extern const SKP_uint8 SKP_Silk_shell_code_table_offsets[ MAX_PULSES + 1 ]; /* 17 */ - -extern const SKP_uint8 SKP_Silk_lsb_iCDF[ 2 ]; /* 2 */ - -extern const SKP_uint8 SKP_Silk_sign_iCDF[ 36 ]; /* 36 */ - -extern const SKP_uint8 SKP_Silk_uniform2_iCDF[ 2 ]; /* 2 */ -extern const SKP_uint8 SKP_Silk_uniform3_iCDF[ 3 ]; /* 3 */ -extern const SKP_uint8 SKP_Silk_uniform4_iCDF[ 4 ]; /* 4 */ -extern const SKP_uint8 SKP_Silk_uniform5_iCDF[ 5 ]; /* 5 */ -extern const SKP_uint8 SKP_Silk_uniform6_iCDF[ 6 ]; /* 6 */ -extern const SKP_uint8 SKP_Silk_uniform8_iCDF[ 8 ]; /* 8 */ - -extern const SKP_uint8 SKP_Silk_NLSF_EXT_iCDF[ 7 ]; /* 7 */ - -extern const SKP_uint8 SKP_Silk_LTP_per_index_iCDF[ 3 ]; /* 3 */ -extern const SKP_uint8 * const SKP_Silk_LTP_gain_iCDF_ptrs[ NB_LTP_CBKS ]; /* 3 */ -extern const SKP_uint8 * const SKP_Silk_LTP_gain_BITS_Q5_ptrs[ NB_LTP_CBKS ]; /* 3 */ -extern const SKP_int16 SKP_Silk_LTP_gain_middle_avg_RD_Q14; -extern const SKP_int8 * const SKP_Silk_LTP_vq_ptrs_Q7[ NB_LTP_CBKS ]; /* 168 */ -extern const SKP_int8 SKP_Silk_LTP_vq_sizes[ NB_LTP_CBKS ]; /* 3 */ - -extern const SKP_uint8 SKP_Silk_LTPscale_iCDF[ 3 ]; /* 4 */ -extern const SKP_int16 SKP_Silk_LTPScales_table_Q14[ 3 ]; - -extern const SKP_uint8 SKP_Silk_type_offset_VAD_iCDF[ 4 ]; /* 4 */ -extern const SKP_uint8 SKP_Silk_type_offset_no_VAD_iCDF[ 2 ]; /* 2 */ - -extern const SKP_int16 SKP_Silk_stereo_pred_quant_Q13[ STEREO_QUANT_TAB_SIZE ]; /* 32 */ -extern const SKP_uint8 SKP_Silk_stereo_pred_joint_iCDF[ 25 ]; /* 25 */ - -extern const SKP_uint8 * const SKP_Silk_LBRR_flags_iCDF_ptr[ 2 ]; /* 10 */ - -extern const SKP_uint8 SKP_Silk_NLSF_interpolation_factor_iCDF[ 5 ]; /* 5 */ - -extern const SKP_Silk_NLSF_CB_struct SKP_Silk_NLSF_CB_WB; -extern const SKP_Silk_NLSF_CB_struct SKP_Silk_NLSF_CB_NB_MB; - -/* Piece-wise linear mapping from bitrate in kbps to coding quality in dB SNR */ -extern const SKP_int32 TargetRate_table_NB[ TARGET_RATE_TAB_SZ ]; -extern const SKP_int32 TargetRate_table_MB[ TARGET_RATE_TAB_SZ ]; -extern const SKP_int32 TargetRate_table_WB[ TARGET_RATE_TAB_SZ ]; -extern const SKP_int16 SNR_table_Q1[ TARGET_RATE_TAB_SZ ]; - -/* Quantization offsets */ -extern const SKP_int16 SKP_Silk_Quantization_Offsets_Q10[ 2 ][ 2 ]; - -/* Interpolation points for filter coefficients used in the bandwidth transition smoother */ -extern const SKP_int32 SKP_Silk_Transition_LP_B_Q28[ TRANSITION_INT_NUM ][ TRANSITION_NB ]; -extern const SKP_int32 SKP_Silk_Transition_LP_A_Q28[ TRANSITION_INT_NUM ][ TRANSITION_NA ]; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/silk/fixed/SKP_Silk_LTP_analysis_filter_FIX.c b/silk/fixed/silk_LTP_analysis_filter_FIX.c similarity index 96% rename from silk/fixed/SKP_Silk_LTP_analysis_filter_FIX.c rename to silk/fixed/silk_LTP_analysis_filter_FIX.c index 4e21d65e..2e864a49 100644 --- a/silk/fixed/SKP_Silk_LTP_analysis_filter_FIX.c +++ b/silk/fixed/silk_LTP_analysis_filter_FIX.c @@ -25,9 +25,9 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FIX.h" +#include "silk_main_FIX.h" -void SKP_Silk_LTP_analysis_filter_FIX( +void silk_LTP_analysis_filter_FIX( SKP_int16 *LTP_res, /* O: LTP residual signal of length MAX_NB_SUBFR * ( pre_length + subfr_length ) */ const SKP_int16 *x, /* I: Pointer to input signal with at least max( pitchL ) preceeding samples */ const SKP_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ],/* I: LTP_ORDER LTP coefficients for each MAX_NB_SUBFR subframe */ diff --git a/silk/fixed/SKP_Silk_LTP_scale_ctrl_FIX.c b/silk/fixed/silk_LTP_scale_ctrl_FIX.c similarity index 82% rename from silk/fixed/SKP_Silk_LTP_scale_ctrl_FIX.c rename to silk/fixed/silk_LTP_scale_ctrl_FIX.c index 08516050..946d24cc 100644 --- a/silk/fixed/SKP_Silk_LTP_scale_ctrl_FIX.c +++ b/silk/fixed/silk_LTP_scale_ctrl_FIX.c @@ -25,11 +25,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FIX.h" +#include "silk_main_FIX.h" -void SKP_Silk_LTP_scale_ctrl_FIX( - SKP_Silk_encoder_state_FIX *psEnc, /* I/O encoder state FIX */ - SKP_Silk_encoder_control_FIX *psEncCtrl /* I/O encoder control FIX */ +void silk_LTP_scale_ctrl_FIX( + silk_encoder_state_FIX *psEnc, /* I/O encoder state FIX */ + silk_encoder_control_FIX *psEncCtrl /* I/O encoder control FIX */ ) { SKP_int round_loss; @@ -40,13 +40,13 @@ void SKP_Silk_LTP_scale_ctrl_FIX( psEnc->prevLTPredCodGain_Q7 = psEncCtrl->LTPredCodGain_Q7; /* Only scale if first frame in packet */ - if( psEnc->sCmn.nFramesAnalyzed == 0 ) { + if( psEnc->sCmn.nFramesEncoded == 0 ) { round_loss = psEnc->sCmn.PacketLoss_perc + psEnc->sCmn.nFramesPerPacket - 1; psEnc->sCmn.indices.LTP_scaleIndex = (SKP_int8)SKP_LIMIT( - SKP_SMULWB( SKP_SMULBB( round_loss, psEnc->HPLTPredCodGain_Q7 ), SKP_FIX_CONST( 0.1, 9 ) ), 0, 2 ); + SKP_SMULWB( SKP_SMULBB( round_loss, psEnc->HPLTPredCodGain_Q7 ), SILK_FIX_CONST( 0.1, 9 ) ), 0, 2 ); } else { /* Default is minimum scaling */ psEnc->sCmn.indices.LTP_scaleIndex = 0; } - psEncCtrl->LTP_scale_Q14 = SKP_Silk_LTPScales_table_Q14[ psEnc->sCmn.indices.LTP_scaleIndex ]; + psEncCtrl->LTP_scale_Q14 = silk_LTPScales_table_Q14[ psEnc->sCmn.indices.LTP_scaleIndex ]; } diff --git a/silk/fixed/SKP_Silk_corrMatrix_FIX.c b/silk/fixed/silk_corrMatrix_FIX.c similarity index 93% rename from silk/fixed/SKP_Silk_corrMatrix_FIX.c rename to silk/fixed/silk_corrMatrix_FIX.c index 1ac1b195..453cac84 100644 --- a/silk/fixed/SKP_Silk_corrMatrix_FIX.c +++ b/silk/fixed/silk_corrMatrix_FIX.c @@ -29,10 +29,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * Correlation Matrix Computations for LS estimate. **********************************************************************/ -#include "SKP_Silk_main_FIX.h" +#include "silk_main_FIX.h" /* Calculates correlation vector X'*t */ -void SKP_Silk_corrVector_FIX( +void silk_corrVector_FIX( const SKP_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */ const SKP_int16 *t, /* I target vector [L] */ const SKP_int L, /* I Length of vectors */ @@ -61,14 +61,14 @@ void SKP_Silk_corrVector_FIX( } else { SKP_assert( rshifts == 0 ); for( lag = 0; lag < order; lag++ ) { - Xt[ lag ] = SKP_Silk_inner_prod_aligned( ptr1, ptr2, L ); /* X[:,lag]'*t */ + Xt[ lag ] = silk_inner_prod_aligned( ptr1, ptr2, L ); /* X[:,lag]'*t */ ptr1--; /* Go to next column of X */ } } } /* Calculates correlation matrix X'*X */ -void SKP_Silk_corrMatrix_FIX( +void silk_corrMatrix_FIX( const SKP_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */ const SKP_int L, /* I Length of vectors */ const SKP_int order, /* I Max lag for correlation */ @@ -82,9 +82,9 @@ void SKP_Silk_corrMatrix_FIX( const SKP_int16 *ptr1, *ptr2; /* Calculate energy to find shift used to fit in 32 bits */ - SKP_Silk_sum_sqr_shift( &energy, &rshifts_local, x, L + order - 1 ); + silk_sum_sqr_shift( &energy, &rshifts_local, x, L + order - 1 ); /* Add shifts to get the desired head room */ - head_room_rshifts = SKP_max( head_room - SKP_Silk_CLZ32( energy ), 0 ); + head_room_rshifts = SKP_max( head_room - silk_CLZ32( energy ), 0 ); energy = SKP_RSHIFT32( energy, head_room_rshifts ); rshifts_local += head_room_rshifts; @@ -134,7 +134,7 @@ void SKP_Silk_corrMatrix_FIX( } else { for( lag = 1; lag < order; lag++ ) { /* Inner product of column 0 and column lag: X[:,0]'*X[:,lag] */ - energy = SKP_Silk_inner_prod_aligned( ptr1, ptr2, L ); + energy = silk_inner_prod_aligned( ptr1, ptr2, L ); matrix_ptr( XX, lag, 0, order ) = energy; matrix_ptr( XX, 0, lag, order ) = energy; /* Calculate remaining off diagonal: X[:,j]'*X[:,j + lag] */ diff --git a/silk/fixed/SKP_Silk_encode_frame_FIX.c b/silk/fixed/silk_encode_frame_FIX.c similarity index 80% rename from silk/fixed/SKP_Silk_encode_frame_FIX.c rename to silk/fixed/silk_encode_frame_FIX.c index a1fbf1ed..06d1d321 100644 --- a/silk/fixed/SKP_Silk_encode_frame_FIX.c +++ b/silk/fixed/silk_encode_frame_FIX.c @@ -25,19 +25,19 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FIX.h" -#include "SKP_Silk_tuning_parameters.h" +#include "silk_main_FIX.h" +#include "silk_tuning_parameters.h" /****************/ /* Encode frame */ /****************/ -SKP_int SKP_Silk_encode_frame_FIX( - SKP_Silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */ +SKP_int silk_encode_frame_FIX( + silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */ SKP_int32 *pnBytesOut, /* O Number of payload bytes */ ec_enc *psRangeEnc /* I/O compressor data structure */ ) { - SKP_Silk_encoder_control_FIX sEncCtrl; + silk_encoder_control_FIX sEncCtrl; SKP_int ret = 0; SKP_int16 *x_frame, *res_pitch_frame; SKP_int16 xfw[ MAX_FRAME_LENGTH ]; @@ -58,16 +58,16 @@ TIC(ENCODE_FRAME) /* Voice Activity Detection */ /****************************/ TIC(VAD) - ret = SKP_Silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf ); + ret = silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf - 1 ); TOC(VAD) /**************************************************/ /* Convert speech activity into VAD and DTX flags */ /**************************************************/ - if( psEnc->sCmn.nFramesAnalyzed == 0 ) { + if( psEnc->sCmn.nFramesEncoded == 0 ) { psEnc->sCmn.inDTX = psEnc->sCmn.useDTX; } - if( psEnc->sCmn.speech_activity_Q8 < SKP_FIX_CONST( SPEECH_ACTIVITY_DTX_THRES, 8 ) ) { + if( psEnc->sCmn.speech_activity_Q8 < SILK_FIX_CONST( SPEECH_ACTIVITY_DTX_THRES, 8 ) ) { psEnc->sCmn.indices.signalType = TYPE_NO_VOICE_ACTIVITY; psEnc->sCmn.noSpeechCounter++; if( psEnc->sCmn.noSpeechCounter < NB_SPEECH_FRAMES_BEFORE_DTX ) { @@ -76,76 +76,76 @@ TOC(VAD) psEnc->sCmn.noSpeechCounter = NB_SPEECH_FRAMES_BEFORE_DTX; psEnc->sCmn.inDTX = 0; } - psEnc->sCmn.VAD_flags[ psEnc->sCmn.nFramesAnalyzed ] = 0; + psEnc->sCmn.VAD_flags[ psEnc->sCmn.nFramesEncoded ] = 0; } else { psEnc->sCmn.noSpeechCounter = 0; psEnc->sCmn.inDTX = 0; psEnc->sCmn.indices.signalType = TYPE_UNVOICED; - psEnc->sCmn.VAD_flags[ psEnc->sCmn.nFramesAnalyzed ] = 1; + psEnc->sCmn.VAD_flags[ psEnc->sCmn.nFramesEncoded ] = 1; } - /*******************************************/ - /* High-pass filtering of the input signal */ - /*******************************************/ -TIC(HP_IN) - SKP_Silk_HP_variable_cutoff( &psEnc->sCmn, x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, psEnc->sCmn.inputBuf, psEnc->sCmn.frame_length ); -TOC(HP_IN) - + /***************************************/ /* Ensure smooth bandwidth transitions */ - SKP_Silk_LP_variable_cutoff( &psEnc->sCmn.sLP, x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, psEnc->sCmn.frame_length ); + /***************************************/ + silk_LP_variable_cutoff( &psEnc->sCmn.sLP, psEnc->sCmn.inputBuf - 1, psEnc->sCmn.frame_length ); + /*******************************************/ + /* Copy new frame to front of input buffer */ + /*******************************************/ + SKP_memcpy( x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, psEnc->sCmn.inputBuf - 1, psEnc->sCmn.frame_length * sizeof( SKP_int16 ) ); + /*****************************************/ /* Find pitch lags, initial LPC analysis */ /*****************************************/ TIC(FIND_PITCH) - SKP_Silk_find_pitch_lags_FIX( psEnc, &sEncCtrl, res_pitch, x_frame ); + silk_find_pitch_lags_FIX( psEnc, &sEncCtrl, res_pitch, x_frame ); TOC(FIND_PITCH) /************************/ /* Noise shape analysis */ /************************/ TIC(NOISE_SHAPE_ANALYSIS) - SKP_Silk_noise_shape_analysis_FIX( psEnc, &sEncCtrl, res_pitch_frame, x_frame ); + silk_noise_shape_analysis_FIX( psEnc, &sEncCtrl, res_pitch_frame, x_frame ); TOC(NOISE_SHAPE_ANALYSIS) /***************************************************/ /* Find linear prediction coefficients (LPC + LTP) */ /***************************************************/ TIC(FIND_PRED_COEF) - SKP_Silk_find_pred_coefs_FIX( psEnc, &sEncCtrl, res_pitch, x_frame ); + silk_find_pred_coefs_FIX( psEnc, &sEncCtrl, res_pitch, x_frame ); TOC(FIND_PRED_COEF) /****************************************/ /* Process gains */ /****************************************/ TIC(PROCESS_GAINS) - SKP_Silk_process_gains_FIX( psEnc, &sEncCtrl ); + silk_process_gains_FIX( psEnc, &sEncCtrl ); TOC(PROCESS_GAINS) - /****************************************/ - /* Low Bitrate Redundant Encoding */ - /****************************************/ -TIC(LBRR) - SKP_Silk_LBRR_encode_FIX( psEnc, &sEncCtrl, xfw ); -TOC(LBRR) - /*****************************************/ /* Prefiltering for noise shaper */ /*****************************************/ TIC(PREFILTER) - SKP_Silk_prefilter_FIX( psEnc, &sEncCtrl, xfw, x_frame ); + silk_prefilter_FIX( psEnc, &sEncCtrl, xfw, x_frame ); TOC(PREFILTER) + /****************************************/ + /* Low Bitrate Redundant Encoding */ + /****************************************/ +TIC(LBRR) + silk_LBRR_encode_FIX( psEnc, &sEncCtrl, xfw ); +TOC(LBRR) + /*****************************************/ /* Noise shaping quantization */ /*****************************************/ TIC(NSQ) if( psEnc->sCmn.nStatesDelayedDecision > 1 || psEnc->sCmn.warping_Q16 > 0 ) { - SKP_Silk_NSQ_del_dec( &psEnc->sCmn, &psEnc->sCmn.sNSQ, &psEnc->sCmn.indices, xfw, psEnc->sCmn.pulses, + silk_NSQ_del_dec( &psEnc->sCmn, &psEnc->sCmn.sNSQ, &psEnc->sCmn.indices, xfw, psEnc->sCmn.pulses, sEncCtrl.PredCoef_Q12[ 0 ], sEncCtrl.LTPCoef_Q14, sEncCtrl.AR2_Q13, sEncCtrl.HarmShapeGain_Q14, sEncCtrl.Tilt_Q14, sEncCtrl.LF_shp_Q14, sEncCtrl.Gains_Q16, sEncCtrl.pitchL, sEncCtrl.Lambda_Q10, sEncCtrl.LTP_scale_Q14 ); } else { - SKP_Silk_NSQ( &psEnc->sCmn, &psEnc->sCmn.sNSQ, &psEnc->sCmn.indices, xfw, psEnc->sCmn.pulses, + silk_NSQ( &psEnc->sCmn, &psEnc->sCmn.sNSQ, &psEnc->sCmn.indices, xfw, psEnc->sCmn.pulses, sEncCtrl.PredCoef_Q12[ 0 ], sEncCtrl.LTPCoef_Q14, sEncCtrl.AR2_Q13, sEncCtrl.HarmShapeGain_Q14, sEncCtrl.Tilt_Q14, sEncCtrl.LF_shp_Q14, sEncCtrl.Gains_Q16, sEncCtrl.pitchL, sEncCtrl.Lambda_Q10, sEncCtrl.LTP_scale_Q14 ); } @@ -170,14 +170,14 @@ TOC(NSQ) /* Encode Parameters */ /****************************************/ TIC(ENCODE_PARAMS) - SKP_Silk_encode_indices( &psEnc->sCmn, psRangeEnc, psEnc->sCmn.nFramesAnalyzed, 0 ); + silk_encode_indices( &psEnc->sCmn, psRangeEnc, psEnc->sCmn.nFramesEncoded, 0 ); TOC(ENCODE_PARAMS) /****************************************/ /* Encode Excitation Signal */ /****************************************/ TIC(ENCODE_PULSES) - SKP_Silk_encode_pulses( psRangeEnc, psEnc->sCmn.indices.signalType, psEnc->sCmn.indices.quantOffsetType, + silk_encode_pulses( psRangeEnc, psEnc->sCmn.indices.signalType, psEnc->sCmn.indices.quantOffsetType, psEnc->sCmn.pulses, psEnc->sCmn.frame_length ); TOC(ENCODE_PULSES) @@ -185,12 +185,12 @@ TOC(ENCODE_PULSES) /* Finalize payload */ /****************************************/ psEnc->sCmn.first_frame_after_reset = 0; - if( ++psEnc->sCmn.nFramesAnalyzed >= psEnc->sCmn.nFramesPerPacket ) { + if( ++psEnc->sCmn.nFramesEncoded >= psEnc->sCmn.nFramesPerPacket ) { /* Payload size */ *pnBytesOut = SKP_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 ); /* Reset the number of frames in payload buffer */ - psEnc->sCmn.nFramesAnalyzed = 0; + psEnc->sCmn.nFramesEncoded = 0; } else { /* No payload this time */ *pnBytesOut = 0; @@ -243,30 +243,30 @@ TOC(ENCODE_FRAME) } /* Low-Bitrate Redundancy (LBRR) encoding. Reuse all parameters but encode excitation at lower bitrate */ -void SKP_Silk_LBRR_encode_FIX( - SKP_Silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */ - SKP_Silk_encoder_control_FIX *psEncCtrl, /* I/O Pointer to Silk FIX encoder control struct */ +void silk_LBRR_encode_FIX( + silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */ + silk_encoder_control_FIX *psEncCtrl, /* I/O Pointer to Silk FIX encoder control struct */ const SKP_int16 xfw[] /* I Input signal */ ) { SKP_int32 TempGains_Q16[ MAX_NB_SUBFR ]; - SideInfoIndices *psIndices_LBRR = &psEnc->sCmn.indices_LBRR[ psEnc->sCmn.nFramesAnalyzed ]; - SKP_Silk_nsq_state sNSQ_LBRR; + SideInfoIndices *psIndices_LBRR = &psEnc->sCmn.indices_LBRR[ psEnc->sCmn.nFramesEncoded ]; + silk_nsq_state sNSQ_LBRR; /*******************************************/ /* Control use of inband LBRR */ /*******************************************/ - if( psEnc->sCmn.LBRR_enabled && psEnc->sCmn.speech_activity_Q8 > SKP_FIX_CONST( LBRR_SPEECH_ACTIVITY_THRES, 8 ) ) { - psEnc->sCmn.LBRR_flags[ psEnc->sCmn.nFramesAnalyzed ] = 1; + if( psEnc->sCmn.LBRR_enabled && psEnc->sCmn.speech_activity_Q8 > SILK_FIX_CONST( LBRR_SPEECH_ACTIVITY_THRES, 8 ) ) { + psEnc->sCmn.LBRR_flags[ psEnc->sCmn.nFramesEncoded ] = 1; /* Copy noise shaping quantizer state and quantization indices from regular encoding */ - SKP_memcpy( &sNSQ_LBRR, &psEnc->sCmn.sNSQ, sizeof( SKP_Silk_nsq_state ) ); + SKP_memcpy( &sNSQ_LBRR, &psEnc->sCmn.sNSQ, sizeof( silk_nsq_state ) ); SKP_memcpy( psIndices_LBRR, &psEnc->sCmn.indices, sizeof( SideInfoIndices ) ); /* Save original gains */ SKP_memcpy( TempGains_Q16, psEncCtrl->Gains_Q16, psEnc->sCmn.nb_subfr * sizeof( SKP_int32 ) ); - if( psEnc->sCmn.nFramesAnalyzed == 0 || psEnc->sCmn.LBRR_flags[ psEnc->sCmn.nFramesAnalyzed - 1 ] == 0 ) { + if( psEnc->sCmn.nFramesEncoded == 0 || psEnc->sCmn.LBRR_flags[ psEnc->sCmn.nFramesEncoded - 1 ] == 0 ) { /* First frame in packet or previous frame not LBRR coded */ psEnc->sCmn.LBRRprevLastGainIndex = psEnc->sShape.LastGainIndex; @@ -277,20 +277,20 @@ void SKP_Silk_LBRR_encode_FIX( /* Decode to get gains in sync with decoder */ /* Overwrite unquantized gains with quantized gains */ - SKP_Silk_gains_dequant( psEncCtrl->Gains_Q16, psIndices_LBRR->GainsIndices, - &psEnc->sCmn.LBRRprevLastGainIndex, psEnc->sCmn.nFramesAnalyzed, psEnc->sCmn.nb_subfr ); + silk_gains_dequant( psEncCtrl->Gains_Q16, psIndices_LBRR->GainsIndices, + &psEnc->sCmn.LBRRprevLastGainIndex, psEnc->sCmn.nFramesEncoded, psEnc->sCmn.nb_subfr ); /*****************************************/ /* Noise shaping quantization */ /*****************************************/ if( psEnc->sCmn.nStatesDelayedDecision > 1 || psEnc->sCmn.warping_Q16 > 0 ) { - SKP_Silk_NSQ_del_dec( &psEnc->sCmn, &sNSQ_LBRR, psIndices_LBRR, xfw, - psEnc->sCmn.pulses_LBRR[ psEnc->sCmn.nFramesAnalyzed ], psEncCtrl->PredCoef_Q12[ 0 ], psEncCtrl->LTPCoef_Q14, + silk_NSQ_del_dec( &psEnc->sCmn, &sNSQ_LBRR, psIndices_LBRR, xfw, + psEnc->sCmn.pulses_LBRR[ psEnc->sCmn.nFramesEncoded ], psEncCtrl->PredCoef_Q12[ 0 ], psEncCtrl->LTPCoef_Q14, psEncCtrl->AR2_Q13, psEncCtrl->HarmShapeGain_Q14, psEncCtrl->Tilt_Q14, psEncCtrl->LF_shp_Q14, psEncCtrl->Gains_Q16, psEncCtrl->pitchL, psEncCtrl->Lambda_Q10, psEncCtrl->LTP_scale_Q14 ); } else { - SKP_Silk_NSQ( &psEnc->sCmn, &sNSQ_LBRR, psIndices_LBRR, xfw, - psEnc->sCmn.pulses_LBRR[ psEnc->sCmn.nFramesAnalyzed ], psEncCtrl->PredCoef_Q12[ 0 ], psEncCtrl->LTPCoef_Q14, + silk_NSQ( &psEnc->sCmn, &sNSQ_LBRR, psIndices_LBRR, xfw, + psEnc->sCmn.pulses_LBRR[ psEnc->sCmn.nFramesEncoded ], psEncCtrl->PredCoef_Q12[ 0 ], psEncCtrl->LTPCoef_Q14, psEncCtrl->AR2_Q13, psEncCtrl->HarmShapeGain_Q14, psEncCtrl->Tilt_Q14, psEncCtrl->LF_shp_Q14, psEncCtrl->Gains_Q16, psEncCtrl->pitchL, psEncCtrl->Lambda_Q10, psEncCtrl->LTP_scale_Q14 ); } diff --git a/silk/fixed/SKP_Silk_find_LPC_FIX.c b/silk/fixed/silk_find_LPC_FIX.c similarity index 81% rename from silk/fixed/SKP_Silk_find_LPC_FIX.c rename to silk/fixed/silk_find_LPC_FIX.c index bf065db1..01d82467 100644 --- a/silk/fixed/SKP_Silk_find_LPC_FIX.c +++ b/silk/fixed/silk_find_LPC_FIX.c @@ -25,11 +25,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FIX.h" -#include "SKP_Silk_tuning_parameters.h" +#include "silk_main_FIX.h" +#include "silk_tuning_parameters.h" /* Finds LPC vector from correlations, and converts to NLSF */ -void SKP_Silk_find_LPC_FIX( +void silk_find_LPC_FIX( SKP_int16 NLSF_Q15[], /* O NLSFs */ SKP_int8 *interpIndex, /* O NLSF interpolation index, only used for NLSF interpolation */ const SKP_int16 prev_NLSFq_Q15[], /* I previous NLSFs, only used for NLSF interpolation */ @@ -58,21 +58,21 @@ void SKP_Silk_find_LPC_FIX( *interpIndex = 4; /* Burg AR analysis for the full frame */ - 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 ); + silk_burg_modified( &res_nrg, &res_nrg_Q, a_Q16, x, subfr_length, nb_subfr, SILK_FIX_CONST( FIND_LPC_COND_FAC, 32 ), LPC_order ); if( firstFrameAfterReset ) { - SKP_Silk_bwexpander_32( a_Q16, LPC_order, SKP_FIX_CONST( FIND_LPC_CHIRP_FIRST_FRAME, 16 ) ); + silk_bwexpander_32( a_Q16, LPC_order, SILK_FIX_CONST( FIND_LPC_CHIRP_FIRST_FRAME, 16 ) ); } else { - SKP_Silk_bwexpander_32( a_Q16, LPC_order, SKP_FIX_CONST( FIND_LPC_CHIRP, 16 ) ); + silk_bwexpander_32( a_Q16, LPC_order, SILK_FIX_CONST( FIND_LPC_CHIRP, 16 ) ); } if( useInterpNLSFs && !firstFrameAfterReset && nb_subfr == MAX_NB_SUBFR ) { /* Optimal solution for last 10 ms */ - SKP_Silk_burg_modified( &res_tmp_nrg, &res_tmp_nrg_Q, a_tmp_Q16, x + ( MAX_NB_SUBFR >> 1 ) * subfr_length, - subfr_length, ( MAX_NB_SUBFR >> 1 ), SKP_FIX_CONST( FIND_LPC_COND_FAC, 32 ), LPC_order ); + silk_burg_modified( &res_tmp_nrg, &res_tmp_nrg_Q, a_tmp_Q16, x + ( MAX_NB_SUBFR >> 1 ) * subfr_length, + subfr_length, ( MAX_NB_SUBFR >> 1 ), SILK_FIX_CONST( FIND_LPC_COND_FAC, 32 ), LPC_order ); - SKP_Silk_bwexpander_32( a_tmp_Q16, LPC_order, SKP_FIX_CONST( FIND_LPC_CHIRP, 16 ) ); + silk_bwexpander_32( a_tmp_Q16, LPC_order, SILK_FIX_CONST( FIND_LPC_CHIRP, 16 ) ); /* subtract residual energy here, as that's easier than adding it to the */ /* residual energy of the first 10 ms in each iteration of the search below */ @@ -88,22 +88,22 @@ void SKP_Silk_find_LPC_FIX( } /* Convert to NLSFs */ - SKP_Silk_A2NLSF( NLSF_Q15, a_tmp_Q16, LPC_order ); + silk_A2NLSF( NLSF_Q15, a_tmp_Q16, LPC_order ); /* Search over interpolation indices to find the one with lowest residual energy */ res_nrg_2nd = SKP_int32_MAX; for( k = 3; k >= 0; k-- ) { /* Interpolate NLSFs for first half */ - SKP_Silk_interpolate( NLSF0_Q15, prev_NLSFq_Q15, NLSF_Q15, k, LPC_order ); + silk_interpolate( NLSF0_Q15, prev_NLSFq_Q15, NLSF_Q15, k, LPC_order ); /* Convert to LPC for residual energy evaluation */ - SKP_Silk_NLSF2A_stable( a_tmp_Q12, NLSF0_Q15, LPC_order ); + silk_NLSF2A_stable( a_tmp_Q12, NLSF0_Q15, LPC_order ); /* Calculate residual energy with NLSF interpolation */ - SKP_Silk_LPC_analysis_filter( LPC_res, x, a_tmp_Q12, 2 * subfr_length, LPC_order ); + silk_LPC_analysis_filter( LPC_res, x, a_tmp_Q12, 2 * subfr_length, LPC_order ); - SKP_Silk_sum_sqr_shift( &res_nrg0, &rshift0, LPC_res + LPC_order, subfr_length - LPC_order ); - SKP_Silk_sum_sqr_shift( &res_nrg1, &rshift1, LPC_res + LPC_order + subfr_length, subfr_length - LPC_order ); + silk_sum_sqr_shift( &res_nrg0, &rshift0, LPC_res + LPC_order, subfr_length - LPC_order ); + silk_sum_sqr_shift( &res_nrg1, &rshift1, LPC_res + LPC_order + subfr_length, subfr_length - LPC_order ); /* Add subframe energies from first half frame */ shift = rshift0 - rshift1; @@ -150,7 +150,7 @@ void SKP_Silk_find_LPC_FIX( if( *interpIndex == 4 ) { /* NLSF interpolation is currently inactive, calculate NLSFs from full frame AR coefficients */ - SKP_Silk_A2NLSF( NLSF_Q15, a_Q16, LPC_order ); + silk_A2NLSF( NLSF_Q15, a_Q16, LPC_order ); } SKP_assert( *interpIndex == 4 || ( useInterpNLSFs && !firstFrameAfterReset && nb_subfr == MAX_NB_SUBFR ) ); diff --git a/silk/fixed/SKP_Silk_find_LTP_FIX.c b/silk/fixed/silk_find_LTP_FIX.c similarity index 81% rename from silk/fixed/SKP_Silk_find_LTP_FIX.c rename to silk/fixed/silk_find_LTP_FIX.c index 50aeb562..21b28d3d 100644 --- a/silk/fixed/SKP_Silk_find_LTP_FIX.c +++ b/silk/fixed/silk_find_LTP_FIX.c @@ -25,18 +25,18 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FIX.h" -#include "SKP_Silk_tuning_parameters.h" +#include "silk_main_FIX.h" +#include "silk_tuning_parameters.h" /* Head room for correlations */ #define LTP_CORRS_HEAD_ROOM 2 -void SKP_Silk_fit_LTP( +void silk_fit_LTP( SKP_int32 LTP_coefs_Q16[ LTP_ORDER ], SKP_int16 LTP_coefs_Q14[ LTP_ORDER ] ); -void SKP_Silk_find_LTP_FIX( +void silk_find_LTP_FIX( SKP_int16 b_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* O LTP coefs */ SKP_int32 WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */ SKP_int *LTPredCodGain_Q7, /* O LTP coding gain */ @@ -71,37 +71,37 @@ void SKP_Silk_find_LTP_FIX( for( k = 0; k < nb_subfr; k++ ) { lag_ptr = r_ptr - ( lag[ k ] + LTP_ORDER / 2 ); - SKP_Silk_sum_sqr_shift( &rr[ k ], &rr_shifts, r_ptr, subfr_length ); /* rr[ k ] in Q( -rr_shifts ) */ + silk_sum_sqr_shift( &rr[ k ], &rr_shifts, r_ptr, subfr_length ); /* rr[ k ] in Q( -rr_shifts ) */ /* Assure headroom */ - LZs = SKP_Silk_CLZ32( rr[k] ); + LZs = silk_CLZ32( rr[k] ); if( LZs < LTP_CORRS_HEAD_ROOM ) { rr[ k ] = SKP_RSHIFT_ROUND( rr[ k ], LTP_CORRS_HEAD_ROOM - LZs ); rr_shifts += ( LTP_CORRS_HEAD_ROOM - LZs ); } corr_rshifts[ k ] = rr_shifts; - 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 ] ) */ + 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 ] ) */ /* The correlation vector always has lower max abs value than rr and/or RR so head room is assured */ - SKP_Silk_corrVector_FIX( lag_ptr, r_ptr, subfr_length, LTP_ORDER, Rr, corr_rshifts[ k ] ); /* Rr_fix_ptr in Q( -corr_rshifts[ k ] ) */ + silk_corrVector_FIX( lag_ptr, r_ptr, subfr_length, LTP_ORDER, Rr, corr_rshifts[ k ] ); /* Rr_fix_ptr in Q( -corr_rshifts[ k ] ) */ if( corr_rshifts[ k ] > rr_shifts ) { rr[ k ] = SKP_RSHIFT( rr[ k ], corr_rshifts[ k ] - rr_shifts ); /* rr[ k ] in Q( -corr_rshifts[ k ] ) */ } SKP_assert( rr[ k ] >= 0 ); regu = 1; - regu = SKP_SMLAWB( regu, rr[ k ], SKP_FIX_CONST( LTP_DAMPING/3, 16 ) ); - regu = SKP_SMLAWB( regu, matrix_ptr( WLTP_ptr, 0, 0, LTP_ORDER ), SKP_FIX_CONST( LTP_DAMPING/3, 16 ) ); - regu = SKP_SMLAWB( regu, matrix_ptr( WLTP_ptr, LTP_ORDER-1, LTP_ORDER-1, LTP_ORDER ), SKP_FIX_CONST( LTP_DAMPING/3, 16 ) ); - SKP_Silk_regularize_correlations_FIX( WLTP_ptr, &rr[k], regu, LTP_ORDER ); + regu = SKP_SMLAWB( regu, rr[ k ], SILK_FIX_CONST( LTP_DAMPING/3, 16 ) ); + regu = SKP_SMLAWB( regu, matrix_ptr( WLTP_ptr, 0, 0, LTP_ORDER ), SILK_FIX_CONST( LTP_DAMPING/3, 16 ) ); + regu = SKP_SMLAWB( regu, matrix_ptr( WLTP_ptr, LTP_ORDER-1, LTP_ORDER-1, LTP_ORDER ), SILK_FIX_CONST( LTP_DAMPING/3, 16 ) ); + silk_regularize_correlations_FIX( WLTP_ptr, &rr[k], regu, LTP_ORDER ); - 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]) */ + silk_solve_LDL_FIX( WLTP_ptr, LTP_ORDER, Rr, b_Q16 ); /* WLTP_fix_ptr and Rr_fix_ptr both in Q(-corr_rshifts[k]) */ /* Limit and store in Q14 */ - SKP_Silk_fit_LTP( b_Q16, b_Q14_ptr ); + silk_fit_LTP( b_Q16, b_Q14_ptr ); /* Calculate residual energy */ - nrg[ k ] = SKP_Silk_residual_energy16_covar_FIX( b_Q14_ptr, WLTP_ptr, Rr, rr[ k ], LTP_ORDER, 14 ); /* nrg_fix in Q( -corr_rshifts[ k ] ) */ + nrg[ k ] = silk_residual_energy16_covar_FIX( b_Q14_ptr, WLTP_ptr, Rr, rr[ k ], LTP_ORDER, 14 ); /* nrg_fix in Q( -corr_rshifts[ k ] ) */ /* temp = Wght[ k ] / ( nrg[ k ] * Wght[ k ] + 0.01f * subfr_length ); */ extra_shifts = SKP_min_int( corr_rshifts[ k ], LTP_CORRS_HEAD_ROOM ); @@ -117,13 +117,13 @@ void SKP_Silk_find_LTP_FIX( for( i = 0; i < LTP_ORDER * LTP_ORDER; i++ ) { WLTP_max = SKP_max( WLTP_ptr[ i ], WLTP_max ); } - lshift = SKP_Silk_CLZ32( WLTP_max ) - 1 - 3; /* keep 3 bits free for vq_nearest_neighbor_fix */ + lshift = silk_CLZ32( WLTP_max ) - 1 - 3; /* keep 3 bits free for vq_nearest_neighbor_fix */ SKP_assert( 26 - 18 + lshift >= 0 ); if( 26 - 18 + lshift < 31 ) { temp32 = SKP_min_32( temp32, SKP_LSHIFT( ( SKP_int32 )1, 26 - 18 + lshift ) ); } - SKP_Silk_scale_vector32_Q26_lshift_18( WLTP_ptr, temp32, LTP_ORDER * LTP_ORDER ); /* WLTP_ptr in Q( 18 - corr_rshifts[ k ] ) */ + silk_scale_vector32_Q26_lshift_18( WLTP_ptr, temp32, LTP_ORDER * LTP_ORDER ); /* WLTP_ptr in Q( 18 - corr_rshifts[ k ] ) */ w[ k ] = matrix_ptr( WLTP_ptr, LTP_ORDER/2, LTP_ORDER/2, LTP_ORDER ); /* w in Q( 18 - corr_rshifts[ k ] ) */ SKP_assert( w[k] >= 0 ); @@ -149,10 +149,10 @@ void SKP_Silk_find_LTP_FIX( } LPC_LTP_res_nrg = SKP_max( LPC_LTP_res_nrg, 1 ); /* avoid division by zero */ - div_Q16 = SKP_DIV32_varQ( LPC_res_nrg, LPC_LTP_res_nrg, 16 ); - *LTPredCodGain_Q7 = ( SKP_int )SKP_SMULBB( 3, SKP_Silk_lin2log( div_Q16 ) - ( 16 << 7 ) ); + div_Q16 = silk_DIV32_varQ( LPC_res_nrg, LPC_LTP_res_nrg, 16 ); + *LTPredCodGain_Q7 = ( SKP_int )SKP_SMULBB( 3, silk_lin2log( div_Q16 ) - ( 16 << 7 ) ); - SKP_assert( *LTPredCodGain_Q7 == ( SKP_int )SKP_SAT16( SKP_MUL( 3, SKP_Silk_lin2log( div_Q16 ) - ( 16 << 7 ) ) ) ); + SKP_assert( *LTPredCodGain_Q7 == ( SKP_int )SKP_SAT16( SKP_MUL( 3, silk_lin2log( div_Q16 ) - ( 16 << 7 ) ) ) ); } /* smoothing */ @@ -175,14 +175,14 @@ void SKP_Silk_find_LTP_FIX( max_abs_d_Q14 = SKP_max_32( max_abs_d_Q14, SKP_abs( d_Q14[ k ] ) ); /* w[ k ] is in Q( 18 - corr_rshifts[ k ] ) */ /* Find bits needed in Q( 18 - maxRshifts ) */ - max_w_bits = SKP_max_32( max_w_bits, 32 - SKP_Silk_CLZ32( w[ k ] ) + corr_rshifts[ k ] - maxRshifts ); + max_w_bits = SKP_max_32( max_w_bits, 32 - silk_CLZ32( w[ k ] ) + corr_rshifts[ k ] - maxRshifts ); } /* max_abs_d_Q14 = (5 << 15); worst case, i.e. LTP_ORDER * -SKP_int16_MIN */ SKP_assert( max_abs_d_Q14 <= ( 5 << 15 ) ); /* How many bits is needed for w*d' in Q( 18 - maxRshifts ) in the worst case, of all d_Q14's being equal to max_abs_d_Q14 */ - extra_shifts = max_w_bits + 32 - SKP_Silk_CLZ32( max_abs_d_Q14 ) - 14; + extra_shifts = max_w_bits + 32 - silk_CLZ32( max_abs_d_Q14 ) - 14; /* Subtract what we got available; bits in output var plus maxRshifts */ extra_shifts -= ( 32 - 1 - 2 + maxRshifts ); /* Keep sign bit free as well as 2 bits for accumulation */ @@ -197,7 +197,7 @@ void SKP_Silk_find_LTP_FIX( temp32 = SKP_ADD32( temp32, SKP_RSHIFT( w[ k ], maxRshifts_wxtra - corr_rshifts[ k ] ) ); /* Q( 18 - maxRshifts_wxtra ) */ wd = SKP_ADD32( wd, SKP_LSHIFT( SKP_SMULWW( SKP_RSHIFT( w[ k ], maxRshifts_wxtra - corr_rshifts[ k ] ), d_Q14[ k ] ), 2 ) ); /* Q( 18 - maxRshifts_wxtra ) */ } - m_Q12 = SKP_DIV32_varQ( wd, temp32, 12 ); + m_Q12 = silk_DIV32_varQ( wd, temp32, 12 ); b_Q14_ptr = b_Q14; for( k = 0; k < nb_subfr; k++ ) { @@ -210,8 +210,8 @@ void SKP_Silk_find_LTP_FIX( g_Q26 = SKP_MUL( SKP_DIV32( - SKP_FIX_CONST( LTP_SMOOTHING, 26 ), - SKP_RSHIFT( SKP_FIX_CONST( LTP_SMOOTHING, 26 ), 10 ) + temp32 ), /* Q10 */ + SILK_FIX_CONST( LTP_SMOOTHING, 26 ), + SKP_RSHIFT( SILK_FIX_CONST( LTP_SMOOTHING, 26 ), 10 ) + temp32 ), /* Q10 */ SKP_LSHIFT_SAT32( SKP_SUB_SAT32( ( SKP_int32 )m_Q12, SKP_RSHIFT( d_Q14[ k ], 2 ) ), 4 ) ); /* Q16 */ temp32 = 0; @@ -228,7 +228,7 @@ void SKP_Silk_find_LTP_FIX( TOC(find_LTP_FIX) } -void SKP_Silk_fit_LTP( +void silk_fit_LTP( SKP_int32 LTP_coefs_Q16[ LTP_ORDER ], SKP_int16 LTP_coefs_Q14[ LTP_ORDER ] ) diff --git a/silk/fixed/SKP_Silk_find_pitch_lags_FIX.c b/silk/fixed/silk_find_pitch_lags_FIX.c similarity index 74% rename from silk/fixed/SKP_Silk_find_pitch_lags_FIX.c rename to silk/fixed/silk_find_pitch_lags_FIX.c index bfc3e36b..d6c4ee89 100644 --- a/silk/fixed/SKP_Silk_find_pitch_lags_FIX.c +++ b/silk/fixed/silk_find_pitch_lags_FIX.c @@ -25,13 +25,13 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FIX.h" -#include "SKP_Silk_tuning_parameters.h" +#include "silk_main_FIX.h" +#include "silk_tuning_parameters.h" /* Find pitch lags */ -void SKP_Silk_find_pitch_lags_FIX( - SKP_Silk_encoder_state_FIX *psEnc, /* I/O encoder state */ - SKP_Silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */ +void silk_find_pitch_lags_FIX( + silk_encoder_state_FIX *psEnc, /* I/O encoder state */ + silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */ SKP_int16 res[], /* O residual */ const SKP_int16 x[] /* I Speech signal */ ) @@ -64,7 +64,7 @@ void SKP_Silk_find_pitch_lags_FIX( /* First LA_LTP samples */ x_buf_ptr = x_buf + buf_len - psEnc->sCmn.pitch_LPC_win_length; Wsig_ptr = Wsig; - SKP_Silk_apply_sine_window( Wsig_ptr, x_buf_ptr, 1, psEnc->sCmn.la_pitch ); + silk_apply_sine_window( Wsig_ptr, x_buf_ptr, 1, psEnc->sCmn.la_pitch ); /* Middle un - windowed samples */ Wsig_ptr += psEnc->sCmn.la_pitch; @@ -74,22 +74,22 @@ void SKP_Silk_find_pitch_lags_FIX( /* Last LA_LTP samples */ Wsig_ptr += psEnc->sCmn.pitch_LPC_win_length - SKP_LSHIFT( psEnc->sCmn.la_pitch, 1 ); x_buf_ptr += psEnc->sCmn.pitch_LPC_win_length - SKP_LSHIFT( psEnc->sCmn.la_pitch, 1 ); - SKP_Silk_apply_sine_window( Wsig_ptr, x_buf_ptr, 2, psEnc->sCmn.la_pitch ); + silk_apply_sine_window( Wsig_ptr, x_buf_ptr, 2, psEnc->sCmn.la_pitch ); /* Calculate autocorrelation sequence */ - SKP_Silk_autocorr( auto_corr, &scale, Wsig, psEnc->sCmn.pitch_LPC_win_length, psEnc->sCmn.pitchEstimationLPCOrder + 1 ); + silk_autocorr( auto_corr, &scale, Wsig, psEnc->sCmn.pitch_LPC_win_length, psEnc->sCmn.pitchEstimationLPCOrder + 1 ); /* Add white noise, as fraction of energy */ - auto_corr[ 0 ] = SKP_SMLAWB( auto_corr[ 0 ], auto_corr[ 0 ], SKP_FIX_CONST( FIND_PITCH_WHITE_NOISE_FRACTION, 16 ) ) + 1; + auto_corr[ 0 ] = SKP_SMLAWB( auto_corr[ 0 ], auto_corr[ 0 ], SILK_FIX_CONST( FIND_PITCH_WHITE_NOISE_FRACTION, 16 ) ) + 1; /* Calculate the reflection coefficients using schur */ - res_nrg = SKP_Silk_schur( rc_Q15, auto_corr, psEnc->sCmn.pitchEstimationLPCOrder ); + res_nrg = silk_schur( rc_Q15, auto_corr, psEnc->sCmn.pitchEstimationLPCOrder ); /* Prediction gain */ - psEncCtrl->predGain_Q16 = SKP_DIV32_varQ( auto_corr[ 0 ], SKP_max_int( res_nrg, 1 ), 16 ); + psEncCtrl->predGain_Q16 = silk_DIV32_varQ( auto_corr[ 0 ], SKP_max_int( res_nrg, 1 ), 16 ); /* Convert reflection coefficients to prediction coefficients */ - SKP_Silk_k2a( A_Q24, rc_Q15, psEnc->sCmn.pitchEstimationLPCOrder ); + silk_k2a( A_Q24, rc_Q15, psEnc->sCmn.pitchEstimationLPCOrder ); /* Convert From 32 bit Q24 to 16 bit Q12 coefs */ for( i = 0; i < psEnc->sCmn.pitchEstimationLPCOrder; i++ ) { @@ -97,26 +97,26 @@ void SKP_Silk_find_pitch_lags_FIX( } /* Do BWE */ - SKP_Silk_bwexpander( A_Q12, psEnc->sCmn.pitchEstimationLPCOrder, SKP_FIX_CONST( FIND_PITCH_BANDWITH_EXPANSION, 16 ) ); + silk_bwexpander( A_Q12, psEnc->sCmn.pitchEstimationLPCOrder, SILK_FIX_CONST( FIND_PITCH_BANDWITH_EXPANSION, 16 ) ); /*****************************************/ /* LPC analysis filtering */ /*****************************************/ - SKP_Silk_LPC_analysis_filter( res, x_buf, A_Q12, buf_len, psEnc->sCmn.pitchEstimationLPCOrder ); + silk_LPC_analysis_filter( res, x_buf, A_Q12, buf_len, psEnc->sCmn.pitchEstimationLPCOrder ); if( psEnc->sCmn.indices.signalType != TYPE_NO_VOICE_ACTIVITY && psEnc->sCmn.first_frame_after_reset == 0 ) { /* Threshold for pitch estimator */ - thrhld_Q15 = SKP_FIX_CONST( 0.6, 15 ); - thrhld_Q15 = SKP_SMLABB( thrhld_Q15, SKP_FIX_CONST( -0.004, 15 ), psEnc->sCmn.pitchEstimationLPCOrder ); - thrhld_Q15 = SKP_SMLABB( thrhld_Q15, SKP_FIX_CONST( -0.1, 7 ), psEnc->sCmn.speech_activity_Q8 ); - thrhld_Q15 = SKP_SMLABB( thrhld_Q15, SKP_FIX_CONST( -0.15, 15 ), SKP_RSHIFT( psEnc->sCmn.prevSignalType, 1 ) ); - thrhld_Q15 = SKP_SMLAWB( thrhld_Q15, SKP_FIX_CONST( -0.1, 16 ), psEnc->sCmn.input_tilt_Q15 ); + thrhld_Q15 = SILK_FIX_CONST( 0.6, 15 ); + thrhld_Q15 = SKP_SMLABB( thrhld_Q15, SILK_FIX_CONST( -0.004, 15 ), psEnc->sCmn.pitchEstimationLPCOrder ); + thrhld_Q15 = SKP_SMLABB( thrhld_Q15, SILK_FIX_CONST( -0.1, 7 ), psEnc->sCmn.speech_activity_Q8 ); + thrhld_Q15 = SKP_SMLABB( thrhld_Q15, SILK_FIX_CONST( -0.15, 15 ), SKP_RSHIFT( psEnc->sCmn.prevSignalType, 1 ) ); + thrhld_Q15 = SKP_SMLAWB( thrhld_Q15, SILK_FIX_CONST( -0.1, 16 ), psEnc->sCmn.input_tilt_Q15 ); thrhld_Q15 = SKP_SAT16( thrhld_Q15 ); /*****************************************/ /* Call pitch estimator */ /*****************************************/ - if( SKP_Silk_pitch_analysis_core( res, psEncCtrl->pitchL, &psEnc->sCmn.indices.lagIndex, &psEnc->sCmn.indices.contourIndex, + if( silk_pitch_analysis_core( res, psEncCtrl->pitchL, &psEnc->sCmn.indices.lagIndex, &psEnc->sCmn.indices.contourIndex, &psEnc->LTPCorr_Q15, psEnc->sCmn.prevLag, psEnc->sCmn.pitchEstimationThreshold_Q16, ( SKP_int16 )thrhld_Q15, psEnc->sCmn.fs_kHz, psEnc->sCmn.pitchEstimationComplexity, psEnc->sCmn.nb_subfr ) == 0 ) { diff --git a/silk/fixed/SKP_Silk_find_pred_coefs_FIX.c b/silk/fixed/silk_find_pred_coefs_FIX.c similarity index 82% rename from silk/fixed/SKP_Silk_find_pred_coefs_FIX.c rename to silk/fixed/silk_find_pred_coefs_FIX.c index 033a5a09..21885b4d 100644 --- a/silk/fixed/SKP_Silk_find_pred_coefs_FIX.c +++ b/silk/fixed/silk_find_pred_coefs_FIX.c @@ -25,11 +25,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FIX.h" +#include "silk_main_FIX.h" -void SKP_Silk_find_pred_coefs_FIX( - SKP_Silk_encoder_state_FIX *psEnc, /* I/O encoder state */ - SKP_Silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */ +void silk_find_pred_coefs_FIX( + silk_encoder_state_FIX *psEnc, /* I/O encoder state */ + silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */ const SKP_int16 res_pitch[], /* I Residual from pitch analysis */ const SKP_int16 x[] /* I Speech signal */ ) @@ -52,7 +52,7 @@ void SKP_Silk_find_pred_coefs_FIX( /* Divide to Q16 */ SKP_assert( psEncCtrl->Gains_Q16[ i ] > 0 ); /* Invert and normalize gains, and ensure that maximum invGains_Q16 is within range of a 16 bit int */ - invGains_Q16[ i ] = SKP_DIV32_varQ( min_gain_Q16, psEncCtrl->Gains_Q16[ i ], 16 - 2 ); + invGains_Q16[ i ] = silk_DIV32_varQ( min_gain_Q16, psEncCtrl->Gains_Q16[ i ], 16 - 2 ); /* Ensure Wght_Q15 a minimum value 1 */ invGains_Q16[ i ] = SKP_max( invGains_Q16[ i ], 363 ); @@ -73,19 +73,19 @@ void SKP_Silk_find_pred_coefs_FIX( SKP_assert( psEnc->sCmn.ltp_mem_length - psEnc->sCmn.predictLPCOrder >= psEncCtrl->pitchL[ 0 ] + LTP_ORDER / 2 ); /* LTP analysis */ - SKP_Silk_find_LTP_FIX( psEncCtrl->LTPCoef_Q14, WLTP, &psEncCtrl->LTPredCodGain_Q7, + silk_find_LTP_FIX( psEncCtrl->LTPCoef_Q14, WLTP, &psEncCtrl->LTPredCodGain_Q7, res_pitch, psEncCtrl->pitchL, Wght_Q15, psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.ltp_mem_length, LTP_corrs_rshift ); /* Quantize LTP gain parameters */ - SKP_Silk_quant_LTP_gains( psEncCtrl->LTPCoef_Q14, psEnc->sCmn.indices.LTPIndex, &psEnc->sCmn.indices.PERIndex, + silk_quant_LTP_gains( psEncCtrl->LTPCoef_Q14, psEnc->sCmn.indices.LTPIndex, &psEnc->sCmn.indices.PERIndex, WLTP, psEnc->sCmn.mu_LTP_Q9, psEnc->sCmn.LTPQuantLowComplexity, psEnc->sCmn.nb_subfr); /* Control LTP scaling */ - SKP_Silk_LTP_scale_ctrl_FIX( psEnc, psEncCtrl ); + silk_LTP_scale_ctrl_FIX( psEnc, psEncCtrl ); /* Create LTP residual */ - SKP_Silk_LTP_analysis_filter_FIX( LPC_in_pre, x - psEnc->sCmn.predictLPCOrder, psEncCtrl->LTPCoef_Q14, + silk_LTP_analysis_filter_FIX( LPC_in_pre, x - psEnc->sCmn.predictLPCOrder, psEncCtrl->LTPCoef_Q14, psEncCtrl->pitchL, invGains_Q16, psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.predictLPCOrder ); } else { @@ -96,7 +96,7 @@ void SKP_Silk_find_pred_coefs_FIX( x_ptr = x - psEnc->sCmn.predictLPCOrder; x_pre_ptr = LPC_in_pre; for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { - SKP_Silk_scale_copy_vector16( x_pre_ptr, x_ptr, invGains_Q16[ i ], + silk_scale_copy_vector16( x_pre_ptr, x_ptr, invGains_Q16[ i ], psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder ); x_pre_ptr += psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder; x_ptr += psEnc->sCmn.subfr_length; @@ -108,18 +108,18 @@ void SKP_Silk_find_pred_coefs_FIX( /* LPC_in_pre contains the LTP-filtered input for voiced, and the unfiltered input for unvoiced */ TIC(FIND_LPC) - SKP_Silk_find_LPC_FIX( NLSF_Q15, &psEnc->sCmn.indices.NLSFInterpCoef_Q2, psEnc->sCmn.prev_NLSFq_Q15, + silk_find_LPC_FIX( NLSF_Q15, &psEnc->sCmn.indices.NLSFInterpCoef_Q2, psEnc->sCmn.prev_NLSFq_Q15, psEnc->sCmn.useInterpolatedNLSFs, psEnc->sCmn.first_frame_after_reset, psEnc->sCmn.predictLPCOrder, LPC_in_pre, psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder, psEnc->sCmn.nb_subfr ); TOC(FIND_LPC) /* Quantize LSFs */ TIC(PROCESS_LSFS) - SKP_Silk_process_NLSFs( &psEnc->sCmn, psEncCtrl->PredCoef_Q12, NLSF_Q15, psEnc->sCmn.prev_NLSFq_Q15 ); + silk_process_NLSFs( &psEnc->sCmn, psEncCtrl->PredCoef_Q12, NLSF_Q15, psEnc->sCmn.prev_NLSFq_Q15 ); TOC(PROCESS_LSFS) /* Calculate residual energy using quantized LPC coefficients */ - SKP_Silk_residual_energy_FIX( psEncCtrl->ResNrg, psEncCtrl->ResNrgQ, LPC_in_pre, psEncCtrl->PredCoef_Q12, local_gains, + silk_residual_energy_FIX( psEncCtrl->ResNrg, psEncCtrl->ResNrgQ, LPC_in_pre, psEncCtrl->PredCoef_Q12, local_gains, psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.predictLPCOrder ); /* Copy to prediction struct for use in next frame for fluctuation reduction */ diff --git a/silk/fixed/silk_fixed.vcxproj b/silk/fixed/silk_fixed.vcxproj index 004b0329..10840bed 100644 --- a/silk/fixed/silk_fixed.vcxproj +++ b/silk/fixed/silk_fixed.vcxproj @@ -86,26 +86,28 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - + + + + diff --git a/silk/fixed/silk_fixed.vcxproj.filters b/silk/fixed/silk_fixed.vcxproj.filters index 49c8f28d..4fbb3696 100644 --- a/silk/fixed/silk_fixed.vcxproj.filters +++ b/silk/fixed/silk_fixed.vcxproj.filters @@ -18,60 +18,66 @@ - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Header Files - + + Header Files + + + Header Files + + Header Files diff --git a/silk/fixed/SKP_Silk_main_FIX.h b/silk/fixed/silk_main_FIX.h similarity index 83% rename from silk/fixed/SKP_Silk_main_FIX.h rename to silk/fixed/silk_main_FIX.h index b65c78ff..cc3be26a 100644 --- a/silk/fixed/SKP_Silk_main_FIX.h +++ b/silk/fixed/silk_main_FIX.h @@ -25,15 +25,15 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#ifndef SKP_SILK_MAIN_FIX_H -#define SKP_SILK_MAIN_FIX_H +#ifndef SILK_MAIN_FIX_H +#define SILK_MAIN_FIX_H -#include "SKP_Silk_SigProc_FIX.h" -#include "SKP_Silk_structs_FIX.h" -#include "SKP_Silk_control.h" -#include "SKP_Silk_main.h" -#include "SKP_Silk_PLC.h" -#include "SKP_debug.h" +#include "silk_SigProc_FIX.h" +#include "silk_structs_FIX.h" +#include "silk_control.h" +#include "silk_main.h" +#include "silk_PLC.h" +#include "silk_debug.h" #include "entenc.h" #ifndef FORCE_CPP_BUILD @@ -43,33 +43,42 @@ extern "C" #endif #endif +#define silk_encoder_state_Fxx silk_encoder_state_FIX +#define silk_encode_frame_Fxx silk_encode_frame_FIX + /*********************/ /* Encoder Functions */ /*********************/ +/* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */ +void silk_HP_variable_cutoff( + silk_encoder_state_Fxx state_Fxx[], /* I/O Encoder states */ + const SKP_int nChannels /* I Number of channels */ +); + /* Encoder main function */ -SKP_int SKP_Silk_encode_frame_FIX( - SKP_Silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */ +SKP_int silk_encode_frame_FIX( + silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */ SKP_int32 *pnBytesOut, /* O Pointer to number of payload bytes; */ ec_enc *psRangeEnc /* I/O compressor data structure */ ); /* Low Bitrate Redundancy (LBRR) encoding. Reuse all parameters but encode with lower bitrate */ -void SKP_Silk_LBRR_encode_FIX( - SKP_Silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */ - SKP_Silk_encoder_control_FIX *psEncCtrl, /* I/O Pointer to Silk FIX encoder control struct */ +void silk_LBRR_encode_FIX( + silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */ + silk_encoder_control_FIX *psEncCtrl, /* I/O Pointer to Silk FIX encoder control struct */ const SKP_int16 xfw[] /* I Input signal */ ); /* Initializes the Silk encoder state */ -SKP_int SKP_Silk_init_encoder( - SKP_Silk_encoder_state_FIX *psEnc /* I/O Pointer to Silk FIX encoder state */ +SKP_int silk_init_encoder( + silk_encoder_state_FIX *psEnc /* I/O Pointer to Silk FIX encoder state */ ); /* Control the Silk encoder */ -SKP_int SKP_Silk_control_encoder( - SKP_Silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk encoder state */ - SKP_SILK_SDK_EncControlStruct *encControl, /* I: Control structure */ +SKP_int silk_control_encoder( + silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk encoder state */ + silk_EncControlStruct *encControl, /* I: Control structure */ const SKP_int32 TargetRate_bps, /* I Target max bitrate (bps) */ const SKP_int allow_bw_switch, /* I Flag to allow switching audio bandwidth */ const SKP_int channelNb /* I Channel number */ @@ -78,9 +87,9 @@ SKP_int SKP_Silk_control_encoder( /****************/ /* Prefiltering */ /****************/ -void SKP_Silk_prefilter_FIX( - SKP_Silk_encoder_state_FIX *psEnc, /* I/O Encoder state */ - const SKP_Silk_encoder_control_FIX *psEncCtrl, /* I Encoder control */ +void silk_prefilter_FIX( + silk_encoder_state_FIX *psEnc, /* I/O Encoder state */ + const silk_encoder_control_FIX *psEncCtrl, /* I Encoder control */ SKP_int16 xw[], /* O Weighted signal */ const SKP_int16 x[] /* I Speech signal */ ); @@ -89,15 +98,15 @@ void SKP_Silk_prefilter_FIX( /* Noise shaping analysis */ /**************************/ /* Compute noise shaping coefficients and initial gain values */ -void SKP_Silk_noise_shape_analysis_FIX( - SKP_Silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */ - SKP_Silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control FIX */ +void silk_noise_shape_analysis_FIX( + silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */ + silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control FIX */ const SKP_int16 *pitch_res, /* I LPC residual from pitch analysis */ const SKP_int16 *x /* I Input signal [ frame_length + la_shape ] */ ); /* Autocorrelations for a warped frequency axis */ -void SKP_Silk_warped_autocorrelation_FIX( +void silk_warped_autocorrelation_FIX( SKP_int32 *corr, /* O Result [order + 1] */ SKP_int *scale, /* O Scaling of the correlation vector */ const SKP_int16 *input, /* I Input data to correlate */ @@ -107,32 +116,32 @@ void SKP_Silk_warped_autocorrelation_FIX( ); /* Calculation of LTP state scaling */ -void SKP_Silk_LTP_scale_ctrl_FIX( - SKP_Silk_encoder_state_FIX *psEnc, /* I/O encoder state */ - SKP_Silk_encoder_control_FIX *psEncCtrl /* I/O encoder control */ +void silk_LTP_scale_ctrl_FIX( + silk_encoder_state_FIX *psEnc, /* I/O encoder state */ + silk_encoder_control_FIX *psEncCtrl /* I/O encoder control */ ); /**********************************************/ /* Prediction Analysis */ /**********************************************/ /* Find pitch lags */ -void SKP_Silk_find_pitch_lags_FIX( - SKP_Silk_encoder_state_FIX *psEnc, /* I/O encoder state */ - SKP_Silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */ +void silk_find_pitch_lags_FIX( + silk_encoder_state_FIX *psEnc, /* I/O encoder state */ + silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */ SKP_int16 res[], /* O residual */ const SKP_int16 x[] /* I Speech signal */ ); /* Find LPC and LTP coefficients */ -void SKP_Silk_find_pred_coefs_FIX( - SKP_Silk_encoder_state_FIX *psEnc, /* I/O encoder state */ - SKP_Silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */ +void silk_find_pred_coefs_FIX( + silk_encoder_state_FIX *psEnc, /* I/O encoder state */ + silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */ const SKP_int16 res_pitch[], /* I Residual from pitch analysis */ const SKP_int16 x[] /* I Speech signal */ ); /* LPC analysis */ -void SKP_Silk_find_LPC_FIX( +void silk_find_LPC_FIX( SKP_int16 NLSF_Q15[], /* O NLSFs */ SKP_int8 *interpIndex, /* O NLSF interpolation index, only used for NLSF interpolation */ const SKP_int16 prev_NLSFq_Q15[], /* I previous NLSFs, only used for NLSF interpolation */ @@ -145,7 +154,7 @@ void SKP_Silk_find_LPC_FIX( ); /* LTP analysis */ -void SKP_Silk_find_LTP_FIX( +void silk_find_LTP_FIX( SKP_int16 b_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* O LTP coefs */ SKP_int32 WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */ SKP_int *LTPredCodGain_Q7, /* O LTP coding gain */ @@ -158,7 +167,7 @@ void SKP_Silk_find_LTP_FIX( SKP_int corr_rshifts[ MAX_NB_SUBFR ] /* O right shifts applied to correlations */ ); -void SKP_Silk_LTP_analysis_filter_FIX( +void silk_LTP_analysis_filter_FIX( SKP_int16 *LTP_res, /* O: LTP residual signal of length MAX_NB_SUBFR * ( pre_length + subfr_length ) */ const SKP_int16 *x, /* I: Pointer to input signal with at least max( pitchL ) preceeding samples */ const SKP_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ],/* I: LTP_ORDER LTP coefficients for each MAX_NB_SUBFR subframe */ @@ -171,11 +180,11 @@ void SKP_Silk_LTP_analysis_filter_FIX( /* Calculates residual energies of input subframes where all subframes have LPC_order */ /* of preceeding samples */ -void SKP_Silk_residual_energy_FIX( +void silk_residual_energy_FIX( SKP_int32 nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */ SKP_int nrgsQ[ MAX_NB_SUBFR ], /* O Q value per subframe */ const SKP_int16 x[], /* I Input signal */ - const SKP_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */ + SKP_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */ const SKP_int32 gains[ MAX_NB_SUBFR ], /* I Quantization gains */ const SKP_int subfr_length, /* I Subframe length */ const SKP_int nb_subfr, /* I Number of subframes */ @@ -183,7 +192,7 @@ void SKP_Silk_residual_energy_FIX( ); /* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */ -SKP_int32 SKP_Silk_residual_energy16_covar_FIX( +SKP_int32 silk_residual_energy16_covar_FIX( const SKP_int16 *c, /* I Prediction vector */ const SKP_int32 *wXX, /* I Correlation matrix */ const SKP_int32 *wXx, /* I Correlation vector */ @@ -193,16 +202,16 @@ SKP_int32 SKP_Silk_residual_energy16_covar_FIX( ); /* Processing of gains */ -void SKP_Silk_process_gains_FIX( - SKP_Silk_encoder_state_FIX *psEnc, /* I/O Encoder state */ - SKP_Silk_encoder_control_FIX *psEncCtrl /* I/O Encoder control */ +void silk_process_gains_FIX( + silk_encoder_state_FIX *psEnc, /* I/O Encoder state */ + silk_encoder_control_FIX *psEncCtrl /* I/O Encoder control */ ); /******************/ /* Linear Algebra */ /******************/ /* Calculates correlation matrix X'*X */ -void SKP_Silk_corrMatrix_FIX( +void silk_corrMatrix_FIX( const SKP_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */ const SKP_int L, /* I Length of vectors */ const SKP_int order, /* I Max lag for correlation */ @@ -212,7 +221,7 @@ void SKP_Silk_corrMatrix_FIX( ); /* Calculates correlation vector X'*t */ -void SKP_Silk_corrVector_FIX( +void silk_corrVector_FIX( const SKP_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */ const SKP_int16 *t, /* I Target vector [L] */ const SKP_int L, /* I Length of vectors */ @@ -222,7 +231,7 @@ void SKP_Silk_corrVector_FIX( ); /* Add noise to matrix diagonal */ -void SKP_Silk_regularize_correlations_FIX( +void silk_regularize_correlations_FIX( SKP_int32 *XX, /* I/O Correlation matrices */ SKP_int32 *xx, /* I/O Correlation values */ SKP_int32 noise, /* I Noise to add */ @@ -230,7 +239,7 @@ void SKP_Silk_regularize_correlations_FIX( ); /* Solves Ax = b, assuming A is symmetric */ -void SKP_Silk_solve_LDL_FIX( +void silk_solve_LDL_FIX( SKP_int32 *A, /* I Pointer to symetric square matrix A */ SKP_int M, /* I Size of matrix */ const SKP_int32 *b, /* I Pointer to b vector */ @@ -242,4 +251,4 @@ void SKP_Silk_solve_LDL_FIX( } #endif /* __cplusplus */ #endif /* FORCE_CPP_BUILD */ -#endif /* SKP_SILK_MAIN_FIX_H */ +#endif /* SILK_MAIN_FIX_H */ diff --git a/silk/fixed/SKP_Silk_noise_shape_analysis_FIX.c b/silk/fixed/silk_noise_shape_analysis_FIX.c similarity index 65% rename from silk/fixed/SKP_Silk_noise_shape_analysis_FIX.c rename to silk/fixed/silk_noise_shape_analysis_FIX.c index b8d804c9..ad23d3bd 100644 --- a/silk/fixed/SKP_Silk_noise_shape_analysis_FIX.c +++ b/silk/fixed/silk_noise_shape_analysis_FIX.c @@ -25,8 +25,8 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FIX.h" -#include "SKP_Silk_tuning_parameters.h" +#include "silk_main_FIX.h" +#include "silk_tuning_parameters.h" /* Compute gain to make warped filter coefficients have a zero mean log frequency response on a */ /* non-warped frequency scale. (So that it can be implemented with a minimum-phase monic filter.) */ @@ -43,8 +43,8 @@ SKP_INLINE SKP_int32 warped_gain( // gain in Q16 for( i = order - 2; i >= 0; i-- ) { gain_Q24 = SKP_SMLAWB( coefs_Q24[ i ], gain_Q24, lambda_Q16 ); } - gain_Q24 = SKP_SMLAWB( SKP_FIX_CONST( 1.0, 24 ), gain_Q24, -lambda_Q16 ); - return SKP_INVERSE32_varQ( gain_Q24, 40 ); + gain_Q24 = SKP_SMLAWB( SILK_FIX_CONST( 1.0, 24 ), gain_Q24, -lambda_Q16 ); + return silk_INVERSE32_varQ( gain_Q24, 40 ); } /* Convert warped filter coefficients to monic pseudo-warped coefficients and limit maximum */ @@ -67,11 +67,11 @@ SKP_INLINE void limit_warped_coefs( coefs_ana_Q24[ i - 1 ] = SKP_SMLAWB( coefs_ana_Q24[ i - 1 ], coefs_ana_Q24[ i ], lambda_Q16 ); } lambda_Q16 = -lambda_Q16; - nom_Q16 = SKP_SMLAWB( SKP_FIX_CONST( 1.0, 16 ), -lambda_Q16, lambda_Q16 ); - den_Q24 = SKP_SMLAWB( SKP_FIX_CONST( 1.0, 24 ), coefs_syn_Q24[ 0 ], lambda_Q16 ); - gain_syn_Q16 = SKP_DIV32_varQ( nom_Q16, den_Q24, 24 ); - den_Q24 = SKP_SMLAWB( SKP_FIX_CONST( 1.0, 24 ), coefs_ana_Q24[ 0 ], lambda_Q16 ); - gain_ana_Q16 = SKP_DIV32_varQ( nom_Q16, den_Q24, 24 ); + nom_Q16 = SKP_SMLAWB( SILK_FIX_CONST( 1.0, 16 ), -lambda_Q16, lambda_Q16 ); + den_Q24 = SKP_SMLAWB( SILK_FIX_CONST( 1.0, 24 ), coefs_syn_Q24[ 0 ], lambda_Q16 ); + gain_syn_Q16 = silk_DIV32_varQ( nom_Q16, den_Q24, 24 ); + den_Q24 = SKP_SMLAWB( SILK_FIX_CONST( 1.0, 24 ), coefs_ana_Q24[ 0 ], lambda_Q16 ); + gain_ana_Q16 = silk_DIV32_varQ( nom_Q16, den_Q24, 24 ); for( i = 0; i < order; i++ ) { coefs_syn_Q24[ i ] = SKP_SMULWW( gain_syn_Q16, coefs_syn_Q24[ i ] ); coefs_ana_Q24[ i ] = SKP_SMULWW( gain_ana_Q16, coefs_ana_Q24[ i ] ); @@ -97,19 +97,19 @@ SKP_INLINE void limit_warped_coefs( coefs_syn_Q24[ i - 1 ] = SKP_SMLAWB( coefs_syn_Q24[ i - 1 ], coefs_syn_Q24[ i ], lambda_Q16 ); coefs_ana_Q24[ i - 1 ] = SKP_SMLAWB( coefs_ana_Q24[ i - 1 ], coefs_ana_Q24[ i ], lambda_Q16 ); } - gain_syn_Q16 = SKP_INVERSE32_varQ( gain_syn_Q16, 32 ); - gain_ana_Q16 = SKP_INVERSE32_varQ( gain_ana_Q16, 32 ); + gain_syn_Q16 = silk_INVERSE32_varQ( gain_syn_Q16, 32 ); + gain_ana_Q16 = silk_INVERSE32_varQ( gain_ana_Q16, 32 ); for( i = 0; i < order; i++ ) { coefs_syn_Q24[ i ] = SKP_SMULWW( gain_syn_Q16, coefs_syn_Q24[ i ] ); coefs_ana_Q24[ i ] = SKP_SMULWW( gain_ana_Q16, coefs_ana_Q24[ i ] ); } /* Apply bandwidth expansion */ - chirp_Q16 = SKP_FIX_CONST( 0.99, 16 ) - SKP_DIV32_varQ( - SKP_SMULWB( maxabs_Q24 - limit_Q24, SKP_SMLABB( SKP_FIX_CONST( 0.8, 10 ), SKP_FIX_CONST( 0.1, 10 ), iter ) ), + chirp_Q16 = SILK_FIX_CONST( 0.99, 16 ) - silk_DIV32_varQ( + SKP_SMULWB( maxabs_Q24 - limit_Q24, SKP_SMLABB( SILK_FIX_CONST( 0.8, 10 ), SILK_FIX_CONST( 0.1, 10 ), iter ) ), SKP_MUL( maxabs_Q24, ind + 1 ), 22 ); - SKP_Silk_bwexpander_32( coefs_syn_Q24, order, chirp_Q16 ); - SKP_Silk_bwexpander_32( coefs_ana_Q24, order, chirp_Q16 ); + silk_bwexpander_32( coefs_syn_Q24, order, chirp_Q16 ); + silk_bwexpander_32( coefs_ana_Q24, order, chirp_Q16 ); /* Convert to monic warped coefficients */ lambda_Q16 = -lambda_Q16; @@ -118,11 +118,11 @@ SKP_INLINE void limit_warped_coefs( coefs_ana_Q24[ i - 1 ] = SKP_SMLAWB( coefs_ana_Q24[ i - 1 ], coefs_ana_Q24[ i ], lambda_Q16 ); } lambda_Q16 = -lambda_Q16; - nom_Q16 = SKP_SMLAWB( SKP_FIX_CONST( 1.0, 16 ), -lambda_Q16, lambda_Q16 ); - den_Q24 = SKP_SMLAWB( SKP_FIX_CONST( 1.0, 24 ), coefs_syn_Q24[ 0 ], lambda_Q16 ); - gain_syn_Q16 = SKP_DIV32_varQ( nom_Q16, den_Q24, 24 ); - den_Q24 = SKP_SMLAWB( SKP_FIX_CONST( 1.0, 24 ), coefs_ana_Q24[ 0 ], lambda_Q16 ); - gain_ana_Q16 = SKP_DIV32_varQ( nom_Q16, den_Q24, 24 ); + nom_Q16 = SKP_SMLAWB( SILK_FIX_CONST( 1.0, 16 ), -lambda_Q16, lambda_Q16 ); + den_Q24 = SKP_SMLAWB( SILK_FIX_CONST( 1.0, 24 ), coefs_syn_Q24[ 0 ], lambda_Q16 ); + gain_syn_Q16 = silk_DIV32_varQ( nom_Q16, den_Q24, 24 ); + den_Q24 = SKP_SMLAWB( SILK_FIX_CONST( 1.0, 24 ), coefs_ana_Q24[ 0 ], lambda_Q16 ); + gain_ana_Q16 = silk_DIV32_varQ( nom_Q16, den_Q24, 24 ); for( i = 0; i < order; i++ ) { coefs_syn_Q24[ i ] = SKP_SMULWW( gain_syn_Q16, coefs_syn_Q24[ i ] ); coefs_ana_Q24[ i ] = SKP_SMULWW( gain_ana_Q16, coefs_ana_Q24[ i ] ); @@ -134,14 +134,14 @@ SKP_INLINE void limit_warped_coefs( /**************************************************************/ /* Compute noise shaping coefficients and initial gain values */ /**************************************************************/ -void SKP_Silk_noise_shape_analysis_FIX( - SKP_Silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */ - SKP_Silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control FIX */ +void silk_noise_shape_analysis_FIX( + silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */ + silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control FIX */ const SKP_int16 *pitch_res, /* I LPC residual from pitch analysis */ const SKP_int16 *x /* I Input signal [ frame_length + la_shape ] */ ) { - SKP_Silk_shape_state_FIX *psShapeSt = &psEnc->sShape; + silk_shape_state_FIX *psShapeSt = &psEnc->sShape; SKP_int k, i, nSamples, Qnrg, b_Q14, warping_Q16, scale = 0; SKP_int32 SNR_adj_dB_Q7, HarmBoost_Q16, HarmShapeGain_Q16, Tilt_Q16, tmp32; SKP_int32 nrg, pre_nrg_Q30, log_energy_Q7, log_energy_prev_Q7, energy_variation_Q7; @@ -167,26 +167,26 @@ void SKP_Silk_noise_shape_analysis_FIX( + psEnc->sCmn.input_quality_bands_Q15[ 1 ], 2 ); /* Coding quality level, between 0.0_Q0 and 1.0_Q0, but in Q14 */ - psEncCtrl->coding_quality_Q14 = SKP_RSHIFT( SKP_Silk_sigm_Q15( SKP_RSHIFT_ROUND( SNR_adj_dB_Q7 - - SKP_FIX_CONST( 18.0, 7 ), 4 ) ), 1 ); + psEncCtrl->coding_quality_Q14 = SKP_RSHIFT( silk_sigm_Q15( SKP_RSHIFT_ROUND( SNR_adj_dB_Q7 - + SILK_FIX_CONST( 18.0, 7 ), 4 ) ), 1 ); /* Reduce coding SNR during low speech activity */ if( psEnc->sCmn.useCBR == 0 ) { - b_Q8 = SKP_FIX_CONST( 1.0, 8 ) - psEnc->sCmn.speech_activity_Q8; + b_Q8 = SILK_FIX_CONST( 1.0, 8 ) - psEnc->sCmn.speech_activity_Q8; b_Q8 = SKP_SMULWB( SKP_LSHIFT( b_Q8, 8 ), b_Q8 ); SNR_adj_dB_Q7 = SKP_SMLAWB( SNR_adj_dB_Q7, - SKP_SMULBB( SKP_FIX_CONST( -BG_SNR_DECR_dB, 7 ) >> ( 4 + 1 ), b_Q8 ), // Q11 - SKP_SMULWB( SKP_FIX_CONST( 1.0, 14 ) + psEncCtrl->input_quality_Q14, psEncCtrl->coding_quality_Q14 ) ); // Q12 + SKP_SMULBB( SILK_FIX_CONST( -BG_SNR_DECR_dB, 7 ) >> ( 4 + 1 ), b_Q8 ), // Q11 + SKP_SMULWB( SILK_FIX_CONST( 1.0, 14 ) + psEncCtrl->input_quality_Q14, psEncCtrl->coding_quality_Q14 ) ); // Q12 } if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) { /* Reduce gains for periodic signals */ - SNR_adj_dB_Q7 = SKP_SMLAWB( SNR_adj_dB_Q7, SKP_FIX_CONST( HARM_SNR_INCR_dB, 8 ), psEnc->LTPCorr_Q15 ); + SNR_adj_dB_Q7 = SKP_SMLAWB( SNR_adj_dB_Q7, SILK_FIX_CONST( HARM_SNR_INCR_dB, 8 ), psEnc->LTPCorr_Q15 ); } else { /* For unvoiced signals and low-quality input, adjust the quality slower than SNR_dB setting */ SNR_adj_dB_Q7 = SKP_SMLAWB( SNR_adj_dB_Q7, - SKP_SMLAWB( SKP_FIX_CONST( 6.0, 9 ), -SKP_FIX_CONST( 0.4, 18 ), psEnc->sCmn.SNR_dB_Q7 ), - SKP_FIX_CONST( 1.0, 14 ) - psEncCtrl->input_quality_Q14 ); + SKP_SMLAWB( SILK_FIX_CONST( 6.0, 9 ), -SILK_FIX_CONST( 0.4, 18 ), psEnc->sCmn.SNR_dB_Q7 ), + SILK_FIX_CONST( 1.0, 14 ) - psEncCtrl->input_quality_Q14 ); } /*************************/ @@ -204,10 +204,10 @@ void SKP_Silk_noise_shape_analysis_FIX( log_energy_prev_Q7 = 0; pitch_res_ptr = pitch_res; for( k = 0; k < SKP_SMULBB( SUB_FRAME_LENGTH_MS, psEnc->sCmn.nb_subfr ) / 2; k++ ) { - SKP_Silk_sum_sqr_shift( &nrg, &scale, pitch_res_ptr, nSamples ); + silk_sum_sqr_shift( &nrg, &scale, pitch_res_ptr, nSamples ); nrg += SKP_RSHIFT( nSamples, scale ); // Q(-scale) - log_energy_Q7 = SKP_Silk_lin2log( nrg ); + log_energy_Q7 = silk_lin2log( nrg ); if( k > 0 ) { energy_variation_Q7 += SKP_abs( log_energy_Q7 - log_energy_prev_Q7 ); } @@ -215,29 +215,29 @@ void SKP_Silk_noise_shape_analysis_FIX( pitch_res_ptr += nSamples; } - psEncCtrl->sparseness_Q8 = SKP_RSHIFT( SKP_Silk_sigm_Q15( SKP_SMULWB( energy_variation_Q7 - - SKP_FIX_CONST( 5.0, 7 ), SKP_FIX_CONST( 0.1, 16 ) ) ), 7 ); + psEncCtrl->sparseness_Q8 = SKP_RSHIFT( silk_sigm_Q15( SKP_SMULWB( energy_variation_Q7 - + SILK_FIX_CONST( 5.0, 7 ), SILK_FIX_CONST( 0.1, 16 ) ) ), 7 ); /* Set quantization offset depending on sparseness measure */ - if( psEncCtrl->sparseness_Q8 > SKP_FIX_CONST( SPARSENESS_THRESHOLD_QNT_OFFSET, 8 ) ) { + if( psEncCtrl->sparseness_Q8 > SILK_FIX_CONST( SPARSENESS_THRESHOLD_QNT_OFFSET, 8 ) ) { psEnc->sCmn.indices.quantOffsetType = 0; } else { psEnc->sCmn.indices.quantOffsetType = 1; } /* Increase coding SNR for sparse signals */ - 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 ) ); + SNR_adj_dB_Q7 = SKP_SMLAWB( SNR_adj_dB_Q7, SILK_FIX_CONST( SPARSE_SNR_INCR_dB, 15 ), psEncCtrl->sparseness_Q8 - SILK_FIX_CONST( 0.5, 8 ) ); } /*******************************/ /* Control bandwidth expansion */ /*******************************/ /* More BWE for signals with high prediction gain */ - strength_Q16 = SKP_SMULWB( psEncCtrl->predGain_Q16, SKP_FIX_CONST( FIND_PITCH_WHITE_NOISE_FRACTION, 16 ) ); - BWExp1_Q16 = BWExp2_Q16 = SKP_DIV32_varQ( SKP_FIX_CONST( BANDWIDTH_EXPANSION, 16 ), - SKP_SMLAWW( SKP_FIX_CONST( 1.0, 16 ), strength_Q16, strength_Q16 ), 16 ); - delta_Q16 = SKP_SMULWB( SKP_FIX_CONST( 1.0, 16 ) - SKP_SMULBB( 3, psEncCtrl->coding_quality_Q14 ), - SKP_FIX_CONST( LOW_RATE_BANDWIDTH_EXPANSION_DELTA, 16 ) ); + strength_Q16 = SKP_SMULWB( psEncCtrl->predGain_Q16, SILK_FIX_CONST( FIND_PITCH_WHITE_NOISE_FRACTION, 16 ) ); + BWExp1_Q16 = BWExp2_Q16 = silk_DIV32_varQ( SILK_FIX_CONST( BANDWIDTH_EXPANSION, 16 ), + SKP_SMLAWW( SILK_FIX_CONST( 1.0, 16 ), strength_Q16, strength_Q16 ), 16 ); + delta_Q16 = SKP_SMULWB( SILK_FIX_CONST( 1.0, 16 ) - SKP_SMULBB( 3, psEncCtrl->coding_quality_Q14 ), + SILK_FIX_CONST( LOW_RATE_BANDWIDTH_EXPANSION_DELTA, 16 ) ); BWExp1_Q16 = SKP_SUB32( BWExp1_Q16, delta_Q16 ); BWExp2_Q16 = SKP_ADD32( BWExp2_Q16, delta_Q16 ); /* BWExp1 will be applied after BWExp2, so make it relative */ @@ -245,7 +245,7 @@ void SKP_Silk_noise_shape_analysis_FIX( if( psEnc->sCmn.warping_Q16 > 0 ) { /* Slightly more warping in analysis will move quantization noise up in frequency, where it's better masked */ - warping_Q16 = SKP_SMLAWB( psEnc->sCmn.warping_Q16, psEncCtrl->coding_quality_Q14, SKP_FIX_CONST( 0.01, 18 ) ); + warping_Q16 = SKP_SMLAWB( psEnc->sCmn.warping_Q16, psEncCtrl->coding_quality_Q14, SILK_FIX_CONST( 0.01, 18 ) ); } else { warping_Q16 = 0; } @@ -259,33 +259,33 @@ void SKP_Silk_noise_shape_analysis_FIX( flat_part = psEnc->sCmn.fs_kHz * 3; slope_part = SKP_RSHIFT( psEnc->sCmn.shapeWinLength - flat_part, 1 ); - SKP_Silk_apply_sine_window( x_windowed, x_ptr, 1, slope_part ); + silk_apply_sine_window( x_windowed, x_ptr, 1, slope_part ); shift = slope_part; SKP_memcpy( x_windowed + shift, x_ptr + shift, flat_part * sizeof(SKP_int16) ); shift += flat_part; - SKP_Silk_apply_sine_window( x_windowed + shift, x_ptr + shift, 2, slope_part ); + silk_apply_sine_window( x_windowed + shift, x_ptr + shift, 2, slope_part ); /* Update pointer: next LPC analysis block */ x_ptr += psEnc->sCmn.subfr_length; if( psEnc->sCmn.warping_Q16 > 0 ) { /* Calculate warped auto correlation */ - SKP_Silk_warped_autocorrelation_FIX( auto_corr, &scale, x_windowed, warping_Q16, psEnc->sCmn.shapeWinLength, psEnc->sCmn.shapingLPCOrder ); + silk_warped_autocorrelation_FIX( auto_corr, &scale, x_windowed, warping_Q16, psEnc->sCmn.shapeWinLength, psEnc->sCmn.shapingLPCOrder ); } else { /* Calculate regular auto correlation */ - SKP_Silk_autocorr( auto_corr, &scale, x_windowed, psEnc->sCmn.shapeWinLength, psEnc->sCmn.shapingLPCOrder + 1 ); + silk_autocorr( auto_corr, &scale, x_windowed, psEnc->sCmn.shapeWinLength, psEnc->sCmn.shapingLPCOrder + 1 ); } /* Add white noise, as a fraction of energy */ auto_corr[0] = SKP_ADD32( auto_corr[0], SKP_max_32( SKP_SMULWB( SKP_RSHIFT( auto_corr[ 0 ], 4 ), - SKP_FIX_CONST( SHAPE_WHITE_NOISE_FRACTION, 20 ) ), 1 ) ); + SILK_FIX_CONST( SHAPE_WHITE_NOISE_FRACTION, 20 ) ), 1 ) ); /* Calculate the reflection coefficients using schur */ - nrg = SKP_Silk_schur64( refl_coef_Q16, auto_corr, psEnc->sCmn.shapingLPCOrder ); + nrg = silk_schur64( refl_coef_Q16, auto_corr, psEnc->sCmn.shapingLPCOrder ); SKP_assert( nrg >= 0 ); /* Convert reflection coefficients to prediction coefficients */ - SKP_Silk_k2a_Q16( AR2_Q24, refl_coef_Q16, psEnc->sCmn.shapingLPCOrder ); + silk_k2a_Q16( AR2_Q24, refl_coef_Q16, psEnc->sCmn.shapingLPCOrder ); Qnrg = -scale; // range: -12...30 SKP_assert( Qnrg >= -12 ); @@ -297,7 +297,7 @@ void SKP_Silk_noise_shape_analysis_FIX( nrg >>= 1; } - tmp32 = SKP_Silk_SQRT_APPROX( nrg ); + tmp32 = silk_SQRT_APPROX( nrg ); Qnrg >>= 1; // range: -6...15 sqrt_nrg[ k ] = tmp32; @@ -312,25 +312,25 @@ void SKP_Silk_noise_shape_analysis_FIX( } /* Bandwidth expansion for synthesis filter shaping */ - SKP_Silk_bwexpander_32( AR2_Q24, psEnc->sCmn.shapingLPCOrder, BWExp2_Q16 ); + silk_bwexpander_32( AR2_Q24, psEnc->sCmn.shapingLPCOrder, BWExp2_Q16 ); /* Compute noise shaping filter coefficients */ SKP_memcpy( AR1_Q24, AR2_Q24, psEnc->sCmn.shapingLPCOrder * sizeof( SKP_int32 ) ); /* Bandwidth expansion for analysis filter shaping */ - SKP_assert( BWExp1_Q16 <= SKP_FIX_CONST( 1.0, 16 ) ); - SKP_Silk_bwexpander_32( AR1_Q24, psEnc->sCmn.shapingLPCOrder, BWExp1_Q16 ); + SKP_assert( BWExp1_Q16 <= SILK_FIX_CONST( 1.0, 16 ) ); + silk_bwexpander_32( AR1_Q24, psEnc->sCmn.shapingLPCOrder, BWExp1_Q16 ); /* Ratio of prediction gains, in energy domain */ - SKP_Silk_LPC_inverse_pred_gain_Q24( &pre_nrg_Q30, AR2_Q24, psEnc->sCmn.shapingLPCOrder ); - SKP_Silk_LPC_inverse_pred_gain_Q24( &nrg, AR1_Q24, psEnc->sCmn.shapingLPCOrder ); + silk_LPC_inverse_pred_gain_Q24( &pre_nrg_Q30, AR2_Q24, psEnc->sCmn.shapingLPCOrder ); + silk_LPC_inverse_pred_gain_Q24( &nrg, AR1_Q24, psEnc->sCmn.shapingLPCOrder ); //psEncCtrl->GainsPre[ k ] = 1.0f - 0.7f * ( 1.0f - pre_nrg / nrg ) = 0.3f + 0.7f * pre_nrg / nrg; - pre_nrg_Q30 = SKP_LSHIFT32( SKP_SMULWB( pre_nrg_Q30, SKP_FIX_CONST( 0.7, 15 ) ), 1 ); - psEncCtrl->GainsPre_Q14[ k ] = ( SKP_int ) SKP_FIX_CONST( 0.3, 14 ) + SKP_DIV32_varQ( pre_nrg_Q30, nrg, 14 ); + pre_nrg_Q30 = SKP_LSHIFT32( SKP_SMULWB( pre_nrg_Q30, SILK_FIX_CONST( 0.7, 15 ) ), 1 ); + psEncCtrl->GainsPre_Q14[ k ] = ( SKP_int ) SILK_FIX_CONST( 0.3, 14 ) + silk_DIV32_varQ( pre_nrg_Q30, nrg, 14 ); /* Convert to monic warped prediction coefficients and limit absolute values */ - limit_warped_coefs( AR2_Q24, AR1_Q24, warping_Q16, SKP_FIX_CONST( 3.999, 24 ), psEnc->sCmn.shapingLPCOrder ); + limit_warped_coefs( AR2_Q24, AR1_Q24, warping_Q16, SILK_FIX_CONST( 3.999, 24 ), psEnc->sCmn.shapingLPCOrder ); /* Convert from Q24 to Q13 and store in int16 */ for( i = 0; i < psEnc->sCmn.shapingLPCOrder; i++ ) { @@ -343,8 +343,8 @@ void SKP_Silk_noise_shape_analysis_FIX( /* Gain tweaking */ /*****************/ /* Increase gains during low speech activity and put lower limit on gains */ - gain_mult_Q16 = SKP_Silk_log2lin( -SKP_SMLAWB( -SKP_FIX_CONST( 16.0, 7 ), SNR_adj_dB_Q7, SKP_FIX_CONST( 0.16, 16 ) ) ); - gain_add_Q16 = SKP_Silk_log2lin( SKP_SMLAWB( SKP_FIX_CONST( 16.0, 7 ), SKP_FIX_CONST( MIN_QGAIN_DB, 7 ), SKP_FIX_CONST( 0.16, 16 ) ) ); + gain_mult_Q16 = silk_log2lin( -SKP_SMLAWB( -SILK_FIX_CONST( 16.0, 7 ), SNR_adj_dB_Q7, SILK_FIX_CONST( 0.16, 16 ) ) ); + gain_add_Q16 = silk_log2lin( SKP_SMLAWB( SILK_FIX_CONST( 16.0, 7 ), SILK_FIX_CONST( MIN_QGAIN_DB, 7 ), SILK_FIX_CONST( 0.16, 16 ) ) ); SKP_assert( gain_mult_Q16 > 0 ); for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { psEncCtrl->Gains_Q16[ k ] = SKP_SMULWW( psEncCtrl->Gains_Q16[ k ], gain_mult_Q16 ); @@ -352,8 +352,8 @@ void SKP_Silk_noise_shape_analysis_FIX( psEncCtrl->Gains_Q16[ k ] = SKP_ADD_POS_SAT32( psEncCtrl->Gains_Q16[ k ], gain_add_Q16 ); } - gain_mult_Q16 = SKP_FIX_CONST( 1.0, 16 ) + SKP_RSHIFT_ROUND( SKP_MLA( SKP_FIX_CONST( INPUT_TILT, 26 ), - psEncCtrl->coding_quality_Q14, SKP_FIX_CONST( HIGH_RATE_INPUT_TILT, 12 ) ), 10 ); + gain_mult_Q16 = SILK_FIX_CONST( 1.0, 16 ) + SKP_RSHIFT_ROUND( SKP_MLA( SILK_FIX_CONST( INPUT_TILT, 26 ), + psEncCtrl->coding_quality_Q14, SILK_FIX_CONST( HIGH_RATE_INPUT_TILT, 12 ) ), 10 ); for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { psEncCtrl->GainsPre_Q14[ k ] = SKP_SMULWB( gain_mult_Q16, psEncCtrl->GainsPre_Q14[ k ] ); } @@ -362,55 +362,55 @@ void SKP_Silk_noise_shape_analysis_FIX( /* Control low-frequency shaping and noise tilt */ /************************************************/ /* Less low frequency shaping for noisy inputs */ - strength_Q16 = SKP_MUL( SKP_FIX_CONST( LOW_FREQ_SHAPING, 4 ), SKP_SMLAWB( SKP_FIX_CONST( 1.0, 12 ), - SKP_FIX_CONST( LOW_QUALITY_LOW_FREQ_SHAPING_DECR, 13 ), psEnc->sCmn.input_quality_bands_Q15[ 0 ] - SKP_FIX_CONST( 1.0, 15 ) ) ); + strength_Q16 = SKP_MUL( SILK_FIX_CONST( LOW_FREQ_SHAPING, 4 ), SKP_SMLAWB( SILK_FIX_CONST( 1.0, 12 ), + SILK_FIX_CONST( LOW_QUALITY_LOW_FREQ_SHAPING_DECR, 13 ), psEnc->sCmn.input_quality_bands_Q15[ 0 ] - SILK_FIX_CONST( 1.0, 15 ) ) ); strength_Q16 = SKP_RSHIFT( SKP_MUL( strength_Q16, psEnc->sCmn.speech_activity_Q8 ), 8 ); if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) { /* Reduce low frequencies quantization noise for periodic signals, depending on pitch lag */ /*f = 400; freqz([1, -0.98 + 2e-4 * f], [1, -0.97 + 7e-4 * f], 2^12, Fs); axis([0, 1000, -10, 1])*/ - SKP_int fs_kHz_inv = SKP_DIV32_16( SKP_FIX_CONST( 0.2, 14 ), psEnc->sCmn.fs_kHz ); + SKP_int fs_kHz_inv = SKP_DIV32_16( SILK_FIX_CONST( 0.2, 14 ), psEnc->sCmn.fs_kHz ); for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { - b_Q14 = fs_kHz_inv + SKP_DIV32_16( SKP_FIX_CONST( 3.0, 14 ), psEncCtrl->pitchL[ k ] ); + b_Q14 = fs_kHz_inv + SKP_DIV32_16( SILK_FIX_CONST( 3.0, 14 ), psEncCtrl->pitchL[ k ] ); /* Pack two coefficients in one int32 */ - psEncCtrl->LF_shp_Q14[ k ] = SKP_LSHIFT( SKP_FIX_CONST( 1.0, 14 ) - b_Q14 - SKP_SMULWB( strength_Q16, b_Q14 ), 16 ); - psEncCtrl->LF_shp_Q14[ k ] |= (SKP_uint16)( b_Q14 - SKP_FIX_CONST( 1.0, 14 ) ); + psEncCtrl->LF_shp_Q14[ k ] = SKP_LSHIFT( SILK_FIX_CONST( 1.0, 14 ) - b_Q14 - SKP_SMULWB( strength_Q16, b_Q14 ), 16 ); + psEncCtrl->LF_shp_Q14[ k ] |= (SKP_uint16)( b_Q14 - SILK_FIX_CONST( 1.0, 14 ) ); } - 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 - Tilt_Q16 = - SKP_FIX_CONST( HP_NOISE_COEF, 16 ) - - SKP_SMULWB( SKP_FIX_CONST( 1.0, 16 ) - SKP_FIX_CONST( HP_NOISE_COEF, 16 ), - SKP_SMULWB( SKP_FIX_CONST( HARM_HP_NOISE_COEF, 24 ), psEnc->sCmn.speech_activity_Q8 ) ); + SKP_assert( SILK_FIX_CONST( HARM_HP_NOISE_COEF, 24 ) < SILK_FIX_CONST( 0.5, 24 ) ); // Guarantees that second argument to SMULWB() is within range of an SKP_int16 + Tilt_Q16 = - SILK_FIX_CONST( HP_NOISE_COEF, 16 ) - + SKP_SMULWB( SILK_FIX_CONST( 1.0, 16 ) - SILK_FIX_CONST( HP_NOISE_COEF, 16 ), + SKP_SMULWB( SILK_FIX_CONST( HARM_HP_NOISE_COEF, 24 ), psEnc->sCmn.speech_activity_Q8 ) ); } else { b_Q14 = SKP_DIV32_16( 21299, psEnc->sCmn.fs_kHz ); // 1.3_Q0 = 21299_Q14 /* Pack two coefficients in one int32 */ - psEncCtrl->LF_shp_Q14[ 0 ] = SKP_LSHIFT( SKP_FIX_CONST( 1.0, 14 ) - b_Q14 - - SKP_SMULWB( strength_Q16, SKP_SMULWB( SKP_FIX_CONST( 0.6, 16 ), b_Q14 ) ), 16 ); - psEncCtrl->LF_shp_Q14[ 0 ] |= (SKP_uint16)( b_Q14 - SKP_FIX_CONST( 1.0, 14 ) ); + psEncCtrl->LF_shp_Q14[ 0 ] = SKP_LSHIFT( SILK_FIX_CONST( 1.0, 14 ) - b_Q14 - + SKP_SMULWB( strength_Q16, SKP_SMULWB( SILK_FIX_CONST( 0.6, 16 ), b_Q14 ) ), 16 ); + psEncCtrl->LF_shp_Q14[ 0 ] |= (SKP_uint16)( b_Q14 - SILK_FIX_CONST( 1.0, 14 ) ); for( k = 1; k < psEnc->sCmn.nb_subfr; k++ ) { psEncCtrl->LF_shp_Q14[ k ] = psEncCtrl->LF_shp_Q14[ 0 ]; } - Tilt_Q16 = -SKP_FIX_CONST( HP_NOISE_COEF, 16 ); + Tilt_Q16 = -SILK_FIX_CONST( HP_NOISE_COEF, 16 ); } /****************************/ /* HARMONIC SHAPING CONTROL */ /****************************/ /* Control boosting of harmonic frequencies */ - HarmBoost_Q16 = SKP_SMULWB( SKP_SMULWB( SKP_FIX_CONST( 1.0, 17 ) - SKP_LSHIFT( psEncCtrl->coding_quality_Q14, 3 ), - psEnc->LTPCorr_Q15 ), SKP_FIX_CONST( LOW_RATE_HARMONIC_BOOST, 16 ) ); + HarmBoost_Q16 = SKP_SMULWB( SKP_SMULWB( SILK_FIX_CONST( 1.0, 17 ) - SKP_LSHIFT( psEncCtrl->coding_quality_Q14, 3 ), + psEnc->LTPCorr_Q15 ), SILK_FIX_CONST( LOW_RATE_HARMONIC_BOOST, 16 ) ); /* More harmonic boost for noisy input signals */ HarmBoost_Q16 = SKP_SMLAWB( HarmBoost_Q16, - SKP_FIX_CONST( 1.0, 16 ) - SKP_LSHIFT( psEncCtrl->input_quality_Q14, 2 ), SKP_FIX_CONST( LOW_INPUT_QUALITY_HARMONIC_BOOST, 16 ) ); + SILK_FIX_CONST( 1.0, 16 ) - SKP_LSHIFT( psEncCtrl->input_quality_Q14, 2 ), SILK_FIX_CONST( LOW_INPUT_QUALITY_HARMONIC_BOOST, 16 ) ); if( USE_HARM_SHAPING && psEnc->sCmn.indices.signalType == TYPE_VOICED ) { /* More harmonic noise shaping for high bitrates or noisy input */ - HarmShapeGain_Q16 = SKP_SMLAWB( SKP_FIX_CONST( HARMONIC_SHAPING, 16 ), - SKP_FIX_CONST( 1.0, 16 ) - SKP_SMULWB( SKP_FIX_CONST( 1.0, 18 ) - SKP_LSHIFT( psEncCtrl->coding_quality_Q14, 4 ), - psEncCtrl->input_quality_Q14 ), SKP_FIX_CONST( HIGH_RATE_OR_LOW_QUALITY_HARMONIC_SHAPING, 16 ) ); + HarmShapeGain_Q16 = SKP_SMLAWB( SILK_FIX_CONST( HARMONIC_SHAPING, 16 ), + SILK_FIX_CONST( 1.0, 16 ) - SKP_SMULWB( SILK_FIX_CONST( 1.0, 18 ) - SKP_LSHIFT( psEncCtrl->coding_quality_Q14, 4 ), + psEncCtrl->input_quality_Q14 ), SILK_FIX_CONST( HIGH_RATE_OR_LOW_QUALITY_HARMONIC_SHAPING, 16 ) ); /* Less harmonic noise shaping for less periodic signals */ HarmShapeGain_Q16 = SKP_SMULWB( SKP_LSHIFT( HarmShapeGain_Q16, 1 ), - SKP_Silk_SQRT_APPROX( SKP_LSHIFT( psEnc->LTPCorr_Q15, 15 ) ) ); + silk_SQRT_APPROX( SKP_LSHIFT( psEnc->LTPCorr_Q15, 15 ) ) ); } else { HarmShapeGain_Q16 = 0; } @@ -420,11 +420,11 @@ void SKP_Silk_noise_shape_analysis_FIX( /*************************/ for( k = 0; k < MAX_NB_SUBFR; k++ ) { psShapeSt->HarmBoost_smth_Q16 = - SKP_SMLAWB( psShapeSt->HarmBoost_smth_Q16, HarmBoost_Q16 - psShapeSt->HarmBoost_smth_Q16, SKP_FIX_CONST( SUBFR_SMTH_COEF, 16 ) ); + SKP_SMLAWB( psShapeSt->HarmBoost_smth_Q16, HarmBoost_Q16 - psShapeSt->HarmBoost_smth_Q16, SILK_FIX_CONST( SUBFR_SMTH_COEF, 16 ) ); psShapeSt->HarmShapeGain_smth_Q16 = - SKP_SMLAWB( psShapeSt->HarmShapeGain_smth_Q16, HarmShapeGain_Q16 - psShapeSt->HarmShapeGain_smth_Q16, SKP_FIX_CONST( SUBFR_SMTH_COEF, 16 ) ); + SKP_SMLAWB( psShapeSt->HarmShapeGain_smth_Q16, HarmShapeGain_Q16 - psShapeSt->HarmShapeGain_smth_Q16, SILK_FIX_CONST( SUBFR_SMTH_COEF, 16 ) ); psShapeSt->Tilt_smth_Q16 = - SKP_SMLAWB( psShapeSt->Tilt_smth_Q16, Tilt_Q16 - psShapeSt->Tilt_smth_Q16, SKP_FIX_CONST( SUBFR_SMTH_COEF, 16 ) ); + SKP_SMLAWB( psShapeSt->Tilt_smth_Q16, Tilt_Q16 - psShapeSt->Tilt_smth_Q16, SILK_FIX_CONST( SUBFR_SMTH_COEF, 16 ) ); psEncCtrl->HarmBoost_Q14[ k ] = ( SKP_int )SKP_RSHIFT_ROUND( psShapeSt->HarmBoost_smth_Q16, 2 ); psEncCtrl->HarmShapeGain_Q14[ k ] = ( SKP_int )SKP_RSHIFT_ROUND( psShapeSt->HarmShapeGain_smth_Q16, 2 ); diff --git a/silk/fixed/SKP_Silk_prefilter_FIX.c b/silk/fixed/silk_prefilter_FIX.c similarity index 88% rename from silk/fixed/SKP_Silk_prefilter_FIX.c rename to silk/fixed/silk_prefilter_FIX.c index 58be293f..44e60346 100644 --- a/silk/fixed/SKP_Silk_prefilter_FIX.c +++ b/silk/fixed/silk_prefilter_FIX.c @@ -25,12 +25,12 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FIX.h" -#include "SKP_Silk_tuning_parameters.h" +#include "silk_main_FIX.h" +#include "silk_tuning_parameters.h" -/* SKP_Silk_prefilter. Prefilter for finding Quantizer input signal */ -SKP_INLINE void SKP_Silk_prefilt_FIX( - SKP_Silk_prefilter_state_FIX *P, /* I/O state */ +/* silk_prefilter. Prefilter for finding Quantizer input signal */ +SKP_INLINE void silk_prefilt_FIX( + silk_prefilter_state_FIX *P, /* I/O state */ SKP_int32 st_res_Q12[], /* I short term residual signal */ SKP_int16 xw[], /* O prefiltered signal */ SKP_int32 HarmShapeFIRPacked_Q12, /* I Harmonic shaping coeficients */ @@ -40,7 +40,7 @@ SKP_INLINE void SKP_Silk_prefilt_FIX( SKP_int length /* I Length of signals */ ); -void SKP_Silk_warped_LPC_analysis_filter_FIX( +void silk_warped_LPC_analysis_filter_FIX( SKP_int32 state[], /* I/O State [order + 1] */ SKP_int16 res[], /* O Residual signal [length] */ const SKP_int16 coef_Q13[], /* I Coefficients [order] */ @@ -81,14 +81,14 @@ void SKP_Silk_warped_LPC_analysis_filter_FIX( } } -void SKP_Silk_prefilter_FIX( - SKP_Silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */ - const SKP_Silk_encoder_control_FIX *psEncCtrl, /* I Encoder control FIX */ +void silk_prefilter_FIX( + silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */ + const silk_encoder_control_FIX *psEncCtrl, /* I Encoder control FIX */ SKP_int16 xw[], /* O Weighted signal */ const SKP_int16 x[] /* I Speech signal */ ) { - SKP_Silk_prefilter_state_FIX *P = &psEnc->sPrefilt; + silk_prefilter_state_FIX *P = &psEnc->sPrefilt; SKP_int j, k, lag; SKP_int32 tmp_32; const SKP_int16 *AR1_shp_Q13; @@ -120,13 +120,13 @@ void SKP_Silk_prefilter_FIX( AR1_shp_Q13 = &psEncCtrl->AR1_Q13[ k * MAX_SHAPE_LPC_ORDER ]; /* Short term FIR filtering*/ - SKP_Silk_warped_LPC_analysis_filter_FIX( P->sAR_shp, st_res, AR1_shp_Q13, px, + silk_warped_LPC_analysis_filter_FIX( P->sAR_shp, st_res, AR1_shp_Q13, px, psEnc->sCmn.warping_Q16, psEnc->sCmn.subfr_length, psEnc->sCmn.shapingLPCOrder ); /* reduce (mainly) low frequencies during harmonic emphasis */ B_Q12[ 0 ] = SKP_RSHIFT_ROUND( psEncCtrl->GainsPre_Q14[ k ], 2 ); - tmp_32 = SKP_SMLABB( SKP_FIX_CONST( INPUT_TILT, 26 ), psEncCtrl->HarmBoost_Q14[ k ], HarmShapeGain_Q12 ); /* Q26 */ - tmp_32 = SKP_SMLABB( tmp_32, psEncCtrl->coding_quality_Q14, SKP_FIX_CONST( HIGH_RATE_INPUT_TILT, 12 ) ); /* Q26 */ + tmp_32 = SKP_SMLABB( SILK_FIX_CONST( INPUT_TILT, 26 ), psEncCtrl->HarmBoost_Q14[ k ], HarmShapeGain_Q12 ); /* Q26 */ + tmp_32 = SKP_SMLABB( tmp_32, psEncCtrl->coding_quality_Q14, SILK_FIX_CONST( HIGH_RATE_INPUT_TILT, 12 ) ); /* Q26 */ tmp_32 = SKP_SMULWB( tmp_32, -psEncCtrl->GainsPre_Q14[ k ] ); /* Q24 */ tmp_32 = SKP_RSHIFT_ROUND( tmp_32, 12 ); /* Q12 */ B_Q12[ 1 ]= SKP_SAT16( tmp_32 ); @@ -137,7 +137,7 @@ void SKP_Silk_prefilter_FIX( } P->sHarmHP = st_res[ psEnc->sCmn.subfr_length - 1 ]; - SKP_Silk_prefilt_FIX( P, x_filt_Q12, pxw, HarmShapeFIRPacked_Q12, Tilt_Q14, + silk_prefilt_FIX( P, x_filt_Q12, pxw, HarmShapeFIRPacked_Q12, Tilt_Q14, LF_shp_Q14, lag, psEnc->sCmn.subfr_length ); px += psEnc->sCmn.subfr_length; @@ -147,9 +147,9 @@ void SKP_Silk_prefilter_FIX( P->lagPrev = psEncCtrl->pitchL[ MAX_NB_SUBFR - 1 ]; } -/* SKP_Silk_prefilter. Prefilter for finding Quantizer input signal */ -SKP_INLINE void SKP_Silk_prefilt_FIX( - SKP_Silk_prefilter_state_FIX *P, /* I/O state */ +/* silk_prefilter. Prefilter for finding Quantizer input signal */ +SKP_INLINE void silk_prefilt_FIX( + silk_prefilter_state_FIX *P, /* I/O state */ SKP_int32 st_res_Q12[], /* I short term residual signal */ SKP_int16 xw[], /* O prefiltered signal */ SKP_int32 HarmShapeFIRPacked_Q12, /* I Harmonic shaping coeficients */ diff --git a/silk/fixed/SKP_Silk_process_gains_FIX.c b/silk/fixed/silk_process_gains_FIX.c similarity index 67% rename from silk/fixed/SKP_Silk_process_gains_FIX.c rename to silk/fixed/silk_process_gains_FIX.c index c11502b0..b884129c 100644 --- a/silk/fixed/SKP_Silk_process_gains_FIX.c +++ b/silk/fixed/silk_process_gains_FIX.c @@ -25,23 +25,23 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FIX.h" -#include "SKP_Silk_tuning_parameters.h" +#include "silk_main_FIX.h" +#include "silk_tuning_parameters.h" /* Processing of gains */ -void SKP_Silk_process_gains_FIX( - SKP_Silk_encoder_state_FIX *psEnc, /* I/O Encoder state_FIX */ - SKP_Silk_encoder_control_FIX *psEncCtrl /* I/O Encoder control_FIX */ +void silk_process_gains_FIX( + silk_encoder_state_FIX *psEnc, /* I/O Encoder state_FIX */ + silk_encoder_control_FIX *psEncCtrl /* I/O Encoder control_FIX */ ) { - SKP_Silk_shape_state_FIX *psShapeSt = &psEnc->sShape; + silk_shape_state_FIX *psShapeSt = &psEnc->sShape; SKP_int k; SKP_int32 s_Q16, InvMaxSqrVal_Q16, gain, gain_squared, ResNrg, ResNrgPart, quant_offset_Q10; /* Gain reduction when LTP coding gain is high */ if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) { /*s = -0.5f * SKP_sigmoid( 0.25f * ( psEncCtrl->LTPredCodGain - 12.0f ) ); */ - s_Q16 = -SKP_Silk_sigm_Q15( SKP_RSHIFT_ROUND( psEncCtrl->LTPredCodGain_Q7 - SKP_FIX_CONST( 12.0, 7 ), 4 ) ); + s_Q16 = -silk_sigm_Q15( SKP_RSHIFT_ROUND( psEncCtrl->LTPredCodGain_Q7 - SILK_FIX_CONST( 12.0, 7 ), 4 ) ); for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { psEncCtrl->Gains_Q16[ k ] = SKP_SMLAWB( psEncCtrl->Gains_Q16[ k ], psEncCtrl->Gains_Q16[ k ], s_Q16 ); } @@ -49,8 +49,8 @@ void SKP_Silk_process_gains_FIX( /* Limit the quantized signal */ /* InvMaxSqrVal = pow( 2.0f, 0.33f * ( 21.0f - SNR_dB ) ) / subfr_length; */ - InvMaxSqrVal_Q16 = SKP_DIV32_16( SKP_Silk_log2lin( - SKP_SMULWB( SKP_FIX_CONST( 21 + 16 / 0.33, 7 ) - psEnc->sCmn.SNR_dB_Q7, SKP_FIX_CONST( 0.33, 16 ) ) ), psEnc->sCmn.subfr_length ); + InvMaxSqrVal_Q16 = SKP_DIV32_16( silk_log2lin( + SKP_SMULWB( SILK_FIX_CONST( 21 + 16 / 0.33, 7 ) - psEnc->sCmn.SNR_dB_Q7, SILK_FIX_CONST( 0.33, 16 ) ) ), psEnc->sCmn.subfr_length ); for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { /* Soft limit on ratio residual energy and squared gains */ @@ -71,23 +71,23 @@ void SKP_Silk_process_gains_FIX( /* recalculate with higher precision */ gain_squared = SKP_SMLAWW( SKP_LSHIFT( ResNrgPart, 16 ), gain, gain ); SKP_assert( gain_squared > 0 ); - gain = SKP_Silk_SQRT_APPROX( gain_squared ); /* Q8 */ + gain = silk_SQRT_APPROX( gain_squared ); /* Q8 */ gain = SKP_min( gain, SKP_int32_MAX >> 8 ); psEncCtrl->Gains_Q16[ k ] = SKP_LSHIFT_SAT32( gain, 8 ); /* Q16 */ } else { - gain = SKP_Silk_SQRT_APPROX( gain_squared ); /* Q0 */ + gain = silk_SQRT_APPROX( gain_squared ); /* Q0 */ gain = SKP_min( gain, SKP_int32_MAX >> 16 ); psEncCtrl->Gains_Q16[ k ] = SKP_LSHIFT_SAT32( gain, 16 ); /* Q16 */ } } /* Noise shaping quantization */ - SKP_Silk_gains_quant( psEnc->sCmn.indices.GainsIndices, psEncCtrl->Gains_Q16, - &psShapeSt->LastGainIndex, psEnc->sCmn.nFramesAnalyzed, psEnc->sCmn.nb_subfr ); + silk_gains_quant( psEnc->sCmn.indices.GainsIndices, psEncCtrl->Gains_Q16, + &psShapeSt->LastGainIndex, psEnc->sCmn.nFramesEncoded, psEnc->sCmn.nb_subfr ); /* Set quantizer offset for voiced signals. Larger offset when LTP coding gain is low or tilt is high (ie low-pass) */ if( psEnc->sCmn.indices.signalType == TYPE_VOICED ) { - if( psEncCtrl->LTPredCodGain_Q7 + SKP_RSHIFT( psEnc->sCmn.input_tilt_Q15, 8 ) > SKP_FIX_CONST( 1.0, 7 ) ) { + if( psEncCtrl->LTPredCodGain_Q7 + SKP_RSHIFT( psEnc->sCmn.input_tilt_Q15, 8 ) > SILK_FIX_CONST( 1.0, 7 ) ) { psEnc->sCmn.indices.quantOffsetType = 0; } else { psEnc->sCmn.indices.quantOffsetType = 1; @@ -95,14 +95,14 @@ void SKP_Silk_process_gains_FIX( } /* Quantizer boundary adjustment */ - quant_offset_Q10 = SKP_Silk_Quantization_Offsets_Q10[ psEnc->sCmn.indices.signalType >> 1 ][ psEnc->sCmn.indices.quantOffsetType ]; - psEncCtrl->Lambda_Q10 = SKP_FIX_CONST( LAMBDA_OFFSET, 10 ) - + SKP_SMULBB( SKP_FIX_CONST( LAMBDA_DELAYED_DECISIONS, 10 ), psEnc->sCmn.nStatesDelayedDecision ) - + SKP_SMULWB( SKP_FIX_CONST( LAMBDA_SPEECH_ACT, 18 ), psEnc->sCmn.speech_activity_Q8 ) - + SKP_SMULWB( SKP_FIX_CONST( LAMBDA_INPUT_QUALITY, 12 ), psEncCtrl->input_quality_Q14 ) - + SKP_SMULWB( SKP_FIX_CONST( LAMBDA_CODING_QUALITY, 12 ), psEncCtrl->coding_quality_Q14 ) - + SKP_SMULWB( SKP_FIX_CONST( LAMBDA_QUANT_OFFSET, 16 ), quant_offset_Q10 ); + quant_offset_Q10 = silk_Quantization_Offsets_Q10[ psEnc->sCmn.indices.signalType >> 1 ][ psEnc->sCmn.indices.quantOffsetType ]; + psEncCtrl->Lambda_Q10 = SILK_FIX_CONST( LAMBDA_OFFSET, 10 ) + + SKP_SMULBB( SILK_FIX_CONST( LAMBDA_DELAYED_DECISIONS, 10 ), psEnc->sCmn.nStatesDelayedDecision ) + + SKP_SMULWB( SILK_FIX_CONST( LAMBDA_SPEECH_ACT, 18 ), psEnc->sCmn.speech_activity_Q8 ) + + SKP_SMULWB( SILK_FIX_CONST( LAMBDA_INPUT_QUALITY, 12 ), psEncCtrl->input_quality_Q14 ) + + SKP_SMULWB( SILK_FIX_CONST( LAMBDA_CODING_QUALITY, 12 ), psEncCtrl->coding_quality_Q14 ) + + SKP_SMULWB( SILK_FIX_CONST( LAMBDA_QUANT_OFFSET, 16 ), quant_offset_Q10 ); SKP_assert( psEncCtrl->Lambda_Q10 > 0 ); - SKP_assert( psEncCtrl->Lambda_Q10 < SKP_FIX_CONST( 2, 10 ) ); + SKP_assert( psEncCtrl->Lambda_Q10 < SILK_FIX_CONST( 2, 10 ) ); } diff --git a/silk/fixed/SKP_Silk_regularize_correlations_FIX.c b/silk/fixed/silk_regularize_correlations_FIX.c similarity index 95% rename from silk/fixed/SKP_Silk_regularize_correlations_FIX.c rename to silk/fixed/silk_regularize_correlations_FIX.c index f30f631c..b0737d42 100644 --- a/silk/fixed/SKP_Silk_regularize_correlations_FIX.c +++ b/silk/fixed/silk_regularize_correlations_FIX.c @@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FIX.h" +#include "silk_main_FIX.h" /* Add noise to matrix diagonal */ -void SKP_Silk_regularize_correlations_FIX( +void silk_regularize_correlations_FIX( SKP_int32 *XX, /* I/O Correlation matrices */ SKP_int32 *xx, /* I/O Correlation values */ SKP_int32 noise, /* I Noise to add */ diff --git a/silk/fixed/SKP_Silk_residual_energy16_FIX.c b/silk/fixed/silk_residual_energy16_FIX.c similarity index 92% rename from silk/fixed/SKP_Silk_residual_energy16_FIX.c rename to silk/fixed/silk_residual_energy16_FIX.c index b559ce61..f6511604 100644 --- a/silk/fixed/SKP_Silk_residual_energy16_FIX.c +++ b/silk/fixed/silk_residual_energy16_FIX.c @@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FIX.h" +#include "silk_main_FIX.h" /* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */ -SKP_int32 SKP_Silk_residual_energy16_covar_FIX( +SKP_int32 silk_residual_energy16_covar_FIX( const SKP_int16 *c, /* I Prediction vector */ const SKP_int32 *wXX, /* I Correlation matrix */ const SKP_int32 *wXx, /* I Correlation vector */ @@ -55,10 +55,10 @@ SKP_int32 SKP_Silk_residual_energy16_covar_FIX( for( i = 0; i < D; i++ ) { c_max = SKP_max_32( c_max, SKP_abs( ( SKP_int32 )c[ i ] ) ); } - Qxtra = SKP_min_int( Qxtra, SKP_Silk_CLZ32( c_max ) - 17 ); + Qxtra = SKP_min_int( Qxtra, silk_CLZ32( c_max ) - 17 ); w_max = SKP_max_32( wXX[ 0 ], wXX[ D * D - 1 ] ); - Qxtra = SKP_min_int( Qxtra, SKP_Silk_CLZ32( SKP_MUL( D, SKP_RSHIFT( SKP_SMULWB( w_max, c_max ), 4 ) ) ) - 5 ); + Qxtra = SKP_min_int( Qxtra, silk_CLZ32( SKP_MUL( D, SKP_RSHIFT( SKP_SMULWB( w_max, c_max ), 4 ) ) ) - 5 ); Qxtra = SKP_max_int( Qxtra, 0 ); for( i = 0; i < D; i++ ) { cn[ i ] = SKP_LSHIFT( ( SKP_int )c[ i ], Qxtra ); diff --git a/silk/fixed/SKP_Silk_residual_energy_FIX.c b/silk/fixed/silk_residual_energy_FIX.c similarity index 88% rename from silk/fixed/SKP_Silk_residual_energy_FIX.c rename to silk/fixed/silk_residual_energy_FIX.c index 2fb531ca..c161bb29 100644 --- a/silk/fixed/SKP_Silk_residual_energy_FIX.c +++ b/silk/fixed/silk_residual_energy_FIX.c @@ -25,15 +25,15 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FIX.h" +#include "silk_main_FIX.h" /* Calculates residual energies of input subframes where all subframes have LPC_order */ /* of preceeding samples */ -void SKP_Silk_residual_energy_FIX( +void silk_residual_energy_FIX( SKP_int32 nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */ SKP_int nrgsQ[ MAX_NB_SUBFR ], /* O Q value per subframe */ const SKP_int16 x[], /* I Input signal */ - const SKP_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */ + SKP_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */ const SKP_int32 gains[ MAX_NB_SUBFR ], /* I Quantization gains */ const SKP_int subfr_length, /* I Subframe length */ const SKP_int nb_subfr, /* I Number of subframes */ @@ -51,13 +51,13 @@ void SKP_Silk_residual_energy_FIX( /* Filter input to create the LPC residual for each frame half, and measure subframe energies */ for( i = 0; i < nb_subfr >> 1; i++ ) { /* Calculate half frame LPC residual signal including preceeding samples */ - SKP_Silk_LPC_analysis_filter( LPC_res, x_ptr, a_Q12[ i ], ( MAX_NB_SUBFR >> 1 ) * offset, LPC_order ); + silk_LPC_analysis_filter( LPC_res, x_ptr, a_Q12[ i ], ( MAX_NB_SUBFR >> 1 ) * offset, LPC_order ); /* Point to first subframe of the just calculated LPC residual signal */ LPC_res_ptr = LPC_res + LPC_order; for( j = 0; j < ( MAX_NB_SUBFR >> 1 ); j++ ) { /* Measure subframe energy */ - SKP_Silk_sum_sqr_shift( &nrgs[ i * ( MAX_NB_SUBFR >> 1 ) + j ], &rshift, LPC_res_ptr, subfr_length ); + silk_sum_sqr_shift( &nrgs[ i * ( MAX_NB_SUBFR >> 1 ) + j ], &rshift, LPC_res_ptr, subfr_length ); /* Set Q values for the measured energy */ nrgsQ[ i * ( MAX_NB_SUBFR >> 1 ) + j ] = -rshift; @@ -72,8 +72,8 @@ void SKP_Silk_residual_energy_FIX( /* Apply the squared subframe gains */ for( i = 0; i < nb_subfr; i++ ) { /* Fully upscale gains and energies */ - lz1 = SKP_Silk_CLZ32( nrgs[ i ] ) - 1; - lz2 = SKP_Silk_CLZ32( gains[ i ] ) - 1; + lz1 = silk_CLZ32( nrgs[ i ] ) - 1; + lz2 = silk_CLZ32( gains[ i ] ) - 1; tmp32 = SKP_LSHIFT32( gains[ i ], lz2 ); diff --git a/silk/fixed/SKP_Silk_solve_LS_FIX.c b/silk/fixed/silk_solve_LS_FIX.c similarity index 89% rename from silk/fixed/SKP_Silk_solve_LS_FIX.c rename to silk/fixed/silk_solve_LS_FIX.c index 25684185..a287a29b 100644 --- a/silk/fixed/SKP_Silk_solve_LS_FIX.c +++ b/silk/fixed/silk_solve_LS_FIX.c @@ -25,8 +25,8 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FIX.h" -#include "SKP_Silk_tuning_parameters.h" +#include "silk_main_FIX.h" +#include "silk_tuning_parameters.h" /*****************************/ /* Internal function headers */ @@ -38,7 +38,7 @@ typedef struct { } inv_D_t; /* Factorize square matrix A into LDL form */ -SKP_INLINE void SKP_Silk_LDL_factorize_FIX( +SKP_INLINE void silk_LDL_factorize_FIX( SKP_int32 *A, /* I/O Pointer to Symetric Square Matrix */ SKP_int M, /* I Size of Matrix */ SKP_int32 *L_Q16, /* I/O Pointer to Square Upper triangular Matrix */ @@ -46,7 +46,7 @@ SKP_INLINE void SKP_Silk_LDL_factorize_FIX( ); /* Solve Lx = b, when L is lower triangular and has ones on the diagonal */ -SKP_INLINE void SKP_Silk_LS_SolveFirst_FIX( +SKP_INLINE void silk_LS_SolveFirst_FIX( const SKP_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */ SKP_int M, /* I Dim of Matrix equation */ const SKP_int32 *b, /* I b Vector */ @@ -54,21 +54,21 @@ SKP_INLINE void SKP_Silk_LS_SolveFirst_FIX( ); /* Solve L^t*x = b, where L is lower triangular with ones on the diagonal */ -SKP_INLINE void SKP_Silk_LS_SolveLast_FIX( +SKP_INLINE void silk_LS_SolveLast_FIX( const SKP_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */ const SKP_int M, /* I Dim of Matrix equation */ const SKP_int32 *b, /* I b Vector */ SKP_int32 *x_Q16 /* O x Vector */ ); -SKP_INLINE void SKP_Silk_LS_divide_Q16_FIX( +SKP_INLINE void silk_LS_divide_Q16_FIX( SKP_int32 T[], /* I/O Numenator vector */ inv_D_t *inv_D, /* I 1 / D vector */ SKP_int M /* I dimension */ ); /* Solves Ax = b, assuming A is symmetric */ -void SKP_Silk_solve_LDL_FIX( +void silk_solve_LDL_FIX( SKP_int32 *A, /* I Pointer to symetric square matrix A */ SKP_int M, /* I Size of matrix */ const SKP_int32 *b, /* I Pointer to b vector */ @@ -85,27 +85,27 @@ void SKP_Silk_solve_LDL_FIX( Factorize A by LDL such that A = L*D*L', where L is lower triangular with ones on diagonal ****************************************************/ - SKP_Silk_LDL_factorize_FIX( A, M, L_Q16, inv_D ); + silk_LDL_factorize_FIX( A, M, L_Q16, inv_D ); /**************************************************** * substitute D*L'*x = Y. ie: L*D*L'*x = b => L*Y = b <=> Y = inv(L)*b ******************************************************/ - SKP_Silk_LS_SolveFirst_FIX( L_Q16, M, b, Y ); + silk_LS_SolveFirst_FIX( L_Q16, M, b, Y ); /**************************************************** D*L'*x = Y <=> L'*x = inv(D)*Y, because D is diagonal just multiply with 1/d_i ****************************************************/ - SKP_Silk_LS_divide_Q16_FIX( Y, inv_D, M ); + silk_LS_divide_Q16_FIX( Y, inv_D, M ); /**************************************************** x = inv(L') * inv(D) * Y *****************************************************/ - SKP_Silk_LS_SolveLast_FIX( L_Q16, M, Y, x_Q16 ); + silk_LS_SolveLast_FIX( L_Q16, M, Y, x_Q16 ); } -SKP_INLINE void SKP_Silk_LDL_factorize_FIX( +SKP_INLINE void silk_LDL_factorize_FIX( SKP_int32 *A, /* I Pointer to Symetric Square Matrix */ SKP_int M, /* I Size of Matrix */ SKP_int32 *L_Q16, /* I/O Pointer to Square Upper triangular Matrix */ @@ -121,7 +121,7 @@ SKP_INLINE void SKP_Silk_LDL_factorize_FIX( SKP_assert( M <= MAX_MATRIX_SIZE ); status = 1; - 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 ); + diag_min_value = SKP_max_32( SKP_SMMUL( SKP_ADD_SAT32( A[ 0 ], A[ SKP_SMULBB( M, M ) - 1 ] ), SILK_FIX_CONST( FIND_LTP_COND_FAC, 31 ) ), 1 << 9 ); for( loop_count = 0; loop_count < M && status == 1; loop_count++ ) { status = 0; for( j = 0; j < M; j++ ) { @@ -145,7 +145,7 @@ SKP_INLINE void SKP_Silk_LDL_factorize_FIX( D_Q0[ j ] = tmp_32; /* always < max(Correlation) */ /* two-step division */ - one_div_diag_Q36 = SKP_INVERSE32_varQ( tmp_32, 36 ); /* Q36 */ + one_div_diag_Q36 = silk_INVERSE32_varQ( tmp_32, 36 ); /* Q36 */ one_div_diag_Q40 = SKP_LSHIFT( one_div_diag_Q36, 4 ); /* Q40 */ err = SKP_SUB32( 1 << 24, SKP_SMULWW( tmp_32, one_div_diag_Q40 ) ); /* Q24 */ one_div_diag_Q48 = SKP_SMULWW( err, one_div_diag_Q40 ); /* Q48 */ @@ -177,7 +177,7 @@ SKP_INLINE void SKP_Silk_LDL_factorize_FIX( SKP_assert( status == 0 ); } -SKP_INLINE void SKP_Silk_LS_divide_Q16_FIX( +SKP_INLINE void silk_LS_divide_Q16_FIX( SKP_int32 T[], /* I/O Numenator vector */ inv_D_t *inv_D, /* I 1 / D vector */ SKP_int M /* I Order */ @@ -197,7 +197,7 @@ SKP_INLINE void SKP_Silk_LS_divide_Q16_FIX( } /* Solve Lx = b, when L is lower triangular and has ones on the diagonal */ -SKP_INLINE void SKP_Silk_LS_SolveFirst_FIX( +SKP_INLINE void silk_LS_SolveFirst_FIX( const SKP_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */ SKP_int M, /* I Dim of Matrix equation */ const SKP_int32 *b, /* I b Vector */ @@ -219,7 +219,7 @@ SKP_INLINE void SKP_Silk_LS_SolveFirst_FIX( } /* Solve L^t*x = b, where L is lower triangular with ones on the diagonal */ -SKP_INLINE void SKP_Silk_LS_SolveLast_FIX( +SKP_INLINE void silk_LS_SolveLast_FIX( const SKP_int32 *L_Q16, /* I Pointer to Lower Triangular Matrix */ const SKP_int M, /* I Dim of Matrix equation */ const SKP_int32 *b, /* I b Vector */ diff --git a/silk/fixed/SKP_Silk_structs_FIX.h b/silk/fixed/silk_structs_FIX.h similarity index 78% rename from silk/fixed/SKP_Silk_structs_FIX.h rename to silk/fixed/silk_structs_FIX.h index f7e91d2d..a479b52c 100644 --- a/silk/fixed/SKP_Silk_structs_FIX.h +++ b/silk/fixed/silk_structs_FIX.h @@ -25,12 +25,12 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#ifndef SKP_SILK_STRUCTS_FIX_H -#define SKP_SILK_STRUCTS_FIX_H +#ifndef SILK_STRUCTS_FIX_H +#define SILK_STRUCTS_FIX_H -#include "SKP_Silk_typedef.h" -#include "SKP_Silk_main.h" -#include "SKP_Silk_structs.h" +#include "silk_typedef.h" +#include "silk_main.h" +#include "silk_structs.h" #ifdef __cplusplus extern "C" @@ -45,7 +45,7 @@ typedef struct { SKP_int32 HarmBoost_smth_Q16; SKP_int32 HarmShapeGain_smth_Q16; SKP_int32 Tilt_smth_Q16; -} SKP_Silk_shape_state_FIX; +} silk_shape_state_FIX; /********************************/ /* Prefilter state */ @@ -59,15 +59,15 @@ typedef struct { SKP_int sHarmHP; SKP_int32 rand_seed; SKP_int lagPrev; -} SKP_Silk_prefilter_state_FIX; +} silk_prefilter_state_FIX; /********************************/ /* Encoder state FIX */ /********************************/ typedef struct { - SKP_Silk_encoder_state sCmn; /* Common struct, shared with floating-point code */ - SKP_Silk_shape_state_FIX sShape; /* Shape state */ - SKP_Silk_prefilter_state_FIX sPrefilt; /* Prefilter State */ + silk_encoder_state sCmn; /* Common struct, shared with floating-point code */ + silk_shape_state_FIX sShape; /* Shape state */ + silk_prefilter_state_FIX sPrefilt; /* Prefilter State */ /* Buffer for find pitch and noise shape analysis */ SKP_DWORD_ALIGN SKP_int16 x_buf[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ]; @@ -76,7 +76,7 @@ typedef struct { /* Parameters For LTP scaling Control */ SKP_int prevLTPredCodGain_Q7; SKP_int HPLTPredCodGain_Q7; -} SKP_Silk_encoder_state_FIX; +} silk_encoder_state_FIX; /************************/ /* Encoder control FIX */ @@ -109,7 +109,19 @@ typedef struct { SKP_int32 ResNrg[ MAX_NB_SUBFR ]; /* Residual energy per subframe */ SKP_int ResNrgQ[ MAX_NB_SUBFR ]; /* Q domain for the residual energy > 0 */ -} SKP_Silk_encoder_control_FIX; +} silk_encoder_control_FIX; + +/************************/ +/* Encoder Super Struct */ +/************************/ +typedef struct { + silk_encoder_state_FIX state_Fxx[ ENCODER_NUM_CHANNELS ]; + stereo_enc_state sStereo; + SKP_int32 nBitsExceeded; + SKP_int nChannels; + SKP_int timeSinceSwitchAllowed_ms; + SKP_int allowBandwidthSwitch; +} silk_encoder; #ifdef __cplusplus diff --git a/silk/fixed/SKP_Silk_warped_autocorrelation_FIX.c b/silk/fixed/silk_warped_autocorrelation_FIX.c similarity index 95% rename from silk/fixed/SKP_Silk_warped_autocorrelation_FIX.c rename to silk/fixed/silk_warped_autocorrelation_FIX.c index 380104ff..18a3cad9 100644 --- a/silk/fixed/SKP_Silk_warped_autocorrelation_FIX.c +++ b/silk/fixed/silk_warped_autocorrelation_FIX.c @@ -25,13 +25,13 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FIX.h" +#include "silk_main_FIX.h" #define QC 10 #define QS 14 /* Autocorrelations for a warped frequency axis */ -void SKP_Silk_warped_autocorrelation_FIX( +void silk_warped_autocorrelation_FIX( SKP_int32 *corr, /* O Result [order + 1] */ SKP_int *scale, /* O Scaling of the correlation vector */ const SKP_int16 *input, /* I Input data to correlate */ @@ -67,7 +67,7 @@ void SKP_Silk_warped_autocorrelation_FIX( corr_QC[ order ] += SKP_RSHIFT64( SKP_SMULL( tmp1_QS, state_QS[ 0 ] ), 2 * QS - QC ); } - lsh = SKP_Silk_CLZ64( corr_QC[ 0 ] ) - 35; + lsh = silk_CLZ64( corr_QC[ 0 ] ) - 35; lsh = SKP_LIMIT( lsh, -12 - QC, 30 - QC ); *scale = -( QC + lsh ); SKP_assert( *scale >= -30 && *scale <= 12 ); diff --git a/silk/float/SKP_Silk_LPC_analysis_filter_FLP.c b/silk/float/silk_LPC_analysis_filter_FLP.c similarity index 91% rename from silk/float/SKP_Silk_LPC_analysis_filter_FLP.c rename to silk/float/silk_LPC_analysis_filter_FLP.c index e8d7d6ba..b28196cd 100644 --- a/silk/float/SKP_Silk_LPC_analysis_filter_FLP.c +++ b/silk/float/silk_LPC_analysis_filter_FLP.c @@ -26,7 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ #include -#include "SKP_Silk_main_FLP.h" +#include "silk_main_FLP.h" /*******************************************/ /* LPC analysis filter */ @@ -36,7 +36,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /*******************************************/ /* 16th order LPC analysis filter, does not write first 16 samples */ -void SKP_Silk_LPC_analysis_filter16_FLP( +void silk_LPC_analysis_filter16_FLP( SKP_float r_LPC[], /* O LPC residual signal */ const SKP_float PredCoef[], /* I LPC coefficients */ const SKP_float s[], /* I Input signal */ @@ -74,7 +74,7 @@ void SKP_Silk_LPC_analysis_filter16_FLP( } /* 14th order LPC analysis filter, does not write first 14 samples */ -void SKP_Silk_LPC_analysis_filter14_FLP( +void silk_LPC_analysis_filter14_FLP( SKP_float r_LPC[], /* O LPC residual signal */ const SKP_float PredCoef[], /* I LPC coefficients */ const SKP_float s[], /* I Input signal */ @@ -110,7 +110,7 @@ void SKP_Silk_LPC_analysis_filter14_FLP( } /* 12th order LPC analysis filter, does not write first 12 samples */ -void SKP_Silk_LPC_analysis_filter12_FLP( +void silk_LPC_analysis_filter12_FLP( SKP_float r_LPC[], /* O LPC residual signal */ const SKP_float PredCoef[], /* I LPC coefficients */ const SKP_float s[], /* I Input signal */ @@ -144,7 +144,7 @@ void SKP_Silk_LPC_analysis_filter12_FLP( } /* 10th order LPC analysis filter, does not write first 10 samples */ -void SKP_Silk_LPC_analysis_filter10_FLP( +void silk_LPC_analysis_filter10_FLP( SKP_float r_LPC[], /* O LPC residual signal */ const SKP_float PredCoef[], /* I LPC coefficients */ const SKP_float s[], /* I Input signal */ @@ -176,7 +176,7 @@ void SKP_Silk_LPC_analysis_filter10_FLP( } /* 8th order LPC analysis filter, does not write first 8 samples */ -void SKP_Silk_LPC_analysis_filter8_FLP( +void silk_LPC_analysis_filter8_FLP( SKP_float r_LPC[], /* O LPC residual signal */ const SKP_float PredCoef[], /* I LPC coefficients */ const SKP_float s[], /* I Input signal */ @@ -206,7 +206,7 @@ void SKP_Silk_LPC_analysis_filter8_FLP( } /* 6th order LPC analysis filter, does not write first 6 samples */ -void SKP_Silk_LPC_analysis_filter6_FLP( +void silk_LPC_analysis_filter6_FLP( SKP_float r_LPC[], /* O LPC residual signal */ const SKP_float PredCoef[], /* I LPC coefficients */ const SKP_float s[], /* I Input signal */ @@ -240,7 +240,7 @@ void SKP_Silk_LPC_analysis_filter6_FLP( /* first Order output samples are not set */ /*******************************************/ -void SKP_Silk_LPC_analysis_filter_FLP( +void silk_LPC_analysis_filter_FLP( SKP_float r_LPC[], /* O LPC residual signal */ const SKP_float PredCoef[], /* I LPC coefficients */ const SKP_float s[], /* I Input signal */ @@ -252,27 +252,27 @@ void SKP_Silk_LPC_analysis_filter_FLP( switch( Order ) { case 6: - SKP_Silk_LPC_analysis_filter6_FLP( r_LPC, PredCoef, s, length ); + silk_LPC_analysis_filter6_FLP( r_LPC, PredCoef, s, length ); break; case 8: - SKP_Silk_LPC_analysis_filter8_FLP( r_LPC, PredCoef, s, length ); + silk_LPC_analysis_filter8_FLP( r_LPC, PredCoef, s, length ); break; case 10: - SKP_Silk_LPC_analysis_filter10_FLP( r_LPC, PredCoef, s, length ); + silk_LPC_analysis_filter10_FLP( r_LPC, PredCoef, s, length ); break; case 12: - SKP_Silk_LPC_analysis_filter12_FLP( r_LPC, PredCoef, s, length ); + silk_LPC_analysis_filter12_FLP( r_LPC, PredCoef, s, length ); break; case 14: - SKP_Silk_LPC_analysis_filter14_FLP( r_LPC, PredCoef, s, length ); + silk_LPC_analysis_filter14_FLP( r_LPC, PredCoef, s, length ); break; case 16: - SKP_Silk_LPC_analysis_filter16_FLP( r_LPC, PredCoef, s, length ); + silk_LPC_analysis_filter16_FLP( r_LPC, PredCoef, s, length ); break; default: diff --git a/silk/float/SKP_Silk_LPC_inv_pred_gain_FLP.c b/silk/float/silk_LPC_inv_pred_gain_FLP.c similarity index 76% rename from silk/float/SKP_Silk_LPC_inv_pred_gain_FLP.c rename to silk/float/silk_LPC_inv_pred_gain_FLP.c index 4b2f2f2b..512ae5d8 100644 --- a/silk/float/SKP_Silk_LPC_inv_pred_gain_FLP.c +++ b/silk/float/silk_LPC_inv_pred_gain_FLP.c @@ -25,23 +25,15 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -/* * - * SKP_Silk_LPC_inverse_pred_gain.c * - * * - * compute inverse of LPC prediction gain, and * - * test if LPC coefficients are stable (all poles within unit circle) * - * * - * Copyright 2008 (c), Skype Limited * - * */ -#include "SKP_Silk_SigProc_FIX.h" -#include "SKP_Silk_SigProc_FLP.h" +#include "silk_SigProc_FIX.h" +#include "silk_SigProc_FLP.h" #define RC_THRESHOLD 0.9999f /* compute inverse of LPC prediction gain, and */ /* test if LPC coefficients are stable (all poles within unit circle) */ -/* this code is based on SKP_Silk_a2k_FLP() */ -SKP_int SKP_Silk_LPC_inverse_pred_gain_FLP( /* O: returns 1 if unstable, otherwise 0 */ +/* this code is based on silk_a2k_FLP() */ +SKP_int silk_LPC_inverse_pred_gain_FLP( /* O: returns 1 if unstable, otherwise 0 */ SKP_float *invGain, /* O: inverse prediction gain, energy domain */ const SKP_float *A, /* I: prediction coefficients [order] */ SKP_int32 order /* I: prediction order */ @@ -49,7 +41,7 @@ SKP_int SKP_Silk_LPC_inverse_pred_gain_FLP( /* O: returns 1 if unstable, oth { SKP_int k, n; double rc, rc_mult1, rc_mult2; - SKP_float Atmp[ 2 ][ SKP_Silk_MAX_ORDER_LPC ]; + SKP_float Atmp[ 2 ][ SILK_MAX_ORDER_LPC ]; SKP_float *Aold, *Anew; Anew = Atmp[ order & 1 ]; diff --git a/silk/float/SKP_Silk_LTP_analysis_filter_FLP.c b/silk/float/silk_LTP_analysis_filter_FLP.c similarity index 96% rename from silk/float/SKP_Silk_LTP_analysis_filter_FLP.c rename to silk/float/silk_LTP_analysis_filter_FLP.c index b27b08d4..3bf61691 100644 --- a/silk/float/SKP_Silk_LTP_analysis_filter_FLP.c +++ b/silk/float/silk_LTP_analysis_filter_FLP.c @@ -25,9 +25,9 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FLP.h" +#include "silk_main_FLP.h" -void SKP_Silk_LTP_analysis_filter_FLP( +void silk_LTP_analysis_filter_FLP( SKP_float *LTP_res, /* O LTP res MAX_NB_SUBFR*(pre_lgth+subfr_lngth) */ const SKP_float *x, /* I Input signal, with preceeding samples */ const SKP_float B[ LTP_ORDER * MAX_NB_SUBFR ], /* I LTP coefficients for each subframe */ diff --git a/silk/float/SKP_Silk_LTP_scale_ctrl_FLP.c b/silk/float/silk_LTP_scale_ctrl_FLP.c similarity index 83% rename from silk/float/SKP_Silk_LTP_scale_ctrl_FLP.c rename to silk/float/silk_LTP_scale_ctrl_FLP.c index 4d9345d9..437c5249 100644 --- a/silk/float/SKP_Silk_LTP_scale_ctrl_FLP.c +++ b/silk/float/silk_LTP_scale_ctrl_FLP.c @@ -25,11 +25,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FLP.h" +#include "silk_main_FLP.h" -void SKP_Silk_LTP_scale_ctrl_FLP( - SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - SKP_Silk_encoder_control_FLP *psEncCtrl /* I/O Encoder control FLP */ +void silk_LTP_scale_ctrl_FLP( + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + silk_encoder_control_FLP *psEncCtrl /* I/O Encoder control FLP */ ) { SKP_int round_loss; @@ -41,12 +41,12 @@ void SKP_Silk_LTP_scale_ctrl_FLP( psEnc->prevLTPredCodGain = psEncCtrl->LTPredCodGain; /* Only scale if first frame in packet */ - if( psEnc->sCmn.nFramesAnalyzed == 0 ) { + if( psEnc->sCmn.nFramesEncoded == 0 ) { round_loss = psEnc->sCmn.PacketLoss_perc + psEnc->sCmn.nFramesPerPacket; psEnc->sCmn.indices.LTP_scaleIndex = (SKP_int8)SKP_LIMIT( round_loss * psEnc->HPLTPredCodGain * 0.1f, 0.0f, 2.0f ); } else { /* Default is minimum scaling */ psEnc->sCmn.indices.LTP_scaleIndex = 0; } - psEncCtrl->LTP_scale = (SKP_float)SKP_Silk_LTPScales_table_Q14[ psEnc->sCmn.indices.LTP_scaleIndex ] / 16384.0f; + psEncCtrl->LTP_scale = (SKP_float)silk_LTPScales_table_Q14[ psEnc->sCmn.indices.LTP_scaleIndex ] / 16384.0f; } diff --git a/silk/float/SKP_Silk_SigProc_FLP.h b/silk/float/silk_SigProc_FLP.h similarity index 84% rename from silk/float/SKP_Silk_SigProc_FLP.h rename to silk/float/silk_SigProc_FLP.h index 97067bd1..b20bcfd4 100644 --- a/silk/float/SKP_Silk_SigProc_FLP.h +++ b/silk/float/silk_SigProc_FLP.h @@ -25,12 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ +#ifndef _SILK_SIGPROC_FLP_H_ +#define _SILK_SIGPROC_FLP_H_ -#ifndef _SKP_SILK_SIGPROC_FLP_H_ -#define _SKP_SILK_SIGPROC_FLP_H_ - -#include "SKP_Silk_SigProc_FIX.h" -#include "float_cast.h" +#include "silk_SigProc_FIX.h" #include #ifdef __cplusplus @@ -43,7 +41,7 @@ extern "C" /********************************************************************/ /* Chirp (bw expand) LP AR filter */ -void SKP_Silk_bwexpander_FLP( +void silk_bwexpander_FLP( SKP_float *ar, /* io AR filter to be expanded (without leading 1) */ const SKP_int d, /* i length of ar */ const SKP_float chirp /* i chirp factor (typically in range (0..1) ) */ @@ -51,34 +49,34 @@ void SKP_Silk_bwexpander_FLP( /* compute inverse of LPC prediction gain, and */ /* test if LPC coefficients are stable (all poles within unit circle) */ -/* this code is based on SKP_Silk_FLP_a2k() */ -SKP_int SKP_Silk_LPC_inverse_pred_gain_FLP( /* O: returns 1 if unstable, otherwise 0 */ +/* this code is based on silk_FLP_a2k() */ +SKP_int silk_LPC_inverse_pred_gain_FLP( /* O: returns 1 if unstable, otherwise 0 */ SKP_float *invGain, /* O: inverse prediction gain, energy domain */ const SKP_float *A, /* I: prediction coefficients [order] */ SKP_int32 order /* I: prediction order */ ); -SKP_float SKP_Silk_schur_FLP( /* O returns residual energy */ +SKP_float silk_schur_FLP( /* O returns residual energy */ SKP_float refl_coef[], /* O reflection coefficients (length order) */ const SKP_float auto_corr[], /* I autocorrelation sequence (length order+1) */ SKP_int order /* I order */ ); -void SKP_Silk_k2a_FLP( +void silk_k2a_FLP( SKP_float *A, /* O: prediction coefficients [order] */ const SKP_float *rc, /* I: reflection coefficients [order] */ SKP_int32 order /* I: prediction order */ ); /* Solve the normal equations using the Levinson-Durbin recursion */ -SKP_float SKP_Silk_levinsondurbin_FLP( /* O prediction error energy */ +SKP_float silk_levinsondurbin_FLP( /* O prediction error energy */ SKP_float A[], /* O prediction coefficients [order] */ const SKP_float corr[], /* I input auto-correlations [order + 1] */ const SKP_int order /* I prediction order */ ); /* compute autocorrelation */ -void SKP_Silk_autocorrelation_FLP( +void silk_autocorrelation_FLP( SKP_float *results, /* o result (length correlationCount) */ const SKP_float *inputData, /* i input data to correlate */ SKP_int inputDataSize, /* i length of input */ @@ -90,7 +88,7 @@ void SKP_Silk_autocorrelation_FLP( #define SigProc_PE_MID_COMPLEX 1 #define SigProc_PE_MAX_COMPLEX 2 -SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoiced */ +SKP_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoiced */ const SKP_float *signal, /* I signal of length PE_FRAME_LENGTH_MS*Fs_kHz */ SKP_int *pitch_out, /* O 4 pitch lag values */ SKP_int16 *lagIndex, /* O lag Index */ @@ -106,15 +104,15 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv #define PI (3.1415926536f) -void SKP_Silk_insertion_sort_decreasing_FLP( +void silk_insertion_sort_decreasing_FLP( SKP_float *a, /* I/O: Unsorted / Sorted vector */ - SKP_int *index, /* O: Index vector for the sorted elements */ + SKP_int *idx, /* O: Index vector for the sorted elements */ const SKP_int L, /* I: Vector length */ const SKP_int K /* I: Number of correctly sorted positions */ ); /* Compute reflection coefficients from input signal */ -SKP_float SKP_Silk_burg_modified_FLP( /* O returns residual energy */ +SKP_float silk_burg_modified_FLP( /* O returns residual energy */ SKP_float A[], /* O prediction coefficients (length order) */ const SKP_float x[], /* I input signal, length: nb_subfr*(D+L_sub) */ const SKP_int subfr_length, /* I input signal subframe length (including D preceeding samples) */ @@ -124,14 +122,14 @@ SKP_float SKP_Silk_burg_modified_FLP( /* O returns residual energy ); /* multiply a vector by a constant */ -void SKP_Silk_scale_vector_FLP( +void silk_scale_vector_FLP( SKP_float *data1, SKP_float gain, SKP_int dataSize ); /* copy and multiply a vector by a constant */ -void SKP_Silk_scale_copy_vector_FLP( +void silk_scale_copy_vector_FLP( SKP_float *data_out, const SKP_float *data_in, SKP_float gain, @@ -139,14 +137,14 @@ void SKP_Silk_scale_copy_vector_FLP( ); /* inner product of two SKP_float arrays, with result as double */ -double SKP_Silk_inner_product_FLP( +double silk_inner_product_FLP( const SKP_float *data1, const SKP_float *data2, SKP_int dataSize ); /* sum of squares of a SKP_float array, with result as double */ -double SKP_Silk_energy_FLP( +double silk_energy_FLP( const SKP_float *data, SKP_int dataSize ); @@ -169,16 +167,15 @@ SKP_INLINE SKP_float SKP_sigmoid(SKP_float x) } /* floating-point to integer conversion (rounding) */ -#if 1 -/* use implementation in float_cast.h */ -#define SKP_float2int(x) float2int(x) -#else -SKP_INLINE SKP_int32 SKP_float2int(SKP_float x) +SKP_INLINE SKP_int32 SKP_float2int(double x) { - double y = x; - return (SKP_int32)( ( y > 0 ) ? y + 0.5 : y - 0.5 ); -} +#ifdef _WIN32 + double t = x + 6755399441055744.0; + return *((SKP_int32 *)( &t )); +#else + return (SKP_int32)( ( x > 0 ) ? x + 0.5 : x - 0.5 ); #endif +} /* floating-point to integer conversion (rounding) */ SKP_INLINE void SKP_float2short_array( @@ -189,7 +186,13 @@ SKP_INLINE void SKP_float2short_array( { SKP_int32 k; for (k = length-1; k >= 0; k--) { - out[k] = (SKP_int16)SKP_SAT16( float2int( in[k] ) ); +#ifdef _WIN32 + double t = in[k] + 6755399441055744.0; + out[k] = (SKP_int16)SKP_SAT16(*(( SKP_int32 * )( &t ))); +#else + double x = in[k]; + out[k] = (SKP_int16)SKP_SAT16( ( x > 0 ) ? x + 0.5 : x - 0.5 ); +#endif } } @@ -206,7 +209,8 @@ SKP_INLINE void SKP_short2float_array( } } -#define SKP_round(x) (SKP_float)((x)>=0 ? (SKP_int64)((x)+0.5) : (SKP_int64)((x)-0.5)) +/* using log2() helps the fixed-point conversion */ +SKP_INLINE SKP_float silk_log2( double x ) { return ( SKP_float )( 3.32192809488736 * log10( x ) ); } #ifdef __cplusplus } diff --git a/silk/float/SKP_Silk_apply_sine_window_FLP.c b/silk/float/silk_apply_sine_window_FLP.c similarity index 96% rename from silk/float/SKP_Silk_apply_sine_window_FLP.c rename to silk/float/silk_apply_sine_window_FLP.c index 1db6b147..450be05c 100644 --- a/silk/float/SKP_Silk_apply_sine_window_FLP.c +++ b/silk/float/silk_apply_sine_window_FLP.c @@ -25,13 +25,13 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FLP.h" +#include "silk_main_FLP.h" /* Apply sine window to signal vector. */ /* Window types: */ /* 1 -> sine window from 0 to pi/2 */ /* 2 -> sine window from pi/2 to pi */ -void SKP_Silk_apply_sine_window_FLP( +void silk_apply_sine_window_FLP( SKP_float px_win[], /* O Pointer to windowed signal */ const SKP_float px[], /* I Pointer to input signal */ const SKP_int win_type, /* I Selects a window type */ diff --git a/silk/float/SKP_Silk_autocorrelation_FLP.c b/silk/float/silk_autocorrelation_FLP.c similarity index 90% rename from silk/float/SKP_Silk_autocorrelation_FLP.c rename to silk/float/silk_autocorrelation_FLP.c index 2fa56b49..7cbf8711 100644 --- a/silk/float/SKP_Silk_autocorrelation_FLP.c +++ b/silk/float/silk_autocorrelation_FLP.c @@ -25,11 +25,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_typedef.h" -#include "SKP_Silk_SigProc_FLP.h" +#include "silk_typedef.h" +#include "silk_SigProc_FLP.h" /* compute autocorrelation */ -void SKP_Silk_autocorrelation_FLP( +void silk_autocorrelation_FLP( SKP_float *results, /* O result (length correlationCount) */ const SKP_float *inputData, /* I input data to correlate */ SKP_int inputDataSize, /* I length of input */ @@ -43,6 +43,6 @@ void SKP_Silk_autocorrelation_FLP( } for( i = 0; i < correlationCount; i++ ) { - results[ i ] = (SKP_float)SKP_Silk_inner_product_FLP( inputData, inputData + i, inputDataSize - i ); + results[ i ] = (SKP_float)silk_inner_product_FLP( inputData, inputData + i, inputDataSize - i ); } } diff --git a/silk/float/SKP_Silk_burg_modified_FLP.c b/silk/float/silk_burg_modified_FLP.c similarity index 80% rename from silk/float/SKP_Silk_burg_modified_FLP.c rename to silk/float/silk_burg_modified_FLP.c index 5b44c724..563216a7 100644 --- a/silk/float/SKP_Silk_burg_modified_FLP.c +++ b/silk/float/silk_burg_modified_FLP.c @@ -25,23 +25,13 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -/* * - * SKP_Silk_burg_modified.c * - * * - * Calculates the reflection coefficients from the input vector * - * Input vector contains nb_subfr sub vectors of length L_sub + D * - * * - * Copyright 2009 (c), Skype Limited * - * Date: 091130 * - */ - -#include "SKP_Silk_SigProc_FLP.h" +#include "silk_SigProc_FLP.h" #define MAX_FRAME_SIZE 384 // subfr_length * nb_subfr = ( 0.005 * 16000 + 16 ) * 4 = 384 #define MAX_NB_SUBFR 4 /* Compute reflection coefficients from input signal */ -SKP_float SKP_Silk_burg_modified_FLP( /* O returns residual energy */ +SKP_float silk_burg_modified_FLP( /* O returns residual energy */ SKP_float A[], /* O prediction coefficients (length order) */ const SKP_float x[], /* I input signal, length: nb_subfr*(D+L_sub) */ const SKP_int subfr_length, /* I input signal subframe length (including D preceeding samples) */ @@ -53,23 +43,23 @@ SKP_float SKP_Silk_burg_modified_FLP( /* O returns residual energy SKP_int k, n, s; double C0, num, nrg_f, nrg_b, rc, Atmp, tmp1, tmp2; const SKP_float *x_ptr; - double C_first_row[ SKP_Silk_MAX_ORDER_LPC ], C_last_row[ SKP_Silk_MAX_ORDER_LPC ]; - double CAf[ SKP_Silk_MAX_ORDER_LPC + 1 ], CAb[ SKP_Silk_MAX_ORDER_LPC + 1 ]; - double Af[ SKP_Silk_MAX_ORDER_LPC ]; + double C_first_row[ SILK_MAX_ORDER_LPC ], C_last_row[ SILK_MAX_ORDER_LPC ]; + double CAf[ SILK_MAX_ORDER_LPC + 1 ], CAb[ SILK_MAX_ORDER_LPC + 1 ]; + double Af[ SILK_MAX_ORDER_LPC ]; SKP_assert( subfr_length * nb_subfr <= MAX_FRAME_SIZE ); SKP_assert( nb_subfr <= MAX_NB_SUBFR ); /* Compute autocorrelations, added over subframes */ - C0 = SKP_Silk_energy_FLP( x, nb_subfr * subfr_length ); - SKP_memset( C_first_row, 0, SKP_Silk_MAX_ORDER_LPC * sizeof( double ) ); + C0 = silk_energy_FLP( x, nb_subfr * subfr_length ); + SKP_memset( C_first_row, 0, SILK_MAX_ORDER_LPC * sizeof( double ) ); for( s = 0; s < nb_subfr; s++ ) { x_ptr = x + s * subfr_length; for( n = 1; n < D + 1; n++ ) { - C_first_row[ n - 1 ] += SKP_Silk_inner_product_FLP( x_ptr, x_ptr + n, subfr_length - n ); + C_first_row[ n - 1 ] += silk_inner_product_FLP( x_ptr, x_ptr + n, subfr_length - n ); } } - SKP_memcpy( C_last_row, C_first_row, SKP_Silk_MAX_ORDER_LPC * sizeof( double ) ); + SKP_memcpy( C_last_row, C_first_row, SILK_MAX_ORDER_LPC * sizeof( double ) ); /* Initialize */ CAb[ 0 ] = CAf[ 0 ] = C0 + WhiteNoiseFrac * C0 + 1e-9f; diff --git a/silk/float/SKP_Silk_bwexpander_FLP.c b/silk/float/silk_bwexpander_FLP.c similarity index 95% rename from silk/float/SKP_Silk_bwexpander_FLP.c rename to silk/float/silk_bwexpander_FLP.c index 3cf18090..d97328e1 100644 --- a/silk/float/SKP_Silk_bwexpander_FLP.c +++ b/silk/float/silk_bwexpander_FLP.c @@ -26,11 +26,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_SigProc_FLP.h" +#include "silk_SigProc_FLP.h" /* Chirp (bw expand) LP AR filter */ -void SKP_Silk_bwexpander_FLP( +void silk_bwexpander_FLP( SKP_float *ar, /* I/O AR filter to be expanded (without leading 1) */ const SKP_int d, /* I length of ar */ const SKP_float chirp /* I chirp factor (typically in range (0..1) ) */ diff --git a/silk/float/SKP_Silk_corrMatrix_FLP.c b/silk/float/silk_corrMatrix_FLP.c similarity index 92% rename from silk/float/SKP_Silk_corrMatrix_FLP.c rename to silk/float/silk_corrMatrix_FLP.c index 0fdaabd0..4a259719 100644 --- a/silk/float/SKP_Silk_corrMatrix_FLP.c +++ b/silk/float/silk_corrMatrix_FLP.c @@ -29,10 +29,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * Correlation matrix computations for LS estimate. **********************************************************************/ -#include "SKP_Silk_main_FLP.h" +#include "silk_main_FLP.h" /* Calculates correlation vector X'*t */ -void SKP_Silk_corrVector_FLP( +void silk_corrVector_FLP( const SKP_float *x, /* I x vector [L+order-1] used to create X */ const SKP_float *t, /* I Target vector [L] */ const SKP_int L, /* I Length of vecors */ @@ -46,13 +46,13 @@ void SKP_Silk_corrVector_FLP( ptr1 = &x[ Order - 1 ]; /* Points to first sample of column 0 of X: X[:,0] */ for( lag = 0; lag < Order; lag++ ) { /* Calculate X[:,lag]'*t */ - Xt[ lag ] = (SKP_float)SKP_Silk_inner_product_FLP( ptr1, t, L ); + Xt[ lag ] = (SKP_float)silk_inner_product_FLP( ptr1, t, L ); ptr1--; /* Next column of X */ } } /* Calculates correlation matrix X'*X */ -void SKP_Silk_corrMatrix_FLP( +void silk_corrMatrix_FLP( const SKP_float *x, /* I x vector [ L+order-1 ] used to create X */ const SKP_int L, /* I Length of vectors */ const SKP_int Order, /* I Max lag for correlation */ @@ -64,7 +64,7 @@ void SKP_Silk_corrMatrix_FLP( const SKP_float *ptr1, *ptr2; ptr1 = &x[ Order - 1 ]; /* First sample of column 0 of X */ - energy = SKP_Silk_energy_FLP( ptr1, L ); /* X[:,0]'*X[:,0] */ + energy = silk_energy_FLP( ptr1, L ); /* X[:,0]'*X[:,0] */ matrix_ptr( XX, 0, 0, Order ) = ( SKP_float )energy; for( j = 1; j < Order; j++ ) { /* Calculate X[:,j]'*X[:,j] */ @@ -75,7 +75,7 @@ void SKP_Silk_corrMatrix_FLP( ptr2 = &x[ Order - 2 ]; /* First sample of column 1 of X */ for( lag = 1; lag < Order; lag++ ) { /* Calculate X[:,0]'*X[:,lag] */ - energy = SKP_Silk_inner_product_FLP( ptr1, ptr2, L ); + energy = silk_inner_product_FLP( ptr1, ptr2, L ); matrix_ptr( XX, lag, 0, Order ) = ( SKP_float )energy; matrix_ptr( XX, 0, lag, Order ) = ( SKP_float )energy; /* Calculate X[:,j]'*X[:,j + lag] */ diff --git a/silk/float/SKP_Silk_encode_frame_FLP.c b/silk/float/silk_encode_frame_FLP.c similarity index 78% rename from silk/float/SKP_Silk_encode_frame_FLP.c rename to silk/float/silk_encode_frame_FLP.c index 0a9fc0c5..d18f22b0 100644 --- a/silk/float/SKP_Silk_encode_frame_FLP.c +++ b/silk/float/silk_encode_frame_FLP.c @@ -25,22 +25,21 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FLP.h" -#include "SKP_Silk_tuning_parameters.h" +#include "silk_main_FLP.h" +#include "silk_tuning_parameters.h" /****************/ /* Encode frame */ /****************/ -SKP_int SKP_Silk_encode_frame_FLP( - SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ +SKP_int silk_encode_frame_FLP( + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ SKP_int32 *pnBytesOut, /* O Number of payload bytes */ ec_enc *psRangeEnc /* I/O compressor data structure */ ) { - SKP_Silk_encoder_control_FLP sEncCtrl; + silk_encoder_control_FLP sEncCtrl; SKP_int i, ret = 0; SKP_float *x_frame, *res_pitch_frame; - SKP_int16 pIn_HP[ MAX_FRAME_LENGTH ]; SKP_float xfw[ MAX_FRAME_LENGTH ]; SKP_float res_pitch[ 2 * MAX_FRAME_LENGTH + LA_PITCH_MAX ]; @@ -59,16 +58,16 @@ TIC(ENCODE_FRAME) /* Voice Activity Detection */ /****************************/ TIC(VAD) - ret = SKP_Silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf ); + ret = silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf - 1 ); TOC(VAD) /**************************************************/ /* Convert speech activity into VAD and DTX flags */ /**************************************************/ - if( psEnc->sCmn.nFramesAnalyzed == 0 ) { + if( psEnc->sCmn.nFramesEncoded == 0 ) { psEnc->sCmn.inDTX = psEnc->sCmn.useDTX; } - if( psEnc->sCmn.speech_activity_Q8 < SKP_FIX_CONST( SPEECH_ACTIVITY_DTX_THRES, 8 ) ) { + if( psEnc->sCmn.speech_activity_Q8 < SILK_FIX_CONST( SPEECH_ACTIVITY_DTX_THRES, 8 ) ) { psEnc->sCmn.indices.signalType = TYPE_NO_VOICE_ACTIVITY; psEnc->sCmn.noSpeechCounter++; if( psEnc->sCmn.noSpeechCounter < NB_SPEECH_FRAMES_BEFORE_DTX ) { @@ -77,28 +76,23 @@ TOC(VAD) psEnc->sCmn.noSpeechCounter = NB_SPEECH_FRAMES_BEFORE_DTX; psEnc->sCmn.inDTX = 0; } - psEnc->sCmn.VAD_flags[ psEnc->sCmn.nFramesAnalyzed ] = 0; + psEnc->sCmn.VAD_flags[ psEnc->sCmn.nFramesEncoded ] = 0; } else { psEnc->sCmn.noSpeechCounter = 0; psEnc->sCmn.inDTX = 0; psEnc->sCmn.indices.signalType = TYPE_UNVOICED; - psEnc->sCmn.VAD_flags[ psEnc->sCmn.nFramesAnalyzed ] = 1; + psEnc->sCmn.VAD_flags[ psEnc->sCmn.nFramesEncoded ] = 1; } - /*******************************************/ - /* High-pass filtering of the input signal */ - /*******************************************/ -TIC(HP_IN) - SKP_Silk_HP_variable_cutoff( &psEnc->sCmn, pIn_HP, psEnc->sCmn.inputBuf, psEnc->sCmn.frame_length ); -TOC(HP_IN) - + /***************************************/ /* Ensure smooth bandwidth transitions */ - SKP_Silk_LP_variable_cutoff( &psEnc->sCmn.sLP, pIn_HP, psEnc->sCmn.frame_length ); + /***************************************/ + silk_LP_variable_cutoff( &psEnc->sCmn.sLP, psEnc->sCmn.inputBuf - 1, psEnc->sCmn.frame_length ); /*******************************************/ /* Copy new frame to front of input buffer */ /*******************************************/ - SKP_short2float_array( x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, pIn_HP, psEnc->sCmn.frame_length ); + SKP_short2float_array( x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, psEnc->sCmn.inputBuf - 1, psEnc->sCmn.frame_length ); /* Add tiny signal to avoid high CPU load from denormalized floating point numbers */ for( i = 0; i < 8; i++ ) { @@ -109,49 +103,49 @@ TOC(HP_IN) /* Find pitch lags, initial LPC analysis */ /*****************************************/ TIC(FIND_PITCH) - SKP_Silk_find_pitch_lags_FLP( psEnc, &sEncCtrl, res_pitch, x_frame ); + silk_find_pitch_lags_FLP( psEnc, &sEncCtrl, res_pitch, x_frame ); TOC(FIND_PITCH) /************************/ /* Noise shape analysis */ /************************/ TIC(NOISE_SHAPE_ANALYSIS) - SKP_Silk_noise_shape_analysis_FLP( psEnc, &sEncCtrl, res_pitch_frame, x_frame ); + silk_noise_shape_analysis_FLP( psEnc, &sEncCtrl, res_pitch_frame, x_frame ); TOC(NOISE_SHAPE_ANALYSIS) /***************************************************/ /* Find linear prediction coefficients (LPC + LTP) */ /***************************************************/ TIC(FIND_PRED_COEF) - SKP_Silk_find_pred_coefs_FLP( psEnc, &sEncCtrl, res_pitch, x_frame ); + silk_find_pred_coefs_FLP( psEnc, &sEncCtrl, res_pitch, x_frame ); TOC(FIND_PRED_COEF) /****************************************/ /* Process gains */ /****************************************/ TIC(PROCESS_GAINS) - SKP_Silk_process_gains_FLP( psEnc, &sEncCtrl ); + silk_process_gains_FLP( psEnc, &sEncCtrl ); TOC(PROCESS_GAINS) - /****************************************/ - /* Low Bitrate Redundant Encoding */ - /****************************************/ -TIC(LBRR) - SKP_Silk_LBRR_encode_FLP( psEnc, &sEncCtrl, xfw ); -TOC(LBRR) - /*****************************************/ /* Prefiltering for noise shaper */ /*****************************************/ TIC(PREFILTER) - SKP_Silk_prefilter_FLP( psEnc, &sEncCtrl, xfw, x_frame ); + silk_prefilter_FLP( psEnc, &sEncCtrl, xfw, x_frame ); TOC(PREFILTER) + /****************************************/ + /* Low Bitrate Redundant Encoding */ + /****************************************/ +TIC(LBRR) + silk_LBRR_encode_FLP( psEnc, &sEncCtrl, xfw ); +TOC(LBRR) + /*****************************************/ /* Noise shaping quantization */ /*****************************************/ TIC(NSQ) - SKP_Silk_NSQ_wrapper_FLP( psEnc, &sEncCtrl, &psEnc->sCmn.indices, &psEnc->sCmn.sNSQ, psEnc->sCmn.pulses, xfw ); + silk_NSQ_wrapper_FLP( psEnc, &sEncCtrl, &psEnc->sCmn.indices, &psEnc->sCmn.sNSQ, psEnc->sCmn.pulses, xfw ); TOC(NSQ) /* Update input buffer */ @@ -173,14 +167,14 @@ TOC(NSQ) /* Encode Parameters */ /****************************************/ TIC(ENCODE_PARAMS) - SKP_Silk_encode_indices( &psEnc->sCmn, psRangeEnc, psEnc->sCmn.nFramesAnalyzed, 0 ); + silk_encode_indices( &psEnc->sCmn, psRangeEnc, psEnc->sCmn.nFramesEncoded, 0 ); TOC(ENCODE_PARAMS) /****************************************/ /* Encode Excitation Signal */ /****************************************/ TIC(ENCODE_PULSES) - SKP_Silk_encode_pulses( psRangeEnc, psEnc->sCmn.indices.signalType, psEnc->sCmn.indices.quantOffsetType, + silk_encode_pulses( psRangeEnc, psEnc->sCmn.indices.signalType, psEnc->sCmn.indices.quantOffsetType, psEnc->sCmn.pulses, psEnc->sCmn.frame_length ); TOC(ENCODE_PULSES) @@ -188,12 +182,12 @@ TOC(ENCODE_PULSES) /* Finalize payload */ /****************************************/ psEnc->sCmn.first_frame_after_reset = 0; - if( ++psEnc->sCmn.nFramesAnalyzed >= psEnc->sCmn.nFramesPerPacket ) { + if( ++psEnc->sCmn.nFramesEncoded >= psEnc->sCmn.nFramesPerPacket ) { /* Payload size */ *pnBytesOut = SKP_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 ); /* Reset the number of frames in payload buffer */ - psEnc->sCmn.nFramesAnalyzed = 0; + psEnc->sCmn.nFramesEncoded = 0; } else { /* No payload this time */ *pnBytesOut = 0; @@ -222,32 +216,32 @@ TOC(ENCODE_FRAME) } /* Low-Bitrate Redundancy (LBRR) encoding. Reuse all parameters but encode excitation at lower bitrate */ -void SKP_Silk_LBRR_encode_FLP( - SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - SKP_Silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ +void silk_LBRR_encode_FLP( + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ const SKP_float xfw[] /* I Input signal */ ) { SKP_int k; SKP_int32 Gains_Q16[ MAX_NB_SUBFR ]; SKP_float TempGains[ MAX_NB_SUBFR ]; - SideInfoIndices *psIndices_LBRR = &psEnc->sCmn.indices_LBRR[ psEnc->sCmn.nFramesAnalyzed ]; - SKP_Silk_nsq_state sNSQ_LBRR; + SideInfoIndices *psIndices_LBRR = &psEnc->sCmn.indices_LBRR[ psEnc->sCmn.nFramesEncoded ]; + silk_nsq_state sNSQ_LBRR; /*******************************************/ /* Control use of inband LBRR */ /*******************************************/ - if( psEnc->sCmn.LBRR_enabled && psEnc->sCmn.speech_activity_Q8 > SKP_FIX_CONST( LBRR_SPEECH_ACTIVITY_THRES, 8 ) ) { - psEnc->sCmn.LBRR_flags[ psEnc->sCmn.nFramesAnalyzed ] = 1; + if( psEnc->sCmn.LBRR_enabled && psEnc->sCmn.speech_activity_Q8 > SILK_FIX_CONST( LBRR_SPEECH_ACTIVITY_THRES, 8 ) ) { + psEnc->sCmn.LBRR_flags[ psEnc->sCmn.nFramesEncoded ] = 1; /* Copy noise shaping quantizer state and quantization indices from regular encoding */ - SKP_memcpy( &sNSQ_LBRR, &psEnc->sCmn.sNSQ, sizeof( SKP_Silk_nsq_state ) ); + SKP_memcpy( &sNSQ_LBRR, &psEnc->sCmn.sNSQ, sizeof( silk_nsq_state ) ); SKP_memcpy( psIndices_LBRR, &psEnc->sCmn.indices, sizeof( SideInfoIndices ) ); /* Save original gains */ SKP_memcpy( TempGains, psEncCtrl->Gains, psEnc->sCmn.nb_subfr * sizeof( SKP_float ) ); - if( psEnc->sCmn.nFramesAnalyzed == 0 || psEnc->sCmn.LBRR_flags[ psEnc->sCmn.nFramesAnalyzed - 1 ] == 0 ) { + if( psEnc->sCmn.nFramesEncoded == 0 || psEnc->sCmn.LBRR_flags[ psEnc->sCmn.nFramesEncoded - 1 ] == 0 ) { /* First frame in packet or previous frame not LBRR coded */ psEnc->sCmn.LBRRprevLastGainIndex = psEnc->sShape.LastGainIndex; @@ -257,19 +251,19 @@ void SKP_Silk_LBRR_encode_FLP( } /* Decode to get gains in sync with decoder */ - SKP_Silk_gains_dequant( Gains_Q16, psIndices_LBRR->GainsIndices, - &psEnc->sCmn.LBRRprevLastGainIndex, psEnc->sCmn.nFramesAnalyzed, psEnc->sCmn.nb_subfr ); + silk_gains_dequant( Gains_Q16, psIndices_LBRR->GainsIndices, + &psEnc->sCmn.LBRRprevLastGainIndex, psEnc->sCmn.nFramesEncoded, psEnc->sCmn.nb_subfr ); /* Overwrite unquantized gains with quantized gains and convert back to Q0 from Q16 */ for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { - psEncCtrl->Gains[ k ] = Gains_Q16[ k ] / 65536.0f; + psEncCtrl->Gains[ k ] = Gains_Q16[ k ] * ( 1.0f / 65536.0f ); } /*****************************************/ /* Noise shaping quantization */ /*****************************************/ - SKP_Silk_NSQ_wrapper_FLP( psEnc, psEncCtrl, psIndices_LBRR, &sNSQ_LBRR, - psEnc->sCmn.pulses_LBRR[ psEnc->sCmn.nFramesAnalyzed ], xfw ); + silk_NSQ_wrapper_FLP( psEnc, psEncCtrl, psIndices_LBRR, &sNSQ_LBRR, + psEnc->sCmn.pulses_LBRR[ psEnc->sCmn.nFramesEncoded ], xfw ); /* Restore original gains */ SKP_memcpy( psEncCtrl->Gains, TempGains, psEnc->sCmn.nb_subfr * sizeof( SKP_float ) ); diff --git a/silk/float/SKP_Silk_energy_FLP.c b/silk/float/silk_energy_FLP.c similarity index 95% rename from silk/float/SKP_Silk_energy_FLP.c rename to silk/float/silk_energy_FLP.c index 579364d2..87cbb9e3 100644 --- a/silk/float/SKP_Silk_energy_FLP.c +++ b/silk/float/silk_energy_FLP.c @@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_SigProc_FLP.h" +#include "silk_SigProc_FLP.h" /* sum of squares of a SKP_float array, with result as double */ -double SKP_Silk_energy_FLP( +double silk_energy_FLP( const SKP_float *data, SKP_int dataSize ) diff --git a/silk/float/SKP_Silk_find_LPC_FLP.c b/silk/float/silk_find_LPC_FLP.c similarity index 80% rename from silk/float/SKP_Silk_find_LPC_FLP.c rename to silk/float/silk_find_LPC_FLP.c index 88392f39..d0f52953 100644 --- a/silk/float/SKP_Silk_find_LPC_FLP.c +++ b/silk/float/silk_find_LPC_FLP.c @@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FLP.h" -#include "SKP_Silk_tuning_parameters.h" +#include "silk_main_FLP.h" +#include "silk_tuning_parameters.h" -void SKP_Silk_find_LPC_FLP( +void silk_find_LPC_FLP( SKP_int16 NLSF_Q15[], /* O NLSFs */ SKP_int8 *interpIndex, /* O NLSF interp. index for NLSF interp. */ const SKP_int16 prev_NLSFq_Q15[], /* I Previous NLSFs, for NLSF interpolation */ @@ -53,39 +53,39 @@ void SKP_Silk_find_LPC_FLP( *interpIndex = 4; /* Burg AR analysis for the full frame */ - res_nrg = SKP_Silk_burg_modified_FLP( a, x, subfr_length, nb_subfr, FIND_LPC_COND_FAC, LPC_order ); + res_nrg = silk_burg_modified_FLP( a, x, subfr_length, nb_subfr, FIND_LPC_COND_FAC, LPC_order ); if( firstFrameAfterReset ) { - SKP_Silk_bwexpander_FLP( a, LPC_order, FIND_LPC_CHIRP_FIRST_FRAME ); + silk_bwexpander_FLP( a, LPC_order, FIND_LPC_CHIRP_FIRST_FRAME ); } else { - SKP_Silk_bwexpander_FLP( a_tmp, LPC_order, FIND_LPC_CHIRP ); + silk_bwexpander_FLP( a_tmp, LPC_order, FIND_LPC_CHIRP ); } if( useInterpNLSFs && !firstFrameAfterReset && nb_subfr == MAX_NB_SUBFR ) { /* Optimal solution for last 10 ms; subtract residual energy here, as that's easier than */ /* adding it to the residual energy of the first 10 ms in each iteration of the search below */ - res_nrg -= SKP_Silk_burg_modified_FLP( a_tmp, x + ( MAX_NB_SUBFR / 2 ) * subfr_length, + res_nrg -= silk_burg_modified_FLP( a_tmp, x + ( MAX_NB_SUBFR / 2 ) * subfr_length, subfr_length, MAX_NB_SUBFR / 2, FIND_LPC_COND_FAC, LPC_order ); - SKP_Silk_bwexpander_FLP( a_tmp, LPC_order, FIND_LPC_CHIRP ); + silk_bwexpander_FLP( a_tmp, LPC_order, FIND_LPC_CHIRP ); /* Convert to NLSFs */ - SKP_Silk_A2NLSF_FLP( NLSF_Q15, a_tmp, LPC_order ); + silk_A2NLSF_FLP( NLSF_Q15, a_tmp, LPC_order ); /* Search over interpolation indices to find the one with lowest residual energy */ res_nrg_2nd = SKP_float_MAX; for( k = 3; k >= 0; k-- ) { /* Interpolate NLSFs for first half */ - SKP_Silk_interpolate( NLSF0_Q15, prev_NLSFq_Q15, NLSF_Q15, k, LPC_order ); + silk_interpolate( NLSF0_Q15, prev_NLSFq_Q15, NLSF_Q15, k, LPC_order ); /* Convert to LPC for residual energy evaluation */ - SKP_Silk_NLSF2A_stable_FLP( a_tmp, NLSF0_Q15, LPC_order ); + silk_NLSF2A_stable_FLP( a_tmp, NLSF0_Q15, LPC_order ); /* Calculate residual energy with LSF interpolation */ - SKP_Silk_LPC_analysis_filter_FLP( LPC_res, a_tmp, x, 2 * subfr_length, LPC_order ); + silk_LPC_analysis_filter_FLP( LPC_res, a_tmp, x, 2 * subfr_length, LPC_order ); res_nrg_interp = - SKP_Silk_energy_FLP( LPC_res + LPC_order, subfr_length - LPC_order ) + - SKP_Silk_energy_FLP( LPC_res + LPC_order + subfr_length, subfr_length - LPC_order ); + silk_energy_FLP( LPC_res + LPC_order, subfr_length - LPC_order ) + + silk_energy_FLP( LPC_res + LPC_order + subfr_length, subfr_length - LPC_order ); /* Determine whether current interpolated NLSFs are best so far */ if( res_nrg_interp < res_nrg ) { @@ -102,7 +102,7 @@ void SKP_Silk_find_LPC_FLP( if( *interpIndex == 4 ) { /* NLSF interpolation is currently inactive, calculate NLSFs from full frame AR coefficients */ - SKP_Silk_A2NLSF_FLP( NLSF_Q15, a, LPC_order ); + silk_A2NLSF_FLP( NLSF_Q15, a, LPC_order ); } SKP_assert( *interpIndex == 4 || ( useInterpNLSFs && !firstFrameAfterReset && nb_subfr == MAX_NB_SUBFR ) ); diff --git a/silk/float/SKP_Silk_find_LTP_FLP.c b/silk/float/silk_find_LTP_FLP.c similarity index 85% rename from silk/float/SKP_Silk_find_LTP_FLP.c rename to silk/float/silk_find_LTP_FLP.c index 7daf5fbb..e8fe1e77 100644 --- a/silk/float/SKP_Silk_find_LTP_FLP.c +++ b/silk/float/silk_find_LTP_FLP.c @@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FLP.h" -#include "SKP_Silk_tuning_parameters.h" +#include "silk_main_FLP.h" +#include "silk_tuning_parameters.h" -void SKP_Silk_find_LTP_FLP( +void silk_find_LTP_FLP( SKP_float b[ MAX_NB_SUBFR * LTP_ORDER ], /* O LTP coefs */ SKP_float WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */ SKP_float *LTPredCodGain, /* O LTP coding gain */ @@ -54,22 +54,22 @@ void SKP_Silk_find_LTP_FLP( for( k = 0; k < nb_subfr; k++ ) { lag_ptr = r_ptr - ( lag[ k ] + LTP_ORDER / 2 ); - SKP_Silk_corrMatrix_FLP( lag_ptr, subfr_length, LTP_ORDER, WLTP_ptr ); - SKP_Silk_corrVector_FLP( lag_ptr, r_ptr, subfr_length, LTP_ORDER, Rr ); + silk_corrMatrix_FLP( lag_ptr, subfr_length, LTP_ORDER, WLTP_ptr ); + silk_corrVector_FLP( lag_ptr, r_ptr, subfr_length, LTP_ORDER, Rr ); - rr[ k ] = ( SKP_float )SKP_Silk_energy_FLP( r_ptr, subfr_length ); + rr[ k ] = ( SKP_float )silk_energy_FLP( r_ptr, subfr_length ); regu = 1.0f + rr[ k ] + matrix_ptr( WLTP_ptr, 0, 0, LTP_ORDER ) + matrix_ptr( WLTP_ptr, LTP_ORDER-1, LTP_ORDER-1, LTP_ORDER ); regu *= LTP_DAMPING / 3; - SKP_Silk_regularize_correlations_FLP( WLTP_ptr, &rr[ k ], regu, LTP_ORDER ); - SKP_Silk_solve_LDL_FLP( WLTP_ptr, LTP_ORDER, Rr, b_ptr ); + silk_regularize_correlations_FLP( WLTP_ptr, &rr[ k ], regu, LTP_ORDER ); + silk_solve_LDL_FLP( WLTP_ptr, LTP_ORDER, Rr, b_ptr ); /* Calculate residual energy */ - nrg[ k ] = SKP_Silk_residual_energy_covar_FLP( b_ptr, WLTP_ptr, Rr, rr[ k ], LTP_ORDER ); + nrg[ k ] = silk_residual_energy_covar_FLP( b_ptr, WLTP_ptr, Rr, rr[ k ], LTP_ORDER ); temp = Wght[ k ] / ( nrg[ k ] * Wght[ k ] + 0.01f * subfr_length ); - SKP_Silk_scale_vector_FLP( WLTP_ptr, temp, LTP_ORDER * LTP_ORDER ); + silk_scale_vector_FLP( WLTP_ptr, temp, LTP_ORDER * LTP_ORDER ); w[ k ] = matrix_ptr( WLTP_ptr, LTP_ORDER / 2, LTP_ORDER / 2, LTP_ORDER ); r_ptr += subfr_length; @@ -87,7 +87,7 @@ void SKP_Silk_find_LTP_FLP( } SKP_assert( LPC_LTP_res_nrg > 0 ); - *LTPredCodGain = 3.0f * SKP_Silk_log2( LPC_res_nrg / LPC_LTP_res_nrg ); + *LTPredCodGain = 3.0f * silk_log2( LPC_res_nrg / LPC_LTP_res_nrg ); } /* Smoothing */ diff --git a/silk/float/SKP_Silk_find_pitch_lags_FLP.c b/silk/float/silk_find_pitch_lags_FLP.c similarity index 82% rename from silk/float/SKP_Silk_find_pitch_lags_FLP.c rename to silk/float/silk_find_pitch_lags_FLP.c index c8de0e26..8f213ca7 100644 --- a/silk/float/SKP_Silk_find_pitch_lags_FLP.c +++ b/silk/float/silk_find_pitch_lags_FLP.c @@ -26,12 +26,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ #include -#include "SKP_Silk_main_FLP.h" -#include "SKP_Silk_tuning_parameters.h" +#include "silk_main_FLP.h" +#include "silk_tuning_parameters.h" -void SKP_Silk_find_pitch_lags_FLP( - SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - SKP_Silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ +void silk_find_pitch_lags_FLP( + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ SKP_float res[], /* O Residual */ const SKP_float x[] /* I Speech signal */ ) @@ -64,7 +64,7 @@ void SKP_Silk_find_pitch_lags_FLP( /* First LA_LTP samples */ x_buf_ptr = x_buf + buf_len - psEnc->sCmn.pitch_LPC_win_length; Wsig_ptr = Wsig; - SKP_Silk_apply_sine_window_FLP( Wsig_ptr, x_buf_ptr, 1, psEnc->sCmn.la_pitch ); + silk_apply_sine_window_FLP( Wsig_ptr, x_buf_ptr, 1, psEnc->sCmn.la_pitch ); /* Middle non-windowed samples */ Wsig_ptr += psEnc->sCmn.la_pitch; @@ -74,30 +74,30 @@ void SKP_Silk_find_pitch_lags_FLP( /* Last LA_LTP samples */ Wsig_ptr += psEnc->sCmn.pitch_LPC_win_length - ( psEnc->sCmn.la_pitch << 1 ); x_buf_ptr += psEnc->sCmn.pitch_LPC_win_length - ( psEnc->sCmn.la_pitch << 1 ); - SKP_Silk_apply_sine_window_FLP( Wsig_ptr, x_buf_ptr, 2, psEnc->sCmn.la_pitch ); + silk_apply_sine_window_FLP( Wsig_ptr, x_buf_ptr, 2, psEnc->sCmn.la_pitch ); /* Calculate autocorrelation sequence */ - SKP_Silk_autocorrelation_FLP( auto_corr, Wsig, psEnc->sCmn.pitch_LPC_win_length, psEnc->sCmn.pitchEstimationLPCOrder + 1 ); + silk_autocorrelation_FLP( auto_corr, Wsig, psEnc->sCmn.pitch_LPC_win_length, psEnc->sCmn.pitchEstimationLPCOrder + 1 ); /* Add white noise, as a fraction of the energy */ auto_corr[ 0 ] += auto_corr[ 0 ] * FIND_PITCH_WHITE_NOISE_FRACTION + 1; /* Calculate the reflection coefficients using Schur */ - res_nrg = SKP_Silk_schur_FLP( refl_coef, auto_corr, psEnc->sCmn.pitchEstimationLPCOrder ); + res_nrg = silk_schur_FLP( refl_coef, auto_corr, psEnc->sCmn.pitchEstimationLPCOrder ); /* Prediction gain */ psEncCtrl->predGain = auto_corr[ 0 ] / SKP_max_float( res_nrg, 1.0f ); /* Convert reflection coefficients to prediction coefficients */ - SKP_Silk_k2a_FLP( A, refl_coef, psEnc->sCmn.pitchEstimationLPCOrder ); + silk_k2a_FLP( A, refl_coef, psEnc->sCmn.pitchEstimationLPCOrder ); /* Bandwidth expansion */ - SKP_Silk_bwexpander_FLP( A, psEnc->sCmn.pitchEstimationLPCOrder, FIND_PITCH_BANDWITH_EXPANSION ); + silk_bwexpander_FLP( A, psEnc->sCmn.pitchEstimationLPCOrder, FIND_PITCH_BANDWITH_EXPANSION ); /*****************************************/ /* LPC analysis filtering */ /*****************************************/ - SKP_Silk_LPC_analysis_filter_FLP( res, A, x_buf, buf_len, psEnc->sCmn.pitchEstimationLPCOrder ); + silk_LPC_analysis_filter_FLP( res, A, x_buf, buf_len, psEnc->sCmn.pitchEstimationLPCOrder ); if( psEnc->sCmn.indices.signalType != TYPE_NO_VOICE_ACTIVITY && psEnc->sCmn.first_frame_after_reset == 0 ) { /* Threshold for pitch estimator */ @@ -110,7 +110,7 @@ void SKP_Silk_find_pitch_lags_FLP( /*****************************************/ /* Call Pitch estimator */ /*****************************************/ - if( SKP_Silk_pitch_analysis_core_FLP( res, psEncCtrl->pitchL, &psEnc->sCmn.indices.lagIndex, + if( silk_pitch_analysis_core_FLP( res, psEncCtrl->pitchL, &psEnc->sCmn.indices.lagIndex, &psEnc->sCmn.indices.contourIndex, &psEnc->LTPCorr, psEnc->sCmn.prevLag, psEnc->sCmn.pitchEstimationThreshold_Q16 / 65536.0f, thrhld, psEnc->sCmn.fs_kHz, psEnc->sCmn.pitchEstimationComplexity, psEnc->sCmn.nb_subfr ) == 0 ) { diff --git a/silk/float/SKP_Silk_find_pred_coefs_FLP.c b/silk/float/silk_find_pred_coefs_FLP.c similarity index 82% rename from silk/float/SKP_Silk_find_pred_coefs_FLP.c rename to silk/float/silk_find_pred_coefs_FLP.c index 4224402f..200c78c5 100644 --- a/silk/float/SKP_Silk_find_pred_coefs_FLP.c +++ b/silk/float/silk_find_pred_coefs_FLP.c @@ -25,12 +25,12 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FLP.h" +#include "silk_main_FLP.h" -void SKP_Silk_find_pred_coefs_FLP( - SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - SKP_Silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ +void silk_find_pred_coefs_FLP( + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ const SKP_float res_pitch[], /* I Residual from pitch analysis */ const SKP_float x[] /* I Speech signal */ ) @@ -56,7 +56,7 @@ void SKP_Silk_find_pred_coefs_FLP( SKP_assert( psEnc->sCmn.ltp_mem_length - psEnc->sCmn.predictLPCOrder >= psEncCtrl->pitchL[ 0 ] + LTP_ORDER / 2 ); /* LTP analysis */ - SKP_Silk_find_LTP_FLP( psEncCtrl->LTPCoef, WLTP, &psEncCtrl->LTPredCodGain, res_pitch, + silk_find_LTP_FLP( psEncCtrl->LTPCoef, WLTP, &psEncCtrl->LTPredCodGain, res_pitch, psEncCtrl->pitchL, Wght, psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.ltp_mem_length ); #ifdef SAVE_ALL_INTERNAL_DATA @@ -65,14 +65,14 @@ void SKP_Silk_find_pred_coefs_FLP( #endif /* Quantize LTP gain parameters */ - SKP_Silk_quant_LTP_gains_FLP( psEncCtrl->LTPCoef, psEnc->sCmn.indices.LTPIndex, &psEnc->sCmn.indices.PERIndex, + silk_quant_LTP_gains_FLP( psEncCtrl->LTPCoef, psEnc->sCmn.indices.LTPIndex, &psEnc->sCmn.indices.PERIndex, WLTP, psEnc->sCmn.mu_LTP_Q9, psEnc->sCmn.LTPQuantLowComplexity, psEnc->sCmn.nb_subfr ); /* Control LTP scaling */ - SKP_Silk_LTP_scale_ctrl_FLP( psEnc, psEncCtrl ); + silk_LTP_scale_ctrl_FLP( psEnc, psEncCtrl ); /* Create LTP residual */ - SKP_Silk_LTP_analysis_filter_FLP( LPC_in_pre, x - psEnc->sCmn.predictLPCOrder, psEncCtrl->LTPCoef, + silk_LTP_analysis_filter_FLP( LPC_in_pre, x - psEnc->sCmn.predictLPCOrder, psEncCtrl->LTPCoef, psEncCtrl->pitchL, invGains, psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.predictLPCOrder ); } else { @@ -83,7 +83,7 @@ void SKP_Silk_find_pred_coefs_FLP( x_ptr = x - psEnc->sCmn.predictLPCOrder; x_pre_ptr = LPC_in_pre; for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { - SKP_Silk_scale_copy_vector_FLP( x_pre_ptr, x_ptr, invGains[ i ], + silk_scale_copy_vector_FLP( x_pre_ptr, x_ptr, invGains[ i ], psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder ); x_pre_ptr += psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder; x_ptr += psEnc->sCmn.subfr_length; @@ -94,17 +94,17 @@ void SKP_Silk_find_pred_coefs_FLP( } /* LPC_in_pre contains the LTP-filtered input for voiced, and the unfiltered input for unvoiced */ - SKP_Silk_find_LPC_FLP( NLSF_Q15, &psEnc->sCmn.indices.NLSFInterpCoef_Q2, psEnc->sCmn.prev_NLSFq_Q15, + silk_find_LPC_FLP( NLSF_Q15, &psEnc->sCmn.indices.NLSFInterpCoef_Q2, psEnc->sCmn.prev_NLSFq_Q15, psEnc->sCmn.useInterpolatedNLSFs, psEnc->sCmn.first_frame_after_reset, psEnc->sCmn.predictLPCOrder, LPC_in_pre, psEnc->sCmn.subfr_length + psEnc->sCmn.predictLPCOrder, psEnc->sCmn.nb_subfr ); /* Quantize LSFs */ TIC(LSF_quant); - SKP_Silk_process_NLSFs_FLP( &psEnc->sCmn, psEncCtrl->PredCoef, NLSF_Q15, psEnc->sCmn.prev_NLSFq_Q15 ); + silk_process_NLSFs_FLP( &psEnc->sCmn, psEncCtrl->PredCoef, NLSF_Q15, psEnc->sCmn.prev_NLSFq_Q15 ); TOC(LSF_quant); /* Calculate residual energy using quantized LPC coefficients */ - SKP_Silk_residual_energy_FLP( psEncCtrl->ResNrg, LPC_in_pre, psEncCtrl->PredCoef, psEncCtrl->Gains, + silk_residual_energy_FLP( psEncCtrl->ResNrg, LPC_in_pre, psEncCtrl->PredCoef, psEncCtrl->Gains, psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr, psEnc->sCmn.predictLPCOrder ); /* Copy to prediction struct for use in next frame for fluctuation reduction */ diff --git a/silk/float/silk_float.vcxproj b/silk/float/silk_float.vcxproj index 313ba68c..8a6c9862 100644 --- a/silk/float/silk_float.vcxproj +++ b/silk/float/silk_float.vcxproj @@ -86,43 +86,43 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + diff --git a/silk/float/silk_float.vcxproj.filters b/silk/float/silk_float.vcxproj.filters index 8c6efb0c..debd97d9 100644 --- a/silk/float/silk_float.vcxproj.filters +++ b/silk/float/silk_float.vcxproj.filters @@ -18,112 +18,112 @@ - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - - Header Files - - - Header Files - - - Header Files - Header Files + + Header Files + + + Header Files + + + Header Files + \ No newline at end of file diff --git a/silk/float/SKP_Silk_inner_product_FLP.c b/silk/float/silk_inner_product_FLP.c similarity index 94% rename from silk/float/SKP_Silk_inner_product_FLP.c rename to silk/float/silk_inner_product_FLP.c index d9012941..80ad1f5d 100644 --- a/silk/float/SKP_Silk_inner_product_FLP.c +++ b/silk/float/silk_inner_product_FLP.c @@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_SigProc_FLP.h" +#include "silk_SigProc_FLP.h" /* inner product of two SKP_float arrays, with result as double */ -double SKP_Silk_inner_product_FLP( /* O result */ +double silk_inner_product_FLP( /* O result */ const SKP_float *data1, /* I vector 1 */ const SKP_float *data2, /* I vector 2 */ SKP_int dataSize /* I length of vectors */ diff --git a/silk/float/SKP_Silk_k2a_FLP.c b/silk/float/silk_k2a_FLP.c similarity index 74% rename from silk/float/SKP_Silk_k2a_FLP.c rename to silk/float/silk_k2a_FLP.c index d6d4b165..8aec7da7 100644 --- a/silk/float/SKP_Silk_k2a_FLP.c +++ b/silk/float/silk_k2a_FLP.c @@ -25,26 +25,17 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -/* * - * SKP_Silk_k2a.c * - * * - * step up function, converts reflection coefficients to prediction * - * coefficients * - * * - * Copyright 2008 (c), Skype Limited * - * Date: 080103 * - * */ -#include "SKP_Silk_SigProc_FLP.h" +#include "silk_SigProc_FLP.h" /* step up function, converts reflection coefficients to prediction coefficients */ -void SKP_Silk_k2a_FLP( +void silk_k2a_FLP( SKP_float *A, /* O: prediction coefficients [order] */ const SKP_float *rc, /* I: reflection coefficients [order] */ SKP_int32 order /* I: prediction order */ ) { SKP_int k, n; - SKP_float Atmp[ SKP_Silk_MAX_ORDER_LPC ]; + SKP_float Atmp[ SILK_MAX_ORDER_LPC ]; for( k = 0; k < order; k++ ){ for( n = 0; n < k; n++ ){ diff --git a/silk/float/SKP_Silk_levinsondurbin_FLP.c b/silk/float/silk_levinsondurbin_FLP.c similarity index 93% rename from silk/float/SKP_Silk_levinsondurbin_FLP.c rename to silk/float/silk_levinsondurbin_FLP.c index 6b09f02d..b58a48a3 100644 --- a/silk/float/SKP_Silk_levinsondurbin_FLP.c +++ b/silk/float/silk_levinsondurbin_FLP.c @@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_SigProc_FLP.h" +#include "silk_SigProc_FLP.h" /* Solve the normal equations using the Levinson-Durbin recursion */ -SKP_float SKP_Silk_levinsondurbin_FLP( /* O prediction error energy */ +SKP_float silk_levinsondurbin_FLP( /* O prediction error energy */ SKP_float A[], /* O prediction coefficients [order] */ const SKP_float corr[], /* I input auto-correlations [order + 1] */ const SKP_int order /* I prediction order */ diff --git a/silk/float/SKP_Silk_main_FLP.h b/silk/float/silk_main_FLP.h similarity index 83% rename from silk/float/SKP_Silk_main_FLP.h rename to silk/float/silk_main_FLP.h index faa20c87..5d03f0c2 100644 --- a/silk/float/SKP_Silk_main_FLP.h +++ b/silk/float/silk_main_FLP.h @@ -25,15 +25,15 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#ifndef SKP_SILK_MAIN_FLP_H -#define SKP_SILK_MAIN_FLP_H +#ifndef SILK_MAIN_FLP_H +#define SILK_MAIN_FLP_H -#include "SKP_Silk_SigProc_FLP.h" -#include "SKP_Silk_SigProc_FIX.h" -#include "SKP_Silk_structs_FLP.h" -#include "SKP_Silk_main.h" -#include "SKP_Silk_define.h" -#include "SKP_debug.h" +#include "silk_SigProc_FLP.h" +#include "silk_SigProc_FIX.h" +#include "silk_structs_FLP.h" +#include "silk_main.h" +#include "silk_define.h" +#include "silk_debug.h" #include "entenc.h" #ifdef __cplusplus @@ -41,33 +41,42 @@ extern "C" { #endif +#define silk_encoder_state_Fxx silk_encoder_state_FLP +#define silk_encode_frame_Fxx silk_encode_frame_FLP + /*********************/ /* Encoder Functions */ /*********************/ +/* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */ +void silk_HP_variable_cutoff( + silk_encoder_state_Fxx state_Fxx[], /* I/O Encoder states */ + const SKP_int nChannels /* I Number of channels */ +); + /* Encoder main function */ -SKP_int SKP_Silk_encode_frame_FLP( - SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ +SKP_int silk_encode_frame_FLP( + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ SKP_int32 *pnBytesOut, /* O Number of payload bytes; */ - ec_enc *psRangeEnc /* I/O compressor data structure */ + ec_enc *psRangeEnc /* I/O compressor data structure */ ); /* Low Bitrate Redundancy (LBRR) encoding. Reuse all parameters but encode with lower bitrate */ -void SKP_Silk_LBRR_encode_FLP( - SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - SKP_Silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ +void silk_LBRR_encode_FLP( + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ const SKP_float xfw[] /* I Input signal */ ); /* Initializes the Silk encoder state */ -SKP_int SKP_Silk_init_encoder( - SKP_Silk_encoder_state_FLP *psEnc /* I/O Encoder state FLP */ +SKP_int silk_init_encoder( + silk_encoder_state_FLP *psEnc /* I/O Encoder state FLP */ ); /* Control the Silk encoder */ -SKP_int SKP_Silk_control_encoder( - SKP_Silk_encoder_state_FLP *psEnc, /* I/O Pointer to Silk encoder state FLP */ - SKP_SILK_SDK_EncControlStruct *encControl, /* I: Control structure */ +SKP_int silk_control_encoder( + silk_encoder_state_FLP *psEnc, /* I/O Pointer to Silk encoder state FLP */ + silk_EncControlStruct *encControl, /* I: Control structure */ const SKP_int32 TargetRate_bps, /* I Target max bitrate (bps) */ const SKP_int allow_bw_switch, /* I Flag to allow switching audio bandwidth */ const SKP_int channelNb /* I Channel number */ @@ -76,9 +85,9 @@ SKP_int SKP_Silk_control_encoder( /****************/ /* Prefiltering */ /****************/ -void SKP_Silk_prefilter_FLP( - SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - const SKP_Silk_encoder_control_FLP *psEncCtrl, /* I Encoder control FLP */ +void silk_prefilter_FLP( + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + const silk_encoder_control_FLP *psEncCtrl, /* I Encoder control FLP */ SKP_float xw[], /* O Weighted signal */ const SKP_float x[] /* I Speech signal */ ); @@ -87,15 +96,15 @@ void SKP_Silk_prefilter_FLP( /* Noise shaping analysis */ /**************************/ /* Compute noise shaping coefficients and initial gain values */ -void SKP_Silk_noise_shape_analysis_FLP( - SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - SKP_Silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ +void silk_noise_shape_analysis_FLP( + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ const SKP_float *pitch_res, /* I LPC residual from pitch analysis */ const SKP_float *x /* I Input signal [frame_length + la_shape] */ ); /* Autocorrelations for a warped frequency axis */ -void SKP_Silk_warped_autocorrelation_FLP( +void silk_warped_autocorrelation_FLP( SKP_float *corr, /* O Result [order + 1] */ const SKP_float *input, /* I Input data to correlate */ const SKP_float warping, /* I Warping coefficient */ @@ -104,32 +113,32 @@ void SKP_Silk_warped_autocorrelation_FLP( ); /* Calculation of LTP state scaling */ -void SKP_Silk_LTP_scale_ctrl_FLP( - SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - SKP_Silk_encoder_control_FLP *psEncCtrl /* I/O Encoder control FLP */ +void silk_LTP_scale_ctrl_FLP( + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + silk_encoder_control_FLP *psEncCtrl /* I/O Encoder control FLP */ ); /**********************************************/ /* Prediction Analysis */ /**********************************************/ /* Find pitch lags */ -void SKP_Silk_find_pitch_lags_FLP( - SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - SKP_Silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ +void silk_find_pitch_lags_FLP( + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ SKP_float res[], /* O Residual */ const SKP_float x[] /* I Speech signal */ ); /* Find LPC and LTP coefficients */ -void SKP_Silk_find_pred_coefs_FLP( - SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - SKP_Silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ +void silk_find_pred_coefs_FLP( + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ const SKP_float res_pitch[], /* I Residual from pitch analysis */ const SKP_float x[] /* I Speech signal */ ); /* LPC analysis */ -void SKP_Silk_find_LPC_FLP( +void silk_find_LPC_FLP( SKP_int16 NLSF_Q15[], /* O NLSFs */ SKP_int8 *interpIndex, /* O NLSF interp. index for NLSF interp. */ const SKP_int16 prev_NLSFq_Q15[], /* I Previous NLSFs, for NLSF interpolation */ @@ -142,7 +151,7 @@ void SKP_Silk_find_LPC_FLP( ); /* LTP analysis */ -void SKP_Silk_find_LTP_FLP( +void silk_find_LTP_FLP( SKP_float b[ MAX_NB_SUBFR * LTP_ORDER ], /* O LTP coefs */ SKP_float WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */ SKP_float *LTPredCodGain, /* O LTP coding gain */ @@ -154,7 +163,7 @@ void SKP_Silk_find_LTP_FLP( const SKP_int mem_offset /* I Number of samples in LTP memory */ ); -void SKP_Silk_LTP_analysis_filter_FLP( +void silk_LTP_analysis_filter_FLP( SKP_float *LTP_res, /* O LTP res MAX_NB_SUBFR*(pre_lgth+subfr_lngth) */ const SKP_float *x, /* I Input signal, with preceeding samples */ const SKP_float B[ LTP_ORDER * MAX_NB_SUBFR ], /* I LTP coefficients for each subframe */ @@ -167,10 +176,10 @@ void SKP_Silk_LTP_analysis_filter_FLP( /* Calculates residual energies of input subframes where all subframes have LPC_order */ /* of preceeding samples */ -void SKP_Silk_residual_energy_FLP( +void silk_residual_energy_FLP( SKP_float nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */ const SKP_float x[], /* I Input signal */ - const SKP_float a[ 2 ][ MAX_LPC_ORDER ],/* I AR coefs for each frame half */ + SKP_float a[ 2 ][ MAX_LPC_ORDER ],/* I AR coefs for each frame half */ const SKP_float gains[], /* I Quantization gains */ const SKP_int subfr_length, /* I Subframe length */ const SKP_int nb_subfr, /* I number of subframes */ @@ -178,7 +187,7 @@ void SKP_Silk_residual_energy_FLP( ); /* 16th order LPC analysis filter */ -void SKP_Silk_LPC_analysis_filter_FLP( +void silk_LPC_analysis_filter_FLP( SKP_float r_LPC[], /* O LPC residual signal */ const SKP_float PredCoef[], /* I LPC coefficients */ const SKP_float s[], /* I Input signal */ @@ -187,7 +196,7 @@ void SKP_Silk_LPC_analysis_filter_FLP( ); /* LTP tap quantizer */ -void SKP_Silk_quant_LTP_gains_FLP( +void silk_quant_LTP_gains_FLP( SKP_float B[ MAX_NB_SUBFR * LTP_ORDER ], /* I/O (Un-)quantized LTP gains */ SKP_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook index */ SKP_int8 *periodicity_index, /* O Periodicity index */ @@ -201,15 +210,15 @@ void SKP_Silk_quant_LTP_gains_FLP( /* NLSF Quantizer */ /******************/ /* Limit, stabilize, and quantize NLSFs */ -void SKP_Silk_process_NLSFs_FLP( - SKP_Silk_encoder_state *psEncC, /* I/O Encoder state */ +void silk_process_NLSFs_FLP( + silk_encoder_state *psEncC, /* I/O Encoder state */ SKP_float PredCoef[ 2 ][ MAX_LPC_ORDER ], /* O Prediction coefficients */ SKP_int16 NLSF_Q15[ MAX_LPC_ORDER ], /* I/O Normalized LSFs (quant out) (0 - (2^15-1)) */ const SKP_int16 prev_NLSF_Q15[ MAX_LPC_ORDER ] /* I Previous Normalized LSFs (0 - (2^15-1)) */ ); /* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */ -SKP_float SKP_Silk_residual_energy_covar_FLP( /* O Weighted residual energy */ +SKP_float silk_residual_energy_covar_FLP( /* O Weighted residual energy */ const SKP_float *c, /* I Filter coefficients */ SKP_float *wXX, /* I/O Weighted correlation matrix, reg. out */ const SKP_float *wXx, /* I Weighted correlation vector */ @@ -218,7 +227,7 @@ SKP_float SKP_Silk_residual_energy_covar_FLP( /* O Weighted residua ); /* Entropy constrained MATRIX-weighted VQ, for a single input data vector */ -void SKP_Silk_VQ_WMat_EC_FLP( +void silk_VQ_WMat_EC_FLP( SKP_int *ind, /* O Index of best codebook vector */ SKP_float *rate_dist, /* O Best weighted quant. error + mu * rate */ const SKP_float *in, /* I Input vector to be quantized */ @@ -230,16 +239,16 @@ void SKP_Silk_VQ_WMat_EC_FLP( ); /* Processing of gains */ -void SKP_Silk_process_gains_FLP( - SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - SKP_Silk_encoder_control_FLP *psEncCtrl /* I/O Encoder control FLP */ +void silk_process_gains_FLP( + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + silk_encoder_control_FLP *psEncCtrl /* I/O Encoder control FLP */ ); /******************/ /* Linear Algebra */ /******************/ /* Calculates correlation matrix X'*X */ -void SKP_Silk_corrMatrix_FLP( +void silk_corrMatrix_FLP( const SKP_float *x, /* I x vector [ L+order-1 ] used to create X */ const SKP_int L, /* I Length of vectors */ const SKP_int Order, /* I Max lag for correlation */ @@ -247,7 +256,7 @@ void SKP_Silk_corrMatrix_FLP( ); /* Calculates correlation vector X'*t */ -void SKP_Silk_corrVector_FLP( +void silk_corrVector_FLP( const SKP_float *x, /* I x vector [L+order-1] used to create X */ const SKP_float *t, /* I Target vector [L] */ const SKP_int L, /* I Length of vecors */ @@ -256,7 +265,7 @@ void SKP_Silk_corrVector_FLP( ); /* Add noise to matrix diagonal */ -void SKP_Silk_regularize_correlations_FLP( +void silk_regularize_correlations_FLP( SKP_float *XX, /* I/O Correlation matrices */ SKP_float *xx, /* I/O Correlation values */ const SKP_float noise, /* I Noise energy to add */ @@ -264,7 +273,7 @@ void SKP_Silk_regularize_correlations_FLP( ); /* Function to solve linear equation Ax = b, where A is an MxM symmetric matrix */ -void SKP_Silk_solve_LDL_FLP( +void silk_solve_LDL_FLP( SKP_float *A, /* I/O Symmetric square matrix, out: reg. */ const SKP_int M, /* I Size of matrix */ const SKP_float *b, /* I Pointer to b vector */ @@ -275,7 +284,7 @@ void SKP_Silk_solve_LDL_FLP( /* Window types: */ /* 1 -> sine window from 0 to pi/2 */ /* 2 -> sine window from pi/2 to pi */ -void SKP_Silk_apply_sine_window_FLP( +void silk_apply_sine_window_FLP( SKP_float px_win[], /* O Pointer to windowed signal */ const SKP_float px[], /* I Pointer to input signal */ const SKP_int win_type, /* I Selects a window type */ @@ -285,14 +294,14 @@ void SKP_Silk_apply_sine_window_FLP( /* Wrappers. Calls flp / fix code */ /* Convert AR filter coefficients to NLSF parameters */ -void SKP_Silk_A2NLSF_FLP( +void silk_A2NLSF_FLP( SKP_int16 *NLSF_Q15, /* O NLSF vector [ LPC_order ] */ const SKP_float *pAR, /* I LPC coefficients [ LPC_order ] */ const SKP_int LPC_order /* I LPC order */ ); /* Convert NLSF parameters to AR prediction filter coefficients */ -void SKP_Silk_NLSF2A_stable_FLP( +void silk_NLSF2A_stable_FLP( SKP_float *pAR, /* O LPC coefficients [ LPC_order ] */ const SKP_int16 *NLSF_Q15, /* I NLSF vector [ LPC_order ] */ const SKP_int LPC_order /* I LPC order */ @@ -301,18 +310,15 @@ void SKP_Silk_NLSF2A_stable_FLP( /****************************************/ /* Floating-point Silk NSQ wrapper */ /****************************************/ -void SKP_Silk_NSQ_wrapper_FLP( - SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - SKP_Silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ +void silk_NSQ_wrapper_FLP( + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ SideInfoIndices *psIndices, /* I/O Quantization indices */ - SKP_Silk_nsq_state *psNSQ, /* I/O Noise Shaping Quantzation state */ + silk_nsq_state *psNSQ, /* I/O Noise Shaping Quantzation state */ SKP_int8 pulses[], /* O Quantized pulse signal */ const SKP_float x[] /* I Prefiltered input signal */ ); -/* using log2() helps the fixed-point conversion */ -SKP_INLINE SKP_float SKP_Silk_log2( double x ) { return ( SKP_float )( 3.32192809488736 * log10( x ) ); } - #ifdef __cplusplus } #endif diff --git a/silk/float/SKP_Silk_noise_shape_analysis_FLP.c b/silk/float/silk_noise_shape_analysis_FLP.c similarity index 89% rename from silk/float/SKP_Silk_noise_shape_analysis_FLP.c rename to silk/float/silk_noise_shape_analysis_FLP.c index 05f98fa8..4ff41c66 100644 --- a/silk/float/SKP_Silk_noise_shape_analysis_FLP.c +++ b/silk/float/silk_noise_shape_analysis_FLP.c @@ -25,8 +25,8 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FLP.h" -#include "SKP_Silk_tuning_parameters.h" +#include "silk_main_FLP.h" +#include "silk_tuning_parameters.h" /* Compute gain to make warped filter coefficients have a zero mean log frequency response on a */ /* non-warped frequency scale. (So that it can be implemented with a minimum-phase monic filter.) */ @@ -100,8 +100,8 @@ SKP_INLINE void warped_true2monic_coefs( /* Apply bandwidth expansion */ chirp = 0.99f - ( 0.8f + 0.1f * iter ) * ( maxabs - limit ) / ( maxabs * ( ind + 1 ) ); - SKP_Silk_bwexpander_FLP( coefs_syn, order, chirp ); - SKP_Silk_bwexpander_FLP( coefs_ana, order, chirp ); + silk_bwexpander_FLP( coefs_syn, order, chirp ); + silk_bwexpander_FLP( coefs_ana, order, chirp ); /* Convert to monic warped coefficients */ for( i = order - 1; i > 0; i-- ) { @@ -119,14 +119,14 @@ SKP_INLINE void warped_true2monic_coefs( } /* Compute noise shaping coefficients and initial gain values */ -void SKP_Silk_noise_shape_analysis_FLP( - SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - SKP_Silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ +void silk_noise_shape_analysis_FLP( + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ const SKP_float *pitch_res, /* I LPC residual from pitch analysis */ const SKP_float *x /* I Input signal [frame_length + la_shape] */ ) { - SKP_Silk_shape_state_FLP *psShapeSt = &psEnc->sShape; + silk_shape_state_FLP *psShapeSt = &psEnc->sShape; SKP_int k, nSamples; SKP_float SNR_adj_dB, HarmBoost, HarmShapeGain, Tilt; SKP_float nrg, pre_nrg, log_energy, log_energy_prev, energy_variation; @@ -178,8 +178,8 @@ void SKP_Silk_noise_shape_analysis_FLP( log_energy_prev = 0.0f; pitch_res_ptr = pitch_res; for( k = 0; k < SKP_SMULBB( SUB_FRAME_LENGTH_MS, psEnc->sCmn.nb_subfr ) / 2; k++ ) { - nrg = ( SKP_float )nSamples + ( SKP_float )SKP_Silk_energy_FLP( pitch_res_ptr, nSamples ); - log_energy = SKP_Silk_log2( nrg ); + nrg = ( SKP_float )nSamples + ( SKP_float )silk_energy_FLP( pitch_res_ptr, nSamples ); + log_energy = silk_log2( nrg ); if( k > 0 ) { energy_variation += SKP_abs_float( log_energy - log_energy_prev ); } @@ -227,29 +227,29 @@ void SKP_Silk_noise_shape_analysis_FLP( flat_part = psEnc->sCmn.fs_kHz * 3; slope_part = ( psEnc->sCmn.shapeWinLength - flat_part ) / 2; - SKP_Silk_apply_sine_window_FLP( x_windowed, x_ptr, 1, slope_part ); + silk_apply_sine_window_FLP( x_windowed, x_ptr, 1, slope_part ); shift = slope_part; SKP_memcpy( x_windowed + shift, x_ptr + shift, flat_part * sizeof(SKP_float) ); shift += flat_part; - SKP_Silk_apply_sine_window_FLP( x_windowed + shift, x_ptr + shift, 2, slope_part ); + silk_apply_sine_window_FLP( x_windowed + shift, x_ptr + shift, 2, slope_part ); /* Update pointer: next LPC analysis block */ x_ptr += psEnc->sCmn.subfr_length; if( psEnc->sCmn.warping_Q16 > 0 ) { /* Calculate warped auto correlation */ - SKP_Silk_warped_autocorrelation_FLP( auto_corr, x_windowed, warping, + silk_warped_autocorrelation_FLP( auto_corr, x_windowed, warping, psEnc->sCmn.shapeWinLength, psEnc->sCmn.shapingLPCOrder ); } else { /* Calculate regular auto correlation */ - SKP_Silk_autocorrelation_FLP( auto_corr, x_windowed, psEnc->sCmn.shapeWinLength, psEnc->sCmn.shapingLPCOrder + 1 ); + silk_autocorrelation_FLP( auto_corr, x_windowed, psEnc->sCmn.shapeWinLength, psEnc->sCmn.shapingLPCOrder + 1 ); } /* Add white noise, as a fraction of energy */ auto_corr[ 0 ] += auto_corr[ 0 ] * SHAPE_WHITE_NOISE_FRACTION; /* Convert correlations to prediction coefficients, and compute residual energy */ - nrg = SKP_Silk_levinsondurbin_FLP( &psEncCtrl->AR2[ k * MAX_SHAPE_LPC_ORDER ], auto_corr, psEnc->sCmn.shapingLPCOrder ); + nrg = silk_levinsondurbin_FLP( &psEncCtrl->AR2[ k * MAX_SHAPE_LPC_ORDER ], auto_corr, psEnc->sCmn.shapingLPCOrder ); psEncCtrl->Gains[ k ] = ( SKP_float )sqrt( nrg ); if( psEnc->sCmn.warping_Q16 > 0 ) { @@ -258,7 +258,7 @@ void SKP_Silk_noise_shape_analysis_FLP( } /* Bandwidth expansion for synthesis filter shaping */ - SKP_Silk_bwexpander_FLP( &psEncCtrl->AR2[ k * MAX_SHAPE_LPC_ORDER ], psEnc->sCmn.shapingLPCOrder, BWExp2 ); + silk_bwexpander_FLP( &psEncCtrl->AR2[ k * MAX_SHAPE_LPC_ORDER ], psEnc->sCmn.shapingLPCOrder, BWExp2 ); /* Compute noise shaping filter coefficients */ SKP_memcpy( @@ -267,11 +267,11 @@ void SKP_Silk_noise_shape_analysis_FLP( psEnc->sCmn.shapingLPCOrder * sizeof( SKP_float ) ); /* Bandwidth expansion for analysis filter shaping */ - SKP_Silk_bwexpander_FLP( &psEncCtrl->AR1[ k * MAX_SHAPE_LPC_ORDER ], psEnc->sCmn.shapingLPCOrder, BWExp1 ); + silk_bwexpander_FLP( &psEncCtrl->AR1[ k * MAX_SHAPE_LPC_ORDER ], psEnc->sCmn.shapingLPCOrder, BWExp1 ); /* Ratio of prediction gains, in energy domain */ - SKP_Silk_LPC_inverse_pred_gain_FLP( &pre_nrg, &psEncCtrl->AR2[ k * MAX_SHAPE_LPC_ORDER ], psEnc->sCmn.shapingLPCOrder ); - SKP_Silk_LPC_inverse_pred_gain_FLP( &nrg, &psEncCtrl->AR1[ k * MAX_SHAPE_LPC_ORDER ], psEnc->sCmn.shapingLPCOrder ); + silk_LPC_inverse_pred_gain_FLP( &pre_nrg, &psEncCtrl->AR2[ k * MAX_SHAPE_LPC_ORDER ], psEnc->sCmn.shapingLPCOrder ); + silk_LPC_inverse_pred_gain_FLP( &nrg, &psEncCtrl->AR1[ k * MAX_SHAPE_LPC_ORDER ], psEnc->sCmn.shapingLPCOrder ); psEncCtrl->GainsPre[ k ] = 1.0f - 0.7f * ( 1.0f - pre_nrg / nrg ); /* Convert to monic warped prediction coefficients and limit absolute values */ diff --git a/silk/float/SKP_Silk_pitch_analysis_core_FLP.c b/silk/float/silk_pitch_analysis_core_FLP.c similarity index 87% rename from silk/float/SKP_Silk_pitch_analysis_core_FLP.c rename to silk/float/silk_pitch_analysis_core_FLP.c index 244754c3..abcdfe27 100644 --- a/silk/float/SKP_Silk_pitch_analysis_core_FLP.c +++ b/silk/float/silk_pitch_analysis_core_FLP.c @@ -30,9 +30,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * Pitch analyser function * ******************************************************************************/ -#include "SKP_Silk_SigProc_FLP.h" -#include "SKP_Silk_SigProc_FIX.h" -#include "SKP_Silk_pitch_est_defines.h" +#include "silk_SigProc_FLP.h" +#include "silk_SigProc_FIX.h" +#include "silk_pitch_est_defines.h" #define SCRATCH_SIZE 22 @@ -41,13 +41,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /************************************************************/ #define eps 1.192092896e-07f -/* using log2() helps the fixed-point conversion */ -SKP_INLINE SKP_float SKP_P_log2(double x) { return (SKP_float)(3.32192809488736 * log10(x)); } - /************************************************************/ /* Internally used functions */ /************************************************************/ -static void SKP_P_Ana_calc_corr_st3( +static void silk_P_Ana_calc_corr_st3( SKP_float cross_corr_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ], /* O 3 DIM correlation array */ const SKP_float signal[], /* I vector to correlate */ SKP_int start_lag, /* I start lag */ @@ -56,7 +53,7 @@ static void SKP_P_Ana_calc_corr_st3( SKP_int complexity /* I Complexity setting */ ); -static void SKP_P_Ana_calc_energy_st3( +static void silk_P_Ana_calc_energy_st3( SKP_float energies_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ], /* O 3 DIM correlation array */ const SKP_float signal[], /* I vector to correlate */ SKP_int start_lag, /* I start lag */ @@ -68,7 +65,7 @@ static void SKP_P_Ana_calc_energy_st3( //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //% CORE PITCH ANALYSIS FUNCTION % //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoiced */ +SKP_int silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unvoiced */ const SKP_float *signal, /* I signal of length PE_FRAME_LENGTH_MS*Fs_kHz */ SKP_int *pitch_out, /* O 4 pitch lag values */ SKP_int16 *lagIndex, /* O lag Index */ @@ -142,14 +139,14 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv SKP_int16 signal_16_FIX[ 16 * PE_MAX_FRAME_LENGTH_MS ]; SKP_float2short_array( signal_16_FIX, signal, frame_length ); SKP_memset( filt_state, 0, 2 * sizeof( SKP_int32 ) ); - SKP_Silk_resampler_down2( filt_state, signal_8_FIX, signal_16_FIX, frame_length ); + silk_resampler_down2( filt_state, signal_8_FIX, signal_16_FIX, frame_length ); SKP_short2float_array( signal_8kHz, signal_8_FIX, frame_length_8kHz ); } else if( Fs_kHz == 12 ) { /* Resample to 12 -> 8 khz */ SKP_int16 signal_12_FIX[ 12 * PE_MAX_FRAME_LENGTH_MS ]; SKP_float2short_array( signal_12_FIX, signal, frame_length ); SKP_memset( filt_state, 0, 6 * sizeof( SKP_int32 ) ); - SKP_Silk_resampler_down2_3( filt_state, signal_8_FIX, signal_12_FIX, frame_length ); + silk_resampler_down2_3( filt_state, signal_8_FIX, signal_12_FIX, frame_length ); SKP_short2float_array( signal_8kHz, signal_8_FIX, frame_length_8kHz ); } else { SKP_assert( Fs_kHz == 8 ); @@ -158,7 +155,7 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv /* Decimate again to 4 kHz */ SKP_memset( filt_state, 0, 2 * sizeof( SKP_int32 ) ); - SKP_Silk_resampler_down2( filt_state, signal_4_FIX, signal_8_FIX, frame_length_8kHz ); + silk_resampler_down2( filt_state, signal_4_FIX, signal_8_FIX, frame_length_8kHz ); SKP_short2float_array( signal_4kHz, signal_4_FIX, frame_length_4kHz ); /* Low-pass filter */ @@ -182,8 +179,8 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv SKP_assert( basis_ptr + sf_length_8kHz <= signal_4kHz + frame_length_4kHz ); /* Calculate first vector products before loop */ - cross_corr = SKP_Silk_inner_product_FLP( target_ptr, basis_ptr, sf_length_8kHz ); - normalizer = SKP_Silk_energy_FLP( basis_ptr, sf_length_8kHz ) + sf_length_8kHz * 4000.0f; + cross_corr = silk_inner_product_FLP( target_ptr, basis_ptr, sf_length_8kHz ); + normalizer = silk_energy_FLP( basis_ptr, sf_length_8kHz ) + sf_length_8kHz * 4000.0f; C[ 0 ][ min_lag_4kHz ] += (SKP_float)(cross_corr / sqrt(normalizer)); @@ -195,7 +192,7 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv SKP_assert( basis_ptr >= signal_4kHz ); SKP_assert( basis_ptr + sf_length_8kHz <= signal_4kHz + frame_length_4kHz ); - cross_corr = SKP_Silk_inner_product_FLP(target_ptr, basis_ptr, sf_length_8kHz); + cross_corr = silk_inner_product_FLP(target_ptr, basis_ptr, sf_length_8kHz); /* Add contribution of new sample and remove contribution from oldest sample */ normalizer += @@ -215,7 +212,7 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv /* Sort */ length_d_srch = 4 + 2 * complexity; SKP_assert( 3 * length_d_srch <= PE_D_SRCH_LENGTH ); - SKP_Silk_insertion_sort_decreasing_FLP( &C[ 0 ][ min_lag_4kHz ], d_srch, max_lag_4kHz - min_lag_4kHz + 1, length_d_srch ); + silk_insertion_sort_decreasing_FLP( &C[ 0 ][ min_lag_4kHz ], d_srch, max_lag_4kHz - min_lag_4kHz + 1, length_d_srch ); /* Escape if correlation is very low already here */ Cmax = C[ 0 ][ min_lag_4kHz ]; @@ -273,7 +270,7 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv length_d_comp = 0; for( i = min_lag_8kHz; i < max_lag_8kHz + 4; i++ ) { if( d_comp[ i ] > 0 ) { - d_comp[ length_d_comp ] = i - 2; + d_comp[ length_d_comp ] = (SKP_int16)( i - 2 ); length_d_comp++; } } @@ -292,12 +289,12 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv target_ptr = &signal_8kHz[ PE_LTP_MEM_LENGTH_MS * 8 ]; } for( k = 0; k < nb_subfr; k++ ) { - energy_tmp = SKP_Silk_energy_FLP( target_ptr, sf_length_8kHz ); + energy_tmp = silk_energy_FLP( target_ptr, sf_length_8kHz ); for( j = 0; j < length_d_comp; j++ ) { d = d_comp[ j ]; basis_ptr = target_ptr - d; - cross_corr = SKP_Silk_inner_product_FLP( basis_ptr, target_ptr, sf_length_8kHz ); - energy = SKP_Silk_energy_FLP( basis_ptr, sf_length_8kHz ); + cross_corr = silk_inner_product_FLP( basis_ptr, target_ptr, sf_length_8kHz ); + energy = silk_energy_FLP( basis_ptr, sf_length_8kHz ); if (cross_corr > 0.0f) { C[ k ][ d ] = (SKP_float)(cross_corr * cross_corr / (energy * energy_tmp + eps)); } else { @@ -322,7 +319,7 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv } else if( Fs_kHz == 16 ) { prevLag = SKP_RSHIFT( prevLag, 1 ); } - prevLag_log2 = SKP_P_log2((SKP_float)prevLag); + prevLag_log2 = silk_log2((SKP_float)prevLag); } else { prevLag_log2 = 0; } @@ -330,7 +327,7 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv /* Setup stage 2 codebook based on number of subframes */ if( nb_subfr == PE_MAX_NB_SUBFR ) { cbk_size = PE_NB_CBKS_STAGE2_EXT; - Lag_CB_ptr = &SKP_Silk_CB_lags_stage2[ 0 ][ 0 ]; + Lag_CB_ptr = &silk_CB_lags_stage2[ 0 ][ 0 ]; if( Fs_kHz == 8 && complexity > SigProc_PE_MIN_COMPLEX ) { /* If input is 8 khz use a larger codebook here because it is last stage */ nb_cbk_search = PE_NB_CBKS_STAGE2_EXT; @@ -339,7 +336,7 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv } } else { cbk_size = PE_NB_CBKS_STAGE2_10MS; - Lag_CB_ptr = &SKP_Silk_CB_lags_stage2_10_ms[ 0 ][ 0 ]; + Lag_CB_ptr = &silk_CB_lags_stage2_10_ms[ 0 ][ 0 ]; nb_cbk_search = PE_NB_CBKS_STAGE2_10MS; } @@ -365,7 +362,7 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv CCmax_new_b = CCmax_new; /* Bias towards shorter lags */ - lag_log2 = SKP_P_log2((SKP_float)d); + lag_log2 = silk_log2((SKP_float)d); CCmax_new_b -= PE_SHORTLAG_BIAS * nb_subfr * lag_log2; /* Bias towards previous lag */ @@ -377,7 +374,7 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv if ( CCmax_new_b > CCmax_b && /* Find maximum biased correlation */ CCmax_new > nb_subfr * search_thres2 * search_thres2 && /* Correlation needs to be high enough to be voiced */ - SKP_Silk_CB_lags_stage2[ 0 ][ CBimax_new ] <= min_lag_8kHz /* Lag must be in range */ + silk_CB_lags_stage2[ 0 ][ CBimax_new ] <= min_lag_8kHz /* Lag must be in range */ ) { CCmax_b = CCmax_new_b; CCmax = CCmax_new; @@ -419,8 +416,8 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv CCmax = -1000.0f; /* Calculate the correlations and energies needed in stage 3 */ - SKP_P_Ana_calc_corr_st3( cross_corr_st3, signal, start_lag, sf_length, nb_subfr, complexity ); - SKP_P_Ana_calc_energy_st3( energies_st3, signal, start_lag, sf_length, nb_subfr, complexity ); + silk_P_Ana_calc_corr_st3( cross_corr_st3, signal, start_lag, sf_length, nb_subfr, complexity ); + silk_P_Ana_calc_energy_st3( energies_st3, signal, start_lag, sf_length, nb_subfr, complexity ); lag_counter = 0; SKP_assert( lag == SKP_SAT16( lag ) ); @@ -428,13 +425,13 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv /* Setup cbk parameters acording to complexity setting and frame length */ if( nb_subfr == PE_MAX_NB_SUBFR ) { - nb_cbk_search = (SKP_int)SKP_Silk_nb_cbk_searchs_stage3[ complexity ]; + nb_cbk_search = (SKP_int)silk_nb_cbk_searchs_stage3[ complexity ]; cbk_size = PE_NB_CBKS_STAGE3_MAX; - Lag_CB_ptr = &SKP_Silk_CB_lags_stage3[ 0 ][ 0 ]; + Lag_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ]; } else { nb_cbk_search = PE_NB_CBKS_STAGE3_10MS; cbk_size = PE_NB_CBKS_STAGE3_10MS; - Lag_CB_ptr = &SKP_Silk_CB_lags_stage3_10_ms[ 0 ][ 0 ]; + Lag_CB_ptr = &silk_CB_lags_stage3_10_ms[ 0 ][ 0 ]; } for( d = start_lag; d <= end_lag; d++ ) { @@ -454,7 +451,7 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv } if( CCmax_new > CCmax && - ( d + (SKP_int)SKP_Silk_CB_lags_stage3[ 0 ][ j ] ) <= max_lag + ( d + (SKP_int)silk_CB_lags_stage3[ 0 ][ j ] ) <= max_lag ) { CCmax = CCmax_new; lag_new = d; @@ -484,7 +481,7 @@ SKP_int SKP_Silk_pitch_analysis_core_FLP( /* O voicing estimate: 0 voiced, 1 unv return 0; } -static void SKP_P_Ana_calc_corr_st3( +static void silk_P_Ana_calc_corr_st3( SKP_float cross_corr_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ], /* O 3 DIM correlation array */ const SKP_float signal[], /* I vector to correlate */ SKP_int start_lag, /* I start lag */ @@ -516,14 +513,14 @@ static void SKP_P_Ana_calc_corr_st3( SKP_assert( complexity <= SigProc_PE_MAX_COMPLEX ); if( nb_subfr == PE_MAX_NB_SUBFR ){ - Lag_range_ptr = &SKP_Silk_Lag_range_stage3[ complexity ][ 0 ][ 0 ]; - Lag_CB_ptr = &SKP_Silk_CB_lags_stage3[ 0 ][ 0 ]; - nb_cbk_search = SKP_Silk_nb_cbk_searchs_stage3[ complexity ]; + Lag_range_ptr = &silk_Lag_range_stage3[ complexity ][ 0 ][ 0 ]; + Lag_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ]; + nb_cbk_search = silk_nb_cbk_searchs_stage3[ complexity ]; cbk_size = PE_NB_CBKS_STAGE3_MAX; } else { SKP_assert( nb_subfr == PE_MAX_NB_SUBFR >> 1); - Lag_range_ptr = &SKP_Silk_Lag_range_stage3_10_ms[ 0 ][ 0 ]; - Lag_CB_ptr = &SKP_Silk_CB_lags_stage3_10_ms[ 0 ][ 0 ]; + Lag_range_ptr = &silk_Lag_range_stage3_10_ms[ 0 ][ 0 ]; + Lag_CB_ptr = &silk_CB_lags_stage3_10_ms[ 0 ][ 0 ]; nb_cbk_search = PE_NB_CBKS_STAGE3_10MS; cbk_size = PE_NB_CBKS_STAGE3_10MS; } @@ -538,7 +535,7 @@ static void SKP_P_Ana_calc_corr_st3( for( j = lag_low; j <= lag_high; j++ ) { basis_ptr = target_ptr - ( start_lag + j ); SKP_assert( lag_counter < SCRATCH_SIZE ); - scratch_mem[ lag_counter ] = (SKP_float)SKP_Silk_inner_product_FLP( target_ptr, basis_ptr, sf_length ); + scratch_mem[ lag_counter ] = (SKP_float)silk_inner_product_FLP( target_ptr, basis_ptr, sf_length ); lag_counter++; } @@ -557,7 +554,7 @@ static void SKP_P_Ana_calc_corr_st3( } } -static void SKP_P_Ana_calc_energy_st3( +static void silk_P_Ana_calc_energy_st3( SKP_float energies_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ], /* O 3 DIM correlation array */ const SKP_float signal[], /* I vector to correlate */ SKP_int start_lag, /* I start lag */ @@ -581,14 +578,14 @@ calculated recursively. SKP_assert( complexity <= SigProc_PE_MAX_COMPLEX ); if( nb_subfr == PE_MAX_NB_SUBFR ){ - Lag_range_ptr = &SKP_Silk_Lag_range_stage3[ complexity ][ 0 ][ 0 ]; - Lag_CB_ptr = &SKP_Silk_CB_lags_stage3[ 0 ][ 0 ]; - nb_cbk_search = SKP_Silk_nb_cbk_searchs_stage3[ complexity ]; + Lag_range_ptr = &silk_Lag_range_stage3[ complexity ][ 0 ][ 0 ]; + Lag_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ]; + nb_cbk_search = silk_nb_cbk_searchs_stage3[ complexity ]; cbk_size = PE_NB_CBKS_STAGE3_MAX; } else { SKP_assert( nb_subfr == PE_MAX_NB_SUBFR >> 1); - Lag_range_ptr = &SKP_Silk_Lag_range_stage3_10_ms[ 0 ][ 0 ]; - Lag_CB_ptr = &SKP_Silk_CB_lags_stage3_10_ms[ 0 ][ 0 ]; + Lag_range_ptr = &silk_Lag_range_stage3_10_ms[ 0 ][ 0 ]; + Lag_CB_ptr = &silk_CB_lags_stage3_10_ms[ 0 ][ 0 ]; nb_cbk_search = PE_NB_CBKS_STAGE3_10MS; cbk_size = PE_NB_CBKS_STAGE3_10MS; } @@ -599,7 +596,7 @@ calculated recursively. /* Calculate the energy for first lag */ basis_ptr = target_ptr - ( start_lag + matrix_ptr( Lag_range_ptr, k, 0, 2 ) ); - energy = SKP_Silk_energy_FLP( basis_ptr, sf_length ) + 1e-3; + energy = silk_energy_FLP( basis_ptr, sf_length ) + 1e-3; SKP_assert( energy >= 0.0 ); scratch_mem[lag_counter] = (SKP_float)energy; lag_counter++; diff --git a/silk/float/SKP_Silk_prefilter_FLP.c b/silk/float/silk_prefilter_FLP.c similarity index 87% rename from silk/float/SKP_Silk_prefilter_FLP.c rename to silk/float/silk_prefilter_FLP.c index c3a23d15..3a61c717 100644 --- a/silk/float/SKP_Silk_prefilter_FLP.c +++ b/silk/float/silk_prefilter_FLP.c @@ -25,14 +25,14 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FLP.h" -#include "SKP_Silk_tuning_parameters.h" +#include "silk_main_FLP.h" +#include "silk_tuning_parameters.h" /* -* SKP_Silk_prefilter. Prefilter for finding Quantizer input signal +* silk_prefilter. Prefilter for finding Quantizer input signal */ -SKP_INLINE void SKP_Silk_prefilt_FLP( - SKP_Silk_prefilter_state_FLP *P,/* I/O state */ +SKP_INLINE void silk_prefilt_FLP( + silk_prefilter_state_FLP *P,/* I/O state */ SKP_float st_res[], /* I */ SKP_float xw[], /* O */ SKP_float *HarmShapeFIR, /* I */ @@ -43,7 +43,7 @@ SKP_INLINE void SKP_Silk_prefilt_FLP( SKP_int length /* I */ ); -void SKP_Silk_warped_LPC_analysis_filter_FLP( +void silk_warped_LPC_analysis_filter_FLP( SKP_float state[], /* I/O State [order + 1] */ SKP_float res[], /* O Residual signal [length] */ const SKP_float coef[], /* I Coefficients [order] */ @@ -85,16 +85,16 @@ void SKP_Silk_warped_LPC_analysis_filter_FLP( } /* -* SKP_Silk_prefilter. Main prefilter function +* silk_prefilter. Main prefilter function */ -void SKP_Silk_prefilter_FLP( - SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - const SKP_Silk_encoder_control_FLP *psEncCtrl, /* I Encoder control FLP */ +void silk_prefilter_FLP( + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + const silk_encoder_control_FLP *psEncCtrl, /* I Encoder control FLP */ SKP_float xw[], /* O Weighted signal */ const SKP_float x[] /* I Speech signal */ ) { - SKP_Silk_prefilter_state_FLP *P = &psEnc->sPrefilt; + silk_prefilter_state_FLP *P = &psEnc->sPrefilt; SKP_int j, k, lag; SKP_float HarmShapeGain, Tilt, LF_MA_shp, LF_AR_shp; SKP_float B[ 2 ]; @@ -125,7 +125,7 @@ void SKP_Silk_prefilter_FLP( AR1_shp = &psEncCtrl->AR1[ k * MAX_SHAPE_LPC_ORDER ]; /* Short term FIR filtering */ - SKP_Silk_warped_LPC_analysis_filter_FLP( P->sAR_shp, st_res, AR1_shp, px, + silk_warped_LPC_analysis_filter_FLP( P->sAR_shp, st_res, AR1_shp, px, (SKP_float)psEnc->sCmn.warping_Q16 / 65536.0f, psEnc->sCmn.subfr_length, psEnc->sCmn.shapingLPCOrder ); /* Reduce (mainly) low frequencies during harmonic emphasis */ @@ -138,7 +138,7 @@ void SKP_Silk_prefilter_FLP( } P->sHarmHP = st_res[ psEnc->sCmn.subfr_length - 1 ]; - SKP_Silk_prefilt_FLP( P, pxw, pxw, HarmShapeFIR, Tilt, LF_MA_shp, LF_AR_shp, lag, psEnc->sCmn.subfr_length ); + silk_prefilt_FLP( P, pxw, pxw, HarmShapeFIR, Tilt, LF_MA_shp, LF_AR_shp, lag, psEnc->sCmn.subfr_length ); px += psEnc->sCmn.subfr_length; pxw += psEnc->sCmn.subfr_length; @@ -149,8 +149,8 @@ void SKP_Silk_prefilter_FLP( /* * Prefilter for finding Quantizer input signal */ -SKP_INLINE void SKP_Silk_prefilt_FLP( - SKP_Silk_prefilter_state_FLP *P,/* I/O state */ +SKP_INLINE void silk_prefilt_FLP( + silk_prefilter_state_FLP *P,/* I/O state */ SKP_float st_res[], /* I */ SKP_float xw[], /* O */ SKP_float *HarmShapeFIR, /* I */ diff --git a/silk/float/SKP_Silk_process_gains_FLP.c b/silk/float/silk_process_gains_FLP.c similarity index 84% rename from silk/float/SKP_Silk_process_gains_FLP.c rename to silk/float/silk_process_gains_FLP.c index 4f0a2089..8f517dfa 100644 --- a/silk/float/SKP_Silk_process_gains_FLP.c +++ b/silk/float/silk_process_gains_FLP.c @@ -25,16 +25,16 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FLP.h" -#include "SKP_Silk_tuning_parameters.h" +#include "silk_main_FLP.h" +#include "silk_tuning_parameters.h" /* Processing of gains */ -void SKP_Silk_process_gains_FLP( - SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - SKP_Silk_encoder_control_FLP *psEncCtrl /* I/O Encoder control FLP */ +void silk_process_gains_FLP( + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + silk_encoder_control_FLP *psEncCtrl /* I/O Encoder control FLP */ ) { - SKP_Silk_shape_state_FLP *psShapeSt = &psEnc->sShape; + silk_shape_state_FLP *psShapeSt = &psEnc->sShape; SKP_int k; SKP_int32 pGains_Q16[ MAX_NB_SUBFR ]; SKP_float s, InvMaxSqrVal, gain, quant_offset; @@ -63,8 +63,8 @@ void SKP_Silk_process_gains_FLP( } /* Noise shaping quantization */ - SKP_Silk_gains_quant( psEnc->sCmn.indices.GainsIndices, pGains_Q16, - &psShapeSt->LastGainIndex, psEnc->sCmn.nFramesAnalyzed, psEnc->sCmn.nb_subfr ); + silk_gains_quant( psEnc->sCmn.indices.GainsIndices, pGains_Q16, + &psShapeSt->LastGainIndex, psEnc->sCmn.nFramesEncoded, psEnc->sCmn.nb_subfr ); /* Overwrite unquantized gains with quantized gains and convert back to Q0 from Q16 */ for( k = 0; k < psEnc->sCmn.nb_subfr; k++ ) { @@ -81,7 +81,7 @@ void SKP_Silk_process_gains_FLP( } /* Quantizer boundary adjustment */ - quant_offset = SKP_Silk_Quantization_Offsets_Q10[ psEnc->sCmn.indices.signalType >> 1 ][ psEnc->sCmn.indices.quantOffsetType ] / 1024.0f; + quant_offset = silk_Quantization_Offsets_Q10[ psEnc->sCmn.indices.signalType >> 1 ][ psEnc->sCmn.indices.quantOffsetType ] / 1024.0f; psEncCtrl->Lambda = LAMBDA_OFFSET + LAMBDA_DELAYED_DECISIONS * psEnc->sCmn.nStatesDelayedDecision + LAMBDA_SPEECH_ACT * psEnc->sCmn.speech_activity_Q8 * ( 1.0f / 256.0f ) diff --git a/silk/float/SKP_Silk_regularize_correlations_FLP.c b/silk/float/silk_regularize_correlations_FLP.c similarity index 95% rename from silk/float/SKP_Silk_regularize_correlations_FLP.c rename to silk/float/silk_regularize_correlations_FLP.c index 3acb944d..dd5d0362 100644 --- a/silk/float/SKP_Silk_regularize_correlations_FLP.c +++ b/silk/float/silk_regularize_correlations_FLP.c @@ -25,9 +25,9 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FLP.h" +#include "silk_main_FLP.h" -void SKP_Silk_regularize_correlations_FLP( +void silk_regularize_correlations_FLP( SKP_float *XX, /* I/O Correlation matrices */ SKP_float *xx, /* I/O Correlation values */ const SKP_float noise, /* I Noise energy to add */ diff --git a/silk/float/SKP_Silk_residual_energy_FLP.c b/silk/float/silk_residual_energy_FLP.c similarity index 83% rename from silk/float/SKP_Silk_residual_energy_FLP.c rename to silk/float/silk_residual_energy_FLP.c index 1d11b4ec..192e5704 100644 --- a/silk/float/SKP_Silk_residual_energy_FLP.c +++ b/silk/float/silk_residual_energy_FLP.c @@ -25,13 +25,13 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FLP.h" +#include "silk_main_FLP.h" #define MAX_ITERATIONS_RESIDUAL_NRG 10 #define REGULARIZATION_FACTOR 1e-8f /* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */ -SKP_float SKP_Silk_residual_energy_covar_FLP( /* O Weighted residual energy */ +SKP_float silk_residual_energy_covar_FLP( /* O Weighted residual energy */ const SKP_float *c, /* I Filter coefficients */ SKP_float *wXX, /* I/O Weighted correlation matrix, reg. out */ const SKP_float *wXx, /* I Weighted correlation vector */ @@ -40,7 +40,7 @@ SKP_float SKP_Silk_residual_energy_covar_FLP( /* O Weighted residua ) { SKP_int i, j, k; - SKP_float tmp, nrg, regularization; + SKP_float tmp, nrg = 0.0f, regularization; /* Safety checks */ SKP_assert( D >= 0 ); @@ -84,10 +84,10 @@ SKP_float SKP_Silk_residual_energy_covar_FLP( /* O Weighted residua /* Calculates residual energies of input subframes where all subframes have LPC_order */ /* of preceeding samples */ -void SKP_Silk_residual_energy_FLP( +void silk_residual_energy_FLP( SKP_float nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */ const SKP_float x[], /* I Input signal */ - const SKP_float a[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */ + SKP_float a[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */ const SKP_float gains[], /* I Quantization gains */ const SKP_int subfr_length, /* I Subframe length */ const SKP_int nb_subfr, /* I number of subframes */ @@ -101,13 +101,13 @@ void SKP_Silk_residual_energy_FLP( shift = LPC_order + subfr_length; /* Filter input to create the LPC residual for each frame half, and measure subframe energies */ - SKP_Silk_LPC_analysis_filter_FLP( LPC_res, a[ 0 ], x + 0 * shift, 2 * shift, LPC_order ); - nrgs[ 0 ] = ( SKP_float )( gains[ 0 ] * gains[ 0 ] * SKP_Silk_energy_FLP( LPC_res_ptr + 0 * shift, subfr_length ) ); - nrgs[ 1 ] = ( SKP_float )( gains[ 1 ] * gains[ 1 ] * SKP_Silk_energy_FLP( LPC_res_ptr + 1 * shift, subfr_length ) ); + silk_LPC_analysis_filter_FLP( LPC_res, a[ 0 ], x + 0 * shift, 2 * shift, LPC_order ); + nrgs[ 0 ] = ( SKP_float )( gains[ 0 ] * gains[ 0 ] * silk_energy_FLP( LPC_res_ptr + 0 * shift, subfr_length ) ); + nrgs[ 1 ] = ( SKP_float )( gains[ 1 ] * gains[ 1 ] * silk_energy_FLP( LPC_res_ptr + 1 * shift, subfr_length ) ); if( nb_subfr == MAX_NB_SUBFR ) { - SKP_Silk_LPC_analysis_filter_FLP( LPC_res, a[ 1 ], x + 2 * shift, 2 * shift, LPC_order ); - nrgs[ 2 ] = ( SKP_float )( gains[ 2 ] * gains[ 2 ] * SKP_Silk_energy_FLP( LPC_res_ptr + 0 * shift, subfr_length ) ); - nrgs[ 3 ] = ( SKP_float )( gains[ 3 ] * gains[ 3 ] * SKP_Silk_energy_FLP( LPC_res_ptr + 1 * shift, subfr_length ) ); + silk_LPC_analysis_filter_FLP( LPC_res, a[ 1 ], x + 2 * shift, 2 * shift, LPC_order ); + nrgs[ 2 ] = ( SKP_float )( gains[ 2 ] * gains[ 2 ] * silk_energy_FLP( LPC_res_ptr + 0 * shift, subfr_length ) ); + nrgs[ 3 ] = ( SKP_float )( gains[ 3 ] * gains[ 3 ] * silk_energy_FLP( LPC_res_ptr + 1 * shift, subfr_length ) ); } } diff --git a/silk/float/SKP_Silk_scale_copy_vector_FLP.c b/silk/float/silk_scale_copy_vector_FLP.c similarity index 95% rename from silk/float/SKP_Silk_scale_copy_vector_FLP.c rename to silk/float/silk_scale_copy_vector_FLP.c index 94274fd6..3a9487a2 100644 --- a/silk/float/SKP_Silk_scale_copy_vector_FLP.c +++ b/silk/float/silk_scale_copy_vector_FLP.c @@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_SigProc_FLP.h" +#include "silk_SigProc_FLP.h" /* copy and multiply a vector by a constant */ -void SKP_Silk_scale_copy_vector_FLP( +void silk_scale_copy_vector_FLP( SKP_float *data_out, const SKP_float *data_in, SKP_float gain, diff --git a/silk/float/SKP_Silk_scale_vector_FLP.c b/silk/float/silk_scale_vector_FLP.c similarity index 95% rename from silk/float/SKP_Silk_scale_vector_FLP.c rename to silk/float/silk_scale_vector_FLP.c index 69b47e67..457d738a 100644 --- a/silk/float/SKP_Silk_scale_vector_FLP.c +++ b/silk/float/silk_scale_vector_FLP.c @@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_SigProc_FLP.h" +#include "silk_SigProc_FLP.h" /* multiply a vector by a constant */ -void SKP_Silk_scale_vector_FLP( +void silk_scale_vector_FLP( SKP_float *data1, SKP_float gain, SKP_int dataSize diff --git a/silk/float/SKP_Silk_schur_FLP.c b/silk/float/silk_schur_FLP.c similarity index 78% rename from silk/float/SKP_Silk_schur_FLP.c rename to silk/float/silk_schur_FLP.c index a6dd24ca..651e50da 100644 --- a/silk/float/SKP_Silk_schur_FLP.c +++ b/silk/float/silk_schur_FLP.c @@ -25,25 +25,16 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -/* * - * SKP_Silk_schur.c * - * * - * Calculates the reflection coefficients from the correlation sequence * - * * - * Copyright 2008 (c), Skype Limited * - * Date: 080103 * - */ +#include "silk_SigProc_FLP.h" -#include "SKP_Silk_SigProc_FLP.h" - -SKP_float SKP_Silk_schur_FLP( /* O returns residual energy */ +SKP_float silk_schur_FLP( /* O returns residual energy */ SKP_float refl_coef[], /* O reflection coefficients (length order) */ const SKP_float auto_corr[], /* I autotcorrelation sequence (length order+1) */ SKP_int order /* I order */ ) { SKP_int k, n; - SKP_float C[ SKP_Silk_MAX_ORDER_LPC + 1 ][ 2 ]; + SKP_float C[ SILK_MAX_ORDER_LPC + 1 ][ 2 ]; SKP_float Ctmp1, Ctmp2, rc_tmp; /* Copy correlations */ diff --git a/silk/float/SKP_Silk_solve_LS_FLP.c b/silk/float/silk_solve_LS_FLP.c similarity index 91% rename from silk/float/SKP_Silk_solve_LS_FLP.c rename to silk/float/silk_solve_LS_FLP.c index e6c02c4d..296d2ffc 100644 --- a/silk/float/SKP_Silk_solve_LS_FLP.c +++ b/silk/float/silk_solve_LS_FLP.c @@ -25,15 +25,15 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FLP.h" -#include "SKP_Silk_tuning_parameters.h" +#include "silk_main_FLP.h" +#include "silk_tuning_parameters.h" /********************************************************************** * LDL Factorisation. Finds the upper triangular matrix L and the diagonal * Matrix D (only the diagonal elements returned in a vector)such that * the symmetric matric A is given by A = L*D*L'. **********************************************************************/ -void SKP_Silk_LDL_FLP( +void silk_LDL_FLP( SKP_float *A, /* (I/O) Pointer to Symetric Square Matrix */ SKP_int M, /* (I) Size of Matrix */ SKP_float *L, /* (I/O) Pointer to Square Upper triangular Matrix */ @@ -44,7 +44,7 @@ void SKP_Silk_LDL_FLP( * Function to solve linear equation Ax = b, when A is a MxM lower * triangular matrix, with ones on the diagonal. **********************************************************************/ -void SKP_Silk_SolveWithLowerTriangularWdiagOnes_FLP( +void silk_SolveWithLowerTriangularWdiagOnes_FLP( const SKP_float *L, /* (I) Pointer to Lower Triangular Matrix */ SKP_int M, /* (I) Dim of Matrix equation */ const SKP_float *b, /* (I) b Vector */ @@ -55,7 +55,7 @@ void SKP_Silk_SolveWithLowerTriangularWdiagOnes_FLP( * Function to solve linear equation (A^T)x = b, when A is a MxM lower * triangular, with ones on the diagonal. (ie then A^T is upper triangular) **********************************************************************/ -void SKP_Silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP( +void silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP( const SKP_float *L, /* (I) Pointer to Lower Triangular Matrix */ SKP_int M, /* (I) Dim of Matrix equation */ const SKP_float *b, /* (I) b Vector */ @@ -66,7 +66,7 @@ void SKP_Silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP( * Function to solve linear equation Ax = b, when A is a MxM * symmetric square matrix - using LDL factorisation **********************************************************************/ -void SKP_Silk_solve_LDL_FLP( +void silk_solve_LDL_FLP( SKP_float *A, /* I/O Symmetric square matrix, out: reg. */ const SKP_int M, /* I Size of matrix */ const SKP_float *b, /* I Pointer to b vector */ @@ -84,13 +84,13 @@ void SKP_Silk_solve_LDL_FLP( Factorize A by LDL such that A = L*D*(L^T), where L is lower triangular with ones on diagonal ****************************************************/ - SKP_Silk_LDL_FLP( A, M, &L[ 0 ][ 0 ], Dinv ); + silk_LDL_FLP( A, M, &L[ 0 ][ 0 ], Dinv ); /**************************************************** * substitute D*(L^T) = T. ie: L*D*(L^T)*x = b => L*T = b <=> T = inv(L)*b ******************************************************/ - SKP_Silk_SolveWithLowerTriangularWdiagOnes_FLP( &L[ 0 ][ 0 ], M, b, T ); + silk_SolveWithLowerTriangularWdiagOnes_FLP( &L[ 0 ][ 0 ], M, b, T ); /**************************************************** D*(L^T)*x = T <=> (L^T)*x = inv(D)*T, because D is @@ -102,10 +102,10 @@ void SKP_Silk_solve_LDL_FLP( /**************************************************** x = inv(L') * inv(D) * T *****************************************************/ - SKP_Silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP( &L[ 0 ][ 0 ], M, T, x ); + silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP( &L[ 0 ][ 0 ], M, T, x ); } -void SKP_Silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP( +void silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP( const SKP_float *L, /* (I) Pointer to Lower Triangular Matrix */ SKP_int M, /* (I) Dim of Matrix equation */ const SKP_float *b, /* (I) b Vector */ @@ -127,7 +127,7 @@ void SKP_Silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP( } } -void SKP_Silk_SolveWithLowerTriangularWdiagOnes_FLP( +void silk_SolveWithLowerTriangularWdiagOnes_FLP( const SKP_float *L, /* (I) Pointer to Lower Triangular Matrix */ SKP_int M, /* (I) Dim of Matrix equation */ const SKP_float *b, /* (I) b Vector */ @@ -149,7 +149,7 @@ void SKP_Silk_SolveWithLowerTriangularWdiagOnes_FLP( } } -void SKP_Silk_LDL_FLP( +void silk_LDL_FLP( SKP_float *A, /* (I/O) Pointer to Symetric Square Matrix */ SKP_int M, /* (I) Size of Matrix */ SKP_float *L, /* (I/O) Pointer to Square Upper triangular Matrix */ diff --git a/silk/float/SKP_Silk_sort_FLP.c b/silk/float/silk_sort_FLP.c similarity index 80% rename from silk/float/SKP_Silk_sort_FLP.c rename to silk/float/silk_sort_FLP.c index 20d3f7d5..7872fe28 100644 --- a/silk/float/SKP_Silk_sort_FLP.c +++ b/silk/float/silk_sort_FLP.c @@ -29,12 +29,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Best case: O(n) for an already sorted array */ /* Worst case: O(n^2) for an inversely sorted array */ -#include "SKP_Silk_typedef.h" -#include "SKP_Silk_SigProc_FLP.h" +#include "silk_typedef.h" +#include "silk_SigProc_FLP.h" -void SKP_Silk_insertion_sort_decreasing_FLP( +void silk_insertion_sort_decreasing_FLP( SKP_float *a, /* I/O: Unsorted / Sorted vector */ - SKP_int *index, /* O: Index vector for the sorted elements */ + SKP_int *idx, /* O: Index vector for the sorted elements */ const SKP_int L, /* I: Vector length */ const SKP_int K /* I: Number of correctly sorted positions */ ) @@ -49,18 +49,18 @@ void SKP_Silk_insertion_sort_decreasing_FLP( /* Write start indices in index vector */ for( i = 0; i < K; i++ ) { - index[ i ] = i; + idx[ i ] = i; } /* Sort vector elements by value, decreasing order */ for( i = 1; i < K; i++ ) { value = a[ i ]; for( j = i - 1; ( j >= 0 ) && ( value > a[ j ] ); j-- ) { - a[ j + 1 ] = a[ j ]; /* Shift value */ - index[ j + 1 ] = index[ j ]; /* Shift index */ + a[ j + 1 ] = a[ j ]; /* Shift value */ + idx[ j + 1 ] = idx[ j ]; /* Shift index */ } - a[ j + 1 ] = value; /* Write value */ - index[ j + 1 ] = i; /* Write index */ + a[ j + 1 ] = value; /* Write value */ + idx[ j + 1 ] = i; /* Write index */ } /* If less than L values are asked check the remaining values, */ @@ -69,11 +69,11 @@ void SKP_Silk_insertion_sort_decreasing_FLP( value = a[ i ]; if( value > a[ K - 1 ] ) { for( j = K - 2; ( j >= 0 ) && ( value > a[ j ] ); j-- ) { - a[ j + 1 ] = a[ j ]; /* Shift value */ - index[ j + 1 ] = index[ j ]; /* Shift index */ + a[ j + 1 ] = a[ j ]; /* Shift value */ + idx[ j + 1 ] = idx[ j ]; /* Shift index */ } - a[ j + 1 ] = value; /* Write value */ - index[ j + 1 ] = i; /* Write index */ + a[ j + 1 ] = value; /* Write value */ + idx[ j + 1 ] = i; /* Write index */ } } } diff --git a/silk/float/SKP_Silk_structs_FLP.h b/silk/float/silk_structs_FLP.h similarity index 78% rename from silk/float/SKP_Silk_structs_FLP.h rename to silk/float/silk_structs_FLP.h index 3c823fa9..44c1e94f 100644 --- a/silk/float/SKP_Silk_structs_FLP.h +++ b/silk/float/silk_structs_FLP.h @@ -25,12 +25,12 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#ifndef SKP_SILK_STRUCTS_FLP_H -#define SKP_SILK_STRUCTS_FLP_H +#ifndef SILK_STRUCTS_FLP_H +#define SILK_STRUCTS_FLP_H -#include "SKP_Silk_typedef.h" -#include "SKP_Silk_main.h" -#include "SKP_Silk_structs.h" +#include "silk_typedef.h" +#include "silk_main.h" +#include "silk_structs.h" #ifdef __cplusplus extern "C" @@ -45,7 +45,7 @@ typedef struct { SKP_float HarmBoost_smth; SKP_float HarmShapeGain_smth; SKP_float Tilt_smth; -} SKP_Silk_shape_state_FLP; +} silk_shape_state_FLP; /********************************/ /* Prefilter state */ @@ -59,15 +59,15 @@ typedef struct { SKP_float sHarmHP; SKP_int32 rand_seed; SKP_int lagPrev; -} SKP_Silk_prefilter_state_FLP; +} silk_prefilter_state_FLP; /********************************/ /* Encoder state FLP */ /********************************/ typedef struct { - SKP_Silk_encoder_state sCmn; /* Common struct, shared with fixed-point code */ - SKP_Silk_shape_state_FLP sShape; /* Noise shaping state */ - SKP_Silk_prefilter_state_FLP sPrefilt; /* Prefilter State */ + silk_encoder_state sCmn; /* Common struct, shared with fixed-point code */ + silk_shape_state_FLP sShape; /* Noise shaping state */ + silk_prefilter_state_FLP sPrefilt; /* Prefilter State */ /* Buffer for find pitch and noise shape analysis */ SKP_float x_buf[ 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ];/* Buffer for find pitch and noise shape analysis */ @@ -76,7 +76,7 @@ typedef struct { /* Parameters for LTP scaling control */ SKP_float prevLTPredCodGain; SKP_float HPLTPredCodGain; -} SKP_Silk_encoder_state_FLP; +} silk_encoder_state_FLP; /************************/ /* Encoder control FLP */ @@ -107,7 +107,20 @@ typedef struct { SKP_float predGain; SKP_float LTPredCodGain; SKP_float ResNrg[ MAX_NB_SUBFR ]; /* Residual energy per subframe */ -} SKP_Silk_encoder_control_FLP; +} silk_encoder_control_FLP; + +/************************/ +/* Encoder Super Struct */ +/************************/ +typedef struct { + silk_encoder_state_FLP state_Fxx[ ENCODER_NUM_CHANNELS ]; + stereo_enc_state sStereo; + SKP_int32 nBitsExceeded; + SKP_int nChannelsAPI; + SKP_int nChannelsInternal; + SKP_int timeSinceSwitchAllowed_ms; + SKP_int allowBandwidthSwitch; +} silk_encoder; #ifdef __cplusplus } diff --git a/silk/float/SKP_Silk_warped_autocorrelation_FLP.c b/silk/float/silk_warped_autocorrelation_FLP.c similarity index 95% rename from silk/float/SKP_Silk_warped_autocorrelation_FLP.c rename to silk/float/silk_warped_autocorrelation_FLP.c index 355d7e49..402e2ecb 100644 --- a/silk/float/SKP_Silk_warped_autocorrelation_FLP.c +++ b/silk/float/silk_warped_autocorrelation_FLP.c @@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FLP.h" +#include "silk_main_FLP.h" /* Autocorrelations for a warped frequency axis */ -void SKP_Silk_warped_autocorrelation_FLP( +void silk_warped_autocorrelation_FLP( SKP_float *corr, /* O Result [order + 1] */ const SKP_float *input, /* I Input data to correlate */ const SKP_float warping, /* I Warping coefficient */ diff --git a/silk/float/SKP_Silk_wrappers_FLP.c b/silk/float/silk_wrappers_FLP.c similarity index 87% rename from silk/float/SKP_Silk_wrappers_FLP.c rename to silk/float/silk_wrappers_FLP.c index 9e5b7650..27a71e5c 100644 --- a/silk/float/SKP_Silk_wrappers_FLP.c +++ b/silk/float/silk_wrappers_FLP.c @@ -25,12 +25,12 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FLP.h" +#include "silk_main_FLP.h" /* Wrappers. Calls flp / fix code */ /* Convert AR filter coefficients to NLSF parameters */ -void SKP_Silk_A2NLSF_FLP( +void silk_A2NLSF_FLP( SKP_int16 *NLSF_Q15, /* O NLSF vector [ LPC_order ] */ const SKP_float *pAR, /* I LPC coefficients [ LPC_order ] */ const SKP_int LPC_order /* I LPC order */ @@ -43,11 +43,11 @@ void SKP_Silk_A2NLSF_FLP( a_fix_Q16[ i ] = SKP_float2int( pAR[ i ] * 65536.0f ); } - SKP_Silk_A2NLSF( NLSF_Q15, a_fix_Q16, LPC_order ); + silk_A2NLSF( NLSF_Q15, a_fix_Q16, LPC_order ); } /* Convert LSF parameters to AR prediction filter coefficients */ -void SKP_Silk_NLSF2A_stable_FLP( +void silk_NLSF2A_stable_FLP( SKP_float *pAR, /* O LPC coefficients [ LPC_order ] */ const SKP_int16 *NLSF_Q15, /* I NLSF vector [ LPC_order ] */ const SKP_int LPC_order /* I LPC order */ @@ -56,7 +56,7 @@ void SKP_Silk_NLSF2A_stable_FLP( SKP_int i; SKP_int16 a_fix_Q12[ MAX_LPC_ORDER ]; - SKP_Silk_NLSF2A_stable( a_fix_Q12, NLSF_Q15, LPC_order ); + silk_NLSF2A_stable( a_fix_Q12, NLSF_Q15, LPC_order ); for( i = 0; i < LPC_order; i++ ) { pAR[ i ] = ( SKP_float )a_fix_Q12[ i ] * ( 1.0f / 4096.0f ); @@ -66,8 +66,8 @@ void SKP_Silk_NLSF2A_stable_FLP( /******************************************/ /* Floating-point NLSF processing wrapper */ /******************************************/ -void SKP_Silk_process_NLSFs_FLP( - SKP_Silk_encoder_state *psEncC, /* I/O Encoder state */ +void silk_process_NLSFs_FLP( + silk_encoder_state *psEncC, /* I/O Encoder state */ SKP_float PredCoef[ 2 ][ MAX_LPC_ORDER ], /* O Prediction coefficients */ SKP_int16 NLSF_Q15[ MAX_LPC_ORDER ], /* I/O Normalized LSFs (quant out) (0 - (2^15-1)) */ const SKP_int16 prev_NLSF_Q15[ MAX_LPC_ORDER ] /* I Previous Normalized LSFs (0 - (2^15-1)) */ @@ -76,7 +76,7 @@ void SKP_Silk_process_NLSFs_FLP( SKP_int i, j; SKP_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ]; - SKP_Silk_process_NLSFs( psEncC, PredCoef_Q12, NLSF_Q15, prev_NLSF_Q15); + silk_process_NLSFs( psEncC, PredCoef_Q12, NLSF_Q15, prev_NLSF_Q15); for( j = 0; j < 2; j++ ) { for( i = 0; i < psEncC->predictLPCOrder; i++ ) { @@ -88,11 +88,11 @@ void SKP_Silk_process_NLSFs_FLP( /****************************************/ /* Floating-point Silk NSQ wrapper */ /****************************************/ -void SKP_Silk_NSQ_wrapper_FLP( - SKP_Silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ - SKP_Silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ +void silk_NSQ_wrapper_FLP( + silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */ + silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */ SideInfoIndices *psIndices, /* I/O Quantization indices */ - SKP_Silk_nsq_state *psNSQ, /* I/O Noise Shaping Quantzation state */ + silk_nsq_state *psNSQ, /* I/O Noise Shaping Quantzation state */ SKP_int8 pulses[], /* O Quantized pulse signal */ const SKP_float x[] /* I Prefiltered input signal */ ) @@ -144,7 +144,7 @@ void SKP_Silk_NSQ_wrapper_FLP( } if( psIndices->signalType == TYPE_VOICED ) { - LTP_scale_Q14 = SKP_Silk_LTPScales_table_Q14[ psIndices->LTP_scaleIndex ]; + LTP_scale_Q14 = silk_LTPScales_table_Q14[ psIndices->LTP_scaleIndex ]; } else { LTP_scale_Q14 = 0; } @@ -154,10 +154,10 @@ void SKP_Silk_NSQ_wrapper_FLP( /* Call NSQ */ if( psEnc->sCmn.nStatesDelayedDecision > 1 || psEnc->sCmn.warping_Q16 > 0 ) { - SKP_Silk_NSQ_del_dec( &psEnc->sCmn, psNSQ, psIndices, x_16, pulses, PredCoef_Q12[ 0 ], LTPCoef_Q14, + silk_NSQ_del_dec( &psEnc->sCmn, psNSQ, psIndices, x_16, pulses, PredCoef_Q12[ 0 ], LTPCoef_Q14, AR2_Q13, HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, psEncCtrl->pitchL, Lambda_Q10, LTP_scale_Q14 ); } else { - SKP_Silk_NSQ( &psEnc->sCmn, psNSQ, psIndices, x_16, pulses, PredCoef_Q12[ 0 ], LTPCoef_Q14, + silk_NSQ( &psEnc->sCmn, psNSQ, psIndices, x_16, pulses, PredCoef_Q12[ 0 ], LTPCoef_Q14, AR2_Q13, HarmShapeGain_Q14, Tilt_Q14, LF_shp_Q14, Gains_Q16, psEncCtrl->pitchL, Lambda_Q10, LTP_scale_Q14 ); } } @@ -165,7 +165,7 @@ void SKP_Silk_NSQ_wrapper_FLP( /***********************************************/ /* Floating-point Silk LTP quantiation wrapper */ /***********************************************/ -void SKP_Silk_quant_LTP_gains_FLP( +void silk_quant_LTP_gains_FLP( SKP_float B[ MAX_NB_SUBFR * LTP_ORDER ], /* I/O (Un-)quantized LTP gains */ SKP_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook index */ SKP_int8 *periodicity_index, /* O Periodicity index */ @@ -186,7 +186,7 @@ void SKP_Silk_quant_LTP_gains_FLP( W_Q18[ i ] = (SKP_int32)SKP_float2int( W[ i ] * 262144.0f ); } - SKP_Silk_quant_LTP_gains( B_Q14, cbk_index, periodicity_index, W_Q18, mu_Q10, lowComplexity, nb_subfr ); + silk_quant_LTP_gains( B_Q14, cbk_index, periodicity_index, W_Q18, mu_Q10, lowComplexity, nb_subfr ); for( i = 0; i < nb_subfr * LTP_ORDER; i++ ) { B[ i ] = (SKP_float)B_Q14[ i ] * ( 1.0f / 16384.0f ); diff --git a/silk/SKP_Silk_A2NLSF.c b/silk/silk_A2NLSF.c similarity index 83% rename from silk/SKP_Silk_A2NLSF.c rename to silk/silk_A2NLSF.c index 592c88ca..a2257dc9 100644 --- a/silk/SKP_Silk_A2NLSF.c +++ b/silk/silk_A2NLSF.c @@ -29,9 +29,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Requires the order to be an even number */ /* A piecewise linear approximation maps LSF <-> cos(LSF) */ /* Therefore the result is not accurate NLSFs, but the two */ -/* function are accurate inverses of each other */ +/* functions are accurate inverses of each other */ -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_SigProc_FIX.h" +#include "silk_tables.h" /* Number of binary divisions, when not in low complexity mode */ #define BIN_DIV_STEPS_A2NLSF_FIX 3 /* must be no higher than 16 - log2( LSF_COS_TAB_SZ_FIX ) */ @@ -43,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Helper function for A2NLSF(..) */ /* Transforms polynomials from cos(n*f) to cos(f)^n */ -SKP_INLINE void SKP_Silk_A2NLSF_trans_poly( +SKP_INLINE void silk_A2NLSF_trans_poly( SKP_int32 *p, /* I/O Polynomial */ const SKP_int dd /* I Polynomial order (= filter order / 2 ) */ ) @@ -59,7 +60,7 @@ SKP_INLINE void SKP_Silk_A2NLSF_trans_poly( } /* Helper function for A2NLSF(..) */ /* Polynomial evaluation */ -SKP_INLINE SKP_int32 SKP_Silk_A2NLSF_eval_poly( /* return the polynomial evaluation, in QPoly */ +SKP_INLINE SKP_int32 silk_A2NLSF_eval_poly( /* return the polynomial evaluation, in QPoly */ SKP_int32 *p, /* I Polynomial, QPoly */ const SKP_int32 x, /* I Evaluation point, Q12 */ const SKP_int dd /* I Order */ @@ -76,7 +77,7 @@ SKP_INLINE SKP_int32 SKP_Silk_A2NLSF_eval_poly( /* return the polynomial eval return y32; } -SKP_INLINE void SKP_Silk_A2NLSF_init( +SKP_INLINE void silk_A2NLSF_init( const SKP_int32 *a_Q16, SKP_int32 *P, SKP_int32 *Q, @@ -110,13 +111,13 @@ SKP_INLINE void SKP_Silk_A2NLSF_init( } /* Transform polynomials from cos(n*f) to cos(f)^n */ - SKP_Silk_A2NLSF_trans_poly( P, dd ); - SKP_Silk_A2NLSF_trans_poly( Q, dd ); + silk_A2NLSF_trans_poly( P, dd ); + silk_A2NLSF_trans_poly( Q, dd ); } /* Compute Normalized Line Spectral Frequencies (NLSFs) from whitening filter coefficients */ /* If not all roots are found, the a_Q16 coefficients are bandwidth expanded until convergence. */ -void SKP_Silk_A2NLSF( +void silk_A2NLSF( SKP_int16 *NLSF, /* O Normalized Line Spectral Frequencies, Q15 (0 - (2^15-1)), [d] */ SKP_int32 *a_Q16, /* I/O Monic whitening filter coefficients in Q16 [d] */ const SKP_int d /* I Filter order (must be even) */ @@ -126,8 +127,8 @@ void SKP_Silk_A2NLSF( SKP_int32 xlo, xhi, xmid; SKP_int32 ylo, yhi, ymid; SKP_int32 nom, den; - SKP_int32 P[ SKP_Silk_MAX_ORDER_LPC / 2 + 1 ]; - SKP_int32 Q[ SKP_Silk_MAX_ORDER_LPC / 2 + 1 ]; + SKP_int32 P[ SILK_MAX_ORDER_LPC / 2 + 1 ]; + SKP_int32 Q[ SILK_MAX_ORDER_LPC / 2 + 1 ]; SKP_int32 *PQ[ 2 ]; SKP_int32 *p; @@ -137,19 +138,19 @@ void SKP_Silk_A2NLSF( dd = SKP_RSHIFT( d, 1 ); - SKP_Silk_A2NLSF_init( a_Q16, P, Q, dd ); + silk_A2NLSF_init( a_Q16, P, Q, dd ); /* Find roots, alternating between P and Q */ p = P; /* Pointer to polynomial */ - xlo = SKP_Silk_LSFCosTab_FIX_Q12[ 0 ]; // Q12 - ylo = SKP_Silk_A2NLSF_eval_poly( p, xlo, dd ); + xlo = silk_LSFCosTab_FIX_Q12[ 0 ]; // Q12 + ylo = silk_A2NLSF_eval_poly( p, xlo, dd ); if( ylo < 0 ) { /* Set the first NLSF to zero and move on to the next */ NLSF[ 0 ] = 0; p = Q; /* Pointer to polynomial */ - ylo = SKP_Silk_A2NLSF_eval_poly( p, xlo, dd ); + ylo = silk_A2NLSF_eval_poly( p, xlo, dd ); root_ix = 1; /* Index of current root */ } else { root_ix = 0; /* Index of current root */ @@ -159,13 +160,13 @@ void SKP_Silk_A2NLSF( while( 1 ) { /* Evaluate polynomial */ #if OVERSAMPLE_COSINE_TABLE - xhi = SKP_Silk_LSFCosTab_FIX_Q12[ k >> 1 ] + - ( ( SKP_Silk_LSFCosTab_FIX_Q12[ ( k + 1 ) >> 1 ] - - SKP_Silk_LSFCosTab_FIX_Q12[ k >> 1 ] ) >> 1 ); /* Q12 */ + xhi = silk_LSFCosTab_FIX_Q12[ k >> 1 ] + + ( ( silk_LSFCosTab_FIX_Q12[ ( k + 1 ) >> 1 ] - + silk_LSFCosTab_FIX_Q12[ k >> 1 ] ) >> 1 ); /* Q12 */ #else - xhi = SKP_Silk_LSFCosTab_FIX_Q12[ k ]; /* Q12 */ + xhi = silk_LSFCosTab_FIX_Q12[ k ]; /* Q12 */ #endif - yhi = SKP_Silk_A2NLSF_eval_poly( p, xhi, dd ); + yhi = silk_A2NLSF_eval_poly( p, xhi, dd ); /* Detect zero crossing */ if( ( ylo <= 0 && yhi >= 0 ) || ( ylo >= 0 && yhi <= 0 ) ) { @@ -178,7 +179,7 @@ void SKP_Silk_A2NLSF( for( m = 0; m < BIN_DIV_STEPS_A2NLSF_FIX; m++ ) { /* Evaluate polynomial */ xmid = SKP_RSHIFT_ROUND( xlo + xhi, 1 ); - ymid = SKP_Silk_A2NLSF_eval_poly( p, xmid, dd ); + ymid = silk_A2NLSF_eval_poly( p, xmid, dd ); /* Detect zero crossing */ if( ( ylo <= 0 && ymid >= 0 ) || ( ylo >= 0 && ymid <= 0 ) ) { @@ -228,11 +229,11 @@ void SKP_Silk_A2NLSF( /* Evaluate polynomial */ #if OVERSAMPLE_COSINE_TABLE - xlo = SKP_Silk_LSFCosTab_FIX_Q12[ ( k - 1 ) >> 1 ] + - ( ( SKP_Silk_LSFCosTab_FIX_Q12[ k >> 1 ] - - SKP_Silk_LSFCosTab_FIX_Q12[ ( k - 1 ) >> 1 ] ) >> 1 ); // Q12 + xlo = silk_LSFCosTab_FIX_Q12[ ( k - 1 ) >> 1 ] + + ( ( silk_LSFCosTab_FIX_Q12[ k >> 1 ] - + silk_LSFCosTab_FIX_Q12[ ( k - 1 ) >> 1 ] ) >> 1 ); // Q12 #else - xlo = SKP_Silk_LSFCosTab_FIX_Q12[ k - 1 ]; // Q12 + xlo = silk_LSFCosTab_FIX_Q12[ k - 1 ]; // Q12 #endif ylo = SKP_LSHIFT( 1 - ( root_ix & 2 ), 12 ); } else { @@ -257,17 +258,17 @@ void SKP_Silk_A2NLSF( } /* Error: Apply progressively more bandwidth expansion and run again */ - SKP_Silk_bwexpander_32( a_Q16, d, 65536 - SKP_SMULBB( 10 + i, i ) ); // 10_Q16 = 0.00015 + silk_bwexpander_32( a_Q16, d, 65536 - SKP_SMULBB( 10 + i, i ) ); // 10_Q16 = 0.00015 - SKP_Silk_A2NLSF_init( a_Q16, P, Q, dd ); + silk_A2NLSF_init( a_Q16, P, Q, dd ); p = P; /* Pointer to polynomial */ - xlo = SKP_Silk_LSFCosTab_FIX_Q12[ 0 ]; // Q12 - ylo = SKP_Silk_A2NLSF_eval_poly( p, xlo, dd ); + xlo = silk_LSFCosTab_FIX_Q12[ 0 ]; // Q12 + ylo = silk_A2NLSF_eval_poly( p, xlo, dd ); if( ylo < 0 ) { /* Set the first NLSF to zero and move on to the next */ NLSF[ 0 ] = 0; p = Q; /* Pointer to polynomial */ - ylo = SKP_Silk_A2NLSF_eval_poly( p, xlo, dd ); + ylo = silk_A2NLSF_eval_poly( p, xlo, dd ); root_ix = 1; /* Index of current root */ } else { root_ix = 0; /* Index of current root */ diff --git a/silk/SKP_Silk_SDK_API.h b/silk/silk_API.h similarity index 77% rename from silk/SKP_Silk_SDK_API.h rename to silk/silk_API.h index fcbfc7fa..24c530a6 100644 --- a/silk/SKP_Silk_SDK_API.h +++ b/silk/silk_API.h @@ -25,12 +25,12 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#ifndef SKP_SILK_SDK_API_H -#define SKP_SILK_SDK_API_H +#ifndef SILK_API_H +#define SILK_API_H -#include "SKP_Silk_control.h" -#include "SKP_Silk_typedef.h" -#include "SKP_Silk_errors.h" +#include "silk_control.h" +#include "silk_typedef.h" +#include "silk_errors.h" #include "entenc.h" #include "entdec.h" @@ -46,7 +46,7 @@ typedef struct { SKP_int VADFlag; /* Voice activity for packet */ SKP_int VADFlags[ SILK_MAX_FRAMES_PER_PACKET ]; /* Voice activity for each frame in packet */ SKP_int inbandFECFlag; /* Flag indicating if packet contains in-band FEC */ -} SKP_Silk_TOC_struct; +} silk_TOC_struct; /****************************************/ /* Encoder functions */ @@ -55,24 +55,24 @@ typedef struct { /***********************************************/ /* Get size in bytes of the Silk encoder state */ /***********************************************/ -SKP_int SKP_Silk_SDK_Get_Encoder_Size( /* O: Returns error code */ +SKP_int silk_Get_Encoder_Size( /* O: Returns error code */ SKP_int32 *encSizeBytes /* O: Number of bytes in SILK encoder state */ ); /*************************/ /* Init or reset encoder */ /*************************/ -SKP_int SKP_Silk_SDK_InitEncoder( /* O: Returns error code */ +SKP_int silk_InitEncoder( /* O: Returns error code */ void *encState, /* I/O: State */ - SKP_SILK_SDK_EncControlStruct *encStatus /* O: Encoder Status */ + silk_EncControlStruct *encStatus /* O: Encoder Status */ ); /***************************************/ /* Read control structure from encoder */ /***************************************/ -SKP_int SKP_Silk_SDK_QueryEncoder( /* O: Returns error code */ +SKP_int silk_QueryEncoder( /* O: Returns error code */ const void *encState, /* I: State */ - SKP_SILK_SDK_EncControlStruct *encStatus /* O: Encoder Status */ + silk_EncControlStruct *encStatus /* O: Encoder Status */ ); /**************************/ @@ -80,9 +80,9 @@ SKP_int SKP_Silk_SDK_QueryEncoder( /* O: Returns error co /**************************/ /* Note: if prefillFlag is set, the input must contain 10 ms of audio, irrespective of what */ /* encControl->payloadSize_ms is set to */ -SKP_int SKP_Silk_SDK_Encode( /* O: Returns error code */ +SKP_int silk_Encode( /* O: Returns error code */ void *encState, /* I/O: State */ - SKP_SILK_SDK_EncControlStruct *encControl, /* I: Control status */ + silk_EncControlStruct *encControl, /* I: Control status */ const SKP_int16 *samplesIn, /* I: Speech sample input vector */ SKP_int nSamplesIn, /* I: Number of samples in input vector */ ec_enc *psRangeEnc, /* I/O Compressor data structure */ @@ -97,23 +97,23 @@ SKP_int SKP_Silk_SDK_Encode( /* O: Returns error co /***********************************************/ /* Get size in bytes of the Silk decoder state */ /***********************************************/ -SKP_int SKP_Silk_SDK_Get_Decoder_Size( /* O: Returns error code */ +SKP_int silk_Get_Decoder_Size( /* O: Returns error code */ SKP_int32 *decSizeBytes /* O: Number of bytes in SILK decoder state */ ); /*************************/ /* Init or Reset decoder */ /*************************/ -SKP_int SKP_Silk_SDK_InitDecoder( /* O: Returns error code */ +SKP_int silk_InitDecoder( /* O: Returns error code */ void *decState /* I/O: State */ ); /******************/ /* Decode a frame */ /******************/ -SKP_int SKP_Silk_SDK_Decode( /* O: Returns error code */ +SKP_int silk_Decode( /* O: Returns error code */ void* decState, /* I/O: State */ - SKP_SILK_SDK_DecControlStruct* decControl, /* I/O: Control Structure */ + silk_DecControlStruct* decControl, /* I/O: Control Structure */ SKP_int lostFlag, /* I: 0: no loss, 1 loss, 2 decode fec */ SKP_int newPacketFlag, /* I: Indicates first decoder call for this packet */ ec_dec *psRangeDec, /* I/O Compressor data structure */ @@ -121,25 +121,14 @@ SKP_int SKP_Silk_SDK_Decode( /* O: Returns error co SKP_int32 *nSamplesOut /* O: Number of samples decoded */ ); -/***************************************************************/ -/* Find Low Bit Rate Redundancy (LBRR) information in a packet */ -/***************************************************************/ -void SKP_Silk_SDK_search_for_LBRR( - const SKP_uint8 *inData, /* I: Encoded input vector */ - const SKP_int16 nBytesIn, /* I: Number of input bytes */ - SKP_int lost_offset, /* I: Offset from lost packet */ - SKP_uint8 *LBRRData, /* O: LBRR payload */ - SKP_int32 *nLBRRBytes /* O: Number of LBRR Bytes */ -); - /**************************************/ /* Get table of contents for a packet */ /**************************************/ -SKP_int SKP_Silk_SDK_get_TOC( +SKP_int silk_get_TOC( const SKP_uint8 *payload, /* I Payload data */ const SKP_int nBytesIn, /* I: Number of input bytes */ const SKP_int nFramesPerPayload, /* I: Number of SILK frames per payload */ - SKP_Silk_TOC_struct *Silk_TOC /* O: Type of content */ + silk_TOC_struct *Silk_TOC /* O: Type of content */ ); #ifdef __cplusplus diff --git a/silk/SKP_Silk_CNG.c b/silk/silk_CNG.c similarity index 86% rename from silk/SKP_Silk_CNG.c rename to silk/silk_CNG.c index 41128ef2..209e2d12 100644 --- a/silk/SKP_Silk_CNG.c +++ b/silk/silk_CNG.c @@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" +#include "silk_main.h" /* Generates excitation for CNG LPC synthesis */ -SKP_INLINE void SKP_Silk_CNG_exc( +SKP_INLINE void silk_CNG_exc( SKP_int16 residual[], /* O CNG residual signal Q0 */ SKP_int32 exc_buf_Q10[], /* I Random samples buffer Q10 */ SKP_int32 Gain_Q16, /* I Gain to apply */ @@ -55,8 +55,8 @@ SKP_INLINE void SKP_Silk_CNG_exc( *rand_seed = seed; } -void SKP_Silk_CNG_Reset( - SKP_Silk_decoder_state *psDec /* I/O Decoder state */ +void silk_CNG_Reset( + silk_decoder_state *psDec /* I/O Decoder state */ ) { SKP_int i, NLSF_step_Q15, NLSF_acc_Q15; @@ -72,9 +72,9 @@ void SKP_Silk_CNG_Reset( } /* Updates CNG estimate, and applies the CNG when packet was lost */ -void SKP_Silk_CNG( - SKP_Silk_decoder_state *psDec, /* I/O Decoder state */ - SKP_Silk_decoder_control *psDecCtrl, /* I/O Decoder control */ +void silk_CNG( + silk_decoder_state *psDec, /* I/O Decoder state */ + silk_decoder_control *psDecCtrl, /* I/O Decoder control */ SKP_int16 signal[], /* I/O Signal */ SKP_int length /* I Length of residual */ ) @@ -83,12 +83,12 @@ void SKP_Silk_CNG( SKP_int32 tmp_32, Gain_Q26, max_Gain_Q16; SKP_int16 LPC_buf[ MAX_LPC_ORDER ]; SKP_int16 CNG_sig[ MAX_FRAME_LENGTH ]; - SKP_Silk_CNG_struct *psCNG; + silk_CNG_struct *psCNG; psCNG = &psDec->sCNG; if( psDec->fs_kHz != psCNG->fs_kHz ) { /* Reset state */ - SKP_Silk_CNG_Reset( psDec ); + silk_CNG_Reset( psDec ); psCNG->fs_kHz = psDec->fs_kHz; } @@ -122,20 +122,20 @@ void SKP_Silk_CNG( if( psDec->lossCnt ) { /* Generate CNG excitation */ - SKP_Silk_CNG_exc( CNG_sig, psCNG->CNG_exc_buf_Q10, + silk_CNG_exc( CNG_sig, psCNG->CNG_exc_buf_Q10, psCNG->CNG_smth_Gain_Q16, length, &psCNG->rand_seed ); /* Convert CNG NLSF to filter representation */ - SKP_Silk_NLSF2A_stable( LPC_buf, psCNG->CNG_smth_NLSF_Q15, psDec->LPC_order ); + silk_NLSF2A_stable( LPC_buf, psCNG->CNG_smth_NLSF_Q15, psDec->LPC_order ); Gain_Q26 = ( SKP_int32 )1 << 26; /* 1.0 */ /* Generate CNG signal, by synthesis filtering */ if( psDec->LPC_order == 16 ) { - SKP_Silk_LPC_synthesis_order16( CNG_sig, LPC_buf, + silk_LPC_synthesis_order16( CNG_sig, LPC_buf, Gain_Q26, psCNG->CNG_synth_state, CNG_sig, length ); } else { - SKP_Silk_LPC_synthesis_filter( CNG_sig, LPC_buf, + silk_LPC_synthesis_filter( CNG_sig, LPC_buf, Gain_Q26, psCNG->CNG_synth_state, CNG_sig, length, psDec->LPC_order ); } /* Mix with signal */ diff --git a/silk/SKP_Silk_HP_variable_cutoff.c b/silk/silk_HP_variable_cutoff.c similarity index 50% rename from silk/SKP_Silk_HP_variable_cutoff.c rename to silk/silk_HP_variable_cutoff.c index 5e7b5b22..10f6868c 100644 --- a/silk/SKP_Silk_HP_variable_cutoff.c +++ b/silk/silk_HP_variable_cutoff.c @@ -25,79 +25,74 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main_FIX.h" -#include "SKP_Silk_tuning_parameters.h" - -#define SKP_RADIANS_CONSTANT_Q19 1482 // 0.45f * 2.0f * 3.14159265359 / 1000 -#define SKP_LOG2_VARIABLE_HP_MIN_FREQ_Q7 809 // log(80) in Q7 +#ifdef FIXED_POINT +#include "silk_main_FIX.h" +#else +#include "silk_main_FLP.h" +#endif +#include "silk_tuning_parameters.h" /* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */ -void SKP_Silk_HP_variable_cutoff( - SKP_Silk_encoder_state *psEncC, /* I/O Encoder state */ - SKP_int16 *out, /* O high-pass filtered output signal */ - const SKP_int16 *in, /* I input signal */ - const SKP_int frame_length /* I length of input */ +void silk_HP_variable_cutoff( + silk_encoder_state_Fxx state_Fxx[], /* I/O Encoder states */ + const SKP_int nChannels /* I Number of channels */ ) { - SKP_int quality_Q15; - SKP_float pitch_freq_low_Hz; + SKP_int quality_Q15, cutoff_Hz; SKP_int32 B_Q28[ 3 ], A_Q28[ 2 ]; SKP_int32 Fc_Q19, r_Q28, r_Q22; SKP_int32 pitch_freq_Hz_Q16, pitch_freq_log_Q7, delta_freq_Q7; + silk_encoder_state *psEncC1 = &state_Fxx[ 0 ].sCmn; /*********************************************/ /* Estimate Low End of Pitch Frequency Range */ /*********************************************/ - if( psEncC->prevSignalType == TYPE_VOICED ) { + if( psEncC1->prevSignalType == TYPE_VOICED ) { /* difference, in log domain */ - pitch_freq_Hz_Q16 = SKP_DIV32_16( SKP_LSHIFT( SKP_MUL( psEncC->fs_kHz, 1000 ), 16 ), psEncC->prevLag ); - pitch_freq_log_Q7 = SKP_Silk_lin2log( pitch_freq_Hz_Q16 ) - ( 16 << 7 ); //0x70 + pitch_freq_Hz_Q16 = SKP_DIV32_16( SKP_LSHIFT( SKP_MUL( psEncC1->fs_kHz, 1000 ), 16 ), psEncC1->prevLag ); + pitch_freq_log_Q7 = silk_lin2log( pitch_freq_Hz_Q16 ) - ( 16 << 7 ); /* adjustment based on quality */ - quality_Q15 = psEncC->input_quality_bands_Q15[ 0 ]; - pitch_freq_log_Q7 = SKP_SUB32( pitch_freq_log_Q7, SKP_SMULWB( SKP_SMULWB( SKP_LSHIFT( quality_Q15, 2 ), quality_Q15 ), - pitch_freq_log_Q7 - SKP_LOG2_VARIABLE_HP_MIN_FREQ_Q7 ) ); - pitch_freq_log_Q7 = SKP_ADD32( pitch_freq_log_Q7, SKP_RSHIFT( SKP_FIX_CONST( 0.6, 15 ) - quality_Q15, 9 ) ); + quality_Q15 = psEncC1->input_quality_bands_Q15[ 0 ]; + pitch_freq_log_Q7 = SKP_SMLAWB( pitch_freq_log_Q7, SKP_SMULWB( SKP_LSHIFT( -quality_Q15, 2 ), quality_Q15 ), + pitch_freq_log_Q7 - ( silk_lin2log( SILK_FIX_CONST( VARIABLE_HP_MIN_CUTOFF_HZ, 16 ) ) - ( 16 << 7 ) ) ); - //delta_freq = pitch_freq_log - psEnc->variable_HP_smth1; - delta_freq_Q7 = pitch_freq_log_Q7 - SKP_RSHIFT( psEncC->variable_HP_smth1_Q15, 8 ); + /* delta_freq = pitch_freq_log - psEnc->variable_HP_smth1; */ + delta_freq_Q7 = pitch_freq_log_Q7 - SKP_RSHIFT( psEncC1->variable_HP_smth1_Q15, 8 ); if( delta_freq_Q7 < 0 ) { /* less smoothing for decreasing pitch frequency, to track something close to the minimum */ delta_freq_Q7 = SKP_MUL( delta_freq_Q7, 3 ); } - /* limit delta, to reduce impact of outliers */ - 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 ) ); + /* limit delta, to reduce impact of outliers in pitch estimation */ + delta_freq_Q7 = SKP_LIMIT_32( delta_freq_Q7, -SILK_FIX_CONST( VARIABLE_HP_MAX_DELTA_FREQ, 7 ), SILK_FIX_CONST( VARIABLE_HP_MAX_DELTA_FREQ, 7 ) ); /* update smoother */ - psEncC->variable_HP_smth1_Q15 = SKP_SMLAWB( psEncC->variable_HP_smth1_Q15, - SKP_MUL( SKP_LSHIFT( psEncC->speech_activity_Q8, 1 ), delta_freq_Q7 ), SKP_FIX_CONST( VARIABLE_HP_SMTH_COEF1, 16 ) ); + psEncC1->variable_HP_smth1_Q15 = SKP_SMLAWB( psEncC1->variable_HP_smth1_Q15, + SKP_SMULBB( psEncC1->speech_activity_Q8, delta_freq_Q7 ), SILK_FIX_CONST( VARIABLE_HP_SMTH_COEF1, 16 ) ); } /* second smoother */ - psEncC->variable_HP_smth2_Q15 = SKP_SMLAWB( psEncC->variable_HP_smth2_Q15, - psEncC->variable_HP_smth1_Q15 - psEncC->variable_HP_smth2_Q15, SKP_FIX_CONST( VARIABLE_HP_SMTH_COEF2, 16 ) ); + psEncC1->variable_HP_smth2_Q15 = SKP_SMLAWB( psEncC1->variable_HP_smth2_Q15, + psEncC1->variable_HP_smth1_Q15 - psEncC1->variable_HP_smth2_Q15, SILK_FIX_CONST( VARIABLE_HP_SMTH_COEF2, 16 ) ); /* convert from log scale to Hertz */ - pitch_freq_low_Hz = SKP_Silk_log2lin( SKP_RSHIFT( psEncC->variable_HP_smth2_Q15, 8 ) ); + cutoff_Hz = silk_log2lin( SKP_RSHIFT( psEncC1->variable_HP_smth2_Q15, 8 ) ); /* limit frequency range */ - pitch_freq_low_Hz = SKP_LIMIT_32( pitch_freq_low_Hz, SKP_FIX_CONST( VARIABLE_HP_MIN_FREQ, 0 ), SKP_FIX_CONST( VARIABLE_HP_MAX_FREQ, 0 ) ); + cutoff_Hz = SKP_LIMIT_32( cutoff_Hz, SILK_FIX_CONST( VARIABLE_HP_MIN_CUTOFF_HZ, 0 ), SILK_FIX_CONST( VARIABLE_HP_MAX_CUTOFF_HZ, 0 ) ); /********************************/ /* Compute Filter Coefficients */ /********************************/ - /* compute cut-off frequency, in radians */ - //Fc_num = (SKP_float)( 0.45f * 2.0f * 3.14159265359 * pitch_freq_low_Hz ); - //Fc_denom = (SKP_float)( 1e3f * psEncC->fs_kHz ); - SKP_assert( pitch_freq_low_Hz <= SKP_int32_MAX / SKP_RADIANS_CONSTANT_Q19 ); - Fc_Q19 = SKP_DIV32_16( SKP_SMULBB( SKP_RADIANS_CONSTANT_Q19, pitch_freq_low_Hz ), psEncC->fs_kHz ); // range: 3704 - 27787, 11-15 bits - SKP_assert( Fc_Q19 >= 3704 ); - SKP_assert( Fc_Q19 <= 27787 ); + /* compute cut-off frequency, in radians */ + /* Fc_num = 1.5 * 3.14159 * cutoff_Hz */ + /* Fc_denom = 1e3f * psEncC1->fs_kHz */ + SKP_assert( cutoff_Hz <= SKP_int32_MAX / SILK_FIX_CONST( 1.5 * 3.14159 / 1000, 19 ) ); + Fc_Q19 = SKP_DIV32_16( SKP_SMULBB( SILK_FIX_CONST( 1.5 * 3.14159 / 1000, 19 ), cutoff_Hz ), psEncC1->fs_kHz ); + SKP_assert( Fc_Q19 > 0 && Fc_Q19 < 32768 ); - r_Q28 = SKP_FIX_CONST( 1.0, 28 ) - SKP_MUL( SKP_FIX_CONST( 0.92, 9 ), Fc_Q19 ); - SKP_assert( r_Q28 >= 255347779 ); - SKP_assert( r_Q28 <= 266690872 ); + r_Q28 = SILK_FIX_CONST( 1.0, 28 ) - SKP_MUL( SILK_FIX_CONST( 0.92, 9 ), Fc_Q19 ); /* b = r * [ 1; -2; 1 ]; */ /* a = [ 1; -2 * r * ( 1 - 0.5 * Fc^2 ); r^2 ]; */ @@ -105,13 +100,17 @@ void SKP_Silk_HP_variable_cutoff( B_Q28[ 1 ] = SKP_LSHIFT( -r_Q28, 1 ); B_Q28[ 2 ] = r_Q28; - // -r * ( 2 - Fc * Fc ); + /* -r * ( 2 - Fc * Fc ); */ r_Q22 = SKP_RSHIFT( r_Q28, 6 ); - A_Q28[ 0 ] = SKP_SMULWW( r_Q22, SKP_SMULWW( Fc_Q19, Fc_Q19 ) - SKP_FIX_CONST( 2.0, 22 ) ); + A_Q28[ 0 ] = SKP_SMULWW( r_Q22, SKP_SMULWW( Fc_Q19, Fc_Q19 ) - SILK_FIX_CONST( 2.0, 22 ) ); A_Q28[ 1 ] = SKP_SMULWW( r_Q22, r_Q22 ); /********************************/ /* High-Pass Filter */ /********************************/ - SKP_Silk_biquad_alt( in, B_Q28, A_Q28, psEncC->In_HP_State, out, frame_length ); + silk_biquad_alt( psEncC1->inputBuf, B_Q28, A_Q28, psEncC1->In_HP_State, psEncC1->inputBuf, psEncC1->frame_length ); + if( nChannels == 2 ) { + silk_biquad_alt( state_Fxx[ 1 ].sCmn.inputBuf, B_Q28, A_Q28, state_Fxx[ 1 ].sCmn.In_HP_State, + state_Fxx[ 1 ].sCmn.inputBuf, state_Fxx[ 1 ].sCmn.frame_length ); + } } diff --git a/silk/SKP_Silk_Inlines.h b/silk/silk_Inlines.h similarity index 76% rename from silk/SKP_Silk_Inlines.h rename to silk/silk_Inlines.h index 49c69e58..5df42de8 100644 --- a/silk/SKP_Silk_Inlines.h +++ b/silk/silk_Inlines.h @@ -25,12 +25,12 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -/*! \file SKP_Silk_Inlines.h - * \brief SKP_Silk_Inlines.h defines inline signal processing functions. +/*! \file silk_Inlines.h + * \brief silk_Inlines.h defines inline signal processing functions. */ -#ifndef _SKP_SILK_FIX_INLINES_H_ -#define _SKP_SILK_FIX_INLINES_H_ +#ifndef _SILK_FIX_INLINES_H_ +#define _SILK_FIX_INLINES_H_ #ifdef __cplusplus extern "C" @@ -38,35 +38,35 @@ extern "C" #endif /* count leading zeros of SKP_int64 */ -SKP_INLINE SKP_int32 SKP_Silk_CLZ64(SKP_int64 in) +SKP_INLINE SKP_int32 silk_CLZ64(SKP_int64 in) { SKP_int32 in_upper; in_upper = (SKP_int32)SKP_RSHIFT64(in, 32); if (in_upper == 0) { /* Search in the lower 32 bits */ - return 32 + SKP_Silk_CLZ32( (SKP_int32) in ); + return 32 + silk_CLZ32( (SKP_int32) in ); } else { /* Search in the upper 32 bits */ - return SKP_Silk_CLZ32( in_upper ); + return silk_CLZ32( in_upper ); } } /* get number of leading zeros and fractional part (the bits right after the leading one */ -SKP_INLINE void SKP_Silk_CLZ_FRAC(SKP_int32 in, /* I: input */ +SKP_INLINE void silk_CLZ_FRAC(SKP_int32 in, /* I: input */ SKP_int32 *lz, /* O: number of leading zeros */ SKP_int32 *frac_Q7) /* O: the 7 bits right after the leading one */ { - SKP_int32 lzeros = SKP_Silk_CLZ32(in); + SKP_int32 lzeros = silk_CLZ32(in); * lz = lzeros; - * frac_Q7 = SKP_ROR32(in, 24 - lzeros) & 0x7f; + * frac_Q7 = silk_ROR32(in, 24 - lzeros) & 0x7f; } /* Approximation of square root */ /* Accuracy: < +/- 10% for output values > 15 */ /* < +/- 2.5% for output values > 120 */ -SKP_INLINE SKP_int32 SKP_Silk_SQRT_APPROX(SKP_int32 x) +SKP_INLINE SKP_int32 silk_SQRT_APPROX(SKP_int32 x) { SKP_int32 y, lz, frac_Q7; @@ -74,7 +74,7 @@ SKP_INLINE SKP_int32 SKP_Silk_SQRT_APPROX(SKP_int32 x) return 0; } - SKP_Silk_CLZ_FRAC(x, &lz, &frac_Q7); + silk_CLZ_FRAC(x, &lz, &frac_Q7); if( lz & 1 ) { y = 32768; @@ -91,35 +91,8 @@ SKP_INLINE SKP_int32 SKP_Silk_SQRT_APPROX(SKP_int32 x) return y; } -/* returns the number of left shifts before overflow for a 16 bit number (ITU definition with norm(0)=0) */ -SKP_INLINE SKP_int32 SKP_Silk_norm16(SKP_int16 a) { - - SKP_int32 a32; - - /* if ((a == 0) || (a == SKP_int16_MIN)) return(0); */ - if ((a << 1) == 0) return(0); - - a32 = a; - /* if (a32 < 0) a32 = -a32 - 1; */ - a32 ^= SKP_RSHIFT(a32, 31); - - return SKP_Silk_CLZ32(a32) - 17; -} - -/* returns the number of left shifts before overflow for a 32 bit number (ITU definition with norm(0)=0) */ -SKP_INLINE SKP_int32 SKP_Silk_norm32(SKP_int32 a) { - - /* if ((a == 0) || (a == SKP_int32_MIN)) return(0); */ - if ((a << 1) == 0) return(0); - - /* if (a < 0) a = -a - 1; */ - a ^= SKP_RSHIFT(a, 31); - - return SKP_Silk_CLZ32(a) - 1; -} - /* Divide two int32 values and return result as int32 in a given Q-domain */ -SKP_INLINE SKP_int32 SKP_DIV32_varQ( /* O returns a good approximation of "(a32 << Qres) / b32" */ +SKP_INLINE SKP_int32 silk_DIV32_varQ( /* O returns a good approximation of "(a32 << Qres) / b32" */ const SKP_int32 a32, /* I numerator (Q0) */ const SKP_int32 b32, /* I denominator (Q0) */ const SKP_int Qres /* I Q-domain of result (>= 0) */ @@ -132,9 +105,9 @@ SKP_INLINE SKP_int32 SKP_DIV32_varQ( /* O returns a good approximation of SKP_assert( Qres >= 0 ); /* Compute number of bits head room and normalize inputs */ - a_headrm = SKP_Silk_CLZ32( SKP_abs(a32) ) - 1; + a_headrm = silk_CLZ32( SKP_abs(a32) ) - 1; a32_nrm = SKP_LSHIFT(a32, a_headrm); /* Q: a_headrm */ - b_headrm = SKP_Silk_CLZ32( SKP_abs(b32) ) - 1; + b_headrm = silk_CLZ32( SKP_abs(b32) ) - 1; b32_nrm = SKP_LSHIFT(b32, b_headrm); /* Q: b_headrm */ /* Inverse of b32, with 14 bits of precision */ @@ -164,7 +137,7 @@ SKP_INLINE SKP_int32 SKP_DIV32_varQ( /* O returns a good approximation of } /* Invert int32 value and return result as int32 in a given Q-domain */ -SKP_INLINE SKP_int32 SKP_INVERSE32_varQ( /* O returns a good approximation of "(1 << Qres) / b32" */ +SKP_INLINE SKP_int32 silk_INVERSE32_varQ( /* O returns a good approximation of "(1 << Qres) / b32" */ const SKP_int32 b32, /* I denominator (Q0) */ const SKP_int Qres /* I Q-domain of result (> 0) */ ) @@ -176,7 +149,7 @@ SKP_INLINE SKP_int32 SKP_INVERSE32_varQ( /* O returns a good approximation SKP_assert( Qres > 0 ); /* Compute number of bits head room and normalize input */ - b_headrm = SKP_Silk_CLZ32( SKP_abs(b32) ) - 1; + b_headrm = silk_CLZ32( SKP_abs(b32) ) - 1; b32_nrm = SKP_LSHIFT(b32, b_headrm); /* Q: b_headrm */ /* Inverse of b32, with 14 bits of precision */ @@ -209,4 +182,4 @@ SKP_INLINE SKP_int32 SKP_INVERSE32_varQ( /* O returns a good approximation } #endif -#endif //_SKP_SILK_FIX_INLINES_H_ +#endif //_SILK_FIX_INLINES_H_ diff --git a/silk/SKP_Silk_LPC_analysis_filter.c b/silk/silk_LPC_analysis_filter.c similarity index 96% rename from silk/SKP_Silk_LPC_analysis_filter.c rename to silk/silk_LPC_analysis_filter.c index ba9475b4..b3f9ad75 100644 --- a/silk/SKP_Silk_LPC_analysis_filter.c +++ b/silk/silk_LPC_analysis_filter.c @@ -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. ***********************************************************************/ -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_SigProc_FIX.h" /*******************************************/ /* LPC analysis filter */ @@ -34,7 +34,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* first Order output samples are not set */ /*******************************************/ -void SKP_Silk_LPC_analysis_filter( +void silk_LPC_analysis_filter( SKP_int16 *out, /* O: Output signal */ const SKP_int16 *in, /* I: Input signal */ const SKP_int16 *B, /* I: MA prediction coefficients, Q12 [order] */ diff --git a/silk/SKP_Silk_LPC_inv_pred_gain.c b/silk/silk_LPC_inv_pred_gain.c similarity index 80% rename from silk/SKP_Silk_LPC_inv_pred_gain.c rename to silk/silk_LPC_inv_pred_gain.c index 06aaa198..08575d71 100644 --- a/silk/SKP_Silk_LPC_inv_pred_gain.c +++ b/silk/silk_LPC_inv_pred_gain.c @@ -25,24 +25,16 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -/* * - * SKP_Silk_LPC_inverse_pred_gain.c * - * * - * Compute inverse of LPC prediction gain, and * - * test if LPC coefficients are stable (all poles within unit circle) * - * * - * Copyright 2008 (c), Skype Limited * - * */ -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_SigProc_FIX.h" #define QA 16 -#define A_LIMIT SKP_FIX_CONST( 0.99975, QA ) +#define A_LIMIT SILK_FIX_CONST( 0.99975, QA ) /* Compute inverse of LPC prediction gain, and */ /* test if LPC coefficients are stable (all poles within unit circle) */ static SKP_int LPC_inverse_pred_gain_QA( /* O: Returns 1 if unstable, otherwise 0 */ SKP_int32 *invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */ - SKP_int32 A_QA[ 2 ][ SKP_Silk_MAX_ORDER_LPC ], + SKP_int32 A_QA[ 2 ][ SILK_MAX_ORDER_LPC ], /* I: Prediction coefficients */ const SKP_int order /* I: Prediction order */ ) @@ -69,7 +61,7 @@ static SKP_int LPC_inverse_pred_gain_QA( /* O: Returns 1 if unstable, o SKP_assert( rc_mult1_Q30 < ( 1 << 30 ) ); /* rc_mult2_Q16 range: [ 2^16 : SKP_int32_MAX ] */ - rc_mult2_Q16 = SKP_INVERSE32_varQ( rc_mult1_Q30, 46 ); /* 16 = 46 - 30 */ + rc_mult2_Q16 = silk_INVERSE32_varQ( rc_mult1_Q30, 46 ); /* 16 = 46 - 30 */ /* Update inverse gain */ /* invGain_Q30 range: [ 0 : 2^30 ] */ @@ -82,7 +74,7 @@ static SKP_int LPC_inverse_pred_gain_QA( /* O: Returns 1 if unstable, o Anew_QA = A_QA[ k & 1 ]; /* Update AR coefficient */ - headrm = SKP_Silk_CLZ32( rc_mult2_Q16 ) - 1; + headrm = silk_CLZ32( rc_mult2_Q16 ) - 1; rc_mult2_Q16 = SKP_LSHIFT( rc_mult2_Q16, headrm ); /* Q: 16 + headrm */ for( n = 0; n < k; n++ ) { tmp_QA = Aold_QA[ n ] - SKP_LSHIFT( SKP_SMMUL( Aold_QA[ k - n - 1 ], rc_Q31 ), 1 ); @@ -111,14 +103,14 @@ static SKP_int LPC_inverse_pred_gain_QA( /* O: Returns 1 if unstable, o } /* For input in Q12 domain */ -SKP_int SKP_Silk_LPC_inverse_pred_gain( /* O: Returns 1 if unstable, otherwise 0 */ +SKP_int silk_LPC_inverse_pred_gain( /* O: Returns 1 if unstable, otherwise 0 */ SKP_int32 *invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */ const SKP_int16 *A_Q12, /* I: Prediction coefficients, Q12 [order] */ const SKP_int order /* I: Prediction order */ ) { SKP_int k; - SKP_int32 Atmp_QA[ 2 ][ SKP_Silk_MAX_ORDER_LPC ]; + SKP_int32 Atmp_QA[ 2 ][ SILK_MAX_ORDER_LPC ]; SKP_int32 *Anew_QA; Anew_QA = Atmp_QA[ order & 1 ]; @@ -132,14 +124,14 @@ SKP_int SKP_Silk_LPC_inverse_pred_gain( /* O: Returns 1 if unstable, oth } /* For input in Q13 domain */ -SKP_int SKP_Silk_LPC_inverse_pred_gain_Q13( /* O: Returns 1 if unstable, otherwise 0 */ +SKP_int silk_LPC_inverse_pred_gain_Q13( /* O: Returns 1 if unstable, otherwise 0 */ SKP_int32 *invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */ const SKP_int16 *A_Q13, /* I: Prediction coefficients, Q13 [order] */ const SKP_int order /* I: Prediction order */ ) { SKP_int k; - SKP_int32 Atmp_QA[ 2 ][ SKP_Silk_MAX_ORDER_LPC ]; + SKP_int32 Atmp_QA[ 2 ][ SILK_MAX_ORDER_LPC ]; SKP_int32 *Anew_QA; Anew_QA = Atmp_QA[ order & 1 ]; @@ -153,14 +145,14 @@ SKP_int SKP_Silk_LPC_inverse_pred_gain_Q13( /* O: Returns 1 if unstable, oth } /* For input in Q24 domain */ -SKP_int SKP_Silk_LPC_inverse_pred_gain_Q24( /* O: Returns 1 if unstable, otherwise 0 */ +SKP_int silk_LPC_inverse_pred_gain_Q24( /* O: Returns 1 if unstable, otherwise 0 */ SKP_int32 *invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */ const SKP_int32 *A_Q24, /* I: Prediction coefficients, Q24 [order] */ const SKP_int order /* I: Prediction order */ ) { SKP_int k; - SKP_int32 Atmp_QA[ 2 ][ SKP_Silk_MAX_ORDER_LPC ]; + SKP_int32 Atmp_QA[ 2 ][ SILK_MAX_ORDER_LPC ]; SKP_int32 *Anew_QA; Anew_QA = Atmp_QA[ order & 1 ]; diff --git a/silk/SKP_Silk_LPC_stabilize.c b/silk/silk_LPC_stabilize.c similarity index 90% rename from silk/SKP_Silk_LPC_stabilize.c rename to silk/silk_LPC_stabilize.c index 3dd58470..ca1a1154 100644 --- a/silk/SKP_Silk_LPC_stabilize.c +++ b/silk/silk_LPC_stabilize.c @@ -25,13 +25,13 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_typedef.h" -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_typedef.h" +#include "silk_SigProc_FIX.h" #define LPC_STABILIZE_LPC_MAX_ABS_VALUE_Q16 ( ( (SKP_int32)SKP_int16_MAX ) << 4 ) /* LPC stabilizer, for a single input data vector */ -void SKP_Silk_LPC_stabilize( +void silk_LPC_stabilize( SKP_int16 *a_Q12, /* O stabilized LPC vector [L] */ SKP_int32 *a_Q16, /* I LPC vector [L] */ const SKP_int32 bwe_Q16, /* I Bandwidth expansion factor */ @@ -42,7 +42,7 @@ void SKP_Silk_LPC_stabilize( SKP_int i, idx = 0; SKP_int32 invGain_Q30; - SKP_Silk_bwexpander_32( a_Q16, L, bwe_Q16 ); + silk_bwexpander_32( a_Q16, L, bwe_Q16 ); /***************************/ /* Limit range of the LPCs */ @@ -66,7 +66,7 @@ void SKP_Silk_LPC_stabilize( sc_Q16 = SKP_DIV32( sc_Q16, idx + 1 ); sc_Q16 = 65536 - sc_Q16; sc_Q16 = SKP_LSHIFT( SKP_SMULWB( sc_Q16, 32604 ), 1 ); // 0.995 in Q16 - SKP_Silk_bwexpander_32( a_Q16, L, sc_Q16 ); + silk_bwexpander_32( a_Q16, L, sc_Q16 ); } else { break; } @@ -80,12 +80,12 @@ void SKP_Silk_LPC_stabilize( /**********************/ /* Ensure stable LPCs */ /**********************/ - while( SKP_Silk_LPC_inverse_pred_gain( &invGain_Q30, a_Q12, L ) == 1 ) { - SKP_Silk_bwexpander( a_Q12, L, 65339 ); // 0.997 in Q16 + while( silk_LPC_inverse_pred_gain( &invGain_Q30, a_Q12, L ) == 1 ) { + silk_bwexpander( a_Q12, L, 65339 ); // 0.997 in Q16 } } -void SKP_Silk_LPC_fit( +void silk_LPC_fit( SKP_int16 *a_QQ, /* O Stabilized LPC vector, Q(24-rshift) [L] */ SKP_int32 *a_Q24, /* I LPC vector [L] */ const SKP_int QQ, /* I Q domain of output LPC vector */ @@ -119,7 +119,7 @@ void SKP_Silk_LPC_fit( maxabs = SKP_min( maxabs, 98369 ); // ( SKP_int32_MAX / ( 65470 >> 2 ) ) + SKP_int16_MAX = 98369 sc_Q16 = 65470 - SKP_DIV32( SKP_MUL( 65470 >> 2, maxabs - SKP_int16_MAX ), SKP_RSHIFT32( SKP_MUL( maxabs, idx + 1), 2 ) ); - SKP_Silk_bwexpander_32( a_Q24, L, sc_Q16 ); + silk_bwexpander_32( a_Q24, L, sc_Q16 ); } else { break; } diff --git a/silk/SKP_Silk_LPC_synthesis_filter.c b/silk/silk_LPC_synthesis_filter.c similarity index 94% rename from silk/SKP_Silk_LPC_synthesis_filter.c rename to silk/silk_LPC_synthesis_filter.c index e5f8d24a..5f95a180 100644 --- a/silk/SKP_Silk_LPC_synthesis_filter.c +++ b/silk/silk_LPC_synthesis_filter.c @@ -26,15 +26,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ /* * - * SKP_Silk_LPC_synthesis_filter.c * + * silk_LPC_synthesis_filter.c * * Coefficients are in Q12 * * * * even order AR filter * * */ -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_SigProc_FIX.h" /* even order AR filter */ -void SKP_Silk_LPC_synthesis_filter( +void silk_LPC_synthesis_filter( const SKP_int16 *in, /* I: excitation signal */ const SKP_int16 *A_Q12, /* I: AR coefficients [Order], between -8_Q0 and 8_Q0 */ const SKP_int32 Gain_Q26, /* I: gain */ diff --git a/silk/SKP_Silk_LPC_synthesis_order16.c b/silk/silk_LPC_synthesis_order16.c similarity index 94% rename from silk/SKP_Silk_LPC_synthesis_order16.c rename to silk/silk_LPC_synthesis_order16.c index 82d8afd9..f35b9a95 100644 --- a/silk/SKP_Silk_LPC_synthesis_order16.c +++ b/silk/silk_LPC_synthesis_order16.c @@ -26,15 +26,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ /* * - * SKP_Silk_LPC_synthesis_order16.c * + * silk_LPC_synthesis_order16.c * * Coefficients are in Q12 * * * * 16th order AR filter * * */ -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_SigProc_FIX.h" /* 16th order AR filter */ -void SKP_Silk_LPC_synthesis_order16(const SKP_int16 *in, /* I: excitation signal */ +void silk_LPC_synthesis_order16(const SKP_int16 *in, /* I: excitation signal */ const SKP_int16 *A_Q12, /* I: AR coefficients [16], between -8_Q0 and 8_Q0 */ const SKP_int32 Gain_Q26, /* I: gain */ SKP_int32 *S, /* I/O: state vector [16] */ diff --git a/silk/SKP_Silk_LP_variable_cutoff.c b/silk/silk_LP_variable_cutoff.c similarity index 72% rename from silk/SKP_Silk_LP_variable_cutoff.c rename to silk/silk_LP_variable_cutoff.c index 7654c50b..61659790 100644 --- a/silk/SKP_Silk_LP_variable_cutoff.c +++ b/silk/silk_LP_variable_cutoff.c @@ -32,10 +32,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. [0.95 : 0.15 : 0.35] normalized cut off frequencies. */ -#include "SKP_Silk_main.h" +#include "silk_main.h" /* Helper function, interpolates the filter taps */ -SKP_INLINE void SKP_Silk_LP_interpolate_filter_taps( +SKP_INLINE void silk_LP_interpolate_filter_taps( SKP_int32 B_Q28[ TRANSITION_NB ], SKP_int32 A_Q28[ TRANSITION_NA ], const SKP_int ind, @@ -50,16 +50,16 @@ SKP_INLINE void SKP_Silk_LP_interpolate_filter_taps( /* Piece-wise linear interpolation of B and A */ for( nb = 0; nb < TRANSITION_NB; nb++ ) { B_Q28[ nb ] = SKP_SMLAWB( - SKP_Silk_Transition_LP_B_Q28[ ind ][ nb ], - SKP_Silk_Transition_LP_B_Q28[ ind + 1 ][ nb ] - - SKP_Silk_Transition_LP_B_Q28[ ind ][ nb ], + silk_Transition_LP_B_Q28[ ind ][ nb ], + silk_Transition_LP_B_Q28[ ind + 1 ][ nb ] - + silk_Transition_LP_B_Q28[ ind ][ nb ], fac_Q16 ); } for( na = 0; na < TRANSITION_NA; na++ ) { A_Q28[ na ] = SKP_SMLAWB( - SKP_Silk_Transition_LP_A_Q28[ ind ][ na ], - SKP_Silk_Transition_LP_A_Q28[ ind + 1 ][ na ] - - SKP_Silk_Transition_LP_A_Q28[ ind ][ na ], + silk_Transition_LP_A_Q28[ ind ][ na ], + silk_Transition_LP_A_Q28[ ind + 1 ][ na ] - + silk_Transition_LP_A_Q28[ ind ][ na ], fac_Q16 ); } } else { /* ( fac_Q16 - ( 1 << 16 ) ) is in range of a 16-bit int */ @@ -67,26 +67,26 @@ SKP_INLINE void SKP_Silk_LP_interpolate_filter_taps( /* Piece-wise linear interpolation of B and A */ for( nb = 0; nb < TRANSITION_NB; nb++ ) { B_Q28[ nb ] = SKP_SMLAWB( - SKP_Silk_Transition_LP_B_Q28[ ind + 1 ][ nb ], - SKP_Silk_Transition_LP_B_Q28[ ind + 1 ][ nb ] - - SKP_Silk_Transition_LP_B_Q28[ ind ][ nb ], + silk_Transition_LP_B_Q28[ ind + 1 ][ nb ], + silk_Transition_LP_B_Q28[ ind + 1 ][ nb ] - + silk_Transition_LP_B_Q28[ ind ][ nb ], fac_Q16 - ( 1 << 16 ) ); } for( na = 0; na < TRANSITION_NA; na++ ) { A_Q28[ na ] = SKP_SMLAWB( - SKP_Silk_Transition_LP_A_Q28[ ind + 1 ][ na ], - SKP_Silk_Transition_LP_A_Q28[ ind + 1 ][ na ] - - SKP_Silk_Transition_LP_A_Q28[ ind ][ na ], + silk_Transition_LP_A_Q28[ ind + 1 ][ na ], + silk_Transition_LP_A_Q28[ ind + 1 ][ na ] - + silk_Transition_LP_A_Q28[ ind ][ na ], fac_Q16 - ( 1 << 16 ) ); } } } else { - SKP_memcpy( B_Q28, SKP_Silk_Transition_LP_B_Q28[ ind ], TRANSITION_NB * sizeof( SKP_int32 ) ); - SKP_memcpy( A_Q28, SKP_Silk_Transition_LP_A_Q28[ ind ], TRANSITION_NA * sizeof( SKP_int32 ) ); + SKP_memcpy( B_Q28, silk_Transition_LP_B_Q28[ ind ], TRANSITION_NB * sizeof( SKP_int32 ) ); + SKP_memcpy( A_Q28, silk_Transition_LP_A_Q28[ ind ], TRANSITION_NA * sizeof( SKP_int32 ) ); } } else { - SKP_memcpy( B_Q28, SKP_Silk_Transition_LP_B_Q28[ TRANSITION_INT_NUM - 1 ], TRANSITION_NB * sizeof( SKP_int32 ) ); - SKP_memcpy( A_Q28, SKP_Silk_Transition_LP_A_Q28[ TRANSITION_INT_NUM - 1 ], TRANSITION_NA * sizeof( SKP_int32 ) ); + SKP_memcpy( B_Q28, silk_Transition_LP_B_Q28[ TRANSITION_INT_NUM - 1 ], TRANSITION_NB * sizeof( SKP_int32 ) ); + SKP_memcpy( A_Q28, silk_Transition_LP_A_Q28[ TRANSITION_INT_NUM - 1 ], TRANSITION_NA * sizeof( SKP_int32 ) ); } } @@ -94,8 +94,8 @@ SKP_INLINE void SKP_Silk_LP_interpolate_filter_taps( /* piece-wise linear interpolation between elliptic filters */ /* Start by setting psEncC->mode <> 0; */ /* Deactivate by setting psEncC->mode = 0; */ -void SKP_Silk_LP_variable_cutoff( - SKP_Silk_LP_state *psLP, /* I/O LP filter state */ +void silk_LP_variable_cutoff( + silk_LP_state *psLP, /* I/O LP filter state */ SKP_int16 *signal, /* I/O Low-pass filtered output signal */ const SKP_int frame_length /* I Frame length */ ) @@ -120,13 +120,13 @@ void SKP_Silk_LP_variable_cutoff( SKP_assert( ind < TRANSITION_INT_NUM ); /* Interpolate filter coefficients */ - SKP_Silk_LP_interpolate_filter_taps( B_Q28, A_Q28, ind, fac_Q16 ); + silk_LP_interpolate_filter_taps( B_Q28, A_Q28, ind, fac_Q16 ); /* Update transition frame number for next frame */ psLP->transition_frame_no = SKP_LIMIT( psLP->transition_frame_no + psLP->mode, 0, TRANSITION_FRAMES ); /* ARMA low-pass filtering */ SKP_assert( TRANSITION_NB == 3 && TRANSITION_NA == 2 ); - SKP_Silk_biquad_alt( signal, B_Q28, A_Q28, psLP->In_LP_State, signal, frame_length ); + silk_biquad_alt( signal, B_Q28, A_Q28, psLP->In_LP_State, signal, frame_length ); } } diff --git a/silk/SKP_Silk_MacroCount.h b/silk/silk_MacroCount.h similarity index 100% rename from silk/SKP_Silk_MacroCount.h rename to silk/silk_MacroCount.h diff --git a/silk/SKP_Silk_MacroDebug.h b/silk/silk_MacroDebug.h similarity index 100% rename from silk/SKP_Silk_MacroDebug.h rename to silk/silk_MacroDebug.h diff --git a/silk/SKP_Silk_NLSF2A.c b/silk/silk_NLSF2A.c similarity index 87% rename from silk/SKP_Silk_NLSF2A.c rename to silk/silk_NLSF2A.c index b8b04ca5..21251cf7 100644 --- a/silk/SKP_Silk_NLSF2A.c +++ b/silk/silk_NLSF2A.c @@ -29,12 +29,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* order should be even */ /* a piecewise linear approximation maps LSF <-> cos(LSF) */ /* therefore the result is not accurate LSFs, but the two */ -/* function are accurate inverses of each other */ +/* functions are accurate inverses of each other */ -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_SigProc_FIX.h" +#include "silk_tables.h" /* helper function for NLSF2A(..) */ -SKP_INLINE void SKP_Silk_NLSF2A_find_poly( +SKP_INLINE void silk_NLSF2A_find_poly( SKP_int32 *out, /* o intermediate polynomial, Q20 */ const SKP_int32 *cLSF, /* i vector of interleaved 2*cos(LSFs), Q20 */ SKP_int dd /* i polynomial order (= 1/2 * filter order) */ @@ -56,20 +57,20 @@ SKP_INLINE void SKP_Silk_NLSF2A_find_poly( } /* compute whitening filter coefficients from normalized line spectral frequencies */ -void SKP_Silk_NLSF2A( +void silk_NLSF2A( SKP_int16 *a, /* o monic whitening filter coefficients in Q12, [d] */ const SKP_int16 *NLSF, /* i normalized line spectral frequencies in Q15, [d] */ const SKP_int d /* i filter order (should be even) */ ) { SKP_int k, i, dd; - SKP_int32 cos_LSF_Q20[SKP_Silk_MAX_ORDER_LPC]; - SKP_int32 P[SKP_Silk_MAX_ORDER_LPC/2+1], Q[SKP_Silk_MAX_ORDER_LPC/2+1]; + SKP_int32 cos_LSF_Q20[SILK_MAX_ORDER_LPC]; + SKP_int32 P[SILK_MAX_ORDER_LPC/2+1], Q[SILK_MAX_ORDER_LPC/2+1]; SKP_int32 Ptmp, Qtmp; SKP_int32 f_int; SKP_int32 f_frac; SKP_int32 cos_val, delta; - SKP_int32 a_int32[SKP_Silk_MAX_ORDER_LPC]; + SKP_int32 a_int32[SILK_MAX_ORDER_LPC]; SKP_int32 maxabs, absval, idx=0, sc_Q16; SKP_assert( LSF_COS_TAB_SZ_FIX == 128 ); @@ -89,8 +90,8 @@ void SKP_Silk_NLSF2A( SKP_assert(f_int < LSF_COS_TAB_SZ_FIX ); /* Read start and end value from table */ - cos_val = SKP_Silk_LSFCosTab_FIX_Q12[ f_int ]; /* Q12 */ - delta = SKP_Silk_LSFCosTab_FIX_Q12[ f_int + 1 ] - cos_val; /* Q12, with a range of 0..200 */ + cos_val = silk_LSFCosTab_FIX_Q12[ f_int ]; /* Q12 */ + delta = silk_LSFCosTab_FIX_Q12[ f_int + 1 ] - cos_val; /* Q12, with a range of 0..200 */ /* Linear interpolation */ cos_LSF_Q20[k] = SKP_LSHIFT( cos_val, 8 ) + SKP_MUL( delta, f_frac ); /* Q20 */ @@ -99,8 +100,8 @@ void SKP_Silk_NLSF2A( dd = SKP_RSHIFT( d, 1 ); /* generate even and odd polynomials using convolution */ - SKP_Silk_NLSF2A_find_poly( P, &cos_LSF_Q20[0], dd ); - SKP_Silk_NLSF2A_find_poly( Q, &cos_LSF_Q20[1], dd ); + silk_NLSF2A_find_poly( P, &cos_LSF_Q20[0], dd ); + silk_NLSF2A_find_poly( Q, &cos_LSF_Q20[1], dd ); /* convert even and odd polynomials to SKP_int32 Q12 filter coefs */ for( k = 0; k < dd; k++ ) { @@ -130,7 +131,7 @@ void SKP_Silk_NLSF2A( maxabs = SKP_min( maxabs, 98369 ); // ( SKP_int32_MAX / ( 65470 >> 2 ) ) + SKP_int16_MAX = 98369 sc_Q16 = 65470 - SKP_DIV32( SKP_MUL( 65470 >> 2, maxabs - SKP_int16_MAX ), SKP_RSHIFT32( SKP_MUL( maxabs, idx + 1), 2 ) ); - SKP_Silk_bwexpander_32( a_int32, d, sc_Q16 ); + silk_bwexpander_32( a_int32, d, sc_Q16 ); } else { break; } diff --git a/silk/SKP_Silk_NLSF2A_stable.c b/silk/silk_NLSF2A_stable.c similarity index 87% rename from silk/SKP_Silk_NLSF2A_stable.c rename to silk/silk_NLSF2A_stable.c index f4de4b43..b4b59ba1 100644 --- a/silk/SKP_Silk_NLSF2A_stable.c +++ b/silk/silk_NLSF2A_stable.c @@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" +#include "silk_main.h" /* Convert NLSF parameters to stable AR prediction filter coefficients */ -void SKP_Silk_NLSF2A_stable( +void silk_NLSF2A_stable( SKP_int16 pAR_Q12[ MAX_LPC_ORDER ], /* O Stabilized AR coefs [LPC_order] */ const SKP_int16 pNLSF[ MAX_LPC_ORDER ], /* I NLSF vector [LPC_order] */ const SKP_int LPC_order /* I LPC/LSF order */ @@ -37,12 +37,12 @@ void SKP_Silk_NLSF2A_stable( SKP_int i; SKP_int32 invGain_Q30; - SKP_Silk_NLSF2A( pAR_Q12, pNLSF, LPC_order ); + silk_NLSF2A( pAR_Q12, pNLSF, LPC_order ); /* Ensure stable LPCs */ for( i = 0; i < MAX_LPC_STABILIZE_ITERATIONS; i++ ) { - if( SKP_Silk_LPC_inverse_pred_gain( &invGain_Q30, pAR_Q12, LPC_order ) == 1 ) { - SKP_Silk_bwexpander( pAR_Q12, LPC_order, 65536 - SKP_SMULBB( 10 + i, i ) ); /* 10_Q16 = 0.00015 */ + if( silk_LPC_inverse_pred_gain( &invGain_Q30, pAR_Q12, LPC_order ) == 1 ) { + silk_bwexpander( pAR_Q12, LPC_order, 65536 - SKP_SMULBB( 10 + i, i ) ); /* 10_Q16 = 0.00015 */ } else { break; } diff --git a/silk/SKP_Silk_NLSF_VQ.c b/silk/silk_NLSF_VQ.c similarity index 96% rename from silk/SKP_Silk_NLSF_VQ.c rename to silk/silk_NLSF_VQ.c index 47e9cfe7..caecbcfb 100644 --- a/silk/SKP_Silk_NLSF_VQ.c +++ b/silk/silk_NLSF_VQ.c @@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" +#include "silk_main.h" /* Compute quantization errors for an LPC_order element input vector for a VQ codebook */ -void SKP_Silk_NLSF_VQ( +void silk_NLSF_VQ( SKP_int32 err_Q26[], /* O Quantization errors [K] */ const SKP_int16 in_Q15[], /* I Input vectors to be quantized [LPC_order] */ const SKP_uint8 pCB_Q8[], /* I Codebook vectors [K*LPC_order] */ diff --git a/silk/SKP_Silk_NLSF_VQ_weights_laroia.c b/silk/silk_NLSF_VQ_weights_laroia.c similarity index 96% rename from silk/SKP_Silk_NLSF_VQ_weights_laroia.c rename to silk/silk_NLSF_VQ_weights_laroia.c index e50736be..218f521f 100644 --- a/silk/SKP_Silk_NLSF_VQ_weights_laroia.c +++ b/silk/silk_NLSF_VQ_weights_laroia.c @@ -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. ***********************************************************************/ -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_SigProc_FIX.h" /* R. Laroia, N. Phamdo and N. Farvardin, "Robust and Efficient Quantization of Speech LSP @@ -36,7 +36,7 @@ Signal Processing, pp. 641-644, 1991. #define Q_OUT 5 /* Laroia low complexity NLSF weights */ -void SKP_Silk_NLSF_VQ_weights_laroia( +void silk_NLSF_VQ_weights_laroia( SKP_int16 *pNLSFW_Q5, /* O: Pointer to input vector weights [D x 1] */ const SKP_int16 *pNLSF_Q15, /* I: Pointer to input vector [D x 1] */ const SKP_int D /* I: Input vector dimension (even) */ diff --git a/silk/SKP_Silk_NLSF_decode.c b/silk/silk_NLSF_decode.c similarity index 80% rename from silk/SKP_Silk_NLSF_decode.c rename to silk/silk_NLSF_decode.c index ec8017e9..8951764a 100644 --- a/silk/SKP_Silk_NLSF_decode.c +++ b/silk/silk_NLSF_decode.c @@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" +#include "silk_main.h" /* Predictive dequantizer for NLSF residuals */ -void SKP_Silk_NLSF_residual_dequant( /* O Returns RD value in Q30 */ +void silk_NLSF_residual_dequant( /* O Returns RD value in Q30 */ SKP_int16 x_Q10[], /* O Output [ order ] */ const SKP_int8 indices[], /* I Quantization indices [ order ] */ const SKP_uint8 pred_coef_Q8[], /* I Backward predictor coefs [ order ] */ @@ -43,9 +43,9 @@ void SKP_Silk_NLSF_residual_dequant( /* O Returns RD v pred_Q10 = SKP_RSHIFT( SKP_SMULBB( out_Q10, (SKP_int16)pred_coef_Q8[ i ] ), 8 ); out_Q10 = SKP_LSHIFT( indices[ i ], 10 ); if( out_Q10 > 0 ) { - out_Q10 = SKP_SUB16( out_Q10, SKP_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); + out_Q10 = SKP_SUB16( out_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); } else if( out_Q10 < 0 ) { - out_Q10 = SKP_ADD16( out_Q10, SKP_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); + out_Q10 = SKP_ADD16( out_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); } out_Q10 = SKP_SMLAWB( pred_Q10, out_Q10, quant_step_size_Q16 ); x_Q10[ i ] = out_Q10; @@ -56,10 +56,10 @@ void SKP_Silk_NLSF_residual_dequant( /* O Returns RD v /***********************/ /* NLSF vector decoder */ /***********************/ -void SKP_Silk_NLSF_decode( +void silk_NLSF_decode( SKP_int16 *pNLSF_Q15, /* O Quantized NLSF vector [ LPC_ORDER ] */ SKP_int8 *NLSFIndices, /* I Codebook path vector [ LPC_ORDER + 1 ] */ - const SKP_Silk_NLSF_CB_struct *psNLSF_CB /* I Codebook object */ + const silk_NLSF_CB_struct *psNLSF_CB /* I Codebook object */ ) { SKP_int i; @@ -77,20 +77,20 @@ void SKP_Silk_NLSF_decode( } /* Unpack entropy table indices and predictor for current CB1 index */ - SKP_Silk_NLSF_unpack( ec_ix, pred_Q8, psNLSF_CB, NLSFIndices[ 0 ] ); + silk_NLSF_unpack( ec_ix, pred_Q8, psNLSF_CB, NLSFIndices[ 0 ] ); /* Trellis dequantizer */ - SKP_Silk_NLSF_residual_dequant( res_Q10, &NLSFIndices[ 1 ], pred_Q8, psNLSF_CB->quantStepSize_Q16, psNLSF_CB->order ); + silk_NLSF_residual_dequant( res_Q10, &NLSFIndices[ 1 ], pred_Q8, psNLSF_CB->quantStepSize_Q16, psNLSF_CB->order ); /* Weights from codebook vector */ - SKP_Silk_NLSF_VQ_weights_laroia( W_tmp_Q5, pNLSF_Q15, psNLSF_CB->order ); + silk_NLSF_VQ_weights_laroia( W_tmp_Q5, pNLSF_Q15, psNLSF_CB->order ); /* Apply inverse square-rooted weights and add to output */ for( i = 0; i < psNLSF_CB->order; i++ ) { - W_tmp_Q9 = SKP_Silk_SQRT_APPROX( SKP_LSHIFT( ( SKP_int32 )W_tmp_Q5[ i ], 13 ) ); + W_tmp_Q9 = silk_SQRT_APPROX( SKP_LSHIFT( ( SKP_int32 )W_tmp_Q5[ i ], 13 ) ); pNLSF_Q15[ i ] = SKP_ADD16( pNLSF_Q15[ i ], (SKP_int16)SKP_DIV32_16( SKP_LSHIFT( ( SKP_int32 )res_Q10[ i ], 14 ), W_tmp_Q9 ) ); } /* NLSF stabilization */ - SKP_Silk_NLSF_stabilize( pNLSF_Q15, psNLSF_CB->deltaMin_Q15, psNLSF_CB->order ); + silk_NLSF_stabilize( pNLSF_Q15, psNLSF_CB->deltaMin_Q15, psNLSF_CB->order ); } diff --git a/silk/SKP_Silk_NLSF_del_dec_quant.c b/silk/silk_NLSF_del_dec_quant.c similarity index 92% rename from silk/SKP_Silk_NLSF_del_dec_quant.c rename to silk/silk_NLSF_del_dec_quant.c index bf43014b..85c6cc30 100644 --- a/silk/SKP_Silk_NLSF_del_dec_quant.c +++ b/silk/silk_NLSF_del_dec_quant.c @@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" +#include "silk_main.h" /* Delayed-decision quantizer for NLSF residuals */ -SKP_int32 SKP_Silk_NLSF_del_dec_quant( /* O Returns RD value in Q25 */ +SKP_int32 silk_NLSF_del_dec_quant( /* O Returns RD value in Q25 */ SKP_int8 indices[], /* O Quantization indices [ order ] */ const SKP_int16 x_Q10[], /* I Input [ order ] */ const SKP_int16 w_Q5[], /* I Weights [ order ] */ @@ -72,15 +72,15 @@ SKP_int32 SKP_Silk_NLSF_del_dec_quant( /* O Returns RD value out0_Q10 = SKP_LSHIFT( ind_tmp, 10 ); out1_Q10 = SKP_ADD16( out0_Q10, 1024 ); if( ind_tmp > 0 ) { - out0_Q10 = SKP_SUB16( out0_Q10, SKP_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); - out1_Q10 = SKP_SUB16( out1_Q10, SKP_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); + out0_Q10 = SKP_SUB16( out0_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); + out1_Q10 = SKP_SUB16( out1_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); } else if( ind_tmp == 0 ) { - out1_Q10 = SKP_SUB16( out1_Q10, SKP_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); + out1_Q10 = SKP_SUB16( out1_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); } else if( ind_tmp == -1 ) { - out0_Q10 = SKP_ADD16( out0_Q10, SKP_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); + out0_Q10 = SKP_ADD16( out0_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); } else { - out0_Q10 = SKP_ADD16( out0_Q10, SKP_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); - out1_Q10 = SKP_ADD16( out1_Q10, SKP_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); + out0_Q10 = SKP_ADD16( out0_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); + out1_Q10 = SKP_ADD16( out1_Q10, SILK_FIX_CONST( NLSF_QUANT_LEVEL_ADJ, 10 ) ); } out0_Q10 = SKP_SMULWB( out0_Q10, quant_step_size_Q16 ); out1_Q10 = SKP_SMULWB( out1_Q10, quant_step_size_Q16 ); diff --git a/silk/SKP_Silk_NLSF_encode.c b/silk/silk_NLSF_encode.c similarity index 83% rename from silk/SKP_Silk_NLSF_encode.c rename to silk/silk_NLSF_encode.c index 965eb3c7..f0cfba37 100644 --- a/silk/SKP_Silk_NLSF_encode.c +++ b/silk/silk_NLSF_encode.c @@ -25,17 +25,17 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" +#include "silk_main.h" #define STORE_LSF_DATA_FOR_TRAINING 0 /***********************/ /* NLSF vector encoder */ /***********************/ -SKP_int32 SKP_Silk_NLSF_encode( /* O Returns RD value in Q25 */ +SKP_int32 silk_NLSF_encode( /* O Returns RD value in Q25 */ SKP_int8 *NLSFIndices, /* I Codebook path vector [ LPC_ORDER + 1 ] */ SKP_int16 *pNLSF_Q15, /* I/O Quantized NLSF vector [ LPC_ORDER ] */ - const SKP_Silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */ + const silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */ const SKP_int16 *pW_Q5, /* I NLSF weight vector [ LPC_ORDER ] */ const SKP_int NLSF_mu_Q20, /* I Rate weight for the RD optimization */ const SKP_int nSurvivors, /* I Max survivors after first stage */ @@ -71,13 +71,13 @@ SKP_int32 SKP_Silk_NLSF_encode( /* O Returns RD v SKP_assert( NLSF_mu_Q20 <= 32767 && NLSF_mu_Q20 >= 0 ); /* NLSF stabilization */ - SKP_Silk_NLSF_stabilize( pNLSF_Q15, psNLSF_CB->deltaMin_Q15, psNLSF_CB->order ); + silk_NLSF_stabilize( pNLSF_Q15, psNLSF_CB->deltaMin_Q15, psNLSF_CB->order ); /* First stage: VQ */ - SKP_Silk_NLSF_VQ( err_Q26, pNLSF_Q15, psNLSF_CB->CB1_NLSF_Q8, psNLSF_CB->nVectors, psNLSF_CB->order ); + silk_NLSF_VQ( err_Q26, pNLSF_Q15, psNLSF_CB->CB1_NLSF_Q8, psNLSF_CB->nVectors, psNLSF_CB->order ); /* Sort the quantization errors */ - SKP_Silk_insertion_sort_increasing( err_Q26, tempIndices1, psNLSF_CB->nVectors, nSurvivors ); + silk_insertion_sort_increasing( err_Q26, tempIndices1, psNLSF_CB->nVectors, nSurvivors ); /* Loop over survivors */ for( s = 0; s < nSurvivors; s++ ) { @@ -91,11 +91,11 @@ SKP_int32 SKP_Silk_NLSF_encode( /* O Returns RD v } /* Weights from codebook vector */ - SKP_Silk_NLSF_VQ_weights_laroia( W_tmp_Q5, NLSF_tmp_Q15, psNLSF_CB->order ); + silk_NLSF_VQ_weights_laroia( W_tmp_Q5, NLSF_tmp_Q15, psNLSF_CB->order ); /* Apply square-rooted weights */ for( i = 0; i < psNLSF_CB->order; i++ ) { - W_tmp_Q9 = SKP_Silk_SQRT_APPROX( SKP_LSHIFT( ( SKP_int32 )W_tmp_Q5[ i ], 13 ) ); + W_tmp_Q9 = silk_SQRT_APPROX( SKP_LSHIFT( ( SKP_int32 )W_tmp_Q5[ i ], 13 ) ); res_Q10[ i ] = ( SKP_int16 )SKP_RSHIFT( SKP_SMULBB( res_Q15[ i ], W_tmp_Q9 ), 14 ); } @@ -105,10 +105,10 @@ SKP_int32 SKP_Silk_NLSF_encode( /* O Returns RD v } /* Unpack entropy table indices and predictor for current CB1 index */ - SKP_Silk_NLSF_unpack( ec_ix, pred_Q8, psNLSF_CB, ind1 ); + silk_NLSF_unpack( ec_ix, pred_Q8, psNLSF_CB, ind1 ); /* Trellis quantizer */ - RD_Q25[ s ] = SKP_Silk_NLSF_del_dec_quant( &tempIndices2[ s * MAX_LPC_ORDER ], res_Q10, W_adj_Q5, pred_Q8, ec_ix, + RD_Q25[ s ] = silk_NLSF_del_dec_quant( &tempIndices2[ s * MAX_LPC_ORDER ], res_Q10, W_adj_Q5, pred_Q8, ec_ix, psNLSF_CB->ec_Rates_Q5, psNLSF_CB->quantStepSize_Q16, psNLSF_CB->invQuantStepSize_Q6, NLSF_mu_Q20, psNLSF_CB->order ); /* Add rate for first stage */ @@ -118,33 +118,33 @@ SKP_int32 SKP_Silk_NLSF_encode( /* O Returns RD v } else { prob_Q8 = iCDF_ptr[ ind1 - 1 ] - iCDF_ptr[ ind1 ]; } - bits_q7 = ( 8 << 7 ) - SKP_Silk_lin2log( prob_Q8 ); + bits_q7 = ( 8 << 7 ) - silk_lin2log( prob_Q8 ); RD_Q25[ s ] = SKP_SMLABB( RD_Q25[ s ], bits_q7, SKP_RSHIFT( NLSF_mu_Q20, 2 ) ); } /* Find the lowest rate-distortion error */ - SKP_Silk_insertion_sort_increasing( RD_Q25, &bestIndex, nSurvivors, 1 ); + silk_insertion_sort_increasing( RD_Q25, &bestIndex, nSurvivors, 1 ); NLSFIndices[ 0 ] = ( SKP_int8 )tempIndices1[ bestIndex ]; SKP_memcpy( &NLSFIndices[ 1 ], &tempIndices2[ bestIndex * MAX_LPC_ORDER ], psNLSF_CB->order * sizeof( SKP_int8 ) ); /* Decode */ - SKP_Silk_NLSF_decode( pNLSF_Q15, NLSFIndices, psNLSF_CB ); + silk_NLSF_decode( pNLSF_Q15, NLSFIndices, psNLSF_CB ); #if STORE_LSF_DATA_FOR_TRAINING { /* code for training the codebooks */ SKP_int32 RD_dec_Q22, Dist_Q22_dec, Rate_Q7, diff_Q15; ind1 = NLSFIndices[ 0 ]; - SKP_Silk_NLSF_unpack( ec_ix, pred_Q8, psNLSF_CB, ind1 ); + silk_NLSF_unpack( ec_ix, pred_Q8, psNLSF_CB, ind1 ); pCB_element = &psNLSF_CB->CB1_NLSF_Q8[ ind1 * psNLSF_CB->order ]; for( i = 0; i < psNLSF_CB->order; i++ ) { NLSF_tmp_Q15[ i ] = SKP_LSHIFT16( ( SKP_int16 )pCB_element[ i ], 7 ); } - SKP_Silk_NLSF_VQ_weights_laroia( W_tmp_Q5, NLSF_tmp_Q15, psNLSF_CB->order ); + silk_NLSF_VQ_weights_laroia( W_tmp_Q5, NLSF_tmp_Q15, psNLSF_CB->order ); for( i = 0; i < psNLSF_CB->order; i++ ) { - W_tmp_Q9 = SKP_Silk_SQRT_APPROX( SKP_LSHIFT( ( SKP_int32 )W_tmp_Q5[ i ], 13 ) ); + W_tmp_Q9 = silk_SQRT_APPROX( SKP_LSHIFT( ( SKP_int32 )W_tmp_Q5[ i ], 13 ) ); res_Q15[ i ] = pNLSF_Q15_orig[ i ] - NLSF_tmp_Q15[ i ]; res_Q10[ i ] = (SKP_int16)SKP_RSHIFT( SKP_SMULBB( res_Q15[ i ], W_tmp_Q9 ), 14 ); DEBUG_STORE_DATA( NLSF_res_q10.dat, &res_Q10[ i ], sizeof( SKP_int16 ) ); @@ -164,7 +164,7 @@ SKP_int32 SKP_Silk_NLSF_encode( /* O Returns RD v } else { prob_Q8 = iCDF_ptr[ ind1 - 1 ] - iCDF_ptr[ ind1 ]; } - Rate_Q7 = ( 8 << 7 ) - SKP_Silk_lin2log( prob_Q8 ); + Rate_Q7 = ( 8 << 7 ) - silk_lin2log( prob_Q8 ); for( i = 0; i < psNLSF_CB->order; i++ ) { Rate_Q7 += ((int)psNLSF_CB->ec_Rates_Q5[ ec_ix[ i ] + SKP_LIMIT( NLSFIndices[ i + 1 ] + NLSF_QUANT_MAX_AMPLITUDE, 0, 2 * NLSF_QUANT_MAX_AMPLITUDE ) ] ) << 2; if( SKP_abs( NLSFIndices[ i + 1 ] ) >= NLSF_QUANT_MAX_AMPLITUDE ) { diff --git a/silk/SKP_Silk_NLSF_stabilize.c b/silk/silk_NLSF_stabilize.c similarity index 95% rename from silk/SKP_Silk_NLSF_stabilize.c rename to silk/silk_NLSF_stabilize.c index 1e7def86..45f71cd0 100644 --- a/silk/SKP_Silk_NLSF_stabilize.c +++ b/silk/silk_NLSF_stabilize.c @@ -33,13 +33,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Euclidean distance to input vector */ /* - Output are sorted NLSF coefficients */ /* */ -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_SigProc_FIX.h" /* Constant Definitions */ #define MAX_LOOPS 20 /* NLSF stabilizer, for a single input data vector */ -void SKP_Silk_NLSF_stabilize( +void silk_NLSF_stabilize( SKP_int16 *NLSF_Q15, /* I/O: Unstable/stabilized normalized LSF vector in Q15 [L] */ const SKP_int16 *NDeltaMin_Q15, /* I: Normalized delta min vector in Q15, NDeltaMin_Q15[L] must be >= 1 [L+1] */ const SKP_int L /* I: Number of NLSF parameters in the input vector */ @@ -119,7 +119,7 @@ void SKP_Silk_NLSF_stabilize( /* Insertion sort (fast for already almost sorted arrays): */ /* Best case: O(n) for an already sorted array */ /* Worst case: O(n^2) for an inversely sorted array */ - SKP_Silk_insertion_sort_increasing_all_values_int16( &NLSF_Q15[0], L ); + silk_insertion_sort_increasing_all_values_int16( &NLSF_Q15[0], L ); /* First NLSF should be no less than NDeltaMin[0] */ NLSF_Q15[0] = SKP_max_int( NLSF_Q15[0], NDeltaMin_Q15[0] ); diff --git a/silk/SKP_Silk_NLSF_unpack.c b/silk/silk_NLSF_unpack.c similarity index 92% rename from silk/SKP_Silk_NLSF_unpack.c rename to silk/silk_NLSF_unpack.c index 4dd3a9c4..557277bf 100644 --- a/silk/SKP_Silk_NLSF_unpack.c +++ b/silk/silk_NLSF_unpack.c @@ -25,13 +25,13 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" +#include "silk_main.h" /* Unpack predictor values and indices for entropy coding tables */ -void SKP_Silk_NLSF_unpack( +void silk_NLSF_unpack( SKP_int16 ec_ix[], /* O Indices to entropy tales [ LPC_ORDER ] */ SKP_uint8 pred_Q8[], /* O LSF predictor [ LPC_ORDER ] */ - const SKP_Silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */ + const silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */ const SKP_int CB1_index /* I Index of vector in first LSF codebook */ ) { diff --git a/silk/SKP_Silk_NSQ.c b/silk/silk_NSQ.c similarity index 92% rename from silk/SKP_Silk_NSQ.c rename to silk/silk_NSQ.c index 90ea49bf..bf5f2042 100644 --- a/silk/SKP_Silk_NSQ.c +++ b/silk/silk_NSQ.c @@ -25,11 +25,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" +#include "silk_main.h" -SKP_INLINE void SKP_Silk_nsq_scale_states( - const SKP_Silk_encoder_state *psEncC, /* I Encoder State */ - SKP_Silk_nsq_state *NSQ, /* I/O NSQ state */ +SKP_INLINE void silk_nsq_scale_states( + const silk_encoder_state *psEncC, /* I Encoder State */ + silk_nsq_state *NSQ, /* I/O NSQ state */ const SKP_int16 x[], /* I input in Q0 */ SKP_int32 x_sc_Q10[], /* O input scaled with 1/Gain */ const SKP_int16 sLTP[], /* I re-whitened LTP state in Q0 */ @@ -40,8 +40,8 @@ SKP_INLINE void SKP_Silk_nsq_scale_states( const SKP_int pitchL[ MAX_NB_SUBFR ] /* I */ ); -SKP_INLINE void SKP_Silk_noise_shape_quantizer( - SKP_Silk_nsq_state *NSQ, /* I/O NSQ state */ +SKP_INLINE void silk_noise_shape_quantizer( + silk_nsq_state *NSQ, /* I/O NSQ state */ SKP_int signalType, /* I Signal type */ const SKP_int32 x_sc_Q10[], /* I */ SKP_int8 pulses[], /* O */ @@ -62,9 +62,9 @@ SKP_INLINE void SKP_Silk_noise_shape_quantizer( SKP_int predictLPCOrder /* I Prediction filter order */ ); -void SKP_Silk_NSQ( - const SKP_Silk_encoder_state *psEncC, /* I/O Encoder State */ - SKP_Silk_nsq_state *NSQ, /* I/O NSQ state */ +void silk_NSQ( + const silk_encoder_state *psEncC, /* I/O Encoder State */ + silk_nsq_state *NSQ, /* I/O NSQ state */ SideInfoIndices *psIndices, /* I/O Quantization Indices */ const SKP_int16 x[], /* I prefiltered input signal */ SKP_int8 pulses[], /* O quantized qulse signal */ @@ -96,7 +96,7 @@ void SKP_Silk_NSQ( SKP_assert( NSQ->prev_inv_gain_Q16 != 0 ); - offset_Q10 = SKP_Silk_Quantization_Offsets_Q10[ psIndices->signalType >> 1 ][ psIndices->quantOffsetType ]; + offset_Q10 = silk_Quantization_Offsets_Q10[ psIndices->signalType >> 1 ][ psIndices->quantOffsetType ]; if( psIndices->NLSFInterpCoef_Q2 == 4 ) { LSF_interpolation_flag = 0; @@ -129,7 +129,7 @@ void SKP_Silk_NSQ( start_idx = psEncC->ltp_mem_length - lag - psEncC->predictLPCOrder - LTP_ORDER / 2; SKP_assert( start_idx > 0 ); - SKP_Silk_LPC_analysis_filter( &sLTP[ start_idx ], &NSQ->xq[ start_idx + k * psEncC->subfr_length ], + silk_LPC_analysis_filter( &sLTP[ start_idx ], &NSQ->xq[ start_idx + k * psEncC->subfr_length ], A_Q12, psEncC->ltp_mem_length - start_idx, psEncC->predictLPCOrder ); NSQ->rewhite_flag = 1; @@ -137,9 +137,9 @@ void SKP_Silk_NSQ( } } - SKP_Silk_nsq_scale_states( psEncC, NSQ, x, x_sc_Q10, sLTP, sLTP_Q16, k, LTP_scale_Q14, Gains_Q16, pitchL ); + silk_nsq_scale_states( psEncC, NSQ, x, x_sc_Q10, sLTP, sLTP_Q16, k, LTP_scale_Q14, Gains_Q16, pitchL ); - SKP_Silk_noise_shape_quantizer( NSQ, psIndices->signalType, x_sc_Q10, pulses, pxq, sLTP_Q16, A_Q12, B_Q14, + silk_noise_shape_quantizer( NSQ, psIndices->signalType, x_sc_Q10, pulses, pxq, sLTP_Q16, A_Q12, B_Q14, AR_shp_Q13, lag, HarmShapeFIRPacked_Q14, Tilt_Q14[ k ], LF_shp_Q14[ k ], Gains_Q16[ k ], Lambda_Q10, offset_Q10, psEncC->subfr_length, psEncC->shapingLPCOrder, psEncC->predictLPCOrder ); @@ -163,10 +163,10 @@ void SKP_Silk_NSQ( } /***********************************/ -/* SKP_Silk_noise_shape_quantizer */ +/* silk_noise_shape_quantizer */ /***********************************/ -SKP_INLINE void SKP_Silk_noise_shape_quantizer( - SKP_Silk_nsq_state *NSQ, /* I/O NSQ state */ +SKP_INLINE void silk_noise_shape_quantizer( + silk_nsq_state *NSQ, /* I/O NSQ state */ SKP_int signalType, /* I Signal type */ const SKP_int32 x_sc_Q10[], /* I */ SKP_int8 pulses[], /* O */ @@ -356,9 +356,9 @@ SKP_INLINE void SKP_Silk_noise_shape_quantizer( SKP_memcpy( NSQ->sLPC_Q14, &NSQ->sLPC_Q14[ length ], NSQ_LPC_BUF_LENGTH * sizeof( SKP_int32 ) ); } -SKP_INLINE void SKP_Silk_nsq_scale_states( - const SKP_Silk_encoder_state *psEncC, /* I Encoder State */ - SKP_Silk_nsq_state *NSQ, /* I/O NSQ state */ +SKP_INLINE void silk_nsq_scale_states( + const silk_encoder_state *psEncC, /* I Encoder State */ + silk_nsq_state *NSQ, /* I/O NSQ state */ const SKP_int16 x[], /* I input in Q0 */ SKP_int32 x_sc_Q10[], /* O input scaled with 1/Gain */ const SKP_int16 sLTP[], /* I re-whitened LTP state in Q0 */ @@ -372,7 +372,7 @@ SKP_INLINE void SKP_Silk_nsq_scale_states( SKP_int i, lag; SKP_int32 inv_gain_Q16, gain_adj_Q16, inv_gain_Q32; - inv_gain_Q16 = SKP_INVERSE32_varQ( SKP_max( Gains_Q16[ subfr ], 1 ), 32 ); + inv_gain_Q16 = silk_INVERSE32_varQ( SKP_max( Gains_Q16[ subfr ], 1 ), 32 ); inv_gain_Q16 = SKP_min( inv_gain_Q16, SKP_int16_MAX ); lag = pitchL[ subfr ]; @@ -391,7 +391,7 @@ SKP_INLINE void SKP_Silk_nsq_scale_states( /* Adjust for changing gain */ if( inv_gain_Q16 != NSQ->prev_inv_gain_Q16 ) { - gain_adj_Q16 = SKP_DIV32_varQ( inv_gain_Q16, NSQ->prev_inv_gain_Q16, 16 ); + gain_adj_Q16 = silk_DIV32_varQ( inv_gain_Q16, NSQ->prev_inv_gain_Q16, 16 ); /* Scale long-term shaping state */ for( i = NSQ->sLTP_shp_buf_idx - psEncC->ltp_mem_length; i < NSQ->sLTP_shp_buf_idx; i++ ) { diff --git a/silk/SKP_Silk_NSQ_del_dec.c b/silk/silk_NSQ_del_dec.c similarity index 94% rename from silk/SKP_Silk_NSQ_del_dec.c rename to silk/silk_NSQ_del_dec.c index 6ef1bd5b..8ff138ae 100644 --- a/silk/SKP_Silk_NSQ_del_dec.c +++ b/silk/silk_NSQ_del_dec.c @@ -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. ***********************************************************************/ -#include "SKP_Silk_main.h" +#include "silk_main.h" typedef struct { SKP_int32 sLPC_Q14[ MAX_FRAME_LENGTH / MAX_NB_SUBFR + NSQ_LPC_BUF_LENGTH ]; @@ -50,9 +50,9 @@ typedef struct { SKP_int32 LPC_exc_Q16; } NSQ_sample_struct; -SKP_INLINE void SKP_Silk_nsq_del_dec_scale_states( - const SKP_Silk_encoder_state *psEncC, /* I Encoder State */ - SKP_Silk_nsq_state *NSQ, /* I/O NSQ state */ +SKP_INLINE void silk_nsq_del_dec_scale_states( + const silk_encoder_state *psEncC, /* I Encoder State */ + silk_nsq_state *NSQ, /* I/O NSQ state */ NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */ const SKP_int16 x[], /* I Input in Q0 */ SKP_int32 x_sc_Q10[], /* O Input scaled with 1/Gain in Q10 */ @@ -69,8 +69,8 @@ SKP_INLINE void SKP_Silk_nsq_del_dec_scale_states( /******************************************/ /* Noise shape quantizer for one subframe */ /******************************************/ -SKP_INLINE void SKP_Silk_noise_shape_quantizer_del_dec( - SKP_Silk_nsq_state *NSQ, /* I/O NSQ state */ +SKP_INLINE void silk_noise_shape_quantizer_del_dec( + silk_nsq_state *NSQ, /* I/O NSQ state */ NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */ SKP_int signalType, /* I Signal type */ const SKP_int32 x_Q10[], /* I */ @@ -98,9 +98,9 @@ SKP_INLINE void SKP_Silk_noise_shape_quantizer_del_dec( SKP_int decisionDelay /* I */ ); -void SKP_Silk_NSQ_del_dec( - const SKP_Silk_encoder_state *psEncC, /* I/O Encoder State */ - SKP_Silk_nsq_state *NSQ, /* I/O NSQ state */ +void silk_NSQ_del_dec( + const silk_encoder_state *psEncC, /* I/O Encoder State */ + silk_nsq_state *NSQ, /* I/O NSQ state */ SideInfoIndices *psIndices, /* I/O Quantization Indices */ const SKP_int16 x[], /* I Prefiltered input signal */ SKP_int8 pulses[], /* O Quantized pulse signal */ @@ -148,7 +148,7 @@ void SKP_Silk_NSQ_del_dec( SKP_memcpy( psDD->sAR2_Q14, NSQ->sAR2_Q14, sizeof( NSQ->sAR2_Q14 ) ); } - offset_Q10 = SKP_Silk_Quantization_Offsets_Q10[ psIndices->signalType >> 1 ][ psIndices->quantOffsetType ]; + offset_Q10 = silk_Quantization_Offsets_Q10[ psIndices->signalType >> 1 ][ psIndices->quantOffsetType ]; smpl_buf_idx = 0; /* index of oldest samples */ decisionDelay = SKP_min_int( DECISION_DELAY, psEncC->subfr_length ); @@ -228,7 +228,7 @@ void SKP_Silk_NSQ_del_dec( start_idx = psEncC->ltp_mem_length - lag - psEncC->predictLPCOrder - LTP_ORDER / 2; SKP_assert( start_idx > 0 ); - SKP_Silk_LPC_analysis_filter( &sLTP[ start_idx ], &NSQ->xq[ start_idx + k * psEncC->subfr_length ], + silk_LPC_analysis_filter( &sLTP[ start_idx ], &NSQ->xq[ start_idx + k * psEncC->subfr_length ], A_Q12, psEncC->ltp_mem_length - start_idx, psEncC->predictLPCOrder ); NSQ->sLTP_buf_idx = psEncC->ltp_mem_length; @@ -236,10 +236,10 @@ void SKP_Silk_NSQ_del_dec( } } - SKP_Silk_nsq_del_dec_scale_states( psEncC, NSQ, psDelDec, x, x_sc_Q10, sLTP, sLTP_Q16, k, + silk_nsq_del_dec_scale_states( psEncC, NSQ, psDelDec, x, x_sc_Q10, sLTP, sLTP_Q16, k, psEncC->nStatesDelayedDecision, smpl_buf_idx, LTP_scale_Q14, Gains_Q16, pitchL ); - SKP_Silk_noise_shape_quantizer_del_dec( NSQ, psDelDec, psIndices->signalType, x_sc_Q10, pulses, pxq, sLTP_Q16, + silk_noise_shape_quantizer_del_dec( NSQ, psDelDec, psIndices->signalType, x_sc_Q10, pulses, pxq, sLTP_Q16, delayedGain_Q16, A_Q12, B_Q14, AR_shp_Q13, lag, HarmShapeFIRPacked_Q14, Tilt_Q14[ k ], LF_shp_Q14[ k ], Gains_Q16[ k ], Lambda_Q10, offset_Q10, psEncC->subfr_length, subfr++, psEncC->shapingLPCOrder, psEncC->predictLPCOrder, psEncC->warping_Q16, psEncC->nStatesDelayedDecision, &smpl_buf_idx, decisionDelay ); @@ -292,8 +292,8 @@ void SKP_Silk_NSQ_del_dec( /******************************************/ /* Noise shape quantizer for one subframe */ /******************************************/ -SKP_INLINE void SKP_Silk_noise_shape_quantizer_del_dec( - SKP_Silk_nsq_state *NSQ, /* I/O NSQ state */ +SKP_INLINE void silk_noise_shape_quantizer_del_dec( + silk_nsq_state *NSQ, /* I/O NSQ state */ NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */ SKP_int signalType, /* I Signal type */ const SKP_int32 x_Q10[], /* I */ @@ -596,9 +596,9 @@ SKP_INLINE void SKP_Silk_noise_shape_quantizer_del_dec( } } -SKP_INLINE void SKP_Silk_nsq_del_dec_scale_states( - const SKP_Silk_encoder_state *psEncC, /* I Encoder State */ - SKP_Silk_nsq_state *NSQ, /* I/O NSQ state */ +SKP_INLINE void silk_nsq_del_dec_scale_states( + const silk_encoder_state *psEncC, /* I Encoder State */ + silk_nsq_state *NSQ, /* I/O NSQ state */ NSQ_del_dec_struct psDelDec[], /* I/O Delayed decision states */ const SKP_int16 x[], /* I Input in Q0 */ SKP_int32 x_sc_Q10[], /* O Input scaled with 1/Gain in Q10 */ @@ -616,7 +616,7 @@ SKP_INLINE void SKP_Silk_nsq_del_dec_scale_states( SKP_int32 inv_gain_Q16, gain_adj_Q16, inv_gain_Q32; NSQ_del_dec_struct *psDD; - inv_gain_Q16 = SKP_INVERSE32_varQ( SKP_max( Gains_Q16[ subfr ], 1 ), 32 ); + inv_gain_Q16 = silk_INVERSE32_varQ( SKP_max( Gains_Q16[ subfr ], 1 ), 32 ); inv_gain_Q16 = SKP_min( inv_gain_Q16, SKP_int16_MAX ); lag = pitchL[ subfr ]; @@ -635,7 +635,7 @@ SKP_INLINE void SKP_Silk_nsq_del_dec_scale_states( /* Adjust for changing gain */ if( inv_gain_Q16 != NSQ->prev_inv_gain_Q16 ) { - gain_adj_Q16 = SKP_DIV32_varQ( inv_gain_Q16, NSQ->prev_inv_gain_Q16, 16 ); + gain_adj_Q16 = silk_DIV32_varQ( inv_gain_Q16, NSQ->prev_inv_gain_Q16, 16 ); /* Scale long-term shaping state */ for( i = NSQ->sLTP_shp_buf_idx - psEncC->ltp_mem_length; i < NSQ->sLTP_shp_buf_idx; i++ ) { diff --git a/silk/SKP_Silk_PLC.c b/silk/silk_PLC.c similarity index 87% rename from silk/SKP_Silk_PLC.c rename to silk/silk_PLC.c index c10e4205..478f429a 100644 --- a/silk/SKP_Silk_PLC.c +++ b/silk/silk_PLC.c @@ -25,24 +25,24 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" -#include "SKP_Silk_PLC.h" +#include "silk_main.h" +#include "silk_PLC.h" #define NB_ATT 2 static const SKP_int16 HARM_ATT_Q15[NB_ATT] = { 32440, 31130 }; /* 0.99, 0.95 */ static const SKP_int16 PLC_RAND_ATTENUATE_V_Q15[NB_ATT] = { 31130, 26214 }; /* 0.95, 0.8 */ static const SKP_int16 PLC_RAND_ATTENUATE_UV_Q15[NB_ATT] = { 32440, 29491 }; /* 0.99, 0.9 */ -void SKP_Silk_PLC_Reset( - SKP_Silk_decoder_state *psDec /* I/O Decoder state */ +void silk_PLC_Reset( + silk_decoder_state *psDec /* I/O Decoder state */ ) { psDec->sPLC.pitchL_Q8 = SKP_RSHIFT( psDec->frame_length, 1 ); } -void SKP_Silk_PLC( - SKP_Silk_decoder_state *psDec, /* I Decoder state */ - SKP_Silk_decoder_control *psDecCtrl, /* I Decoder control */ +void silk_PLC( + silk_decoder_state *psDec, /* I Decoder state */ + silk_decoder_control *psDecCtrl, /* I Decoder control */ SKP_int16 signal[], /* O Concealed signal */ SKP_int length, /* I length of residual */ SKP_int lost /* I Loss flag */ @@ -50,7 +50,7 @@ void SKP_Silk_PLC( { /* PLC control function */ if( psDec->fs_kHz != psDec->sPLC.fs_kHz ) { - SKP_Silk_PLC_Reset( psDec ); + silk_PLC_Reset( psDec ); psDec->sPLC.fs_kHz = psDec->fs_kHz; } @@ -58,30 +58,30 @@ void SKP_Silk_PLC( /****************************/ /* Generate Signal */ /****************************/ - SKP_Silk_PLC_conceal( psDec, psDecCtrl, signal, length ); + silk_PLC_conceal( psDec, psDecCtrl, signal, length ); psDec->lossCnt++; } else { /****************************/ /* Update state */ /****************************/ - SKP_Silk_PLC_update( psDec, psDecCtrl, signal, length ); + silk_PLC_update( psDec, psDecCtrl, signal, length ); } } /**************************************************/ /* Update state of PLC */ /**************************************************/ -void SKP_Silk_PLC_update( - SKP_Silk_decoder_state *psDec, /* (I/O) Decoder state */ - SKP_Silk_decoder_control *psDecCtrl, /* (I/O) Decoder control */ +void silk_PLC_update( + silk_decoder_state *psDec, /* (I/O) Decoder state */ + silk_decoder_control *psDecCtrl, /* (I/O) Decoder control */ SKP_int16 signal[], SKP_int length ) { SKP_int32 LTP_Gain_Q14, temp_LTP_Gain_Q14; SKP_int i, j; - SKP_Silk_PLC_struct *psPLC; + silk_PLC_struct *psPLC; psPLC = &psDec->sPLC; @@ -146,9 +146,9 @@ void SKP_Silk_PLC_update( SKP_memcpy( psPLC->prevGain_Q16, psDecCtrl->Gains_Q16, psDec->nb_subfr * sizeof( SKP_int32 ) ); } -void SKP_Silk_PLC_conceal( - SKP_Silk_decoder_state *psDec, /* I/O Decoder state */ - SKP_Silk_decoder_control *psDecCtrl, /* I/O Decoder control */ +void silk_PLC_conceal( + silk_decoder_state *psDec, /* I/O Decoder state */ + silk_decoder_control *psDecCtrl, /* I/O Decoder control */ SKP_int16 signal[], /* O concealed signal */ SKP_int length /* I length of residual */ ) @@ -160,14 +160,14 @@ void SKP_Silk_PLC_conceal( SKP_int lag, idx, sLTP_buf_idx, shift1, shift2; SKP_int32 energy1, energy2, *rand_ptr, *pred_lag_ptr; SKP_int32 sig_Q10[ MAX_FRAME_LENGTH ], *sig_Q10_ptr, LPC_exc_Q10, LPC_pred_Q10, LTP_pred_Q14; - SKP_Silk_PLC_struct *psPLC; + silk_PLC_struct *psPLC; psPLC = &psDec->sPLC; /* Update LTP buffer */ SKP_memmove( psDec->sLTP_Q16, &psDec->sLTP_Q16[ psDec->frame_length ], psDec->ltp_mem_length * sizeof( SKP_int32 ) ); /* LPC concealment. Apply BWE to previous LPC */ - SKP_Silk_bwexpander( psPLC->prevLPC_Q12, psDec->LPC_order, SKP_FIX_CONST( BWE_COEF, 16 ) ); + silk_bwexpander( psPLC->prevLPC_Q12, psDec->LPC_order, SILK_FIX_CONST( BWE_COEF, 16 ) ); /* Find random noise component */ /* Scale previous excitation signal */ @@ -180,8 +180,8 @@ void SKP_Silk_PLC_conceal( exc_buf_ptr += psDec->subfr_length; } /* Find the subframe with lowest energy of the last two and use that as random noise generator */ - SKP_Silk_sum_sqr_shift( &energy1, &shift1, exc_buf, psDec->subfr_length ); - SKP_Silk_sum_sqr_shift( &energy2, &shift2, &exc_buf[ psDec->subfr_length ], psDec->subfr_length ); + silk_sum_sqr_shift( &energy1, &shift1, exc_buf, psDec->subfr_length ); + silk_sum_sqr_shift( &energy2, &shift2, &exc_buf[ psDec->subfr_length ], psDec->subfr_length ); if( SKP_RSHIFT( energy1, shift2 ) < SKP_RSHIFT( energy2, shift1 ) ) { /* First sub-frame has lowest energy */ @@ -218,7 +218,7 @@ void SKP_Silk_PLC_conceal( /* Reduce random noise for unvoiced frames with high LPC gain */ SKP_int32 invGain_Q30, down_scale_Q30; - SKP_Silk_LPC_inverse_pred_gain( &invGain_Q30, psPLC->prevLPC_Q12, psDec->LPC_order ); + silk_LPC_inverse_pred_gain( &invGain_Q30, psPLC->prevLPC_Q12, psDec->LPC_order ); down_scale_Q30 = SKP_min_32( SKP_RSHIFT( 1 << 30, LOG2_INV_LPC_GAIN_HIGH_THRES ), invGain_Q30 ); down_scale_Q30 = SKP_max_32( SKP_RSHIFT( 1 << 30, LOG2_INV_LPC_GAIN_LOW_THRES ), down_scale_Q30 ); @@ -328,27 +328,27 @@ void SKP_Silk_PLC_conceal( } /* Glues concealed frames with new good recieved frames */ -void SKP_Silk_PLC_glue_frames( - SKP_Silk_decoder_state *psDec, /* I/O decoder state */ - SKP_Silk_decoder_control *psDecCtrl, /* I/O Decoder control */ +void silk_PLC_glue_frames( + silk_decoder_state *psDec, /* I/O decoder state */ + silk_decoder_control *psDecCtrl, /* I/O Decoder control */ SKP_int16 signal[], /* I/O signal */ SKP_int length /* I length of residual */ ) { SKP_int i, energy_shift; SKP_int32 energy; - SKP_Silk_PLC_struct *psPLC; + silk_PLC_struct *psPLC; psPLC = &psDec->sPLC; if( psDec->lossCnt ) { /* Calculate energy in concealed residual */ - SKP_Silk_sum_sqr_shift( &psPLC->conc_energy, &psPLC->conc_energy_shift, signal, length ); + silk_sum_sqr_shift( &psPLC->conc_energy, &psPLC->conc_energy_shift, signal, length ); psPLC->last_frame_lost = 1; } else { if( psDec->sPLC.last_frame_lost ) { /* Calculate residual in decoded signal if last frame was lost */ - SKP_Silk_sum_sqr_shift( &energy, &energy_shift, signal, length ); + silk_sum_sqr_shift( &energy, &energy_shift, signal, length ); /* Normalize energies */ if( energy_shift > psPLC->conc_energy_shift ) { @@ -362,14 +362,14 @@ void SKP_Silk_PLC_glue_frames( SKP_int32 frac_Q24, LZ; SKP_int32 gain_Q16, slope_Q16; - LZ = SKP_Silk_CLZ32( psPLC->conc_energy ); + LZ = silk_CLZ32( psPLC->conc_energy ); LZ = LZ - 1; psPLC->conc_energy = SKP_LSHIFT( psPLC->conc_energy, LZ ); energy = SKP_RSHIFT( energy, SKP_max_32( 24 - LZ, 0 ) ); frac_Q24 = SKP_DIV32( psPLC->conc_energy, SKP_max( energy, 1 ) ); - gain_Q16 = SKP_LSHIFT( SKP_Silk_SQRT_APPROX( frac_Q24 ), 4 ); + gain_Q16 = SKP_LSHIFT( silk_SQRT_APPROX( frac_Q24 ), 4 ); slope_Q16 = SKP_DIV32_16( ( 1 << 16 ) - gain_Q16, length ); /* Make slope 4x steeper to avoid missing onsets after DTX */ slope_Q16 = SKP_LSHIFT( slope_Q16, 2 ); diff --git a/silk/SKP_Silk_PLC.h b/silk/silk_PLC.h similarity index 75% rename from silk/SKP_Silk_PLC.h rename to silk/silk_PLC.h index 97fc9011..8044c1a9 100644 --- a/silk/SKP_Silk_PLC.h +++ b/silk/silk_PLC.h @@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#ifndef SKP_SILK_PLC_FIX_H -#define SKP_SILK_PLC_FIX_H +#ifndef SILK_PLC_FIX_H +#define SILK_PLC_FIX_H -#include "SKP_Silk_main.h" +#include "silk_main.h" #define BWE_COEF 0.99 #define V_PITCH_GAIN_START_MIN_Q14 11469 /* 0.7 in Q14 */ @@ -42,35 +42,35 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define LOG2_INV_LPC_GAIN_LOW_THRES 8 /* 2^8 = 24 dB LPC gain */ #define PITCH_DRIFT_FAC_Q16 655 /* 0.01 in Q16 */ -void SKP_Silk_PLC_Reset( - SKP_Silk_decoder_state *psDec /* I/O Decoder state */ +void silk_PLC_Reset( + silk_decoder_state *psDec /* I/O Decoder state */ ); -void SKP_Silk_PLC( - SKP_Silk_decoder_state *psDec, /* I/O Decoder state */ - SKP_Silk_decoder_control *psDecCtrl, /* I/O Decoder control */ +void silk_PLC( + silk_decoder_state *psDec, /* I/O Decoder state */ + silk_decoder_control *psDecCtrl, /* I/O Decoder control */ SKP_int16 signal[], /* I/O signal */ SKP_int length, /* I length of residual */ SKP_int lost /* I Loss flag */ ); -void SKP_Silk_PLC_update( - SKP_Silk_decoder_state *psDec, /* I/O Decoder state */ - SKP_Silk_decoder_control *psDecCtrl, /* I/O Decoder control */ +void silk_PLC_update( + silk_decoder_state *psDec, /* I/O Decoder state */ + silk_decoder_control *psDecCtrl, /* I/O Decoder control */ SKP_int16 signal[], SKP_int length ); -void SKP_Silk_PLC_conceal( - SKP_Silk_decoder_state *psDec, /* I/O Decoder state */ - SKP_Silk_decoder_control *psDecCtrl, /* I/O Decoder control */ +void silk_PLC_conceal( + silk_decoder_state *psDec, /* I/O Decoder state */ + silk_decoder_control *psDecCtrl, /* I/O Decoder control */ SKP_int16 signal[], /* O LPC residual signal */ SKP_int length /* I length of signal */ ); -void SKP_Silk_PLC_glue_frames( - SKP_Silk_decoder_state *psDec, /* I/O decoder state */ - SKP_Silk_decoder_control *psDecCtrl, /* I/O Decoder control */ +void silk_PLC_glue_frames( + silk_decoder_state *psDec, /* I/O decoder state */ + silk_decoder_control *psDecCtrl, /* I/O Decoder control */ SKP_int16 signal[], /* I/O signal */ SKP_int length /* I length of signal */ ); diff --git a/silk/SKP_Silk_SigProc_FIX.h b/silk/silk_SigProc_FIX.h similarity index 87% rename from silk/SKP_Silk_SigProc_FIX.h rename to silk/silk_SigProc_FIX.h index 56782b3a..79e62597 100644 --- a/silk/SKP_Silk_SigProc_FIX.h +++ b/silk/silk_SigProc_FIX.h @@ -25,26 +25,23 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ - -#ifndef _SKP_SILK_SIGPROC_FIX_H_ -#define _SKP_SILK_SIGPROC_FIX_H_ +#ifndef _SILK_SIGPROC_FIX_H_ +#define _SILK_SIGPROC_FIX_H_ #ifdef __cplusplus extern "C" { #endif -//#define SKP_MACRO_COUNT /* Used to enable WMOPS counting */ +//#define SKP_MACRO_COUNT /* Used to enable WMOPS counting */ -#define SKP_Silk_MAX_ORDER_LPC 16 /* max order of the LPC analysis in schur() and k2a() */ -#define SKP_Silk_MAX_CORRELATION_LENGTH 640 /* max input length to the correlation */ -#include "SKP_Silk_typedef.h" -#include -#include /* for abs() */ -#include "SKP_Silk_resampler_structs.h" - -# include "SKP_Silk_macros.h" +#define SILK_MAX_ORDER_LPC 16 /* max order of the LPC analysis in schur() and k2a() */ +#include /* for abs() */ +#include /* for memset(), memcpy(), memmove() */ +#include "silk_typedef.h" +#include "silk_resampler_structs.h" +#include "silk_macros.h" /********************************************************************/ @@ -54,25 +51,24 @@ extern "C" /*! * Initialize/reset the resampler state for a given pair of input/output sampling rates */ -SKP_int SKP_Silk_resampler_init( - SKP_Silk_resampler_state_struct *S, /* I/O: Resampler state */ +SKP_int silk_resampler_init( + silk_resampler_state_struct *S, /* I/O: Resampler state */ SKP_int32 Fs_Hz_in, /* I: Input sampling rate (Hz) */ SKP_int32 Fs_Hz_out /* I: Output sampling rate (Hz) */ ); - /*! * Clear the states of all resampling filters, without resetting sampling rate ratio */ -SKP_int SKP_Silk_resampler_clear( - SKP_Silk_resampler_state_struct *S /* I/O: Resampler state */ +SKP_int silk_resampler_clear( + silk_resampler_state_struct *S /* I/O: Resampler state */ ); /*! * Resampler: convert from one sampling rate to another */ -SKP_int SKP_Silk_resampler( - SKP_Silk_resampler_state_struct *S, /* I/O: Resampler state */ +SKP_int silk_resampler( + silk_resampler_state_struct *S, /* I/O: Resampler state */ SKP_int16 out[], /* O: Output signal */ const SKP_int16 in[], /* I: Input signal */ SKP_int32 inLen /* I: Number of input samples */ @@ -81,7 +77,7 @@ SKP_int SKP_Silk_resampler( /*! Upsample 2x, low quality */ -void SKP_Silk_resampler_up2( +void silk_resampler_up2( SKP_int32 *S, /* I/O: State vector [ 2 ] */ SKP_int16 *out, /* O: Output signal [ 2 * len ] */ const SKP_int16 *in, /* I: Input signal [ len ] */ @@ -91,7 +87,7 @@ void SKP_Silk_resampler_up2( /*! * Downsample 2x, mediocre quality */ -void SKP_Silk_resampler_down2( +void silk_resampler_down2( SKP_int32 *S, /* I/O: State vector [ 2 ] */ SKP_int16 *out, /* O: Output signal [ len ] */ const SKP_int16 *in, /* I: Input signal [ floor(len/2) ] */ @@ -102,7 +98,7 @@ void SKP_Silk_resampler_down2( /*! * Downsample by a factor 2/3, low quality */ -void SKP_Silk_resampler_down2_3( +void silk_resampler_down2_3( SKP_int32 *S, /* I/O: State vector [ 6 ] */ SKP_int16 *out, /* O: Output signal [ floor(2*inLen/3) ] */ const SKP_int16 *in, /* I: Input signal [ inLen ] */ @@ -112,7 +108,7 @@ void SKP_Silk_resampler_down2_3( /*! * Downsample by a factor 3, low quality */ -void SKP_Silk_resampler_down3( +void silk_resampler_down3( SKP_int32 *S, /* I/O: State vector [ 8 ] */ SKP_int16 *out, /* O: Output signal [ floor(inLen/3) ] */ const SKP_int16 *in, /* I: Input signal [ inLen ] */ @@ -124,11 +120,11 @@ void SKP_Silk_resampler_down3( * slower than biquad() but uses more precise coefficients * can handle (slowly) varying coefficients */ -void SKP_Silk_biquad_alt( +void silk_biquad_alt( const SKP_int16 *in, /* I: input signal */ const SKP_int32 *B_Q28, /* I: MA coefficients [3] */ const SKP_int32 *A_Q28, /* I: AR coefficients [2] */ - SKP_int32 *S, /* I/O: state vector [2] */ + SKP_int32 *S, /* I/O: State vector [2] */ SKP_int16 *out, /* O: output signal */ const SKP_int32 len /* I: signal length (must be even) */ ); @@ -136,19 +132,19 @@ void SKP_Silk_biquad_alt( /*! * variable order MA filter. Prediction error filter implementation. Coeficients negated and starting with coef to x[n - 1] */ -void SKP_Silk_MA_Prediction( +void silk_MA_Prediction( const SKP_int16 *in, /* I: Input signal */ const SKP_int16 *B, /* I: MA prediction coefficients, Q12 [order] */ SKP_int32 *S, /* I/O: State vector [order] */ SKP_int16 *out, /* O: Output signal */ const SKP_int32 len, /* I: Signal length */ - const SKP_int32 order /* I: Filter order */ + const SKP_int32 order /* I: Filter order */ ); /*! * 16th order AR filter for LPC synthesis, coefficients are in Q12 */ -void SKP_Silk_LPC_synthesis_order16( +void silk_LPC_synthesis_order16( const SKP_int16 *in, /* I: excitation signal */ const SKP_int16 *A_Q12, /* I: AR coefficients [16], between -8_Q0 and 8_Q0 */ const SKP_int32 Gain_Q26, /* I: gain */ @@ -158,8 +154,8 @@ void SKP_Silk_LPC_synthesis_order16( ); /* variable order MA prediction error filter. */ -/* Inverse filter of SKP_Silk_LPC_synthesis_filter */ -void SKP_Silk_LPC_analysis_filter( +/* Inverse filter of silk_LPC_synthesis_filter */ +void silk_LPC_analysis_filter( SKP_int16 *out, /* O: Output signal */ const SKP_int16 *in, /* I: Input signal */ const SKP_int16 *B, /* I: MA prediction coefficients, Q12 [order] */ @@ -168,7 +164,7 @@ void SKP_Silk_LPC_analysis_filter( ); /* even order AR filter */ -void SKP_Silk_LPC_synthesis_filter( +void silk_LPC_synthesis_filter( const SKP_int16 *in, /* I: excitation signal */ const SKP_int16 *A_Q12, /* I: AR coefficients [Order], between -8_Q0 and 8_Q0 */ const SKP_int32 Gain_Q26, /* I: gain */ @@ -179,14 +175,14 @@ void SKP_Silk_LPC_synthesis_filter( ); /* Chirp (bandwidth expand) LP AR filter */ -void SKP_Silk_bwexpander( +void silk_bwexpander( SKP_int16 *ar, /* I/O AR filter to be expanded (without leading 1) */ const SKP_int d, /* I Length of ar */ SKP_int32 chirp_Q16 /* I Chirp factor (typically in the range 0 to 1) */ ); /* Chirp (bandwidth expand) LP AR filter */ -void SKP_Silk_bwexpander_32( +void silk_bwexpander_32( SKP_int32 *ar, /* I/O AR filter to be expanded (without leading 1) */ const SKP_int d, /* I Length of ar */ SKP_int32 chirp_Q16 /* I Chirp factor in Q16 */ @@ -194,20 +190,20 @@ void SKP_Silk_bwexpander_32( /* Compute inverse of LPC prediction gain, and */ /* test if LPC coefficients are stable (all poles within unit circle) */ -SKP_int SKP_Silk_LPC_inverse_pred_gain( /* O: Returns 1 if unstable, otherwise 0 */ +SKP_int silk_LPC_inverse_pred_gain( /* O: Returns 1 if unstable, otherwise 0 */ SKP_int32 *invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */ const SKP_int16 *A_Q12, /* I: Prediction coefficients, Q12 [order] */ const SKP_int order /* I: Prediction order */ ); -SKP_int SKP_Silk_LPC_inverse_pred_gain_Q24( /* O: Returns 1 if unstable, otherwise 0 */ +SKP_int silk_LPC_inverse_pred_gain_Q24( /* O: Returns 1 if unstable, otherwise 0 */ SKP_int32 *invGain_Q30, /* O: Inverse prediction gain, Q30 energy domain */ const SKP_int32 *A_Q24, /* I: Prediction coefficients, Q24 [order] */ const SKP_int order /* I: Prediction order */ ); /* split signal in two decimated bands using first-order allpass filters */ -void SKP_Silk_ana_filt_bank_1( +void silk_ana_filt_bank_1( const SKP_int16 *in, /* I: Input signal [N] */ SKP_int32 *S, /* I/O: State vector [2] */ SKP_int16 *outL, /* O: Low band [N/2] */ @@ -221,24 +217,24 @@ void SKP_Silk_ana_filt_bank_1( /* approximation of 128 * log2() (exact inverse of approx 2^() below) */ /* convert input to a log scale */ -SKP_int32 SKP_Silk_lin2log(const SKP_int32 inLin); /* I: input in linear scale */ +SKP_int32 silk_lin2log(const SKP_int32 inLin); /* I: input in linear scale */ /* Approximation of a sigmoid function */ -SKP_int SKP_Silk_sigm_Q15(SKP_int in_Q5); +SKP_int silk_sigm_Q15(SKP_int in_Q5); /* approximation of 2^() (exact inverse of approx log2() above) */ /* convert input to a linear scale */ -SKP_int32 SKP_Silk_log2lin(const SKP_int32 inLog_Q7); /* I: input on log scale */ +SKP_int32 silk_log2lin(const SKP_int32 inLog_Q7); /* I: input on log scale */ /* Function that returns the maximum absolut value of the input vector */ -SKP_int16 SKP_Silk_int16_array_maxabs( /* O Maximum absolute value, max: 2^15-1 */ +SKP_int16 silk_int16_array_maxabs( /* O Maximum absolute value, max: 2^15-1 */ const SKP_int16 *vec, /* I Input vector [len] */ const SKP_int32 len /* I Length of input vector */ ); /* Compute number of bits to right shift the sum of squares of a vector */ /* of int16s to make it fit in an int32 */ -void SKP_Silk_sum_sqr_shift( +void silk_sum_sqr_shift( SKP_int32 *energy, /* O Energy of x, after shifting to the right */ SKP_int *shift, /* O Number of bits right shift applied to energy */ const SKP_int16 *x, /* I Input vector */ @@ -248,7 +244,7 @@ void SKP_Silk_sum_sqr_shift( /* Calculates the reflection coefficients from the correlation sequence */ /* Faster than schur64(), but much less accurate. */ /* uses SMLAWB(), requiring armv5E and higher. */ -SKP_int32 SKP_Silk_schur( /* O: Returns residual energy */ +SKP_int32 silk_schur( /* O: Returns residual energy */ SKP_int16 *rc_Q15, /* O: reflection coefficients [order] Q15 */ const SKP_int32 *c, /* I: correlations [order+1] */ const SKP_int32 order /* I: prediction order */ @@ -257,21 +253,21 @@ SKP_int32 SKP_Silk_schur( /* O: Returns residual energy /* Calculates the reflection coefficients from the correlation sequence */ /* Slower than schur(), but more accurate. */ /* Uses SMULL(), available on armv4 */ -SKP_int32 SKP_Silk_schur64( /* O: returns residual energy */ +SKP_int32 silk_schur64( /* O: returns residual energy */ SKP_int32 rc_Q16[], /* O: Reflection coefficients [order] Q16 */ const SKP_int32 c[], /* I: Correlations [order+1] */ SKP_int32 order /* I: Prediction order */ ); /* Step up function, converts reflection coefficients to prediction coefficients */ -void SKP_Silk_k2a( +void silk_k2a( SKP_int32 *A_Q24, /* O: Prediction coefficients [order] Q24 */ const SKP_int16 *rc_Q15, /* I: Reflection coefficients [order] Q15 */ const SKP_int32 order /* I: Prediction order */ ); /* Step up function, converts reflection coefficients to prediction coefficients */ -void SKP_Silk_k2a_Q16( +void silk_k2a_Q16( SKP_int32 *A_Q24, /* O: Prediction coefficients [order] Q24 */ const SKP_int32 *rc_Q16, /* I: Reflection coefficients [order] Q16 */ const SKP_int32 order /* I: Prediction order */ @@ -282,7 +278,7 @@ void SKP_Silk_k2a_Q16( /* 1 -> sine window from 0 to pi/2 */ /* 2 -> sine window from pi/2 to pi */ /* every other sample of window is linearly interpolated, for speed */ -void SKP_Silk_apply_sine_window( +void silk_apply_sine_window( SKP_int16 px_win[], /* O Pointer to windowed signal */ const SKP_int16 px[], /* I Pointer to input signal */ const SKP_int win_type, /* I Selects a window type */ @@ -290,7 +286,7 @@ void SKP_Silk_apply_sine_window( ); /* Compute autocorrelation */ -void SKP_Silk_autocorr( +void silk_autocorr( SKP_int32 *results, /* O Result (length correlationCount) */ SKP_int *scale, /* O Scaling of the correlation vector */ const SKP_int16 *inputData, /* I Input data to correlate */ @@ -299,11 +295,11 @@ void SKP_Silk_autocorr( ); /* Pitch estimator */ -#define SKP_Silk_PE_MIN_COMPLEX 0 -#define SKP_Silk_PE_MID_COMPLEX 1 -#define SKP_Silk_PE_MAX_COMPLEX 2 +#define SILK_PE_MIN_COMPLEX 0 +#define SILK_PE_MID_COMPLEX 1 +#define SILK_PE_MAX_COMPLEX 2 -void SKP_Silk_decode_pitch( +void silk_decode_pitch( SKP_int16 lagIndex, /* I */ SKP_int8 contourIndex, /* O */ SKP_int pitch_lags[], /* O 4 pitch values */ @@ -311,7 +307,7 @@ void SKP_Silk_decode_pitch( const SKP_int nb_subfr /* I number of sub frames */ ); -SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 unvoiced */ +SKP_int silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 unvoiced */ const SKP_int16 *signal, /* I Signal of length PE_FRAME_LENGTH_MS*Fs_kHz */ SKP_int *pitch_out, /* O 4 pitch lag values */ SKP_int16 *lagIndex, /* O Lag Index */ @@ -325,14 +321,7 @@ SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 u const SKP_int nb_subfr /* I number of 5 ms subframes */ ); -/* parameter defining the size and accuracy of the piecewise linear */ -/* cosine approximatin table. */ - -#define LSF_COS_TAB_SZ_FIX 128 -/* rom table with cosine values */ -extern const SKP_int SKP_Silk_LSFCosTab_FIX_Q12[ LSF_COS_TAB_SZ_FIX + 1 ]; - -void SKP_Silk_LPC_fit( +void silk_LPC_fit( SKP_int16 *a_QQ, /* O stabilized LPC vector, Q(24-rshift) [L] */ SKP_int32 *a_Q24, /* I LPC vector [L] */ const SKP_int QQ, /* I Q domain of output LPC vector */ @@ -341,54 +330,54 @@ void SKP_Silk_LPC_fit( /* Compute Normalized Line Spectral Frequencies (NLSFs) from whitening filter coefficients */ /* If not all roots are found, the a_Q16 coefficients are bandwidth expanded until convergence. */ -void SKP_Silk_A2NLSF( +void silk_A2NLSF( SKP_int16 *NLSF, /* O Normalized Line Spectral Frequencies, Q15 (0 - (2^15-1)), [d] */ SKP_int32 *a_Q16, /* I/O Monic whitening filter coefficients in Q16 [d] */ const SKP_int d /* I Filter order (must be even) */ ); /* compute whitening filter coefficients from normalized line spectral frequencies */ -void SKP_Silk_NLSF2A( +void silk_NLSF2A( SKP_int16 *a, /* o monic whitening filter coefficients in Q12, [d] */ const SKP_int16 *NLSF, /* i normalized line spectral frequencies in Q15, [d] */ const SKP_int d /* i filter order (should be even) */ ); -void SKP_Silk_insertion_sort_increasing( +void silk_insertion_sort_increasing( SKP_int32 *a, /* I/O Unsorted / Sorted vector */ - SKP_int *index, /* O: Index vector for the sorted elements */ + SKP_int *idx, /* O: Index vector for the sorted elements */ const SKP_int L, /* I: Vector length */ const SKP_int K /* I: Number of correctly sorted positions */ ); -void SKP_Silk_insertion_sort_decreasing_int16( +void silk_insertion_sort_decreasing_int16( SKP_int16 *a, /* I/O: Unsorted / Sorted vector */ - SKP_int *index, /* O: Index vector for the sorted elements */ + SKP_int *idx, /* O: Index vector for the sorted elements */ const SKP_int L, /* I: Vector length */ const SKP_int K /* I: Number of correctly sorted positions */ ); -void SKP_Silk_insertion_sort_increasing_all_values_int16( +void silk_insertion_sort_increasing_all_values_int16( SKP_int16 *a, /* I/O: Unsorted / Sorted vector */ const SKP_int L /* I: Vector length */ ); /* NLSF stabilizer, for a single input data vector */ -void SKP_Silk_NLSF_stabilize( +void silk_NLSF_stabilize( SKP_int16 *NLSF_Q15, /* I/O: Unstable/stabilized normalized LSF vector in Q15 [L] */ const SKP_int16 *NDeltaMin_Q15, /* I: Normalized delta min vector in Q15, NDeltaMin_Q15[L] must be >= 1 [L+1] */ const SKP_int L /* I: Number of NLSF parameters in the input vector */ ); /* Laroia low complexity NLSF weights */ -void SKP_Silk_NLSF_VQ_weights_laroia( +void silk_NLSF_VQ_weights_laroia( SKP_int16 *pNLSFW_Q5, /* O: Pointer to input vector weights [D x 1] */ const SKP_int16 *pNLSF_Q15, /* I: Pointer to input vector [D x 1] */ const SKP_int D /* I: Input vector dimension (even) */ ); /* Compute reflection coefficients from input signal */ -void SKP_Silk_burg_modified( +void silk_burg_modified( SKP_int32 *res_nrg, /* O residual energy */ SKP_int *res_nrgQ, /* O residual energy Q value */ SKP_int32 A_Q16[], /* O prediction coefficients (length order) */ @@ -400,7 +389,7 @@ void SKP_Silk_burg_modified( ); /* Copy and multiply a vector by a constant */ -void SKP_Silk_scale_copy_vector16( +void silk_scale_copy_vector16( SKP_int16 *data_out, const SKP_int16 *data_in, SKP_int32 gain_Q16, /* I: gain in Q16 */ @@ -408,7 +397,7 @@ void SKP_Silk_scale_copy_vector16( ); /* Some for the LTP related function requires Q26 to work.*/ -void SKP_Silk_scale_vector32_Q26_lshift_18( +void silk_scale_vector32_Q26_lshift_18( SKP_int32 *data1, /* I/O: Q0/Q18 */ SKP_int32 gain_Q26, /* I: Q26 */ SKP_int dataSize /* I: length */ @@ -419,20 +408,20 @@ void SKP_Silk_scale_vector32_Q26_lshift_18( /********************************************************************/ /* return sum(inVec1[i]*inVec2[i]) */ -SKP_int32 SKP_Silk_inner_prod_aligned( +SKP_int32 silk_inner_prod_aligned( const SKP_int16 *const inVec1, /* I input vector 1 */ const SKP_int16 *const inVec2, /* I input vector 2 */ const SKP_int len /* I vector lengths */ ); -SKP_int32 SKP_Silk_inner_prod_aligned_scale( +SKP_int32 silk_inner_prod_aligned_scale( const SKP_int16 *const inVec1, /* I input vector 1 */ const SKP_int16 *const inVec2, /* I input vector 2 */ const SKP_int scale, /* I number of bits to shift */ const SKP_int len /* I vector lengths */ ); -SKP_int64 SKP_Silk_inner_prod16_aligned_64( +SKP_int64 silk_inner_prod16_aligned_64( const SKP_int16 *inVec1, /* I input vector 1 */ const SKP_int16 *inVec2, /* I input vector 2 */ const SKP_int len /* I vector lengths */ @@ -446,7 +435,7 @@ SKP_int64 SKP_Silk_inner_prod16_aligned_64( left. Output is 32bit int. Note: contemporary compilers recognize the C expression below and compile it into a 'ror' instruction if available. No need for inline ASM! */ -SKP_INLINE SKP_int32 SKP_ROR32( SKP_int32 a32, SKP_int rot ) +SKP_INLINE SKP_int32 silk_ROR32( SKP_int32 a32, SKP_int rot ) { SKP_uint32 x = (SKP_uint32) a32; SKP_uint32 r = (SKP_uint32) rot; @@ -506,7 +495,7 @@ SKP_INLINE SKP_int32 SKP_ROR32( SKP_int32 a32, SKP_int rot ) #define SKP_DIV32_16(a32, b16) ((SKP_int32)((a32) / (b16))) #define SKP_DIV32(a32, b32) ((SKP_int32)((a32) / (b32))) -// These macros enables checking for overflow in SKP_Silk_API_Debug.h +// These macros enables checking for overflow in silk_API_Debug.h #define SKP_ADD16(a, b) ((a) + (b)) #define SKP_ADD32(a, b) ((a) + (b)) #define SKP_ADD64(a, b) ((a) + (b)) @@ -581,15 +570,15 @@ SKP_INLINE SKP_int32 SKP_ROR32( SKP_int32 a32, SKP_int rot ) #define SKP_RSHIFT_ROUND64(a, shift) ((shift) == 1 ? ((a) >> 1) + ((a) & 1) : (((a) >> ((shift) - 1)) + 1) >> 1) /* Number of rightshift required to fit the multiplication */ -#define SKP_NSHIFT_MUL_32_32(a, b) ( -(31- (32-SKP_Silk_CLZ32(SKP_abs(a)) + (32-SKP_Silk_CLZ32(SKP_abs(b))))) ) -#define SKP_NSHIFT_MUL_16_16(a, b) ( -(15- (16-SKP_Silk_CLZ16(SKP_abs(a)) + (16-SKP_Silk_CLZ16(SKP_abs(b))))) ) +#define SKP_NSHIFT_MUL_32_32(a, b) ( -(31- (32-silk_CLZ32(SKP_abs(a)) + (32-silk_CLZ32(SKP_abs(b))))) ) +#define SKP_NSHIFT_MUL_16_16(a, b) ( -(15- (16-silk_CLZ16(SKP_abs(a)) + (16-silk_CLZ16(SKP_abs(b))))) ) #define SKP_min(a, b) (((a) < (b)) ? (a) : (b)) #define SKP_max(a, b) (((a) > (b)) ? (a) : (b)) /* Macro to convert floating-point constants to fixed-point */ -#define SKP_FIX_CONST( C, Q ) ((SKP_int32)((C) * ((SKP_int64)1 << (Q)) + 0.5)) +#define SILK_FIX_CONST( C, Q ) ((SKP_int32)((C) * ((SKP_int64)1 << (Q)) + 0.5)) /* SKP_min() versions with typecast in the function call */ SKP_INLINE SKP_int SKP_min_int(SKP_int a, SKP_int b) @@ -660,9 +649,9 @@ SKP_INLINE SKP_int64 SKP_max_64(SKP_int64 a, SKP_int64 b) // the following seems faster on x86 #define SKP_SMMUL(a32, b32) (SKP_int32)SKP_RSHIFT64(SKP_SMULL((a32), (b32)), 32) -#include "SKP_Silk_Inlines.h" -#include "SKP_Silk_MacroCount.h" -#include "SKP_Silk_MacroDebug.h" +#include "silk_Inlines.h" +#include "silk_MacroCount.h" +#include "silk_MacroDebug.h" #ifdef __cplusplus } diff --git a/silk/SKP_Silk_VAD.c b/silk/silk_VAD.c similarity index 84% rename from silk/SKP_Silk_VAD.c rename to silk/silk_VAD.c index e929d144..15295fde 100644 --- a/silk/SKP_Silk_VAD.c +++ b/silk/silk_VAD.c @@ -26,19 +26,19 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ #include -#include "SKP_Silk_main.h" +#include "silk_main.h" /**********************************/ /* Initialization of the Silk VAD */ /**********************************/ -SKP_int SKP_Silk_VAD_Init( /* O Return value, 0 if success */ - SKP_Silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */ +SKP_int silk_VAD_Init( /* O Return value, 0 if success */ + silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */ ) { SKP_int b, ret = 0; /* reset state memory */ - SKP_memset( psSilk_VAD, 0, sizeof( SKP_Silk_VAD_state ) ); + SKP_memset( psSilk_VAD, 0, sizeof( silk_VAD_state ) ); /* init noise levels */ /* Initialize array with approx pink noise levels (psd proportional to inverse of frequency) */ @@ -62,13 +62,13 @@ SKP_int SKP_Silk_VAD_Init( /* O Return value, 0 } /* Weighting factors for tilt measure */ -const static SKP_int32 tiltWeights[ VAD_N_BANDS ] = { 30000, 6000, -12000, -12000 }; +static const SKP_int32 tiltWeights[ VAD_N_BANDS ] = { 30000, 6000, -12000, -12000 }; /***************************************/ /* Get the speech activity level in Q8 */ /***************************************/ -SKP_int SKP_Silk_VAD_GetSA_Q8( /* O Return value, 0 if success */ - SKP_Silk_encoder_state *psEncC, /* I/O Encoder state */ +SKP_int silk_VAD_GetSA_Q8( /* O Return value, 0 if success */ + silk_encoder_state *psEncC, /* I/O Encoder state */ const SKP_int16 pIn[] /* I PCM input */ ) { @@ -81,7 +81,7 @@ SKP_int SKP_Silk_VAD_GetSA_Q8( /* O Return value, 0 if s SKP_int32 NrgToNoiseRatio_Q8[ VAD_N_BANDS ]; SKP_int32 speech_nrg, x_tmp; SKP_int ret = 0; - SKP_Silk_VAD_state *psSilk_VAD = &psEncC->sVAD; + silk_VAD_state *psSilk_VAD = &psEncC->sVAD; /* Safety checks */ SKP_assert( VAD_N_BANDS == 4 ); @@ -93,13 +93,13 @@ SKP_int SKP_Silk_VAD_GetSA_Q8( /* O Return value, 0 if s /* Filter and Decimate */ /***********************/ /* 0-8 kHz to 0-4 kHz and 4-8 kHz */ - SKP_Silk_ana_filt_bank_1( pIn, &psSilk_VAD->AnaState[ 0 ], &X[ 0 ][ 0 ], &X[ 3 ][ 0 ], psEncC->frame_length ); + silk_ana_filt_bank_1( pIn, &psSilk_VAD->AnaState[ 0 ], &X[ 0 ][ 0 ], &X[ 3 ][ 0 ], psEncC->frame_length ); /* 0-4 kHz to 0-2 kHz and 2-4 kHz */ - SKP_Silk_ana_filt_bank_1( &X[ 0 ][ 0 ], &psSilk_VAD->AnaState1[ 0 ], &X[ 0 ][ 0 ], &X[ 2 ][ 0 ], SKP_RSHIFT( psEncC->frame_length, 1 ) ); + silk_ana_filt_bank_1( &X[ 0 ][ 0 ], &psSilk_VAD->AnaState1[ 0 ], &X[ 0 ][ 0 ], &X[ 2 ][ 0 ], SKP_RSHIFT( psEncC->frame_length, 1 ) ); /* 0-2 kHz to 0-1 kHz and 1-2 kHz */ - SKP_Silk_ana_filt_bank_1( &X[ 0 ][ 0 ], &psSilk_VAD->AnaState2[ 0 ], &X[ 0 ][ 0 ], &X[ 1 ][ 0 ], SKP_RSHIFT( psEncC->frame_length, 2 ) ); + silk_ana_filt_bank_1( &X[ 0 ][ 0 ], &psSilk_VAD->AnaState2[ 0 ], &X[ 0 ][ 0 ], &X[ 1 ][ 0 ], SKP_RSHIFT( psEncC->frame_length, 2 ) ); /*********************************************/ /* HP filter on lowest band (differentiator) */ @@ -156,7 +156,7 @@ SKP_int SKP_Silk_VAD_GetSA_Q8( /* O Return value, 0 if s /********************/ /* Noise estimation */ /********************/ - SKP_Silk_VAD_GetNoiseLevels( &Xnrg[ 0 ], psSilk_VAD ); + silk_VAD_GetNoiseLevels( &Xnrg[ 0 ], psSilk_VAD ); /***********************************************/ /* Signal-plus-noise to noise ratio estimation */ @@ -174,7 +174,7 @@ SKP_int SKP_Silk_VAD_GetSA_Q8( /* O Return value, 0 if s } /* Convert to log domain */ - SNR_Q7 = SKP_Silk_lin2log( NrgToNoiseRatio_Q8[ b ] ) - 8 * 128; + SNR_Q7 = silk_lin2log( NrgToNoiseRatio_Q8[ b ] ) - 8 * 128; /* Sum-of-squares */ sumSquared = SKP_SMLABB( sumSquared, SNR_Q7, SNR_Q7 ); /* Q14 */ @@ -182,7 +182,7 @@ SKP_int SKP_Silk_VAD_GetSA_Q8( /* O Return value, 0 if s /* Tilt measure */ if( speech_nrg < ( 1 << 20 ) ) { /* Scale down SNR value for small subband speech energies */ - SNR_Q7 = SKP_SMULWB( SKP_LSHIFT( SKP_Silk_SQRT_APPROX( speech_nrg ), 6 ), SNR_Q7 ); + SNR_Q7 = SKP_SMULWB( SKP_LSHIFT( silk_SQRT_APPROX( speech_nrg ), 6 ), SNR_Q7 ); } input_tilt = SKP_SMLAWB( input_tilt, tiltWeights[ b ], SNR_Q7 ); } else { @@ -194,17 +194,17 @@ SKP_int SKP_Silk_VAD_GetSA_Q8( /* O Return value, 0 if s sumSquared = SKP_DIV32_16( sumSquared, VAD_N_BANDS ); /* Q14 */ /* Root-mean-square approximation, scale to dBs, and write to output pointer */ - pSNR_dB_Q7 = ( SKP_int16 )( 3 * SKP_Silk_SQRT_APPROX( sumSquared ) ); /* Q7 */ + pSNR_dB_Q7 = ( SKP_int16 )( 3 * silk_SQRT_APPROX( sumSquared ) ); /* Q7 */ /*********************************/ /* Speech Probability Estimation */ /*********************************/ - SA_Q15 = SKP_Silk_sigm_Q15( SKP_SMULWB( VAD_SNR_FACTOR_Q16, pSNR_dB_Q7 ) - VAD_NEGATIVE_OFFSET_Q5 ); + SA_Q15 = silk_sigm_Q15( SKP_SMULWB( VAD_SNR_FACTOR_Q16, pSNR_dB_Q7 ) - VAD_NEGATIVE_OFFSET_Q5 ); /**************************/ /* Frequency Tilt Measure */ /**************************/ - psEncC->input_tilt_Q15 = SKP_LSHIFT( SKP_Silk_sigm_Q15( input_tilt ) - 16384, 1 ); + psEncC->input_tilt_Q15 = SKP_LSHIFT( silk_sigm_Q15( input_tilt ) - 16384, 1 ); /**************************************************/ /* Scale the sigmoid output based on power levels */ @@ -226,7 +226,7 @@ SKP_int SKP_Silk_VAD_GetSA_Q8( /* O Return value, 0 if s } /* square-root */ - speech_nrg = SKP_Silk_SQRT_APPROX( speech_nrg ); + speech_nrg = silk_SQRT_APPROX( speech_nrg ); SA_Q15 = SKP_SMULWB( 32768 + speech_nrg, SA_Q15 ); } @@ -249,9 +249,9 @@ SKP_int SKP_Silk_VAD_GetSA_Q8( /* O Return value, 0 if s NrgToNoiseRatio_Q8[ b ] - psSilk_VAD->NrgRatioSmth_Q8[ b ], smooth_coef_Q16 ); /* signal to noise ratio in dB per band */ - SNR_Q7 = 3 * ( SKP_Silk_lin2log( psSilk_VAD->NrgRatioSmth_Q8[b] ) - 8 * 128 ); + SNR_Q7 = 3 * ( silk_lin2log( psSilk_VAD->NrgRatioSmth_Q8[b] ) - 8 * 128 ); /* quality = sigmoid( 0.25 * ( SNR_dB - 16 ) ); */ - psEncC->input_quality_bands_Q15[ b ] = SKP_Silk_sigm_Q15( SKP_RSHIFT( SNR_Q7 - 16 * 128, 4 ) ); + psEncC->input_quality_bands_Q15[ b ] = silk_sigm_Q15( SKP_RSHIFT( SNR_Q7 - 16 * 128, 4 ) ); } return( ret ); @@ -260,9 +260,9 @@ SKP_int SKP_Silk_VAD_GetSA_Q8( /* O Return value, 0 if s /**************************/ /* Noise level estimation */ /**************************/ -void SKP_Silk_VAD_GetNoiseLevels( +void silk_VAD_GetNoiseLevels( const SKP_int32 pX[ VAD_N_BANDS ], /* I subband energies */ - SKP_Silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */ + silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */ ) { SKP_int k; diff --git a/silk/SKP_Silk_VQ_WMat_EC.c b/silk/silk_VQ_WMat_EC.c similarity index 97% rename from silk/SKP_Silk_VQ_WMat_EC.c rename to silk/silk_VQ_WMat_EC.c index 1bcd91c2..bf123eb7 100644 --- a/silk/SKP_Silk_VQ_WMat_EC.c +++ b/silk/silk_VQ_WMat_EC.c @@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" +#include "silk_main.h" /* Entropy constrained matrix-weighted VQ, hard-coded to 5-element vectors, for a single input data vector */ -void SKP_Silk_VQ_WMat_EC( +void silk_VQ_WMat_EC( SKP_int8 *ind, /* O index of best codebook vector */ SKP_int32 *rate_dist_Q14, /* O best weighted quantization error + mu * rate*/ const SKP_int16 *in_Q14, /* I input vector to be quantized */ diff --git a/silk/SKP_Silk_ana_filt_bank_1.c b/silk/silk_ana_filt_bank_1.c similarity index 82% rename from silk/SKP_Silk_ana_filt_bank_1.c rename to silk/silk_ana_filt_bank_1.c index 66bc6a44..7ad8b926 100644 --- a/silk/SKP_Silk_ana_filt_bank_1.c +++ b/silk/silk_ana_filt_bank_1.c @@ -25,15 +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. ***********************************************************************/ -/* * - * SKP_ana_filt_bank_1.c * - * * - * Split signal into two decimated bands using first-order allpass filters * - * * - * Copyright 2006 (c), Skype Limited * - * Date: 060221 * - * */ -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_SigProc_FIX.h" /* Coefficients for 2-band filter bank based on first-order allpass filters */ // old @@ -41,7 +33,7 @@ static SKP_int16 A_fb1_20[ 1 ] = { 5394 << 1 }; static SKP_int16 A_fb1_21[ 1 ] = { 20623 << 1 }; /* wrap-around to negative number is intentional */ /* Split signal into two decimated bands using first-order allpass filters */ -void SKP_Silk_ana_filt_bank_1( +void silk_ana_filt_bank_1( const SKP_int16 *in, /* I: Input signal [N] */ SKP_int32 *S, /* I/O: State vector [2] */ SKP_int16 *outL, /* O: Low band [N/2] */ diff --git a/silk/SKP_Silk_apply_sine_window.c b/silk/silk_apply_sine_window.c similarity index 96% rename from silk/SKP_Silk_apply_sine_window.c rename to silk/silk_apply_sine_window.c index 87d71f89..ce8acf9c 100644 --- a/silk/SKP_Silk_apply_sine_window.c +++ b/silk/silk_apply_sine_window.c @@ -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. ***********************************************************************/ -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_SigProc_FIX.h" /* Apply sine window to signal vector. */ /* Window types: */ @@ -43,7 +43,7 @@ static SKP_int16 freq_table_Q16[ 27 ] = { 2313, 2214, 2123, 2038, 1961, 1889, 1822, 1760, 1702, }; -void SKP_Silk_apply_sine_window( +void silk_apply_sine_window( SKP_int16 px_win[], /* O Pointer to windowed signal */ const SKP_int16 px[], /* I Pointer to input signal */ const SKP_int win_type, /* I Selects a window type */ diff --git a/silk/SKP_Silk_array_maxabs.c b/silk/silk_array_maxabs.c similarity index 75% rename from silk/SKP_Silk_array_maxabs.c rename to silk/silk_array_maxabs.c index 90b58b2a..8fd59111 100644 --- a/silk/SKP_Silk_array_maxabs.c +++ b/silk/silk_array_maxabs.c @@ -25,19 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -/* * - * SKP_Silk_int16_array_maxabs.c * - * * - * Function that returns the maximum absolut value of * - * the input vector * - * * - * Copyright 2006 (c), Skype Limited * - * Date: 060221 * - * */ -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_SigProc_FIX.h" /* Function that returns the maximum absolut value of the input vector */ -SKP_int16 SKP_Silk_int16_array_maxabs( /* O Maximum absolute value, max: 2^15-1 */ +SKP_int16 silk_int16_array_maxabs( /* O Maximum absolute value, max: 2^15-1 */ const SKP_int16 *vec, /* I Input vector [len] */ const SKP_int32 len /* I Length of input vector */ ) diff --git a/silk/SKP_Silk_autocorr.c b/silk/silk_autocorr.c similarity index 87% rename from silk/SKP_Silk_autocorr.c rename to silk/silk_autocorr.c index c7f8b292..1b613639 100644 --- a/silk/SKP_Silk_autocorr.c +++ b/silk/silk_autocorr.c @@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_SigProc_FIX.h" /* Compute autocorrelation */ -void SKP_Silk_autocorr( +void silk_autocorr( SKP_int32 *results, /* O Result (length correlationCount) */ SKP_int *scale, /* O Scaling of the correlation vector */ const SKP_int16 *inputData, /* I Input data to correlate */ @@ -42,13 +42,13 @@ void SKP_Silk_autocorr( corrCount = SKP_min_int( inputDataSize, correlationCount ); /* compute energy (zero-lag correlation) */ - corr64 = SKP_Silk_inner_prod16_aligned_64( inputData, inputData, inputDataSize ); + corr64 = silk_inner_prod16_aligned_64( inputData, inputData, inputDataSize ); /* deal with all-zero input data */ corr64 += 1; /* number of leading zeros */ - lz = SKP_Silk_CLZ64( corr64 ); + lz = silk_CLZ64( corr64 ); /* scaling: number of right shifts applied to correlations */ nRightShifts = 35 - lz; @@ -59,14 +59,14 @@ void SKP_Silk_autocorr( /* compute remaining correlations based on int32 inner product */ for( i = 1; i < corrCount; i++ ) { - results[ i ] = SKP_LSHIFT( SKP_Silk_inner_prod_aligned( inputData, inputData + i, inputDataSize - i ), -nRightShifts ); + results[ i ] = SKP_LSHIFT( silk_inner_prod_aligned( inputData, inputData + i, inputDataSize - i ), -nRightShifts ); } } else { results[ 0 ] = (SKP_int32)SKP_CHECK_FIT32( SKP_RSHIFT64( corr64, nRightShifts ) ); /* compute remaining correlations based on int64 inner product */ for( i = 1; i < corrCount; i++ ) { - results[ i ] = (SKP_int32)SKP_CHECK_FIT32( SKP_RSHIFT64( SKP_Silk_inner_prod16_aligned_64( inputData, inputData + i, inputDataSize - i ), nRightShifts ) ); + results[ i ] = (SKP_int32)SKP_CHECK_FIT32( SKP_RSHIFT64( silk_inner_prod16_aligned_64( inputData, inputData + i, inputDataSize - i ), nRightShifts ) ); } } } diff --git a/silk/SKP_Silk_biquad_alt.c b/silk/silk_biquad_alt.c similarity index 95% rename from silk/SKP_Silk_biquad_alt.c rename to silk/silk_biquad_alt.c index f7ffc33d..74bf2c45 100644 --- a/silk/SKP_Silk_biquad_alt.c +++ b/silk/silk_biquad_alt.c @@ -26,16 +26,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ /* * - * SKP_Silk_biquad_alt.c * + * silk_biquad_alt.c * * * * Second order ARMA filter * * Can handle slowly varying filter coefficients * * */ -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_SigProc_FIX.h" /* Second order ARMA filter, alternative implementation */ -void SKP_Silk_biquad_alt( +void silk_biquad_alt( const SKP_int16 *in, /* I: Input signal */ const SKP_int32 *B_Q28, /* I: MA coefficients [3] */ const SKP_int32 *A_Q28, /* I: AR coefficients [2] */ diff --git a/silk/SKP_Silk_burg_modified.c b/silk/silk_burg_modified.c similarity index 87% rename from silk/SKP_Silk_burg_modified.c rename to silk/silk_burg_modified.c index 235184ff..c4f330ef 100644 --- a/silk/SKP_Silk_burg_modified.c +++ b/silk/silk_burg_modified.c @@ -25,17 +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. ***********************************************************************/ -/* * - * SKP_Silk_burg_modified.c * - * * - * Calculates the reflection coefficients from the input vector * - * Input vector contains nb_subfr sub vectors of length L_sub + D * - * * - * Copyright 2009 (c), Skype Limited * - * Date: 100105 * - */ - -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_SigProc_FIX.h" #define MAX_FRAME_SIZE 384 // subfr_length * nb_subfr = ( 0.005 * 16000 + 16 ) * 4 = 384 #define MAX_NB_SUBFR 4 @@ -46,7 +36,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define MAX_RSHIFTS (32 - QA) /* Compute reflection coefficients from input signal */ -void SKP_Silk_burg_modified( +void silk_burg_modified( SKP_int32 *res_nrg, /* O residual energy */ SKP_int *res_nrg_Q, /* O residual energy Q value */ SKP_int32 A_Q16[], /* O prediction coefficients (length order) */ @@ -61,25 +51,25 @@ void SKP_Silk_burg_modified( SKP_int32 C0, num, nrg, rc_Q31, Atmp_QA, Atmp1, tmp1, tmp2, x1, x2; const SKP_int16 *x_ptr; - SKP_int32 C_first_row[ SKP_Silk_MAX_ORDER_LPC ]; - SKP_int32 C_last_row[ SKP_Silk_MAX_ORDER_LPC ]; - SKP_int32 Af_QA[ SKP_Silk_MAX_ORDER_LPC ]; + SKP_int32 C_first_row[ SILK_MAX_ORDER_LPC ]; + SKP_int32 C_last_row[ SILK_MAX_ORDER_LPC ]; + SKP_int32 Af_QA[ SILK_MAX_ORDER_LPC ]; - SKP_int32 CAf[ SKP_Silk_MAX_ORDER_LPC + 1 ]; - SKP_int32 CAb[ SKP_Silk_MAX_ORDER_LPC + 1 ]; + SKP_int32 CAf[ SILK_MAX_ORDER_LPC + 1 ]; + SKP_int32 CAb[ SILK_MAX_ORDER_LPC + 1 ]; SKP_assert( subfr_length * nb_subfr <= MAX_FRAME_SIZE ); SKP_assert( nb_subfr <= MAX_NB_SUBFR ); /* Compute autocorrelations, added over subframes */ - SKP_Silk_sum_sqr_shift( &C0, &rshifts, x, nb_subfr * subfr_length ); + silk_sum_sqr_shift( &C0, &rshifts, x, nb_subfr * subfr_length ); if( rshifts > MAX_RSHIFTS ) { C0 = SKP_LSHIFT32( C0, rshifts - MAX_RSHIFTS ); SKP_assert( C0 > 0 ); rshifts = MAX_RSHIFTS; } else { - lz = SKP_Silk_CLZ32( C0 ) - 1; + lz = silk_CLZ32( C0 ) - 1; rshifts_extra = N_BITS_HEAD_ROOM - lz; if( rshifts_extra > 0 ) { rshifts_extra = SKP_min( rshifts_extra, MAX_RSHIFTS - rshifts ); @@ -90,13 +80,13 @@ void SKP_Silk_burg_modified( } rshifts += rshifts_extra; } - SKP_memset( C_first_row, 0, SKP_Silk_MAX_ORDER_LPC * sizeof( SKP_int32 ) ); + SKP_memset( C_first_row, 0, SILK_MAX_ORDER_LPC * sizeof( SKP_int32 ) ); if( rshifts > 0 ) { for( s = 0; s < nb_subfr; s++ ) { x_ptr = x + s * subfr_length; for( n = 1; n < D + 1; n++ ) { C_first_row[ n - 1 ] += (SKP_int32)SKP_RSHIFT64( - SKP_Silk_inner_prod16_aligned_64( x_ptr, x_ptr + n, subfr_length - n ), rshifts ); + silk_inner_prod16_aligned_64( x_ptr, x_ptr + n, subfr_length - n ), rshifts ); } } } else { @@ -104,11 +94,11 @@ void SKP_Silk_burg_modified( x_ptr = x + s * subfr_length; for( n = 1; n < D + 1; n++ ) { C_first_row[ n - 1 ] += SKP_LSHIFT32( - SKP_Silk_inner_prod_aligned( x_ptr, x_ptr + n, subfr_length - n ), -rshifts ); + silk_inner_prod_aligned( x_ptr, x_ptr + n, subfr_length - n ), -rshifts ); } } } - SKP_memcpy( C_last_row, C_first_row, SKP_Silk_MAX_ORDER_LPC * sizeof( SKP_int32 ) ); + SKP_memcpy( C_last_row, C_first_row, SILK_MAX_ORDER_LPC * sizeof( SKP_int32 ) ); /* Initialize */ CAb[ 0 ] = CAf[ 0 ] = C0 + SKP_SMMUL( WhiteNoiseFrac_Q32, C0 ) + 1; // Q(-rshifts) @@ -171,7 +161,7 @@ void SKP_Silk_burg_modified( nrg = SKP_ADD32( CAb[ 0 ], CAf[ 0 ] ); // Q( 1-rshifts ) for( k = 0; k < n; k++ ) { Atmp_QA = Af_QA[ k ]; - lz = SKP_Silk_CLZ32( SKP_abs( Atmp_QA ) ) - 1; + lz = silk_CLZ32( SKP_abs( Atmp_QA ) ) - 1; lz = SKP_min( 32 - QA, lz ); Atmp1 = SKP_LSHIFT32( Atmp_QA, lz ); // Q( QA + lz ) @@ -188,7 +178,7 @@ void SKP_Silk_burg_modified( /* Calculate the next order reflection (parcor) coefficient */ if( SKP_abs( num ) < nrg ) { - rc_Q31 = SKP_DIV32_varQ( num, nrg, 31 ); + rc_Q31 = silk_DIV32_varQ( num, nrg, 31 ); } else { /* Negative energy or ratio too high; set remaining coefficients to zero and exit loop */ SKP_memset( &Af_QA[ n ], 0, ( D - n ) * sizeof( SKP_int32 ) ); diff --git a/silk/SKP_Silk_bwexpander.c b/silk/silk_bwexpander.c similarity index 96% rename from silk/SKP_Silk_bwexpander.c rename to silk/silk_bwexpander.c index 9cdc64a0..8131ffa7 100644 --- a/silk/SKP_Silk_bwexpander.c +++ b/silk/silk_bwexpander.c @@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_SigProc_FIX.h" /* Chirp (bandwidth expand) LP AR filter */ -void SKP_Silk_bwexpander( +void silk_bwexpander( SKP_int16 *ar, /* I/O AR filter to be expanded (without leading 1) */ const SKP_int d, /* I Length of ar */ SKP_int32 chirp_Q16 /* I Chirp factor (typically in the range 0 to 1) */ diff --git a/silk/SKP_Silk_bwexpander_32.c b/silk/silk_bwexpander_32.c similarity index 95% rename from silk/SKP_Silk_bwexpander_32.c rename to silk/silk_bwexpander_32.c index f5f5e907..8e70ade2 100644 --- a/silk/SKP_Silk_bwexpander_32.c +++ b/silk/silk_bwexpander_32.c @@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_SigProc_FIX.h" /* Chirp (bandwidth expand) LP AR filter */ -void SKP_Silk_bwexpander_32( +void silk_bwexpander_32( SKP_int32 *ar, /* I/O AR filter to be expanded (without leading 1) */ const SKP_int d, /* I Length of ar */ SKP_int32 chirp_Q16 /* I Chirp factor in Q16 */ diff --git a/silk/SKP_Silk_check_control_input.c b/silk/silk_check_control_input.c similarity index 77% rename from silk/SKP_Silk_check_control_input.c rename to silk/silk_check_control_input.c index 0ddf7fae..d787ebaa 100644 --- a/silk/SKP_Silk_check_control_input.c +++ b/silk/silk_check_control_input.c @@ -25,13 +25,13 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" -#include "SKP_Silk_control.h" -#include "SKP_Silk_errors.h" +#include "silk_main.h" +#include "silk_control.h" +#include "silk_errors.h" /* Check encoder control struct */ SKP_int check_control_input( - SKP_SILK_SDK_EncControlStruct *encControl /* I: Control structure */ + silk_EncControlStruct *encControl /* I: Control structure */ ) { SKP_assert( encControl != NULL ); @@ -56,39 +56,47 @@ SKP_int check_control_input( ( encControl->maxInternalSampleRate < encControl->desiredInternalSampleRate ) || ( encControl->minInternalSampleRate > encControl->maxInternalSampleRate ) ) { SKP_assert( 0 ); - return SKP_SILK_ENC_FS_NOT_SUPPORTED; + return SILK_ENC_FS_NOT_SUPPORTED; } if( encControl->payloadSize_ms != 10 && encControl->payloadSize_ms != 20 && encControl->payloadSize_ms != 40 && encControl->payloadSize_ms != 60 ) { SKP_assert( 0 ); - return SKP_SILK_ENC_PACKET_SIZE_NOT_SUPPORTED; + return SILK_ENC_PACKET_SIZE_NOT_SUPPORTED; } if( encControl->packetLossPercentage < 0 || encControl->packetLossPercentage > 100 ) { SKP_assert( 0 ); - return SKP_SILK_ENC_INVALID_LOSS_RATE; + return SILK_ENC_INVALID_LOSS_RATE; } if( encControl->useDTX < 0 || encControl->useDTX > 1 ) { SKP_assert( 0 ); - return SKP_SILK_ENC_INVALID_DTX_SETTING; + return SILK_ENC_INVALID_DTX_SETTING; } if( encControl->useCBR < 0 || encControl->useCBR > 1 ) { SKP_assert( 0 ); - return SKP_SILK_ENC_INVALID_CBR_SETTING; + return SILK_ENC_INVALID_CBR_SETTING; } if( encControl->useInBandFEC < 0 || encControl->useInBandFEC > 1 ) { SKP_assert( 0 ); - return SKP_SILK_ENC_INVALID_INBAND_FEC_SETTING; + return SILK_ENC_INVALID_INBAND_FEC_SETTING; } - if( encControl->nChannels < 1 || encControl->nChannels > ENCODER_NUM_CHANNELS ) { + if( encControl->nChannelsAPI < 1 || encControl->nChannelsAPI > ENCODER_NUM_CHANNELS ) { SKP_assert( 0 ); - return SKP_SILK_ENC_INVALID_NUMBER_OF_CHANNELS_ERROR; + return SILK_ENC_INVALID_NUMBER_OF_CHANNELS_ERROR; + } + if( encControl->nChannelsInternal < 1 || encControl->nChannelsInternal > ENCODER_NUM_CHANNELS ) { + SKP_assert( 0 ); + return SILK_ENC_INVALID_NUMBER_OF_CHANNELS_ERROR; + } + if( encControl->nChannelsInternal > encControl->nChannelsAPI ) { + SKP_assert( 0 ); + return SILK_ENC_INVALID_NUMBER_OF_CHANNELS_ERROR; } if( encControl->complexity < 0 || encControl->complexity > 10 ) { SKP_assert( 0 ); - return SKP_SILK_ENC_INVALID_COMPLEXITY_SETTING; + return SILK_ENC_INVALID_COMPLEXITY_SETTING; } - return SKP_SILK_NO_ERROR; + return SILK_NO_ERROR; } diff --git a/silk/SKP_Silk_code_signs.c b/silk/silk_code_signs.c similarity index 95% rename from silk/SKP_Silk_code_signs.c rename to silk/silk_code_signs.c index ee15f981..86ae69ed 100644 --- a/silk/SKP_Silk_code_signs.c +++ b/silk/silk_code_signs.c @@ -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. ***********************************************************************/ -#include "SKP_Silk_main.h" +#include "silk_main.h" //#define SKP_enc_map(a) ((a) > 0 ? 1 : 0) //#define SKP_dec_map(a) ((a) > 0 ? 1 : -1) @@ -34,7 +34,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define SKP_dec_map(a) ( SKP_LSHIFT( (a), 1 ) - 1 ) /* Encodes signs of excitation */ -void SKP_Silk_encode_signs( +void silk_encode_signs( ec_enc *psRangeEnc, /* I/O Compressor data structure */ const SKP_int8 pulses[], /* I pulse signal */ SKP_int length, /* I length of input */ @@ -51,7 +51,7 @@ void SKP_Silk_encode_signs( icdf[ 1 ] = 0; q_ptr = pulses; i = SKP_SMULBB( 6, SKP_ADD_LSHIFT( quantOffsetType, signalType, 1 ) ); - icdf_ptr = &SKP_Silk_sign_iCDF[ i ]; + icdf_ptr = &silk_sign_iCDF[ i ]; length = SKP_RSHIFT( length + SHELL_CODEC_FRAME_LENGTH/2, LOG2_SHELL_CODEC_FRAME_LENGTH ); for( i = 0; i < length; i++ ) { p = sum_pulses[ i ]; @@ -68,7 +68,7 @@ void SKP_Silk_encode_signs( } /* Decodes signs of excitation */ -void SKP_Silk_decode_signs( +void silk_decode_signs( ec_dec *psRangeDec, /* I/O Compressor data structure */ SKP_int pulses[], /* I/O pulse signal */ SKP_int length, /* I length of input */ @@ -85,7 +85,7 @@ void SKP_Silk_decode_signs( icdf[ 1 ] = 0; q_ptr = pulses; i = SKP_SMULBB( 6, SKP_ADD_LSHIFT( quantOffsetType, signalType, 1 ) ); - icdf_ptr = &SKP_Silk_sign_iCDF[ i ]; + icdf_ptr = &silk_sign_iCDF[ i ]; length = SKP_RSHIFT( length + SHELL_CODEC_FRAME_LENGTH/2, LOG2_SHELL_CODEC_FRAME_LENGTH ); for( i = 0; i < length; i++ ) { p = sum_pulses[ i ]; diff --git a/silk/silk_common.vcxproj b/silk/silk_common.vcxproj index 748da77d..0a18f9df 100644 --- a/silk/silk_common.vcxproj +++ b/silk/silk_common.vcxproj @@ -86,125 +86,127 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/silk/silk_common.vcxproj.filters b/silk/silk_common.vcxproj.filters index 561e1c0d..455efe85 100644 --- a/silk/silk_common.vcxproj.filters +++ b/silk/silk_common.vcxproj.filters @@ -18,357 +18,363 @@ - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + Source Files - + + Source Files + + Source Files - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - Header Files - + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + Header Files diff --git a/silk/SKP_Silk_control.h b/silk/silk_control.h similarity index 89% rename from silk/SKP_Silk_control.h rename to silk/silk_control.h index d970fac8..a74c5420 100644 --- a/silk/SKP_Silk_control.h +++ b/silk/silk_control.h @@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#ifndef SKP_SILK_CONTROL_H -#define SKP_SILK_CONTROL_H +#ifndef SILK_CONTROL_H +#define SILK_CONTROL_H -#include "SKP_Silk_typedef.h" +#include "silk_typedef.h" #ifdef __cplusplus extern "C" @@ -45,7 +45,10 @@ extern "C" /***********************************************/ typedef struct { /* I: Number of channels; 1/2 */ - SKP_int32 nChannels; + SKP_int32 nChannelsAPI; + + /* I: Number of channels; 1/2 */ + SKP_int32 nChannelsInternal; /* I: Input signal sampling rate in Hertz; 8000/12000/16000/24000/32000/44100/48000 */ SKP_int32 API_sampleRate; @@ -88,30 +91,30 @@ typedef struct { /* O: Flag that SILK runs in WB mode without variable LP filter (use for switching between WB/SWB/FB) */ SKP_int inWBmodeWithoutVariableLP; -} SKP_SILK_SDK_EncControlStruct; + + /* O: Stereo width */ + SKP_int stereoWidth_Q14; +} silk_EncControlStruct; /**************************************************************************/ /* Structure for controlling decoder operation and reading decoder status */ /**************************************************************************/ typedef struct { /* I: Number of channels; 1/2 */ - SKP_int32 nChannels; + SKP_int32 nChannelsAPI; + + /* I: Number of channels; 1/2 */ + SKP_int32 nChannelsInternal; /* I: Output signal sampling rate in Hertz; 8000/12000/16000/24000/32000/44100/48000 */ SKP_int32 API_sampleRate; - /* I: Number of samples per packet in milliseconds; 10/20/40/60 */ - SKP_int payloadSize_ms; - /* I: Internal sampling rate used, in Hertz; 8000/12000/16000 */ SKP_int32 internalSampleRate; - /* O: Number of samples per frame */ - SKP_int frameSize; - - /* O: Frames per payload 1, 2, 3 */ - SKP_int framesPerPayload; -} SKP_SILK_SDK_DecControlStruct; + /* I: Number of samples per packet in milliseconds; 10/20/40/60 */ + SKP_int payloadSize_ms; +} silk_DecControlStruct; #ifdef __cplusplus } diff --git a/silk/SKP_Silk_control_SNR.c b/silk/silk_control_SNR.c similarity index 78% rename from silk/SKP_Silk_control_SNR.c rename to silk/silk_control_SNR.c index 81618c25..28f0ef99 100644 --- a/silk/SKP_Silk_control_SNR.c +++ b/silk/silk_control_SNR.c @@ -25,16 +25,16 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" -#include "SKP_Silk_tuning_parameters.h" +#include "silk_main.h" +#include "silk_tuning_parameters.h" /* Control SNR of redidual quantizer */ -SKP_int SKP_Silk_control_SNR( - SKP_Silk_encoder_state *psEncC, /* I/O Pointer to Silk encoder state */ +SKP_int silk_control_SNR( + silk_encoder_state *psEncC, /* I/O Pointer to Silk encoder state */ SKP_int32 TargetRate_bps /* I Target max bitrate (bps) */ ) { - SKP_int k, ret = SKP_SILK_NO_ERROR; + SKP_int k, ret = SILK_NO_ERROR; SKP_int32 frac_Q6; const SKP_int32 *rateTable; @@ -45,13 +45,11 @@ SKP_int SKP_Silk_control_SNR( /* If new TargetRate_bps, translate to SNR_dB value */ if( psEncC->fs_kHz == 8 ) { - rateTable = TargetRate_table_NB; + rateTable = silk_TargetRate_table_NB; } else if( psEncC->fs_kHz == 12 ) { - rateTable = TargetRate_table_MB; - } else if( psEncC->fs_kHz == 16 ) { - rateTable = TargetRate_table_WB; + rateTable = silk_TargetRate_table_MB; } else { - SKP_assert( 0 ); + rateTable = silk_TargetRate_table_WB; } /* Reduce bitrate for 10 ms modes in these calculations */ @@ -64,10 +62,15 @@ SKP_int SKP_Silk_control_SNR( if( TargetRate_bps <= rateTable[ k ] ) { frac_Q6 = SKP_DIV32( SKP_LSHIFT( TargetRate_bps - rateTable[ k - 1 ], 6 ), rateTable[ k ] - rateTable[ k - 1 ] ); - psEncC->SNR_dB_Q7 = SKP_LSHIFT( SNR_table_Q1[ k - 1 ], 6 ) + SKP_MUL( frac_Q6, SNR_table_Q1[ k ] - SNR_table_Q1[ k - 1 ] ); + psEncC->SNR_dB_Q7 = SKP_LSHIFT( silk_SNR_table_Q1[ k - 1 ], 6 ) + SKP_MUL( frac_Q6, silk_SNR_table_Q1[ k ] - silk_SNR_table_Q1[ k - 1 ] ); break; } } + + /* Reduce coding quality whenever LBRR is enabled, to free up some bits */ + if( psEncC->LBRR_enabled ) { + psEncC->SNR_dB_Q7 = SKP_SMLABB( psEncC->SNR_dB_Q7, 12 - psEncC->LBRR_GainIncreases, SILK_FIX_CONST( -0.25, 7 ) ); + } } return ret; diff --git a/silk/SKP_Silk_control_audio_bandwidth.c b/silk/silk_control_audio_bandwidth.c similarity index 93% rename from silk/SKP_Silk_control_audio_bandwidth.c rename to silk/silk_control_audio_bandwidth.c index b2d0e042..8f887dca 100644 --- a/silk/SKP_Silk_control_audio_bandwidth.c +++ b/silk/silk_control_audio_bandwidth.c @@ -25,12 +25,12 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" -#include "SKP_Silk_tuning_parameters.h" +#include "silk_main.h" +#include "silk_tuning_parameters.h" /* Control internal sampling rate */ -SKP_int SKP_Silk_control_audio_bandwidth( - SKP_Silk_encoder_state *psEncC /* I/O Pointer to Silk encoder state */ +SKP_int silk_control_audio_bandwidth( + silk_encoder_state *psEncC /* I/O Pointer to Silk encoder state */ ) { SKP_int fs_kHz; diff --git a/silk/SKP_Silk_control_codec.c b/silk/silk_control_codec.c similarity index 68% rename from silk/SKP_Silk_control_codec.c rename to silk/silk_control_codec.c index 6d813d49..bc8e46e9 100644 --- a/silk/SKP_Silk_control_codec.c +++ b/silk/silk_control_codec.c @@ -25,45 +25,41 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "SKP_Silk_tuning_parameters.h" +#include "silk_tuning_parameters.h" #ifdef FIXED_POINT -#include "SKP_Silk_main_FIX.h" -#define SKP_Silk_encoder_state_Fxx SKP_Silk_encoder_state_FIX +#include "silk_main_FIX.h" +#define silk_encoder_state_Fxx silk_encoder_state_FIX #else -#include "SKP_Silk_main_FLP.h" -#define SKP_Silk_encoder_state_Fxx SKP_Silk_encoder_state_FLP +#include "silk_main_FLP.h" +#define silk_encoder_state_Fxx silk_encoder_state_FLP #endif -SKP_int SKP_Silk_setup_resamplers( - SKP_Silk_encoder_state_Fxx *psEnc, /* I/O */ +SKP_int silk_setup_resamplers( + silk_encoder_state_Fxx *psEnc, /* I/O */ SKP_int fs_kHz /* I */ ); -SKP_int SKP_Silk_setup_fs( - SKP_Silk_encoder_state_Fxx *psEnc, /* I/O */ +SKP_int silk_setup_fs( + silk_encoder_state_Fxx *psEnc, /* I/O */ SKP_int fs_kHz, /* I */ SKP_int PacketSize_ms /* I */ ); -SKP_int SKP_Silk_setup_complexity( - SKP_Silk_encoder_state *psEncC, /* I/O */ +SKP_int silk_setup_complexity( + silk_encoder_state *psEncC, /* I/O */ SKP_int Complexity /* I */ ); -SKP_INLINE SKP_int SKP_Silk_setup_LBRR( - SKP_Silk_encoder_state *psEncC, /* I/O */ +SKP_INLINE SKP_int silk_setup_LBRR( + silk_encoder_state *psEncC, /* I/O */ const SKP_int32 TargetRate_bps /* I */ ); /* Control encoder */ -SKP_int SKP_Silk_control_encoder( - SKP_Silk_encoder_state_Fxx *psEnc, /* I/O Pointer to Silk encoder state */ - SKP_SILK_SDK_EncControlStruct *encControl, /* I: Control structure */ +SKP_int silk_control_encoder( + silk_encoder_state_Fxx *psEnc, /* I/O Pointer to Silk encoder state */ + silk_EncControlStruct *encControl, /* I: Control structure */ const SKP_int32 TargetRate_bps, /* I Target max bitrate (bps) */ const SKP_int allow_bw_switch, /* I Flag to allow switching audio bandwidth */ const SKP_int channelNb /* I Channel number */ @@ -78,14 +74,15 @@ SKP_int SKP_Silk_control_encoder( psEnc->sCmn.minInternal_fs_Hz = encControl->minInternalSampleRate; psEnc->sCmn.desiredInternal_fs_Hz = encControl->desiredInternalSampleRate; psEnc->sCmn.useInBandFEC = encControl->useInBandFEC; - psEnc->sCmn.nChannels = encControl->nChannels; + psEnc->sCmn.nChannelsAPI = encControl->nChannelsAPI; + psEnc->sCmn.nChannelsInternal = encControl->nChannelsInternal; psEnc->sCmn.allow_bandwidth_switch = allow_bw_switch; psEnc->sCmn.channelNb = channelNb; if( psEnc->sCmn.controlled_since_last_payload != 0 && psEnc->sCmn.prefillFlag == 0 ) { if( psEnc->sCmn.API_fs_Hz != psEnc->sCmn.prev_API_fs_Hz && psEnc->sCmn.fs_kHz > 0 ) { /* Change in API sampling rate in the middle of encoding a packet */ - ret += SKP_Silk_setup_resamplers( psEnc, psEnc->sCmn.fs_kHz ); + ret += silk_setup_resamplers( psEnc, psEnc->sCmn.fs_kHz ); } return ret; } @@ -95,22 +92,22 @@ SKP_int SKP_Silk_control_encoder( /********************************************/ /* Determine internal sampling rate */ /********************************************/ - fs_kHz = SKP_Silk_control_audio_bandwidth( &psEnc->sCmn ); + fs_kHz = silk_control_audio_bandwidth( &psEnc->sCmn ); /********************************************/ /* Prepare resampler and buffered data */ /********************************************/ - ret += SKP_Silk_setup_resamplers( psEnc, fs_kHz ); + ret += silk_setup_resamplers( psEnc, fs_kHz ); /********************************************/ /* Set internal sampling frequency */ /********************************************/ - ret += SKP_Silk_setup_fs( psEnc, fs_kHz, encControl->payloadSize_ms ); + ret += silk_setup_fs( psEnc, fs_kHz, encControl->payloadSize_ms ); /********************************************/ /* Set encoding complexity */ /********************************************/ - ret += SKP_Silk_setup_complexity( &psEnc->sCmn, encControl->complexity ); + ret += silk_setup_complexity( &psEnc->sCmn, encControl->complexity ); /********************************************/ /* Set packet loss rate measured by farend */ @@ -120,29 +117,29 @@ SKP_int SKP_Silk_control_encoder( /********************************************/ /* Set LBRR usage */ /********************************************/ - ret += SKP_Silk_setup_LBRR( &psEnc->sCmn, TargetRate_bps ); + ret += silk_setup_LBRR( &psEnc->sCmn, TargetRate_bps ); psEnc->sCmn.controlled_since_last_payload = 1; return ret; } -SKP_int SKP_Silk_setup_resamplers( - SKP_Silk_encoder_state_Fxx *psEnc, /* I/O */ +SKP_int silk_setup_resamplers( + silk_encoder_state_Fxx *psEnc, /* I/O */ SKP_int fs_kHz /* I */ ) { - SKP_int ret = SKP_SILK_NO_ERROR; + SKP_int ret = SILK_NO_ERROR; SKP_int32 nSamples_temp; if( psEnc->sCmn.fs_kHz != fs_kHz || psEnc->sCmn.prev_API_fs_Hz != psEnc->sCmn.API_fs_Hz ) { if( psEnc->sCmn.fs_kHz == 0 ) { /* Initialize the resampler for enc_API.c preparing resampling from API_fs_Hz to fs_kHz */ - ret += SKP_Silk_resampler_init( &psEnc->sCmn.resampler_state, psEnc->sCmn.API_fs_Hz, fs_kHz * 1000 ); + ret += silk_resampler_init( &psEnc->sCmn.resampler_state, psEnc->sCmn.API_fs_Hz, fs_kHz * 1000 ); } else { - /* Allocate space for worst case temporary upsampling, 8 to 48 kHz, so a factor 6 */ - SKP_int16 x_buf_API_fs_Hz[ ( 2 * MAX_FRAME_LENGTH + LA_SHAPE_MAX ) * ( MAX_API_FS_KHZ / 8 ) ]; + /* Allocate worst case space for temporary upsampling, 8 to 48 kHz, so a factor 6 */ + SKP_int16 x_buf_API_fs_Hz[ ( 2 * MAX_FRAME_LENGTH_MS + LA_SHAPE_MS ) * MAX_API_FS_KHZ ]; #ifdef FIXED_POINT SKP_int16 *x_bufFIX = psEnc->x_buf; #else @@ -158,19 +155,19 @@ SKP_int SKP_Silk_setup_resamplers( if( SKP_SMULBB( fs_kHz, 1000 ) < psEnc->sCmn.API_fs_Hz && psEnc->sCmn.fs_kHz != 0 ) { /* Resample buffered data in x_buf to API_fs_Hz */ - SKP_Silk_resampler_state_struct temp_resampler_state; + silk_resampler_state_struct temp_resampler_state; /* Initialize resampler for temporary resampling of x_buf data to API_fs_Hz */ - ret += SKP_Silk_resampler_init( &temp_resampler_state, SKP_SMULBB( psEnc->sCmn.fs_kHz, 1000 ), psEnc->sCmn.API_fs_Hz ); + ret += silk_resampler_init( &temp_resampler_state, SKP_SMULBB( psEnc->sCmn.fs_kHz, 1000 ), psEnc->sCmn.API_fs_Hz ); /* Temporary resampling of x_buf data to API_fs_Hz */ - ret += SKP_Silk_resampler( &temp_resampler_state, x_buf_API_fs_Hz, x_bufFIX, nSamples_temp ); + ret += silk_resampler( &temp_resampler_state, x_buf_API_fs_Hz, x_bufFIX, nSamples_temp ); /* Calculate number of samples that has been temporarily upsampled */ nSamples_temp = SKP_DIV32_16( nSamples_temp * psEnc->sCmn.API_fs_Hz, SKP_SMULBB( psEnc->sCmn.fs_kHz, 1000 ) ); /* Initialize the resampler for enc_API.c preparing resampling from API_fs_Hz to fs_kHz */ - ret += SKP_Silk_resampler_init( &psEnc->sCmn.resampler_state, psEnc->sCmn.API_fs_Hz, SKP_SMULBB( fs_kHz, 1000 ) ); + ret += silk_resampler_init( &psEnc->sCmn.resampler_state, psEnc->sCmn.API_fs_Hz, SKP_SMULBB( fs_kHz, 1000 ) ); } else { /* Copy data */ @@ -179,7 +176,7 @@ SKP_int SKP_Silk_setup_resamplers( if( 1000 * fs_kHz != psEnc->sCmn.API_fs_Hz ) { /* Correct resampler state (unless resampling by a factor 1) by resampling buffered data from API_fs_Hz to fs_kHz */ - ret += SKP_Silk_resampler( &psEnc->sCmn.resampler_state, x_bufFIX, x_buf_API_fs_Hz, nSamples_temp ); + ret += silk_resampler( &psEnc->sCmn.resampler_state, x_bufFIX, x_buf_API_fs_Hz, nSamples_temp ); } #ifndef FIXED_POINT SKP_short2float_array( psEnc->x_buf, x_bufFIX, ( 2 * MAX_FRAME_LENGTH_MS + LA_SHAPE_MS ) * fs_kHz ); @@ -192,13 +189,13 @@ SKP_int SKP_Silk_setup_resamplers( return ret; } -SKP_int SKP_Silk_setup_fs( - SKP_Silk_encoder_state_Fxx *psEnc, /* I/O */ +SKP_int silk_setup_fs( + silk_encoder_state_Fxx *psEnc, /* I/O */ SKP_int fs_kHz, /* I */ SKP_int PacketSize_ms /* I */ ) { - SKP_int ret = SKP_SILK_NO_ERROR; + SKP_int ret = SILK_NO_ERROR; /* Set packet size */ if( PacketSize_ms != psEnc->sCmn.PacketSize_ms ) { @@ -206,7 +203,7 @@ SKP_int SKP_Silk_setup_fs( ( PacketSize_ms != 20 ) && ( PacketSize_ms != 40 ) && ( PacketSize_ms != 60 ) ) { - ret = SKP_SILK_ENC_PACKET_SIZE_NOT_SUPPORTED; + ret = SILK_ENC_PACKET_SIZE_NOT_SUPPORTED; } if( PacketSize_ms <= 10 ) { psEnc->sCmn.nFramesPerPacket = 1; @@ -214,9 +211,9 @@ SKP_int SKP_Silk_setup_fs( psEnc->sCmn.frame_length = SKP_SMULBB( PacketSize_ms, fs_kHz ); psEnc->sCmn.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS_2_SF, fs_kHz ); if( psEnc->sCmn.fs_kHz == 8 ) { - psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_NB_iCDF; + psEnc->sCmn.pitch_contour_iCDF = silk_pitch_contour_10_ms_NB_iCDF; } else { - psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_iCDF; + psEnc->sCmn.pitch_contour_iCDF = silk_pitch_contour_10_ms_iCDF; } } else { psEnc->sCmn.nFramesPerPacket = SKP_DIV32_16( PacketSize_ms, MAX_FRAME_LENGTH_MS ); @@ -224,9 +221,9 @@ SKP_int SKP_Silk_setup_fs( psEnc->sCmn.frame_length = SKP_SMULBB( 20, fs_kHz ); psEnc->sCmn.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS, fs_kHz ); if( psEnc->sCmn.fs_kHz == 8 ) { - psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_NB_iCDF; + psEnc->sCmn.pitch_contour_iCDF = silk_pitch_contour_NB_iCDF; } else { - psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_iCDF; + psEnc->sCmn.pitch_contour_iCDF = silk_pitch_contour_iCDF; } } psEnc->sCmn.PacketSize_ms = PacketSize_ms; @@ -239,17 +236,17 @@ SKP_int SKP_Silk_setup_fs( if( psEnc->sCmn.fs_kHz != fs_kHz ) { /* reset part of the state */ #ifdef FIXED_POINT - SKP_memset( &psEnc->sShape, 0, sizeof( SKP_Silk_shape_state_FIX ) ); - SKP_memset( &psEnc->sPrefilt, 0, sizeof( SKP_Silk_prefilter_state_FIX ) ); + SKP_memset( &psEnc->sShape, 0, sizeof( silk_shape_state_FIX ) ); + SKP_memset( &psEnc->sPrefilt, 0, sizeof( silk_prefilter_state_FIX ) ); #else - SKP_memset( &psEnc->sShape, 0, sizeof( SKP_Silk_shape_state_FLP ) ); - SKP_memset( &psEnc->sPrefilt, 0, sizeof( SKP_Silk_prefilter_state_FLP ) ); + SKP_memset( &psEnc->sShape, 0, sizeof( silk_shape_state_FLP ) ); + SKP_memset( &psEnc->sPrefilt, 0, sizeof( silk_prefilter_state_FLP ) ); #endif - SKP_memset( &psEnc->sCmn.sNSQ, 0, sizeof( SKP_Silk_nsq_state ) ); + SKP_memset( &psEnc->sCmn.sNSQ, 0, sizeof( silk_nsq_state ) ); SKP_memset( psEnc->sCmn.prev_NLSFq_Q15, 0, sizeof( psEnc->sCmn.prev_NLSFq_Q15 ) ); SKP_memset( &psEnc->sCmn.sLP.In_LP_State, 0, sizeof( psEnc->sCmn.sLP.In_LP_State ) ); psEnc->sCmn.inputBufIx = 0; - psEnc->sCmn.nFramesAnalyzed = 0; + psEnc->sCmn.nFramesEncoded = 0; psEnc->sCmn.TargetRate_bps = 0; /* trigger new SNR computation */ /* Initialize non-zero parameters */ @@ -263,23 +260,23 @@ SKP_int SKP_Silk_setup_fs( psEnc->sCmn.fs_kHz = fs_kHz; if( psEnc->sCmn.fs_kHz == 8 ) { if( psEnc->sCmn.nb_subfr == MAX_NB_SUBFR ) { - psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_NB_iCDF; + psEnc->sCmn.pitch_contour_iCDF = silk_pitch_contour_NB_iCDF; } else { - psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_NB_iCDF; + psEnc->sCmn.pitch_contour_iCDF = silk_pitch_contour_10_ms_NB_iCDF; } } else { if( psEnc->sCmn.nb_subfr == MAX_NB_SUBFR ) { - psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_iCDF; + psEnc->sCmn.pitch_contour_iCDF = silk_pitch_contour_iCDF; } else { - psEnc->sCmn.pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_iCDF; + psEnc->sCmn.pitch_contour_iCDF = silk_pitch_contour_10_ms_iCDF; } } if( psEnc->sCmn.fs_kHz == 8 || psEnc->sCmn.fs_kHz == 12 ) { psEnc->sCmn.predictLPCOrder = MIN_LPC_ORDER; - psEnc->sCmn.psNLSF_CB = &SKP_Silk_NLSF_CB_NB_MB; + psEnc->sCmn.psNLSF_CB = &silk_NLSF_CB_NB_MB; } else { psEnc->sCmn.predictLPCOrder = MAX_LPC_ORDER; - psEnc->sCmn.psNLSF_CB = &SKP_Silk_NLSF_CB_WB; + psEnc->sCmn.psNLSF_CB = &silk_NLSF_CB_WB; } psEnc->sCmn.subfr_length = SUB_FRAME_LENGTH_MS * fs_kHz; psEnc->sCmn.frame_length = SKP_SMULBB( psEnc->sCmn.subfr_length, psEnc->sCmn.nb_subfr ); @@ -292,14 +289,14 @@ SKP_int SKP_Silk_setup_fs( psEnc->sCmn.pitch_LPC_win_length = SKP_SMULBB( FIND_PITCH_LPC_WIN_MS_2_SF, fs_kHz ); } if( psEnc->sCmn.fs_kHz == 16 ) { - psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_WB, 9 ); - psEnc->sCmn.pitch_lag_low_bits_iCDF = SKP_Silk_uniform8_iCDF; + psEnc->sCmn.mu_LTP_Q9 = SILK_FIX_CONST( MU_LTP_QUANT_WB, 9 ); + psEnc->sCmn.pitch_lag_low_bits_iCDF = silk_uniform8_iCDF; } else if( psEnc->sCmn.fs_kHz == 12 ) { - psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_MB, 9 ); - psEnc->sCmn.pitch_lag_low_bits_iCDF = SKP_Silk_uniform6_iCDF; + psEnc->sCmn.mu_LTP_Q9 = SILK_FIX_CONST( MU_LTP_QUANT_MB, 9 ); + psEnc->sCmn.pitch_lag_low_bits_iCDF = silk_uniform6_iCDF; } else { - psEnc->sCmn.mu_LTP_Q9 = SKP_FIX_CONST( MU_LTP_QUANT_NB, 9 ); - psEnc->sCmn.pitch_lag_low_bits_iCDF = SKP_Silk_uniform4_iCDF; + psEnc->sCmn.mu_LTP_Q9 = SILK_FIX_CONST( MU_LTP_QUANT_NB, 9 ); + psEnc->sCmn.pitch_lag_low_bits_iCDF = silk_uniform4_iCDF; } } @@ -309,8 +306,8 @@ SKP_int SKP_Silk_setup_fs( return ret; } -SKP_int SKP_Silk_setup_complexity( - SKP_Silk_encoder_state *psEncC, /* I/O */ +SKP_int silk_setup_complexity( + silk_encoder_state *psEncC, /* I/O */ SKP_int Complexity /* I */ ) { @@ -319,8 +316,8 @@ SKP_int SKP_Silk_setup_complexity( /* Set encoding complexity */ SKP_assert( Complexity >= 0 && Complexity <= 10 ); if( Complexity < 2 ) { - psEncC->pitchEstimationComplexity = SKP_Silk_PE_MIN_COMPLEX; - psEncC->pitchEstimationThreshold_Q16 = SKP_FIX_CONST( 0.8, 16 ); + psEncC->pitchEstimationComplexity = SILK_PE_MIN_COMPLEX; + psEncC->pitchEstimationThreshold_Q16 = SILK_FIX_CONST( 0.8, 16 ); psEncC->pitchEstimationLPCOrder = 6; psEncC->shapingLPCOrder = 8; psEncC->la_shape = 3 * psEncC->fs_kHz; @@ -330,8 +327,8 @@ SKP_int SKP_Silk_setup_complexity( psEncC->NLSF_MSVQ_Survivors = 2; psEncC->warping_Q16 = 0; } else if( Complexity < 4 ) { - psEncC->pitchEstimationComplexity = SKP_Silk_PE_MID_COMPLEX; - psEncC->pitchEstimationThreshold_Q16 = SKP_FIX_CONST( 0.76, 16 ); + psEncC->pitchEstimationComplexity = SILK_PE_MID_COMPLEX; + psEncC->pitchEstimationThreshold_Q16 = SILK_FIX_CONST( 0.76, 16 ); psEncC->pitchEstimationLPCOrder = 8; psEncC->shapingLPCOrder = 10; psEncC->la_shape = 5 * psEncC->fs_kHz; @@ -341,8 +338,8 @@ SKP_int SKP_Silk_setup_complexity( psEncC->NLSF_MSVQ_Survivors = 4; psEncC->warping_Q16 = 0; } else if( Complexity < 6 ) { - psEncC->pitchEstimationComplexity = SKP_Silk_PE_MID_COMPLEX; - psEncC->pitchEstimationThreshold_Q16 = SKP_FIX_CONST( 0.74, 16 ); + psEncC->pitchEstimationComplexity = SILK_PE_MID_COMPLEX; + psEncC->pitchEstimationThreshold_Q16 = SILK_FIX_CONST( 0.74, 16 ); psEncC->pitchEstimationLPCOrder = 10; psEncC->shapingLPCOrder = 12; psEncC->la_shape = 5 * psEncC->fs_kHz; @@ -350,10 +347,10 @@ SKP_int SKP_Silk_setup_complexity( psEncC->useInterpolatedNLSFs = 0; psEncC->LTPQuantLowComplexity = 0; psEncC->NLSF_MSVQ_Survivors = 6; - psEncC->warping_Q16 = psEncC->fs_kHz * SKP_FIX_CONST( WARPING_MULTIPLIER, 16 ); + psEncC->warping_Q16 = psEncC->fs_kHz * SILK_FIX_CONST( WARPING_MULTIPLIER, 16 ); } else if( Complexity < 8 ) { - psEncC->pitchEstimationComplexity = SKP_Silk_PE_MID_COMPLEX; - psEncC->pitchEstimationThreshold_Q16 = SKP_FIX_CONST( 0.72, 16 ); + psEncC->pitchEstimationComplexity = SILK_PE_MID_COMPLEX; + psEncC->pitchEstimationThreshold_Q16 = SILK_FIX_CONST( 0.72, 16 ); psEncC->pitchEstimationLPCOrder = 12; psEncC->shapingLPCOrder = 14; psEncC->la_shape = 5 * psEncC->fs_kHz; @@ -361,10 +358,10 @@ SKP_int SKP_Silk_setup_complexity( psEncC->useInterpolatedNLSFs = 0; psEncC->LTPQuantLowComplexity = 0; psEncC->NLSF_MSVQ_Survivors = 8; - psEncC->warping_Q16 = psEncC->fs_kHz * SKP_FIX_CONST( WARPING_MULTIPLIER, 16 ); + psEncC->warping_Q16 = psEncC->fs_kHz * SILK_FIX_CONST( WARPING_MULTIPLIER, 16 ); } else { - psEncC->pitchEstimationComplexity = SKP_Silk_PE_MAX_COMPLEX; - psEncC->pitchEstimationThreshold_Q16 = SKP_FIX_CONST( 0.7, 16 ); + psEncC->pitchEstimationComplexity = SILK_PE_MAX_COMPLEX; + psEncC->pitchEstimationThreshold_Q16 = SILK_FIX_CONST( 0.7, 16 ); psEncC->pitchEstimationLPCOrder = 16; psEncC->shapingLPCOrder = 16; psEncC->la_shape = 5 * psEncC->fs_kHz; @@ -372,12 +369,13 @@ SKP_int SKP_Silk_setup_complexity( psEncC->useInterpolatedNLSFs = 1; psEncC->LTPQuantLowComplexity = 0; psEncC->NLSF_MSVQ_Survivors = 16; - psEncC->warping_Q16 = psEncC->fs_kHz * SKP_FIX_CONST( WARPING_MULTIPLIER, 16 ); + psEncC->warping_Q16 = psEncC->fs_kHz * SILK_FIX_CONST( WARPING_MULTIPLIER, 16 ); } /* Do not allow higher pitch estimation LPC order than predict LPC order */ psEncC->pitchEstimationLPCOrder = SKP_min_int( psEncC->pitchEstimationLPCOrder, psEncC->predictLPCOrder ); psEncC->shapeWinLength = SUB_FRAME_LENGTH_MS * psEncC->fs_kHz + 2 * psEncC->la_shape; + psEncC->Complexity = Complexity; SKP_assert( psEncC->pitchEstimationLPCOrder <= MAX_FIND_PITCH_LPC_ORDER ); SKP_assert( psEncC->shapingLPCOrder <= MAX_SHAPE_LPC_ORDER ); @@ -390,30 +388,30 @@ SKP_int SKP_Silk_setup_complexity( return ret; } -SKP_INLINE SKP_int SKP_Silk_setup_LBRR( - SKP_Silk_encoder_state *psEncC, /* I/O */ +SKP_INLINE SKP_int silk_setup_LBRR( + silk_encoder_state *psEncC, /* I/O */ const SKP_int32 TargetRate_bps /* I */ ) { - SKP_int ret = SKP_SILK_NO_ERROR; - SKP_int32 LBRRRate_thres_bps; + SKP_int ret = SILK_NO_ERROR; + SKP_int32 LBRR_rate_thres_bps; - SKP_assert( psEncC->fs_kHz == 8 || psEncC->fs_kHz == 12 || psEncC->fs_kHz == 16 ); - if( psEncC->fs_kHz == 8 ) { - LBRRRate_thres_bps = LBRR_NB_MIN_RATE_BPS; - } else if( psEncC->fs_kHz == 12 ) { - LBRRRate_thres_bps = LBRR_MB_MIN_RATE_BPS; - } else { - LBRRRate_thres_bps = LBRR_WB_MIN_RATE_BPS; - } + psEncC->LBRR_enabled = 0; + if( psEncC->useInBandFEC && psEncC->PacketLoss_perc > 0 ) { + if( psEncC->fs_kHz == 8 ) { + LBRR_rate_thres_bps = LBRR_NB_MIN_RATE_BPS; + } else if( psEncC->fs_kHz == 12 ) { + LBRR_rate_thres_bps = LBRR_MB_MIN_RATE_BPS; + } else { + LBRR_rate_thres_bps = LBRR_WB_MIN_RATE_BPS; + } + LBRR_rate_thres_bps = SKP_SMULWB( SKP_MUL( LBRR_rate_thres_bps, 125 - SKP_min( psEncC->PacketLoss_perc, 25 ) ), SILK_FIX_CONST( 0.01, 16 ) ); - LBRRRate_thres_bps = SKP_RSHIFT( SKP_SMULBB( LBRRRate_thres_bps, 7 - psEncC->PacketLoss_perc ), 2 ); - if( psEncC->useInBandFEC && TargetRate_bps >= LBRRRate_thres_bps && psEncC->PacketLoss_perc > 0 ) { - /* Set gain increase / rate reduction for LBRR usage */ - psEncC->LBRR_GainIncreases = SKP_max_int( 7 - SKP_SMULWB( psEncC->PacketLoss_perc, SKP_FIX_CONST( 0.4, 16 ) ), 2 ); - psEncC->LBRR_enabled = 1; - } else { - psEncC->LBRR_enabled = 0; + if( TargetRate_bps > LBRR_rate_thres_bps ) { + /* Set gain increase for coding LBRR excitation */ + psEncC->LBRR_enabled = 1; + psEncC->LBRR_GainIncreases = SKP_max_int( 7 - SKP_SMULWB( psEncC->PacketLoss_perc, SILK_FIX_CONST( 0.4, 16 ) ), 2 ); + } } return ret; diff --git a/silk/SKP_Silk_create_init_destroy.c b/silk/silk_create_init_destroy.c similarity index 86% rename from silk/SKP_Silk_create_init_destroy.c rename to silk/silk_create_init_destroy.c index 0a1e02a4..10500bb1 100644 --- a/silk/SKP_Silk_create_init_destroy.c +++ b/silk/silk_create_init_destroy.c @@ -25,28 +25,28 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" +#include "silk_main.h" /************************/ /* Init Decoder State */ /************************/ -SKP_int SKP_Silk_init_decoder( - SKP_Silk_decoder_state *psDec /* I/O Decoder state pointer */ +SKP_int silk_init_decoder( + silk_decoder_state *psDec /* I/O Decoder state pointer */ ) { /* Clear the entire encoder state, except anything copied */ - SKP_memset( psDec, 0, sizeof( SKP_Silk_decoder_state ) ); + SKP_memset( psDec, 0, sizeof( silk_decoder_state ) ); /* Used to deactivate e.g. LSF interpolation and fluctuation reduction */ psDec->first_frame_after_reset = 1; psDec->prev_inv_gain_Q16 = 65536; /* Reset CNG state */ - SKP_Silk_CNG_Reset( psDec ); + silk_CNG_Reset( psDec ); /* Reset PLC state */ - SKP_Silk_PLC_Reset( psDec ); + silk_PLC_Reset( psDec ); return(0); } diff --git a/silk/SKP_Silk_debug.c b/silk/silk_debug.c similarity index 52% rename from silk/SKP_Silk_debug.c rename to silk/silk_debug.c index a7d99556..d948960b 100644 --- a/silk/SKP_Silk_debug.c +++ b/silk/silk_debug.c @@ -25,19 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -/* * - * SKP_debug.c * - * * - * This contains code to help debugging * - * * - * Copyright 2009 (c), Skype Limited * - * Date: 090629 * - * */ +#include "silk_debug.h" +#include "silk_SigProc_FIX.h" -#include "SKP_debug.h" -#include "SKP_Silk_SigProc_FIX.h" - -#if SKP_TIC_TOC +#if SILK_TIC_TOC #ifdef _WIN32 @@ -47,7 +38,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #endif -unsigned long GetHighResolutionTime(void) /* O: time in usec*/ +unsigned long silk_GetHighResolutionTime(void) /* O: time in usec*/ { /* Returns a time counter in microsec */ /* the resolution is platform dependent */ @@ -67,24 +58,24 @@ unsigned long GetHighResolutionTime(void) /* O: time in usec*/ } #endif -int SKP_Timer_nTimers = 0; -int SKP_Timer_depth_ctr = 0; -char SKP_Timer_tags[SKP_NUM_TIMERS_MAX][SKP_NUM_TIMERS_MAX_TAG_LEN]; +int silk_Timer_nTimers = 0; +int silk_Timer_depth_ctr = 0; +char silk_Timer_tags[SKP_NUM_TIMERS_MAX][SKP_NUM_TIMERS_MAX_TAG_LEN]; #ifdef WIN32 -LARGE_INTEGER SKP_Timer_start[SKP_NUM_TIMERS_MAX]; +LARGE_INTEGER silk_Timer_start[SKP_NUM_TIMERS_MAX]; #else -unsigned long SKP_Timer_start[SKP_NUM_TIMERS_MAX]; +unsigned long silk_Timer_start[SKP_NUM_TIMERS_MAX]; #endif -unsigned int SKP_Timer_cnt[SKP_NUM_TIMERS_MAX]; -SKP_int64 SKP_Timer_min[SKP_NUM_TIMERS_MAX]; -SKP_int64 SKP_Timer_sum[SKP_NUM_TIMERS_MAX]; -SKP_int64 SKP_Timer_max[SKP_NUM_TIMERS_MAX]; -SKP_int64 SKP_Timer_depth[SKP_NUM_TIMERS_MAX]; +unsigned int silk_Timer_cnt[SKP_NUM_TIMERS_MAX]; +SKP_int64 silk_Timer_min[SKP_NUM_TIMERS_MAX]; +SKP_int64 silk_Timer_sum[SKP_NUM_TIMERS_MAX]; +SKP_int64 silk_Timer_max[SKP_NUM_TIMERS_MAX]; +SKP_int64 silk_Timer_depth[SKP_NUM_TIMERS_MAX]; #ifdef WIN32 -void SKP_TimerSave(char *file_name) +void silk_TimerSave(char *file_name) { - if( SKP_Timer_nTimers > 0 ) + if( silk_Timer_nTimers > 0 ) { int k; FILE *fp; @@ -103,62 +94,62 @@ void SKP_TimerSave(char *file_name) QueryPerformanceFrequency(&lpFrequency); /* print results to file */ sum_avg = 0.0f; - for( k = 0; k < SKP_Timer_nTimers; k++ ) { - if (SKP_Timer_depth[k] == 0) { - sum_avg += (1e6 * SKP_Timer_sum[k] / SKP_Timer_cnt[k] - del) / lpFrequency.QuadPart * SKP_Timer_cnt[k]; + for( k = 0; k < silk_Timer_nTimers; k++ ) { + if (silk_Timer_depth[k] == 0) { + sum_avg += (1e6 * silk_Timer_sum[k] / silk_Timer_cnt[k] - del) / lpFrequency.QuadPart * silk_Timer_cnt[k]; } } fp = fopen(file_name, "w"); fprintf(fp, " min avg %% max count\n"); - for( k = 0; k < SKP_Timer_nTimers; k++ ) { - if (SKP_Timer_depth[k] == 0) { - fprintf(fp, "%-28s", SKP_Timer_tags[k]); - } else if (SKP_Timer_depth[k] == 1) { - fprintf(fp, " %-27s", SKP_Timer_tags[k]); - } else if (SKP_Timer_depth[k] == 2) { - fprintf(fp, " %-26s", SKP_Timer_tags[k]); - } else if (SKP_Timer_depth[k] == 3) { - fprintf(fp, " %-25s", SKP_Timer_tags[k]); + for( k = 0; k < silk_Timer_nTimers; k++ ) { + if (silk_Timer_depth[k] == 0) { + fprintf(fp, "%-28s", silk_Timer_tags[k]); + } else if (silk_Timer_depth[k] == 1) { + fprintf(fp, " %-27s", silk_Timer_tags[k]); + } else if (silk_Timer_depth[k] == 2) { + fprintf(fp, " %-26s", silk_Timer_tags[k]); + } else if (silk_Timer_depth[k] == 3) { + fprintf(fp, " %-25s", silk_Timer_tags[k]); } else { - fprintf(fp, " %-24s", SKP_Timer_tags[k]); + fprintf(fp, " %-24s", silk_Timer_tags[k]); } - avg = (1e6 * SKP_Timer_sum[k] / SKP_Timer_cnt[k] - del) / lpFrequency.QuadPart; - fprintf(fp, "%8.2f", (1e6 * (SKP_max_64(SKP_Timer_min[k] - del, 0))) / lpFrequency.QuadPart); - fprintf(fp, "%12.2f %6.2f", avg, 100.0 * avg / sum_avg * SKP_Timer_cnt[k]); - fprintf(fp, "%12.2f", (1e6 * (SKP_max_64(SKP_Timer_max[k] - del, 0))) / lpFrequency.QuadPart); - fprintf(fp, "%10d\n", SKP_Timer_cnt[k]); + avg = (1e6 * silk_Timer_sum[k] / silk_Timer_cnt[k] - del) / lpFrequency.QuadPart; + fprintf(fp, "%8.2f", (1e6 * (SKP_max_64(silk_Timer_min[k] - del, 0))) / lpFrequency.QuadPart); + fprintf(fp, "%12.2f %6.2f", avg, 100.0 * avg / sum_avg * silk_Timer_cnt[k]); + fprintf(fp, "%12.2f", (1e6 * (SKP_max_64(silk_Timer_max[k] - del, 0))) / lpFrequency.QuadPart); + fprintf(fp, "%10d\n", silk_Timer_cnt[k]); } fprintf(fp, " microseconds\n"); fclose(fp); } } #else -void SKP_TimerSave(char *file_name) +void silk_TimerSave(char *file_name) { - if( SKP_Timer_nTimers > 0 ) + if( silk_Timer_nTimers > 0 ) { int k; FILE *fp; /* print results to file */ fp = fopen(file_name, "w"); fprintf(fp, " min avg max count\n"); - for( k = 0; k < SKP_Timer_nTimers; k++ ) + for( k = 0; k < silk_Timer_nTimers; k++ ) { - if (SKP_Timer_depth[k] == 0) { - fprintf(fp, "%-28s", SKP_Timer_tags[k]); - } else if (SKP_Timer_depth[k] == 1) { - fprintf(fp, " %-27s", SKP_Timer_tags[k]); - } else if (SKP_Timer_depth[k] == 2) { - fprintf(fp, " %-26s", SKP_Timer_tags[k]); - } else if (SKP_Timer_depth[k] == 3) { - fprintf(fp, " %-25s", SKP_Timer_tags[k]); + if (silk_Timer_depth[k] == 0) { + fprintf(fp, "%-28s", silk_Timer_tags[k]); + } else if (silk_Timer_depth[k] == 1) { + fprintf(fp, " %-27s", silk_Timer_tags[k]); + } else if (silk_Timer_depth[k] == 2) { + fprintf(fp, " %-26s", silk_Timer_tags[k]); + } else if (silk_Timer_depth[k] == 3) { + fprintf(fp, " %-25s", silk_Timer_tags[k]); } else { - fprintf(fp, " %-24s", SKP_Timer_tags[k]); + fprintf(fp, " %-24s", silk_Timer_tags[k]); } - fprintf(fp, "%d ", SKP_Timer_min[k]); - fprintf(fp, "%f ", (double)SKP_Timer_sum[k] / (double)SKP_Timer_cnt[k]); - fprintf(fp, "%d ", SKP_Timer_max[k]); - fprintf(fp, "%10d\n", SKP_Timer_cnt[k]); + fprintf(fp, "%d ", silk_Timer_min[k]); + fprintf(fp, "%f ", (double)silk_Timer_sum[k] / (double)silk_Timer_cnt[k]); + fprintf(fp, "%d ", silk_Timer_max[k]); + fprintf(fp, "%10d\n", silk_Timer_cnt[k]); } fprintf(fp, " microseconds\n"); fclose(fp); @@ -166,10 +157,10 @@ void SKP_TimerSave(char *file_name) } #endif -#endif /* SKP_TIC_TOC */ +#endif /* SILK_TIC_TOC */ -#if SKP_DEBUG -FILE *SKP_debug_store_fp[ SKP_NUM_STORES_MAX ]; -int SKP_debug_store_count = 0; -#endif /* SKP_DEBUG */ +#if SILK_DEBUG +FILE *silk_debug_store_fp[ SKP_NUM_STORES_MAX ]; +int silk_debug_store_count = 0; +#endif /* SILK_DEBUG */ diff --git a/silk/SKP_debug.h b/silk/silk_debug.h similarity index 66% rename from silk/SKP_debug.h rename to silk/silk_debug.h index 84952098..1aad9f76 100644 --- a/silk/SKP_debug.h +++ b/silk/silk_debug.h @@ -25,14 +25,14 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#ifndef _SKP_DEBUG_H_ -#define _SKP_DEBUG_H_ +#ifndef _SILK_DEBUG_H_ +#define _SILK_DEBUG_H_ #ifdef _WIN32 #define _CRT_SECURE_NO_DEPRECATE 1 #endif -#include "SKP_Silk_typedef.h" +#include "silk_typedef.h" #include /* file writing */ #include /* strcpy, strcmp */ @@ -43,28 +43,28 @@ extern "C" unsigned long GetHighResolutionTime(void); /* O: time in usec*/ -/* make SKP_DEBUG dependent on compiler's _DEBUG */ +/* make SILK_DEBUG dependent on compiler's _DEBUG */ #if defined _WIN32 #ifdef _DEBUG - #define SKP_DEBUG 1 + #define SILK_DEBUG 1 #else - #define SKP_DEBUG 0 + #define SILK_DEBUG 0 #endif /* overrule the above */ #if 0 // #define NO_ASSERTS - #undef SKP_DEBUG - #define SKP_DEBUG 1 + #undef SILK_DEBUG + #define SILK_DEBUG 1 #endif #else - #define SKP_DEBUG 0 + #define SILK_DEBUG 0 #endif /* Flag for using timers */ -#define SKP_TIC_TOC 0 +#define SILK_TIC_TOC 0 -#if SKP_TIC_TOC +#if SILK_TIC_TOC #if (defined(_WIN32) || defined(_WINCE)) #include /* timer */ @@ -84,30 +84,30 @@ unsigned long GetHighResolutionTime(void); /* O: time in usec*/ /* */ /* and call the following just before exiting (from main) */ /* */ -/* SKP_TimerSave("SKP_TimingData.txt"); */ +/* silk_TimerSave("SKP_TimingData.txt"); */ /* */ /* results are now in SKP_TimingData.txt */ -void SKP_TimerSave(char *file_name); +void silk_TimerSave(char *file_name); /* max number of timers (in different locations) */ #define SKP_NUM_TIMERS_MAX 50 /* max length of name tags in TIC(..), TOC(..) */ #define SKP_NUM_TIMERS_MAX_TAG_LEN 30 -extern int SKP_Timer_nTimers; -extern int SKP_Timer_depth_ctr; -extern char SKP_Timer_tags[SKP_NUM_TIMERS_MAX][SKP_NUM_TIMERS_MAX_TAG_LEN]; +extern int silk_Timer_nTimers; +extern int silk_Timer_depth_ctr; +extern char silk_Timer_tags[SKP_NUM_TIMERS_MAX][SKP_NUM_TIMERS_MAX_TAG_LEN]; #ifdef _WIN32 -extern LARGE_INTEGER SKP_Timer_start[SKP_NUM_TIMERS_MAX]; +extern LARGE_INTEGER silk_Timer_start[SKP_NUM_TIMERS_MAX]; #else -extern unsigned long SKP_Timer_start[SKP_NUM_TIMERS_MAX]; +extern unsigned long silk_Timer_start[SKP_NUM_TIMERS_MAX]; #endif -extern unsigned int SKP_Timer_cnt[SKP_NUM_TIMERS_MAX]; -extern SKP_int64 SKP_Timer_sum[SKP_NUM_TIMERS_MAX]; -extern SKP_int64 SKP_Timer_max[SKP_NUM_TIMERS_MAX]; -extern SKP_int64 SKP_Timer_min[SKP_NUM_TIMERS_MAX]; -extern SKP_int64 SKP_Timer_depth[SKP_NUM_TIMERS_MAX]; +extern unsigned int silk_Timer_cnt[SKP_NUM_TIMERS_MAX]; +extern SKP_int64 silk_Timer_sum[SKP_NUM_TIMERS_MAX]; +extern SKP_int64 silk_Timer_max[SKP_NUM_TIMERS_MAX]; +extern SKP_int64 silk_Timer_min[SKP_NUM_TIMERS_MAX]; +extern SKP_int64 silk_Timer_depth[SKP_NUM_TIMERS_MAX]; /* WARNING: TIC()/TOC can measure only up to 0.1 seconds at a time */ #ifdef _WIN32 @@ -118,25 +118,25 @@ extern SKP_int64 SKP_Timer_depth[SKP_NUM_TIMERS_MAX]; { \ int k; \ init = 1; \ - for( k = 0; k < SKP_Timer_nTimers; k++ ) { \ - if( strcmp(SKP_Timer_tags[k], #TAG_NAME) == 0 ) { \ + for( k = 0; k < silk_Timer_nTimers; k++ ) { \ + if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \ ID = k; \ break; \ } \ } \ if (ID == -1) { \ - ID = SKP_Timer_nTimers; \ - SKP_Timer_nTimers++; \ - SKP_Timer_depth[ID] = SKP_Timer_depth_ctr; \ - strcpy(SKP_Timer_tags[ID], #TAG_NAME); \ - SKP_Timer_cnt[ID] = 0; \ - SKP_Timer_sum[ID] = 0; \ - SKP_Timer_min[ID] = 0xFFFFFFFF; \ - SKP_Timer_max[ID] = 0; \ + ID = silk_Timer_nTimers; \ + silk_Timer_nTimers++; \ + silk_Timer_depth[ID] = silk_Timer_depth_ctr; \ + strcpy(silk_Timer_tags[ID], #TAG_NAME); \ + silk_Timer_cnt[ID] = 0; \ + silk_Timer_sum[ID] = 0; \ + silk_Timer_min[ID] = 0xFFFFFFFF; \ + silk_Timer_max[ID] = 0; \ } \ } \ - SKP_Timer_depth_ctr++; \ - QueryPerformanceCounter(&SKP_Timer_start[ID]); \ + silk_Timer_depth_ctr++; \ + QueryPerformanceCounter(&silk_Timer_start[ID]); \ } #else #define TIC(TAG_NAME) { \ @@ -146,25 +146,25 @@ extern SKP_int64 SKP_Timer_depth[SKP_NUM_TIMERS_MAX]; { \ int k; \ init = 1; \ - for( k = 0; k < SKP_Timer_nTimers; k++ ) { \ - if( strcmp(SKP_Timer_tags[k], #TAG_NAME) == 0 ) { \ + for( k = 0; k < silk_Timer_nTimers; k++ ) { \ + if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \ ID = k; \ break; \ } \ } \ if (ID == -1) { \ - ID = SKP_Timer_nTimers; \ - SKP_Timer_nTimers++; \ - SKP_Timer_depth[ID] = SKP_Timer_depth_ctr; \ - strcpy(SKP_Timer_tags[ID], #TAG_NAME); \ - SKP_Timer_cnt[ID] = 0; \ - SKP_Timer_sum[ID] = 0; \ - SKP_Timer_min[ID] = 0xFFFFFFFF; \ - SKP_Timer_max[ID] = 0; \ + ID = silk_Timer_nTimers; \ + silk_Timer_nTimers++; \ + silk_Timer_depth[ID] = silk_Timer_depth_ctr; \ + strcpy(silk_Timer_tags[ID], #TAG_NAME); \ + silk_Timer_cnt[ID] = 0; \ + silk_Timer_sum[ID] = 0; \ + silk_Timer_min[ID] = 0xFFFFFFFF; \ + silk_Timer_max[ID] = 0; \ } \ } \ - SKP_Timer_depth_ctr++; \ - SKP_Timer_start[ID] = GetHighResolutionTime(); \ + silk_Timer_depth_ctr++; \ + silk_Timer_start[ID] = GetHighResolutionTime(); \ } #endif @@ -177,25 +177,25 @@ extern SKP_int64 SKP_Timer_depth[SKP_NUM_TIMERS_MAX]; { \ int k; \ init = 1; \ - for( k = 0; k < SKP_Timer_nTimers; k++ ) { \ - if( strcmp(SKP_Timer_tags[k], #TAG_NAME) == 0 ) { \ + for( k = 0; k < silk_Timer_nTimers; k++ ) { \ + if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \ ID = k; \ break; \ } \ } \ } \ QueryPerformanceCounter(&lpPerformanceCount); \ - lpPerformanceCount.QuadPart -= SKP_Timer_start[ID].QuadPart; \ + lpPerformanceCount.QuadPart -= silk_Timer_start[ID].QuadPart; \ if((lpPerformanceCount.QuadPart < 100000000) && \ (lpPerformanceCount.QuadPart >= 0)) { \ - SKP_Timer_cnt[ID]++; \ - SKP_Timer_sum[ID] += lpPerformanceCount.QuadPart; \ - if( lpPerformanceCount.QuadPart > SKP_Timer_max[ID] ) \ - SKP_Timer_max[ID] = lpPerformanceCount.QuadPart; \ - if( lpPerformanceCount.QuadPart < SKP_Timer_min[ID] ) \ - SKP_Timer_min[ID] = lpPerformanceCount.QuadPart; \ + silk_Timer_cnt[ID]++; \ + silk_Timer_sum[ID] += lpPerformanceCount.QuadPart; \ + if( lpPerformanceCount.QuadPart > silk_Timer_max[ID] ) \ + silk_Timer_max[ID] = lpPerformanceCount.QuadPart; \ + if( lpPerformanceCount.QuadPart < silk_Timer_min[ID] ) \ + silk_Timer_min[ID] = lpPerformanceCount.QuadPart; \ } \ - SKP_Timer_depth_ctr--; \ + silk_Timer_depth_ctr--; \ } #else #define TOC(TAG_NAME) { \ @@ -206,40 +206,40 @@ extern SKP_int64 SKP_Timer_depth[SKP_NUM_TIMERS_MAX]; { \ int k; \ init = 1; \ - for( k = 0; k < SKP_Timer_nTimers; k++ ) { \ - if( strcmp(SKP_Timer_tags[k], #TAG_NAME) == 0 ) { \ + for( k = 0; k < silk_Timer_nTimers; k++ ) { \ + if( strcmp(silk_Timer_tags[k], #TAG_NAME) == 0 ) { \ ID = k; \ break; \ } \ } \ } \ endTime = GetHighResolutionTime(); \ - endTime -= SKP_Timer_start[ID]; \ + endTime -= silk_Timer_start[ID]; \ if((endTime < 100000000) && \ (endTime >= 0)) { \ - SKP_Timer_cnt[ID]++; \ - SKP_Timer_sum[ID] += endTime; \ - if( endTime > SKP_Timer_max[ID] ) \ - SKP_Timer_max[ID] = endTime; \ - if( endTime < SKP_Timer_min[ID] ) \ - SKP_Timer_min[ID] = endTime; \ + silk_Timer_cnt[ID]++; \ + silk_Timer_sum[ID] += endTime; \ + if( endTime > silk_Timer_max[ID] ) \ + silk_Timer_max[ID] = endTime; \ + if( endTime < silk_Timer_min[ID] ) \ + silk_Timer_min[ID] = endTime; \ } \ - SKP_Timer_depth_ctr--; \ + silk_Timer_depth_ctr--; \ } #endif -#else /* SKP_TIC_TOC */ +#else /* SILK_TIC_TOC */ /* define macros as empty strings */ #define TIC(TAG_NAME) #define TOC(TAG_NAME) -#define SKP_TimerSave(FILE_NAME) +#define silk_TimerSave(FILE_NAME) -#endif /* SKP_TIC_TOC */ +#endif /* SILK_TIC_TOC */ -#if SKP_DEBUG +#if SILK_DEBUG /************************************/ /* write data to file for debugging */ /************************************/ @@ -263,13 +263,13 @@ extern SKP_int64 SKP_Timer_depth[SKP_NUM_TIMERS_MAX]; #if 0 /* Ensure that everything is written to files when an assert breaks */ #define DEBUG_STORE_DATA(FILE_NAME, DATA_PTR, N_BYTES) SAVE_DATA(FILE_NAME, DATA_PTR, N_BYTES) -#define DEBUG_STORE_CLOSE_FILES +#define SILK_DEBUG_STORE_CLOSE_FILES #else #define SKP_NUM_STORES_MAX 100 -extern FILE *SKP_debug_store_fp[ SKP_NUM_STORES_MAX ]; -extern int SKP_debug_store_count; +extern FILE *silk_debug_store_fp[ SKP_NUM_STORES_MAX ]; +extern int silk_debug_store_count; /* Faster way of storing the data */ #define DEBUG_STORE_DATA( FILE_NAME, DATA_PTR, N_BYTES ) { \ @@ -277,35 +277,35 @@ extern int SKP_debug_store_count; static FILE **fp; \ if (init == 0) { \ init = 1; \ - cnt = SKP_debug_store_count++; \ - SKP_debug_store_fp[ cnt ] = fopen(#FILE_NAME, "wb"); \ + cnt = silk_debug_store_count++; \ + silk_debug_store_fp[ cnt ] = fopen(#FILE_NAME, "wb"); \ } \ - fwrite((DATA_PTR), (N_BYTES), 1, SKP_debug_store_fp[ cnt ]); \ + fwrite((DATA_PTR), (N_BYTES), 1, silk_debug_store_fp[ cnt ]); \ } /* Call this at the end of main() */ -#define DEBUG_STORE_CLOSE_FILES { \ +#define SILK_DEBUG_STORE_CLOSE_FILES { \ SKP_int i; \ - for( i = 0; i < SKP_debug_store_count; i++ ) { \ - fclose( SKP_debug_store_fp[ i ] ); \ + for( i = 0; i < silk_debug_store_count; i++ ) { \ + fclose( silk_debug_store_fp[ i ] ); \ } \ } #endif /* micro sec */ -#define SKP_GETTIME(void) time = (SKP_int64) GetHighResolutionTime(); +#define SKP_GETTIME(void) time = (SKP_int64) silk_GetHighResolutionTime(); -#else /* SKP_DEBUG */ +#else /* SILK_DEBUG */ /* define macros as empty strings */ #define DEBUG_STORE_DATA(FILE_NAME, DATA_PTR, N_BYTES) #define SAVE_DATA(FILE_NAME, DATA_PTR, N_BYTES) -#define DEBUG_STORE_CLOSE_FILES +#define SILK_DEBUG_STORE_CLOSE_FILES -#endif /* SKP_DEBUG */ +#endif /* SILK_DEBUG */ #ifdef __cplusplus } #endif -#endif /* _SKP_DEBUG_H_ */ +#endif /* _SILK_DEBUG_H_ */ diff --git a/silk/SKP_Silk_dec_API.c b/silk/silk_dec_API.c similarity index 52% rename from silk/SKP_Silk_dec_API.c rename to silk/silk_dec_API.c index 6340f2d8..652f8668 100644 --- a/silk/SKP_Silk_dec_API.c +++ b/silk/silk_dec_API.c @@ -28,50 +28,51 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include "SKP_Silk_SDK_API.h" -#include "SKP_Silk_main.h" +#include "silk_API.h" +#include "silk_main.h" /************************/ /* Decoder Super Struct */ /************************/ typedef struct { - SKP_Silk_decoder_state channel_state[ DECODER_NUM_CHANNELS ]; - stereo_state sStereo; - SKP_int nChannels; -} SKP_Silk_decoder; + silk_decoder_state channel_state[ DECODER_NUM_CHANNELS ]; + stereo_dec_state sStereo; + SKP_int nChannelsAPI; + SKP_int nChannelsInternal; +} silk_decoder; /*********************/ /* Decoder functions */ /*********************/ -SKP_int SKP_Silk_SDK_Get_Decoder_Size( SKP_int32 *decSizeBytes ) +SKP_int silk_Get_Decoder_Size( SKP_int32 *decSizeBytes ) { - SKP_int ret = SKP_SILK_NO_ERROR; + SKP_int ret = SILK_NO_ERROR; - *decSizeBytes = sizeof( SKP_Silk_decoder ); + *decSizeBytes = sizeof( silk_decoder ); return ret; } /* Reset decoder state */ -SKP_int SKP_Silk_SDK_InitDecoder( +SKP_int silk_InitDecoder( void* decState /* I/O: State */ ) { - SKP_int n, ret = SKP_SILK_NO_ERROR; - SKP_Silk_decoder_state *channel_state = ((SKP_Silk_decoder *)decState)->channel_state; + SKP_int n, ret = SILK_NO_ERROR; + silk_decoder_state *channel_state = ((silk_decoder *)decState)->channel_state; for( n = 0; n < DECODER_NUM_CHANNELS; n++ ) { - ret = SKP_Silk_init_decoder( &channel_state[ n ] ); + ret = silk_init_decoder( &channel_state[ n ] ); } return ret; } /* Decode a frame */ -SKP_int SKP_Silk_SDK_Decode( +SKP_int silk_Decode( void* decState, /* I/O: State */ - SKP_SILK_SDK_DecControlStruct* decControl, /* I/O: Control Structure */ + silk_DecControlStruct* decControl, /* I/O: Control Structure */ SKP_int lostFlag, /* I: 0: no loss, 1 loss, 2 decode FEC */ SKP_int newPacketFlag, /* I: Indicates first decoder call for this packet */ ec_dec *psRangeDec, /* I/O Compressor data structure */ @@ -79,20 +80,20 @@ SKP_int SKP_Silk_SDK_Decode( SKP_int32 *nSamplesOut /* O: Number of samples decoded */ ) { - SKP_int i, n, prev_fs_kHz, doResample, flags, nFlags, ret = SKP_SILK_NO_ERROR; + SKP_int i, n, prev_fs_kHz, decode_only_middle = 0, ret = SILK_NO_ERROR; SKP_int32 nSamplesOutDec, LBRR_symbol; - SKP_int16 samplesOut1_tmp[ 2 * MAX_FS_KHZ * MAX_FRAME_LENGTH_MS ]; + SKP_int16 samplesOut1_tmp[ 2 ][ MAX_FS_KHZ * MAX_FRAME_LENGTH_MS + 2 ]; SKP_int16 samplesOut2_tmp[ MAX_API_FS_KHZ * MAX_FRAME_LENGTH_MS ]; - SKP_int MS_pred_Q14[ 2 ] = { 0 }; - SKP_int16 *dec_out_ptr, *resample_out_ptr; - SKP_Silk_decoder *psDec = ( SKP_Silk_decoder * )decState; - SKP_Silk_decoder_state *channel_state = psDec->channel_state; + SKP_int MS_pred_Q13[ 2 ] = { 0 }; + SKP_int16 *resample_out_ptr; + silk_decoder *psDec = ( silk_decoder * )decState; + silk_decoder_state *channel_state = psDec->channel_state; /**********************************/ /* Test if first frame in payload */ /**********************************/ if( newPacketFlag ) { - for( n = 0; n < decControl->nChannels; n++ ) { + for( n = 0; n < decControl->nChannelsInternal; n++ ) { channel_state[ n ].nFramesDecoded = 0; /* Used to count frames in packet */ } } @@ -100,14 +101,15 @@ SKP_int SKP_Silk_SDK_Decode( /* Save previous sample frequency */ prev_fs_kHz = channel_state[ 0 ].fs_kHz; - if( decControl->nChannels > psDec->nChannels ) { - /* Mono -> Stereo transition: init state of second channel and stereo state */ - SKP_memset( &psDec->sStereo, 0, sizeof( psDec->sStereo ) ); - ret += SKP_Silk_init_decoder( &channel_state[ 1 ] ); + /* If Mono -> Stereo transition in bitstream: init state of second channel */ + if( decControl->nChannelsInternal > psDec->nChannelsInternal ) { + ret += silk_init_decoder( &channel_state[ 1 ] ); + if( psDec->nChannelsAPI == 2 ) { + SKP_memcpy( &channel_state[ 1 ].resampler_state, &channel_state[ 0 ].resampler_state, sizeof( silk_resampler_state_struct ) ); + } } - psDec->nChannels = decControl->nChannels; - for( n = 0; n < decControl->nChannels; n++ ) { + for( n = 0; n < decControl->nChannelsInternal; n++ ) { if( channel_state[ n ].nFramesDecoded == 0 ) { SKP_int fs_kHz_dec; if( decControl->payloadSize_ms == 10 ) { @@ -124,60 +126,54 @@ SKP_int SKP_Silk_SDK_Decode( channel_state[ n ].nb_subfr = 4; } else { SKP_assert( 0 ); - return SKP_SILK_DEC_INVALID_FRAME_SIZE; + return SILK_DEC_INVALID_FRAME_SIZE; } fs_kHz_dec = ( decControl->internalSampleRate >> 10 ) + 1; if( fs_kHz_dec != 8 && fs_kHz_dec != 12 && fs_kHz_dec != 16 ) { SKP_assert( 0 ); - return SKP_SILK_DEC_INVALID_SAMPLING_FREQUENCY; + return SILK_DEC_INVALID_SAMPLING_FREQUENCY; } - SKP_Silk_decoder_set_fs( &channel_state[ n ], fs_kHz_dec ); + silk_decoder_set_fs( &channel_state[ n ], fs_kHz_dec ); } } - + + /* Initialize resampler when switching internal or external sampling frequency */ + if( prev_fs_kHz != channel_state[ 0 ].fs_kHz || channel_state[ 0 ].prev_API_sampleRate != decControl->API_sampleRate ) { + ret = silk_resampler_init( &channel_state[ 0 ].resampler_state, SKP_SMULBB( channel_state[ 0 ].fs_kHz, 1000 ), decControl->API_sampleRate ); + if( decControl->nChannelsAPI == 2 && decControl->nChannelsInternal == 2 ) { + SKP_memcpy( &channel_state[ 1 ].resampler_state, &channel_state[ 0 ].resampler_state, sizeof( silk_resampler_state_struct ) ); + } + } + channel_state[ 0 ].prev_API_sampleRate = decControl->API_sampleRate; + if( decControl->nChannelsAPI == 2 && decControl->nChannelsInternal == 2 && ( psDec->nChannelsAPI == 1 || psDec->nChannelsInternal == 1 ) ) { + SKP_memset( psDec->sStereo.pred_prev_Q13, 0, sizeof( psDec->sStereo.pred_prev_Q13 ) ); + SKP_memset( psDec->sStereo.sSide, 0, sizeof( psDec->sStereo.sSide ) ); + } + psDec->nChannelsAPI = decControl->nChannelsAPI; + psDec->nChannelsInternal = decControl->nChannelsInternal; + if( decControl->API_sampleRate > MAX_API_FS_KHZ * 1000 || decControl->API_sampleRate < 8000 ) { - ret = SKP_SILK_DEC_INVALID_SAMPLING_FREQUENCY; + ret = SILK_DEC_INVALID_SAMPLING_FREQUENCY; return( ret ); } - doResample = SKP_SMULBB( channel_state[ 0 ].fs_kHz, 1000 ) != decControl->API_sampleRate; - - /* Set up pointers to temp buffers */ - if( doResample || decControl->nChannels == 2 ) { - dec_out_ptr = samplesOut1_tmp; - } else { - dec_out_ptr = samplesOut; - } - if( decControl->nChannels == 2 ) { - resample_out_ptr = samplesOut2_tmp; - } else { - resample_out_ptr = samplesOut; - } - if( lostFlag != FLAG_PACKET_LOST && channel_state[ 0 ].nFramesDecoded == 0 ) { /* First decoder call for this payload */ - nFlags = SKP_SMULBB( decControl->nChannels, channel_state[ 0 ].nFramesPerPacket + 1 ); - flags = SKP_RSHIFT( psRangeDec->buf[ 0 ], 8 - nFlags ) & ( SKP_LSHIFT( 1, nFlags ) - 1 ); - for( i = 0; i < nFlags; i++ ) { - ec_dec_icdf( psRangeDec, SKP_Silk_uniform2_iCDF, 8 ); - } /* Decode VAD flags and LBRR flag */ - for( n = decControl->nChannels - 1; n >= 0; n-- ) { - channel_state[ n ].LBRR_flag = flags & 1; - flags = SKP_RSHIFT( flags, 1 ); - for( i = channel_state[ n ].nFramesPerPacket - 1; i >= 0 ; i-- ) { - channel_state[ n ].VAD_flags[ i ] = flags & 1; - flags = SKP_RSHIFT( flags, 1 ); + for( n = 0; n < decControl->nChannelsInternal; n++ ) { + for( i = 0; i < channel_state[ n ].nFramesPerPacket; i++ ) { + channel_state[ n ].VAD_flags[ i ] = ec_dec_bit_logp(psRangeDec, 1); } - } + channel_state[ n ].LBRR_flag = ec_dec_bit_logp(psRangeDec, 1); + } /* Decode LBRR flags */ - for( n = 0; n < decControl->nChannels; n++ ) { + for( n = 0; n < decControl->nChannelsInternal; n++ ) { SKP_memset( channel_state[ n ].LBRR_flags, 0, sizeof( channel_state[ n ].LBRR_flags ) ); if( channel_state[ n ].LBRR_flag ) { if( channel_state[ n ].nFramesPerPacket == 1 ) { channel_state[ n ].LBRR_flags[ 0 ] = 1; } else { - LBRR_symbol = ec_dec_icdf( psRangeDec, SKP_Silk_LBRR_flags_iCDF_ptr[ channel_state[ n ].nFramesPerPacket - 2 ], 8 ) + 1; + LBRR_symbol = ec_dec_icdf( psRangeDec, silk_LBRR_flags_iCDF_ptr[ channel_state[ n ].nFramesPerPacket - 2 ], 8 ) + 1; for( i = 0; i < channel_state[ n ].nFramesPerPacket; i++ ) { channel_state[ n ].LBRR_flags[ i ] = SKP_RSHIFT( LBRR_symbol, i ) & 1; } @@ -188,11 +184,14 @@ SKP_int SKP_Silk_SDK_Decode( if( lostFlag == FLAG_DECODE_NORMAL ) { /* Regular decoding: skip all LBRR data */ for( i = 0; i < channel_state[ 0 ].nFramesPerPacket; i++ ) { - for( n = 0; n < decControl->nChannels; n++ ) { + for( n = 0; n < decControl->nChannelsInternal; n++ ) { if( channel_state[ n ].LBRR_flags[ i ] ) { SKP_int pulses[ MAX_FRAME_LENGTH ]; - SKP_Silk_decode_indices( &channel_state[ n ], psRangeDec, i, 1 ); - SKP_Silk_decode_pulses( psRangeDec, pulses, channel_state[ n ].indices.signalType, + if( decControl->nChannelsInternal == 2 && n == 0 ) { + silk_stereo_decode_pred( psRangeDec, &decode_only_middle, MS_pred_Q13 ); + } + silk_decode_indices( &channel_state[ n ], psRangeDec, i, 1 ); + silk_decode_pulses( psRangeDec, pulses, channel_state[ n ].indices.signalType, channel_state[ n ].indices.quantOffsetType, channel_state[ n ].frame_length ); } } @@ -201,67 +200,75 @@ SKP_int SKP_Silk_SDK_Decode( } /* Get MS predictor index */ - if( decControl->nChannels == 2 ) { - SKP_Silk_stereo_decode_pred( psRangeDec, MS_pred_Q14 ); + if( decControl->nChannelsInternal == 2 ) { + if( lostFlag == FLAG_DECODE_NORMAL || + ( lostFlag == FLAG_DECODE_LBRR && channel_state[ 0 ].LBRR_flags[ channel_state[ 0 ].nFramesDecoded ] == 1 ) ) + { + silk_stereo_decode_pred( psRangeDec, &decode_only_middle, MS_pred_Q13 ); + } else { + SKP_memcpy( MS_pred_Q13, &psDec->sStereo.pred_prev_Q13, sizeof( MS_pred_Q13 ) ); + } } /* Call decoder for one frame */ - for( n = 0; n < decControl->nChannels; n++ ) { - ret += SKP_Silk_decode_frame( &channel_state[ n ], psRangeDec, &dec_out_ptr[ n * MAX_FS_KHZ * MAX_FRAME_LENGTH_MS ], &nSamplesOutDec, lostFlag ); + for( n = 0; n < decControl->nChannelsInternal; n++ ) { + if( n == 0 || decode_only_middle == 0 ) { + ret += silk_decode_frame( &channel_state[ n ], psRangeDec, &samplesOut1_tmp[ n ][ 2 ], &nSamplesOutDec, lostFlag ); + } else { + SKP_memset( &samplesOut1_tmp[ n ][ 2 ], 0, nSamplesOutDec * sizeof( SKP_int16 ) ); + } } - /* Convert Mid/Side to Left/Right */ - if( decControl->nChannels == 2 ) { - SKP_Silk_stereo_MS_to_LR( &psDec->sStereo, dec_out_ptr, &dec_out_ptr[ MAX_FS_KHZ * MAX_FRAME_LENGTH_MS ], MS_pred_Q14, channel_state[ 0 ].fs_kHz, nSamplesOutDec ); + if( decControl->nChannelsAPI == 2 && decControl->nChannelsInternal == 2 ) { + /* Convert Mid/Side to Left/Right */ + silk_stereo_MS_to_LR( &psDec->sStereo, samplesOut1_tmp[ 0 ], samplesOut1_tmp[ 1 ], MS_pred_Q13, channel_state[ 0 ].fs_kHz, nSamplesOutDec ); + } else { + /* Buffering */ + SKP_memcpy( samplesOut1_tmp[ 0 ], psDec->sStereo.sMid, 2 * sizeof( SKP_int16 ) ); + SKP_memcpy( psDec->sStereo.sMid, &samplesOut1_tmp[ 0 ][ nSamplesOutDec ], 2 * sizeof( SKP_int16 ) ); } /* Number of output samples */ - if( doResample ) { - *nSamplesOut = SKP_DIV32( nSamplesOutDec * decControl->API_sampleRate, SKP_SMULBB( channel_state[ 0 ].fs_kHz, 1000 ) ); + *nSamplesOut = SKP_DIV32( nSamplesOutDec * decControl->API_sampleRate, SKP_SMULBB( channel_state[ 0 ].fs_kHz, 1000 ) ); + + /* Set up pointers to temp buffers */ + if( decControl->nChannelsAPI == 2 ) { + resample_out_ptr = samplesOut2_tmp; } else { - *nSamplesOut = nSamplesOutDec; + resample_out_ptr = samplesOut; } - for( n = 0; n < decControl->nChannels; n++ ) { - /* Resample if needed */ - if( doResample ) { - /* Initialize resampler when switching internal or external sampling frequency */ - if( prev_fs_kHz != channel_state[ n ].fs_kHz || channel_state[ n ].prev_API_sampleRate != decControl->API_sampleRate ) { - ret = SKP_Silk_resampler_init( &channel_state[ n ].resampler_state, SKP_SMULBB( channel_state[ n ].fs_kHz, 1000 ), decControl->API_sampleRate ); - } + for( n = 0; n < SKP_min( decControl->nChannelsAPI, decControl->nChannelsInternal ); n++ ) { + /* Resample decoded signal to API_sampleRate */ + ret += silk_resampler( &channel_state[ n ].resampler_state, resample_out_ptr, &samplesOut1_tmp[ n ][ 1 ], nSamplesOutDec ); - /* Resample the output to API_sampleRate */ - ret += SKP_Silk_resampler( &channel_state[ n ].resampler_state, resample_out_ptr, &dec_out_ptr[ n * MAX_FS_KHZ * MAX_FRAME_LENGTH_MS ], nSamplesOutDec ); - } else { - resample_out_ptr = &dec_out_ptr[ n * MAX_FS_KHZ * MAX_FRAME_LENGTH_MS ]; - } - - /* Interleave if needed */ - if( decControl->nChannels == 2 ) { + /* Interleave if stereo output and stereo stream */ + if( decControl->nChannelsAPI == 2 && decControl->nChannelsInternal == 2 ) { for( i = 0; i < *nSamplesOut; i++ ) { samplesOut[ n + 2 * i ] = resample_out_ptr[ i ]; } } - - channel_state[ n ].prev_API_sampleRate = decControl->API_sampleRate; } - /* Copy parameters to control stucture */ - decControl->frameSize = ( SKP_int )*nSamplesOut; - decControl->framesPerPayload = ( SKP_int )channel_state[ n ].nFramesPerPacket; + /* Create two channel output from mono stream */ + if( decControl->nChannelsAPI == 2 && decControl->nChannelsInternal == 1 ) { + for( i = 0; i < *nSamplesOut; i++ ) { + samplesOut[ 0 + 2 * i ] = samplesOut[ 1 + 2 * i ] = resample_out_ptr[ i ]; + } + } return ret; } /* Getting table of contents for a packet */ -SKP_int SKP_Silk_SDK_get_TOC( +SKP_int silk_get_TOC( const SKP_uint8 *payload, /* I Payload data */ const SKP_int nBytesIn, /* I: Number of input bytes */ const SKP_int nFramesPerPayload, /* I: Number of SILK frames per payload */ - SKP_Silk_TOC_struct *Silk_TOC /* O: Type of content */ + silk_TOC_struct *Silk_TOC /* O: Type of content */ ) { - SKP_int i, flags, ret = SKP_SILK_NO_ERROR; + SKP_int i, flags, ret = SILK_NO_ERROR; if( nBytesIn < 1 ) { return -1; diff --git a/silk/SKP_Silk_decode_core.c b/silk/silk_decode_core.c similarity index 91% rename from silk/SKP_Silk_decode_core.c rename to silk/silk_decode_core.c index 3c795f56..f2607480 100644 --- a/silk/SKP_Silk_decode_core.c +++ b/silk/silk_decode_core.c @@ -25,14 +25,14 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" +#include "silk_main.h" /**********************************************************/ /* Core decoder. Performs inverse NSQ operation LTP + LPC */ /**********************************************************/ -void SKP_Silk_decode_core( - SKP_Silk_decoder_state *psDec, /* I/O Decoder state */ - SKP_Silk_decoder_control *psDecCtrl, /* I Decoder control */ +void silk_decode_core( + silk_decoder_state *psDec, /* I/O Decoder state */ + silk_decoder_control *psDecCtrl, /* I Decoder control */ SKP_int16 xq[], /* O Decoded speech */ const SKP_int pulses[ MAX_FRAME_LENGTH ] /* I Pulse signal */ ) @@ -47,7 +47,7 @@ void SKP_Silk_decode_core( SKP_assert( psDec->prev_inv_gain_Q16 != 0 ); - offset_Q10 = SKP_Silk_Quantization_Offsets_Q10[ psDec->indices.signalType >> 1 ][ psDec->indices.quantOffsetType ]; + offset_Q10 = silk_Quantization_Offsets_Q10[ psDec->indices.signalType >> 1 ][ psDec->indices.quantOffsetType ]; if( psDec->indices.NLSFInterpCoef_Q2 < 1 << 2 ) { NLSF_interpolation_flag = 1; @@ -90,13 +90,13 @@ void SKP_Silk_decode_core( Gain_Q16 = psDecCtrl->Gains_Q16[ k ]; signalType = psDec->indices.signalType; - inv_gain_Q16 = SKP_INVERSE32_varQ( SKP_max( Gain_Q16, 1 ), 32 ); + inv_gain_Q16 = silk_INVERSE32_varQ( SKP_max( Gain_Q16, 1 ), 32 ); inv_gain_Q16 = SKP_min( inv_gain_Q16, SKP_int16_MAX ); /* Calculate Gain adjustment factor */ gain_adj_Q16 = 1 << 16; if( inv_gain_Q16 != psDec->prev_inv_gain_Q16 ) { - gain_adj_Q16 = SKP_DIV32_varQ( inv_gain_Q16, psDec->prev_inv_gain_Q16, 16 ); + gain_adj_Q16 = silk_DIV32_varQ( inv_gain_Q16, psDec->prev_inv_gain_Q16, 16 ); /* Scale short term state */ for( i = 0; i < MAX_LPC_ORDER; i++ ) { @@ -113,7 +113,7 @@ void SKP_Silk_decode_core( psDec->indices.signalType != TYPE_VOICED && k < MAX_NB_SUBFR/2 ) { SKP_memset( B_Q14, 0, LTP_ORDER * sizeof( SKP_int16 ) ); - B_Q14[ LTP_ORDER/2 ] = SKP_FIX_CONST( 0.25, 14 ); + B_Q14[ LTP_ORDER/2 ] = SILK_FIX_CONST( 0.25, 14 ); signalType = TYPE_VOICED; psDecCtrl->pitchL[ k ] = psDec->lagPrev; @@ -129,7 +129,7 @@ void SKP_Silk_decode_core( start_idx = psDec->ltp_mem_length - lag - psDec->LPC_order - LTP_ORDER / 2; SKP_assert( start_idx > 0 ); - SKP_Silk_LPC_analysis_filter( &sLTP[ start_idx ], &psDec->outBuf[ start_idx + k * psDec->subfr_length ], + silk_LPC_analysis_filter( &sLTP[ start_idx ], &psDec->outBuf[ start_idx + k * psDec->subfr_length ], A_Q12, psDec->ltp_mem_length - start_idx, psDec->LPC_order ); /* After rewhitening the LTP state is unscaled */ diff --git a/silk/SKP_Silk_decode_frame.c b/silk/silk_decode_frame.c similarity index 85% rename from silk/SKP_Silk_decode_frame.c rename to silk/silk_decode_frame.c index 0db27f81..3d508db9 100644 --- a/silk/SKP_Silk_decode_frame.c +++ b/silk/silk_decode_frame.c @@ -25,21 +25,21 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" -#include "SKP_Silk_PLC.h" +#include "silk_main.h" +#include "silk_PLC.h" /****************/ /* Decode frame */ /****************/ -SKP_int SKP_Silk_decode_frame( - SKP_Silk_decoder_state *psDec, /* I/O Pointer to Silk decoder state */ +SKP_int silk_decode_frame( + silk_decoder_state *psDec, /* I/O Pointer to Silk decoder state */ ec_dec *psRangeDec, /* I/O Compressor data structure */ SKP_int16 pOut[], /* O Pointer to output speech frame */ SKP_int32 *pN, /* O Pointer to size of output frame */ SKP_int lostFlag /* I 0: no loss, 1 loss, 2 decode fec */ ) { - SKP_Silk_decoder_control sDecCtrl; + silk_decoder_control sDecCtrl; SKP_int L, mv_len, ret = 0; SKP_int pulses[ MAX_FRAME_LENGTH ]; @@ -58,14 +58,14 @@ TIC(DECODE_FRAME) /* Decode quantization indices of side info */ /*********************************************/ TIC(decode_indices) - SKP_Silk_decode_indices( psDec, psRangeDec, psDec->nFramesDecoded, lostFlag ); + silk_decode_indices( psDec, psRangeDec, psDec->nFramesDecoded, lostFlag ); TOC(decode_indices) /*********************************************/ /* Decode quantization indices of excitation */ /*********************************************/ TIC(decode_pulses) - SKP_Silk_decode_pulses( psRangeDec, pulses, psDec->indices.signalType, + silk_decode_pulses( psRangeDec, pulses, psDec->indices.signalType, psDec->indices.quantOffsetType, psDec->frame_length ); TOC(decode_pulses) @@ -73,7 +73,7 @@ TOC(decode_pulses) /* Decode parameters and pulse signal */ /********************************************/ TIC(decode_params) - SKP_Silk_decode_parameters( psDec, &sDecCtrl ); + silk_decode_parameters( psDec, &sDecCtrl ); TOC(decode_params) /* Update length. Sampling frequency may have changed */ @@ -83,13 +83,13 @@ TOC(decode_params) /* Run inverse NSQ */ /********************************************************/ TIC(decode_core) - SKP_Silk_decode_core( psDec, &sDecCtrl, pOut, pulses ); + silk_decode_core( psDec, &sDecCtrl, pOut, pulses ); TOC(decode_core) /********************************************************/ /* Update PLC state */ /********************************************************/ - SKP_Silk_PLC( psDec, &sDecCtrl, pOut, L, 0 ); + silk_PLC( psDec, &sDecCtrl, pOut, L, 0 ); psDec->lossCnt = 0; psDec->prevSignalType = psDec->indices.signalType; @@ -99,7 +99,7 @@ TOC(decode_core) psDec->first_frame_after_reset = 0; } else { /* Handle packet loss by extrapolation */ - SKP_Silk_PLC( psDec, &sDecCtrl, pOut, L, 1 ); + silk_PLC( psDec, &sDecCtrl, pOut, L, 1 ); } /*************************/ @@ -113,12 +113,12 @@ TOC(decode_core) /****************************************************************/ /* Ensure smooth connection of extrapolated and good frames */ /****************************************************************/ - SKP_Silk_PLC_glue_frames( psDec, &sDecCtrl, pOut, L ); + silk_PLC_glue_frames( psDec, &sDecCtrl, pOut, L ); /************************************************/ /* Comfort noise generation / estimation */ /************************************************/ - SKP_Silk_CNG( psDec, &sDecCtrl, pOut, L ); + silk_CNG( psDec, &sDecCtrl, pOut, L ); /* Update some decoder state variables */ psDec->lagPrev = sDecCtrl.pitchL[ psDec->nb_subfr - 1 ]; diff --git a/silk/SKP_Silk_decode_indices.c b/silk/silk_decode_indices.c similarity index 82% rename from silk/SKP_Silk_decode_indices.c rename to silk/silk_decode_indices.c index 9864eaf5..0eebdbd3 100644 --- a/silk/SKP_Silk_decode_indices.c +++ b/silk/silk_decode_indices.c @@ -25,11 +25,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" +#include "silk_main.h" /* Decode side-information parameters from payload */ -void SKP_Silk_decode_indices( - SKP_Silk_decoder_state *psDec, /* I/O State */ +void silk_decode_indices( + silk_decoder_state *psDec, /* I/O State */ ec_dec *psRangeDec, /* I/O Compressor data structure */ SKP_int FrameIndex, /* I Frame number */ SKP_int decode_LBRR /* I Flag indicating LBRR data is being decoded */ @@ -51,9 +51,9 @@ void SKP_Silk_decode_indices( /* Decode signal type and quantizer offset */ /*******************************************/ if( decode_LBRR || psDec->VAD_flags[ FrameIndex ] ) { - Ix = ec_dec_icdf( psRangeDec, SKP_Silk_type_offset_VAD_iCDF, 8 ) + 2; + Ix = ec_dec_icdf( psRangeDec, silk_type_offset_VAD_iCDF, 8 ) + 2; } else { - Ix = ec_dec_icdf( psRangeDec, SKP_Silk_type_offset_no_VAD_iCDF, 8 ); + Ix = ec_dec_icdf( psRangeDec, silk_type_offset_no_VAD_iCDF, 8 ); } psDec->indices.signalType = (SKP_int8)SKP_RSHIFT( Ix, 1 ); psDec->indices.quantOffsetType = (SKP_int8)( Ix & 1 ); @@ -64,37 +64,37 @@ void SKP_Silk_decode_indices( /* First subframe */ if( condCoding ) { /* Conditional coding */ - psDec->indices.GainsIndices[ 0 ] = (SKP_int8)ec_dec_icdf( psRangeDec, SKP_Silk_delta_gain_iCDF, 8 ); + psDec->indices.GainsIndices[ 0 ] = (SKP_int8)ec_dec_icdf( psRangeDec, silk_delta_gain_iCDF, 8 ); } else { /* Independent coding, in two stages: MSB bits followed by 3 LSBs */ - psDec->indices.GainsIndices[ 0 ] = (SKP_int8)SKP_LSHIFT( ec_dec_icdf( psRangeDec, SKP_Silk_gain_iCDF[ psDec->indices.signalType ], 8 ), 3 ); - psDec->indices.GainsIndices[ 0 ] += (SKP_int8)ec_dec_icdf( psRangeDec, SKP_Silk_uniform8_iCDF, 8 ); + psDec->indices.GainsIndices[ 0 ] = (SKP_int8)SKP_LSHIFT( ec_dec_icdf( psRangeDec, silk_gain_iCDF[ psDec->indices.signalType ], 8 ), 3 ); + psDec->indices.GainsIndices[ 0 ] += (SKP_int8)ec_dec_icdf( psRangeDec, silk_uniform8_iCDF, 8 ); } /* Remaining subframes */ for( i = 1; i < psDec->nb_subfr; i++ ) { - psDec->indices.GainsIndices[ i ] = (SKP_int8)ec_dec_icdf( psRangeDec, SKP_Silk_delta_gain_iCDF, 8 ); + psDec->indices.GainsIndices[ i ] = (SKP_int8)ec_dec_icdf( psRangeDec, silk_delta_gain_iCDF, 8 ); } /**********************/ /* Decode LSF Indices */ /**********************/ psDec->indices.NLSFIndices[ 0 ] = (SKP_int8)ec_dec_icdf( psRangeDec, &psDec->psNLSF_CB->CB1_iCDF[ ( psDec->indices.signalType >> 1 ) * psDec->psNLSF_CB->nVectors ], 8 ); - SKP_Silk_NLSF_unpack( ec_ix, pred_Q8, psDec->psNLSF_CB, psDec->indices.NLSFIndices[ 0 ] ); + silk_NLSF_unpack( ec_ix, pred_Q8, psDec->psNLSF_CB, psDec->indices.NLSFIndices[ 0 ] ); SKP_assert( psDec->psNLSF_CB->order == psDec->LPC_order ); for( i = 0; i < psDec->psNLSF_CB->order; i++ ) { Ix = ec_dec_icdf( psRangeDec, &psDec->psNLSF_CB->ec_iCDF[ ec_ix[ i ] ], 8 ); if( Ix == 0 ) { - Ix -= ec_dec_icdf( psRangeDec, SKP_Silk_NLSF_EXT_iCDF, 8 ); + Ix -= ec_dec_icdf( psRangeDec, silk_NLSF_EXT_iCDF, 8 ); } else if( Ix == 2 * NLSF_QUANT_MAX_AMPLITUDE ) { - Ix += ec_dec_icdf( psRangeDec, SKP_Silk_NLSF_EXT_iCDF, 8 ); + Ix += ec_dec_icdf( psRangeDec, silk_NLSF_EXT_iCDF, 8 ); } psDec->indices.NLSFIndices[ i+1 ] = (SKP_int8)( Ix - NLSF_QUANT_MAX_AMPLITUDE ); } /* Decode LSF interpolation factor */ if( psDec->nb_subfr == MAX_NB_SUBFR ) { - psDec->indices.NLSFInterpCoef_Q2 = (SKP_int8)ec_dec_icdf( psRangeDec, SKP_Silk_NLSF_interpolation_factor_iCDF, 8 ); + psDec->indices.NLSFInterpCoef_Q2 = (SKP_int8)ec_dec_icdf( psRangeDec, silk_NLSF_interpolation_factor_iCDF, 8 ); } else { psDec->indices.NLSFInterpCoef_Q2 = 4; } @@ -108,7 +108,7 @@ void SKP_Silk_decode_indices( decode_absolute_lagIndex = 1; if( condCoding && psDec->ec_prevSignalType == TYPE_VOICED ) { /* Decode Delta index */ - delta_lagIndex = (SKP_int16)ec_dec_icdf( psRangeDec, SKP_Silk_pitch_delta_iCDF, 8 ); + delta_lagIndex = (SKP_int16)ec_dec_icdf( psRangeDec, silk_pitch_delta_iCDF, 8 ); if( delta_lagIndex > 0 ) { delta_lagIndex = delta_lagIndex - 9; psDec->indices.lagIndex = (SKP_int16)( psDec->ec_prevLagIndex + delta_lagIndex ); @@ -117,7 +117,7 @@ void SKP_Silk_decode_indices( } if( decode_absolute_lagIndex ) { /* Absolute decoding */ - psDec->indices.lagIndex = (SKP_int16)ec_dec_icdf( psRangeDec, SKP_Silk_pitch_lag_iCDF, 8 ) * SKP_RSHIFT( psDec->fs_kHz, 1 ); + psDec->indices.lagIndex = (SKP_int16)ec_dec_icdf( psRangeDec, silk_pitch_lag_iCDF, 8 ) * SKP_RSHIFT( psDec->fs_kHz, 1 ); psDec->indices.lagIndex += (SKP_int16)ec_dec_icdf( psRangeDec, psDec->pitch_lag_low_bits_iCDF, 8 ); } psDec->ec_prevLagIndex = psDec->indices.lagIndex; @@ -129,17 +129,17 @@ void SKP_Silk_decode_indices( /* Decode LTP gains */ /********************/ /* Decode PERIndex value */ - psDec->indices.PERIndex = (SKP_int8)ec_dec_icdf( psRangeDec, SKP_Silk_LTP_per_index_iCDF, 8 ); + psDec->indices.PERIndex = (SKP_int8)ec_dec_icdf( psRangeDec, silk_LTP_per_index_iCDF, 8 ); for( k = 0; k < psDec->nb_subfr; k++ ) { - psDec->indices.LTPIndex[ k ] = (SKP_int8)ec_dec_icdf( psRangeDec, SKP_Silk_LTP_gain_iCDF_ptrs[ psDec->indices.PERIndex ], 8 ); + psDec->indices.LTPIndex[ k ] = (SKP_int8)ec_dec_icdf( psRangeDec, silk_LTP_gain_iCDF_ptrs[ psDec->indices.PERIndex ], 8 ); } /**********************/ /* Decode LTP scaling */ /**********************/ if( !condCoding ) { - psDec->indices.LTP_scaleIndex = (SKP_int8)ec_dec_icdf( psRangeDec, SKP_Silk_LTPscale_iCDF, 8 ); + psDec->indices.LTP_scaleIndex = (SKP_int8)ec_dec_icdf( psRangeDec, silk_LTPscale_iCDF, 8 ); } else { psDec->indices.LTP_scaleIndex = 0; } @@ -149,5 +149,5 @@ void SKP_Silk_decode_indices( /***************/ /* Decode seed */ /***************/ - psDec->indices.Seed = (SKP_int8)ec_dec_icdf( psRangeDec, SKP_Silk_uniform4_iCDF, 8 ); + psDec->indices.Seed = (SKP_int8)ec_dec_icdf( psRangeDec, silk_uniform4_iCDF, 8 ); } diff --git a/silk/SKP_Silk_decode_parameters.c b/silk/silk_decode_parameters.c similarity index 77% rename from silk/SKP_Silk_decode_parameters.c rename to silk/silk_decode_parameters.c index 5ec8145b..1268f46a 100644 --- a/silk/SKP_Silk_decode_parameters.c +++ b/silk/silk_decode_parameters.c @@ -25,12 +25,12 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" +#include "silk_main.h" /* Decode parameters from payload */ -void SKP_Silk_decode_parameters( - SKP_Silk_decoder_state *psDec, /* I/O State */ - SKP_Silk_decoder_control *psDecCtrl /* I/O Decoder control */ +void silk_decode_parameters( + silk_decoder_state *psDec, /* I/O State */ + silk_decoder_control *psDecCtrl /* I/O Decoder control */ ) { SKP_int i, k, Ix; @@ -38,16 +38,16 @@ void SKP_Silk_decode_parameters( const SKP_int8 *cbk_ptr_Q7; /* Dequant Gains */ - SKP_Silk_gains_dequant( psDecCtrl->Gains_Q16, psDec->indices.GainsIndices, + silk_gains_dequant( psDecCtrl->Gains_Q16, psDec->indices.GainsIndices, &psDec->LastGainIndex, psDec->nFramesDecoded, psDec->nb_subfr ); /****************/ /* Decode NLSFs */ /****************/ - SKP_Silk_NLSF_decode( pNLSF_Q15, psDec->indices.NLSFIndices, psDec->psNLSF_CB ); + silk_NLSF_decode( pNLSF_Q15, psDec->indices.NLSFIndices, psDec->psNLSF_CB ); /* Convert NLSF parameters to AR prediction filter coefficients */ - SKP_Silk_NLSF2A_stable( psDecCtrl->PredCoef_Q12[ 1 ], pNLSF_Q15, psDec->LPC_order ); + silk_NLSF2A_stable( psDecCtrl->PredCoef_Q12[ 1 ], pNLSF_Q15, psDec->LPC_order ); /* If just reset, e.g., because internal Fs changed, do not allow interpolation */ /* improves the case of packet loss in the first frame after a switch */ @@ -64,7 +64,7 @@ void SKP_Silk_decode_parameters( } /* Convert NLSF parameters to AR prediction filter coefficients */ - SKP_Silk_NLSF2A_stable( psDecCtrl->PredCoef_Q12[ 0 ], pNLSF0_Q15, psDec->LPC_order ); + silk_NLSF2A_stable( psDecCtrl->PredCoef_Q12[ 0 ], pNLSF0_Q15, psDec->LPC_order ); } else { /* Copy LPC coefficients for first half from second half */ SKP_memcpy( psDecCtrl->PredCoef_Q12[ 0 ], psDecCtrl->PredCoef_Q12[ 1 ], @@ -75,8 +75,8 @@ void SKP_Silk_decode_parameters( /* After a packet loss do BWE of LPC coefs */ if( psDec->lossCnt ) { - SKP_Silk_bwexpander( psDecCtrl->PredCoef_Q12[ 0 ], psDec->LPC_order, BWE_AFTER_LOSS_Q16 ); - SKP_Silk_bwexpander( psDecCtrl->PredCoef_Q12[ 1 ], psDec->LPC_order, BWE_AFTER_LOSS_Q16 ); + silk_bwexpander( psDecCtrl->PredCoef_Q12[ 0 ], psDec->LPC_order, BWE_AFTER_LOSS_Q16 ); + silk_bwexpander( psDecCtrl->PredCoef_Q12[ 1 ], psDec->LPC_order, BWE_AFTER_LOSS_Q16 ); } if( psDec->indices.signalType == TYPE_VOICED ) { @@ -85,10 +85,10 @@ void SKP_Silk_decode_parameters( /*********************/ /* Decode pitch values */ - SKP_Silk_decode_pitch( psDec->indices.lagIndex, psDec->indices.contourIndex, psDecCtrl->pitchL, psDec->fs_kHz, psDec->nb_subfr ); + silk_decode_pitch( psDec->indices.lagIndex, psDec->indices.contourIndex, psDecCtrl->pitchL, psDec->fs_kHz, psDec->nb_subfr ); /* Decode Codebook Index */ - cbk_ptr_Q7 = SKP_Silk_LTP_vq_ptrs_Q7[ psDec->indices.PERIndex ]; /* set pointer to start of codebook */ + cbk_ptr_Q7 = silk_LTP_vq_ptrs_Q7[ psDec->indices.PERIndex ]; /* set pointer to start of codebook */ for( k = 0; k < psDec->nb_subfr; k++ ) { Ix = psDec->indices.LTPIndex[ k ]; @@ -101,7 +101,7 @@ void SKP_Silk_decode_parameters( /* Decode LTP scaling */ /**********************/ Ix = psDec->indices.LTP_scaleIndex; - psDecCtrl->LTP_scale_Q14 = SKP_Silk_LTPScales_table_Q14[ Ix ]; + psDecCtrl->LTP_scale_Q14 = silk_LTPScales_table_Q14[ Ix ]; } else { SKP_memset( psDecCtrl->pitchL, 0, psDec->nb_subfr * sizeof( SKP_int ) ); SKP_memset( psDecCtrl->LTPCoef_Q14, 0, LTP_ORDER * psDec->nb_subfr * sizeof( SKP_int16 ) ); diff --git a/silk/SKP_Silk_decode_pitch.c b/silk/silk_decode_pitch.c similarity index 88% rename from silk/SKP_Silk_decode_pitch.c rename to silk/silk_decode_pitch.c index 540229b7..7ec472ef 100644 --- a/silk/SKP_Silk_decode_pitch.c +++ b/silk/silk_decode_pitch.c @@ -28,10 +28,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /*********************************************************** * Pitch analyser function ********************************************************** */ -#include "SKP_Silk_SigProc_FIX.h" -#include "SKP_Silk_pitch_est_defines.h" +#include "silk_SigProc_FIX.h" +#include "silk_pitch_est_defines.h" -void SKP_Silk_decode_pitch( +void silk_decode_pitch( SKP_int16 lagIndex, /* I */ SKP_int8 contourIndex, /* O */ SKP_int pitch_lags[], /* O pitch values */ @@ -44,20 +44,20 @@ void SKP_Silk_decode_pitch( if( Fs_kHz == 8 ) { if( nb_subfr == PE_MAX_NB_SUBFR ) { - Lag_CB_ptr = &SKP_Silk_CB_lags_stage2[ 0 ][ 0 ]; + Lag_CB_ptr = &silk_CB_lags_stage2[ 0 ][ 0 ]; cbk_size = PE_NB_CBKS_STAGE2_EXT; } else { SKP_assert( nb_subfr == PE_MAX_NB_SUBFR >> 1 ); - Lag_CB_ptr = &SKP_Silk_CB_lags_stage2_10_ms[ 0 ][ 0 ]; + Lag_CB_ptr = &silk_CB_lags_stage2_10_ms[ 0 ][ 0 ]; cbk_size = PE_NB_CBKS_STAGE2_10MS; } } else { if( nb_subfr == PE_MAX_NB_SUBFR ) { - Lag_CB_ptr = &SKP_Silk_CB_lags_stage3[ 0 ][ 0 ]; + Lag_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ]; cbk_size = PE_NB_CBKS_STAGE3_MAX; } else { SKP_assert( nb_subfr == PE_MAX_NB_SUBFR >> 1 ); - Lag_CB_ptr = &SKP_Silk_CB_lags_stage3_10_ms[ 0 ][ 0 ]; + Lag_CB_ptr = &silk_CB_lags_stage3_10_ms[ 0 ][ 0 ]; cbk_size = PE_NB_CBKS_STAGE3_10MS; } } diff --git a/silk/SKP_Silk_decode_pulses.c b/silk/silk_decode_pulses.c similarity index 86% rename from silk/SKP_Silk_decode_pulses.c rename to silk/silk_decode_pulses.c index 2a92790f..9c0aa94a 100644 --- a/silk/SKP_Silk_decode_pulses.c +++ b/silk/silk_decode_pulses.c @@ -25,12 +25,12 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" +#include "silk_main.h" /*********************************************/ /* Decode quantization indices of excitation */ /*********************************************/ -void SKP_Silk_decode_pulses( +void silk_decode_pulses( ec_dec *psRangeDec, /* I/O Compressor data structure */ SKP_int pulses[], /* O Excitation signal */ const SKP_int signalType, /* I Sigtype */ @@ -46,7 +46,7 @@ void SKP_Silk_decode_pulses( /*********************/ /* Decode rate level */ /*********************/ - RateLevelIndex = ec_dec_icdf( psRangeDec, SKP_Silk_rate_levels_iCDF[ signalType >> 1 ], 8 ); + RateLevelIndex = ec_dec_icdf( psRangeDec, silk_rate_levels_iCDF[ signalType >> 1 ], 8 ); /* Calculate number of shell blocks */ SKP_assert( 1 << LOG2_SHELL_CODEC_FRAME_LENGTH == SHELL_CODEC_FRAME_LENGTH ); @@ -59,7 +59,7 @@ void SKP_Silk_decode_pulses( /***************************************************/ /* Sum-Weighted-Pulses Decoding */ /***************************************************/ - cdf_ptr = SKP_Silk_pulses_per_block_iCDF[ RateLevelIndex ]; + cdf_ptr = silk_pulses_per_block_iCDF[ RateLevelIndex ]; for( i = 0; i < iter; i++ ) { nLshifts[ i ] = 0; sum_pulses[ i ] = ec_dec_icdf( psRangeDec, cdf_ptr, 8 ); @@ -67,7 +67,7 @@ void SKP_Silk_decode_pulses( /* LSB indication */ while( sum_pulses[ i ] == MAX_PULSES + 1 ) { nLshifts[ i ]++; - sum_pulses[ i ] = ec_dec_icdf( psRangeDec, SKP_Silk_pulses_per_block_iCDF[ N_RATE_LEVELS - 1 ], 8 ); + sum_pulses[ i ] = ec_dec_icdf( psRangeDec, silk_pulses_per_block_iCDF[ N_RATE_LEVELS - 1 ], 8 ); } } @@ -76,7 +76,7 @@ void SKP_Silk_decode_pulses( /***************************************************/ for( i = 0; i < iter; i++ ) { if( sum_pulses[ i ] > 0 ) { - SKP_Silk_shell_decoder( &pulses[ SKP_SMULBB( i, SHELL_CODEC_FRAME_LENGTH ) ], psRangeDec, sum_pulses[ i ] ); + silk_shell_decoder( &pulses[ SKP_SMULBB( i, SHELL_CODEC_FRAME_LENGTH ) ], psRangeDec, sum_pulses[ i ] ); } else { SKP_memset( &pulses[ SKP_SMULBB( i, SHELL_CODEC_FRAME_LENGTH ) ], 0, SHELL_CODEC_FRAME_LENGTH * sizeof( SKP_int ) ); } @@ -93,7 +93,7 @@ void SKP_Silk_decode_pulses( abs_q = pulses_ptr[ k ]; for( j = 0; j < nLS; j++ ) { abs_q = SKP_LSHIFT( abs_q, 1 ); - abs_q += ec_dec_icdf( psRangeDec, SKP_Silk_lsb_iCDF, 8 ); + abs_q += ec_dec_icdf( psRangeDec, silk_lsb_iCDF, 8 ); } pulses_ptr[ k ] = abs_q; } @@ -103,5 +103,5 @@ void SKP_Silk_decode_pulses( /****************************************/ /* Decode and add signs to pulse signal */ /****************************************/ - SKP_Silk_decode_signs( psRangeDec, pulses, frame_length, signalType, quantOffsetType, sum_pulses ); + silk_decode_signs( psRangeDec, pulses, frame_length, signalType, quantOffsetType, sum_pulses ); } diff --git a/silk/SKP_Silk_decoder_set_fs.c b/silk/silk_decoder_set_fs.c similarity index 80% rename from silk/SKP_Silk_decoder_set_fs.c rename to silk/silk_decoder_set_fs.c index ea316fc9..9d0710c5 100644 --- a/silk/SKP_Silk_decoder_set_fs.c +++ b/silk/silk_decoder_set_fs.c @@ -25,11 +25,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" +#include "silk_main.h" /* Set decoder sampling rate */ -void SKP_Silk_decoder_set_fs( - SKP_Silk_decoder_state *psDec, /* I/O Decoder state pointer */ +void silk_decoder_set_fs( + silk_decoder_state *psDec, /* I/O Decoder state pointer */ SKP_int fs_kHz /* I Sampling frequency (kHz) */ ) { @@ -46,23 +46,23 @@ void SKP_Silk_decoder_set_fs( psDec->ltp_mem_length = SKP_SMULBB( LTP_MEM_LENGTH_MS, fs_kHz ); if( psDec->fs_kHz == 8 ) { if( psDec->nb_subfr == MAX_NB_SUBFR ) { - psDec->pitch_contour_iCDF = SKP_Silk_pitch_contour_NB_iCDF; + psDec->pitch_contour_iCDF = silk_pitch_contour_NB_iCDF; } else { - psDec->pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_NB_iCDF; + psDec->pitch_contour_iCDF = silk_pitch_contour_10_ms_NB_iCDF; } } else { if( psDec->nb_subfr == MAX_NB_SUBFR ) { - psDec->pitch_contour_iCDF = SKP_Silk_pitch_contour_iCDF; + psDec->pitch_contour_iCDF = silk_pitch_contour_iCDF; } else { - psDec->pitch_contour_iCDF = SKP_Silk_pitch_contour_10_ms_iCDF; + psDec->pitch_contour_iCDF = silk_pitch_contour_10_ms_iCDF; } } if( psDec->fs_kHz == 8 || psDec->fs_kHz == 12 ) { psDec->LPC_order = MIN_LPC_ORDER; - psDec->psNLSF_CB = &SKP_Silk_NLSF_CB_NB_MB; + psDec->psNLSF_CB = &silk_NLSF_CB_NB_MB; } else { psDec->LPC_order = MAX_LPC_ORDER; - psDec->psNLSF_CB = &SKP_Silk_NLSF_CB_WB; + psDec->psNLSF_CB = &silk_NLSF_CB_WB; } /* Reset part of the decoder state */ @@ -76,11 +76,11 @@ void SKP_Silk_decoder_set_fs( psDec->first_frame_after_reset = 1; if( fs_kHz == 16 ) { - psDec->pitch_lag_low_bits_iCDF = SKP_Silk_uniform8_iCDF; + psDec->pitch_lag_low_bits_iCDF = silk_uniform8_iCDF; } else if( fs_kHz == 12 ) { - psDec->pitch_lag_low_bits_iCDF = SKP_Silk_uniform6_iCDF; + psDec->pitch_lag_low_bits_iCDF = silk_uniform6_iCDF; } else if( fs_kHz == 8 ) { - psDec->pitch_lag_low_bits_iCDF = SKP_Silk_uniform4_iCDF; + psDec->pitch_lag_low_bits_iCDF = silk_uniform4_iCDF; } else { /* unsupported sampling rate */ SKP_assert( 0 ); diff --git a/silk/SKP_Silk_define.h b/silk/silk_define.h similarity index 92% rename from silk/SKP_Silk_define.h rename to silk/silk_define.h index 22917fa0..716abde1 100644 --- a/silk/SKP_Silk_define.h +++ b/silk/silk_define.h @@ -25,11 +25,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#ifndef SKP_SILK_DEFINE_H -#define SKP_SILK_DEFINE_H +#ifndef SILK_DEFINE_H +#define SILK_DEFINE_H -#include "SKP_Silk_errors.h" -#include "SKP_Silk_typedef.h" +#include "silk_errors.h" +#include "silk_typedef.h" #ifdef HAVE_CONFIG_H #include "config.h" @@ -52,13 +52,10 @@ extern "C" #define MAX_TARGET_RATE_BPS 80000 #define TARGET_RATE_TAB_SZ 8 -/* Decay time for bitreservoir */ -#define BITRESERVOIR_DECAY_TIME_MS 200 - /* LBRR thresholds */ -#define LBRR_NB_MIN_RATE_BPS 9000 -#define LBRR_MB_MIN_RATE_BPS 12000 -#define LBRR_WB_MIN_RATE_BPS 15000 +#define LBRR_NB_MIN_RATE_BPS 12000 +#define LBRR_MB_MIN_RATE_BPS 14000 +#define LBRR_WB_MIN_RATE_BPS 16000 /* DTX settings */ #define NB_SPEECH_FRAMES_BEFORE_DTX 10 /* eq 200 ms */ @@ -73,16 +70,17 @@ extern "C" #define TYPE_UNVOICED 1 #define TYPE_VOICED 2 -/* Setting for stereo processing */ +/* Settings for stereo processing */ #define STEREO_QUANT_TAB_SIZE 16 #define STEREO_QUANT_SUB_STEPS 5 #define STEREO_INTERP_LEN_MS 8 /* must be even */ +#define STEREO_RATIO_SMOOTH_COEF 0.01 /* smoothing coef for signal norms and stereo width */ /* Range of pitch lag estimates */ #define PITCH_EST_MIN_LAG_MS 2 /* 2 ms -> 500 Hz */ #define PITCH_EST_MAX_LAG_MS 18 /* 18 ms -> 56 Hz */ -/* Number of subframes */ +/* Maximum number of subframes */ #define MAX_NB_SUBFR 4 /* Number of samples per frame */ @@ -201,6 +199,9 @@ extern "C" /* smoothing for SNR measurement */ #define VAD_SNR_SMOOTH_COEF_Q18 4096 +/* Size of the piecewise linear cosine approximation table for the LSFs */ +#define LSF_COS_TAB_SZ_FIX 128 + /******************/ /* NLSF quantizer */ /******************/ diff --git a/silk/SKP_Silk_enc_API.c b/silk/silk_enc_API.c similarity index 56% rename from silk/SKP_Silk_enc_API.c rename to silk/silk_enc_API.c index f5560c9e..9f06eced 100644 --- a/silk/SKP_Silk_enc_API.c +++ b/silk/silk_enc_API.c @@ -25,45 +25,28 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include "SKP_Silk_define.h" -#include "SKP_Silk_SDK_API.h" -#include "SKP_Silk_control.h" -#include "SKP_Silk_typedef.h" -#include "SKP_Silk_structs.h" -#include "SKP_Silk_tuning_parameters.h" +#include "silk_define.h" +#include "silk_API.h" +#include "silk_control.h" +#include "silk_typedef.h" +#include "silk_structs.h" +#include "silk_tuning_parameters.h" #ifdef FIXED_POINT -#include "SKP_Silk_main_FIX.h" -#define SKP_Silk_encoder_state_Fxx SKP_Silk_encoder_state_FIX -#define SKP_Silk_encode_frame_Fxx SKP_Silk_encode_frame_FIX +#include "silk_main_FIX.h" #else -#include "SKP_Silk_main_FLP.h" -#define SKP_Silk_encoder_state_Fxx SKP_Silk_encoder_state_FLP -#define SKP_Silk_encode_frame_Fxx SKP_Silk_encode_frame_FLP +#include "silk_main_FLP.h" #endif -/* Encoder Super Struct */ -typedef struct { - SKP_Silk_encoder_state_Fxx state_Fxx[ ENCODER_NUM_CHANNELS ]; - stereo_state sStereo; - SKP_int32 nBitsExceeded; - SKP_int nChannels; - SKP_int timeSinceSwitchAllowed_ms; - SKP_int allowBandwidthSwitch; -} SKP_Silk_encoder; - /****************************************/ /* Encoder functions */ /****************************************/ -SKP_int SKP_Silk_SDK_Get_Encoder_Size( SKP_int32 *encSizeBytes ) +SKP_int silk_Get_Encoder_Size( SKP_int32 *encSizeBytes ) { - SKP_int ret = SKP_SILK_NO_ERROR; + SKP_int ret = SILK_NO_ERROR; - *encSizeBytes = sizeof( SKP_Silk_encoder ); + *encSizeBytes = sizeof( silk_encoder ); return ret; } @@ -71,29 +54,29 @@ SKP_int SKP_Silk_SDK_Get_Encoder_Size( SKP_int32 *encSizeBytes ) /*************************/ /* Init or Reset encoder */ /*************************/ -SKP_int SKP_Silk_SDK_InitEncoder( +SKP_int silk_InitEncoder( void *encState, /* I/O: State */ - SKP_SILK_SDK_EncControlStruct *encStatus /* O: Control structure */ + silk_EncControlStruct *encStatus /* O: Control structure */ ) { - SKP_Silk_encoder *psEnc; - SKP_int n, ret = SKP_SILK_NO_ERROR; + silk_encoder *psEnc; + SKP_int n, ret = SILK_NO_ERROR; - psEnc = (SKP_Silk_encoder *)encState; + psEnc = (silk_encoder *)encState; /* Reset encoder */ + SKP_memset( psEnc, 0, sizeof( silk_encoder ) ); for( n = 0; n < ENCODER_NUM_CHANNELS; n++ ) { - if( ret += SKP_Silk_init_encoder( &psEnc->state_Fxx[ n ] ) ) { + if( ret += silk_init_encoder( &psEnc->state_Fxx[ n ] ) ) { SKP_assert( 0 ); } } - SKP_memset( &psEnc->sStereo, 0, sizeof( psEnc->sStereo ) ); - psEnc->nBitsExceeded = 0; - psEnc->nChannels = 1; + psEnc->nChannelsAPI = 1; + psEnc->nChannelsInternal = 1; /* Read control structure */ - if( ret += SKP_Silk_SDK_QueryEncoder( encState, encStatus ) ) { + if( ret += silk_QueryEncoder( encState, encStatus ) ) { SKP_assert( 0 ); } @@ -103,28 +86,33 @@ SKP_int SKP_Silk_SDK_InitEncoder( /***************************************/ /* Read control structure from encoder */ /***************************************/ -SKP_int SKP_Silk_SDK_QueryEncoder( +SKP_int silk_QueryEncoder( const void *encState, /* I: State Vector */ - SKP_SILK_SDK_EncControlStruct *encStatus /* O: Control Structure */ + silk_EncControlStruct *encStatus /* O: Control Structure */ ) { - SKP_Silk_encoder_state_Fxx *state_Fxx; - SKP_int ret = SKP_SILK_NO_ERROR; + SKP_int ret = SILK_NO_ERROR; + silk_encoder_state_Fxx *state_Fxx; + silk_encoder *psEnc = (silk_encoder *)encState; - state_Fxx = ((SKP_Silk_encoder *)encState)->state_Fxx; + state_Fxx = psEnc->state_Fxx; - encStatus->API_sampleRate = state_Fxx->sCmn.API_fs_Hz; - encStatus->maxInternalSampleRate = state_Fxx->sCmn.maxInternal_fs_Hz; - encStatus->minInternalSampleRate = state_Fxx->sCmn.minInternal_fs_Hz; - encStatus->desiredInternalSampleRate = state_Fxx->sCmn.desiredInternal_fs_Hz; - encStatus->payloadSize_ms = state_Fxx->sCmn.PacketSize_ms; - encStatus->bitRate = state_Fxx->sCmn.TargetRate_bps; - encStatus->packetLossPercentage = state_Fxx->sCmn.PacketLoss_perc; - encStatus->complexity = state_Fxx->sCmn.Complexity; - encStatus->useInBandFEC = state_Fxx->sCmn.useInBandFEC; - encStatus->useDTX = state_Fxx->sCmn.useDTX; - encStatus->useCBR = state_Fxx->sCmn.useCBR; - encStatus->internalSampleRate = SKP_SMULBB( state_Fxx->sCmn.fs_kHz, 1000 ); + encStatus->nChannelsAPI = psEnc->nChannelsAPI; + encStatus->nChannelsInternal = psEnc->nChannelsInternal; + encStatus->API_sampleRate = state_Fxx[ 0 ].sCmn.API_fs_Hz; + encStatus->maxInternalSampleRate = state_Fxx[ 0 ].sCmn.maxInternal_fs_Hz; + encStatus->minInternalSampleRate = state_Fxx[ 0 ].sCmn.minInternal_fs_Hz; + encStatus->desiredInternalSampleRate = state_Fxx[ 0 ].sCmn.desiredInternal_fs_Hz; + encStatus->payloadSize_ms = state_Fxx[ 0 ].sCmn.PacketSize_ms; + encStatus->bitRate = state_Fxx[ 0 ].sCmn.TargetRate_bps; + encStatus->packetLossPercentage = state_Fxx[ 0 ].sCmn.PacketLoss_perc; + encStatus->complexity = state_Fxx[ 0 ].sCmn.Complexity; + encStatus->useInBandFEC = state_Fxx[ 0 ].sCmn.useInBandFEC; + encStatus->useDTX = state_Fxx[ 0 ].sCmn.useDTX; + encStatus->useCBR = state_Fxx[ 0 ].sCmn.useCBR; + encStatus->internalSampleRate = SKP_SMULBB( state_Fxx[ 0 ].sCmn.fs_kHz, 1000 ); + encStatus->allowBandwidthSwitch = state_Fxx[ 0 ].sCmn.allow_bandwidth_switch; + encStatus->inWBmodeWithoutVariableLP = state_Fxx[ 0 ].sCmn.fs_kHz == 16 && state_Fxx[ 0 ].sCmn.sLP.mode == 0; return ret; } @@ -132,9 +120,9 @@ SKP_int SKP_Silk_SDK_QueryEncoder( /**************************/ /* Encode frame with Silk */ /**************************/ -SKP_int SKP_Silk_SDK_Encode( +SKP_int silk_Encode( void *encState, /* I/O: State */ - SKP_SILK_SDK_EncControlStruct *encControl, /* I: Control structure */ + silk_EncControlStruct *encControl, /* I: Control structure */ const SKP_int16 *samplesIn, /* I: Speech sample input vector */ SKP_int nSamplesIn, /* I: Number of samples in input vector */ ec_enc *psRangeEnc, /* I/O Compressor data structure */ @@ -142,11 +130,11 @@ SKP_int SKP_Silk_SDK_Encode( const SKP_int prefillFlag /* I: Flag to indicate prefilling buffers; no coding */ ) { - SKP_int n, i, nBits, flags, tmp_payloadSize_ms, tmp_complexity, ret = 0; + SKP_int n, i, nBits, flags, tmp_payloadSize_ms = 0, tmp_complexity = 0, ret = 0; SKP_int nSamplesToBuffer, nBlocksOf10ms, nSamplesFromInput = 0; SKP_int speech_act_thr_for_switch_Q8; - SKP_int32 TargetRate_bps, channelRate_bps, LBRR_symbol; - SKP_Silk_encoder *psEnc = ( SKP_Silk_encoder * )encState; + SKP_int32 TargetRate_bps, MStargetRates_bps[ 2 ], channelRate_bps, LBRR_symbol; + silk_encoder *psEnc = ( silk_encoder * )encState; SKP_int MS_predictorIx[ 2 ] = { 0 }; SKP_int16 buf[ MAX_FRAME_LENGTH_MS * MAX_API_FS_KHZ ]; @@ -156,24 +144,33 @@ SKP_int SKP_Silk_SDK_Encode( return ret; } - if( encControl->nChannels > psEnc->nChannels ) { + if( encControl->nChannelsInternal > psEnc->nChannelsInternal ) { /* Mono -> Stereo transition: init state of second channel and stereo state */ - SKP_memset( &psEnc->sStereo, 0, sizeof( psEnc->sStereo ) ); - ret += SKP_Silk_init_encoder( &psEnc->state_Fxx[ 1 ] ); + ret += silk_init_encoder( &psEnc->state_Fxx[ 1 ] ); + SKP_memset( psEnc->sStereo.pred_prev_Q13, 0, sizeof( psEnc->sStereo.pred_prev_Q13 ) ); + SKP_memset( psEnc->sStereo.sSide, 0, sizeof( psEnc->sStereo.sSide ) ); + SKP_memset( psEnc->sStereo.mid_side_amp_Q0, 0, sizeof( psEnc->sStereo.mid_side_amp_Q0 ) ); + psEnc->sStereo.width_prev_Q14 = 0; + psEnc->sStereo.smth_width_Q14 = SILK_FIX_CONST( 1, 14 ); + if( psEnc->nChannelsAPI == 2 ) { + SKP_memcpy( &psEnc->state_Fxx[ 1 ].sCmn.resampler_state, &psEnc->state_Fxx[ 0 ].sCmn.resampler_state, sizeof( silk_resampler_state_struct ) ); + SKP_memcpy( &psEnc->state_Fxx[ 1 ].sCmn.In_HP_State, &psEnc->state_Fxx[ 0 ].sCmn.In_HP_State, sizeof( psEnc->state_Fxx[ 1 ].sCmn.In_HP_State ) ); + } } - psEnc->nChannels = encControl->nChannels; + psEnc->nChannelsAPI = encControl->nChannelsAPI; + psEnc->nChannelsInternal = encControl->nChannelsInternal; nBlocksOf10ms = SKP_DIV32( 100 * nSamplesIn, encControl->API_sampleRate ); if( prefillFlag ) { /* Only accept input length of 10 ms */ if( nBlocksOf10ms != 1 ) { - ret = SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES; + ret = SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES; SKP_assert( 0 ); return ret; } /* Reset Encoder */ - for( n = 0; n < encControl->nChannels; n++ ) { - if( ret = SKP_Silk_init_encoder( &psEnc->state_Fxx[ n ] ) ) { + for( n = 0; n < encControl->nChannelsInternal; n++ ) { + if( ret = silk_init_encoder( &psEnc->state_Fxx[ n ] ) ) { SKP_assert( 0 ); } } @@ -181,33 +178,33 @@ SKP_int SKP_Silk_SDK_Encode( encControl->payloadSize_ms = 10; tmp_complexity = encControl->complexity; encControl->complexity = 0; - for( n = 0; n < encControl->nChannels; n++ ) { + for( n = 0; n < encControl->nChannelsInternal; n++ ) { psEnc->state_Fxx[ n ].sCmn.controlled_since_last_payload = 0; psEnc->state_Fxx[ n ].sCmn.prefillFlag = 1; } } else { /* Only accept input lengths that are a multiple of 10 ms */ if( nBlocksOf10ms * encControl->API_sampleRate != 100 * nSamplesIn || nSamplesIn < 0 ) { - ret = SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES; + ret = SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES; SKP_assert( 0 ); return ret; } /* Make sure no more than one packet can be produced */ if( 1000 * (SKP_int32)nSamplesIn > encControl->payloadSize_ms * encControl->API_sampleRate ) { - ret = SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES; + ret = SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES; SKP_assert( 0 ); return ret; } } - TargetRate_bps = SKP_RSHIFT32( encControl->bitRate, encControl->nChannels - 1 ); - for( n = 0; n < encControl->nChannels; n++ ) { - if( ( ret = SKP_Silk_control_encoder( &psEnc->state_Fxx[ n ], encControl, TargetRate_bps, psEnc->allowBandwidthSwitch, n ) ) != 0 ) { + TargetRate_bps = SKP_RSHIFT32( encControl->bitRate, encControl->nChannelsInternal - 1 ); + for( n = 0; n < encControl->nChannelsInternal; n++ ) { + if( ( ret = silk_control_encoder( &psEnc->state_Fxx[ n ], encControl, TargetRate_bps, psEnc->allowBandwidthSwitch, n ) ) != 0 ) { SKP_assert( 0 ); return ret; } } - SKP_assert( encControl->nChannels == 1 || psEnc->state_Fxx[ 0 ].sCmn.fs_kHz == psEnc->state_Fxx[ 1 ].sCmn.fs_kHz ); + SKP_assert( encControl->nChannelsInternal == 1 || psEnc->state_Fxx[ 0 ].sCmn.fs_kHz == psEnc->state_Fxx[ 1 ].sCmn.fs_kHz ); /* Input buffering/resampling and encoding */ while( 1 ) { @@ -215,11 +212,11 @@ SKP_int SKP_Silk_SDK_Encode( nSamplesToBuffer = SKP_min( nSamplesToBuffer, 10 * nBlocksOf10ms * psEnc->state_Fxx[ 0 ].sCmn.fs_kHz ); nSamplesFromInput = SKP_DIV32_16( nSamplesToBuffer * psEnc->state_Fxx[ 0 ].sCmn.API_fs_Hz, psEnc->state_Fxx[ 0 ].sCmn.fs_kHz * 1000 ); /* Resample and write to buffer */ - if( encControl->nChannels == 2 ) { + if( encControl->nChannelsAPI == 2 && encControl->nChannelsInternal == 2 ) { for( n = 0; n < nSamplesFromInput; n++ ) { buf[ n ] = samplesIn[ 2 * n ]; } - ret += SKP_Silk_resampler( &psEnc->state_Fxx[ 0 ].sCmn.resampler_state, + ret += silk_resampler( &psEnc->state_Fxx[ 0 ].sCmn.resampler_state, &psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx ], buf, nSamplesFromInput ); psEnc->state_Fxx[ 0 ].sCmn.inputBufIx += nSamplesToBuffer; @@ -228,16 +225,24 @@ SKP_int SKP_Silk_SDK_Encode( for( n = 0; n < nSamplesFromInput; n++ ) { buf[ n ] = samplesIn[ 2 * n + 1 ]; } - ret += SKP_Silk_resampler( &psEnc->state_Fxx[ 1 ].sCmn.resampler_state, + ret += silk_resampler( &psEnc->state_Fxx[ 1 ].sCmn.resampler_state, &psEnc->state_Fxx[ 1 ].sCmn.inputBuf[ psEnc->state_Fxx[ 1 ].sCmn.inputBufIx ], buf, nSamplesFromInput ); psEnc->state_Fxx[ 1 ].sCmn.inputBufIx += nSamplesToBuffer; + } else if( encControl->nChannelsAPI == 2 && encControl->nChannelsInternal == 1 ) { + /* Combine left and right channels before resampling */ + for( n = 0; n < nSamplesFromInput; n++ ) { + buf[ n ] = (SKP_int16)SKP_RSHIFT_ROUND( samplesIn[ 2 * n ] + samplesIn[ 2 * n + 1 ], 1 ); + } + ret += silk_resampler( &psEnc->state_Fxx[ 0 ].sCmn.resampler_state, + &psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx ], buf, nSamplesFromInput ); + psEnc->state_Fxx[ 0 ].sCmn.inputBufIx += nSamplesToBuffer; } else { - SKP_assert( encControl->nChannels == 1 ); - ret += SKP_Silk_resampler( &psEnc->state_Fxx[ 0 ].sCmn.resampler_state, + SKP_assert( encControl->nChannelsAPI == 1 && encControl->nChannelsInternal == 1 ); + ret += silk_resampler( &psEnc->state_Fxx[ 0 ].sCmn.resampler_state, &psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.inputBufIx ], samplesIn, nSamplesFromInput ); psEnc->state_Fxx[ 0 ].sCmn.inputBufIx += nSamplesToBuffer; } - samplesIn += nSamplesFromInput * encControl->nChannels; + samplesIn += nSamplesFromInput * encControl->nChannelsAPI; nSamplesIn -= nSamplesFromInput; /* Default */ @@ -247,58 +252,57 @@ SKP_int SKP_Silk_SDK_Encode( if( psEnc->state_Fxx[ 0 ].sCmn.inputBufIx >= psEnc->state_Fxx[ 0 ].sCmn.frame_length ) { /* Enough data in input buffer, so encode */ SKP_assert( psEnc->state_Fxx[ 0 ].sCmn.inputBufIx == psEnc->state_Fxx[ 0 ].sCmn.frame_length ); - SKP_assert( encControl->nChannels == 1 || psEnc->state_Fxx[ 1 ].sCmn.inputBufIx == psEnc->state_Fxx[ 1 ].sCmn.frame_length ); + SKP_assert( encControl->nChannelsInternal == 1 || psEnc->state_Fxx[ 1 ].sCmn.inputBufIx == psEnc->state_Fxx[ 1 ].sCmn.frame_length ); /* Deal with LBRR data */ - if( psEnc->state_Fxx[ 0 ].sCmn.nFramesAnalyzed == 0 && !prefillFlag ) { + if( psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded == 0 && !prefillFlag ) { /* Create space at start of payload for VAD and FEC flags */ SKP_uint8 iCDF[ 2 ] = { 0, 0 }; - iCDF[ 0 ] = 256 - SKP_RSHIFT( 256, ( psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket + 1 ) * encControl->nChannels ); + iCDF[ 0 ] = 256 - SKP_RSHIFT( 256, ( psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket + 1 ) * encControl->nChannelsInternal ); ec_enc_icdf( psRangeEnc, 0, iCDF, 8 ); /* Encode any LBRR data from previous packet */ /* Encode LBRR flags */ - for( n = 0; n < encControl->nChannels; n++ ) { + for( n = 0; n < encControl->nChannelsInternal; n++ ) { LBRR_symbol = 0; for( i = 0; i < psEnc->state_Fxx[ n ].sCmn.nFramesPerPacket; i++ ) { LBRR_symbol |= SKP_LSHIFT( psEnc->state_Fxx[ n ].sCmn.LBRR_flags[ i ], i ); } psEnc->state_Fxx[ n ].sCmn.LBRR_flag = LBRR_symbol > 0 ? 1 : 0; if( LBRR_symbol && psEnc->state_Fxx[ n ].sCmn.nFramesPerPacket > 1 ) { - ec_enc_icdf( psRangeEnc, LBRR_symbol - 1, SKP_Silk_LBRR_flags_iCDF_ptr[ psEnc->state_Fxx[ n ].sCmn.nFramesPerPacket - 2 ], 8 ); + ec_enc_icdf( psRangeEnc, LBRR_symbol - 1, silk_LBRR_flags_iCDF_ptr[ psEnc->state_Fxx[ n ].sCmn.nFramesPerPacket - 2 ], 8 ); } } /* Code LBRR indices and excitation signals */ for( i = 0; i < psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket; i++ ) { - for( n = 0; n < encControl->nChannels; n++ ) { + for( n = 0; n < encControl->nChannelsInternal; n++ ) { if( psEnc->state_Fxx[ n ].sCmn.LBRR_flags[ i ] ) { - SKP_Silk_encode_indices( &psEnc->state_Fxx[ n ].sCmn, psRangeEnc, i, 1 ); - SKP_Silk_encode_pulses( psRangeEnc, psEnc->state_Fxx[ n ].sCmn.indices_LBRR[i].signalType, psEnc->state_Fxx[ n ].sCmn.indices_LBRR[i].quantOffsetType, + if( encControl->nChannelsInternal == 2 && n == 0 ) { + silk_stereo_encode_pred( psRangeEnc, psEnc->sStereo.ix[ i ] ); + } + silk_encode_indices( &psEnc->state_Fxx[ n ].sCmn, psRangeEnc, i, 1 ); + silk_encode_pulses( psRangeEnc, psEnc->state_Fxx[ n ].sCmn.indices_LBRR[i].signalType, psEnc->state_Fxx[ n ].sCmn.indices_LBRR[i].quantOffsetType, psEnc->state_Fxx[ n ].sCmn.pulses_LBRR[ i ], psEnc->state_Fxx[ n ].sCmn.frame_length ); } } } /* Reset LBRR flags */ - for( n = 0; n < encControl->nChannels; n++ ) { + for( n = 0; n < encControl->nChannelsInternal; n++ ) { SKP_memset( psEnc->state_Fxx[ n ].sCmn.LBRR_flags, 0, sizeof( psEnc->state_Fxx[ n ].sCmn.LBRR_flags ) ); } } - /* Convert Left/Right to Mid/Side */ - if( encControl->nChannels == 2 ) { - SKP_Silk_stereo_LR_to_MS( psRangeEnc, &psEnc->sStereo, psEnc->state_Fxx[ 0 ].sCmn.inputBuf, psEnc->state_Fxx[ 1 ].sCmn.inputBuf, - psEnc->state_Fxx[ 0 ].sCmn.fs_kHz, psEnc->state_Fxx[ 0 ].sCmn.frame_length ); - } - + /* High-pass filter */ + silk_HP_variable_cutoff( psEnc->state_Fxx, psEnc->nChannelsInternal ); /* Total target bits for packet */ nBits = SKP_DIV32_16( SKP_MUL( encControl->bitRate, encControl->payloadSize_ms ), 1000 ); - /* Subtract bits already used */ - nBits -= ec_tell( psRangeEnc ); + /* Subtract half of the bits already used */ + nBits -= ec_tell( psRangeEnc ) >> 1; /* Divide by number of uncoded frames left in packet */ - nBits = SKP_DIV32_16( nBits, psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket - psEnc->state_Fxx[ 0 ].sCmn.nFramesAnalyzed ); + nBits = SKP_DIV32_16( nBits, psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket - psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded ); /* Convert to bits/second */ if( encControl->payloadSize_ms == 10 ) { TargetRate_bps = SKP_SMULBB( nBits, 100 ); @@ -307,23 +311,37 @@ SKP_int SKP_Silk_SDK_Encode( } /* Subtract fraction of bits in excess of target in previous packets */ TargetRate_bps -= SKP_DIV32_16( SKP_MUL( psEnc->nBitsExceeded, 1000 ), BITRESERVOIR_DECAY_TIME_MS ); - /* Don't exceed input bitrate */ - TargetRate_bps = SKP_min( TargetRate_bps, encControl->bitRate ); + /* Never exceed input bitrate */ + TargetRate_bps = SKP_LIMIT( TargetRate_bps, encControl->bitRate, 5000 ); + + /* Convert Left/Right to Mid/Side */ + if( encControl->nChannelsInternal == 2 ) { + silk_stereo_LR_to_MS( &psEnc->sStereo, psEnc->state_Fxx[ 0 ].sCmn.inputBuf, psEnc->state_Fxx[ 1 ].sCmn.inputBuf, + psEnc->sStereo.ix[ psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded ], MStargetRates_bps, TargetRate_bps, + psEnc->state_Fxx[ 0 ].sCmn.speech_activity_Q8, psEnc->state_Fxx[ 0 ].sCmn.fs_kHz, psEnc->state_Fxx[ 0 ].sCmn.frame_length ); + silk_stereo_encode_pred( psRangeEnc, psEnc->sStereo.ix[ psEnc->state_Fxx[ 0 ].sCmn.nFramesEncoded ] ); + } else { + /* Buffering */ + SKP_memcpy( &psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ -2 ], psEnc->sStereo.sMid, 2 * sizeof( SKP_int16 ) ); + SKP_memcpy( psEnc->sStereo.sMid, &psEnc->state_Fxx[ 0 ].sCmn.inputBuf[ psEnc->state_Fxx[ 0 ].sCmn.frame_length - 2 ], 2 * sizeof( SKP_int16 ) ); + } /* Encode */ - for( n = 0; n < encControl->nChannels; n++ ) { - /* For stereo coding, allocate 60% of the bitrate to mid and 40% to side */ - if( encControl->nChannels == 1 ) { + for( n = 0; n < encControl->nChannelsInternal; n++ ) { + if( encControl->nChannelsInternal == 1 ) { channelRate_bps = TargetRate_bps; - } else if( n == 0 ) { - channelRate_bps = SKP_RSHIFT( TargetRate_bps, 1 ) + 2000; } else { - channelRate_bps = SKP_RSHIFT( TargetRate_bps, 1 ) - 2000; + channelRate_bps = MStargetRates_bps[ n ]; } - SKP_Silk_control_SNR( &psEnc->state_Fxx[ n ].sCmn, channelRate_bps ); - if( ( ret = SKP_Silk_encode_frame_Fxx( &psEnc->state_Fxx[ n ], nBytesOut, psRangeEnc ) ) != 0 ) { - SKP_assert( 0 ); + + if( channelRate_bps > 0 ) { + silk_control_SNR( &psEnc->state_Fxx[ n ].sCmn, channelRate_bps ); + + if( ( ret = silk_encode_frame_Fxx( &psEnc->state_Fxx[ n ], nBytesOut, psRangeEnc ) ) != 0 ) { + SKP_assert( 0 ); + } } + psEnc->state_Fxx[ n ].sCmn.controlled_since_last_payload = 0; psEnc->state_Fxx[ n ].sCmn.inputBufIx = 0; } @@ -331,7 +349,7 @@ SKP_int SKP_Silk_SDK_Encode( /* Insert VAD and FEC flags at beginning of bitstream */ if( *nBytesOut > 0 ) { flags = 0; - for( n = 0; n < encControl->nChannels; n++ ) { + for( n = 0; n < encControl->nChannelsInternal; n++ ) { for( i = 0; i < psEnc->state_Fxx[ n ].sCmn.nFramesPerPacket; i++ ) { flags = SKP_LSHIFT( flags, 1 ); flags |= psEnc->state_Fxx[ n ].sCmn.VAD_flags[ i ]; @@ -339,10 +357,10 @@ SKP_int SKP_Silk_SDK_Encode( flags = SKP_LSHIFT( flags, 1 ); flags |= psEnc->state_Fxx[ n ].sCmn.LBRR_flag; } - ec_enc_patch_initial_bits( psRangeEnc, flags, ( psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket + 1 ) * encControl->nChannels ); + ec_enc_patch_initial_bits( psRangeEnc, flags, ( psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket + 1 ) * encControl->nChannelsInternal ); - /* Return zero bytes if DTXed */ - if( psEnc->state_Fxx[ 0 ].sCmn.inDTX && ( encControl->nChannels == 1 || psEnc->state_Fxx[ 1 ].sCmn.inDTX ) ) { + /* Return zero bytes if all channels DTXed */ + if( psEnc->state_Fxx[ 0 ].sCmn.inDTX && ( encControl->nChannelsInternal == 1 || psEnc->state_Fxx[ 1 ].sCmn.inDTX ) ) { *nBytesOut = 0; } @@ -351,8 +369,8 @@ SKP_int SKP_Silk_SDK_Encode( psEnc->nBitsExceeded = SKP_LIMIT( psEnc->nBitsExceeded, 0, 10000 ); /* Update flag indicating if bandwidth switching is allowed */ - speech_act_thr_for_switch_Q8 = SKP_SMLAWB( SKP_FIX_CONST( SPEECH_ACTIVITY_DTX_THRES, 8 ), - SKP_FIX_CONST( ( 1 - SPEECH_ACTIVITY_DTX_THRES ) / MAX_BANDWIDTH_SWITCH_DELAY_MS, 16 + 8 ), psEnc->timeSinceSwitchAllowed_ms ); + speech_act_thr_for_switch_Q8 = SKP_SMLAWB( SILK_FIX_CONST( SPEECH_ACTIVITY_DTX_THRES, 8 ), + SILK_FIX_CONST( ( 1 - SPEECH_ACTIVITY_DTX_THRES ) / MAX_BANDWIDTH_SWITCH_DELAY_MS, 16 + 8 ), psEnc->timeSinceSwitchAllowed_ms ); if( psEnc->state_Fxx[ 0 ].sCmn.speech_activity_Q8 < speech_act_thr_for_switch_Q8 ) { psEnc->allowBandwidthSwitch = 1; psEnc->timeSinceSwitchAllowed_ms = 0; @@ -371,12 +389,13 @@ SKP_int SKP_Silk_SDK_Encode( } encControl->allowBandwidthSwitch = psEnc->allowBandwidthSwitch; - encControl->inWBmodeWithoutVariableLP = ( psEnc->state_Fxx[ 0 ].sCmn.fs_kHz == 16 ) && ( psEnc->state_Fxx[ 0 ].sCmn.sLP.mode == 0 ); + encControl->inWBmodeWithoutVariableLP = psEnc->state_Fxx[ 0 ].sCmn.fs_kHz == 16 && psEnc->state_Fxx[ 0 ].sCmn.sLP.mode == 0; encControl->internalSampleRate = SKP_SMULBB( psEnc->state_Fxx[ 0 ].sCmn.fs_kHz, 1000 ); + encControl->stereoWidth_Q14 = psEnc->sStereo.width_prev_Q14; if( prefillFlag ) { encControl->payloadSize_ms = tmp_payloadSize_ms; encControl->complexity = tmp_complexity; - for( n = 0; n < encControl->nChannels; n++ ) { + for( n = 0; n < encControl->nChannelsInternal; n++ ) { psEnc->state_Fxx[ n ].sCmn.controlled_since_last_payload = 0; psEnc->state_Fxx[ n ].sCmn.prefillFlag = 0; } diff --git a/silk/SKP_Silk_encode_indices.c b/silk/silk_encode_indices.c similarity index 86% rename from silk/SKP_Silk_encode_indices.c rename to silk/silk_encode_indices.c index 71fc766c..39b8cbb3 100644 --- a/silk/SKP_Silk_encode_indices.c +++ b/silk/silk_encode_indices.c @@ -25,11 +25,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" +#include "silk_main.h" /* Encode side-information parameters to payload */ -void SKP_Silk_encode_indices( - SKP_Silk_encoder_state *psEncC, /* I/O Encoder state */ +void silk_encode_indices( + silk_encoder_state *psEncC, /* I/O Encoder state */ ec_enc *psRangeEnc, /* I/O Compressor data structure */ SKP_int FrameIndex, /* I Frame number */ SKP_int encode_LBRR /* I Flag indicating LBRR data is being encoded */ @@ -65,9 +65,9 @@ void SKP_Silk_encode_indices( SKP_assert( typeOffset >= 0 && typeOffset < 6 ); SKP_assert( encode_LBRR == 0 || typeOffset >= 2 ); if( encode_LBRR || typeOffset >= 2 ) { - ec_enc_icdf( psRangeEnc, typeOffset - 2, SKP_Silk_type_offset_VAD_iCDF, 8 ); + ec_enc_icdf( psRangeEnc, typeOffset - 2, silk_type_offset_VAD_iCDF, 8 ); } else { - ec_enc_icdf( psRangeEnc, typeOffset, SKP_Silk_type_offset_no_VAD_iCDF, 8 ); + ec_enc_icdf( psRangeEnc, typeOffset, silk_type_offset_no_VAD_iCDF, 8 ); } /****************/ @@ -80,18 +80,18 @@ void SKP_Silk_encode_indices( if( condCoding ) { /* conditional coding */ SKP_assert( psIndices->GainsIndices[ 0 ] >= 0 && psIndices->GainsIndices[ 0 ] < MAX_DELTA_GAIN_QUANT - MIN_DELTA_GAIN_QUANT + 1 ); - ec_enc_icdf( psRangeEnc, psIndices->GainsIndices[ 0 ], SKP_Silk_delta_gain_iCDF, 8 ); + ec_enc_icdf( psRangeEnc, psIndices->GainsIndices[ 0 ], silk_delta_gain_iCDF, 8 ); } else { /* independent coding, in two stages: MSB bits followed by 3 LSBs */ SKP_assert( psIndices->GainsIndices[ 0 ] >= 0 && psIndices->GainsIndices[ 0 ] < N_LEVELS_QGAIN ); - ec_enc_icdf( psRangeEnc, SKP_RSHIFT( psIndices->GainsIndices[ 0 ], 3 ), SKP_Silk_gain_iCDF[ psIndices->signalType ], 8 ); - ec_enc_icdf( psRangeEnc, psIndices->GainsIndices[ 0 ] & 7, SKP_Silk_uniform8_iCDF, 8 ); + ec_enc_icdf( psRangeEnc, SKP_RSHIFT( psIndices->GainsIndices[ 0 ], 3 ), silk_gain_iCDF[ psIndices->signalType ], 8 ); + ec_enc_icdf( psRangeEnc, psIndices->GainsIndices[ 0 ] & 7, silk_uniform8_iCDF, 8 ); } /* remaining subframes */ for( i = 1; i < psEncC->nb_subfr; i++ ) { SKP_assert( psIndices->GainsIndices[ i ] >= 0 && psIndices->GainsIndices[ i ] < MAX_DELTA_GAIN_QUANT - MIN_DELTA_GAIN_QUANT + 1 ); - ec_enc_icdf( psRangeEnc, psIndices->GainsIndices[ i ], SKP_Silk_delta_gain_iCDF, 8 ); + ec_enc_icdf( psRangeEnc, psIndices->GainsIndices[ i ], silk_delta_gain_iCDF, 8 ); } #ifdef SAVE_ALL_INTERNAL_DATA @@ -107,15 +107,15 @@ void SKP_Silk_encode_indices( nBytes_before = SKP_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 ); #endif ec_enc_icdf( psRangeEnc, psIndices->NLSFIndices[ 0 ], &psEncC->psNLSF_CB->CB1_iCDF[ ( psIndices->signalType >> 1 ) * psEncC->psNLSF_CB->nVectors ], 8 ); - SKP_Silk_NLSF_unpack( ec_ix, pred_Q8, psEncC->psNLSF_CB, psIndices->NLSFIndices[ 0 ] ); + silk_NLSF_unpack( ec_ix, pred_Q8, psEncC->psNLSF_CB, psIndices->NLSFIndices[ 0 ] ); SKP_assert( psEncC->psNLSF_CB->order == psEncC->predictLPCOrder ); for( i = 0; i < psEncC->psNLSF_CB->order; i++ ) { if( psIndices->NLSFIndices[ i+1 ] >= NLSF_QUANT_MAX_AMPLITUDE ) { ec_enc_icdf( psRangeEnc, 2 * NLSF_QUANT_MAX_AMPLITUDE, &psEncC->psNLSF_CB->ec_iCDF[ ec_ix[ i ] ], 8 ); - ec_enc_icdf( psRangeEnc, psIndices->NLSFIndices[ i+1 ] - NLSF_QUANT_MAX_AMPLITUDE, SKP_Silk_NLSF_EXT_iCDF, 8 ); + ec_enc_icdf( psRangeEnc, psIndices->NLSFIndices[ i+1 ] - NLSF_QUANT_MAX_AMPLITUDE, silk_NLSF_EXT_iCDF, 8 ); } else if( psIndices->NLSFIndices[ i+1 ] <= -NLSF_QUANT_MAX_AMPLITUDE ) { ec_enc_icdf( psRangeEnc, 0, &psEncC->psNLSF_CB->ec_iCDF[ ec_ix[ i ] ], 8 ); - ec_enc_icdf( psRangeEnc, -psIndices->NLSFIndices[ i+1 ] - NLSF_QUANT_MAX_AMPLITUDE, SKP_Silk_NLSF_EXT_iCDF, 8 ); + ec_enc_icdf( psRangeEnc, -psIndices->NLSFIndices[ i+1 ] - NLSF_QUANT_MAX_AMPLITUDE, silk_NLSF_EXT_iCDF, 8 ); } else { ec_enc_icdf( psRangeEnc, psIndices->NLSFIndices[ i+1 ] + NLSF_QUANT_MAX_AMPLITUDE, &psEncC->psNLSF_CB->ec_iCDF[ ec_ix[ i ] ], 8 ); } @@ -125,7 +125,7 @@ void SKP_Silk_encode_indices( if( psEncC->nb_subfr == MAX_NB_SUBFR ) { SKP_assert( psEncC->useInterpolatedNLSFs == 1 || psIndices->NLSFInterpCoef_Q2 == ( 1 << 2 ) ); SKP_assert( psIndices->NLSFInterpCoef_Q2 >= 0 && psIndices->NLSFInterpCoef_Q2 < 5 ); - ec_enc_icdf( psRangeEnc, psIndices->NLSFInterpCoef_Q2, SKP_Silk_NLSF_interpolation_factor_iCDF, 8 ); + ec_enc_icdf( psRangeEnc, psIndices->NLSFInterpCoef_Q2, silk_NLSF_interpolation_factor_iCDF, 8 ); } #ifdef SAVE_ALL_INTERNAL_DATA @@ -155,7 +155,7 @@ void SKP_Silk_encode_indices( encode_absolute_lagIndex = 0; /* Only use delta */ } SKP_assert( delta_lagIndex >= 0 && delta_lagIndex < 21 ); - ec_enc_icdf( psRangeEnc, delta_lagIndex, SKP_Silk_pitch_delta_iCDF, 8 ); + ec_enc_icdf( psRangeEnc, delta_lagIndex, silk_pitch_delta_iCDF, 8 ); } if( encode_absolute_lagIndex ) { /* Absolute encoding */ @@ -164,7 +164,7 @@ void SKP_Silk_encode_indices( pitch_low_bits = psIndices->lagIndex - SKP_SMULBB( pitch_high_bits, SKP_RSHIFT( psEncC->fs_kHz, 1 ) ); SKP_assert( pitch_low_bits < psEncC->fs_kHz / 2 ); SKP_assert( pitch_high_bits < 32 ); - ec_enc_icdf( psRangeEnc, pitch_high_bits, SKP_Silk_pitch_lag_iCDF, 8 ); + ec_enc_icdf( psRangeEnc, pitch_high_bits, silk_pitch_lag_iCDF, 8 ); ec_enc_icdf( psRangeEnc, pitch_low_bits, psEncC->pitch_lag_low_bits_iCDF, 8 ); } psEncC->ec_prevLagIndex = psIndices->lagIndex; @@ -198,12 +198,12 @@ void SKP_Silk_encode_indices( /* PERIndex value */ SKP_assert( psIndices->PERIndex >= 0 && psIndices->PERIndex < 3 ); - ec_enc_icdf( psRangeEnc, psIndices->PERIndex, SKP_Silk_LTP_per_index_iCDF, 8 ); + ec_enc_icdf( psRangeEnc, psIndices->PERIndex, silk_LTP_per_index_iCDF, 8 ); /* Codebook Indices */ for( k = 0; k < psEncC->nb_subfr; k++ ) { SKP_assert( psIndices->LTPIndex[ k ] >= 0 && psIndices->LTPIndex[ k ] < ( 8 << psIndices->PERIndex ) ); - ec_enc_icdf( psRangeEnc, psIndices->LTPIndex[ k ], SKP_Silk_LTP_gain_iCDF_ptrs[ psIndices->PERIndex ], 8 ); + ec_enc_icdf( psRangeEnc, psIndices->LTPIndex[ k ], silk_LTP_gain_iCDF_ptrs[ psIndices->PERIndex ], 8 ); } /**********************/ @@ -211,7 +211,7 @@ void SKP_Silk_encode_indices( /**********************/ if( !condCoding ) { SKP_assert( psIndices->LTP_scaleIndex >= 0 && psIndices->LTP_scaleIndex < 3 ); - ec_enc_icdf( psRangeEnc, psIndices->LTP_scaleIndex, SKP_Silk_LTPscale_iCDF, 8 ); + ec_enc_icdf( psRangeEnc, psIndices->LTP_scaleIndex, silk_LTPscale_iCDF, 8 ); } SKP_assert( !condCoding || psIndices->LTP_scaleIndex == 0 ); @@ -242,5 +242,5 @@ void SKP_Silk_encode_indices( /* Encode seed */ /***************/ SKP_assert( psIndices->Seed >= 0 && psIndices->Seed < 4 ); - ec_enc_icdf( psRangeEnc, psIndices->Seed, SKP_Silk_uniform4_iCDF, 8 ); + ec_enc_icdf( psRangeEnc, psIndices->Seed, silk_uniform4_iCDF, 8 ); } diff --git a/silk/SKP_Silk_encode_pulses.c b/silk/silk_encode_pulses.c similarity index 84% rename from silk/SKP_Silk_encode_pulses.c rename to silk/silk_encode_pulses.c index 6fff9b95..16968319 100644 --- a/silk/SKP_Silk_encode_pulses.c +++ b/silk/silk_encode_pulses.c @@ -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. ***********************************************************************/ -#include "SKP_Silk_main.h" +#include "silk_main.h" /*********************************************/ /* Encode quantization indices of excitation */ @@ -52,7 +52,7 @@ SKP_INLINE SKP_int combine_and_check( /* return ok */ } /* Encode quantization indices of excitation */ -void SKP_Silk_encode_pulses( +void silk_encode_pulses( ec_enc *psRangeEnc, /* I/O compressor data structure */ const SKP_int signalType, /* I Sigtype */ const SKP_int quantOffsetType, /* I quantOffsetType */ @@ -100,13 +100,13 @@ void SKP_Silk_encode_pulses( while( 1 ) { /* 1+1 -> 2 */ - scale_down = combine_and_check( pulses_comb, abs_pulses_ptr, SKP_Silk_max_pulses_table[ 0 ], 8 ); + scale_down = combine_and_check( pulses_comb, abs_pulses_ptr, silk_max_pulses_table[ 0 ], 8 ); /* 2+2 -> 4 */ - scale_down += combine_and_check( pulses_comb, pulses_comb, SKP_Silk_max_pulses_table[ 1 ], 4 ); + scale_down += combine_and_check( pulses_comb, pulses_comb, silk_max_pulses_table[ 1 ], 4 ); /* 4+4 -> 8 */ - scale_down += combine_and_check( pulses_comb, pulses_comb, SKP_Silk_max_pulses_table[ 2 ], 2 ); + scale_down += combine_and_check( pulses_comb, pulses_comb, silk_max_pulses_table[ 2 ], 2 ); /* 8+8 -> 16 */ - scale_down += combine_and_check( &sum_pulses[ i ], pulses_comb, SKP_Silk_max_pulses_table[ 3 ], 1 ); + scale_down += combine_and_check( &sum_pulses[ i ], pulses_comb, silk_max_pulses_table[ 3 ], 1 ); if( scale_down ) { /* We need to downscale the quantization signal */ @@ -128,8 +128,8 @@ void SKP_Silk_encode_pulses( /* find rate level that leads to fewest bits for coding of pulses per block info */ minSumBits_Q5 = SKP_int32_MAX; for( k = 0; k < N_RATE_LEVELS - 1; k++ ) { - nBits_ptr = SKP_Silk_pulses_per_block_BITS_Q5[ k ]; - sumBits_Q5 = SKP_Silk_rate_levels_BITS_Q5[ signalType >> 1 ][ k ]; + nBits_ptr = silk_pulses_per_block_BITS_Q5[ k ]; + sumBits_Q5 = silk_rate_levels_BITS_Q5[ signalType >> 1 ][ k ]; for( i = 0; i < iter; i++ ) { if( nRshifts[ i ] > 0 ) { sumBits_Q5 += nBits_ptr[ MAX_PULSES + 1 ]; @@ -142,21 +142,21 @@ void SKP_Silk_encode_pulses( RateLevelIndex = k; } } - ec_enc_icdf( psRangeEnc, RateLevelIndex, SKP_Silk_rate_levels_iCDF[ signalType >> 1 ], 8 ); + ec_enc_icdf( psRangeEnc, RateLevelIndex, silk_rate_levels_iCDF[ signalType >> 1 ], 8 ); /***************************************************/ /* Sum-Weighted-Pulses Encoding */ /***************************************************/ - cdf_ptr = SKP_Silk_pulses_per_block_iCDF[ RateLevelIndex ]; + cdf_ptr = silk_pulses_per_block_iCDF[ RateLevelIndex ]; for( i = 0; i < iter; i++ ) { if( nRshifts[ i ] == 0 ) { ec_enc_icdf( psRangeEnc, sum_pulses[ i ], cdf_ptr, 8 ); } else { ec_enc_icdf( psRangeEnc, MAX_PULSES + 1, cdf_ptr, 8 ); for( k = 0; k < nRshifts[ i ] - 1; k++ ) { - ec_enc_icdf( psRangeEnc, MAX_PULSES + 1, SKP_Silk_pulses_per_block_iCDF[ N_RATE_LEVELS - 1 ], 8 ); + ec_enc_icdf( psRangeEnc, MAX_PULSES + 1, silk_pulses_per_block_iCDF[ N_RATE_LEVELS - 1 ], 8 ); } - ec_enc_icdf( psRangeEnc, sum_pulses[ i ], SKP_Silk_pulses_per_block_iCDF[ N_RATE_LEVELS - 1 ], 8 ); + ec_enc_icdf( psRangeEnc, sum_pulses[ i ], silk_pulses_per_block_iCDF[ N_RATE_LEVELS - 1 ], 8 ); } } @@ -165,7 +165,7 @@ void SKP_Silk_encode_pulses( /******************/ for( i = 0; i < iter; i++ ) { if( sum_pulses[ i ] > 0 ) { - SKP_Silk_shell_encoder( psRangeEnc, &abs_pulses[ i * SHELL_CODEC_FRAME_LENGTH ] ); + silk_shell_encoder( psRangeEnc, &abs_pulses[ i * SHELL_CODEC_FRAME_LENGTH ] ); } } @@ -180,18 +180,16 @@ void SKP_Silk_encode_pulses( abs_q = (SKP_int8)SKP_abs( pulses_ptr[ k ] ); for( j = nLS; j > 0; j-- ) { bit = SKP_RSHIFT( abs_q, j ) & 1; - ec_enc_icdf( psRangeEnc, bit, SKP_Silk_lsb_iCDF, 8 ); + ec_enc_icdf( psRangeEnc, bit, silk_lsb_iCDF, 8 ); } bit = abs_q & 1; - ec_enc_icdf( psRangeEnc, bit, SKP_Silk_lsb_iCDF, 8 ); + ec_enc_icdf( psRangeEnc, bit, silk_lsb_iCDF, 8 ); } } } -#if! USE_CELT_PVQ /****************/ /* Encode signs */ /****************/ - SKP_Silk_encode_signs( psRangeEnc, pulses, frame_length, signalType, quantOffsetType, sum_pulses ); -#endif + silk_encode_signs( psRangeEnc, pulses, frame_length, signalType, quantOffsetType, sum_pulses ); } diff --git a/silk/SKP_Silk_errors.h b/silk/silk_errors.h similarity index 71% rename from silk/SKP_Silk_errors.h rename to silk/silk_errors.h index b7f194fa..f27dcc7f 100644 --- a/silk/SKP_Silk_errors.h +++ b/silk/silk_errors.h @@ -25,8 +25,8 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#ifndef SKP_SILK_ERRORS_H -#define SKP_SILK_ERRORS_H +#ifndef SILK_ERRORS_H +#define SILK_ERRORS_H #ifdef __cplusplus extern "C" @@ -36,60 +36,60 @@ extern "C" /******************/ /* Error messages */ /******************/ -#define SKP_SILK_NO_ERROR 0 +#define SILK_NO_ERROR 0 /**************************/ /* Encoder error messages */ /**************************/ /* Input length is not a multiple of 10 ms, or length is longer than the packet length */ -#define SKP_SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES -101 +#define SILK_ENC_INPUT_INVALID_NO_OF_SAMPLES -101 /* Sampling frequency not 8000, 12000 or 16000 Hertz */ -#define SKP_SILK_ENC_FS_NOT_SUPPORTED -102 +#define SILK_ENC_FS_NOT_SUPPORTED -102 /* Packet size not 10, 20, 40, or 60 ms */ -#define SKP_SILK_ENC_PACKET_SIZE_NOT_SUPPORTED -103 +#define SILK_ENC_PACKET_SIZE_NOT_SUPPORTED -103 /* Allocated payload buffer too short */ -#define SKP_SILK_ENC_PAYLOAD_BUF_TOO_SHORT -104 +#define SILK_ENC_PAYLOAD_BUF_TOO_SHORT -104 /* Loss rate not between 0 and 100 percent */ -#define SKP_SILK_ENC_INVALID_LOSS_RATE -105 +#define SILK_ENC_INVALID_LOSS_RATE -105 /* Complexity setting not valid, use 0...10 */ -#define SKP_SILK_ENC_INVALID_COMPLEXITY_SETTING -106 +#define SILK_ENC_INVALID_COMPLEXITY_SETTING -106 /* Inband FEC setting not valid, use 0 or 1 */ -#define SKP_SILK_ENC_INVALID_INBAND_FEC_SETTING -107 +#define SILK_ENC_INVALID_INBAND_FEC_SETTING -107 /* DTX setting not valid, use 0 or 1 */ -#define SKP_SILK_ENC_INVALID_DTX_SETTING -108 +#define SILK_ENC_INVALID_DTX_SETTING -108 /* CBR setting not valid, use 0 or 1 */ -#define SKP_SILK_ENC_INVALID_CBR_SETTING -109 +#define SILK_ENC_INVALID_CBR_SETTING -109 /* Internal encoder error */ -#define SKP_SILK_ENC_INTERNAL_ERROR -110 +#define SILK_ENC_INTERNAL_ERROR -110 /* Internal encoder error */ -#define SKP_SILK_ENC_INVALID_NUMBER_OF_CHANNELS_ERROR -111 +#define SILK_ENC_INVALID_NUMBER_OF_CHANNELS_ERROR -111 /**************************/ /* Decoder error messages */ /**************************/ /* Output sampling frequency lower than internal decoded sampling frequency */ -#define SKP_SILK_DEC_INVALID_SAMPLING_FREQUENCY -200 +#define SILK_DEC_INVALID_SAMPLING_FREQUENCY -200 /* Payload size exceeded the maximum allowed 1024 bytes */ -#define SKP_SILK_DEC_PAYLOAD_TOO_LARGE -201 +#define SILK_DEC_PAYLOAD_TOO_LARGE -201 /* Payload has bit errors */ -#define SKP_SILK_DEC_PAYLOAD_ERROR -202 +#define SILK_DEC_PAYLOAD_ERROR -202 /* Payload has bit errors */ -#define SKP_SILK_DEC_INVALID_FRAME_SIZE -203 +#define SILK_DEC_INVALID_FRAME_SIZE -203 #ifdef __cplusplus } diff --git a/silk/SKP_Silk_gain_quant.c b/silk/silk_gain_quant.c similarity index 90% rename from silk/SKP_Silk_gain_quant.c rename to silk/silk_gain_quant.c index 101ecbd6..0ce7dbde 100644 --- a/silk/SKP_Silk_gain_quant.c +++ b/silk/silk_gain_quant.c @@ -25,14 +25,14 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" +#include "silk_main.h" #define OFFSET ( ( MIN_QGAIN_DB * 128 ) / 6 + 16 * 128 ) #define SCALE_Q16 ( ( 65536 * ( N_LEVELS_QGAIN - 1 ) ) / ( ( ( MAX_QGAIN_DB - MIN_QGAIN_DB ) * 128 ) / 6 ) ) #define INV_SCALE_Q16 ( ( 65536 * ( ( ( MAX_QGAIN_DB - MIN_QGAIN_DB ) * 128 ) / 6 ) ) / ( N_LEVELS_QGAIN - 1 ) ) /* Gain scalar quantization with hysteresis, uniform on log scale */ -void SKP_Silk_gains_quant( +void silk_gains_quant( SKP_int8 ind[ MAX_NB_SUBFR ], /* O gain indices */ SKP_int32 gain_Q16[ MAX_NB_SUBFR ], /* I/O gains (quantized out) */ SKP_int8 *prev_ind, /* I/O last index in previous frame */ @@ -44,7 +44,7 @@ void SKP_Silk_gains_quant( for( k = 0; k < nb_subfr; k++ ) { /* Add half of previous quantization error, convert to log scale, scale, floor() */ - ind[ k ] = SKP_SMULWB( SCALE_Q16, SKP_Silk_lin2log( gain_Q16[ k ] ) - OFFSET ); + ind[ k ] = SKP_SMULWB( SCALE_Q16, silk_lin2log( gain_Q16[ k ] ) - OFFSET ); /* Round towards previous quantized gain (hysteresis) */ if( ind[ k ] < *prev_ind ) { @@ -81,12 +81,12 @@ void SKP_Silk_gains_quant( } /* Convert to linear scale and scale */ - gain_Q16[ k ] = SKP_Silk_log2lin( SKP_min_32( SKP_SMULWB( INV_SCALE_Q16, *prev_ind ) + OFFSET, 3967 ) ); /* 3967 = 31 in Q7 */ + gain_Q16[ k ] = silk_log2lin( SKP_min_32( SKP_SMULWB( INV_SCALE_Q16, *prev_ind ) + OFFSET, 3967 ) ); /* 3967 = 31 in Q7 */ } } /* Gains scalar dequantization, uniform on log scale */ -void SKP_Silk_gains_dequant( +void silk_gains_dequant( SKP_int32 gain_Q16[ MAX_NB_SUBFR ], /* O quantized gains */ const SKP_int8 ind[ MAX_NB_SUBFR ], /* I gain indices */ SKP_int8 *prev_ind, /* I/O last index in previous frame */ @@ -111,8 +111,9 @@ void SKP_Silk_gains_dequant( *prev_ind += ind_tmp; } } + *prev_ind = SKP_min( *prev_ind, N_LEVELS_QGAIN - 1 ); /* Convert to linear scale and scale */ - gain_Q16[ k ] = SKP_Silk_log2lin( SKP_min_32( SKP_SMULWB( INV_SCALE_Q16, *prev_ind ) + OFFSET, 3967 ) ); /* 3967 = 31 in Q7 */ + gain_Q16[ k ] = silk_log2lin( SKP_min_32( SKP_SMULWB( INV_SCALE_Q16, *prev_ind ) + OFFSET, 3967 ) ); /* 3967 = 31 in Q7 */ } } diff --git a/silk/SKP_Silk_init_encoder.c b/silk/silk_init_encoder.c similarity index 75% rename from silk/SKP_Silk_init_encoder.c rename to silk/silk_init_encoder.c index c0c40458..7ef5867d 100644 --- a/silk/SKP_Silk_init_encoder.c +++ b/silk/silk_init_encoder.c @@ -25,37 +25,34 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #ifdef FIXED_POINT -#include "SKP_Silk_main_FIX.h" -#define SKP_Silk_encoder_state_Fxx SKP_Silk_encoder_state_FIX +#include "silk_main_FIX.h" #else -#include "SKP_Silk_main_FLP.h" -#define SKP_Silk_encoder_state_Fxx SKP_Silk_encoder_state_FLP +#include "silk_main_FLP.h" #endif +#include "silk_tuning_parameters.h" /*********************************/ /* Initialize Silk Encoder state */ /*********************************/ -SKP_int SKP_Silk_init_encoder( - SKP_Silk_encoder_state_Fxx *psEnc /* I/O Pointer to Silk encoder state */ +SKP_int silk_init_encoder( + silk_encoder_state_Fxx *psEnc /* I/O Pointer to Silk encoder state */ ) { SKP_int ret = 0; /* Clear the entire encoder state */ - SKP_memset( psEnc, 0, sizeof( SKP_Silk_encoder_state_Fxx ) ); + SKP_memset( psEnc, 0, sizeof( silk_encoder_state_Fxx ) ); - psEnc->sCmn.variable_HP_smth1_Q15 = 200844; /* = SKP_Silk_log2(70)_Q0; */ - psEnc->sCmn.variable_HP_smth2_Q15 = 200844; /* = SKP_Silk_log2(70)_Q0; */ + psEnc->sCmn.inputBuf = &psEnc->sCmn.inputBuf__[ 2 ]; + + psEnc->sCmn.variable_HP_smth1_Q15 = SKP_LSHIFT( silk_lin2log( SILK_FIX_CONST( VARIABLE_HP_MIN_CUTOFF_HZ, 16 ) ) - ( 16 << 7 ), 8 ); + psEnc->sCmn.variable_HP_smth2_Q15 = psEnc->sCmn.variable_HP_smth1_Q15; /* Used to deactivate LSF interpolation, fluctuation reduction, pitch prediction */ psEnc->sCmn.first_frame_after_reset = 1; /* Initialize Silk VAD */ - ret += SKP_Silk_VAD_Init( &psEnc->sCmn.sVAD ); + ret += silk_VAD_Init( &psEnc->sCmn.sVAD ); return( ret ); } diff --git a/silk/SKP_Silk_inner_prod_aligned.c b/silk/silk_inner_prod_aligned.c similarity index 93% rename from silk/SKP_Silk_inner_prod_aligned.c rename to silk/silk_inner_prod_aligned.c index cc0364fe..34988e87 100644 --- a/silk/SKP_Silk_inner_prod_aligned.c +++ b/silk/silk_inner_prod_aligned.c @@ -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. ***********************************************************************/ -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_SigProc_FIX.h" /* sum= for(i=0;i6, memory access can be reduced by half. */ -SKP_int32 SKP_Silk_inner_prod_aligned( +SKP_int32 silk_inner_prod_aligned( const SKP_int16 *const inVec1, /* I input vector 1 */ const SKP_int16 *const inVec2, /* I input vector 2 */ const SKP_int len /* I vector lengths */ @@ -47,7 +47,7 @@ SKP_int32 SKP_Silk_inner_prod_aligned( return sum; } -SKP_int32 SKP_Silk_inner_prod_aligned_scale( +SKP_int32 silk_inner_prod_aligned_scale( const SKP_int16 *const inVec1, /* I input vector 1 */ const SKP_int16 *const inVec2, /* I input vector 2 */ const SKP_int scale, /* I number of bits to shift */ @@ -62,7 +62,7 @@ SKP_int32 SKP_Silk_inner_prod_aligned_scale( return sum; } -SKP_int64 SKP_Silk_inner_prod16_aligned_64( +SKP_int64 silk_inner_prod16_aligned_64( const SKP_int16 *inVec1, /* I input vector 1 */ const SKP_int16 *inVec2, /* I input vector 2 */ const SKP_int len /* I vector lengths */ diff --git a/silk/SKP_Silk_interpolate.c b/silk/silk_interpolate.c similarity index 96% rename from silk/SKP_Silk_interpolate.c rename to silk/silk_interpolate.c index aee9eff0..ba510cfe 100644 --- a/silk/SKP_Silk_interpolate.c +++ b/silk/silk_interpolate.c @@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" +#include "silk_main.h" /* Interpolate two vectors */ -void SKP_Silk_interpolate( +void silk_interpolate( SKP_int16 xi[ MAX_LPC_ORDER ], /* O interpolated vector */ const SKP_int16 x0[ MAX_LPC_ORDER ], /* I first vector */ const SKP_int16 x1[ MAX_LPC_ORDER ], /* I second vector */ diff --git a/silk/SKP_Silk_k2a.c b/silk/silk_k2a.c similarity index 94% rename from silk/SKP_Silk_k2a.c rename to silk/silk_k2a.c index b639ba31..c6989f2c 100644 --- a/silk/SKP_Silk_k2a.c +++ b/silk/silk_k2a.c @@ -25,17 +25,17 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_SigProc_FIX.h" /* Step up function, converts reflection coefficients to prediction coefficients */ -void SKP_Silk_k2a( +void silk_k2a( SKP_int32 *A_Q24, /* O: Prediction coefficients [order] Q24 */ const SKP_int16 *rc_Q15, /* I: Reflection coefficients [order] Q15 */ const SKP_int32 order /* I: Prediction order */ ) { SKP_int k, n; - SKP_int32 Atmp[ SKP_Silk_MAX_ORDER_LPC ]; + SKP_int32 Atmp[ SILK_MAX_ORDER_LPC ]; for( k = 0; k < order; k++ ) { for( n = 0; n < k; n++ ) { diff --git a/silk/SKP_Silk_k2a_Q16.c b/silk/silk_k2a_Q16.c similarity index 94% rename from silk/SKP_Silk_k2a_Q16.c rename to silk/silk_k2a_Q16.c index 73ae6f07..f2cde25c 100644 --- a/silk/SKP_Silk_k2a_Q16.c +++ b/silk/silk_k2a_Q16.c @@ -25,17 +25,17 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_SigProc_FIX.h" /* Step up function, converts reflection coefficients to prediction coefficients */ -void SKP_Silk_k2a_Q16( +void silk_k2a_Q16( SKP_int32 *A_Q24, /* O: Prediction coefficients [order] Q24 */ const SKP_int32 *rc_Q16, /* I: Reflection coefficients [order] Q16 */ const SKP_int32 order /* I: Prediction order */ ) { SKP_int k, n; - SKP_int32 Atmp[ SKP_Silk_MAX_ORDER_LPC ]; + SKP_int32 Atmp[ SILK_MAX_ORDER_LPC ]; for( k = 0; k < order; k++ ) { for( n = 0; n < k; n++ ) { diff --git a/silk/SKP_Silk_lin2log.c b/silk/silk_lin2log.c similarity index 90% rename from silk/SKP_Silk_lin2log.c rename to silk/silk_lin2log.c index c6241c53..ddee11c0 100644 --- a/silk/SKP_Silk_lin2log.c +++ b/silk/silk_lin2log.c @@ -25,14 +25,14 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_SigProc_FIX.h" /* Approximation of 128 * log2() (very close inverse of approx 2^() below) */ /* Convert input to a log scale */ -SKP_int32 SKP_Silk_lin2log( const SKP_int32 inLin ) /* I: Input in linear scale */ +SKP_int32 silk_lin2log( const SKP_int32 inLin ) /* I: Input in linear scale */ { SKP_int32 lz, frac_Q7; - SKP_Silk_CLZ_FRAC( inLin, &lz, &frac_Q7 ); + silk_CLZ_FRAC( inLin, &lz, &frac_Q7 ); /* Piece-wise parabolic approximation */ return( SKP_LSHIFT( 31 - lz, 7 ) + SKP_SMLAWB( frac_Q7, SKP_MUL( frac_Q7, 128 - frac_Q7 ), 179 ) ); diff --git a/silk/SKP_Silk_log2lin.c b/silk/silk_log2lin.c similarity index 90% rename from silk/SKP_Silk_log2lin.c rename to silk/silk_log2lin.c index 50d02d8b..f6be92eb 100644 --- a/silk/SKP_Silk_log2lin.c +++ b/silk/silk_log2lin.c @@ -25,11 +25,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_SigProc_FIX.h" -/* Approximation of 2^() (very close inverse of SKP_Silk_lin2log()) */ +/* Approximation of 2^() (very close inverse of silk_lin2log()) */ /* Convert input to a linear scale */ -SKP_int32 SKP_Silk_log2lin( const SKP_int32 inLog_Q7 ) /* I: Input on log scale */ +SKP_int32 silk_log2lin( const SKP_int32 inLog_Q7 ) /* I: Input on log scale */ { SKP_int32 out, frac_Q7; diff --git a/silk/SKP_Silk_macros.h b/silk/silk_macros.h similarity index 93% rename from silk/SKP_Silk_macros.h rename to silk/silk_macros.h index 406781ed..ec022531 100644 --- a/silk/SKP_Silk_macros.h +++ b/silk/silk_macros.h @@ -25,8 +25,8 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#ifndef _SKP_SILK_API_C_H_ -#define _SKP_SILK_API_C_H_ +#ifndef _SILK_API_C_H_ +#define _SILK_API_C_H_ // This is an inline header file for general platform. @@ -72,7 +72,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (( (a) & ((b)^0x80000000) & 0x80000000) ? SKP_int32_MIN : (a)-(b)) : \ ((((a)^0x80000000) & (b) & 0x80000000) ? SKP_int32_MAX : (a)-(b)) ) -SKP_INLINE SKP_int32 SKP_Silk_CLZ16(SKP_int16 in16) +SKP_INLINE SKP_int32 silk_CLZ16(SKP_int16 in16) { SKP_int32 out32 = 0; if( in16 == 0 ) { @@ -108,13 +108,13 @@ SKP_INLINE SKP_int32 SKP_Silk_CLZ16(SKP_int16 in16) } } -SKP_INLINE SKP_int32 SKP_Silk_CLZ32(SKP_int32 in32) +SKP_INLINE SKP_int32 silk_CLZ32(SKP_int32 in32) { /* test highest 16 bits and convert to SKP_int16 */ if( in32 & 0xFFFF0000 ) { - return SKP_Silk_CLZ16((SKP_int16)(in32 >> 16)); + return silk_CLZ16((SKP_int16)(in32 >> 16)); } else { - return SKP_Silk_CLZ16((SKP_int16)in32) + 16; + return silk_CLZ16((SKP_int16)in32) + 16; } } @@ -128,5 +128,5 @@ SKP_INLINE SKP_int32 SKP_Silk_CLZ32(SKP_int32 in32) #endif #define matrix_c_adr(Matrix_base_adr, row, column, M) (Matrix_base_adr + ((row)+(M)*(column))) -#endif //_SKP_SILK_API_C_H_ +#endif //_SILK_API_C_H_ diff --git a/silk/SKP_Silk_main.h b/silk/silk_main.h similarity index 79% rename from silk/SKP_Silk_main.h rename to silk/silk_main.h index f80cc805..582fede3 100644 --- a/silk/SKP_Silk_main.h +++ b/silk/silk_main.h @@ -25,21 +25,21 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#ifndef SKP_SILK_MAIN_H -#define SKP_SILK_MAIN_H +#ifndef SILK_MAIN_H +#define SILK_MAIN_H #ifdef __cplusplus extern "C" { #endif -#include "SKP_Silk_SigProc_FIX.h" -#include "SKP_Silk_define.h" -#include "SKP_Silk_structs.h" -#include "SKP_Silk_tables.h" -#include "SKP_Silk_PLC.h" -#include "SKP_Silk_control.h" -#include "SKP_debug.h" +#include "silk_SigProc_FIX.h" +#include "silk_define.h" +#include "silk_structs.h" +#include "silk_tables.h" +#include "silk_PLC.h" +#include "silk_control.h" +#include "silk_debug.h" #include "entenc.h" #include "entdec.h" @@ -51,18 +51,21 @@ extern "C" /* Convert Left/Right stereo signal to adaptive Mid/Side representation */ -void SKP_Silk_stereo_LR_to_MS( - ec_enc *psRangeEnc, /* I/O Compressor data structure */ - stereo_state *state, /* I/O State */ +void silk_stereo_LR_to_MS( + stereo_enc_state *state, /* I/O State */ SKP_int16 x1[], /* I/O Left input signal, becomes mid signal */ SKP_int16 x2[], /* I/O Right input signal, becomes side signal */ - SKP_int fs_kHz, /* I Samples rate (kHz) */ + SKP_int8 ix[ 2 ][ 4 ], /* O Quantization indices */ + SKP_int32 mid_side_rates_bps[], /* O Bitrates for mid and side signals */ + SKP_int32 total_rate_bps, /* I Total bitrate */ + SKP_int prev_speech_act_Q8, /* I Speech activity level in previous frame */ + SKP_int fs_kHz, /* I Sample rate (kHz) */ SKP_int frame_length /* I Number of samples */ ); /* Convert adaptive Mid/Side representation to Left/Right stereo signal */ -void SKP_Silk_stereo_MS_to_LR( - stereo_state *state, /* I/O State */ +void silk_stereo_MS_to_LR( + stereo_dec_state *state, /* I/O State */ SKP_int16 x1[], /* I/O Left input signal, becomes mid signal */ SKP_int16 x2[], /* I/O Right input signal, becomes side signal */ const SKP_int32 pred_Q13[], /* I Predictors */ @@ -71,26 +74,37 @@ void SKP_Silk_stereo_MS_to_LR( ); /* Find least-squares prediction gain for one signal based on another and quantize it */ -SKP_int32 SKP_Silk_stereo_find_predictor( /* O Returns predictor in Q13 */ +SKP_int32 silk_stereo_find_predictor( /* O Returns predictor in Q13 */ + SKP_int32 *ratio_Q14, /* O Ratio of residual and mid energies */ const SKP_int16 x[], /* I Basis signal */ const SKP_int16 y[], /* I Target signal */ - SKP_int length /* I Number of samples */ + SKP_int32 mid_res_amp_Q0[], /* I/O Smoothed mid, residual norms */ + SKP_int length, /* I Number of samples */ + SKP_int smooth_coef_Q16 /* I Smoothing coefficient */ ); -/* Quantize mid/side predictors and entropy code the quantization indices */ -void SKP_Silk_stereo_encode_pred( +/* Quantize mid/side predictors */ +void silk_stereo_quant_pred( + stereo_enc_state *state, /* I/O State */ + SKP_int32 pred_Q13[], /* I/O Predictors (out: quantized) */ + SKP_int8 ix[ 2 ][ 4 ] /* O Quantization indices */ +); + +/* Entropy code the mid/side quantization indices */ +void silk_stereo_encode_pred( ec_enc *psRangeEnc, /* I/O Compressor data structure */ - SKP_int32 pred_Q13[] /* I/O Predictors (out: quantized) */ + SKP_int8 ix[ 2 ][ 4 ] /* I Quantization indices */ ); /* Decode mid/side predictors */ -void SKP_Silk_stereo_decode_pred( +void silk_stereo_decode_pred( ec_dec *psRangeDec, /* I/O Compressor data structure */ + SKP_int *decode_only_mid, /* O Flag that only mid channel has been coded */ SKP_int32 pred_Q13[] /* O Predictors */ ); /* Encodes signs of excitation */ -void SKP_Silk_encode_signs( +void silk_encode_signs( ec_enc *psRangeEnc, /* I/O Compressor data structure */ const SKP_int8 pulses[], /* I pulse signal */ SKP_int length, /* I length of input */ @@ -100,7 +114,7 @@ void SKP_Silk_encode_signs( ); /* Decodes signs of excitation */ -void SKP_Silk_decode_signs( +void silk_decode_signs( ec_dec *psRangeDec, /* I/O Compressor data structure */ SKP_int pulses[], /* I/O pulse signal */ SKP_int length, /* I length of input */ @@ -111,17 +125,17 @@ void SKP_Silk_decode_signs( /* Check encoder control struct */ SKP_int check_control_input( - SKP_SILK_SDK_EncControlStruct *encControl /* I: Control structure */ + silk_EncControlStruct *encControl /* I: Control structure */ ); /* Control internal sampling rate */ -SKP_int SKP_Silk_control_audio_bandwidth( - SKP_Silk_encoder_state *psEncC /* I/O Pointer to Silk encoder state */ +SKP_int silk_control_audio_bandwidth( + silk_encoder_state *psEncC /* I/O Pointer to Silk encoder state */ ); /* Control SNR of redidual quantizer */ -SKP_int SKP_Silk_control_SNR( - SKP_Silk_encoder_state *psEncC, /* I/O Pointer to Silk encoder state */ +SKP_int silk_control_SNR( + silk_encoder_state *psEncC, /* I/O Pointer to Silk encoder state */ SKP_int32 TargetRate_bps /* I Target max bitrate (bps) */ ); @@ -130,7 +144,7 @@ SKP_int SKP_Silk_control_SNR( /***************/ /* Encode quantization indices of excitation */ -void SKP_Silk_encode_pulses( +void silk_encode_pulses( ec_enc *psRangeEnc, /* I/O compressor data structure */ const SKP_int signalType, /* I Signal type */ const SKP_int quantOffsetType, /* I quantOffsetType */ @@ -139,20 +153,20 @@ void SKP_Silk_encode_pulses( ); /* Shell encoder, operates on one shell code frame of 16 pulses */ -void SKP_Silk_shell_encoder( +void silk_shell_encoder( ec_enc *psRangeEnc, /* I/O compressor data structure */ const SKP_int *pulses0 /* I data: nonnegative pulse amplitudes */ ); /* Shell decoder, operates on one shell code frame of 16 pulses */ -void SKP_Silk_shell_decoder( +void silk_shell_decoder( SKP_int *pulses0, /* O data: nonnegative pulse amplitudes */ ec_dec *psRangeDec, /* I/O Compressor data structure */ const SKP_int pulses4 /* I number of pulses per pulse-subframe */ ); /* Gain scalar quantization with hysteresis, uniform on log scale */ -void SKP_Silk_gains_quant( +void silk_gains_quant( SKP_int8 ind[ MAX_NB_SUBFR ], /* O gain indices */ SKP_int32 gain_Q16[ MAX_NB_SUBFR ], /* I/O gains (quantized out) */ SKP_int8 *prev_ind, /* I/O last index in previous frame */ @@ -161,7 +175,7 @@ void SKP_Silk_gains_quant( ); /* Gains scalar dequantization, uniform on log scale */ -void SKP_Silk_gains_dequant( +void silk_gains_dequant( SKP_int32 gain_Q16[ MAX_NB_SUBFR ], /* O quantized gains */ const SKP_int8 ind[ MAX_NB_SUBFR ], /* I gain indices */ SKP_int8 *prev_ind, /* I/O last index in previous frame */ @@ -170,14 +184,14 @@ void SKP_Silk_gains_dequant( ); /* Convert NLSF parameters to stable AR prediction filter coefficients */ -void SKP_Silk_NLSF2A_stable( - SKP_int16 pAR_Q12[ MAX_LPC_ORDER ], /* O Stabilized AR coefs [LPC_order] */ - const SKP_int16 pNLSF[ MAX_LPC_ORDER ], /* I NLSF vector [LPC_order] */ - const SKP_int LPC_order /* I LPC/LSF order */ +void silk_NLSF2A_stable( + SKP_int16 pAR_Q12[ MAX_LPC_ORDER ], /* O Stabilized AR coefs [LPC_order] */ + const SKP_int16 pNLSF[ MAX_LPC_ORDER ], /* I NLSF vector [LPC_order] */ + const SKP_int LPC_order /* I LPC/LSF order */ ); /* Interpolate two vectors */ -void SKP_Silk_interpolate( +void silk_interpolate( SKP_int16 xi[ MAX_LPC_ORDER ], /* O interpolated vector */ const SKP_int16 x0[ MAX_LPC_ORDER ], /* I first vector */ const SKP_int16 x1[ MAX_LPC_ORDER ], /* I second vector */ @@ -186,7 +200,7 @@ void SKP_Silk_interpolate( ); /* LTP tap quantizer */ -void SKP_Silk_quant_LTP_gains( +void silk_quant_LTP_gains( SKP_int16 B_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* I/O (un)quantized LTP gains */ SKP_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook Index */ SKP_int8 *periodicity_index, /* O Periodicity Index */ @@ -197,7 +211,7 @@ void SKP_Silk_quant_LTP_gains( ); /* Entropy constrained matrix-weighted VQ, for a single input data vector */ -void SKP_Silk_VQ_WMat_EC( +void silk_VQ_WMat_EC( SKP_int8 *ind, /* O index of best codebook vector */ SKP_int32 *rate_dist_Q14, /* O best weighted quantization error + mu * rate*/ const SKP_int16 *in_Q14, /* I input vector to be quantized */ @@ -211,9 +225,9 @@ void SKP_Silk_VQ_WMat_EC( /***********************************/ /* Noise shaping quantization (NSQ)*/ /***********************************/ -void SKP_Silk_NSQ( - const SKP_Silk_encoder_state *psEncC, /* I/O Encoder State */ - SKP_Silk_nsq_state *NSQ, /* I/O NSQ state */ +void silk_NSQ( + const silk_encoder_state *psEncC, /* I/O Encoder State */ + silk_nsq_state *NSQ, /* I/O NSQ state */ SideInfoIndices *psIndices, /* I/O Quantization Indices */ const SKP_int16 x[], /* I prefiltered input signal */ SKP_int8 pulses[], /* O quantized qulse signal */ @@ -230,9 +244,9 @@ void SKP_Silk_NSQ( ); /* Noise shaping using delayed decision */ -void SKP_Silk_NSQ_del_dec( - const SKP_Silk_encoder_state *psEncC, /* I/O Encoder State */ - SKP_Silk_nsq_state *NSQ, /* I/O NSQ state */ +void silk_NSQ_del_dec( + const silk_encoder_state *psEncC, /* I/O Encoder State */ + silk_nsq_state *NSQ, /* I/O NSQ state */ SideInfoIndices *psIndices, /* I/O Quantization Indices */ const SKP_int16 x[], /* I Prefiltered input signal */ SKP_int8 pulses[], /* O Quantized pulse signal */ @@ -252,35 +266,27 @@ void SKP_Silk_NSQ_del_dec( /* Silk VAD */ /************/ /* Initialize the Silk VAD */ -SKP_int SKP_Silk_VAD_Init( /* O Return value, 0 if success */ - SKP_Silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */ +SKP_int silk_VAD_Init( /* O Return value, 0 if success */ + silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */ ); /* Silk VAD noise level estimation */ -void SKP_Silk_VAD_GetNoiseLevels( +void silk_VAD_GetNoiseLevels( const SKP_int32 pX[ VAD_N_BANDS ], /* I subband energies */ - SKP_Silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */ + silk_VAD_state *psSilk_VAD /* I/O Pointer to Silk VAD state */ ); /* Get speech activity level in Q8 */ -SKP_int SKP_Silk_VAD_GetSA_Q8( /* O Return value, 0 if success */ - SKP_Silk_encoder_state *psEncC, /* I/O Encoder state */ +SKP_int silk_VAD_GetSA_Q8( /* O Return value, 0 if success */ + silk_encoder_state *psEncC, /* I/O Encoder state */ const SKP_int16 pIn[] /* I PCM input */ ); -/* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */ -void SKP_Silk_HP_variable_cutoff( - SKP_Silk_encoder_state *psEncC, /* I/O Encoder state */ - SKP_int16 *out, /* O high-pass filtered output signal */ - const SKP_int16 *in, /* I input signal */ - const SKP_int frame_length /* I length of input */ -); - /* Low-pass filter with variable cutoff frequency based on */ /* piece-wise linear interpolation between elliptic filters */ /* Start by setting transition_frame_no = 1; */ -void SKP_Silk_LP_variable_cutoff( - SKP_Silk_LP_state *psLP, /* I/O LP filter state */ +void silk_LP_variable_cutoff( + silk_LP_state *psLP, /* I/O LP filter state */ SKP_int16 *signal, /* I/O Low-pass filtered output signal */ const SKP_int frame_length /* I Frame length */ ); @@ -289,17 +295,17 @@ void SKP_Silk_LP_variable_cutoff( /* NLSF Quantizer */ /******************/ /* Limit, stabilize, convert and quantize NLSFs */ -void SKP_Silk_process_NLSFs( - SKP_Silk_encoder_state *psEncC, /* I/O Encoder state */ +void silk_process_NLSFs( + silk_encoder_state *psEncC, /* I/O Encoder state */ SKP_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ], /* O Prediction coefficients */ SKP_int16 pNLSF_Q15[ MAX_LPC_ORDER ], /* I/O Normalized LSFs (quant out) (0 - (2^15-1)) */ const SKP_int16 prev_NLSFq_Q15[ MAX_LPC_ORDER ] /* I Previous Normalized LSFs (0 - (2^15-1)) */ ); -SKP_int32 SKP_Silk_NLSF_encode( /* O Returns RD value in Q25 */ +SKP_int32 silk_NLSF_encode( /* O Returns RD value in Q25 */ SKP_int8 *NLSFIndices, /* I Codebook path vector [ LPC_ORDER + 1 ] */ SKP_int16 *pNLSF_Q15, /* I/O Quantized NLSF vector [ LPC_ORDER ] */ - const SKP_Silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */ + const silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */ const SKP_int16 *pW_Q5, /* I NLSF weight vector [ LPC_ORDER ] */ const SKP_int NLSF_mu_Q20, /* I Rate weight for the RD optimization */ const SKP_int nSurvivors, /* I Max survivors after first stage */ @@ -307,7 +313,7 @@ SKP_int32 SKP_Silk_NLSF_encode( /* O Returns RD v ); /* Compute quantization errors for an LPC_order element input vector for a VQ codebook */ -void SKP_Silk_NLSF_VQ( +void silk_NLSF_VQ( SKP_int32 err_Q26[], /* O Quantization errors [K] */ const SKP_int16 in_Q15[], /* I Input vectors to be quantized [LPC_order] */ const SKP_uint8 pCB_Q8[], /* I Codebook vectors [K*LPC_order] */ @@ -316,7 +322,7 @@ void SKP_Silk_NLSF_VQ( ); /* Delayed-decision quantizer for NLSF residuals */ -SKP_int32 SKP_Silk_NLSF_del_dec_quant( /* O Returns RD value in Q25 */ +SKP_int32 silk_NLSF_del_dec_quant( /* O Returns RD value in Q25 */ SKP_int8 indices[], /* O Quantization indices [ order ] */ const SKP_int16 x_Q10[], /* I Input [ order ] */ const SKP_int16 w_Q5[], /* I Weights [ order ] */ @@ -330,48 +336,48 @@ SKP_int32 SKP_Silk_NLSF_del_dec_quant( /* O Returns RD value ); /* Unpack predictor values and indices for entropy coding tables */ -void SKP_Silk_NLSF_unpack( +void silk_NLSF_unpack( SKP_int16 ec_ix[], /* O Indices to entropy tales [ LPC_ORDER ] */ SKP_uint8 pred_Q8[], /* O LSF predictor [ LPC_ORDER ] */ - const SKP_Silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */ + const silk_NLSF_CB_struct *psNLSF_CB, /* I Codebook object */ const SKP_int CB1_index /* I Index of vector in first LSF codebook */ ); /***********************/ /* NLSF vector decoder */ /***********************/ -void SKP_Silk_NLSF_decode( +void silk_NLSF_decode( SKP_int16 *pNLSF_Q15, /* O Quantized NLSF vector [ LPC_ORDER ] */ SKP_int8 *NLSFIndices, /* I Codebook path vector [ LPC_ORDER + 1 ] */ - const SKP_Silk_NLSF_CB_struct *psNLSF_CB /* I Codebook object */ + const silk_NLSF_CB_struct *psNLSF_CB /* I Codebook object */ ); /****************************************************/ /* Decoder Functions */ /****************************************************/ -SKP_int SKP_Silk_create_decoder( - SKP_Silk_decoder_state **ppsDec /* I/O Decoder state pointer pointer */ +SKP_int silk_create_decoder( + silk_decoder_state **ppsDec /* I/O Decoder state pointer pointer */ ); -SKP_int SKP_Silk_free_decoder( - SKP_Silk_decoder_state *psDec /* I/O Decoder state pointer */ +SKP_int silk_free_decoder( + silk_decoder_state *psDec /* I/O Decoder state pointer */ ); -SKP_int SKP_Silk_init_decoder( - SKP_Silk_decoder_state *psDec /* I/O Decoder state pointer */ +SKP_int silk_init_decoder( + silk_decoder_state *psDec /* I/O Decoder state pointer */ ); /* Set decoder sampling rate */ -void SKP_Silk_decoder_set_fs( - SKP_Silk_decoder_state *psDec, /* I/O Decoder state pointer */ +void silk_decoder_set_fs( + silk_decoder_state *psDec, /* I/O Decoder state pointer */ SKP_int fs_kHz /* I Sampling frequency (kHz) */ ); /****************/ /* Decode frame */ /****************/ -SKP_int SKP_Silk_decode_frame( - SKP_Silk_decoder_state *psDec, /* I/O Pointer to Silk decoder state */ +SKP_int silk_decode_frame( + silk_decoder_state *psDec, /* I/O Pointer to Silk decoder state */ ec_dec *psRangeDec, /* I/O Compressor data structure */ SKP_int16 pOut[], /* O Pointer to output speech frame */ SKP_int32 *pN, /* O Pointer to size of output frame */ @@ -379,35 +385,35 @@ SKP_int SKP_Silk_decode_frame( ); /* Decode LBRR side info and excitation */ -void SKP_Silk_LBRR_extract( - SKP_Silk_decoder_state *psDec, /* I/O State */ +void silk_LBRR_extract( + silk_decoder_state *psDec, /* I/O State */ ec_dec *psRangeDec /* I/O Compressor data structure */ ); /* Decode indices from payload v4 Bitstream */ -void SKP_Silk_decode_indices( - SKP_Silk_decoder_state *psDec, /* I/O State */ +void silk_decode_indices( + silk_decoder_state *psDec, /* I/O State */ ec_dec *psRangeDec, /* I/O Compressor data structure */ SKP_int FrameIndex, /* I Frame number */ SKP_int decode_LBRR /* I Flag indicating LBRR data is being decoded */ ); /* Decode parameters from payload */ -void SKP_Silk_decode_parameters( - SKP_Silk_decoder_state *psDec, /* I/O State */ - SKP_Silk_decoder_control *psDecCtrl /* I/O Decoder control */ +void silk_decode_parameters( + silk_decoder_state *psDec, /* I/O State */ + silk_decoder_control *psDecCtrl /* I/O Decoder control */ ); /* Core decoder. Performs inverse NSQ operation LTP + LPC */ -void SKP_Silk_decode_core( - SKP_Silk_decoder_state *psDec, /* I/O Decoder state */ - SKP_Silk_decoder_control *psDecCtrl, /* I Decoder control */ +void silk_decode_core( + silk_decoder_state *psDec, /* I/O Decoder state */ + silk_decoder_control *psDecCtrl, /* I Decoder control */ SKP_int16 xq[], /* O Decoded speech */ const SKP_int pulses[ MAX_FRAME_LENGTH ] /* I Pulse signal */ ); /* Decode quantization indices of excitation (Shell coding) */ -void SKP_Silk_decode_pulses( +void silk_decode_pulses( ec_dec *psRangeDec, /* I/O Compressor data structure */ SKP_int pulses[], /* O Excitation signal */ const SKP_int signalType, /* I Sigtype */ @@ -420,21 +426,21 @@ void SKP_Silk_decode_pulses( /******************/ /* Reset CNG */ -void SKP_Silk_CNG_Reset( - SKP_Silk_decoder_state *psDec /* I/O Decoder state */ +void silk_CNG_Reset( + silk_decoder_state *psDec /* I/O Decoder state */ ); /* Updates CNG estimate, and applies the CNG when packet was lost */ -void SKP_Silk_CNG( - SKP_Silk_decoder_state *psDec, /* I/O Decoder state */ - SKP_Silk_decoder_control *psDecCtrl, /* I/O Decoder control */ +void silk_CNG( + silk_decoder_state *psDec, /* I/O Decoder state */ + silk_decoder_control *psDecCtrl, /* I/O Decoder control */ SKP_int16 signal[], /* I/O Signal */ SKP_int length /* I Length of residual */ ); /* Encoding of various parameters */ -void SKP_Silk_encode_indices( - SKP_Silk_encoder_state *psEncC, /* I/O Encoder state */ +void silk_encode_indices( + silk_encoder_state *psEncC, /* I/O Encoder state */ ec_enc *psRangeEnc, /* I/O Compressor data structure */ SKP_int FrameIndex, /* I Frame number */ SKP_int encode_LBRR /* I Flag indicating LBRR data is being encoded */ diff --git a/silk/SKP_Silk_pitch_analysis_core.c b/silk/silk_pitch_analysis_core.c similarity index 84% rename from silk/SKP_Silk_pitch_analysis_core.c rename to silk/silk_pitch_analysis_core.c index bf058913..ef4569fb 100644 --- a/silk/SKP_Silk_pitch_analysis_core.c +++ b/silk/silk_pitch_analysis_core.c @@ -28,16 +28,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /*********************************************************** * Pitch analyser function ********************************************************** */ -#include "SKP_Silk_SigProc_FIX.h" -#include "SKP_Silk_pitch_est_defines.h" -#include "SKP_debug.h" +#include "silk_SigProc_FIX.h" +#include "silk_pitch_est_defines.h" +#include "silk_debug.h" #define SCRATCH_SIZE 22 /************************************************************/ /* Internally used functions */ /************************************************************/ -void SKP_FIX_P_Ana_calc_corr_st3( +void silk_P_Ana_calc_corr_st3( SKP_int32 cross_corr_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ],/* (O) 3 DIM correlation array */ const SKP_int16 signal[], /* I vector to correlate */ SKP_int start_lag, /* I lag offset to search around */ @@ -46,7 +46,7 @@ void SKP_FIX_P_Ana_calc_corr_st3( SKP_int complexity /* I Complexity setting */ ); -void SKP_FIX_P_Ana_calc_energy_st3( +void silk_P_Ana_calc_energy_st3( SKP_int32 energies_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ],/* (O) 3 DIM energy array */ const SKP_int16 signal[], /* I vector to calc energy in */ SKP_int start_lag, /* I lag offset to search around */ @@ -55,7 +55,7 @@ void SKP_FIX_P_Ana_calc_energy_st3( SKP_int complexity /* I Complexity setting */ ); -SKP_int32 SKP_FIX_P_Ana_find_scaling( +SKP_int32 silk_P_Ana_find_scaling( const SKP_int16 *signal, const SKP_int signal_length, const SKP_int sum_sqr_len @@ -64,7 +64,7 @@ SKP_int32 SKP_FIX_P_Ana_find_scaling( /*************************************************************/ /* FIXED POINT CORE PITCH ANALYSIS FUNCTION */ /*************************************************************/ -SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 unvoiced */ +SKP_int silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 unvoiced */ const SKP_int16 *signal, /* I Signal of length PE_FRAME_LENGTH_MS*Fs_kHz */ SKP_int *pitch_out, /* O 4 pitch lag values */ SKP_int16 *lagIndex, /* O Lag Index */ @@ -106,8 +106,8 @@ SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 u SKP_assert( Fs_kHz == 8 || Fs_kHz == 12 || Fs_kHz == 16 ); /* Check for valid complexity setting */ - SKP_assert( complexity >= SKP_Silk_PE_MIN_COMPLEX ); - SKP_assert( complexity <= SKP_Silk_PE_MAX_COMPLEX ); + SKP_assert( complexity >= SILK_PE_MIN_COMPLEX ); + SKP_assert( complexity <= SILK_PE_MAX_COMPLEX ); SKP_assert( search_thres1_Q16 >= 0 && search_thres1_Q16 <= (1<<16) ); SKP_assert( search_thres2_Q15 >= 0 && search_thres2_Q15 <= (1<<15) ); @@ -131,10 +131,10 @@ SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 u /* Resample from input sampled at Fs_kHz to 8 kHz */ if( Fs_kHz == 16 ) { SKP_memset( filt_state, 0, 2 * sizeof( SKP_int32 ) ); - SKP_Silk_resampler_down2( filt_state, signal_8kHz, signal, frame_length ); + silk_resampler_down2( filt_state, signal_8kHz, signal, frame_length ); } else if ( Fs_kHz == 12 ) { SKP_memset( filt_state, 0, 6 * sizeof( SKP_int32 ) ); - SKP_Silk_resampler_down2_3( filt_state, signal_8kHz, signal, frame_length ); + silk_resampler_down2_3( filt_state, signal_8kHz, signal, frame_length ); } else { SKP_assert( Fs_kHz == 8 ); SKP_memcpy( signal_8kHz, signal, frame_length_8kHz * sizeof(SKP_int16) ); @@ -142,7 +142,7 @@ SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 u /* Decimate again to 4 kHz */ SKP_memset( filt_state, 0, 2 * sizeof( SKP_int32 ) );/* Set state to zero */ - SKP_Silk_resampler_down2( filt_state, signal_4kHz, signal_8kHz, frame_length_8kHz ); + silk_resampler_down2( filt_state, signal_4kHz, signal_8kHz, frame_length_8kHz ); /* Low-pass filter */ for( i = frame_length_4kHz - 1; i > 0; i-- ) { @@ -156,7 +156,7 @@ SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 u /* Inner product is calculated with different lengths, so scale for the worst case */ max_sum_sq_length = SKP_max_32( sf_length_8kHz, SKP_LSHIFT( sf_length_4kHz, 2 ) ); - shift = SKP_FIX_P_Ana_find_scaling( signal_4kHz, frame_length_4kHz, max_sum_sq_length ); + shift = silk_P_Ana_find_scaling( signal_4kHz, frame_length_4kHz, max_sum_sq_length ); if( shift > 0 ) { for( i = 0; i < frame_length_4kHz; i++ ) { signal_4kHz[ i ] = SKP_RSHIFT( signal_4kHz[ i ], shift ); @@ -181,11 +181,11 @@ SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 u normalizer = 0; cross_corr = 0; /* Calculate first vector products before loop */ - cross_corr = SKP_Silk_inner_prod_aligned( target_ptr, basis_ptr, sf_length_8kHz ); - normalizer = SKP_Silk_inner_prod_aligned( basis_ptr, basis_ptr, sf_length_8kHz ); + cross_corr = silk_inner_prod_aligned( target_ptr, basis_ptr, sf_length_8kHz ); + normalizer = silk_inner_prod_aligned( basis_ptr, basis_ptr, sf_length_8kHz ); normalizer = SKP_ADD_SAT32( normalizer, SKP_SMULBB( sf_length_8kHz, 4000 ) ); - temp32 = SKP_DIV32( cross_corr, SKP_Silk_SQRT_APPROX( normalizer ) + 1 ); + temp32 = SKP_DIV32( cross_corr, silk_SQRT_APPROX( normalizer ) + 1 ); C[ k ][ min_lag_4kHz ] = (SKP_int16)SKP_SAT16( temp32 ); /* Q0 */ /* From now on normalizer is computed recursively */ @@ -196,14 +196,14 @@ SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 u SKP_assert( basis_ptr >= signal_4kHz ); SKP_assert( basis_ptr + sf_length_8kHz <= signal_4kHz + frame_length_4kHz ); - cross_corr = SKP_Silk_inner_prod_aligned( target_ptr, basis_ptr, sf_length_8kHz ); + cross_corr = silk_inner_prod_aligned( target_ptr, basis_ptr, sf_length_8kHz ); /* Add contribution of new sample and remove contribution from oldest sample */ normalizer += SKP_SMULBB( basis_ptr[ 0 ], basis_ptr[ 0 ] ) - SKP_SMULBB( basis_ptr[ sf_length_8kHz ], basis_ptr[ sf_length_8kHz ] ); - temp32 = SKP_DIV32( cross_corr, SKP_Silk_SQRT_APPROX( normalizer ) + 1 ); + temp32 = SKP_DIV32( cross_corr, silk_SQRT_APPROX( normalizer ) + 1 ); C[ k ][ d ] = (SKP_int16)SKP_SAT16( temp32 ); /* Q0 */ } /* Update target pointer */ @@ -233,11 +233,11 @@ SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 u /* Sort */ length_d_srch = SKP_ADD_LSHIFT32( 4, complexity, 1 ); SKP_assert( 3 * length_d_srch <= PE_D_SRCH_LENGTH ); - SKP_Silk_insertion_sort_decreasing_int16( &C[ 0 ][ min_lag_4kHz ], d_srch, max_lag_4kHz - min_lag_4kHz + 1, length_d_srch ); + silk_insertion_sort_decreasing_int16( &C[ 0 ][ min_lag_4kHz ], d_srch, max_lag_4kHz - min_lag_4kHz + 1, length_d_srch ); /* Escape if correlation is very low already here */ target_ptr = &signal_4kHz[ SKP_SMULBB( sf_length_4kHz, nb_subfr ) ]; - energy = SKP_Silk_inner_prod_aligned( target_ptr, target_ptr, SKP_LSHIFT( sf_length_4kHz, 2 ) ); + energy = silk_inner_prod_aligned( target_ptr, target_ptr, SKP_LSHIFT( sf_length_4kHz, 2 ) ); energy = SKP_ADD_SAT32( energy, 1000 ); /* Q0 */ Cmax = (SKP_int)C[ 0 ][ min_lag_4kHz ]; /* Q-1 */ threshold = SKP_SMULBB( Cmax, Cmax ); /* Q-2 */ @@ -304,7 +304,7 @@ SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 u ** Scale signal down to avoid correlations measures from overflowing *******************************************************************************/ /* find scaling as max scaling for each subframe */ - shift = SKP_FIX_P_Ana_find_scaling( signal_8kHz, frame_length_8kHz, sf_length_8kHz ); + shift = silk_P_Ana_find_scaling( signal_8kHz, frame_length_8kHz, sf_length_8kHz ); if( shift > 0 ) { for( i = 0; i < frame_length_8kHz; i++ ) { signal_8kHz[ i ] = SKP_RSHIFT( signal_8kHz[ i ], shift ); @@ -323,7 +323,7 @@ SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 u SKP_assert( target_ptr >= signal_8kHz ); SKP_assert( target_ptr + sf_length_8kHz <= signal_8kHz + frame_length_8kHz ); - energy_target = SKP_Silk_inner_prod_aligned( target_ptr, target_ptr, sf_length_8kHz ); + energy_target = silk_inner_prod_aligned( target_ptr, target_ptr, sf_length_8kHz ); // ToDo: Calculate 1 / energy_target here and save one division inside next for loop for( j = 0; j < length_d_comp; j++ ) { d = d_comp[ j ]; @@ -333,17 +333,17 @@ SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 u SKP_assert( basis_ptr >= signal_8kHz ); SKP_assert( basis_ptr + sf_length_8kHz <= signal_8kHz + frame_length_8kHz ); - cross_corr = SKP_Silk_inner_prod_aligned( target_ptr, basis_ptr, sf_length_8kHz ); - energy_basis = SKP_Silk_inner_prod_aligned( basis_ptr, basis_ptr, sf_length_8kHz ); + cross_corr = silk_inner_prod_aligned( target_ptr, basis_ptr, sf_length_8kHz ); + energy_basis = silk_inner_prod_aligned( basis_ptr, basis_ptr, sf_length_8kHz ); if( cross_corr > 0 ) { energy = SKP_max( energy_target, energy_basis ); /* Find max to make sure first division < 1.0 */ - lz = SKP_Silk_CLZ32( cross_corr ); + lz = silk_CLZ32( cross_corr ); lshift = SKP_LIMIT_32( lz - 1, 0, 15 ); temp32 = SKP_DIV32( SKP_LSHIFT( cross_corr, lshift ), SKP_RSHIFT( energy, 15 - lshift ) + 1 ); /* Q15 */ SKP_assert( temp32 == SKP_SAT16( temp32 ) ); temp32 = SKP_SMULWB( cross_corr, temp32 ); /* Q(-1), cc * ( cc / max(b, t) ) */ temp32 = SKP_ADD_SAT32( temp32, temp32 ); /* Q(0) */ - lz = SKP_Silk_CLZ32( temp32 ); + lz = silk_CLZ32( temp32 ); lshift = SKP_LIMIT_32( lz - 1, 0, 15 ); energy = SKP_min( energy_target, energy_basis ); C[ k ][ d ] = SKP_DIV32( SKP_LSHIFT( temp32, lshift ), SKP_RSHIFT( energy, 15 - lshift ) + 1 ); // Q15 @@ -369,7 +369,7 @@ SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 u } else if( Fs_kHz == 16 ) { prevLag = SKP_RSHIFT( prevLag, 1 ); } - prevLag_log2_Q7 = SKP_Silk_lin2log( (SKP_int32)prevLag ); + prevLag_log2_Q7 = silk_lin2log( (SKP_int32)prevLag ); } else { prevLag_log2_Q7 = 0; } @@ -377,8 +377,8 @@ SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 u /* Setup stage 2 codebook based on number of subframes */ if( nb_subfr == PE_MAX_NB_SUBFR ) { cbk_size = PE_NB_CBKS_STAGE2_EXT; - Lag_CB_ptr = &SKP_Silk_CB_lags_stage2[ 0 ][ 0 ]; - if( Fs_kHz == 8 && complexity > SKP_Silk_PE_MIN_COMPLEX ) { + Lag_CB_ptr = &silk_CB_lags_stage2[ 0 ][ 0 ]; + if( Fs_kHz == 8 && complexity > SILK_PE_MIN_COMPLEX ) { /* If input is 8 khz use a larger codebook here because it is last stage */ nb_cbk_search = PE_NB_CBKS_STAGE2_EXT; } else { @@ -387,7 +387,7 @@ SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 u corr_thres_Q15 = SKP_RSHIFT( SKP_SMULBB( search_thres2_Q15, search_thres2_Q15 ), 13 ); } else { cbk_size = PE_NB_CBKS_STAGE2_10MS; - Lag_CB_ptr = &SKP_Silk_CB_lags_stage2_10_ms[ 0 ][ 0 ]; + Lag_CB_ptr = &silk_CB_lags_stage2_10_ms[ 0 ][ 0 ]; nb_cbk_search = PE_NB_CBKS_STAGE2_10MS; corr_thres_Q15 = SKP_RSHIFT( SKP_SMULBB( search_thres2_Q15, search_thres2_Q15 ), 14 ); } @@ -412,25 +412,25 @@ SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 u } /* Bias towards shorter lags */ - lag_log2_Q7 = SKP_Silk_lin2log( (SKP_int32)d ); /* Q7 */ + lag_log2_Q7 = silk_lin2log( (SKP_int32)d ); /* Q7 */ SKP_assert( lag_log2_Q7 == SKP_SAT16( lag_log2_Q7 ) ); - SKP_assert( nb_subfr * SKP_FIX_CONST( PE_SHORTLAG_BIAS, 15 ) == SKP_SAT16( nb_subfr * SKP_FIX_CONST( PE_SHORTLAG_BIAS, 15 ) ) ); - CCmax_new_b = CCmax_new - SKP_RSHIFT( SKP_SMULBB( nb_subfr * SKP_FIX_CONST( PE_SHORTLAG_BIAS, 15 ), lag_log2_Q7 ), 7 ); /* Q15 */ + SKP_assert( nb_subfr * SILK_FIX_CONST( PE_SHORTLAG_BIAS, 15 ) == SKP_SAT16( nb_subfr * SILK_FIX_CONST( PE_SHORTLAG_BIAS, 15 ) ) ); + CCmax_new_b = CCmax_new - SKP_RSHIFT( SKP_SMULBB( nb_subfr * SILK_FIX_CONST( PE_SHORTLAG_BIAS, 15 ), lag_log2_Q7 ), 7 ); /* Q15 */ /* Bias towards previous lag */ - SKP_assert( nb_subfr * SKP_FIX_CONST( PE_PREVLAG_BIAS, 15 ) == SKP_SAT16( nb_subfr * SKP_FIX_CONST( PE_PREVLAG_BIAS, 15 ) ) ); + SKP_assert( nb_subfr * SILK_FIX_CONST( PE_PREVLAG_BIAS, 15 ) == SKP_SAT16( nb_subfr * SILK_FIX_CONST( PE_PREVLAG_BIAS, 15 ) ) ); if( prevLag > 0 ) { delta_lag_log2_sqr_Q7 = lag_log2_Q7 - prevLag_log2_Q7; SKP_assert( delta_lag_log2_sqr_Q7 == SKP_SAT16( delta_lag_log2_sqr_Q7 ) ); delta_lag_log2_sqr_Q7 = SKP_RSHIFT( SKP_SMULBB( delta_lag_log2_sqr_Q7, delta_lag_log2_sqr_Q7 ), 7 ); - prev_lag_bias_Q15 = SKP_RSHIFT( SKP_SMULBB( nb_subfr * SKP_FIX_CONST( PE_PREVLAG_BIAS, 15 ), *LTPCorr_Q15 ), 15 ); /* Q15 */ + prev_lag_bias_Q15 = SKP_RSHIFT( SKP_SMULBB( nb_subfr * SILK_FIX_CONST( PE_PREVLAG_BIAS, 15 ), *LTPCorr_Q15 ), 15 ); /* Q15 */ prev_lag_bias_Q15 = SKP_DIV32( SKP_MUL( prev_lag_bias_Q15, delta_lag_log2_sqr_Q7 ), delta_lag_log2_sqr_Q7 + ( 1 << 6 ) ); CCmax_new_b -= prev_lag_bias_Q15; /* Q15 */ } if ( CCmax_new_b > CCmax_b && /* Find maximum biased correlation */ CCmax_new > corr_thres_Q15 && /* Correlation needs to be high enough to be voiced */ - SKP_Silk_CB_lags_stage2[ 0 ][ CBimax_new ] <= min_lag_8kHz /* Lag must be in range */ + silk_CB_lags_stage2[ 0 ][ CBimax_new ] <= min_lag_8kHz /* Lag must be in range */ ) { CCmax_b = CCmax_new_b; CCmax = CCmax_new; @@ -454,7 +454,7 @@ SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 u ** Scale input signal down to avoid correlations measures from overflowing *******************************************************************************/ /* find scaling as max scaling for each subframe */ - shift = SKP_FIX_P_Ana_find_scaling( signal, frame_length, sf_length ); + shift = silk_P_Ana_find_scaling( signal, frame_length, sf_length ); if( shift > 0 ) { /* Move signal to scratch mem because the input signal should be unchanged */ /* Reuse the 32 bit scratch mem vector, use a 16 bit pointer from now */ @@ -486,30 +486,30 @@ SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 u lag_new = lag; /* to avoid undefined lag */ CBimax = 0; /* to avoid undefined lag */ SKP_assert( SKP_LSHIFT( CCmax, 13 ) >= 0 ); - *LTPCorr_Q15 = (SKP_int)SKP_Silk_SQRT_APPROX( SKP_LSHIFT( CCmax, 13 ) ); /* Output normalized correlation */ + *LTPCorr_Q15 = (SKP_int)silk_SQRT_APPROX( SKP_LSHIFT( CCmax, 13 ) ); /* Output normalized correlation */ CCmax = SKP_int32_MIN; /* pitch lags according to second stage */ for( k = 0; k < nb_subfr; k++ ) { - pitch_out[ k ] = lag + 2 * SKP_Silk_CB_lags_stage2[ k ][ CBimax_old ]; + pitch_out[ k ] = lag + 2 * silk_CB_lags_stage2[ k ][ CBimax_old ]; } /* Calculate the correlations and energies needed in stage 3 */ - SKP_FIX_P_Ana_calc_corr_st3( crosscorr_st3, input_signal_ptr, start_lag, sf_length, nb_subfr, complexity ); - SKP_FIX_P_Ana_calc_energy_st3( energies_st3, input_signal_ptr, start_lag, sf_length, nb_subfr, complexity ); + silk_P_Ana_calc_corr_st3( crosscorr_st3, input_signal_ptr, start_lag, sf_length, nb_subfr, complexity ); + silk_P_Ana_calc_energy_st3( energies_st3, input_signal_ptr, start_lag, sf_length, nb_subfr, complexity ); lag_counter = 0; SKP_assert( lag == SKP_SAT16( lag ) ); - contour_bias_Q20 = SKP_DIV32_16( SKP_FIX_CONST( PE_FLATCONTOUR_BIAS, 20 ), lag ); + contour_bias_Q20 = SKP_DIV32_16( SILK_FIX_CONST( PE_FLATCONTOUR_BIAS, 20 ), lag ); /* Setup cbk parameters acording to complexity setting and frame length */ if( nb_subfr == PE_MAX_NB_SUBFR ) { - nb_cbk_search = (SKP_int)SKP_Silk_nb_cbk_searchs_stage3[ complexity ]; + nb_cbk_search = (SKP_int)silk_nb_cbk_searchs_stage3[ complexity ]; cbk_size = PE_NB_CBKS_STAGE3_MAX; - Lag_CB_ptr = &SKP_Silk_CB_lags_stage3[ 0 ][ 0 ]; + Lag_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ]; } else { nb_cbk_search = PE_NB_CBKS_STAGE3_10MS; cbk_size = PE_NB_CBKS_STAGE3_10MS; - Lag_CB_ptr = &SKP_Silk_CB_lags_stage3_10_ms[ 0 ][ 0 ]; + Lag_CB_ptr = &silk_CB_lags_stage3_10_ms[ 0 ][ 0 ]; } for( d = start_lag; d <= end_lag; d++ ) { for( j = 0; j < nb_cbk_search; j++ ) { @@ -523,7 +523,7 @@ SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 u } if( cross_corr > 0 ) { /* Divide cross_corr / energy and get result in Q15 */ - lz = SKP_Silk_CLZ32( cross_corr ); + lz = silk_CLZ32( cross_corr ); /* Divide with result in Q13, cross_corr could be larger than energy */ lshift = SKP_LIMIT_32( lz - 1, 0, 13 ); CCmax_new = SKP_DIV32( SKP_LSHIFT( cross_corr, lshift ), SKP_RSHIFT( energy, 13 - lshift ) + 1 ); @@ -544,7 +544,7 @@ SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 u } if( CCmax_new > CCmax && - ( d + SKP_Silk_CB_lags_stage3[ 0 ][ j ] ) <= max_lag + ( d + silk_CB_lags_stage3[ 0 ][ j ] ) <= max_lag ) { CCmax = CCmax_new; lag_new = d; @@ -562,7 +562,7 @@ SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 u } else { /* Save Lags and correlation */ CCmax = SKP_max( CCmax, 0 ); - *LTPCorr_Q15 = (SKP_int)SKP_Silk_SQRT_APPROX( SKP_LSHIFT( CCmax, 13 ) ); /* Output normalized correlation */ + *LTPCorr_Q15 = (SKP_int)silk_SQRT_APPROX( SKP_LSHIFT( CCmax, 13 ) ); /* Output normalized correlation */ for( k = 0; k < nb_subfr; k++ ) { pitch_out[ k ] = lag + matrix_ptr( Lag_CB_ptr, k, CBimax, cbk_size ); } @@ -578,7 +578,7 @@ SKP_int SKP_Silk_pitch_analysis_core( /* O Voicing estimate: 0 voiced, 1 u /* Calculates the correlations used in stage 3 search. In order to cover */ /* the whole lag codebook for all the searched offset lags (lag +- 2), */ /*************************************************************************/ -void SKP_FIX_P_Ana_calc_corr_st3( +void silk_P_Ana_calc_corr_st3( SKP_int32 cross_corr_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ],/* (O) 3 DIM correlation array */ const SKP_int16 signal[], /* I vector to correlate */ SKP_int start_lag, /* I lag offset to search around */ @@ -594,18 +594,18 @@ void SKP_FIX_P_Ana_calc_corr_st3( SKP_int32 scratch_mem[ SCRATCH_SIZE ]; const SKP_int8 *Lag_range_ptr, *Lag_CB_ptr; - SKP_assert( complexity >= SKP_Silk_PE_MIN_COMPLEX ); - SKP_assert( complexity <= SKP_Silk_PE_MAX_COMPLEX ); + SKP_assert( complexity >= SILK_PE_MIN_COMPLEX ); + SKP_assert( complexity <= SILK_PE_MAX_COMPLEX ); if( nb_subfr == PE_MAX_NB_SUBFR ){ - Lag_range_ptr = &SKP_Silk_Lag_range_stage3[ complexity ][ 0 ][ 0 ]; - Lag_CB_ptr = &SKP_Silk_CB_lags_stage3[ 0 ][ 0 ]; - nb_cbk_search = SKP_Silk_nb_cbk_searchs_stage3[ complexity ]; + Lag_range_ptr = &silk_Lag_range_stage3[ complexity ][ 0 ][ 0 ]; + Lag_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ]; + nb_cbk_search = silk_nb_cbk_searchs_stage3[ complexity ]; cbk_size = PE_NB_CBKS_STAGE3_MAX; } else { SKP_assert( nb_subfr == PE_MAX_NB_SUBFR >> 1); - Lag_range_ptr = &SKP_Silk_Lag_range_stage3_10_ms[ 0 ][ 0 ]; - Lag_CB_ptr = &SKP_Silk_CB_lags_stage3_10_ms[ 0 ][ 0 ]; + Lag_range_ptr = &silk_Lag_range_stage3_10_ms[ 0 ][ 0 ]; + Lag_CB_ptr = &silk_CB_lags_stage3_10_ms[ 0 ][ 0 ]; nb_cbk_search = PE_NB_CBKS_STAGE3_10MS; cbk_size = PE_NB_CBKS_STAGE3_10MS; } @@ -619,7 +619,7 @@ void SKP_FIX_P_Ana_calc_corr_st3( lag_high = matrix_ptr( Lag_range_ptr, k, 1, 2 ); for( j = lag_low; j <= lag_high; j++ ) { basis_ptr = target_ptr - ( start_lag + j ); - cross_corr = SKP_Silk_inner_prod_aligned( (SKP_int16*)target_ptr, (SKP_int16*)basis_ptr, sf_length ); + cross_corr = silk_inner_prod_aligned( (SKP_int16*)target_ptr, (SKP_int16*)basis_ptr, sf_length ); SKP_assert( lag_counter < SCRATCH_SIZE ); scratch_mem[ lag_counter ] = cross_corr; lag_counter++; @@ -644,7 +644,7 @@ void SKP_FIX_P_Ana_calc_corr_st3( /* Calculate the energies for first two subframes. The energies are */ /* calculated recursively. */ /********************************************************************/ -void SKP_FIX_P_Ana_calc_energy_st3( +void silk_P_Ana_calc_energy_st3( SKP_int32 energies_st3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ][ PE_NB_STAGE3_LAGS ],/* (O) 3 DIM energy array */ const SKP_int16 signal[], /* I vector to calc energy in */ SKP_int start_lag, /* I lag offset to search around */ @@ -660,18 +660,18 @@ void SKP_FIX_P_Ana_calc_energy_st3( SKP_int32 scratch_mem[ SCRATCH_SIZE ]; const SKP_int8 *Lag_range_ptr, *Lag_CB_ptr; - SKP_assert( complexity >= SKP_Silk_PE_MIN_COMPLEX ); - SKP_assert( complexity <= SKP_Silk_PE_MAX_COMPLEX ); + SKP_assert( complexity >= SILK_PE_MIN_COMPLEX ); + SKP_assert( complexity <= SILK_PE_MAX_COMPLEX ); if( nb_subfr == PE_MAX_NB_SUBFR ){ - Lag_range_ptr = &SKP_Silk_Lag_range_stage3[ complexity ][ 0 ][ 0 ]; - Lag_CB_ptr = &SKP_Silk_CB_lags_stage3[ 0 ][ 0 ]; - nb_cbk_search = SKP_Silk_nb_cbk_searchs_stage3[ complexity ]; + Lag_range_ptr = &silk_Lag_range_stage3[ complexity ][ 0 ][ 0 ]; + Lag_CB_ptr = &silk_CB_lags_stage3[ 0 ][ 0 ]; + nb_cbk_search = silk_nb_cbk_searchs_stage3[ complexity ]; cbk_size = PE_NB_CBKS_STAGE3_MAX; } else { SKP_assert( nb_subfr == PE_MAX_NB_SUBFR >> 1); - Lag_range_ptr = &SKP_Silk_Lag_range_stage3_10_ms[ 0 ][ 0 ]; - Lag_CB_ptr = &SKP_Silk_CB_lags_stage3_10_ms[ 0 ][ 0 ]; + Lag_range_ptr = &silk_Lag_range_stage3_10_ms[ 0 ][ 0 ]; + Lag_CB_ptr = &silk_CB_lags_stage3_10_ms[ 0 ][ 0 ]; nb_cbk_search = PE_NB_CBKS_STAGE3_10MS; cbk_size = PE_NB_CBKS_STAGE3_10MS; } @@ -681,7 +681,7 @@ void SKP_FIX_P_Ana_calc_energy_st3( /* Calculate the energy for first lag */ basis_ptr = target_ptr - ( start_lag + matrix_ptr( Lag_range_ptr, k, 0, 2 ) ); - energy = SKP_Silk_inner_prod_aligned( basis_ptr, basis_ptr, sf_length ); + energy = silk_inner_prod_aligned( basis_ptr, basis_ptr, sf_length ); SKP_assert( energy >= 0 ); scratch_mem[ lag_counter ] = energy; lag_counter++; @@ -716,7 +716,7 @@ void SKP_FIX_P_Ana_calc_energy_st3( } } -SKP_int32 SKP_FIX_P_Ana_find_scaling( +SKP_int32 silk_P_Ana_find_scaling( const SKP_int16 *signal, const SKP_int signal_length, const SKP_int sum_sqr_len @@ -724,16 +724,16 @@ SKP_int32 SKP_FIX_P_Ana_find_scaling( { SKP_int32 nbits, x_max; - x_max = SKP_Silk_int16_array_maxabs( signal, signal_length ); + x_max = silk_int16_array_maxabs( signal, signal_length ); if( x_max < SKP_int16_MAX ) { /* Number of bits needed for the sum of the squares */ - nbits = 32 - SKP_Silk_CLZ32( SKP_SMULBB( x_max, x_max ) ); + nbits = 32 - silk_CLZ32( SKP_SMULBB( x_max, x_max ) ); } else { /* Here we don't know if x_max should have been SKP_int16_MAX + 1, so we expect the worst case */ nbits = 30; } - nbits += 17 - SKP_Silk_CLZ16( sum_sqr_len ); + nbits += 17 - silk_CLZ16( sum_sqr_len ); /* Without a guarantee of saturation, we need to keep the 31st bit free */ if( nbits < 31 ) { diff --git a/silk/SKP_Silk_pitch_est_defines.h b/silk/silk_pitch_est_defines.h similarity index 81% rename from silk/SKP_Silk_pitch_est_defines.h rename to silk/silk_pitch_est_defines.h index 1960eabf..537d1b39 100644 --- a/silk/SKP_Silk_pitch_est_defines.h +++ b/silk/silk_pitch_est_defines.h @@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#ifndef SKP_SILK_PE_DEFINES_H -#define SKP_SILK_PE_DEFINES_H +#ifndef SILK_PE_DEFINES_H +#define SILK_PE_DEFINES_H -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_SigProc_FIX.h" /************************************************************/ /* Definitions For Fix pitch estimator */ @@ -73,15 +73,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define PE_PREVLAG_BIAS 0.2f /* for logarithmic weighting */ #define PE_FLATCONTOUR_BIAS 0.05f -extern const SKP_int8 SKP_Silk_CB_lags_stage2[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE2_EXT ]; -extern const SKP_int8 SKP_Silk_CB_lags_stage3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ]; -extern const SKP_int8 SKP_Silk_Lag_range_stage3[ SKP_Silk_PE_MAX_COMPLEX + 1 ] [ PE_MAX_NB_SUBFR ][ 2 ]; -extern const SKP_int8 SKP_Silk_nb_cbk_searchs_stage3[ SKP_Silk_PE_MAX_COMPLEX + 1 ]; +extern const SKP_int8 silk_CB_lags_stage2[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE2_EXT ]; +extern const SKP_int8 silk_CB_lags_stage3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ]; +extern const SKP_int8 silk_Lag_range_stage3[ SILK_PE_MAX_COMPLEX + 1 ] [ PE_MAX_NB_SUBFR ][ 2 ]; +extern const SKP_int8 silk_nb_cbk_searchs_stage3[ SILK_PE_MAX_COMPLEX + 1 ]; /* Tables added for 10 ms frames */ -extern const SKP_int8 SKP_Silk_CB_lags_stage2_10_ms[ PE_MAX_NB_SUBFR >> 1][ 3 ]; -extern const SKP_int8 SKP_Silk_CB_lags_stage3_10_ms[ PE_MAX_NB_SUBFR >> 1 ][ 12 ]; -extern const SKP_int8 SKP_Silk_Lag_range_stage3_10_ms[ PE_MAX_NB_SUBFR >> 1 ][ 2 ]; +extern const SKP_int8 silk_CB_lags_stage2_10_ms[ PE_MAX_NB_SUBFR >> 1][ 3 ]; +extern const SKP_int8 silk_CB_lags_stage3_10_ms[ PE_MAX_NB_SUBFR >> 1 ][ 12 ]; +extern const SKP_int8 silk_Lag_range_stage3_10_ms[ PE_MAX_NB_SUBFR >> 1 ][ 2 ]; #endif diff --git a/silk/SKP_Silk_pitch_est_tables.c b/silk/silk_pitch_est_tables.c similarity index 79% rename from silk/SKP_Silk_pitch_est_tables.c rename to silk/silk_pitch_est_tables.c index f513b8d8..1c005308 100644 --- a/silk/SKP_Silk_pitch_est_tables.c +++ b/silk/silk_pitch_est_tables.c @@ -25,28 +25,28 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_typedef.h" -#include "SKP_Silk_pitch_est_defines.h" +#include "silk_typedef.h" +#include "silk_pitch_est_defines.h" -const SKP_int8 SKP_Silk_CB_lags_stage2_10_ms[ PE_MAX_NB_SUBFR >> 1][ PE_NB_CBKS_STAGE2_10MS ] = +const SKP_int8 silk_CB_lags_stage2_10_ms[ PE_MAX_NB_SUBFR >> 1][ PE_NB_CBKS_STAGE2_10MS ] = { {0, 1, 0}, {0, 0, 1} }; -const SKP_int8 SKP_Silk_CB_lags_stage3_10_ms[ PE_MAX_NB_SUBFR >> 1 ][ PE_NB_CBKS_STAGE3_10MS ] = +const SKP_int8 silk_CB_lags_stage3_10_ms[ PE_MAX_NB_SUBFR >> 1 ][ PE_NB_CBKS_STAGE3_10MS ] = { { 0, 0, 1,-1, 1,-1, 2,-2, 2,-2, 3,-3}, { 0, 1, 0, 1,-1, 2,-1, 2,-2, 3,-2, 3} }; -const SKP_int8 SKP_Silk_Lag_range_stage3_10_ms[ PE_MAX_NB_SUBFR >> 1 ][ 2 ] = +const SKP_int8 silk_Lag_range_stage3_10_ms[ PE_MAX_NB_SUBFR >> 1 ][ 2 ] = { {-3, 7}, {-2, 7} }; -const SKP_int8 SKP_Silk_CB_lags_stage2[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE2_EXT ] = +const SKP_int8 silk_CB_lags_stage2[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE2_EXT ] = { {0, 2,-1,-1,-1, 0, 0, 1, 1, 0, 1}, {0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0}, @@ -54,7 +54,7 @@ const SKP_int8 SKP_Silk_CB_lags_stage2[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE2_EXT {0,-1, 2, 1, 0, 1, 1, 0, 0,-1,-1} }; -const SKP_int8 SKP_Silk_CB_lags_stage3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ] = +const SKP_int8 silk_CB_lags_stage3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX ] = { {0, 0, 1,-1, 0, 1,-1, 0,-1, 1,-2, 2,-2,-2, 2,-3, 2, 3,-3,-4, 3,-4, 4, 4,-5, 5,-6,-5, 6,-7, 6, 5, 8,-9}, {0, 0, 1, 0, 0, 0, 0, 0, 0, 0,-1, 1, 0, 0, 1,-1, 0, 1,-1,-1, 1,-1, 2, 1,-1, 2,-2,-2, 2,-2, 2, 2, 3,-3}, @@ -62,7 +62,7 @@ const SKP_int8 SKP_Silk_CB_lags_stage3[ PE_MAX_NB_SUBFR ][ PE_NB_CBKS_STAGE3_MAX {0, 1, 0, 0, 1, 0, 1,-1, 2,-1, 2,-1, 2, 3,-2, 3,-2,-2, 4, 4,-3, 5,-3,-4, 6,-4, 6, 5,-5, 8,-6,-5,-7, 9} }; -const SKP_int8 SKP_Silk_Lag_range_stage3[ SKP_Silk_PE_MAX_COMPLEX + 1 ] [ PE_MAX_NB_SUBFR ][ 2 ] = +const SKP_int8 silk_Lag_range_stage3[ SILK_PE_MAX_COMPLEX + 1 ] [ PE_MAX_NB_SUBFR ][ 2 ] = { /* Lags to search for low number of stage3 cbks */ { @@ -87,7 +87,7 @@ const SKP_int8 SKP_Silk_Lag_range_stage3[ SKP_Silk_PE_MAX_COMPLEX + 1 ] [ PE_MAX } }; -const SKP_int8 SKP_Silk_nb_cbk_searchs_stage3[ SKP_Silk_PE_MAX_COMPLEX + 1 ] = +const SKP_int8 silk_nb_cbk_searchs_stage3[ SILK_PE_MAX_COMPLEX + 1 ] = { PE_NB_CBKS_STAGE3_MIN, PE_NB_CBKS_STAGE3_MID, diff --git a/silk/SKP_Silk_process_NLSFs.c b/silk/silk_process_NLSFs.c similarity index 80% rename from silk/SKP_Silk_process_NLSFs.c rename to silk/silk_process_NLSFs.c index f4da0242..aa4ead42 100644 --- a/silk/SKP_Silk_process_NLSFs.c +++ b/silk/silk_process_NLSFs.c @@ -25,11 +25,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" +#include "silk_main.h" /* Limit, stabilize, convert and quantize NLSFs */ -void SKP_Silk_process_NLSFs( - SKP_Silk_encoder_state *psEncC, /* I/O Encoder state */ +void silk_process_NLSFs( + silk_encoder_state *psEncC, /* I/O Encoder state */ SKP_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ], /* O Prediction coefficients */ SKP_int16 pNLSF_Q15[ MAX_LPC_ORDER ], /* I/O Normalized LSFs (quant out) (0 - (2^15-1)) */ const SKP_int16 prev_NLSFq_Q15[ MAX_LPC_ORDER ] /* I Previous Normalized LSFs (0 - (2^15-1)) */ @@ -43,33 +43,33 @@ void SKP_Silk_process_NLSFs( SKP_int16 pNLSFW0_temp_Q5[ MAX_LPC_ORDER ]; SKP_assert( psEncC->speech_activity_Q8 >= 0 ); - SKP_assert( psEncC->speech_activity_Q8 <= SKP_FIX_CONST( 1.0, 8 ) ); + SKP_assert( psEncC->speech_activity_Q8 <= SILK_FIX_CONST( 1.0, 8 ) ); /***********************/ /* Calculate mu values */ /***********************/ /* NLSF_mu = 0.003 - 0.0015 * psEnc->speech_activity; */ - NLSF_mu_Q20 = SKP_SMLAWB( SKP_FIX_CONST( 0.003, 20 ), SKP_FIX_CONST( -0.0015, 28 ), psEncC->speech_activity_Q8 ); + NLSF_mu_Q20 = SKP_SMLAWB( SILK_FIX_CONST( 0.003, 20 ), SILK_FIX_CONST( -0.0015, 28 ), psEncC->speech_activity_Q8 ); if( psEncC->nb_subfr == 2 ) { /* Multiply by 1.5 for 10 ms packets */ NLSF_mu_Q20 = SKP_ADD_RSHIFT( NLSF_mu_Q20, NLSF_mu_Q20, 1 ); } SKP_assert( NLSF_mu_Q20 > 0 ); - SKP_assert( NLSF_mu_Q20 <= SKP_FIX_CONST( 0.0045, 20 ) ); + SKP_assert( NLSF_mu_Q20 <= SILK_FIX_CONST( 0.0045, 20 ) ); /* Calculate NLSF weights */ - SKP_Silk_NLSF_VQ_weights_laroia( pNLSFW_Q5, pNLSF_Q15, psEncC->predictLPCOrder ); + silk_NLSF_VQ_weights_laroia( pNLSFW_Q5, pNLSF_Q15, psEncC->predictLPCOrder ); /* Update NLSF weights for interpolated NLSFs */ doInterpolate = ( psEncC->useInterpolatedNLSFs == 1 ) && ( psEncC->indices.NLSFInterpCoef_Q2 < 4 ); if( doInterpolate ) { /* Calculate the interpolated NLSF vector for the first half */ - SKP_Silk_interpolate( pNLSF0_temp_Q15, prev_NLSFq_Q15, pNLSF_Q15, + silk_interpolate( pNLSF0_temp_Q15, prev_NLSFq_Q15, pNLSF_Q15, psEncC->indices.NLSFInterpCoef_Q2, psEncC->predictLPCOrder ); /* Calculate first half NLSF weights for the interpolated NLSFs */ - SKP_Silk_NLSF_VQ_weights_laroia( pNLSFW0_temp_Q5, pNLSF0_temp_Q15, psEncC->predictLPCOrder ); + silk_NLSF_VQ_weights_laroia( pNLSFW0_temp_Q5, pNLSF0_temp_Q15, psEncC->predictLPCOrder ); /* Update NLSF weights with contribution from first half */ i_sqr_Q15 = SKP_LSHIFT( SKP_SMULBB( psEncC->indices.NLSFInterpCoef_Q2, psEncC->indices.NLSFInterpCoef_Q2 ), 11 ); @@ -81,20 +81,20 @@ void SKP_Silk_process_NLSFs( } TIC(NLSF_encode) - SKP_Silk_NLSF_encode( psEncC->indices.NLSFIndices, pNLSF_Q15, psEncC->psNLSF_CB, pNLSFW_Q5, + silk_NLSF_encode( psEncC->indices.NLSFIndices, pNLSF_Q15, psEncC->psNLSF_CB, pNLSFW_Q5, NLSF_mu_Q20, psEncC->NLSF_MSVQ_Survivors, psEncC->indices.signalType ); TOC(NLSF_encode) /* Convert quantized NLSFs back to LPC coefficients */ - SKP_Silk_NLSF2A_stable( PredCoef_Q12[ 1 ], pNLSF_Q15, psEncC->predictLPCOrder ); + silk_NLSF2A_stable( PredCoef_Q12[ 1 ], pNLSF_Q15, psEncC->predictLPCOrder ); if( doInterpolate ) { /* Calculate the interpolated, quantized LSF vector for the first half */ - SKP_Silk_interpolate( pNLSF0_temp_Q15, prev_NLSFq_Q15, pNLSF_Q15, + silk_interpolate( pNLSF0_temp_Q15, prev_NLSFq_Q15, pNLSF_Q15, psEncC->indices.NLSFInterpCoef_Q2, psEncC->predictLPCOrder ); /* Convert back to LPC coefficients */ - SKP_Silk_NLSF2A_stable( PredCoef_Q12[ 0 ], pNLSF0_temp_Q15, psEncC->predictLPCOrder ); + silk_NLSF2A_stable( PredCoef_Q12[ 0 ], pNLSF0_temp_Q15, psEncC->predictLPCOrder ); } else { /* Copy LPC coefficients for first half from second half */ diff --git a/silk/SKP_Silk_quant_LTP_gains.c b/silk/silk_quant_LTP_gains.c similarity index 90% rename from silk/SKP_Silk_quant_LTP_gains.c rename to silk/silk_quant_LTP_gains.c index 506cded1..27be18ec 100644 --- a/silk/SKP_Silk_quant_LTP_gains.c +++ b/silk/silk_quant_LTP_gains.c @@ -25,9 +25,9 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" +#include "silk_main.h" -void SKP_Silk_quant_LTP_gains( +void silk_quant_LTP_gains( SKP_int16 B_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* I/O (un)quantized LTP gains */ SKP_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook Index */ SKP_int8 *periodicity_index, /* O Periodicity Index */ @@ -53,9 +53,9 @@ TIC(quant_LTP) /***************************************************/ min_rate_dist_Q14 = SKP_int32_MAX; for( k = 0; k < 3; k++ ) { - cl_ptr_Q5 = SKP_Silk_LTP_gain_BITS_Q5_ptrs[ k ]; - cbk_ptr_Q7 = SKP_Silk_LTP_vq_ptrs_Q7[ k ]; - cbk_size = SKP_Silk_LTP_vq_sizes[ k ]; + cl_ptr_Q5 = silk_LTP_gain_BITS_Q5_ptrs[ k ]; + cbk_ptr_Q7 = silk_LTP_vq_ptrs_Q7[ k ]; + cbk_size = silk_LTP_vq_sizes[ k ]; /* Setup pointer to first subframe */ W_Q18_ptr = W_Q18; @@ -64,7 +64,7 @@ TIC(quant_LTP) rate_dist_Q14 = 0; for( j = 0; j < nb_subfr; j++ ) { - SKP_Silk_VQ_WMat_EC( + silk_VQ_WMat_EC( &temp_idx[ j ], /* O index of best codebook vector */ &rate_dist_Q14_subfr, /* O best weighted quantization error + mu * rate */ b_Q14_ptr, /* I input vector to be quantized */ @@ -91,12 +91,12 @@ TIC(quant_LTP) } /* Break early in low-complexity mode if rate distortion is below threshold */ - if( lowComplexity && ( rate_dist_Q14 < SKP_Silk_LTP_gain_middle_avg_RD_Q14 ) ) { + if( lowComplexity && ( rate_dist_Q14 < silk_LTP_gain_middle_avg_RD_Q14 ) ) { break; } } - cbk_ptr_Q7 = SKP_Silk_LTP_vq_ptrs_Q7[ *periodicity_index ]; + cbk_ptr_Q7 = silk_LTP_vq_ptrs_Q7[ *periodicity_index ]; for( j = 0; j < nb_subfr; j++ ) { for( k = 0; k < LTP_ORDER; k++ ) { B_Q14[ j * LTP_ORDER + k ] = SKP_LSHIFT( cbk_ptr_Q7[ cbk_index[ j ] * LTP_ORDER + k ], 7 ); diff --git a/silk/SKP_Silk_resampler.c b/silk/silk_resampler.c similarity index 76% rename from silk/SKP_Silk_resampler.c rename to silk/silk_resampler.c index 980f81fe..fa78fc95 100644 --- a/silk/SKP_Silk_resampler.c +++ b/silk/silk_resampler.c @@ -25,15 +25,6 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -/* * - * File Name: SKP_Silk_resampler.c * - * * - * Description: Interface to collection of resamplers * - * * - * Copyright 2010 (c), Skype Limited * - * All rights reserved. * - * */ - /* Matrix of resampling methods used: * Fs_out (kHz) * 8 12 16 24 32 44.1 48 @@ -60,7 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * Output signals sampled above 48 kHz are upsampled from at most 48 kHz. */ -#include "SKP_Silk_resampler_private.h" +#include "silk_resampler_private.h" /* Greatest common divisor */ static SKP_int32 gcd( @@ -78,8 +69,8 @@ static SKP_int32 gcd( } /* Initialize/reset the resampler state for a given pair of input/output sampling rates */ -SKP_int SKP_Silk_resampler_init( - SKP_Silk_resampler_state_struct *S, /* I/O: Resampler state */ +SKP_int silk_resampler_init( + silk_resampler_state_struct *S, /* I/O: Resampler state */ SKP_int32 Fs_Hz_in, /* I: Input sampling rate (Hz) */ SKP_int32 Fs_Hz_out /* I: Output sampling rate (Hz) */ ) @@ -87,7 +78,7 @@ SKP_int SKP_Silk_resampler_init( SKP_int32 cycleLen, cyclesPerBatch, up2 = 0, down2 = 0; /* Clear state */ - SKP_memset( S, 0, sizeof( SKP_Silk_resampler_state_struct ) ); + SKP_memset( S, 0, sizeof( silk_resampler_state_struct ) ); /* Input checking */ #if RESAMPLER_SUPPORT_ABOVE_48KHZ @@ -103,10 +94,10 @@ SKP_int SKP_Silk_resampler_init( /* Determine pre downsampling and post upsampling */ if( Fs_Hz_in > 96000 ) { S->nPreDownsamplers = 2; - S->down_pre_function = SKP_Silk_resampler_private_down4; + S->down_pre_function = silk_resampler_private_down4; } else if( Fs_Hz_in > 48000 ) { S->nPreDownsamplers = 1; - S->down_pre_function = SKP_Silk_resampler_down2; + S->down_pre_function = silk_resampler_down2; } else { S->nPreDownsamplers = 0; S->down_pre_function = NULL; @@ -114,10 +105,10 @@ SKP_int SKP_Silk_resampler_init( if( Fs_Hz_out > 96000 ) { S->nPostUpsamplers = 2; - S->up_post_function = SKP_Silk_resampler_private_up4; + S->up_post_function = silk_resampler_private_up4; } else if( Fs_Hz_out > 48000 ) { S->nPostUpsamplers = 1; - S->up_post_function = SKP_Silk_resampler_up2; + S->up_post_function = silk_resampler_up2; } else { S->nPostUpsamplers = 0; S->up_post_function = NULL; @@ -160,81 +151,81 @@ SKP_int SKP_Silk_resampler_init( /* Upsample */ if( Fs_Hz_out == SKP_MUL( Fs_Hz_in, 2 ) ) { /* Fs_out : Fs_in = 2 : 1 */ /* Special case: directly use 2x upsampler */ - S->resampler_function = SKP_Silk_resampler_private_up2_HQ_wrapper; + S->resampler_function = silk_resampler_private_up2_HQ_wrapper; } else { /* Default resampler */ - S->resampler_function = SKP_Silk_resampler_private_IIR_FIR; + S->resampler_function = silk_resampler_private_IIR_FIR; up2 = 1; if( Fs_Hz_in > 24000 ) { /* Low-quality all-pass upsampler */ - S->up2_function = SKP_Silk_resampler_up2; + S->up2_function = silk_resampler_up2; } else { /* High-quality all-pass upsampler */ - S->up2_function = SKP_Silk_resampler_private_up2_HQ; + S->up2_function = silk_resampler_private_up2_HQ; } } } else if ( Fs_Hz_out < Fs_Hz_in ) { /* Downsample */ if( SKP_MUL( Fs_Hz_out, 4 ) == SKP_MUL( Fs_Hz_in, 3 ) ) { /* Fs_out : Fs_in = 3 : 4 */ S->FIR_Fracs = 3; - S->Coefs = SKP_Silk_Resampler_3_4_COEFS; - S->resampler_function = SKP_Silk_resampler_private_down_FIR; + S->Coefs = silk_Resampler_3_4_COEFS; + S->resampler_function = silk_resampler_private_down_FIR; } else if( SKP_MUL( Fs_Hz_out, 3 ) == SKP_MUL( Fs_Hz_in, 2 ) ) { /* Fs_out : Fs_in = 2 : 3 */ S->FIR_Fracs = 2; - S->Coefs = SKP_Silk_Resampler_2_3_COEFS; - S->resampler_function = SKP_Silk_resampler_private_down_FIR; + S->Coefs = silk_Resampler_2_3_COEFS; + S->resampler_function = silk_resampler_private_down_FIR; } else if( SKP_MUL( Fs_Hz_out, 2 ) == Fs_Hz_in ) { /* Fs_out : Fs_in = 1 : 2 */ S->FIR_Fracs = 1; - S->Coefs = SKP_Silk_Resampler_1_2_COEFS; - S->resampler_function = SKP_Silk_resampler_private_down_FIR; + S->Coefs = silk_Resampler_1_2_COEFS; + S->resampler_function = silk_resampler_private_down_FIR; } else if( SKP_MUL( Fs_Hz_out, 8 ) == SKP_MUL( Fs_Hz_in, 3 ) ) { /* Fs_out : Fs_in = 3 : 8 */ S->FIR_Fracs = 3; - S->Coefs = SKP_Silk_Resampler_3_8_COEFS; - S->resampler_function = SKP_Silk_resampler_private_down_FIR; + S->Coefs = silk_Resampler_3_8_COEFS; + S->resampler_function = silk_resampler_private_down_FIR; } else if( SKP_MUL( Fs_Hz_out, 3 ) == Fs_Hz_in ) { /* Fs_out : Fs_in = 1 : 3 */ S->FIR_Fracs = 1; - S->Coefs = SKP_Silk_Resampler_1_3_COEFS; - S->resampler_function = SKP_Silk_resampler_private_down_FIR; + S->Coefs = silk_Resampler_1_3_COEFS; + S->resampler_function = silk_resampler_private_down_FIR; } else if( SKP_MUL( Fs_Hz_out, 4 ) == Fs_Hz_in ) { /* Fs_out : Fs_in = 1 : 4 */ S->FIR_Fracs = 1; down2 = 1; - S->Coefs = SKP_Silk_Resampler_1_2_COEFS; - S->resampler_function = SKP_Silk_resampler_private_down_FIR; + S->Coefs = silk_Resampler_1_2_COEFS; + S->resampler_function = silk_resampler_private_down_FIR; } else if( SKP_MUL( Fs_Hz_out, 6 ) == Fs_Hz_in ) { /* Fs_out : Fs_in = 1 : 6 */ S->FIR_Fracs = 1; down2 = 1; - S->Coefs = SKP_Silk_Resampler_1_3_COEFS; - S->resampler_function = SKP_Silk_resampler_private_down_FIR; + S->Coefs = silk_Resampler_1_3_COEFS; + S->resampler_function = silk_resampler_private_down_FIR; } else if( SKP_MUL( Fs_Hz_out, 441 ) == SKP_MUL( Fs_Hz_in, 80 ) ) { /* Fs_out : Fs_in = 80 : 441 */ - S->Coefs = SKP_Silk_Resampler_80_441_ARMA4_COEFS; - S->resampler_function = SKP_Silk_resampler_private_IIR_FIR; + S->Coefs = silk_Resampler_80_441_ARMA4_COEFS; + S->resampler_function = silk_resampler_private_IIR_FIR; } else if( SKP_MUL( Fs_Hz_out, 441 ) == SKP_MUL( Fs_Hz_in, 120 ) ) { /* Fs_out : Fs_in = 120 : 441 */ - S->Coefs = SKP_Silk_Resampler_120_441_ARMA4_COEFS; - S->resampler_function = SKP_Silk_resampler_private_IIR_FIR; + S->Coefs = silk_Resampler_120_441_ARMA4_COEFS; + S->resampler_function = silk_resampler_private_IIR_FIR; } else if( SKP_MUL( Fs_Hz_out, 441 ) == SKP_MUL( Fs_Hz_in, 160 ) ) { /* Fs_out : Fs_in = 160 : 441 */ - S->Coefs = SKP_Silk_Resampler_160_441_ARMA4_COEFS; - S->resampler_function = SKP_Silk_resampler_private_IIR_FIR; + S->Coefs = silk_Resampler_160_441_ARMA4_COEFS; + S->resampler_function = silk_resampler_private_IIR_FIR; } else if( SKP_MUL( Fs_Hz_out, 441 ) == SKP_MUL( Fs_Hz_in, 240 ) ) { /* Fs_out : Fs_in = 240 : 441 */ - S->Coefs = SKP_Silk_Resampler_240_441_ARMA4_COEFS; - S->resampler_function = SKP_Silk_resampler_private_IIR_FIR; + S->Coefs = silk_Resampler_240_441_ARMA4_COEFS; + S->resampler_function = silk_resampler_private_IIR_FIR; } else if( SKP_MUL( Fs_Hz_out, 441 ) == SKP_MUL( Fs_Hz_in, 320 ) ) { /* Fs_out : Fs_in = 320 : 441 */ - S->Coefs = SKP_Silk_Resampler_320_441_ARMA4_COEFS; - S->resampler_function = SKP_Silk_resampler_private_IIR_FIR; + S->Coefs = silk_Resampler_320_441_ARMA4_COEFS; + S->resampler_function = silk_resampler_private_IIR_FIR; } else { /* Default resampler */ - S->resampler_function = SKP_Silk_resampler_private_IIR_FIR; + S->resampler_function = silk_resampler_private_IIR_FIR; up2 = 1; if( Fs_Hz_in > 24000 ) { /* Low-quality all-pass upsampler */ - S->up2_function = SKP_Silk_resampler_up2; + S->up2_function = silk_resampler_up2; } else { /* High-quality all-pass upsampler */ - S->up2_function = SKP_Silk_resampler_private_up2_HQ; + S->up2_function = silk_resampler_private_up2_HQ; } } } else { /* Input and output sampling rates are equal: copy */ - S->resampler_function = SKP_Silk_resampler_private_copy; + S->resampler_function = silk_resampler_private_copy; } S->input2x = up2 | down2; @@ -252,8 +243,8 @@ SKP_int SKP_Silk_resampler_init( } /* Clear the states of all resampling filters, without resetting sampling rate ratio */ -SKP_int SKP_Silk_resampler_clear( - SKP_Silk_resampler_state_struct *S /* I/O: Resampler state */ +SKP_int silk_resampler_clear( + silk_resampler_state_struct *S /* I/O: Resampler state */ ) { /* Clear state */ @@ -268,8 +259,8 @@ SKP_int SKP_Silk_resampler_clear( } /* Resampler: convert from one sampling rate to another */ -SKP_int SKP_Silk_resampler( - SKP_Silk_resampler_state_struct *S, /* I/O: Resampler state */ +SKP_int silk_resampler( + silk_resampler_state_struct *S, /* I/O: Resampler state */ SKP_int16 out[], /* O: Output signal */ const SKP_int16 in[], /* I: Input signal */ SKP_int32 inLen /* I: Number of input samples */ diff --git a/silk/SKP_Silk_resampler_down2.c b/silk/silk_resampler_down2.c similarity index 77% rename from silk/SKP_Silk_resampler_down2.c rename to silk/silk_resampler_down2.c index f9f6c339..4d952ec5 100644 --- a/silk/SKP_Silk_resampler_down2.c +++ b/silk/silk_resampler_down2.c @@ -25,19 +25,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -/* * - * SKP_Silk_resampler_down2.c * - * * - * Downsample by a factor 2, mediocre quality * - * * - * Copyright 2010 (c), Skype Limited * - * */ - -#include "SKP_Silk_SigProc_FIX.h" -#include "SKP_Silk_resampler_rom.h" +#include "silk_SigProc_FIX.h" +#include "silk_resampler_rom.h" /* Downsample by a factor 2, mediocre quality */ -void SKP_Silk_resampler_down2( +void silk_resampler_down2( SKP_int32 *S, /* I/O: State vector [ 2 ] */ SKP_int16 *out, /* O: Output signal [ len ] */ const SKP_int16 *in, /* I: Input signal [ floor(len/2) ] */ @@ -47,8 +39,8 @@ void SKP_Silk_resampler_down2( SKP_int32 k, len2 = SKP_RSHIFT32( inLen, 1 ); SKP_int32 in32, out32, Y, X; - SKP_assert( SKP_Silk_resampler_down2_0 > 0 ); - SKP_assert( SKP_Silk_resampler_down2_1 < 0 ); + SKP_assert( silk_resampler_down2_0 > 0 ); + SKP_assert( silk_resampler_down2_1 < 0 ); /* Internal variables and state are in Q10 format */ for( k = 0; k < len2; k++ ) { @@ -57,7 +49,7 @@ void SKP_Silk_resampler_down2( /* All-pass section for even input sample */ Y = SKP_SUB32( in32, S[ 0 ] ); - X = SKP_SMLAWB( Y, Y, SKP_Silk_resampler_down2_1 ); + X = SKP_SMLAWB( Y, Y, silk_resampler_down2_1 ); out32 = SKP_ADD32( S[ 0 ], X ); S[ 0 ] = SKP_ADD32( in32, X ); @@ -66,7 +58,7 @@ void SKP_Silk_resampler_down2( /* All-pass section for odd input sample, and add to output of previous section */ Y = SKP_SUB32( in32, S[ 1 ] ); - X = SKP_SMULWB( Y, SKP_Silk_resampler_down2_0 ); + X = SKP_SMULWB( Y, silk_resampler_down2_0 ); out32 = SKP_ADD32( out32, S[ 1 ] ); out32 = SKP_ADD32( out32, X ); S[ 1 ] = SKP_ADD32( in32, X ); diff --git a/silk/SKP_Silk_resampler_down2_3.c b/silk/silk_resampler_down2_3.c similarity index 69% rename from silk/SKP_Silk_resampler_down2_3.c rename to silk/silk_resampler_down2_3.c index 120f296d..42abad5b 100644 --- a/silk/SKP_Silk_resampler_down2_3.c +++ b/silk/silk_resampler_down2_3.c @@ -25,21 +25,13 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -/* * - * SKP_Silk_resampler_down2_3.c * - * * - * Downsample by a factor 2/3, low quality * - * * - * Copyright 2010 (c), Skype Limited * - * */ - -#include "SKP_Silk_SigProc_FIX.h" -#include "SKP_Silk_resampler_private.h" +#include "silk_SigProc_FIX.h" +#include "silk_resampler_private.h" #define ORDER_FIR 4 /* Downsample by a factor 2/3, low quality */ -void SKP_Silk_resampler_down2_3( +void silk_resampler_down2_3( SKP_int32 *S, /* I/O: State vector [ 6 ] */ SKP_int16 *out, /* O: Output signal [ floor(2*inLen/3) ] */ const SKP_int16 *in, /* I: Input signal [ inLen ] */ @@ -58,26 +50,26 @@ void SKP_Silk_resampler_down2_3( nSamplesIn = SKP_min( inLen, RESAMPLER_MAX_BATCH_SIZE_IN ); /* Second-order AR filter (output in Q8) */ - SKP_Silk_resampler_private_AR2( &S[ ORDER_FIR ], &buf[ ORDER_FIR ], in, - SKP_Silk_Resampler_2_3_COEFS_LQ, nSamplesIn ); + silk_resampler_private_AR2( &S[ ORDER_FIR ], &buf[ ORDER_FIR ], in, + silk_Resampler_2_3_COEFS_LQ, nSamplesIn ); /* Interpolate filtered signal */ buf_ptr = buf; counter = nSamplesIn; while( counter > 2 ) { /* Inner product */ - res_Q6 = SKP_SMULWB( buf_ptr[ 0 ], SKP_Silk_Resampler_2_3_COEFS_LQ[ 2 ] ); - res_Q6 = SKP_SMLAWB( res_Q6, buf_ptr[ 1 ], SKP_Silk_Resampler_2_3_COEFS_LQ[ 3 ] ); - res_Q6 = SKP_SMLAWB( res_Q6, buf_ptr[ 2 ], SKP_Silk_Resampler_2_3_COEFS_LQ[ 5 ] ); - res_Q6 = SKP_SMLAWB( res_Q6, buf_ptr[ 3 ], SKP_Silk_Resampler_2_3_COEFS_LQ[ 4 ] ); + res_Q6 = SKP_SMULWB( buf_ptr[ 0 ], silk_Resampler_2_3_COEFS_LQ[ 2 ] ); + res_Q6 = SKP_SMLAWB( res_Q6, buf_ptr[ 1 ], silk_Resampler_2_3_COEFS_LQ[ 3 ] ); + res_Q6 = SKP_SMLAWB( res_Q6, buf_ptr[ 2 ], silk_Resampler_2_3_COEFS_LQ[ 5 ] ); + res_Q6 = SKP_SMLAWB( res_Q6, buf_ptr[ 3 ], silk_Resampler_2_3_COEFS_LQ[ 4 ] ); /* Scale down, saturate and store in output array */ *out++ = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( res_Q6, 6 ) ); - res_Q6 = SKP_SMULWB( buf_ptr[ 1 ], SKP_Silk_Resampler_2_3_COEFS_LQ[ 4 ] ); - res_Q6 = SKP_SMLAWB( res_Q6, buf_ptr[ 2 ], SKP_Silk_Resampler_2_3_COEFS_LQ[ 5 ] ); - res_Q6 = SKP_SMLAWB( res_Q6, buf_ptr[ 3 ], SKP_Silk_Resampler_2_3_COEFS_LQ[ 3 ] ); - res_Q6 = SKP_SMLAWB( res_Q6, buf_ptr[ 4 ], SKP_Silk_Resampler_2_3_COEFS_LQ[ 2 ] ); + res_Q6 = SKP_SMULWB( buf_ptr[ 1 ], silk_Resampler_2_3_COEFS_LQ[ 4 ] ); + res_Q6 = SKP_SMLAWB( res_Q6, buf_ptr[ 2 ], silk_Resampler_2_3_COEFS_LQ[ 5 ] ); + res_Q6 = SKP_SMLAWB( res_Q6, buf_ptr[ 3 ], silk_Resampler_2_3_COEFS_LQ[ 3 ] ); + res_Q6 = SKP_SMLAWB( res_Q6, buf_ptr[ 4 ], silk_Resampler_2_3_COEFS_LQ[ 2 ] ); /* Scale down, saturate and store in output array */ *out++ = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( res_Q6, 6 ) ); diff --git a/silk/SKP_Silk_resampler_down3.c b/silk/silk_resampler_down3.c similarity index 77% rename from silk/SKP_Silk_resampler_down3.c rename to silk/silk_resampler_down3.c index 70c86f66..cf445f76 100644 --- a/silk/SKP_Silk_resampler_down3.c +++ b/silk/silk_resampler_down3.c @@ -25,21 +25,13 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -/* * - * SKP_Silk_resampler_down3.c * - * * - * Downsample by a factor 3, low quality * - * * - * Copyright 2010 (c), Skype Limited * - * */ - -#include "SKP_Silk_SigProc_FIX.h" -#include "SKP_Silk_resampler_private.h" +#include "silk_SigProc_FIX.h" +#include "silk_resampler_private.h" #define ORDER_FIR 6 /* Downsample by a factor 3, low quality */ -void SKP_Silk_resampler_down3( +void silk_resampler_down3( SKP_int32 *S, /* I/O: State vector [ 8 ] */ SKP_int16 *out, /* O: Output signal [ floor(inLen/3) ] */ const SKP_int16 *in, /* I: Input signal [ inLen ] */ @@ -58,17 +50,17 @@ void SKP_Silk_resampler_down3( nSamplesIn = SKP_min( inLen, RESAMPLER_MAX_BATCH_SIZE_IN ); /* Second-order AR filter (output in Q8) */ - SKP_Silk_resampler_private_AR2( &S[ ORDER_FIR ], &buf[ ORDER_FIR ], in, - SKP_Silk_Resampler_1_3_COEFS_LQ, nSamplesIn ); + silk_resampler_private_AR2( &S[ ORDER_FIR ], &buf[ ORDER_FIR ], in, + silk_Resampler_1_3_COEFS_LQ, nSamplesIn ); /* Interpolate filtered signal */ buf_ptr = buf; counter = nSamplesIn; while( counter > 2 ) { /* Inner product */ - res_Q6 = SKP_SMULWB( SKP_ADD32( buf_ptr[ 0 ], buf_ptr[ 5 ] ), SKP_Silk_Resampler_1_3_COEFS_LQ[ 2 ] ); - res_Q6 = SKP_SMLAWB( res_Q6, SKP_ADD32( buf_ptr[ 1 ], buf_ptr[ 4 ] ), SKP_Silk_Resampler_1_3_COEFS_LQ[ 3 ] ); - res_Q6 = SKP_SMLAWB( res_Q6, SKP_ADD32( buf_ptr[ 2 ], buf_ptr[ 3 ] ), SKP_Silk_Resampler_1_3_COEFS_LQ[ 4 ] ); + res_Q6 = SKP_SMULWB( SKP_ADD32( buf_ptr[ 0 ], buf_ptr[ 5 ] ), silk_Resampler_1_3_COEFS_LQ[ 2 ] ); + res_Q6 = SKP_SMLAWB( res_Q6, SKP_ADD32( buf_ptr[ 1 ], buf_ptr[ 4 ] ), silk_Resampler_1_3_COEFS_LQ[ 3 ] ); + res_Q6 = SKP_SMLAWB( res_Q6, SKP_ADD32( buf_ptr[ 2 ], buf_ptr[ 3 ] ), silk_Resampler_1_3_COEFS_LQ[ 4 ] ); /* Scale down, saturate and store in output array */ *out++ = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( res_Q6, 6 ) ); diff --git a/silk/SKP_Silk_resampler_private.h b/silk/silk_resampler_private.h similarity index 82% rename from silk/SKP_Silk_resampler_private.h rename to silk/silk_resampler_private.h index 0402b484..fc973816 100644 --- a/silk/SKP_Silk_resampler_private.h +++ b/silk/silk_resampler_private.h @@ -25,32 +25,22 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -/* * - * File Name: SKP_Silk_resampler_structs.h * - * * - * Description: Structs for IIR/FIR resamplers * - * * - * Copyright 2010 (c), Skype Limited * - * All rights reserved. * - * * - * */ - -#ifndef SKP_Silk_RESAMPLER_H -#define SKP_Silk_RESAMPLER_H +#ifndef SILK_RESAMPLER_H +#define SILK_RESAMPLER_H #ifdef __cplusplus extern "C" { #endif -#include "SKP_Silk_SigProc_FIX.h" -#include "SKP_Silk_resampler_structs.h" -#include "SKP_Silk_resampler_rom.h" +#include "silk_SigProc_FIX.h" +#include "silk_resampler_structs.h" +#include "silk_resampler_rom.h" /* Number of input samples to process in the inner loop */ #define RESAMPLER_MAX_BATCH_SIZE_IN 480 /* Description: Hybrid IIR/FIR polyphase implementation of resampling */ -void SKP_Silk_resampler_private_IIR_FIR( +void silk_resampler_private_IIR_FIR( void *SS, /* I/O: Resampler state */ SKP_int16 out[], /* O: Output signal */ const SKP_int16 in[], /* I: Input signal */ @@ -58,7 +48,7 @@ void SKP_Silk_resampler_private_IIR_FIR( ); /* Description: Hybrid IIR/FIR polyphase implementation of resampling */ -void SKP_Silk_resampler_private_down_FIR( +void silk_resampler_private_down_FIR( void *SS, /* I/O: Resampler state */ SKP_int16 out[], /* O: Output signal */ const SKP_int16 in[], /* I: Input signal */ @@ -66,7 +56,7 @@ void SKP_Silk_resampler_private_down_FIR( ); /* Copy */ -void SKP_Silk_resampler_private_copy( +void silk_resampler_private_copy( void *SS, /* I/O: Resampler state (unused) */ SKP_int16 out[], /* O: Output signal */ const SKP_int16 in[], /* I: Input signal */ @@ -74,7 +64,7 @@ void SKP_Silk_resampler_private_copy( ); /* Upsample by a factor 2, high quality */ -void SKP_Silk_resampler_private_up2_HQ_wrapper( +void silk_resampler_private_up2_HQ_wrapper( void *SS, /* I/O: Resampler state (unused) */ SKP_int16 *out, /* O: Output signal [ 2 * len ] */ const SKP_int16 *in, /* I: Input signal [ len ] */ @@ -82,7 +72,7 @@ void SKP_Silk_resampler_private_up2_HQ_wrapper( ); /* Upsample by a factor 2, high quality */ -void SKP_Silk_resampler_private_up2_HQ( +void silk_resampler_private_up2_HQ( SKP_int32 *S, /* I/O: Resampler state [ 6 ] */ SKP_int16 *out, /* O: Output signal [ 2 * len ] */ const SKP_int16 *in, /* I: Input signal [ len ] */ @@ -90,7 +80,7 @@ void SKP_Silk_resampler_private_up2_HQ( ); /* Upsample 4x, low quality */ -void SKP_Silk_resampler_private_up4( +void silk_resampler_private_up4( SKP_int32 *S, /* I/O: State vector [ 2 ] */ SKP_int16 *out, /* O: Output signal [ 4 * len ] */ const SKP_int16 *in, /* I: Input signal [ len ] */ @@ -98,7 +88,7 @@ void SKP_Silk_resampler_private_up4( ); /* Downsample 4x, low quality */ -void SKP_Silk_resampler_private_down4( +void silk_resampler_private_down4( SKP_int32 *S, /* I/O: State vector [ 2 ] */ SKP_int16 *out, /* O: Output signal [ floor(len/2) ] */ const SKP_int16 *in, /* I: Input signal [ len ] */ @@ -106,7 +96,7 @@ void SKP_Silk_resampler_private_down4( ); /* Second order AR filter */ -void SKP_Silk_resampler_private_AR2( +void silk_resampler_private_AR2( SKP_int32 S[], /* I/O: State vector [ 2 ] */ SKP_int32 out_Q8[], /* O: Output signal */ const SKP_int16 in[], /* I: Input signal */ @@ -115,7 +105,7 @@ void SKP_Silk_resampler_private_AR2( ); /* Fourth order ARMA filter */ -void SKP_Silk_resampler_private_ARMA4( +void silk_resampler_private_ARMA4( SKP_int32 S[], /* I/O: State vector [ 4 ] */ SKP_int16 out[], /* O: Output signal */ const SKP_int16 in[], /* I: Input signal */ @@ -127,5 +117,5 @@ void SKP_Silk_resampler_private_ARMA4( #ifdef __cplusplus } #endif -#endif // SKP_Silk_RESAMPLER_H +#endif // SILK_RESAMPLER_H diff --git a/silk/SKP_Silk_resampler_private_AR2.c b/silk/silk_resampler_private_AR2.c similarity index 81% rename from silk/SKP_Silk_resampler_private_AR2.c rename to silk/silk_resampler_private_AR2.c index 5cc673ad..3279c7ee 100644 --- a/silk/SKP_Silk_resampler_private_AR2.c +++ b/silk/silk_resampler_private_AR2.c @@ -25,19 +25,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -/* * - * SKP_Silk_resampler_private_AR2. c * - * * - * Second order AR filter with single delay elements * - * * - * Copyright 2010 (c), Skype Limited * - * */ - -#include "SKP_Silk_SigProc_FIX.h" -#include "SKP_Silk_resampler_private.h" +#include "silk_SigProc_FIX.h" +#include "silk_resampler_private.h" /* Second order AR filter with single delay elements */ -void SKP_Silk_resampler_private_AR2( +void silk_resampler_private_AR2( SKP_int32 S[], /* I/O: State vector [ 2 ] */ SKP_int32 out_Q8[], /* O: Output signal */ const SKP_int16 in[], /* I: Input signal */ diff --git a/silk/SKP_Silk_resampler_private_ARMA4.c b/silk/silk_resampler_private_ARMA4.c similarity index 85% rename from silk/SKP_Silk_resampler_private_ARMA4.c rename to silk/silk_resampler_private_ARMA4.c index 922c5753..c277238d 100644 --- a/silk/SKP_Silk_resampler_private_ARMA4.c +++ b/silk/silk_resampler_private_ARMA4.c @@ -25,16 +25,8 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -/* * - * SKP_Silk_resampler_private_ARMA4.c * - * * - * Fourth order ARMA filter, applies 64x gain * - * * - * Copyright 2010 (c), Skype Limited * - * */ - -#include "SKP_Silk_SigProc_FIX.h" -#include "SKP_Silk_resampler_private.h" +#include "silk_SigProc_FIX.h" +#include "silk_resampler_private.h" /* Fourth order ARMA filter */ /* Internally operates as two biquad filters in sequence. */ @@ -42,7 +34,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* Coeffients are stored in a packed format: */ /* { B1_Q14[1], B2_Q14[1], -A1_Q14[1], -A1_Q14[2], -A2_Q14[1], -A2_Q14[2], gain_Q16 } */ /* where it is assumed that B*_Q14[0], B*_Q14[2], A*_Q14[0] are all 16384 */ -void SKP_Silk_resampler_private_ARMA4( + +void silk_resampler_private_ARMA4( SKP_int32 S[], /* I/O: State vector [ 4 ] */ SKP_int16 out[], /* O: Output signal */ const SKP_int16 in[], /* I: Input signal */ diff --git a/silk/SKP_Silk_resampler_private_IIR_FIR.c b/silk/silk_resampler_private_IIR_FIR.c similarity index 69% rename from silk/SKP_Silk_resampler_private_IIR_FIR.c rename to silk/silk_resampler_private_IIR_FIR.c index df9a031d..ba4b9ba3 100644 --- a/silk/SKP_Silk_resampler_private_IIR_FIR.c +++ b/silk/silk_resampler_private_IIR_FIR.c @@ -25,18 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -/* * - * File Name: SKP_Silk_resampler_private_IIR_FIR.c * - * * - * Description: Hybrid IIR/FIR polyphase implementation of resampling * - * * - * Copyright 2010 (c), Skype Limited * - * All rights reserved. * - * */ +#include "silk_SigProc_FIX.h" +#include "silk_resampler_private.h" -#include "SKP_Silk_SigProc_FIX.h" -#include "SKP_Silk_resampler_private.h" -SKP_INLINE SKP_int16 *SKP_Silk_resampler_private_IIR_FIR_INTERPOL( +SKP_INLINE SKP_int16 *silk_resampler_private_IIR_FIR_INTERPOL( SKP_int16 * out, SKP_int16 * buf, SKP_int32 max_index_Q16 , SKP_int32 index_increment_Q16 ){ SKP_int32 index_Q16, res_Q15; SKP_int16 *buf_ptr; @@ -46,25 +38,25 @@ SKP_INLINE SKP_int16 *SKP_Silk_resampler_private_IIR_FIR_INTERPOL( table_index = SKP_SMULWB( index_Q16 & 0xFFFF, 144 ); buf_ptr = &buf[ index_Q16 >> 16 ]; - res_Q15 = SKP_SMULBB( buf_ptr[ 0 ], SKP_Silk_resampler_frac_FIR_144[ table_index ][ 0 ] ); - res_Q15 = SKP_SMLABB( res_Q15, buf_ptr[ 1 ], SKP_Silk_resampler_frac_FIR_144[ table_index ][ 1 ] ); - res_Q15 = SKP_SMLABB( res_Q15, buf_ptr[ 2 ], SKP_Silk_resampler_frac_FIR_144[ table_index ][ 2 ] ); - res_Q15 = SKP_SMLABB( res_Q15, buf_ptr[ 3 ], SKP_Silk_resampler_frac_FIR_144[ 143 - table_index ][ 2 ] ); - res_Q15 = SKP_SMLABB( res_Q15, buf_ptr[ 4 ], SKP_Silk_resampler_frac_FIR_144[ 143 - table_index ][ 1 ] ); - res_Q15 = SKP_SMLABB( res_Q15, buf_ptr[ 5 ], SKP_Silk_resampler_frac_FIR_144[ 143 - table_index ][ 0 ] ); + res_Q15 = SKP_SMULBB( buf_ptr[ 0 ], silk_resampler_frac_FIR_144[ table_index ][ 0 ] ); + res_Q15 = SKP_SMLABB( res_Q15, buf_ptr[ 1 ], silk_resampler_frac_FIR_144[ table_index ][ 1 ] ); + res_Q15 = SKP_SMLABB( res_Q15, buf_ptr[ 2 ], silk_resampler_frac_FIR_144[ table_index ][ 2 ] ); + res_Q15 = SKP_SMLABB( res_Q15, buf_ptr[ 3 ], silk_resampler_frac_FIR_144[ 143 - table_index ][ 2 ] ); + res_Q15 = SKP_SMLABB( res_Q15, buf_ptr[ 4 ], silk_resampler_frac_FIR_144[ 143 - table_index ][ 1 ] ); + res_Q15 = SKP_SMLABB( res_Q15, buf_ptr[ 5 ], silk_resampler_frac_FIR_144[ 143 - table_index ][ 0 ] ); *out++ = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( res_Q15, 15 ) ); } return out; } /* Upsample using a combination of allpass-based 2x upsampling and FIR interpolation */ -void SKP_Silk_resampler_private_IIR_FIR( +void silk_resampler_private_IIR_FIR( void *SS, /* I/O: Resampler state */ SKP_int16 out[], /* O: Output signal */ const SKP_int16 in[], /* I: Input signal */ SKP_int32 inLen /* I: Number of input samples */ ) { - SKP_Silk_resampler_state_struct *S = (SKP_Silk_resampler_state_struct *)SS; + silk_resampler_state_struct *S = (silk_resampler_state_struct *)SS; SKP_int32 nSamplesIn; SKP_int32 max_index_Q16, index_increment_Q16; SKP_int16 buf[ 2 * RESAMPLER_MAX_BATCH_SIZE_IN + RESAMPLER_ORDER_FIR_144 ]; @@ -83,11 +75,11 @@ void SKP_Silk_resampler_private_IIR_FIR( S->up2_function( S->sIIR, &buf[ RESAMPLER_ORDER_FIR_144 ], in, nSamplesIn ); } else { /* Fourth-order ARMA filter */ - SKP_Silk_resampler_private_ARMA4( S->sIIR, &buf[ RESAMPLER_ORDER_FIR_144 ], in, S->Coefs, nSamplesIn ); + silk_resampler_private_ARMA4( S->sIIR, &buf[ RESAMPLER_ORDER_FIR_144 ], in, S->Coefs, nSamplesIn ); } max_index_Q16 = SKP_LSHIFT32( nSamplesIn, 16 + S->input2x ); /* +1 if 2x upsampling */ - out = SKP_Silk_resampler_private_IIR_FIR_INTERPOL(out, buf, max_index_Q16, index_increment_Q16); + out = silk_resampler_private_IIR_FIR_INTERPOL(out, buf, max_index_Q16, index_increment_Q16); in += nSamplesIn; inLen -= nSamplesIn; diff --git a/silk/SKP_Silk_resampler_private_copy.c b/silk/silk_resampler_private_copy.c similarity index 77% rename from silk/SKP_Silk_resampler_private_copy.c rename to silk/silk_resampler_private_copy.c index 7c5b0319..3eb6d6c6 100644 --- a/silk/SKP_Silk_resampler_private_copy.c +++ b/silk/silk_resampler_private_copy.c @@ -25,20 +25,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -/* * - * File Name: SKP_Silk_resampler_private_copy.c * - * * - * Description: Copy. * - * * - * Copyright 2010 (c), Skype Limited * - * All rights reserved. * - * */ - -#include "SKP_Silk_SigProc_FIX.h" -#include "SKP_Silk_resampler_private.h" +#include "silk_SigProc_FIX.h" +#include "silk_resampler_private.h" /* Copy */ -void SKP_Silk_resampler_private_copy( +void silk_resampler_private_copy( void *SS, /* I/O: Resampler state (unused) */ SKP_int16 out[], /* O: Output signal */ const SKP_int16 in[], /* I: Input signal */ diff --git a/silk/SKP_Silk_resampler_private_down4.c b/silk/silk_resampler_private_down4.c similarity index 78% rename from silk/SKP_Silk_resampler_private_down4.c rename to silk/silk_resampler_private_down4.c index 0d327c72..bdf42dc6 100644 --- a/silk/SKP_Silk_resampler_private_down4.c +++ b/silk/silk_resampler_private_down4.c @@ -25,19 +25,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -/* * - * SKP_Silk_resampler_private_down4.c * - * * - * Downsample by a factor 4 * - * * - * Copyright 2010 (c), Skype Limited * - * */ - -#include "SKP_Silk_SigProc_FIX.h" -#include "SKP_Silk_resampler_private.h" +#include "silk_SigProc_FIX.h" +#include "silk_resampler_private.h" /* Downsample by a factor 4. Note: very low quality, only use with input sampling rates above 96 kHz. */ -void SKP_Silk_resampler_private_down4( +void silk_resampler_private_down4( SKP_int32 *S, /* I/O: State vector [ 2 ] */ SKP_int16 *out, /* O: Output signal [ floor(len/2) ] */ const SKP_int16 *in, /* I: Input signal [ len ] */ @@ -47,8 +39,8 @@ void SKP_Silk_resampler_private_down4( SKP_int32 k, len4 = SKP_RSHIFT32( inLen, 2 ); SKP_int32 in32, out32, Y, X; - SKP_assert( SKP_Silk_resampler_down2_0 > 0 ); - SKP_assert( SKP_Silk_resampler_down2_1 < 0 ); + SKP_assert( silk_resampler_down2_0 > 0 ); + SKP_assert( silk_resampler_down2_1 < 0 ); /* Internal variables and state are in Q10 format */ for( k = 0; k < len4; k++ ) { @@ -57,7 +49,7 @@ void SKP_Silk_resampler_private_down4( /* All-pass section for even input sample */ Y = SKP_SUB32( in32, S[ 0 ] ); - X = SKP_SMLAWB( Y, Y, SKP_Silk_resampler_down2_1 ); + X = SKP_SMLAWB( Y, Y, silk_resampler_down2_1 ); out32 = SKP_ADD32( S[ 0 ], X ); S[ 0 ] = SKP_ADD32( in32, X ); @@ -66,7 +58,7 @@ void SKP_Silk_resampler_private_down4( /* All-pass section for odd input sample */ Y = SKP_SUB32( in32, S[ 1 ] ); - X = SKP_SMULWB( Y, SKP_Silk_resampler_down2_0 ); + X = SKP_SMULWB( Y, silk_resampler_down2_0 ); out32 = SKP_ADD32( out32, S[ 1 ] ); out32 = SKP_ADD32( out32, X ); S[ 1 ] = SKP_ADD32( in32, X ); diff --git a/silk/SKP_Silk_resampler_private_down_FIR.c b/silk/silk_resampler_private_down_FIR.c similarity index 82% rename from silk/SKP_Silk_resampler_private_down_FIR.c rename to silk/silk_resampler_private_down_FIR.c index d8e06d93..d0306a40 100644 --- a/silk/SKP_Silk_resampler_private_down_FIR.c +++ b/silk/silk_resampler_private_down_FIR.c @@ -25,18 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -/* * - * File Name: SKP_Silk_resampler_private_down_FIR.c * - * * - * Description: Hybrid IIR/FIR polyphase implementation of resampling * - * * - * Copyright 2010 (c), Skype Limited * - * All rights reserved. * - * */ +#include "silk_SigProc_FIX.h" +#include "silk_resampler_private.h" -#include "SKP_Silk_SigProc_FIX.h" -#include "SKP_Silk_resampler_private.h" -SKP_INLINE SKP_int16 *SKP_Silk_resampler_private_down_FIR_INTERPOL0( +SKP_INLINE SKP_int16 *silk_resampler_private_down_FIR_INTERPOL0( SKP_int16 *out, SKP_int32 *buf2, const SKP_int16 *FIR_Coefs, SKP_int32 max_index_Q16, SKP_int32 index_increment_Q16){ SKP_int32 index_Q16, res_Q6; @@ -61,7 +53,7 @@ SKP_INLINE SKP_int16 *SKP_Silk_resampler_private_down_FIR_INTERPOL0( return out; } -SKP_INLINE SKP_int16 *SKP_Silk_resampler_private_down_FIR_INTERPOL1( +SKP_INLINE SKP_int16 *silk_resampler_private_down_FIR_INTERPOL1( SKP_int16 *out, SKP_int32 *buf2, const SKP_int16 *FIR_Coefs, SKP_int32 max_index_Q16, SKP_int32 index_increment_Q16, SKP_int32 FIR_Fracs){ SKP_int32 index_Q16, res_Q6; @@ -103,14 +95,14 @@ SKP_INLINE SKP_int16 *SKP_Silk_resampler_private_down_FIR_INTERPOL1( /* Resample with a 2x downsampler (optional), a 2nd order AR filter followed by FIR interpolation */ -void SKP_Silk_resampler_private_down_FIR( +void silk_resampler_private_down_FIR( void *SS, /* I/O: Resampler state */ SKP_int16 out[], /* O: Output signal */ const SKP_int16 in[], /* I: Input signal */ SKP_int32 inLen /* I: Number of input samples */ ) { - SKP_Silk_resampler_state_struct *S = (SKP_Silk_resampler_state_struct *)SS; + silk_resampler_state_struct *S = (silk_resampler_state_struct *)SS; SKP_int32 nSamplesIn; SKP_int32 max_index_Q16, index_increment_Q16; SKP_int16 buf1[ RESAMPLER_MAX_BATCH_SIZE_IN / 2 ]; @@ -129,24 +121,24 @@ void SKP_Silk_resampler_private_down_FIR( if( S->input2x == 1 ) { /* Downsample 2x */ - SKP_Silk_resampler_down2( S->sDown2, buf1, in, nSamplesIn ); + silk_resampler_down2( S->sDown2, buf1, in, nSamplesIn ); nSamplesIn = SKP_RSHIFT32( nSamplesIn, 1 ); /* Second-order AR filter (output in Q8) */ - SKP_Silk_resampler_private_AR2( S->sIIR, &buf2[ RESAMPLER_DOWN_ORDER_FIR ], buf1, S->Coefs, nSamplesIn ); + silk_resampler_private_AR2( S->sIIR, &buf2[ RESAMPLER_DOWN_ORDER_FIR ], buf1, S->Coefs, nSamplesIn ); } else { /* Second-order AR filter (output in Q8) */ - SKP_Silk_resampler_private_AR2( S->sIIR, &buf2[ RESAMPLER_DOWN_ORDER_FIR ], in, S->Coefs, nSamplesIn ); + silk_resampler_private_AR2( S->sIIR, &buf2[ RESAMPLER_DOWN_ORDER_FIR ], in, S->Coefs, nSamplesIn ); } max_index_Q16 = SKP_LSHIFT32( nSamplesIn, 16 ); /* Interpolate filtered signal */ if( S->FIR_Fracs == 1 ) { - out = SKP_Silk_resampler_private_down_FIR_INTERPOL0(out, buf2, FIR_Coefs, max_index_Q16, index_increment_Q16); + out = silk_resampler_private_down_FIR_INTERPOL0(out, buf2, FIR_Coefs, max_index_Q16, index_increment_Q16); } else { - out = SKP_Silk_resampler_private_down_FIR_INTERPOL1(out, buf2, FIR_Coefs, max_index_Q16, index_increment_Q16, S->FIR_Fracs); + out = silk_resampler_private_down_FIR_INTERPOL1(out, buf2, FIR_Coefs, max_index_Q16, index_increment_Q16, S->FIR_Fracs); } in += nSamplesIn << S->input2x; diff --git a/silk/SKP_Silk_resampler_private_up2_HQ.c b/silk/silk_resampler_private_up2_HQ.c similarity index 72% rename from silk/SKP_Silk_resampler_private_up2_HQ.c rename to silk/silk_resampler_private_up2_HQ.c index b161f92d..860e41b5 100644 --- a/silk/SKP_Silk_resampler_private_up2_HQ.c +++ b/silk/silk_resampler_private_up2_HQ.c @@ -25,13 +25,13 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_SigProc_FIX.h" -#include "SKP_Silk_resampler_private.h" +#include "silk_SigProc_FIX.h" +#include "silk_resampler_private.h" /* Upsample by a factor 2, high quality */ /* Uses 2nd order allpass filters for the 2x upsampling, followed by a */ /* notch filter just above Nyquist. */ -void SKP_Silk_resampler_private_up2_HQ( +void silk_resampler_private_up2_HQ( SKP_int32 *S, /* I/O: Resampler state [ 6 ] */ SKP_int16 *out, /* O: Output signal [ 2 * len ] */ const SKP_int16 *in, /* I: Input signal [ len ] */ @@ -41,10 +41,10 @@ void SKP_Silk_resampler_private_up2_HQ( SKP_int32 k; SKP_int32 in32, out32_1, out32_2, Y, X; - SKP_assert( SKP_Silk_resampler_up2_hq_0[ 0 ] > 0 ); - SKP_assert( SKP_Silk_resampler_up2_hq_0[ 1 ] < 0 ); - SKP_assert( SKP_Silk_resampler_up2_hq_1[ 0 ] > 0 ); - SKP_assert( SKP_Silk_resampler_up2_hq_1[ 1 ] < 0 ); + SKP_assert( silk_resampler_up2_hq_0[ 0 ] > 0 ); + SKP_assert( silk_resampler_up2_hq_0[ 1 ] < 0 ); + SKP_assert( silk_resampler_up2_hq_1[ 0 ] > 0 ); + SKP_assert( silk_resampler_up2_hq_1[ 1 ] < 0 ); /* Internal variables and state are in Q10 format */ for( k = 0; k < len; k++ ) { @@ -53,57 +53,57 @@ void SKP_Silk_resampler_private_up2_HQ( /* First all-pass section for even output sample */ Y = SKP_SUB32( in32, S[ 0 ] ); - X = SKP_SMULWB( Y, SKP_Silk_resampler_up2_hq_0[ 0 ] ); + X = SKP_SMULWB( Y, silk_resampler_up2_hq_0[ 0 ] ); out32_1 = SKP_ADD32( S[ 0 ], X ); S[ 0 ] = SKP_ADD32( in32, X ); /* Second all-pass section for even output sample */ Y = SKP_SUB32( out32_1, S[ 1 ] ); - X = SKP_SMLAWB( Y, Y, SKP_Silk_resampler_up2_hq_0[ 1 ] ); + X = SKP_SMLAWB( Y, Y, silk_resampler_up2_hq_0[ 1 ] ); out32_2 = SKP_ADD32( S[ 1 ], X ); S[ 1 ] = SKP_ADD32( out32_1, X ); /* Biquad notch filter */ - out32_2 = SKP_SMLAWB( out32_2, S[ 5 ], SKP_Silk_resampler_up2_hq_notch[ 2 ] ); - out32_2 = SKP_SMLAWB( out32_2, S[ 4 ], SKP_Silk_resampler_up2_hq_notch[ 1 ] ); - out32_1 = SKP_SMLAWB( out32_2, S[ 4 ], SKP_Silk_resampler_up2_hq_notch[ 0 ] ); + out32_2 = SKP_SMLAWB( out32_2, S[ 5 ], silk_resampler_up2_hq_notch[ 2 ] ); + out32_2 = SKP_SMLAWB( out32_2, S[ 4 ], silk_resampler_up2_hq_notch[ 1 ] ); + out32_1 = SKP_SMLAWB( out32_2, S[ 4 ], silk_resampler_up2_hq_notch[ 0 ] ); S[ 5 ] = SKP_SUB32( out32_2, S[ 5 ] ); /* Apply gain in Q15, convert back to int16 and store to output */ out[ 2 * k ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT32( - SKP_SMLAWB( 256, out32_1, SKP_Silk_resampler_up2_hq_notch[ 3 ] ), 9 ) ); + SKP_SMLAWB( 256, out32_1, silk_resampler_up2_hq_notch[ 3 ] ), 9 ) ); /* First all-pass section for odd output sample */ Y = SKP_SUB32( in32, S[ 2 ] ); - X = SKP_SMULWB( Y, SKP_Silk_resampler_up2_hq_1[ 0 ] ); + X = SKP_SMULWB( Y, silk_resampler_up2_hq_1[ 0 ] ); out32_1 = SKP_ADD32( S[ 2 ], X ); S[ 2 ] = SKP_ADD32( in32, X ); /* Second all-pass section for odd output sample */ Y = SKP_SUB32( out32_1, S[ 3 ] ); - X = SKP_SMLAWB( Y, Y, SKP_Silk_resampler_up2_hq_1[ 1 ] ); + X = SKP_SMLAWB( Y, Y, silk_resampler_up2_hq_1[ 1 ] ); out32_2 = SKP_ADD32( S[ 3 ], X ); S[ 3 ] = SKP_ADD32( out32_1, X ); /* Biquad notch filter */ - out32_2 = SKP_SMLAWB( out32_2, S[ 4 ], SKP_Silk_resampler_up2_hq_notch[ 2 ] ); - out32_2 = SKP_SMLAWB( out32_2, S[ 5 ], SKP_Silk_resampler_up2_hq_notch[ 1 ] ); - out32_1 = SKP_SMLAWB( out32_2, S[ 5 ], SKP_Silk_resampler_up2_hq_notch[ 0 ] ); + out32_2 = SKP_SMLAWB( out32_2, S[ 4 ], silk_resampler_up2_hq_notch[ 2 ] ); + out32_2 = SKP_SMLAWB( out32_2, S[ 5 ], silk_resampler_up2_hq_notch[ 1 ] ); + out32_1 = SKP_SMLAWB( out32_2, S[ 5 ], silk_resampler_up2_hq_notch[ 0 ] ); S[ 4 ] = SKP_SUB32( out32_2, S[ 4 ] ); /* Apply gain in Q15, convert back to int16 and store to output */ out[ 2 * k + 1 ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT32( - SKP_SMLAWB( 256, out32_1, SKP_Silk_resampler_up2_hq_notch[ 3 ] ), 9 ) ); + SKP_SMLAWB( 256, out32_1, silk_resampler_up2_hq_notch[ 3 ] ), 9 ) ); } } -void SKP_Silk_resampler_private_up2_HQ_wrapper( +void silk_resampler_private_up2_HQ_wrapper( void *SS, /* I/O: Resampler state (unused) */ SKP_int16 *out, /* O: Output signal [ 2 * len ] */ const SKP_int16 *in, /* I: Input signal [ len ] */ SKP_int32 len /* I: Number of input samples */ ) { - SKP_Silk_resampler_state_struct *S = (SKP_Silk_resampler_state_struct *)SS; - SKP_Silk_resampler_private_up2_HQ( S->sIIR, out, in, len ); + silk_resampler_state_struct *S = (silk_resampler_state_struct *)SS; + silk_resampler_private_up2_HQ( S->sIIR, out, in, len ); } diff --git a/silk/SKP_Silk_resampler_private_up4.c b/silk/silk_resampler_private_up4.c similarity index 88% rename from silk/SKP_Silk_resampler_private_up4.c rename to silk/silk_resampler_private_up4.c index c099893d..84ccd54e 100644 --- a/silk/SKP_Silk_resampler_private_up4.c +++ b/silk/silk_resampler_private_up4.c @@ -25,11 +25,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_SigProc_FIX.h" -#include "SKP_Silk_resampler_private.h" +#include "silk_SigProc_FIX.h" +#include "silk_resampler_private.h" /* Upsample by a factor 4, Note: low quality, only use with output sampling rates above 96 kHz. */ -void SKP_Silk_resampler_private_up4( +void silk_resampler_private_up4( SKP_int32 *S, /* I/O: State vector [ 2 ] */ SKP_int16 *out, /* O: Output signal [ 4 * len ] */ const SKP_int16 *in, /* I: Input signal [ len ] */ @@ -40,8 +40,8 @@ void SKP_Silk_resampler_private_up4( SKP_int32 in32, out32, Y, X; SKP_int16 out16; - SKP_assert( SKP_Silk_resampler_up2_lq_0 > 0 ); - SKP_assert( SKP_Silk_resampler_up2_lq_1 < 0 ); + SKP_assert( silk_resampler_up2_lq_0 > 0 ); + SKP_assert( silk_resampler_up2_lq_1 < 0 ); /* Internal variables and state are in Q10 format */ for( k = 0; k < len; k++ ) { @@ -50,7 +50,7 @@ void SKP_Silk_resampler_private_up4( /* All-pass section for even output sample */ Y = SKP_SUB32( in32, S[ 0 ] ); - X = SKP_SMULWB( Y, SKP_Silk_resampler_up2_lq_0 ); + X = SKP_SMULWB( Y, silk_resampler_up2_lq_0 ); out32 = SKP_ADD32( S[ 0 ], X ); S[ 0 ] = SKP_ADD32( in32, X ); @@ -61,7 +61,7 @@ void SKP_Silk_resampler_private_up4( /* All-pass section for odd output sample */ Y = SKP_SUB32( in32, S[ 1 ] ); - X = SKP_SMLAWB( Y, Y, SKP_Silk_resampler_up2_lq_1 ); + X = SKP_SMLAWB( Y, Y, silk_resampler_up2_lq_1 ); out32 = SKP_ADD32( S[ 1 ], X ); S[ 1 ] = SKP_ADD32( in32, X ); diff --git a/silk/SKP_Silk_resampler_rom.c b/silk/silk_resampler_rom.c similarity index 71% rename from silk/SKP_Silk_resampler_rom.c rename to silk/silk_resampler_rom.c index 5a220c53..250fc567 100644 --- a/silk/SKP_Silk_resampler_rom.c +++ b/silk/silk_resampler_rom.c @@ -25,73 +25,62 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -/* * - * File Name: SKP_Silk_resampler_rom.c * - * * - * Description: Filter coefficients for IIR/FIR polyphase resampling * - * Total size: <600 Words (1.2 kB) * - * * - * Copyright 2010 (c), Skype Limited * - * All rights reserved. * - * */ +/* Filter coefficients for IIR/FIR polyphase resampling * + * Total size: < 600 Words (1.2 kB) */ -#include "SKP_Silk_resampler_private.h" +#include "silk_resampler_private.h" /* Tables for 2x downsampler */ -const SKP_int16 SKP_Silk_resampler_down2_0 = 9872; -const SKP_int16 SKP_Silk_resampler_down2_1 = 39809 - 65536; +const SKP_int16 silk_resampler_down2_0 = 9872; +const SKP_int16 silk_resampler_down2_1 = 39809 - 65536; /* Tables for 2x upsampler, low quality */ -const SKP_int16 SKP_Silk_resampler_up2_lq_0 = 8102; -const SKP_int16 SKP_Silk_resampler_up2_lq_1 = 36783 - 65536; +const SKP_int16 silk_resampler_up2_lq_0 = 8102; +const SKP_int16 silk_resampler_up2_lq_1 = 36783 - 65536; /* Tables for 2x upsampler, high quality */ -const SKP_int16 SKP_Silk_resampler_up2_hq_0[ 2 ] = { 4280, 33727 - 65536 }; -const SKP_int16 SKP_Silk_resampler_up2_hq_1[ 2 ] = { 16295, 54015 - 65536 }; -/* Matlab code for the notch filter coefficients: */ -/* B = [1, 0.14, 1]; A = [1, 0.08, 0.84]; G = 0.89; freqz(G * B, A, 2^14, 16e3); axis([0, 8000, -10, 1]); */ -/* fprintf('\t%6d, %6d, %6d, %6d\n', round(B(2)*2^16), round(-A(2)*2^16), round((1-A(3))*2^16), round(G*2^15)) */ -const SKP_int16 SKP_Silk_resampler_up2_hq_notch[ 4 ] = { 9175, -5243, 10486, 29164 }; -//const SKP_int16 SKP_Silk_resampler_up2_hq_notch[ 4 ] = { 6554, -3932, 6554, 30573 }; /* for hybrid mode? */ +const SKP_int16 silk_resampler_up2_hq_0[ 2 ] = { 4280, 33727 - 65536 }; +const SKP_int16 silk_resampler_up2_hq_1[ 2 ] = { 16295, 54015 - 65536 }; +const SKP_int16 silk_resampler_up2_hq_notch[ 4 ] = { 6554, -3932, 6554, 30573 }; /* Tables with IIR and FIR coefficients for fractional downsamplers (90 Words) */ -SKP_DWORD_ALIGN const SKP_int16 SKP_Silk_Resampler_3_4_COEFS[ 2 + 3 * RESAMPLER_DOWN_ORDER_FIR / 2 ] = { +SKP_DWORD_ALIGN const SKP_int16 silk_Resampler_3_4_COEFS[ 2 + 3 * RESAMPLER_DOWN_ORDER_FIR / 2 ] = { -20253, -13986, 86, 7, -151, 368, -542, 232, 11041, 21904, 39, 90, -181, 216, -17, -877, 6408, 19695, 2, 113, -108, 2, 314, -977, 2665, 15787, }; -SKP_DWORD_ALIGN const SKP_int16 SKP_Silk_Resampler_2_3_COEFS[ 2 + 2 * RESAMPLER_DOWN_ORDER_FIR / 2 ] = { +SKP_DWORD_ALIGN const SKP_int16 silk_Resampler_2_3_COEFS[ 2 + 2 * RESAMPLER_DOWN_ORDER_FIR / 2 ] = { -13997, -14120, 60, -174, 71, 298, -800, 659, 9238, 17461, 48, -40, -150, 314, -155, -845, 4188, 14293, }; -SKP_DWORD_ALIGN const SKP_int16 SKP_Silk_Resampler_1_2_COEFS[ 2 + RESAMPLER_DOWN_ORDER_FIR / 2 ] = { +SKP_DWORD_ALIGN const SKP_int16 silk_Resampler_1_2_COEFS[ 2 + RESAMPLER_DOWN_ORDER_FIR / 2 ] = { 1233, -14293, -91, 162, 169, -342, -505, 1332, 5281, 8742, }; -SKP_DWORD_ALIGN const SKP_int16 SKP_Silk_Resampler_3_8_COEFS[ 2 + 3 * RESAMPLER_DOWN_ORDER_FIR / 2 ] = { +SKP_DWORD_ALIGN const SKP_int16 silk_Resampler_3_8_COEFS[ 2 + 3 * RESAMPLER_DOWN_ORDER_FIR / 2 ] = { 12634, -14550, 246, -175, -326, -113, 764, 2209, 3664, 4402, 171, 3, -301, -258, 391, 1693, 3227, 4272, 88, 138, -236, -327, 95, 1203, 2733, 4022, }; -SKP_DWORD_ALIGN const SKP_int16 SKP_Silk_Resampler_1_3_COEFS[ 2 + RESAMPLER_DOWN_ORDER_FIR / 2 ] = { +SKP_DWORD_ALIGN const SKP_int16 silk_Resampler_1_3_COEFS[ 2 + RESAMPLER_DOWN_ORDER_FIR / 2 ] = { 16306, -14409, 99, -201, -220, -16, 572, 1483, 2433, 3043, }; -SKP_DWORD_ALIGN const SKP_int16 SKP_Silk_Resampler_2_3_COEFS_LQ[ 2 + 2 * 2 ] = { +SKP_DWORD_ALIGN const SKP_int16 silk_Resampler_2_3_COEFS_LQ[ 2 + 2 * 2 ] = { -2797, -6507, 4697, 10739, 1567, 8276, }; -SKP_DWORD_ALIGN const SKP_int16 SKP_Silk_Resampler_1_3_COEFS_LQ[ 2 + 3 ] = { +SKP_DWORD_ALIGN const SKP_int16 silk_Resampler_1_3_COEFS_LQ[ 2 + 3 ] = { 16777, -9792, 890, 1614, 2148, }; @@ -100,28 +89,28 @@ SKP_DWORD_ALIGN const SKP_int16 SKP_Silk_Resampler_1_3_COEFS_LQ[ 2 + 3 ] = { /* Tables with coefficients for 4th order ARMA filter (35 Words), in a packed format: */ /* { B1_Q14[1], B2_Q14[1], -A1_Q14[1], -A1_Q14[2], -A2_Q14[1], -A2_Q14[2], gain_Q16 } */ /* where it is assumed that B*_Q14[0], B*_Q14[2], A*_Q14[0] are all 16384 */ -SKP_DWORD_ALIGN const SKP_int16 SKP_Silk_Resampler_320_441_ARMA4_COEFS[ 7 ] = { +SKP_DWORD_ALIGN const SKP_int16 silk_Resampler_320_441_ARMA4_COEFS[ 7 ] = { 31454, 24746, -9706, -3386, -17911, -13243, 24797 }; -SKP_DWORD_ALIGN const SKP_int16 SKP_Silk_Resampler_240_441_ARMA4_COEFS[ 7 ] = { +SKP_DWORD_ALIGN const SKP_int16 silk_Resampler_240_441_ARMA4_COEFS[ 7 ] = { 28721, 11254, 3189, -2546, -1495, -12618, 11562 }; -SKP_DWORD_ALIGN const SKP_int16 SKP_Silk_Resampler_160_441_ARMA4_COEFS[ 7 ] = { +SKP_DWORD_ALIGN const SKP_int16 silk_Resampler_160_441_ARMA4_COEFS[ 7 ] = { 23492, -6457, 14358, -4856, 14654, -13008, 4456 }; -SKP_DWORD_ALIGN const SKP_int16 SKP_Silk_Resampler_120_441_ARMA4_COEFS[ 7 ] = { +SKP_DWORD_ALIGN const SKP_int16 silk_Resampler_120_441_ARMA4_COEFS[ 7 ] = { 19311, -15569, 19489, -6950, 21441, -13559, 2370 }; -SKP_DWORD_ALIGN const SKP_int16 SKP_Silk_Resampler_80_441_ARMA4_COEFS[ 7 ] = { +SKP_DWORD_ALIGN const SKP_int16 silk_Resampler_80_441_ARMA4_COEFS[ 7 ] = { 13248, -23849, 24126, -9486, 26806, -14286, 1065 }; /* Table with interplation fractions of 1/288 : 2/288 : 287/288 (432 Words) */ -SKP_DWORD_ALIGN const SKP_int16 SKP_Silk_resampler_frac_FIR_144[ 144 ][ RESAMPLER_ORDER_FIR_144 / 2 ] = { +SKP_DWORD_ALIGN const SKP_int16 silk_resampler_frac_FIR_144[ 144 ][ RESAMPLER_ORDER_FIR_144 / 2 ] = { { -25, 58, 32526}, { -8, -69, 32461}, { 8, -195, 32393}, diff --git a/silk/SKP_Silk_resampler_rom.h b/silk/silk_resampler_rom.h similarity index 59% rename from silk/SKP_Silk_resampler_rom.h rename to silk/silk_resampler_rom.h index e541f508..49d82af2 100644 --- a/silk/SKP_Silk_resampler_rom.h +++ b/silk/silk_resampler_rom.h @@ -25,55 +25,55 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#ifndef _SKP_SILK_FIX_RESAMPLER_ROM_H_ -#define _SKP_SILK_FIX_RESAMPLER_ROM_H_ +#ifndef _SILK_FIX_RESAMPLER_ROM_H_ +#define _SILK_FIX_RESAMPLER_ROM_H_ #ifdef __cplusplus extern "C" { #endif -#include "SKP_Silk_typedef.h" -#include "SKP_Silk_resampler_structs.h" +#include "silk_typedef.h" +#include "silk_resampler_structs.h" #define RESAMPLER_DOWN_ORDER_FIR 16 #define RESAMPLER_ORDER_FIR_144 6 /* Tables for 2x downsampler. Values above 32767 intentionally wrap to a negative value. */ -extern const SKP_int16 SKP_Silk_resampler_down2_0; -extern const SKP_int16 SKP_Silk_resampler_down2_1; +extern const SKP_int16 silk_resampler_down2_0; +extern const SKP_int16 silk_resampler_down2_1; /* Tables for 2x upsampler, low quality. Values above 32767 intentionally wrap to a negative value. */ -extern const SKP_int16 SKP_Silk_resampler_up2_lq_0; -extern const SKP_int16 SKP_Silk_resampler_up2_lq_1; +extern const SKP_int16 silk_resampler_up2_lq_0; +extern const SKP_int16 silk_resampler_up2_lq_1; /* Tables for 2x upsampler, high quality. Values above 32767 intentionally wrap to a negative value. */ -extern const SKP_int16 SKP_Silk_resampler_up2_hq_0[ 2 ]; -extern const SKP_int16 SKP_Silk_resampler_up2_hq_1[ 2 ]; -extern const SKP_int16 SKP_Silk_resampler_up2_hq_notch[ 4 ]; +extern const SKP_int16 silk_resampler_up2_hq_0[ 2 ]; +extern const SKP_int16 silk_resampler_up2_hq_1[ 2 ]; +extern const SKP_int16 silk_resampler_up2_hq_notch[ 4 ]; /* Tables with IIR and FIR coefficients for fractional downsamplers */ -extern const SKP_int16 SKP_Silk_Resampler_3_4_COEFS[ 2 + 3 * RESAMPLER_DOWN_ORDER_FIR / 2 ]; -extern const SKP_int16 SKP_Silk_Resampler_2_3_COEFS[ 2 + 2 * RESAMPLER_DOWN_ORDER_FIR / 2 ]; -extern const SKP_int16 SKP_Silk_Resampler_1_2_COEFS[ 2 + RESAMPLER_DOWN_ORDER_FIR / 2 ]; -extern const SKP_int16 SKP_Silk_Resampler_3_8_COEFS[ 2 + 3 * RESAMPLER_DOWN_ORDER_FIR / 2 ]; -extern const SKP_int16 SKP_Silk_Resampler_1_3_COEFS[ 2 + RESAMPLER_DOWN_ORDER_FIR / 2 ]; -extern const SKP_int16 SKP_Silk_Resampler_2_3_COEFS_LQ[ 2 + 2 * 2 ]; -extern const SKP_int16 SKP_Silk_Resampler_1_3_COEFS_LQ[ 2 + 3 ]; +extern const SKP_int16 silk_Resampler_3_4_COEFS[ 2 + 3 * RESAMPLER_DOWN_ORDER_FIR / 2 ]; +extern const SKP_int16 silk_Resampler_2_3_COEFS[ 2 + 2 * RESAMPLER_DOWN_ORDER_FIR / 2 ]; +extern const SKP_int16 silk_Resampler_1_2_COEFS[ 2 + RESAMPLER_DOWN_ORDER_FIR / 2 ]; +extern const SKP_int16 silk_Resampler_3_8_COEFS[ 2 + 3 * RESAMPLER_DOWN_ORDER_FIR / 2 ]; +extern const SKP_int16 silk_Resampler_1_3_COEFS[ 2 + RESAMPLER_DOWN_ORDER_FIR / 2 ]; +extern const SKP_int16 silk_Resampler_2_3_COEFS_LQ[ 2 + 2 * 2 ]; +extern const SKP_int16 silk_Resampler_1_3_COEFS_LQ[ 2 + 3 ]; /* Tables with coefficients for 4th order ARMA filter */ -extern const SKP_int16 SKP_Silk_Resampler_320_441_ARMA4_COEFS[ 7 ]; -extern const SKP_int16 SKP_Silk_Resampler_240_441_ARMA4_COEFS[ 7 ]; -extern const SKP_int16 SKP_Silk_Resampler_160_441_ARMA4_COEFS[ 7 ]; -extern const SKP_int16 SKP_Silk_Resampler_120_441_ARMA4_COEFS[ 7 ]; -extern const SKP_int16 SKP_Silk_Resampler_80_441_ARMA4_COEFS[ 7 ]; +extern const SKP_int16 silk_Resampler_320_441_ARMA4_COEFS[ 7 ]; +extern const SKP_int16 silk_Resampler_240_441_ARMA4_COEFS[ 7 ]; +extern const SKP_int16 silk_Resampler_160_441_ARMA4_COEFS[ 7 ]; +extern const SKP_int16 silk_Resampler_120_441_ARMA4_COEFS[ 7 ]; +extern const SKP_int16 silk_Resampler_80_441_ARMA4_COEFS[ 7 ]; /* Table with interplation fractions of 1/288 : 2/288 : 287/288 (432 Words) */ -extern const SKP_int16 SKP_Silk_resampler_frac_FIR_144[ 144 ][ RESAMPLER_ORDER_FIR_144 / 2 ]; +extern const SKP_int16 silk_resampler_frac_FIR_144[ 144 ][ RESAMPLER_ORDER_FIR_144 / 2 ]; #ifdef __cplusplus } #endif -#endif // _SKP_SILK_FIX_RESAMPLER_ROM_H_ +#endif // _SILK_FIX_RESAMPLER_ROM_H_ diff --git a/silk/SKP_Silk_resampler_structs.h b/silk/silk_resampler_structs.h similarity index 72% rename from silk/SKP_Silk_resampler_structs.h rename to silk/silk_resampler_structs.h index 292422b7..e00e4117 100644 --- a/silk/SKP_Silk_resampler_structs.h +++ b/silk/silk_resampler_structs.h @@ -25,33 +25,23 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -/* * - * File Name: SKP_Silk_resampler_structs.h * - * * - * Description: Structs for IIR/FIR resamplers * - * * - * Copyright 2010 (c), Skype Limited * - * All rights reserved. * - * * - * */ - -#ifndef SKP_Silk_RESAMPLER_STRUCTS_H -#define SKP_Silk_RESAMPLER_STRUCTS_H +#ifndef SILK_RESAMPLER_STRUCTS_H +#define SILK_RESAMPLER_STRUCTS_H #ifdef __cplusplus extern "C" { #endif /* Flag to enable support for input/output sampling rates above 48 kHz. Turn off for embedded devices */ -#define RESAMPLER_SUPPORT_ABOVE_48KHZ 1 +#define RESAMPLER_SUPPORT_ABOVE_48KHZ 1 -#define SKP_Silk_RESAMPLER_MAX_FIR_ORDER 16 -#define SKP_Silk_RESAMPLER_MAX_IIR_ORDER 6 +#define SILK_RESAMPLER_MAX_FIR_ORDER 16 +#define SILK_RESAMPLER_MAX_IIR_ORDER 6 -typedef struct _SKP_Silk_resampler_state_struct{ - SKP_int32 sIIR[ SKP_Silk_RESAMPLER_MAX_IIR_ORDER ]; /* this must be the first element of this struct */ - SKP_int32 sFIR[ SKP_Silk_RESAMPLER_MAX_FIR_ORDER ]; +typedef struct _silk_resampler_state_struct{ + SKP_int32 sIIR[ SILK_RESAMPLER_MAX_IIR_ORDER ]; /* this must be the first element of this struct */ + SKP_int32 sFIR[ SILK_RESAMPLER_MAX_FIR_ORDER ]; SKP_int32 sDown2[ 2 ]; void (*resampler_function)( void *, SKP_int16 *, const SKP_int16 *, SKP_int32 ); void (*up2_function)( SKP_int32 *, SKP_int16 *, const SKP_int16 *, SKP_int32 ); @@ -71,10 +61,10 @@ typedef struct _SKP_Silk_resampler_state_struct{ SKP_int32 nPostUpsamplers; #endif SKP_int32 magic_number; -} SKP_Silk_resampler_state_struct; +} silk_resampler_state_struct; #ifdef __cplusplus } #endif -#endif // SKP_Silk_RESAMPLER_STRUCTS_H +#endif // SILK_RESAMPLER_STRUCTS_H diff --git a/silk/SKP_Silk_resampler_up2.c b/silk/silk_resampler_up2.c similarity index 77% rename from silk/SKP_Silk_resampler_up2.c rename to silk/silk_resampler_up2.c index 718b2740..b27636d4 100644 --- a/silk/SKP_Silk_resampler_up2.c +++ b/silk/silk_resampler_up2.c @@ -25,19 +25,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -/* * - * SKP_Silk_resampler_up2.c * - * * - * Upsample by a factor 2, low quality * - * * - * Copyright 2010 (c), Skype Limited * - * */ - -#include "SKP_Silk_SigProc_FIX.h" -#include "SKP_Silk_resampler_rom.h" +#include "silk_SigProc_FIX.h" +#include "silk_resampler_rom.h" /* Upsample by a factor 2, low quality */ -void SKP_Silk_resampler_up2( +void silk_resampler_up2( SKP_int32 *S, /* I/O: State vector [ 2 ] */ SKP_int16 *out, /* O: Output signal [ 2 * len ] */ const SKP_int16 *in, /* I: Input signal [ len ] */ @@ -47,8 +39,8 @@ void SKP_Silk_resampler_up2( SKP_int32 k; SKP_int32 in32, out32, Y, X; - SKP_assert( SKP_Silk_resampler_up2_lq_0 > 0 ); - SKP_assert( SKP_Silk_resampler_up2_lq_1 < 0 ); + SKP_assert( silk_resampler_up2_lq_0 > 0 ); + SKP_assert( silk_resampler_up2_lq_1 < 0 ); /* Internal variables and state are in Q10 format */ for( k = 0; k < len; k++ ) { /* Convert to Q10 */ @@ -56,7 +48,7 @@ void SKP_Silk_resampler_up2( /* All-pass section for even output sample */ Y = SKP_SUB32( in32, S[ 0 ] ); - X = SKP_SMULWB( Y, SKP_Silk_resampler_up2_lq_0 ); + X = SKP_SMULWB( Y, silk_resampler_up2_lq_0 ); out32 = SKP_ADD32( S[ 0 ], X ); S[ 0 ] = SKP_ADD32( in32, X ); @@ -65,7 +57,7 @@ void SKP_Silk_resampler_up2( /* All-pass section for odd output sample */ Y = SKP_SUB32( in32, S[ 1 ] ); - X = SKP_SMLAWB( Y, Y, SKP_Silk_resampler_up2_lq_1 ); + X = SKP_SMLAWB( Y, Y, silk_resampler_up2_lq_1 ); out32 = SKP_ADD32( S[ 1 ], X ); S[ 1 ] = SKP_ADD32( in32, X ); diff --git a/silk/SKP_Silk_scale_copy_vector16.c b/silk/silk_scale_copy_vector16.c similarity index 95% rename from silk/SKP_Silk_scale_copy_vector16.c rename to silk/silk_scale_copy_vector16.c index 2fa4bf62..46eb095a 100644 --- a/silk/SKP_Silk_scale_copy_vector16.c +++ b/silk/silk_scale_copy_vector16.c @@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_SigProc_FIX.h" /* Copy and multiply a vector by a constant */ -void SKP_Silk_scale_copy_vector16( +void silk_scale_copy_vector16( SKP_int16 *data_out, const SKP_int16 *data_in, SKP_int32 gain_Q16, /* (I): gain in Q16 */ diff --git a/silk/SKP_Silk_scale_vector.c b/silk/silk_scale_vector.c similarity index 94% rename from silk/SKP_Silk_scale_vector.c rename to silk/silk_scale_vector.c index a6734183..c91fc6ae 100644 --- a/silk/SKP_Silk_scale_vector.c +++ b/silk/silk_scale_vector.c @@ -25,10 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_SigProc_FIX.h" /* Multiply a vector by a constant */ -void SKP_Silk_scale_vector32_Q26_lshift_18( +void silk_scale_vector32_Q26_lshift_18( SKP_int32 *data1, /* (I/O): Q0/Q18 */ SKP_int32 gain_Q26, /* (I): Q26 */ SKP_int dataSize /* (I): length */ diff --git a/silk/SKP_Silk_schur.c b/silk/silk_schur.c similarity index 80% rename from silk/SKP_Silk_schur.c rename to silk/silk_schur.c index 6815612b..7851d41d 100644 --- a/silk/SKP_Silk_schur.c +++ b/silk/silk_schur.c @@ -25,30 +25,22 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -/* * - * SKP_Silk_schur.c * - * * - * Calculates the reflection coefficients from the correlation sequence * - * * - * Copyright 2008 (c), Skype Limited * - * Date: 080103 * - * */ -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_SigProc_FIX.h" /* Faster than schur64(), but much less accurate. */ /* uses SMLAWB(), requiring armv5E and higher. */ -SKP_int32 SKP_Silk_schur( /* O: Returns residual energy */ +SKP_int32 silk_schur( /* O: Returns residual energy */ SKP_int16 *rc_Q15, /* O: reflection coefficients [order] Q15 */ const SKP_int32 *c, /* I: correlations [order+1] */ const SKP_int32 order /* I: prediction order */ ) { SKP_int k, n, lz; - SKP_int32 C[ SKP_Silk_MAX_ORDER_LPC + 1 ][ 2 ]; + SKP_int32 C[ SILK_MAX_ORDER_LPC + 1 ][ 2 ]; SKP_int32 Ctmp1, Ctmp2, rc_tmp_Q15; /* Get number of leading zeros */ - lz = SKP_Silk_CLZ32( c[ 0 ] ); + lz = silk_CLZ32( c[ 0 ] ); /* Copy correlations and adjust level to Q30 */ if( lz < 2 ) { diff --git a/silk/SKP_Silk_schur64.c b/silk/silk_schur64.c similarity index 90% rename from silk/SKP_Silk_schur64.c rename to silk/silk_schur64.c index f2cc70ac..a830f4a5 100644 --- a/silk/SKP_Silk_schur64.c +++ b/silk/silk_schur64.c @@ -25,18 +25,18 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_SigProc_FIX.h" /* Slower than schur(), but more accurate. */ /* Uses SMULL(), available on armv4 */ -SKP_int32 SKP_Silk_schur64( /* O: Returns residual energy */ +SKP_int32 silk_schur64( /* O: Returns residual energy */ SKP_int32 rc_Q16[], /* O: Reflection coefficients [order] Q16 */ const SKP_int32 c[], /* I: Correlations [order+1] */ SKP_int32 order /* I: Prediction order */ ) { SKP_int k, n; - SKP_int32 C[ SKP_Silk_MAX_ORDER_LPC + 1 ][ 2 ]; + SKP_int32 C[ SILK_MAX_ORDER_LPC + 1 ][ 2 ]; SKP_int32 Ctmp1_Q30, Ctmp2_Q30, rc_tmp_Q31; /* Check for invalid input */ @@ -51,7 +51,7 @@ SKP_int32 SKP_Silk_schur64( /* O: Returns residual energ for( k = 0; k < order; k++ ) { /* Get reflection coefficient: divide two Q30 values and get result in Q31 */ - rc_tmp_Q31 = SKP_DIV32_varQ( -C[ k + 1 ][ 0 ], C[ 0 ][ 1 ], 31 ); + rc_tmp_Q31 = silk_DIV32_varQ( -C[ k + 1 ][ 0 ], C[ 0 ][ 1 ], 31 ); /* Save the output */ rc_Q16[ k ] = SKP_RSHIFT_ROUND( rc_tmp_Q31, 15 ); diff --git a/silk/SKP_Silk_shell_coder.c b/silk/silk_shell_coder.c similarity index 69% rename from silk/SKP_Silk_shell_coder.c rename to silk/silk_shell_coder.c index 930204b4..97cd8263 100644 --- a/silk/SKP_Silk_shell_coder.c +++ b/silk/silk_shell_coder.c @@ -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. ***********************************************************************/ -#include "SKP_Silk_main.h" +#include "silk_main.h" /* shell coder; pulse-subframe length is hardcoded */ @@ -49,7 +49,7 @@ SKP_INLINE void encode_split( ) { if( p > 0 ) { - ec_enc_icdf( psRangeEnc, p_child1, &shell_table[ SKP_Silk_shell_code_table_offsets[ p ] ], 8 ); + ec_enc_icdf( psRangeEnc, p_child1, &shell_table[ silk_shell_code_table_offsets[ p ] ], 8 ); } } @@ -62,7 +62,7 @@ SKP_INLINE void decode_split( ) { if( p > 0 ) { - p_child1[ 0 ] = ec_dec_icdf( psRangeDec, &shell_table[ SKP_Silk_shell_code_table_offsets[ p ] ], 8 ); + p_child1[ 0 ] = ec_dec_icdf( psRangeDec, &shell_table[ silk_shell_code_table_offsets[ p ] ], 8 ); p_child2[ 0 ] = p - p_child1[ 0 ]; } else { p_child1[ 0 ] = 0; @@ -71,7 +71,7 @@ SKP_INLINE void decode_split( } /* Shell encoder, operates on one shell code frame of 16 pulses */ -void SKP_Silk_shell_encoder( +void silk_shell_encoder( ec_enc *psRangeEnc, /* I/O compressor data structure */ const SKP_int *pulses0 /* I data: nonnegative pulse amplitudes */ ) @@ -87,32 +87,32 @@ void SKP_Silk_shell_encoder( combine_pulses( pulses3, pulses2, 2 ); combine_pulses( pulses4, pulses3, 1 ); - encode_split( psRangeEnc, pulses3[ 0 ], pulses4[ 0 ], SKP_Silk_shell_code_table3 ); + encode_split( psRangeEnc, pulses3[ 0 ], pulses4[ 0 ], silk_shell_code_table3 ); - encode_split( psRangeEnc, pulses2[ 0 ], pulses3[ 0 ], SKP_Silk_shell_code_table2 ); + encode_split( psRangeEnc, pulses2[ 0 ], pulses3[ 0 ], silk_shell_code_table2 ); - encode_split( psRangeEnc, pulses1[ 0 ], pulses2[ 0 ], SKP_Silk_shell_code_table1 ); - encode_split( psRangeEnc, pulses0[ 0 ], pulses1[ 0 ], SKP_Silk_shell_code_table0 ); - encode_split( psRangeEnc, pulses0[ 2 ], pulses1[ 1 ], SKP_Silk_shell_code_table0 ); + encode_split( psRangeEnc, pulses1[ 0 ], pulses2[ 0 ], silk_shell_code_table1 ); + encode_split( psRangeEnc, pulses0[ 0 ], pulses1[ 0 ], silk_shell_code_table0 ); + encode_split( psRangeEnc, pulses0[ 2 ], pulses1[ 1 ], silk_shell_code_table0 ); - encode_split( psRangeEnc, pulses1[ 2 ], pulses2[ 1 ], SKP_Silk_shell_code_table1 ); - encode_split( psRangeEnc, pulses0[ 4 ], pulses1[ 2 ], SKP_Silk_shell_code_table0 ); - encode_split( psRangeEnc, pulses0[ 6 ], pulses1[ 3 ], SKP_Silk_shell_code_table0 ); + encode_split( psRangeEnc, pulses1[ 2 ], pulses2[ 1 ], silk_shell_code_table1 ); + encode_split( psRangeEnc, pulses0[ 4 ], pulses1[ 2 ], silk_shell_code_table0 ); + encode_split( psRangeEnc, pulses0[ 6 ], pulses1[ 3 ], silk_shell_code_table0 ); - encode_split( psRangeEnc, pulses2[ 2 ], pulses3[ 1 ], SKP_Silk_shell_code_table2 ); + encode_split( psRangeEnc, pulses2[ 2 ], pulses3[ 1 ], silk_shell_code_table2 ); - encode_split( psRangeEnc, pulses1[ 4 ], pulses2[ 2 ], SKP_Silk_shell_code_table1 ); - encode_split( psRangeEnc, pulses0[ 8 ], pulses1[ 4 ], SKP_Silk_shell_code_table0 ); - encode_split( psRangeEnc, pulses0[ 10 ], pulses1[ 5 ], SKP_Silk_shell_code_table0 ); + encode_split( psRangeEnc, pulses1[ 4 ], pulses2[ 2 ], silk_shell_code_table1 ); + encode_split( psRangeEnc, pulses0[ 8 ], pulses1[ 4 ], silk_shell_code_table0 ); + encode_split( psRangeEnc, pulses0[ 10 ], pulses1[ 5 ], silk_shell_code_table0 ); - encode_split( psRangeEnc, pulses1[ 6 ], pulses2[ 3 ], SKP_Silk_shell_code_table1 ); - encode_split( psRangeEnc, pulses0[ 12 ], pulses1[ 6 ], SKP_Silk_shell_code_table0 ); - encode_split( psRangeEnc, pulses0[ 14 ], pulses1[ 7 ], SKP_Silk_shell_code_table0 ); + encode_split( psRangeEnc, pulses1[ 6 ], pulses2[ 3 ], silk_shell_code_table1 ); + encode_split( psRangeEnc, pulses0[ 12 ], pulses1[ 6 ], silk_shell_code_table0 ); + encode_split( psRangeEnc, pulses0[ 14 ], pulses1[ 7 ], silk_shell_code_table0 ); } /* Shell decoder, operates on one shell code frame of 16 pulses */ -void SKP_Silk_shell_decoder( +void silk_shell_decoder( SKP_int *pulses0, /* O data: nonnegative pulse amplitudes */ ec_dec *psRangeDec, /* I/O Compressor data structure */ const SKP_int pulses4 /* I number of pulses per pulse-subframe */ @@ -123,25 +123,25 @@ void SKP_Silk_shell_decoder( /* this function operates on one shell code frame of 16 pulses */ SKP_assert( SHELL_CODEC_FRAME_LENGTH == 16 ); - decode_split( &pulses3[ 0 ], &pulses3[ 1 ], psRangeDec, pulses4, SKP_Silk_shell_code_table3 ); + decode_split( &pulses3[ 0 ], &pulses3[ 1 ], psRangeDec, pulses4, silk_shell_code_table3 ); - decode_split( &pulses2[ 0 ], &pulses2[ 1 ], psRangeDec, pulses3[ 0 ], SKP_Silk_shell_code_table2 ); + decode_split( &pulses2[ 0 ], &pulses2[ 1 ], psRangeDec, pulses3[ 0 ], silk_shell_code_table2 ); - decode_split( &pulses1[ 0 ], &pulses1[ 1 ], psRangeDec, pulses2[ 0 ], SKP_Silk_shell_code_table1 ); - decode_split( &pulses0[ 0 ], &pulses0[ 1 ], psRangeDec, pulses1[ 0 ], SKP_Silk_shell_code_table0 ); - decode_split( &pulses0[ 2 ], &pulses0[ 3 ], psRangeDec, pulses1[ 1 ], SKP_Silk_shell_code_table0 ); + decode_split( &pulses1[ 0 ], &pulses1[ 1 ], psRangeDec, pulses2[ 0 ], silk_shell_code_table1 ); + decode_split( &pulses0[ 0 ], &pulses0[ 1 ], psRangeDec, pulses1[ 0 ], silk_shell_code_table0 ); + decode_split( &pulses0[ 2 ], &pulses0[ 3 ], psRangeDec, pulses1[ 1 ], silk_shell_code_table0 ); - decode_split( &pulses1[ 2 ], &pulses1[ 3 ], psRangeDec, pulses2[ 1 ], SKP_Silk_shell_code_table1 ); - decode_split( &pulses0[ 4 ], &pulses0[ 5 ], psRangeDec, pulses1[ 2 ], SKP_Silk_shell_code_table0 ); - decode_split( &pulses0[ 6 ], &pulses0[ 7 ], psRangeDec, pulses1[ 3 ], SKP_Silk_shell_code_table0 ); + decode_split( &pulses1[ 2 ], &pulses1[ 3 ], psRangeDec, pulses2[ 1 ], silk_shell_code_table1 ); + decode_split( &pulses0[ 4 ], &pulses0[ 5 ], psRangeDec, pulses1[ 2 ], silk_shell_code_table0 ); + decode_split( &pulses0[ 6 ], &pulses0[ 7 ], psRangeDec, pulses1[ 3 ], silk_shell_code_table0 ); - decode_split( &pulses2[ 2 ], &pulses2[ 3 ], psRangeDec, pulses3[ 1 ], SKP_Silk_shell_code_table2 ); + decode_split( &pulses2[ 2 ], &pulses2[ 3 ], psRangeDec, pulses3[ 1 ], silk_shell_code_table2 ); - decode_split( &pulses1[ 4 ], &pulses1[ 5 ], psRangeDec, pulses2[ 2 ], SKP_Silk_shell_code_table1 ); - decode_split( &pulses0[ 8 ], &pulses0[ 9 ], psRangeDec, pulses1[ 4 ], SKP_Silk_shell_code_table0 ); - decode_split( &pulses0[ 10 ], &pulses0[ 11 ], psRangeDec, pulses1[ 5 ], SKP_Silk_shell_code_table0 ); + decode_split( &pulses1[ 4 ], &pulses1[ 5 ], psRangeDec, pulses2[ 2 ], silk_shell_code_table1 ); + decode_split( &pulses0[ 8 ], &pulses0[ 9 ], psRangeDec, pulses1[ 4 ], silk_shell_code_table0 ); + decode_split( &pulses0[ 10 ], &pulses0[ 11 ], psRangeDec, pulses1[ 5 ], silk_shell_code_table0 ); - decode_split( &pulses1[ 6 ], &pulses1[ 7 ], psRangeDec, pulses2[ 3 ], SKP_Silk_shell_code_table1 ); - decode_split( &pulses0[ 12 ], &pulses0[ 13 ], psRangeDec, pulses1[ 6 ], SKP_Silk_shell_code_table0 ); - decode_split( &pulses0[ 14 ], &pulses0[ 15 ], psRangeDec, pulses1[ 7 ], SKP_Silk_shell_code_table0 ); + decode_split( &pulses1[ 6 ], &pulses1[ 7 ], psRangeDec, pulses2[ 3 ], silk_shell_code_table1 ); + decode_split( &pulses0[ 12 ], &pulses0[ 13 ], psRangeDec, pulses1[ 6 ], silk_shell_code_table0 ); + decode_split( &pulses0[ 14 ], &pulses0[ 15 ], psRangeDec, pulses1[ 7 ], silk_shell_code_table0 ); } diff --git a/silk/SKP_Silk_sigm_Q15.c b/silk/silk_sigm_Q15.c similarity index 78% rename from silk/SKP_Silk_sigm_Q15.c rename to silk/silk_sigm_Q15.c index 5b4168c1..a0df8f49 100644 --- a/silk/SKP_Silk_sigm_Q15.c +++ b/silk/silk_sigm_Q15.c @@ -25,18 +25,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -/* * - * SKP_sigm_Q15.c * - * * - * Approximate sigmoid function * - * * - * Copyright 2006 (c), Skype Limited * - * Date: 060221 * - * */ -#include "SKP_Silk_SigProc_FIX.h" -/********************************/ -/* approximate sigmoid function */ -/********************************/ +/* Approximate sigmoid function */ + +#include "silk_SigProc_FIX.h" + /* fprintf(1, '%d, ', round(1024 * ([1 ./ (1 + exp(-(1:5))), 1] - 1 ./ (1 + exp(-(0:5)))))); */ static const SKP_int32 sigm_LUT_slope_Q10[ 6 ] = { 237, 153, 73, 30, 12, 7 @@ -50,7 +42,7 @@ static const SKP_int32 sigm_LUT_neg_Q15[ 6 ] = { 16384, 8812, 3906, 1554, 589, 219 }; -SKP_int SKP_Silk_sigm_Q15( SKP_int in_Q5 ) +SKP_int silk_sigm_Q15( SKP_int in_Q5 ) { SKP_int ind; diff --git a/silk/SKP_Silk_sort.c b/silk/silk_sort.c similarity index 77% rename from silk/SKP_Silk_sort.c rename to silk/silk_sort.c index 6f45f158..53661679 100644 --- a/silk/SKP_Silk_sort.c +++ b/silk/silk_sort.c @@ -31,11 +31,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* */ /* Shell short: http://en.wikipedia.org/wiki/Shell_sort */ -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_SigProc_FIX.h" -void SKP_Silk_insertion_sort_increasing( +void silk_insertion_sort_increasing( SKP_int32 *a, /* I/O: Unsorted / Sorted vector */ - SKP_int *index, /* O: Index vector for the sorted elements */ + SKP_int *idx, /* O: Index vector for the sorted elements */ const SKP_int L, /* I: Vector length */ const SKP_int K /* I: Number of correctly sorted positions */ ) @@ -50,18 +50,18 @@ void SKP_Silk_insertion_sort_increasing( /* Write start indices in index vector */ for( i = 0; i < K; i++ ) { - index[ i ] = i; + idx[ i ] = i; } /* Sort vector elements by value, increasing order */ for( i = 1; i < K; i++ ) { value = a[ i ]; for( j = i - 1; ( j >= 0 ) && ( value < a[ j ] ); j-- ) { - a[ j + 1 ] = a[ j ]; /* Shift value */ - index[ j + 1 ] = index[ j ]; /* Shift index */ + a[ j + 1 ] = a[ j ]; /* Shift value */ + idx[ j + 1 ] = idx[ j ]; /* Shift index */ } - a[ j + 1 ] = value; /* Write value */ - index[ j + 1 ] = i; /* Write index */ + a[ j + 1 ] = value; /* Write value */ + idx[ j + 1 ] = i; /* Write index */ } /* If less than L values are asked for, check the remaining values, */ @@ -70,18 +70,18 @@ void SKP_Silk_insertion_sort_increasing( value = a[ i ]; if( value < a[ K - 1 ] ) { for( j = K - 2; ( j >= 0 ) && ( value < a[ j ] ); j-- ) { - a[ j + 1 ] = a[ j ]; /* Shift value */ - index[ j + 1 ] = index[ j ]; /* Shift index */ + a[ j + 1 ] = a[ j ]; /* Shift value */ + idx[ j + 1 ] = idx[ j ]; /* Shift index */ } - a[ j + 1 ] = value; /* Write value */ - index[ j + 1 ] = i; /* Write index */ + a[ j + 1 ] = value; /* Write value */ + idx[ j + 1 ] = i; /* Write index */ } } } -void SKP_Silk_insertion_sort_decreasing_int16( +void silk_insertion_sort_decreasing_int16( SKP_int16 *a, /* I/O: Unsorted / Sorted vector */ - SKP_int *index, /* O: Index vector for the sorted elements */ + SKP_int *idx, /* O: Index vector for the sorted elements */ const SKP_int L, /* I: Vector length */ const SKP_int K /* I: Number of correctly sorted positions */ ) @@ -96,18 +96,18 @@ void SKP_Silk_insertion_sort_decreasing_int16( /* Write start indices in index vector */ for( i = 0; i < K; i++ ) { - index[ i ] = i; + idx[ i ] = i; } /* Sort vector elements by value, decreasing order */ for( i = 1; i < K; i++ ) { value = a[ i ]; for( j = i - 1; ( j >= 0 ) && ( value > a[ j ] ); j-- ) { - a[ j + 1 ] = a[ j ]; /* Shift value */ - index[ j + 1 ] = index[ j ]; /* Shift index */ + a[ j + 1 ] = a[ j ]; /* Shift value */ + idx[ j + 1 ] = idx[ j ]; /* Shift index */ } - a[ j + 1 ] = value; /* Write value */ - index[ j + 1 ] = i; /* Write index */ + a[ j + 1 ] = value; /* Write value */ + idx[ j + 1 ] = i; /* Write index */ } /* If less than L values are asked for, check the remaining values, */ @@ -116,16 +116,16 @@ void SKP_Silk_insertion_sort_decreasing_int16( value = a[ i ]; if( value > a[ K - 1 ] ) { for( j = K - 2; ( j >= 0 ) && ( value > a[ j ] ); j-- ) { - a[ j + 1 ] = a[ j ]; /* Shift value */ - index[ j + 1 ] = index[ j ]; /* Shift index */ + a[ j + 1 ] = a[ j ]; /* Shift value */ + idx[ j + 1 ] = idx[ j ]; /* Shift index */ } - a[ j + 1 ] = value; /* Write value */ - index[ j + 1 ] = i; /* Write index */ + a[ j + 1 ] = value; /* Write value */ + idx[ j + 1 ] = i; /* Write index */ } } } -void SKP_Silk_insertion_sort_increasing_all_values_int16( +void silk_insertion_sort_increasing_all_values_int16( SKP_int16 *a, /* I/O: Unsorted / Sorted vector */ const SKP_int L /* I: Vector length */ ) diff --git a/silk/silk_stereo_LR_to_MS.c b/silk/silk_stereo_LR_to_MS.c new file mode 100644 index 00000000..c86a96d3 --- /dev/null +++ b/silk/silk_stereo_LR_to_MS.c @@ -0,0 +1,177 @@ +/*********************************************************************** +Copyright (c) 2006-2011, Skype Limited. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, (subject to the limitations in the disclaimer below) +are permitted provided that the following conditions are met: +- Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. +- Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. +- Neither the name of Skype Limited, nor the names of specific +contributors, may be used to endorse or promote products derived from +this software without specific prior written permission. +NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED +BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +***********************************************************************/ + +#include "silk_main.h" + +/* Convert Left/Right stereo signal to adaptive Mid/Side representation */ +void silk_stereo_LR_to_MS( + stereo_enc_state *state, /* I/O State */ + SKP_int16 x1[], /* I/O Left input signal, becomes mid signal */ + SKP_int16 x2[], /* I/O Right input signal, becomes side signal */ + SKP_int8 ix[ 2 ][ 4 ], /* O Quantization indices */ + SKP_int32 mid_side_rates_bps[], /* O Bitrates for mid and side signals */ + SKP_int32 total_rate_bps, /* I Total bitrate */ + SKP_int prev_speech_act_Q8, /* I Speech activity level in previous frame */ + SKP_int fs_kHz, /* I Sample rate (kHz) */ + SKP_int frame_length /* I Number of samples */ +) +{ + SKP_int n, is10msFrame, denom_Q16, delta0_Q13, delta1_Q13; + SKP_int32 sum, diff, smooth_coef_Q16, pred_Q13[ 2 ], pred0_Q13, pred1_Q13; + SKP_int32 LP_ratio_Q14, HP_ratio_Q14, frac_Q16, frac_3_Q16, min_mid_rate_bps, width_Q14, w_Q24, deltaw_Q24; + SKP_int16 side[ MAX_FRAME_LENGTH + 2 ]; + SKP_int16 LP_mid[ MAX_FRAME_LENGTH ], HP_mid[ MAX_FRAME_LENGTH ]; + SKP_int16 LP_side[ MAX_FRAME_LENGTH ], HP_side[ MAX_FRAME_LENGTH ]; + SKP_int16 *mid = &x1[ -2 ]; + + /* Convert to basic mid/side signals */ + for( n = 0; n < frame_length + 2; n++ ) { + sum = x1[ n - 2 ] + (SKP_int32)x2[ n - 2 ]; + diff = x1[ n - 2 ] - (SKP_int32)x2[ n - 2 ]; + mid[ n ] = (SKP_int16)SKP_RSHIFT_ROUND( sum, 1 ); + side[ n ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( diff, 1 ) ); + } + + /* Buffering */ + SKP_memcpy( mid, state->sMid, 2 * sizeof( SKP_int16 ) ); + SKP_memcpy( side, state->sSide, 2 * sizeof( SKP_int16 ) ); + SKP_memcpy( state->sMid, &mid[ frame_length ], 2 * sizeof( SKP_int16 ) ); + SKP_memcpy( state->sSide, &side[ frame_length ], 2 * sizeof( SKP_int16 ) ); + + /* LP and HP filter mid signal */ + for( n = 0; n < frame_length; n++ ) { + sum = SKP_RSHIFT_ROUND( SKP_ADD_LSHIFT( mid[ n ] + mid[ n + 2 ], mid[ n + 1 ], 1 ), 2 ); + LP_mid[ n ] = sum; + HP_mid[ n ] = mid[ n + 1 ] - sum; + } + + /* LP and HP filter side signal */ + for( n = 0; n < frame_length; n++ ) { + sum = SKP_RSHIFT_ROUND( SKP_ADD_LSHIFT( side[ n ] + side[ n + 2 ], side[ n + 1 ], 1 ), 2 ); + LP_side[ n ] = sum; + HP_side[ n ] = side[ n + 1 ] - sum; + } + + /* Find energies and predictors */ + is10msFrame = frame_length == 10 * fs_kHz; + smooth_coef_Q16 = is10msFrame ? + SILK_FIX_CONST( STEREO_RATIO_SMOOTH_COEF / 2, 16 ) : + SILK_FIX_CONST( STEREO_RATIO_SMOOTH_COEF, 16 ); + smooth_coef_Q16 = SKP_SMULWB( SKP_SMULBB( prev_speech_act_Q8 , prev_speech_act_Q8 ), smooth_coef_Q16 ); + + pred_Q13[ 0 ] = silk_stereo_find_predictor( &LP_ratio_Q14, LP_mid, LP_side, &state->mid_side_amp_Q0[ 0 ], frame_length, smooth_coef_Q16 ); + pred_Q13[ 1 ] = silk_stereo_find_predictor( &HP_ratio_Q14, HP_mid, HP_side, &state->mid_side_amp_Q0[ 2 ], frame_length, smooth_coef_Q16 ); + /* Ratio of the norms of residual and mid signals */ + frac_Q16 = SKP_SMLABB( HP_ratio_Q14, LP_ratio_Q14, 3 ); + frac_Q16 = SKP_min( frac_Q16, SILK_FIX_CONST( 1, 16 ) ); + + /* Determine bitrate distribution between mid and side, and possibly reduce stereo width */ + total_rate_bps -= is10msFrame ? 1200 : 600; /* Subtract approximate bitrate for coding stereo parameters */ + min_mid_rate_bps = SKP_SMLABB( 2000, fs_kHz, 900 ); + SKP_assert( min_mid_rate_bps < 32767 ); + /* Default bitrate distribution: 8 parts for Mid and (5+3*frac) parts for Side. so: mid_rate = ( 8 / ( 13 + 3 * frac ) ) * total_ rate */ + frac_3_Q16 = SKP_MUL( 3, frac_Q16 ); + mid_side_rates_bps[ 0 ] = silk_DIV32_varQ( total_rate_bps, SILK_FIX_CONST( 8 + 5, 16 ) + frac_3_Q16, 16+3 ); + /* If Mid bitrate below minimum, reduce stereo width */ + if( mid_side_rates_bps[ 0 ] < min_mid_rate_bps ) { + mid_side_rates_bps[ 0 ] = min_mid_rate_bps; + mid_side_rates_bps[ 1 ] = total_rate_bps - mid_side_rates_bps[ 0 ]; + /* width = 4 * ( 2 * side_rate - min_rate ) / ( ( 1 + 3 * frac ) * min_rate ) */ + width_Q14 = silk_DIV32_varQ( SKP_LSHIFT( mid_side_rates_bps[ 1 ], 1 ) - min_mid_rate_bps, + SKP_SMULWB( SILK_FIX_CONST( 1, 16 ) + frac_3_Q16, min_mid_rate_bps ), 14+2 ); + width_Q14 = SKP_LIMIT( width_Q14, 0, SILK_FIX_CONST( 1, 14 ) ); + } else { + mid_side_rates_bps[ 1 ] = total_rate_bps - mid_side_rates_bps[ 0 ]; + width_Q14 = SILK_FIX_CONST( 1, 14 ); + } + + /* Smoother */ + state->smth_width_Q14 = (SKP_int16)SKP_SMLAWB( state->smth_width_Q14, width_Q14 - state->smth_width_Q14, smooth_coef_Q16 ); + + /* Reduce predictors */ + pred_Q13[ 0 ] = SKP_RSHIFT( SKP_SMULBB( state->smth_width_Q14, pred_Q13[ 0 ] ), 14 ); + pred_Q13[ 1 ] = SKP_RSHIFT( SKP_SMULBB( state->smth_width_Q14, pred_Q13[ 1 ] ), 14 ); + + ix[ 0 ][ 3 ] = 0; + if( state->width_prev_Q14 == 0 && + ( 8 * total_rate_bps < 13 * min_mid_rate_bps || SKP_SMULWB( frac_Q16, state->smth_width_Q14 ) < SILK_FIX_CONST( 0.05, 14 ) ) ) + { + width_Q14 = 0; + /* Only encode mid channel */ + mid_side_rates_bps[ 0 ] = total_rate_bps; + mid_side_rates_bps[ 1 ] = 0; + ix[ 0 ][ 3 ] = 1; + } else if( state->width_prev_Q14 != 0 && + ( 8 * total_rate_bps < 11 * min_mid_rate_bps || SKP_SMULWB( frac_Q16, state->smth_width_Q14 ) < SILK_FIX_CONST( 0.02, 14 ) ) ) + { + width_Q14 = 0; + } else if( state->smth_width_Q14 > SILK_FIX_CONST( 0.95, 14 ) ) { + width_Q14 = SILK_FIX_CONST( 1, 14 ); + } else { + width_Q14 = state->smth_width_Q14; + } + +#if 0 + DEBUG_STORE_DATA( midside.dat, &mid_side_rates_bps[ 0 ], 8 ); + DEBUG_STORE_DATA( norms0.pcm, &state->mid_side_amp_Q0[0], 8 ); + DEBUG_STORE_DATA( norms1.pcm, &state->mid_side_amp_Q0[2], 8 ); + DEBUG_STORE_DATA( width.pcm, &width_Q14, 4 ); +#endif + + /* Quantize predictors */ + silk_stereo_quant_pred( state, pred_Q13, ix ); + + /* Interpolate predictors and subtract prediction from side channel */ + pred0_Q13 = -state->pred_prev_Q13[ 0 ]; + pred1_Q13 = -state->pred_prev_Q13[ 1 ]; + w_Q24 = SKP_LSHIFT( state->width_prev_Q14, 10 ); + denom_Q16 = SKP_DIV32_16( 1 << 16, STEREO_INTERP_LEN_MS * fs_kHz ); + delta0_Q13 = -SKP_RSHIFT_ROUND( SKP_SMULBB( pred_Q13[ 0 ] - state->pred_prev_Q13[ 0 ], denom_Q16 ), 16 ); + delta1_Q13 = -SKP_RSHIFT_ROUND( SKP_SMULBB( pred_Q13[ 1 ] - state->pred_prev_Q13[ 1 ], denom_Q16 ), 16 ); + deltaw_Q24 = SKP_LSHIFT( SKP_SMULWB( width_Q14 - state->width_prev_Q14, denom_Q16 ), 10 ); + for( n = 0; n < STEREO_INTERP_LEN_MS * fs_kHz; n++ ) { + pred0_Q13 += delta0_Q13; + pred1_Q13 += delta1_Q13; + w_Q24 += deltaw_Q24; + sum = SKP_LSHIFT( SKP_ADD_LSHIFT( mid[ n ] + mid[ n + 2 ], mid[ n + 1 ], 1 ), 9 ); /* Q11 */ + sum = SKP_SMLAWB( SKP_SMULWB( w_Q24, side[ n + 1 ] ), sum, pred0_Q13 ); /* Q8 */ + sum = SKP_SMLAWB( sum, SKP_LSHIFT( ( SKP_int32 )mid[ n + 1 ], 11 ), pred1_Q13 ); /* Q8 */ + x2[ n - 1 ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( sum, 8 ) ); + } + pred0_Q13 = -pred_Q13[ 0 ]; + pred1_Q13 = -pred_Q13[ 1 ]; + w_Q24 = SKP_LSHIFT( width_Q14, 10 ); + for( n = STEREO_INTERP_LEN_MS * fs_kHz; n < frame_length; n++ ) { + sum = SKP_LSHIFT( SKP_ADD_LSHIFT( mid[ n ] + mid[ n + 2 ], mid[ n + 1 ], 1 ), 9 ); /* Q11 */ + sum = SKP_SMLAWB( SKP_SMULWB( w_Q24, side[ n + 1 ] ), sum, pred0_Q13 ); /* Q8 */ + sum = SKP_SMLAWB( sum, SKP_LSHIFT( ( SKP_int32 )mid[ n + 1 ], 11 ), pred1_Q13 ); /* Q8 */ + x2[ n - 1 ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( sum, 8 ) ); + } + state->pred_prev_Q13[ 0 ] = (SKP_int16)pred_Q13[ 0 ]; + state->pred_prev_Q13[ 1 ] = (SKP_int16)pred_Q13[ 1 ]; + state->width_prev_Q14 = (SKP_int16)width_Q14; +} diff --git a/silk/SKP_Silk_stereo_MS_to_LR.c b/silk/silk_stereo_MS_to_LR.c similarity index 67% rename from silk/SKP_Silk_stereo_MS_to_LR.c rename to silk/silk_stereo_MS_to_LR.c index b8ba55dc..357415ad 100644 --- a/silk/SKP_Silk_stereo_MS_to_LR.c +++ b/silk/silk_stereo_MS_to_LR.c @@ -25,11 +25,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" +#include "silk_main.h" /* Convert adaptive Mid/Side representation to Left/Right stereo signal */ -void SKP_Silk_stereo_MS_to_LR( - stereo_state *state, /* I/O State */ +void silk_stereo_MS_to_LR( + stereo_dec_state *state, /* I/O State */ SKP_int16 x1[], /* I/O Left input signal, becomes mid signal */ SKP_int16 x2[], /* I/O Right input signal, becomes side signal */ const SKP_int32 pred_Q13[], /* I Predictors */ @@ -39,15 +39,12 @@ void SKP_Silk_stereo_MS_to_LR( { SKP_int n, denom_Q16, delta0_Q13, delta1_Q13; SKP_int32 sum, diff, pred0_Q13, pred1_Q13; - SKP_int16 mid[ MAX_FRAME_LENGTH + 2 ], side[ MAX_FRAME_LENGTH + 2 ]; /* Buffering */ - SKP_memcpy( mid, state->sMid, 2 * sizeof( SKP_int16 ) ); - SKP_memcpy( side, state->sSide, 2 * sizeof( SKP_int16 ) ); - SKP_memcpy( mid + 2, x1, frame_length * sizeof( SKP_int16 ) ); - SKP_memcpy( side + 2, x2, frame_length * sizeof( SKP_int16 ) ); - SKP_memcpy( state->sMid, &mid[ frame_length ], 2 * sizeof( SKP_int16 ) ); - SKP_memcpy( state->sSide, &side[ frame_length ], 2 * sizeof( SKP_int16 ) ); + SKP_memcpy( x1, state->sMid, 2 * sizeof( SKP_int16 ) ); + SKP_memcpy( x2, state->sSide, 2 * sizeof( SKP_int16 ) ); + SKP_memcpy( state->sMid, &x1[ frame_length ], 2 * sizeof( SKP_int16 ) ); + SKP_memcpy( state->sSide, &x2[ frame_length ], 2 * sizeof( SKP_int16 ) ); /* Interpolate predictors and add prediction to side channel */ pred0_Q13 = state->pred_prev_Q13[ 0 ]; @@ -58,27 +55,27 @@ void SKP_Silk_stereo_MS_to_LR( for( n = 0; n < STEREO_INTERP_LEN_MS * fs_kHz; n++ ) { pred0_Q13 += delta0_Q13; pred1_Q13 += delta1_Q13; - sum = SKP_LSHIFT( SKP_ADD_LSHIFT( mid[ n ] + mid[ n + 2 ], mid[ n + 1 ], 1 ), 9 ); /* Q11 */ - sum = SKP_SMLAWB( SKP_LSHIFT( ( SKP_int32 )side[ n + 1 ], 8 ), sum, pred0_Q13 ); /* Q8 */ - sum = SKP_SMLAWB( sum, SKP_LSHIFT( ( SKP_int32 )mid[ n + 1 ], 11 ), pred1_Q13 ); /* Q8 */ - side[ n + 1 ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( sum, 8 ) ); + sum = SKP_LSHIFT( SKP_ADD_LSHIFT( x1[ n ] + x1[ n + 2 ], x1[ n + 1 ], 1 ), 9 ); /* Q11 */ + sum = SKP_SMLAWB( SKP_LSHIFT( ( SKP_int32 )x2[ n + 1 ], 8 ), sum, pred0_Q13 ); /* Q8 */ + sum = SKP_SMLAWB( sum, SKP_LSHIFT( ( SKP_int32 )x1[ n + 1 ], 11 ), pred1_Q13 ); /* Q8 */ + x2[ n + 1 ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( sum, 8 ) ); } pred0_Q13 = pred_Q13[ 0 ]; pred1_Q13 = pred_Q13[ 1 ]; for( n = STEREO_INTERP_LEN_MS * fs_kHz; n < frame_length; n++ ) { - sum = SKP_LSHIFT( SKP_ADD_LSHIFT( mid[ n ] + mid[ n + 2 ], mid[ n + 1 ], 1 ), 9 ); /* Q11 */ - sum = SKP_SMLAWB( SKP_LSHIFT( ( SKP_int32 )side[ n + 1 ], 8 ), sum, pred0_Q13 ); /* Q8 */ - sum = SKP_SMLAWB( sum, SKP_LSHIFT( ( SKP_int32 )mid[ n + 1 ], 11 ), pred1_Q13 ); /* Q8 */ - side[ n + 1 ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( sum, 8 ) ); + sum = SKP_LSHIFT( SKP_ADD_LSHIFT( x1[ n ] + x1[ n + 2 ], x1[ n + 1 ], 1 ), 9 ); /* Q11 */ + sum = SKP_SMLAWB( SKP_LSHIFT( ( SKP_int32 )x2[ n + 1 ], 8 ), sum, pred0_Q13 ); /* Q8 */ + sum = SKP_SMLAWB( sum, SKP_LSHIFT( ( SKP_int32 )x1[ n + 1 ], 11 ), pred1_Q13 ); /* Q8 */ + x2[ n + 1 ] = (SKP_int16)SKP_SAT16( SKP_RSHIFT_ROUND( sum, 8 ) ); } state->pred_prev_Q13[ 0 ] = pred_Q13[ 0 ]; state->pred_prev_Q13[ 1 ] = pred_Q13[ 1 ]; /* Convert to left/right signals */ for( n = 0; n < frame_length; n++ ) { - sum = mid[ n + 1 ] + (SKP_int32)side[ n + 1 ]; - diff = mid[ n + 1 ] - (SKP_int32)side[ n + 1 ]; - x1[ n ] = (SKP_int16)SKP_SAT16( sum ); - x2[ n ] = (SKP_int16)SKP_SAT16( diff ); + sum = x1[ n + 1 ] + (SKP_int32)x2[ n + 1 ]; + diff = x1[ n + 1 ] - (SKP_int32)x2[ n + 1 ]; + x1[ n + 1 ] = (SKP_int16)SKP_SAT16( sum ); + x2[ n + 1 ] = (SKP_int16)SKP_SAT16( diff ); } } diff --git a/silk/SKP_Silk_stereo_decode_pred.c b/silk/silk_stereo_decode_pred.c similarity index 69% rename from silk/SKP_Silk_stereo_decode_pred.c rename to silk/silk_stereo_decode_pred.c index 828b8bd9..e7e6c009 100644 --- a/silk/SKP_Silk_stereo_decode_pred.c +++ b/silk/silk_stereo_decode_pred.c @@ -25,35 +25,39 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" +#include "silk_main.h" /* Decode mid/side predictors */ -void SKP_Silk_stereo_decode_pred( +void silk_stereo_decode_pred( ec_dec *psRangeDec, /* I/O Compressor data structure */ + SKP_int *decode_only_mid, /* O Flag that only mid channel has been coded */ SKP_int32 pred_Q13[] /* O Predictors */ ) { - SKP_int n, ibest[ 2 ] = { 0 }, jbest[ 2 ] = { 0 }, kbest[ 2 ]; + SKP_int n, ix[ 2 ][ 3 ]; SKP_int32 low_Q13, step_Q13; /* Entropy decoding */ - n = ec_dec_icdf( psRangeDec, SKP_Silk_stereo_pred_joint_iCDF, 8 ); - kbest[ 0 ] = SKP_DIV32_16( n, 5 ); - kbest[ 1 ] = n - 5 * kbest[ 0 ]; + n = ec_dec_icdf( psRangeDec, silk_stereo_pred_joint_iCDF, 8 ); + ix[ 0 ][ 2 ] = SKP_DIV32_16( n, 5 ); + ix[ 1 ][ 2 ] = n - 5 * ix[ 0 ][ 2 ]; for( n = 0; n < 2; n++ ) { - ibest[ n ] = ec_dec_icdf( psRangeDec, SKP_Silk_uniform3_iCDF, 8 ); - ibest[ n ] += 3 * kbest[ n ]; - jbest[ n ] = ec_dec_icdf( psRangeDec, SKP_Silk_uniform5_iCDF, 8 ); + ix[ n ][ 0 ] = ec_dec_icdf( psRangeDec, silk_uniform3_iCDF, 8 ); + ix[ n ][ 1 ] = ec_dec_icdf( psRangeDec, silk_uniform5_iCDF, 8 ); } /* Dequantize */ for( n = 0; n < 2; n++ ) { - low_Q13 = SKP_Silk_stereo_pred_quant_Q13[ ibest[ n ] ]; - step_Q13 = SKP_SMULWB( SKP_Silk_stereo_pred_quant_Q13[ ibest[ n ] + 1 ] - low_Q13, - SKP_FIX_CONST( 0.5 / STEREO_QUANT_SUB_STEPS, 16 ) ); - pred_Q13[ n ] = SKP_SMLABB( low_Q13, step_Q13, 2 * jbest[ n ] + 1 ); + ix[ n ][ 0 ] += 3 * ix[ n ][ 2 ]; + low_Q13 = silk_stereo_pred_quant_Q13[ ix[ n ][ 0 ] ]; + step_Q13 = SKP_SMULWB( silk_stereo_pred_quant_Q13[ ix[ n ][ 0 ] + 1 ] - low_Q13, + SILK_FIX_CONST( 0.5 / STEREO_QUANT_SUB_STEPS, 16 ) ); + pred_Q13[ n ] = SKP_SMLABB( low_Q13, step_Q13, 2 * ix[ n ][ 1 ] + 1 ); } /* Subtract second from first predictor (helps when actually applying these) */ pred_Q13[ 0 ] -= pred_Q13[ 1 ]; + + /* Decode flag that only mid channel is coded */ + *decode_only_mid = ec_dec_icdf( psRangeDec, silk_stereo_only_code_mid_iCDF, 8 ); } diff --git a/silk/silk_stereo_encode_pred.c b/silk/silk_stereo_encode_pred.c new file mode 100644 index 00000000..18546ab6 --- /dev/null +++ b/silk/silk_stereo_encode_pred.c @@ -0,0 +1,51 @@ +/*********************************************************************** +Copyright (c) 2006-2011, Skype Limited. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, (subject to the limitations in the disclaimer below) +are permitted provided that the following conditions are met: +- Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. +- Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. +- Neither the name of Skype Limited, nor the names of specific +contributors, may be used to endorse or promote products derived from +this software without specific prior written permission. +NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED +BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +***********************************************************************/ + +#include "silk_main.h" + +/* Entropy code the mid/side quantization indices */ +void silk_stereo_encode_pred( + ec_enc *psRangeEnc, /* I/O Compressor data structure */ + SKP_int8 ix[ 2 ][ 4 ] /* I Quantization indices */ +) +{ + SKP_int n; + + /* Entropy coding */ + n = 5 * ix[ 0 ][ 2 ] + ix[ 1 ][ 2 ]; + SKP_assert( n < 25 ); + ec_enc_icdf( psRangeEnc, n, silk_stereo_pred_joint_iCDF, 8 ); + for( n = 0; n < 2; n++ ) { + SKP_assert( ix[ n ][ 0 ] < 3 ); + SKP_assert( ix[ n ][ 1 ] < STEREO_QUANT_SUB_STEPS ); + ec_enc_icdf( psRangeEnc, ix[ n ][ 0 ], silk_uniform3_iCDF, 8 ); + ec_enc_icdf( psRangeEnc, ix[ n ][ 1 ], silk_uniform5_iCDF, 8 ); + } + + /* Encode flag that only mid channel is coded */ + ec_enc_icdf( psRangeEnc, ix[ 0 ][ 3 ], silk_stereo_only_code_mid_iCDF, 8 ); +} diff --git a/silk/SKP_Silk_stereo_find_predictor.c b/silk/silk_stereo_find_predictor.c similarity index 55% rename from silk/SKP_Silk_stereo_find_predictor.c rename to silk/silk_stereo_find_predictor.c index 0fa373b6..a36a3b90 100644 --- a/silk/SKP_Silk_stereo_find_predictor.c +++ b/silk/silk_stereo_find_predictor.c @@ -25,30 +25,45 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" +#include "silk_main.h" /* Find least-squares prediction gain for one signal based on another and quantize it */ -SKP_int32 SKP_Silk_stereo_find_predictor( /* O Returns predictor in Q13 */ +SKP_int32 silk_stereo_find_predictor( /* O Returns predictor in Q13 */ + SKP_int32 *ratio_Q14, /* O Ratio of residual and mid energies */ const SKP_int16 x[], /* I Basis signal */ const SKP_int16 y[], /* I Target signal */ - SKP_int length /* I Number of samples */ + SKP_int32 mid_res_amp_Q0[], /* I/O Smoothed mid, residual norms */ + SKP_int length, /* I Number of samples */ + SKP_int smooth_coef_Q16 /* I Smoothing coefficient */ ) { SKP_int scale, scale1, scale2; - SKP_int32 nrg1, nrg2, corr, pred_Q13; + SKP_int32 nrgx, nrgy, corr, pred_Q13; /* Find predictor */ - SKP_Silk_sum_sqr_shift( &nrg1, &scale1, x, length ); - SKP_Silk_sum_sqr_shift( &nrg2, &scale2, y, length ); - if( scale1 > scale2 ) { - scale = scale1; - } else { - scale = scale2; - nrg1 = SKP_RSHIFT32( nrg1, scale2 - scale1 ); - } - corr = SKP_Silk_inner_prod_aligned_scale( x, y, scale, length ); - pred_Q13 = SKP_DIV32_varQ( corr, SKP_max( nrg1, 1 ), 13 ); - pred_Q13 = SKP_LIMIT( pred_Q13, -SKP_FIX_CONST( 10, 13 ), SKP_FIX_CONST( 10, 13 ) ); + silk_sum_sqr_shift( &nrgx, &scale1, x, length ); + silk_sum_sqr_shift( &nrgy, &scale2, y, length ); + scale = SKP_max( scale1, scale2 ); + scale = scale + ( scale & 1 ); /* make even */ + nrgy = SKP_RSHIFT32( nrgy, scale - scale2 ); + nrgx = SKP_RSHIFT32( nrgx, scale - scale1 ); + nrgx = SKP_max( nrgx, 1 ); + corr = silk_inner_prod_aligned_scale( x, y, scale, length ); + pred_Q13 = silk_DIV32_varQ( corr, nrgx, 13 ); + pred_Q13 = SKP_SAT16( pred_Q13 ); + + /* Smoothed mid and residual norms */ + SKP_assert( smooth_coef_Q16 < 32768 ); + scale = SKP_RSHIFT( scale, 1 ); + mid_res_amp_Q0[ 0 ] = SKP_SMLAWB( mid_res_amp_Q0[ 0 ], SKP_LSHIFT( silk_SQRT_APPROX( nrgx ), scale ) - mid_res_amp_Q0[ 0 ], + smooth_coef_Q16 ); + nrgy = SKP_SUB_LSHIFT32( nrgy, SKP_SMULWB( corr, pred_Q13 ), 3 ); + mid_res_amp_Q0[ 1 ] = SKP_SMLAWB( mid_res_amp_Q0[ 1 ], SKP_LSHIFT( silk_SQRT_APPROX( nrgy ), scale ) - mid_res_amp_Q0[ 1 ], + smooth_coef_Q16 ); + + /* Ratio of smoothed residual and mid norms */ + *ratio_Q14 = silk_DIV32_varQ( mid_res_amp_Q0[ 1 ], SKP_max( mid_res_amp_Q0[ 0 ], 1 ), 14 ); + *ratio_Q14 = SKP_LIMIT( *ratio_Q14, 0, 32767 ); return pred_Q13; } diff --git a/silk/SKP_Silk_stereo_encode_pred.c b/silk/silk_stereo_quant_pred.c similarity index 68% rename from silk/SKP_Silk_stereo_encode_pred.c rename to silk/silk_stereo_quant_pred.c index 4bc38ed3..275605c7 100644 --- a/silk/SKP_Silk_stereo_encode_pred.c +++ b/silk/silk_stereo_quant_pred.c @@ -25,15 +25,16 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_main.h" +#include "silk_main.h" -/* Quantize mid/side predictors and entropy code the quantization indices */ -void SKP_Silk_stereo_encode_pred( - ec_enc *psRangeEnc, /* I/O Compressor data structure */ - SKP_int32 pred_Q13[] /* I/O Predictors (out: quantized) */ +/* Quantize mid/side predictors */ +void silk_stereo_quant_pred( + stereo_enc_state *state, /* I/O State */ + SKP_int32 pred_Q13[], /* I/O Predictors (out: quantized) */ + SKP_int8 ix[ 2 ][ 4 ] /* O Quantization indices */ ) { - SKP_int i, j, n, ibest[ 2 ] = { 0 }, jbest[ 2 ] = { 0 }, kbest[ 2 ]; + SKP_int i, j, n; SKP_int32 low_Q13, step_Q13, lvl_Q13, err_min_Q13, err_Q13, quant_pred_Q13 = 0; /* Quantize */ @@ -41,17 +42,17 @@ void SKP_Silk_stereo_encode_pred( /* Brute-force search over quantization levels */ err_min_Q13 = SKP_int32_MAX; for( i = 0; i < STEREO_QUANT_TAB_SIZE - 1; i++ ) { - low_Q13 = SKP_Silk_stereo_pred_quant_Q13[ i ]; - step_Q13 = SKP_SMULWB( SKP_Silk_stereo_pred_quant_Q13[ i + 1 ] - low_Q13, - SKP_FIX_CONST( 0.5 / STEREO_QUANT_SUB_STEPS, 16 ) ); + low_Q13 = silk_stereo_pred_quant_Q13[ i ]; + step_Q13 = SKP_SMULWB( silk_stereo_pred_quant_Q13[ i + 1 ] - low_Q13, + SILK_FIX_CONST( 0.5 / STEREO_QUANT_SUB_STEPS, 16 ) ); for( j = 0; j < STEREO_QUANT_SUB_STEPS; j++ ) { lvl_Q13 = SKP_SMLABB( low_Q13, step_Q13, 2 * j + 1 ); err_Q13 = SKP_abs( pred_Q13[ n ] - lvl_Q13 ); if( err_Q13 < err_min_Q13 ) { err_min_Q13 = err_Q13; quant_pred_Q13 = lvl_Q13; - ibest[ n ] = i; - jbest[ n ] = j; + ix[ n ][ 0 ] = i; + ix[ n ][ 1 ] = j; } else { /* Error increasing, so we're past the optimum */ goto done; @@ -59,22 +60,11 @@ void SKP_Silk_stereo_encode_pred( } } done: - kbest[ n ] = SKP_DIV32_16( ibest[ n ], 3 ); - ibest[ n ] -= kbest[ n ] * 3; + ix[ n ][ 2 ] = SKP_DIV32_16( ix[ n ][ 0 ], 3 ); + ix[ n ][ 0 ] -= ix[ n ][ 2 ] * 3; pred_Q13[ n ] = quant_pred_Q13; } /* Subtract second from first predictor (helps when actually applying these) */ pred_Q13[ 0 ] -= pred_Q13[ 1 ]; - - /* Entropy coding */ - i = 5 * kbest[ 0 ] + kbest[ 1 ]; - SKP_assert( i < 25 ); - ec_enc_icdf( psRangeEnc, i, SKP_Silk_stereo_pred_joint_iCDF, 8 ); - for( n = 0; n < 2; n++ ) { - SKP_assert( ibest[ n ] < 3 ); - SKP_assert( jbest[ n ] < STEREO_QUANT_SUB_STEPS ); - ec_enc_icdf( psRangeEnc, ibest[ n ], SKP_Silk_uniform3_iCDF, 8 ); - ec_enc_icdf( psRangeEnc, jbest[ n ], SKP_Silk_uniform5_iCDF, 8 ); - } } diff --git a/silk/SKP_Silk_structs.h b/silk/silk_structs.h similarity index 86% rename from silk/SKP_Silk_structs.h rename to silk/silk_structs.h index 75f58d3f..efcda6e5 100644 --- a/silk/SKP_Silk_structs.h +++ b/silk/silk_structs.h @@ -25,16 +25,16 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#ifndef SKP_SILK_STRUCTS_H -#define SKP_SILK_STRUCTS_H +#ifndef SILK_STRUCTS_H +#define SILK_STRUCTS_H #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include "SKP_Silk_typedef.h" -#include "SKP_Silk_SigProc_FIX.h" -#include "SKP_Silk_define.h" +#include "silk_typedef.h" +#include "silk_SigProc_FIX.h" +#include "silk_define.h" #include "entenc.h" #include "entdec.h" @@ -58,7 +58,7 @@ typedef struct { SKP_int32 rand_seed; SKP_int32 prev_inv_gain_Q16; SKP_int rewhite_flag; -} SKP_Silk_nsq_state; +} silk_nsq_state; /********************************/ /* VAD state */ @@ -74,14 +74,14 @@ typedef struct { SKP_int32 inv_NL[ VAD_N_BANDS ]; /* Inverse noise energy level in each band */ SKP_int32 NoiseLevelBias[ VAD_N_BANDS ]; /* Noise level estimator bias/offset */ SKP_int32 counter; /* Frame counter used in the initial phase */ -} SKP_Silk_VAD_state; +} silk_VAD_state; /* Variable cut-off low-pass filter state */ typedef struct { SKP_int32 In_LP_State[ 2 ]; /* Low pass filter state */ SKP_int32 transition_frame_no; /* Counter which is mapped to a cut-off frequency */ SKP_int mode; /* Operating mode, <0: switch down, >0: switch up; 0: do nothing */ -} SKP_Silk_LP_state; +} silk_LP_state; /* Structure containing NLSF codebook */ typedef struct { @@ -96,26 +96,36 @@ typedef struct { const SKP_uint8 *ec_iCDF; const SKP_uint8 *ec_Rates_Q5; const SKP_int16 *deltaMin_Q15; -} SKP_Silk_NLSF_CB_struct; +} silk_NLSF_CB_struct; typedef struct { - SKP_int32 pred_prev_Q13[ 2 ]; + SKP_int16 pred_prev_Q13[ 2 ]; SKP_int16 sMid[ 2 ]; SKP_int16 sSide[ 2 ]; -} stereo_state; + SKP_int32 mid_side_amp_Q0[ 4 ]; + SKP_int16 smth_width_Q14; + SKP_int16 width_prev_Q14; + SKP_int8 ix[ MAX_FRAMES_PER_PACKET ][ 2 ][ 4 ]; +} stereo_enc_state; typedef struct { - SKP_int8 GainsIndices[ MAX_NB_SUBFR ]; - SKP_int8 LTPIndex[ MAX_NB_SUBFR ]; - SKP_int8 NLSFIndices[ MAX_LPC_ORDER + 1 ]; - SKP_int16 lagIndex; - SKP_int8 contourIndex; - SKP_int8 signalType; - SKP_int8 quantOffsetType; - SKP_int8 NLSFInterpCoef_Q2; - SKP_int8 PERIndex; - SKP_int8 LTP_scaleIndex; - SKP_int8 Seed; + SKP_int16 pred_prev_Q13[ 2 ]; + SKP_int16 sMid[ 2 ]; + SKP_int16 sSide[ 2 ]; +} stereo_dec_state; + +typedef struct { + SKP_int8 GainsIndices[ MAX_NB_SUBFR ]; + SKP_int8 LTPIndex[ MAX_NB_SUBFR ]; + SKP_int8 NLSFIndices[ MAX_LPC_ORDER + 1 ]; + SKP_int16 lagIndex; + SKP_int8 contourIndex; + SKP_int8 signalType; + SKP_int8 quantOffsetType; + SKP_int8 NLSFInterpCoef_Q2; + SKP_int8 PERIndex; + SKP_int8 LTP_scaleIndex; + SKP_int8 Seed; } SideInfoIndices; /********************************/ @@ -125,9 +135,9 @@ typedef struct { SKP_int32 In_HP_State[ 2 ]; /* High pass filter state */ SKP_int32 variable_HP_smth1_Q15; /* State of first smoother */ SKP_int32 variable_HP_smth2_Q15; /* State of second smoother */ - SKP_Silk_LP_state sLP; /* Low pass filter state */ - SKP_Silk_VAD_state sVAD; /* Voice activity detector state */ - SKP_Silk_nsq_state sNSQ; /* Noise Shape Quantizer State */ + silk_LP_state sLP; /* Low pass filter state */ + silk_VAD_state sVAD; /* Voice activity detector state */ + silk_nsq_state sNSQ; /* Noise Shape Quantizer State */ SKP_int16 prev_NLSFq_Q15[ MAX_LPC_ORDER ];/* Previously quantized NLSF vector */ SKP_int speech_activity_Q8; /* Speech activity */ SKP_int allow_bandwidth_switch; /* Flag indicating that switching of internal bandwidth is allowed */ @@ -153,7 +163,7 @@ typedef struct { SKP_int PacketSize_ms; /* Number of milliseconds to put in each packet */ SKP_int PacketLoss_perc; /* Packet loss rate measured by farend */ SKP_int32 frameCounter; - SKP_int Complexity; /* Complexity setting: 0-> low; 1-> medium; 2->high */ + SKP_int Complexity; /* Complexity setting */ SKP_int nStatesDelayedDecision; /* Number of states in delayed decision quantization */ SKP_int useInterpolatedNLSFs; /* Flag for using NLSF interpolation */ SKP_int shapingLPCOrder; /* Filter order for noise shaping filters */ @@ -171,7 +181,7 @@ typedef struct { SKP_int prefillFlag; /* Flag to indicate that only buffers are prefilled, no coding */ const SKP_uint8 *pitch_lag_low_bits_iCDF; /* Pointer to iCDF table for low bits of pitch lag index */ const SKP_uint8 *pitch_contour_iCDF; /* Pointer to iCDF table for pitch contour index */ - const SKP_Silk_NLSF_CB_struct *psNLSF_CB; /* Pointer to NLSF codebook */ + const silk_NLSF_CB_struct *psNLSF_CB; /* Pointer to NLSF codebook */ SKP_int input_quality_bands_Q15[ VAD_N_BANDS ]; SKP_int input_tilt_Q15; SKP_int SNR_dB_Q7; /* Quality setting */ @@ -184,12 +194,14 @@ typedef struct { SKP_int8 pulses[ MAX_FRAME_LENGTH ]; /* Input/output buffering */ - SKP_int16 inputBuf[ MAX_FRAME_LENGTH ]; /* buffer containing input signal */ + SKP_int16 inputBuf__[ MAX_FRAME_LENGTH + 2 ]; /* Buffer containing input signal */ + SKP_int16 *inputBuf; /* Points to second element of above buffer */ SKP_int inputBufIx; SKP_int nFramesPerPacket; - SKP_int nFramesAnalyzed; /* Number of frames analyzed in current packet */ + SKP_int nFramesEncoded; /* Number of frames analyzed in current packet */ - SKP_int nChannels; + SKP_int nChannelsAPI; + SKP_int nChannelsInternal; SKP_int channelNb; /* Parameters For LTP scaling Control */ @@ -199,7 +211,7 @@ typedef struct { SKP_int ec_prevSignalType; SKP_int16 ec_prevLagIndex; - SKP_Silk_resampler_state_struct resampler_state; + silk_resampler_state_struct resampler_state; /* DTX */ SKP_int useDTX; /* Flag to enable DTX */ @@ -209,10 +221,10 @@ typedef struct { /* Inband Low Bitrate Redundancy (LBRR) data */ SKP_int useInBandFEC; /* Saves the API setting for query */ SKP_int LBRR_enabled; /* Depends on useInBandFRC, bitrate and packet loss rate */ - SKP_int LBRR_GainIncreases; /* Number of shifts to Gains to get LBRR rate Voiced frames */ + SKP_int LBRR_GainIncreases; /* Gains increment for coding LBRR frames */ SideInfoIndices indices_LBRR[ MAX_FRAMES_PER_PACKET ]; SKP_int8 pulses_LBRR[ MAX_FRAMES_PER_PACKET ][ MAX_FRAME_LENGTH ]; -} SKP_Silk_encoder_state; +} silk_encoder_state; /* Struct for Packet Loss Concealment */ @@ -228,7 +240,7 @@ typedef struct { SKP_int16 prevLTP_scale_Q14; SKP_int32 prevGain_Q16[ MAX_NB_SUBFR ]; SKP_int fs_kHz; -} SKP_Silk_PLC_struct; +} silk_PLC_struct; /* Struct for CNG */ typedef struct { @@ -238,7 +250,7 @@ typedef struct { SKP_int32 CNG_smth_Gain_Q16; SKP_int32 rand_seed; SKP_int fs_kHz; -} SKP_Silk_CNG_struct; +} silk_CNG_struct; /********************************/ /* Decoder state */ @@ -275,23 +287,23 @@ typedef struct { SKP_int LBRR_flag; SKP_int LBRR_flags[ MAX_FRAMES_PER_PACKET ]; - SKP_Silk_resampler_state_struct resampler_state; + silk_resampler_state_struct resampler_state; - const SKP_Silk_NLSF_CB_struct *psNLSF_CB; /* Pointer to NLSF codebook */ + const silk_NLSF_CB_struct *psNLSF_CB; /* Pointer to NLSF codebook */ /* Quantization indices */ SideInfoIndices indices; /* CNG state */ - SKP_Silk_CNG_struct sCNG; + silk_CNG_struct sCNG; /* Stuff used for PLC */ SKP_int lossCnt; SKP_int prevSignalType; - SKP_Silk_PLC_struct sPLC; + silk_PLC_struct sPLC; -} SKP_Silk_decoder_state; +} silk_decoder_state; /************************/ /* Decoder control */ @@ -304,7 +316,7 @@ typedef struct { SKP_DWORD_ALIGN SKP_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ]; SKP_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ]; SKP_int LTP_scale_Q14; -} SKP_Silk_decoder_control; +} silk_decoder_control; #ifdef __cplusplus diff --git a/silk/SKP_Silk_sum_sqr_shift.c b/silk/silk_sum_sqr_shift.c similarity index 96% rename from silk/SKP_Silk_sum_sqr_shift.c rename to silk/silk_sum_sqr_shift.c index d1848ef2..ddf3b3df 100644 --- a/silk/SKP_Silk_sum_sqr_shift.c +++ b/silk/silk_sum_sqr_shift.c @@ -25,11 +25,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_SigProc_FIX.h" /* Compute number of bits to right shift the sum of squares of a vector */ /* of int16s to make it fit in an int32 */ -void SKP_Silk_sum_sqr_shift( +void silk_sum_sqr_shift( SKP_int32 *energy, /* O Energy of x, after shifting to the right */ SKP_int *shift, /* O Number of bits right shift applied to energy */ const SKP_int16 *x, /* I Input vector */ diff --git a/silk/SKP_Silk_LSF_cos_table.c b/silk/silk_table_LSF_cos.c similarity index 94% rename from silk/SKP_Silk_LSF_cos_table.c rename to silk/silk_table_LSF_cos.c index 1fc87a7a..653a8d1b 100644 --- a/silk/SKP_Silk_LSF_cos_table.c +++ b/silk/silk_table_LSF_cos.c @@ -25,10 +25,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_SigProc_FIX.h" +#include "silk_tables.h" -// Q12 values (even) -const SKP_int SKP_Silk_LSFCosTab_FIX_Q12[LSF_COS_TAB_SZ_FIX + 1] = { +/* Cosine approximation table for LSF conversion */ +/* Q12 values (even) */ +const SKP_int16 silk_LSFCosTab_FIX_Q12[ LSF_COS_TAB_SZ_FIX + 1 ] = { 8192, 8190, 8182, 8170, 8152, 8130, 8104, 8072, 8034, 7994, 7946, 7896, diff --git a/silk/silk_tables.h b/silk/silk_tables.h new file mode 100644 index 00000000..85456ad5 --- /dev/null +++ b/silk/silk_tables.h @@ -0,0 +1,120 @@ +/*********************************************************************** +Copyright (c) 2006-2011, Skype Limited. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, (subject to the limitations in the disclaimer below) +are permitted provided that the following conditions are met: +- Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. +- Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. +- Neither the name of Skype Limited, nor the names of specific +contributors, may be used to endorse or promote products derived from +this software without specific prior written permission. +NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED +BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +***********************************************************************/ + +#ifndef SILK_TABLES_H +#define SILK_TABLES_H + +#include "silk_define.h" +#include "silk_structs.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/* entropy coding tables */ +extern const SKP_uint8 silk_gain_iCDF[ 3 ][ N_LEVELS_QGAIN / 8 ]; /* 24 */ +extern const SKP_uint8 silk_delta_gain_iCDF[ MAX_DELTA_GAIN_QUANT - MIN_DELTA_GAIN_QUANT + 1 ]; /* 41 */ + +extern const SKP_uint8 silk_pitch_lag_iCDF[ 2 * ( PITCH_EST_MAX_LAG_MS - PITCH_EST_MIN_LAG_MS ) ]; /* 32 */ +extern const SKP_uint8 silk_pitch_delta_iCDF[ 21 ]; /* 21 */ +extern const SKP_uint8 silk_pitch_contour_iCDF[ 34 ]; /* 34 */ +extern const SKP_uint8 silk_pitch_contour_NB_iCDF[ 11 ]; /* 11 */ +extern const SKP_uint8 silk_pitch_contour_10_ms_iCDF[ 12 ]; /* 12 */ +extern const SKP_uint8 silk_pitch_contour_10_ms_NB_iCDF[ 3 ]; /* 3 */ + +extern const SKP_uint8 silk_pulses_per_block_iCDF[ N_RATE_LEVELS ][ MAX_PULSES + 2 ]; /* 180 */ +extern const SKP_uint8 silk_pulses_per_block_BITS_Q5[ N_RATE_LEVELS - 1 ][ MAX_PULSES + 2 ]; /* 162 */ + +extern const SKP_uint8 silk_rate_levels_iCDF[ 2 ][ N_RATE_LEVELS - 1 ]; /* 18 */ +extern const SKP_uint8 silk_rate_levels_BITS_Q5[ 2 ][ N_RATE_LEVELS - 1 ]; /* 18 */ + +extern const SKP_uint8 silk_max_pulses_table[ 4 ]; /* 4 */ + +extern const SKP_uint8 silk_shell_code_table0[ 44 ]; /* 44 */ +extern const SKP_uint8 silk_shell_code_table1[ 65 ]; /* 65 */ +extern const SKP_uint8 silk_shell_code_table2[ 90 ]; /* 90 */ +extern const SKP_uint8 silk_shell_code_table3[ 152 ]; /* 152 */ +extern const SKP_uint8 silk_shell_code_table_offsets[ MAX_PULSES + 1 ]; /* 17 */ + +extern const SKP_uint8 silk_lsb_iCDF[ 2 ]; /* 2 */ + +extern const SKP_uint8 silk_sign_iCDF[ 36 ]; /* 36 */ + +extern const SKP_uint8 silk_uniform3_iCDF[ 3 ]; /* 3 */ +extern const SKP_uint8 silk_uniform4_iCDF[ 4 ]; /* 4 */ +extern const SKP_uint8 silk_uniform5_iCDF[ 5 ]; /* 5 */ +extern const SKP_uint8 silk_uniform6_iCDF[ 6 ]; /* 6 */ +extern const SKP_uint8 silk_uniform8_iCDF[ 8 ]; /* 8 */ + +extern const SKP_uint8 silk_NLSF_EXT_iCDF[ 7 ]; /* 7 */ + +extern const SKP_uint8 silk_LTP_per_index_iCDF[ 3 ]; /* 3 */ +extern const SKP_uint8 * const silk_LTP_gain_iCDF_ptrs[ NB_LTP_CBKS ]; /* 3 */ +extern const SKP_uint8 * const silk_LTP_gain_BITS_Q5_ptrs[ NB_LTP_CBKS ]; /* 3 */ +extern const SKP_int16 silk_LTP_gain_middle_avg_RD_Q14; +extern const SKP_int8 * const silk_LTP_vq_ptrs_Q7[ NB_LTP_CBKS ]; /* 168 */ +extern const SKP_int8 silk_LTP_vq_sizes[ NB_LTP_CBKS ]; /* 3 */ + +extern const SKP_uint8 silk_LTPscale_iCDF[ 3 ]; /* 4 */ +extern const SKP_int16 silk_LTPScales_table_Q14[ 3 ]; + +extern const SKP_uint8 silk_type_offset_VAD_iCDF[ 4 ]; /* 4 */ +extern const SKP_uint8 silk_type_offset_no_VAD_iCDF[ 2 ]; /* 2 */ + +extern const SKP_int16 silk_stereo_pred_quant_Q13[ STEREO_QUANT_TAB_SIZE ]; /* 32 */ +extern const SKP_uint8 silk_stereo_pred_joint_iCDF[ 25 ]; /* 25 */ +extern const SKP_uint8 silk_stereo_only_code_mid_iCDF[ 2 ]; /* 2 */ + +extern const SKP_uint8 * const silk_LBRR_flags_iCDF_ptr[ 2 ]; /* 10 */ + +extern const SKP_uint8 silk_NLSF_interpolation_factor_iCDF[ 5 ]; /* 5 */ + +extern const silk_NLSF_CB_struct silk_NLSF_CB_WB; +extern const silk_NLSF_CB_struct silk_NLSF_CB_NB_MB; + +/* Piece-wise linear mapping from bitrate in kbps to coding quality in dB SNR */ +extern const SKP_int32 silk_TargetRate_table_NB[ TARGET_RATE_TAB_SZ ]; +extern const SKP_int32 silk_TargetRate_table_MB[ TARGET_RATE_TAB_SZ ]; +extern const SKP_int32 silk_TargetRate_table_WB[ TARGET_RATE_TAB_SZ ]; +extern const SKP_int16 silk_SNR_table_Q1[ TARGET_RATE_TAB_SZ ]; + +/* Quantization offsets */ +extern const SKP_int16 silk_Quantization_Offsets_Q10[ 2 ][ 2 ]; + +/* Interpolation points for filter coefficients used in the bandwidth transition smoother */ +extern const SKP_int32 silk_Transition_LP_B_Q28[ TRANSITION_INT_NUM ][ TRANSITION_NB ]; +extern const SKP_int32 silk_Transition_LP_A_Q28[ TRANSITION_INT_NUM ][ TRANSITION_NA ]; + +/* Rom table with cosine values */ +extern const SKP_int16 silk_LSFCosTab_FIX_Q12[ LSF_COS_TAB_SZ_FIX + 1 ]; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/silk/SKP_Silk_tables_LTP.c b/silk/silk_tables_LTP.c similarity index 78% rename from silk/SKP_Silk_tables_LTP.c rename to silk/silk_tables_LTP.c index 78d9c447..851c8cd5 100644 --- a/silk/SKP_Silk_tables_LTP.c +++ b/silk/silk_tables_LTP.c @@ -25,59 +25,59 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_tables.h" +#include "silk_tables.h" -const SKP_uint8 SKP_Silk_LTP_per_index_iCDF[3] = { +const SKP_uint8 silk_LTP_per_index_iCDF[3] = { 179, 99, 0 }; -const SKP_uint8 SKP_Silk_LTP_gain_iCDF_0[8] = { +const SKP_uint8 silk_LTP_gain_iCDF_0[8] = { 71, 56, 43, 30, 21, 12, 6, 0 }; -const SKP_uint8 SKP_Silk_LTP_gain_iCDF_1[16] = { +const SKP_uint8 silk_LTP_gain_iCDF_1[16] = { 199, 165, 144, 124, 109, 96, 84, 71, 61, 51, 42, 32, 23, 15, 8, 0 }; -const SKP_uint8 SKP_Silk_LTP_gain_iCDF_2[32] = { +const SKP_uint8 silk_LTP_gain_iCDF_2[32] = { 241, 225, 211, 199, 187, 175, 164, 153, 142, 132, 123, 114, 105, 96, 88, 80, 72, 64, 57, 50, 44, 38, 33, 29, 24, 20, 16, 12, 9, 5, 2, 0 }; -const SKP_int16 SKP_Silk_LTP_gain_middle_avg_RD_Q14 = 12304; +const SKP_int16 silk_LTP_gain_middle_avg_RD_Q14 = 12304; -const SKP_uint8 SKP_Silk_LTP_gain_BITS_Q5_0[8] = { +const SKP_uint8 silk_LTP_gain_BITS_Q5_0[8] = { 15, 131, 138, 138, 155, 155, 173, 173 }; -const SKP_uint8 SKP_Silk_LTP_gain_BITS_Q5_1[16] = { +const SKP_uint8 silk_LTP_gain_BITS_Q5_1[16] = { 69, 93, 115, 118, 131, 138, 141, 138, 150, 150, 155, 150, 155, 160, 166, 160 }; -const SKP_uint8 SKP_Silk_LTP_gain_BITS_Q5_2[32] = { +const SKP_uint8 silk_LTP_gain_BITS_Q5_2[32] = { 131, 128, 134, 141, 141, 141, 145, 145, 145, 150, 155, 155, 155, 155, 160, 160, 160, 160, 166, 166, 173, 173, 182, 192, 182, 192, 192, 192, 205, 192, 205, 224 }; -const SKP_uint8 * const SKP_Silk_LTP_gain_iCDF_ptrs[NB_LTP_CBKS] = { - SKP_Silk_LTP_gain_iCDF_0, - SKP_Silk_LTP_gain_iCDF_1, - SKP_Silk_LTP_gain_iCDF_2 +const SKP_uint8 * const silk_LTP_gain_iCDF_ptrs[NB_LTP_CBKS] = { + silk_LTP_gain_iCDF_0, + silk_LTP_gain_iCDF_1, + silk_LTP_gain_iCDF_2 }; -const SKP_uint8 * const SKP_Silk_LTP_gain_BITS_Q5_ptrs[NB_LTP_CBKS] = { - SKP_Silk_LTP_gain_BITS_Q5_0, - SKP_Silk_LTP_gain_BITS_Q5_1, - SKP_Silk_LTP_gain_BITS_Q5_2 +const SKP_uint8 * const silk_LTP_gain_BITS_Q5_ptrs[NB_LTP_CBKS] = { + silk_LTP_gain_BITS_Q5_0, + silk_LTP_gain_BITS_Q5_1, + silk_LTP_gain_BITS_Q5_2 }; -const SKP_int8 SKP_Silk_LTP_gain_vq_0[8][5] = +const SKP_int8 silk_LTP_gain_vq_0[8][5] = { { 4, 6, 24, 7, 5 @@ -105,7 +105,7 @@ const SKP_int8 SKP_Silk_LTP_gain_vq_0[8][5] = } }; -const SKP_int8 SKP_Silk_LTP_gain_vq_1[16][5] = +const SKP_int8 silk_LTP_gain_vq_1[16][5] = { { 13, 22, 39, 23, 12 @@ -157,7 +157,7 @@ const SKP_int8 SKP_Silk_LTP_gain_vq_1[16][5] = } }; -const SKP_int8 SKP_Silk_LTP_gain_vq_2[32][5] = +const SKP_int8 silk_LTP_gain_vq_2[32][5] = { { -6, 27, 61, 39, 5 @@ -257,12 +257,12 @@ const SKP_int8 SKP_Silk_LTP_gain_vq_2[32][5] = } }; -const SKP_int8 * const SKP_Silk_LTP_vq_ptrs_Q7[NB_LTP_CBKS] = { - (SKP_int8 *)&SKP_Silk_LTP_gain_vq_0[0][0], - (SKP_int8 *)&SKP_Silk_LTP_gain_vq_1[0][0], - (SKP_int8 *)&SKP_Silk_LTP_gain_vq_2[0][0] +const SKP_int8 * const silk_LTP_vq_ptrs_Q7[NB_LTP_CBKS] = { + (SKP_int8 *)&silk_LTP_gain_vq_0[0][0], + (SKP_int8 *)&silk_LTP_gain_vq_1[0][0], + (SKP_int8 *)&silk_LTP_gain_vq_2[0][0] }; -const SKP_int8 SKP_Silk_LTP_vq_sizes[NB_LTP_CBKS] = { +const SKP_int8 silk_LTP_vq_sizes[NB_LTP_CBKS] = { 8, 16, 32 }; diff --git a/silk/SKP_Silk_tables_NLSF_CB_NB_MB.c b/silk/silk_tables_NLSF_CB_NB_MB.c similarity index 89% rename from silk/SKP_Silk_tables_NLSF_CB_NB_MB.c rename to silk/silk_tables_NLSF_CB_NB_MB.c index 48a84aec..5322531b 100644 --- a/silk/SKP_Silk_tables_NLSF_CB_NB_MB.c +++ b/silk/silk_tables_NLSF_CB_NB_MB.c @@ -25,9 +25,9 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_structs.h" +#include "silk_structs.h" -const SKP_uint8 SKP_Silk_NLSF_CB1_NB_MB_Q8[ 320 ] = { +const SKP_uint8 silk_NLSF_CB1_NB_MB_Q8[ 320 ] = { 12, 35, 60, 83, 108, 132, 157, 180, 206, 228, 15, 32, 55, 77, 101, 125, 151, 175, 201, 225, 19, 42, 66, 89, @@ -70,7 +70,7 @@ const SKP_uint8 SKP_Silk_NLSF_CB1_NB_MB_Q8[ 320 ] = { 64, 84, 104, 118, 156, 177, 201, 230 }; -const SKP_uint8 SKP_Silk_NLSF_CB1_iCDF_NB_MB[ 64 ] = { +const SKP_uint8 silk_NLSF_CB1_iCDF_NB_MB[ 64 ] = { 212, 178, 148, 129, 108, 96, 85, 82, 79, 77, 61, 59, 57, 56, 51, 49, 48, 45, 42, 41, 40, 38, 36, 34, @@ -81,7 +81,7 @@ const SKP_uint8 SKP_Silk_NLSF_CB1_iCDF_NB_MB[ 64 ] = { 28, 20, 19, 18, 12, 11, 5, 0 }; -const SKP_uint8 SKP_Silk_NLSF_CB2_SELECT_NB_MB[ 160 ] = { +const SKP_uint8 silk_NLSF_CB2_SELECT_NB_MB[ 160 ] = { 16, 0, 0, 0, 0, 99, 66, 36, 36, 34, 36, 34, 34, 34, 34, 83, 69, 36, 52, 34, 116, 102, 70, 68, @@ -104,7 +104,7 @@ const SKP_uint8 SKP_Silk_NLSF_CB2_SELECT_NB_MB[ 160 ] = { 171, 137, 139, 137, 155, 218, 219, 139 }; -const SKP_uint8 SKP_Silk_NLSF_CB2_iCDF_NB_MB[ 72 ] = { +const SKP_uint8 silk_NLSF_CB2_iCDF_NB_MB[ 72 ] = { 255, 254, 253, 238, 14, 3, 2, 1, 0, 255, 254, 252, 218, 35, 3, 2, 1, 0, 255, 254, 250, 208, 59, 4, @@ -116,7 +116,7 @@ const SKP_uint8 SKP_Silk_NLSF_CB2_iCDF_NB_MB[ 72 ] = { 254, 236, 173, 95, 37, 7, 1, 0 }; -const SKP_uint8 SKP_Silk_NLSF_CB2_BITS_NB_MB_Q5[ 72 ] = { +const SKP_uint8 silk_NLSF_CB2_BITS_NB_MB_Q5[ 72 ] = { 255, 255, 255, 131, 6, 145, 255, 255, 255, 255, 255, 236, 93, 15, 96, 255, 255, 255, 255, 255, 194, 83, 25, 71, @@ -128,28 +128,28 @@ const SKP_uint8 SKP_Silk_NLSF_CB2_BITS_NB_MB_Q5[ 72 ] = { 251, 123, 65, 55, 68, 100, 171, 255 }; -const SKP_uint8 SKP_Silk_NLSF_PRED_NB_MB_Q8[ 18 ] = { +const SKP_uint8 silk_NLSF_PRED_NB_MB_Q8[ 18 ] = { 179, 138, 140, 148, 151, 149, 153, 151, 163, 116, 67, 82, 59, 92, 72, 100, 89, 92 }; -const SKP_int16 SKP_Silk_NLSF_DELTA_MIN_NB_MB_Q15[ 11 ] = { +const SKP_int16 silk_NLSF_DELTA_MIN_NB_MB_Q15[ 11 ] = { 322, 3, 6, 3, 3, 3, 4, 3, 3, 3, 461 }; -const SKP_Silk_NLSF_CB_struct SKP_Silk_NLSF_CB_NB_MB = +const silk_NLSF_CB_struct silk_NLSF_CB_NB_MB = { 32, 10, - SKP_FIX_CONST( 0.18, 16 ), - SKP_FIX_CONST( 1.0 / 0.18, 6 ), - SKP_Silk_NLSF_CB1_NB_MB_Q8, - SKP_Silk_NLSF_CB1_iCDF_NB_MB, - SKP_Silk_NLSF_PRED_NB_MB_Q8, - SKP_Silk_NLSF_CB2_SELECT_NB_MB, - SKP_Silk_NLSF_CB2_iCDF_NB_MB, - SKP_Silk_NLSF_CB2_BITS_NB_MB_Q5, - SKP_Silk_NLSF_DELTA_MIN_NB_MB_Q15, + SILK_FIX_CONST( 0.18, 16 ), + SILK_FIX_CONST( 1.0 / 0.18, 6 ), + silk_NLSF_CB1_NB_MB_Q8, + silk_NLSF_CB1_iCDF_NB_MB, + silk_NLSF_PRED_NB_MB_Q8, + silk_NLSF_CB2_SELECT_NB_MB, + silk_NLSF_CB2_iCDF_NB_MB, + silk_NLSF_CB2_BITS_NB_MB_Q5, + silk_NLSF_DELTA_MIN_NB_MB_Q15, }; diff --git a/silk/SKP_Silk_tables_NLSF_CB_WB.c b/silk/silk_tables_NLSF_CB_WB.c similarity index 91% rename from silk/SKP_Silk_tables_NLSF_CB_WB.c rename to silk/silk_tables_NLSF_CB_WB.c index d2e1945f..afa40f7c 100644 --- a/silk/SKP_Silk_tables_NLSF_CB_WB.c +++ b/silk/silk_tables_NLSF_CB_WB.c @@ -25,9 +25,9 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_structs.h" +#include "silk_structs.h" -const SKP_uint8 SKP_Silk_NLSF_CB1_WB_Q8[ 512 ] = { +const SKP_uint8 silk_NLSF_CB1_WB_Q8[ 512 ] = { 7, 23, 38, 54, 69, 85, 100, 116, 131, 147, 162, 178, 193, 208, 223, 239, 13, 25, 41, 55, 69, 83, 98, 112, @@ -94,7 +94,7 @@ const SKP_uint8 SKP_Silk_NLSF_CB1_WB_Q8[ 512 ] = { 110, 119, 129, 141, 175, 198, 218, 237 }; -const SKP_uint8 SKP_Silk_NLSF_CB1_iCDF_WB[ 64 ] = { +const SKP_uint8 silk_NLSF_CB1_iCDF_WB[ 64 ] = { 225, 204, 201, 184, 183, 175, 158, 154, 153, 135, 119, 115, 113, 110, 109, 99, 98, 95, 79, 68, 52, 50, 48, 45, @@ -105,7 +105,7 @@ const SKP_uint8 SKP_Silk_NLSF_CB1_iCDF_WB[ 64 ] = { 24, 21, 11, 6, 5, 4, 3, 0 }; -const SKP_uint8 SKP_Silk_NLSF_CB2_SELECT_WB[ 256 ] = { +const SKP_uint8 silk_NLSF_CB2_SELECT_WB[ 256 ] = { 0, 0, 0, 0, 0, 0, 0, 1, 100, 102, 102, 68, 68, 36, 34, 96, 164, 107, 158, 185, 180, 185, 139, 102, @@ -140,7 +140,7 @@ const SKP_uint8 SKP_Silk_NLSF_CB2_SELECT_WB[ 256 ] = { 100, 107, 120, 119, 36, 197, 24, 0 }; -const SKP_uint8 SKP_Silk_NLSF_CB2_iCDF_WB[ 72 ] = { +const SKP_uint8 silk_NLSF_CB2_iCDF_WB[ 72 ] = { 255, 254, 253, 244, 12, 3, 2, 1, 0, 255, 254, 252, 224, 38, 3, 2, 1, 0, 255, 254, 251, 209, 57, 4, @@ -152,7 +152,7 @@ const SKP_uint8 SKP_Silk_NLSF_CB2_iCDF_WB[ 72 ] = { 248, 227, 177, 100, 19, 2, 1, 0 }; -const SKP_uint8 SKP_Silk_NLSF_CB2_BITS_WB_Q5[ 72 ] = { +const SKP_uint8 silk_NLSF_CB2_BITS_WB_Q5[ 72 ] = { 255, 255, 255, 156, 4, 154, 255, 255, 255, 255, 255, 227, 102, 15, 92, 255, 255, 255, 255, 255, 213, 83, 24, 72, @@ -164,30 +164,30 @@ const SKP_uint8 SKP_Silk_NLSF_CB2_BITS_WB_Q5[ 72 ] = { 166, 116, 76, 55, 53, 125, 255, 255 }; -const SKP_uint8 SKP_Silk_NLSF_PRED_WB_Q8[ 30 ] = { +const SKP_uint8 silk_NLSF_PRED_WB_Q8[ 30 ] = { 175, 148, 160, 176, 178, 173, 174, 164, 177, 174, 196, 182, 198, 192, 182, 68, 62, 66, 60, 72, 117, 85, 90, 118, 136, 151, 142, 160, 142, 155 }; -const SKP_int16 SKP_Silk_NLSF_DELTA_MIN_WB_Q15[ 17 ] = { +const SKP_int16 silk_NLSF_DELTA_MIN_WB_Q15[ 17 ] = { 121, 3, 42, 3, 3, 3, 5, 14, 14, 10, 11, 3, 8, 9, 7, 3, 347 }; -const SKP_Silk_NLSF_CB_struct SKP_Silk_NLSF_CB_WB = +const silk_NLSF_CB_struct silk_NLSF_CB_WB = { 32, 16, - SKP_FIX_CONST( 0.16, 16 ), - SKP_FIX_CONST( 1.0 / 0.16, 6 ), - SKP_Silk_NLSF_CB1_WB_Q8, - SKP_Silk_NLSF_CB1_iCDF_WB, - SKP_Silk_NLSF_PRED_WB_Q8, - SKP_Silk_NLSF_CB2_SELECT_WB, - SKP_Silk_NLSF_CB2_iCDF_WB, - SKP_Silk_NLSF_CB2_BITS_WB_Q5, - SKP_Silk_NLSF_DELTA_MIN_WB_Q15, + SILK_FIX_CONST( 0.16, 16 ), + SILK_FIX_CONST( 1.0 / 0.16, 6 ), + silk_NLSF_CB1_WB_Q8, + silk_NLSF_CB1_iCDF_WB, + silk_NLSF_PRED_WB_Q8, + silk_NLSF_CB2_SELECT_WB, + silk_NLSF_CB2_iCDF_WB, + silk_NLSF_CB2_BITS_WB_Q5, + silk_NLSF_DELTA_MIN_WB_Q15, }; diff --git a/silk/SKP_Silk_tables_gain.c b/silk/silk_tables_gain.c similarity index 90% rename from silk/SKP_Silk_tables_gain.c rename to silk/silk_tables_gain.c index c3953df8..a03ff283 100644 --- a/silk/SKP_Silk_tables_gain.c +++ b/silk/silk_tables_gain.c @@ -25,14 +25,14 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_tables.h" +#include "silk_tables.h" #ifdef __cplusplus extern "C" { #endif -const SKP_uint8 SKP_Silk_gain_iCDF[ 3 ][ N_LEVELS_QGAIN / 8 ] = +const SKP_uint8 silk_gain_iCDF[ 3 ][ N_LEVELS_QGAIN / 8 ] = { { 224, 112, 44, 15, 3, 2, 1, 0 @@ -45,7 +45,7 @@ const SKP_uint8 SKP_Silk_gain_iCDF[ 3 ][ N_LEVELS_QGAIN / 8 ] = } }; -const SKP_uint8 SKP_Silk_delta_gain_iCDF[ MAX_DELTA_GAIN_QUANT - MIN_DELTA_GAIN_QUANT + 1 ] = { +const SKP_uint8 silk_delta_gain_iCDF[ MAX_DELTA_GAIN_QUANT - MIN_DELTA_GAIN_QUANT + 1 ] = { 250, 245, 234, 203, 71, 50, 42, 38, 35, 33, 31, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, diff --git a/silk/SKP_Silk_tables_other.c b/silk/silk_tables_other.c similarity index 62% rename from silk/SKP_Silk_tables_other.c rename to silk/silk_tables_other.c index 2cbf607e..80dfde03 100644 --- a/silk/SKP_Silk_tables_other.c +++ b/silk/silk_tables_other.c @@ -25,9 +25,9 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_structs.h" -#include "SKP_Silk_define.h" -#include "SKP_Silk_tables.h" +#include "silk_structs.h" +#include "silk_define.h" +#include "silk_tables.h" #ifdef __cplusplus extern "C" @@ -35,81 +35,81 @@ extern "C" #endif /* Piece-wise linear mapping from bitrate in kbps to coding quality in dB SNR */ -const SKP_int32 TargetRate_table_NB[ TARGET_RATE_TAB_SZ ] = { +const SKP_int32 silk_TargetRate_table_NB[ TARGET_RATE_TAB_SZ ] = { 0, 8000, 9400, 11500, 13500, 17500, 25000, MAX_TARGET_RATE_BPS }; -const SKP_int32 TargetRate_table_MB[ TARGET_RATE_TAB_SZ ] = { - 0, 9000, 11800, 14200, 17700, 23700, 34400, MAX_TARGET_RATE_BPS +const SKP_int32 silk_TargetRate_table_MB[ TARGET_RATE_TAB_SZ ] = { + 0, 9000, 12000, 14500, 18500, 24500, 35500, MAX_TARGET_RATE_BPS }; -const SKP_int32 TargetRate_table_WB[ TARGET_RATE_TAB_SZ ] = { - 0, 10500, 14000, 17000, 21300, 28000, 41500, MAX_TARGET_RATE_BPS +const SKP_int32 silk_TargetRate_table_WB[ TARGET_RATE_TAB_SZ ] = { + 0, 10500, 14000, 17000, 21500, 28500, 42000, MAX_TARGET_RATE_BPS }; -const SKP_int16 SNR_table_Q1[ TARGET_RATE_TAB_SZ ] = { +const SKP_int16 silk_SNR_table_Q1[ TARGET_RATE_TAB_SZ ] = { 19, 29, 35, 39, 44, 50, 60, 80 }; /* Tables for stereo predictor coding */ -const SKP_int16 SKP_Silk_stereo_pred_quant_Q13[ STEREO_QUANT_TAB_SIZE ] = { +const SKP_int16 silk_stereo_pred_quant_Q13[ STEREO_QUANT_TAB_SIZE ] = { -13732, -10050, -8266, -7526, -6500, -5000, -2950, -820, 820, 2950, 5000, 6500, 7526, 8266, 10050, 13732 }; -const SKP_uint8 SKP_Silk_stereo_pred_joint_iCDF[ 25 ] = { +const SKP_uint8 silk_stereo_pred_joint_iCDF[ 25 ] = { 249, 247, 246, 245, 244, 234, 210, 202, 201, 200, 197, 174, 82, 59, 56, 55, 54, 46, 22, 12, 11, 10, 9, 7, 0 }; +const SKP_uint8 silk_stereo_only_code_mid_iCDF[ 2 ] = { 64, 0 }; /* Tables for LBRR flags */ -const SKP_uint8 SKP_Silk_LBRR_flags_2_iCDF[ 3 ] = { 203, 150, 0 }; -const SKP_uint8 SKP_Silk_LBRR_flags_3_iCDF[ 7 ] = { 215, 195, 166, 125, 110, 82, 0 }; -const SKP_uint8 * const SKP_Silk_LBRR_flags_iCDF_ptr[ 2 ] = { - SKP_Silk_LBRR_flags_2_iCDF, - SKP_Silk_LBRR_flags_3_iCDF +const SKP_uint8 silk_LBRR_flags_2_iCDF[ 3 ] = { 203, 150, 0 }; +const SKP_uint8 silk_LBRR_flags_3_iCDF[ 7 ] = { 215, 195, 166, 125, 110, 82, 0 }; +const SKP_uint8 * const silk_LBRR_flags_iCDF_ptr[ 2 ] = { + silk_LBRR_flags_2_iCDF, + silk_LBRR_flags_3_iCDF }; /* Table for LSB coding */ -const SKP_uint8 SKP_Silk_lsb_iCDF[ 2 ] = { 120, 0 }; +const SKP_uint8 silk_lsb_iCDF[ 2 ] = { 120, 0 }; /* Tables for LTPScale */ -const SKP_uint8 SKP_Silk_LTPscale_iCDF[ 3 ] = { 128, 64, 0 }; +const SKP_uint8 silk_LTPscale_iCDF[ 3 ] = { 128, 64, 0 }; /* Tables for signal type and offset coding */ -const SKP_uint8 SKP_Silk_type_offset_VAD_iCDF[ 4 ] = { +const SKP_uint8 silk_type_offset_VAD_iCDF[ 4 ] = { 232, 158, 10, 0 }; -const SKP_uint8 SKP_Silk_type_offset_no_VAD_iCDF[ 2 ] = { +const SKP_uint8 silk_type_offset_no_VAD_iCDF[ 2 ] = { 230, 0 }; /* Tables for NLSF interpolation factor */ -const SKP_uint8 SKP_Silk_NLSF_interpolation_factor_iCDF[ 5 ] = { 243, 221, 192, 181, 0 }; +const SKP_uint8 silk_NLSF_interpolation_factor_iCDF[ 5 ] = { 243, 221, 192, 181, 0 }; /* Quantization offsets */ -const SKP_int16 SKP_Silk_Quantization_Offsets_Q10[ 2 ][ 2 ] = { +const SKP_int16 silk_Quantization_Offsets_Q10[ 2 ][ 2 ] = { { OFFSET_UVL_Q10, OFFSET_UVH_Q10 }, { OFFSET_VL_Q10, OFFSET_VH_Q10 } }; /* Table for LTPScale */ -const SKP_int16 SKP_Silk_LTPScales_table_Q14[ 3 ] = { 15565, 12288, 8192 }; +const SKP_int16 silk_LTPScales_table_Q14[ 3 ] = { 15565, 12288, 8192 }; /* Uniform entropy tables */ -const SKP_uint8 SKP_Silk_uniform2_iCDF[ 2 ] = { 128, 0 }; -const SKP_uint8 SKP_Silk_uniform3_iCDF[ 3 ] = { 171, 85, 0 }; -const SKP_uint8 SKP_Silk_uniform4_iCDF[ 4 ] = { 192, 128, 64, 0 }; -const SKP_uint8 SKP_Silk_uniform5_iCDF[ 5 ] = { 205, 154, 102, 51, 0 }; -const SKP_uint8 SKP_Silk_uniform6_iCDF[ 6 ] = { 213, 171, 128, 85, 43, 0 }; -const SKP_uint8 SKP_Silk_uniform8_iCDF[ 8 ] = { 224, 192, 160, 128, 96, 64, 32, 0 }; +const SKP_uint8 silk_uniform3_iCDF[ 3 ] = { 171, 85, 0 }; +const SKP_uint8 silk_uniform4_iCDF[ 4 ] = { 192, 128, 64, 0 }; +const SKP_uint8 silk_uniform5_iCDF[ 5 ] = { 205, 154, 102, 51, 0 }; +const SKP_uint8 silk_uniform6_iCDF[ 6 ] = { 213, 171, 128, 85, 43, 0 }; +const SKP_uint8 silk_uniform8_iCDF[ 8 ] = { 224, 192, 160, 128, 96, 64, 32, 0 }; -const SKP_uint8 SKP_Silk_NLSF_EXT_iCDF[ 7 ] = { 100, 40, 16, 7, 3, 1, 0 }; +const SKP_uint8 silk_NLSF_EXT_iCDF[ 7 ] = { 100, 40, 16, 7, 3, 1, 0 }; /* Elliptic/Cauer filters designed with 0.1 dB passband ripple, 80 dB minimum stopband attenuation, and [0.95 : 0.15 : 0.35] normalized cut off frequencies. */ /* Interpolation points for filter coefficients used in the bandwidth transition smoother */ -const SKP_int32 SKP_Silk_Transition_LP_B_Q28[ TRANSITION_INT_NUM ][ TRANSITION_NB ] = +const SKP_int32 silk_Transition_LP_B_Q28[ TRANSITION_INT_NUM ][ TRANSITION_NB ] = { { 250767114, 501534038, 250767114 }, { 209867381, 419732057, 209867381 }, @@ -119,7 +119,7 @@ const SKP_int32 SKP_Silk_Transition_LP_B_Q28[ TRANSITION_INT_NUM ][ TRANSITION_N }; /* Interpolation points for filter coefficients used in the bandwidth transition smoother */ -const SKP_int32 SKP_Silk_Transition_LP_A_Q28[ TRANSITION_INT_NUM ][ TRANSITION_NA ] = +const SKP_int32 silk_Transition_LP_A_Q28[ TRANSITION_INT_NUM ][ TRANSITION_NA ] = { { 506393414, 239854379 }, { 411067935, 169683996 }, diff --git a/silk/SKP_Silk_tables_pitch_lag.c b/silk/silk_tables_pitch_lag.c similarity index 85% rename from silk/SKP_Silk_tables_pitch_lag.c rename to silk/silk_tables_pitch_lag.c index b4638df4..aa71e592 100644 --- a/silk/SKP_Silk_tables_pitch_lag.c +++ b/silk/silk_tables_pitch_lag.c @@ -25,22 +25,22 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_tables.h" +#include "silk_tables.h" -const SKP_uint8 SKP_Silk_pitch_lag_iCDF[ 2 * ( PITCH_EST_MAX_LAG_MS - PITCH_EST_MIN_LAG_MS ) ] = { +const SKP_uint8 silk_pitch_lag_iCDF[ 2 * ( PITCH_EST_MAX_LAG_MS - PITCH_EST_MIN_LAG_MS ) ] = { 253, 250, 244, 233, 212, 182, 150, 131, 120, 110, 98, 85, 72, 60, 49, 40, 32, 25, 19, 15, 13, 11, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; -const SKP_uint8 SKP_Silk_pitch_delta_iCDF[21] = { +const SKP_uint8 silk_pitch_delta_iCDF[21] = { 210, 208, 206, 203, 199, 193, 183, 168, 142, 104, 74, 52, 37, 27, 20, 14, 10, 6, 4, 2, 0 }; -const SKP_uint8 SKP_Silk_pitch_contour_iCDF[34] = { +const SKP_uint8 silk_pitch_contour_iCDF[34] = { 223, 201, 183, 167, 152, 138, 124, 111, 98, 88, 79, 70, 62, 56, 50, 44, 39, 35, 31, 27, 24, 21, 18, 16, @@ -48,17 +48,17 @@ const SKP_uint8 SKP_Silk_pitch_contour_iCDF[34] = { 1, 0 }; -const SKP_uint8 SKP_Silk_pitch_contour_NB_iCDF[11] = { +const SKP_uint8 silk_pitch_contour_NB_iCDF[11] = { 188, 176, 155, 138, 119, 97, 67, 43, 26, 10, 0 }; -const SKP_uint8 SKP_Silk_pitch_contour_10_ms_iCDF[12] = { +const SKP_uint8 silk_pitch_contour_10_ms_iCDF[12] = { 165, 119, 80, 61, 47, 35, 27, 20, 14, 9, 4, 0 }; -const SKP_uint8 SKP_Silk_pitch_contour_10_ms_NB_iCDF[3] = { +const SKP_uint8 silk_pitch_contour_10_ms_NB_iCDF[3] = { 113, 63, 0 }; diff --git a/silk/SKP_Silk_tables_pulses_per_block.c b/silk/silk_tables_pulses_per_block.c similarity index 90% rename from silk/SKP_Silk_tables_pulses_per_block.c rename to silk/silk_tables_pulses_per_block.c index 02518545..f6984cb8 100644 --- a/silk/SKP_Silk_tables_pulses_per_block.c +++ b/silk/silk_tables_pulses_per_block.c @@ -25,13 +25,13 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#include "SKP_Silk_tables.h" +#include "silk_tables.h" -const SKP_uint8 SKP_Silk_max_pulses_table[ 4 ] = { +const SKP_uint8 silk_max_pulses_table[ 4 ] = { 8, 10, 12, 16 }; -const SKP_uint8 SKP_Silk_pulses_per_block_iCDF[ 10 ][ 18 ] = { +const SKP_uint8 silk_pulses_per_block_iCDF[ 10 ][ 18 ] = { { 125, 51, 26, 18, 15, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, @@ -84,7 +84,7 @@ const SKP_uint8 SKP_Silk_pulses_per_block_iCDF[ 10 ][ 18 ] = { } }; -const SKP_uint8 SKP_Silk_pulses_per_block_BITS_Q5[ 9 ][ 18 ] = { +const SKP_uint8 silk_pulses_per_block_BITS_Q5[ 9 ][ 18 ] = { { 31, 57, 107, 160, 205, 205, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, @@ -132,7 +132,7 @@ const SKP_uint8 SKP_Silk_pulses_per_block_BITS_Q5[ 9 ][ 18 ] = { } }; -const SKP_uint8 SKP_Silk_rate_levels_iCDF[ 2 ][ 9 ] = +const SKP_uint8 silk_rate_levels_iCDF[ 2 ][ 9 ] = { { 241, 190, 178, 132, 87, 74, 41, 14, @@ -144,7 +144,7 @@ const SKP_uint8 SKP_Silk_rate_levels_iCDF[ 2 ][ 9 ] = } }; -const SKP_uint8 SKP_Silk_rate_levels_BITS_Q5[ 2 ][ 9 ] = +const SKP_uint8 silk_rate_levels_BITS_Q5[ 2 ][ 9 ] = { { 131, 74, 141, 79, 80, 138, 95, 104, @@ -156,7 +156,7 @@ const SKP_uint8 SKP_Silk_rate_levels_BITS_Q5[ 2 ][ 9 ] = } }; -const SKP_uint8 SKP_Silk_shell_code_table0[ 44 ] = { +const SKP_uint8 silk_shell_code_table0[ 44 ] = { 128, 0, 214, 42, 0, 235, 128, 21, 0, 244, 184, 72, 11, 0, 248, 214, 128, 42, 7, 0, 248, 225, 170, 80, @@ -165,7 +165,7 @@ const SKP_uint8 SKP_Silk_shell_code_table0[ 44 ] = { 35, 15, 5, 0 }; -const SKP_uint8 SKP_Silk_shell_code_table1[ 65 ] = { +const SKP_uint8 silk_shell_code_table1[ 65 ] = { 129, 0, 207, 50, 0, 236, 129, 20, 0, 245, 185, 72, 10, 0, 249, 213, 129, 42, 6, 0, 250, 226, 169, 87, @@ -177,7 +177,7 @@ const SKP_uint8 SKP_Silk_shell_code_table1[ 65 ] = { 0 }; -const SKP_uint8 SKP_Silk_shell_code_table2[ 90 ] = { +const SKP_uint8 silk_shell_code_table2[ 90 ] = { 129, 0, 203, 54, 0, 234, 129, 23, 0, 245, 184, 73, 10, 0, 250, 215, 129, 41, 5, 0, 252, 232, 173, 86, @@ -192,7 +192,7 @@ const SKP_uint8 SKP_Silk_shell_code_table2[ 90 ] = { 1, 0 }; -const SKP_uint8 SKP_Silk_shell_code_table3[ 152 ] = { +const SKP_uint8 silk_shell_code_table3[ 152 ] = { 130, 0, 200, 58, 0, 231, 130, 26, 0, 244, 184, 76, 12, 0, 249, 214, 130, 43, 6, 0, 252, 232, 173, 87, @@ -214,13 +214,13 @@ const SKP_uint8 SKP_Silk_shell_code_table3[ 152 ] = { 76, 42, 18, 4, 3, 2, 1, 0 }; -const SKP_uint8 SKP_Silk_shell_code_table_offsets[ 17 ] = { +const SKP_uint8 silk_shell_code_table_offsets[ 17 ] = { 0, 0, 2, 5, 9, 14, 20, 27, 35, 44, 54, 65, 77, 90, 104, 119, 135 }; -const SKP_uint8 SKP_Silk_sign_iCDF[ 36 ] = { +const SKP_uint8 silk_sign_iCDF[ 36 ] = { 49, 67, 77, 82, 93, 99, 11, 18, 24, 31, 36, 45, 46, 66, 78, 87, 94, 104, 14, 21, 32, 42, 51, 66, diff --git a/silk/SKP_Silk_tuning_parameters.h b/silk/silk_tuning_parameters.h similarity index 86% rename from silk/SKP_Silk_tuning_parameters.h rename to silk/silk_tuning_parameters.h index e85336de..ea761f06 100644 --- a/silk/SKP_Silk_tuning_parameters.h +++ b/silk/silk_tuning_parameters.h @@ -25,14 +25,17 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#ifndef SKP_SILK_TUNING_PARAMETERS_H -#define SKP_SILK_TUNING_PARAMETERS_H +#ifndef SILK_TUNING_PARAMETERS_H +#define SILK_TUNING_PARAMETERS_H #ifdef __cplusplus extern "C" { #endif +/* Decay time for bitreservoir */ +#define BITRESERVOIR_DECAY_TIME_MS 500 + /*******************/ /* Pitch estimator */ /*******************/ @@ -69,14 +72,12 @@ extern "C" /* Smoothing parameters for low end of pitch frequency range estimation */ #define VARIABLE_HP_SMTH_COEF1 0.1f #define VARIABLE_HP_SMTH_COEF2 0.015f - -/* Min and max values for low end of pitch frequency range estimation */ -#define VARIABLE_HP_MIN_FREQ 80.0f -#define VARIABLE_HP_MAX_FREQ 150.0f - -/* Max absolute difference between log2 of pitch frequency and smoother state, to enter the smoother */ #define VARIABLE_HP_MAX_DELTA_FREQ 0.4f +/* Min and max cut-off frequency values (-3 dB points) */ +#define VARIABLE_HP_MIN_CUTOFF_HZ 60.0f +#define VARIABLE_HP_MAX_CUTOFF_HZ 100.0f + /***********/ /* Various */ /***********/ @@ -92,7 +93,7 @@ extern "C" /*************************/ /* reduction in coding SNR during low speech activity */ -#define BG_SNR_DECR_dB 4.0f +#define BG_SNR_DECR_dB 2.0f /* factor for reducing quantization noise during voiced speech */ #define HARM_SNR_INCR_dB 2.0f @@ -128,7 +129,7 @@ extern "C" #define HIGH_RATE_OR_LOW_QUALITY_HARMONIC_SHAPING 0.2f /* parameter for shaping noise towards higher frequencies */ -#define HP_NOISE_COEF 0.3f +#define HP_NOISE_COEF 0.25f /* parameter for shaping noise even more towards higher frequencies during voiced speech */ #define HARM_HP_NOISE_COEF 0.35f @@ -149,12 +150,12 @@ extern "C" #define SUBFR_SMTH_COEF 0.4f /* parameters defining the R/D tradeoff in the residual quantizer */ -#define LAMBDA_OFFSET 1.3f -#define LAMBDA_SPEECH_ACT -0.3f +#define LAMBDA_OFFSET 1.2f +#define LAMBDA_SPEECH_ACT -0.2f #define LAMBDA_DELAYED_DECISIONS -0.05f -#define LAMBDA_INPUT_QUALITY -0.2f -#define LAMBDA_CODING_QUALITY -0.1f -#define LAMBDA_QUANT_OFFSET 1.5f +#define LAMBDA_INPUT_QUALITY -0.1f +#define LAMBDA_CODING_QUALITY -0.2f +#define LAMBDA_QUANT_OFFSET 0.8f /* Compensation in bitrate calculations for 10 ms modes */ #define REDUCE_BITRATE_10_MS_BPS 2200 @@ -166,4 +167,4 @@ extern "C" } #endif -#endif // SKP_SILK_TUNING_PARAMETERS_H +#endif // SILK_TUNING_PARAMETERS_H diff --git a/silk/SKP_Silk_typedef.h b/silk/silk_typedef.h similarity index 96% rename from silk/SKP_Silk_typedef.h rename to silk/silk_typedef.h index f2c1f6f2..40ca766b 100644 --- a/silk/SKP_Silk_typedef.h +++ b/silk/silk_typedef.h @@ -25,8 +25,8 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***********************************************************************/ -#ifndef _SKP_SILK_API_TYPDEF_H_ -#define _SKP_SILK_API_TYPDEF_H_ +#ifndef _SILK_TYPEDEF_H_ +#define _SILK_TYPEDEF_H_ #ifndef SKP_USE_DOUBLE_PRECISION_FLOATS #define SKP_USE_DOUBLE_PRECISION_FLOATS 0 diff --git a/silk_headers.txt b/silk_headers.txt index 1e14f1fd..6f160b7f 100644 --- a/silk_headers.txt +++ b/silk_headers.txt @@ -1,25 +1,25 @@ -silk/SKP_debug.h -silk/SKP_Silk_control.h -silk/SKP_Silk_errors.h -silk/SKP_Silk_SDK_API.h -silk/SKP_Silk_typedef.h -silk/SKP_Silk_define.h -silk/SKP_Silk_main.h -silk/SKP_Silk_PLC.h -silk/SKP_Silk_structs.h -silk/SKP_Silk_tables.h -silk/SKP_Silk_tuning_parameters.h -silk/SKP_Silk_Inlines.h -silk/SKP_Silk_MacroCount.h -silk/SKP_Silk_MacroDebug.h -silk/SKP_Silk_macros.h -silk/SKP_Silk_pitch_est_defines.h -silk/SKP_Silk_resampler_private.h -silk/SKP_Silk_resampler_rom.h -silk/SKP_Silk_resampler_structs.h -silk/SKP_Silk_SigProc_FIX.h -silk/fixed/SKP_Silk_main_FIX.h -silk/fixed/SKP_Silk_structs_FIX.h -silk/float/SKP_Silk_main_FLP.h -silk/float/SKP_Silk_structs_FLP.h -silk/float/SKP_Silk_SigProc_FLP.h +silk/silk_debug.h +silk/silk_control.h +silk/silk_errors.h +silk/silk_API.h +silk/silk_typedef.h +silk/silk_define.h +silk/silk_main.h +silk/silk_PLC.h +silk/silk_structs.h +silk/silk_tables.h +silk/silk_tuning_parameters.h +silk/silk_Inlines.h +silk/silk_MacroCount.h +silk/silk_MacroDebug.h +silk/silk_macros.h +silk/silk_pitch_est_defines.h +silk/silk_resampler_private.h +silk/silk_resampler_rom.h +silk/silk_resampler_structs.h +silk/silk_SigProc_FIX.h +silk/fixed/silk_main_FIX.h +silk/fixed/silk_structs_FIX.h +silk/float/silk_main_FLP.h +silk/float/silk_structs_FLP.h +silk/float/silk_SigProc_FLP.h diff --git a/silk_sources.mk b/silk_sources.mk index f9ae7a5a..bb523c36 100644 --- a/silk_sources.mk +++ b/silk_sources.mk @@ -1,151 +1,152 @@ SILK_SOURCES = \ -silk/SKP_Silk_CNG.c \ -silk/SKP_Silk_code_signs.c \ -silk/SKP_Silk_create_init_destroy.c \ -silk/SKP_Silk_decode_core.c \ -silk/SKP_Silk_decode_frame.c \ -silk/SKP_Silk_decode_parameters.c \ -silk/SKP_Silk_decode_indices.c \ -silk/SKP_Silk_decode_pulses.c \ -silk/SKP_Silk_decoder_set_fs.c \ -silk/SKP_Silk_dec_API.c \ -silk/SKP_Silk_enc_API.c \ -silk/SKP_Silk_encode_indices.c \ -silk/SKP_Silk_encode_pulses.c \ -silk/SKP_Silk_gain_quant.c \ -silk/SKP_Silk_interpolate.c \ -silk/SKP_Silk_LP_variable_cutoff.c \ -silk/SKP_Silk_NLSF2A_stable.c \ -silk/SKP_Silk_NLSF_decode.c \ -silk/SKP_Silk_NSQ.c \ -silk/SKP_Silk_NSQ_del_dec.c \ -silk/SKP_Silk_PLC.c \ -silk/SKP_Silk_shell_coder.c \ -silk/SKP_Silk_tables_gain.c \ -silk/SKP_Silk_tables_LTP.c \ -silk/SKP_Silk_tables_NLSF_CB_NB_MB.c \ -silk/SKP_Silk_tables_NLSF_CB_WB.c \ -silk/SKP_Silk_tables_other.c \ -silk/SKP_Silk_tables_pitch_lag.c \ -silk/SKP_Silk_tables_pulses_per_block.c \ -silk/SKP_Silk_VAD.c \ -silk/SKP_Silk_control_audio_bandwidth.c \ -silk/SKP_Silk_quant_LTP_gains.c \ -silk/SKP_Silk_VQ_WMat_EC.c \ -silk/SKP_Silk_HP_variable_cutoff.c \ -silk/SKP_Silk_NLSF_encode.c \ -silk/SKP_Silk_NLSF_VQ.c \ -silk/SKP_Silk_NLSF_unpack.c \ -silk/SKP_Silk_NLSF_del_dec_quant.c \ -silk/SKP_Silk_process_NLSFs.c \ -silk/SKP_Silk_stereo_LR_to_MS.c \ -silk/SKP_Silk_stereo_MS_to_LR.c \ -silk/SKP_Silk_check_control_input.c \ -silk/SKP_Silk_control_SNR.c \ -silk/SKP_Silk_init_encoder.c \ -silk/SKP_Silk_control_codec.c \ -silk/SKP_Silk_A2NLSF.c \ -silk/SKP_Silk_ana_filt_bank_1.c \ -silk/SKP_Silk_apply_sine_window.c \ -silk/SKP_Silk_array_maxabs.c \ -silk/SKP_Silk_autocorr.c \ -silk/SKP_Silk_biquad_alt.c \ -silk/SKP_Silk_burg_modified.c \ -silk/SKP_Silk_bwexpander_32.c \ -silk/SKP_Silk_bwexpander.c \ -silk/SKP_Silk_debug.c \ -silk/SKP_Silk_decode_pitch.c \ -silk/SKP_Silk_inner_prod_aligned.c \ -silk/SKP_Silk_k2a.c \ -silk/SKP_Silk_k2a_Q16.c \ -silk/SKP_Silk_lin2log.c \ -silk/SKP_Silk_log2lin.c \ -silk/SKP_Silk_LPC_analysis_filter.c \ -silk/SKP_Silk_LPC_inv_pred_gain.c \ -silk/SKP_Silk_LPC_stabilize.c \ -silk/SKP_Silk_LPC_synthesis_filter.c \ -silk/SKP_Silk_LPC_synthesis_order16.c \ -silk/SKP_Silk_LSF_cos_table.c \ -silk/SKP_Silk_NLSF2A.c \ -silk/SKP_Silk_NLSF_stabilize.c \ -silk/SKP_Silk_NLSF_VQ_weights_laroia.c \ -silk/SKP_Silk_pitch_analysis_core.c \ -silk/SKP_Silk_pitch_est_tables.c \ -silk/SKP_Silk_resampler.c \ -silk/SKP_Silk_resampler_down2_3.c \ -silk/SKP_Silk_resampler_down2.c \ -silk/SKP_Silk_resampler_down3.c \ -silk/SKP_Silk_resampler_private_AR2.c \ -silk/SKP_Silk_resampler_private_ARMA4.c \ -silk/SKP_Silk_resampler_private_copy.c \ -silk/SKP_Silk_resampler_private_down4.c \ -silk/SKP_Silk_resampler_private_down_FIR.c \ -silk/SKP_Silk_resampler_private_IIR_FIR.c \ -silk/SKP_Silk_resampler_private_up2_HQ.c \ -silk/SKP_Silk_resampler_private_up4.c \ -silk/SKP_Silk_resampler_rom.c \ -silk/SKP_Silk_resampler_up2.c \ -silk/SKP_Silk_scale_copy_vector16.c \ -silk/SKP_Silk_scale_vector.c \ -silk/SKP_Silk_schur64.c \ -silk/SKP_Silk_schur.c \ -silk/SKP_Silk_sigm_Q15.c \ -silk/SKP_Silk_sort.c \ -silk/SKP_Silk_sum_sqr_shift.c \ -silk/SKP_Silk_stereo_decode_pred.c \ -silk/SKP_Silk_stereo_encode_pred.c \ -silk/SKP_Silk_stereo_find_predictor.c +silk/silk_CNG.c \ +silk/silk_code_signs.c \ +silk/silk_create_init_destroy.c \ +silk/silk_decode_core.c \ +silk/silk_decode_frame.c \ +silk/silk_decode_parameters.c \ +silk/silk_decode_indices.c \ +silk/silk_decode_pulses.c \ +silk/silk_decoder_set_fs.c \ +silk/silk_dec_API.c \ +silk/silk_enc_API.c \ +silk/silk_encode_indices.c \ +silk/silk_encode_pulses.c \ +silk/silk_gain_quant.c \ +silk/silk_interpolate.c \ +silk/silk_LP_variable_cutoff.c \ +silk/silk_NLSF2A_stable.c \ +silk/silk_NLSF_decode.c \ +silk/silk_NSQ.c \ +silk/silk_NSQ_del_dec.c \ +silk/silk_PLC.c \ +silk/silk_shell_coder.c \ +silk/silk_tables_gain.c \ +silk/silk_tables_LTP.c \ +silk/silk_tables_NLSF_CB_NB_MB.c \ +silk/silk_tables_NLSF_CB_WB.c \ +silk/silk_tables_other.c \ +silk/silk_tables_pitch_lag.c \ +silk/silk_tables_pulses_per_block.c \ +silk/silk_VAD.c \ +silk/silk_control_audio_bandwidth.c \ +silk/silk_quant_LTP_gains.c \ +silk/silk_VQ_WMat_EC.c \ +silk/silk_HP_variable_cutoff.c \ +silk/silk_NLSF_encode.c \ +silk/silk_NLSF_VQ.c \ +silk/silk_NLSF_unpack.c \ +silk/silk_NLSF_del_dec_quant.c \ +silk/silk_process_NLSFs.c \ +silk/silk_stereo_LR_to_MS.c \ +silk/silk_stereo_MS_to_LR.c \ +silk/silk_check_control_input.c \ +silk/silk_control_SNR.c \ +silk/silk_init_encoder.c \ +silk/silk_control_codec.c \ +silk/silk_A2NLSF.c \ +silk/silk_ana_filt_bank_1.c \ +silk/silk_apply_sine_window.c \ +silk/silk_array_maxabs.c \ +silk/silk_autocorr.c \ +silk/silk_biquad_alt.c \ +silk/silk_burg_modified.c \ +silk/silk_bwexpander_32.c \ +silk/silk_bwexpander.c \ +silk/silk_debug.c \ +silk/silk_decode_pitch.c \ +silk/silk_inner_prod_aligned.c \ +silk/silk_k2a.c \ +silk/silk_k2a_Q16.c \ +silk/silk_lin2log.c \ +silk/silk_log2lin.c \ +silk/silk_LPC_analysis_filter.c \ +silk/silk_LPC_inv_pred_gain.c \ +silk/silk_LPC_stabilize.c \ +silk/silk_LPC_synthesis_filter.c \ +silk/silk_LPC_synthesis_order16.c \ +silk/silk_table_LSF_cos.c \ +silk/silk_NLSF2A.c \ +silk/silk_NLSF_stabilize.c \ +silk/silk_NLSF_VQ_weights_laroia.c \ +silk/silk_pitch_analysis_core.c \ +silk/silk_pitch_est_tables.c \ +silk/silk_resampler.c \ +silk/silk_resampler_down2_3.c \ +silk/silk_resampler_down2.c \ +silk/silk_resampler_down3.c \ +silk/silk_resampler_private_AR2.c \ +silk/silk_resampler_private_ARMA4.c \ +silk/silk_resampler_private_copy.c \ +silk/silk_resampler_private_down4.c \ +silk/silk_resampler_private_down_FIR.c \ +silk/silk_resampler_private_IIR_FIR.c \ +silk/silk_resampler_private_up2_HQ.c \ +silk/silk_resampler_private_up4.c \ +silk/silk_resampler_rom.c \ +silk/silk_resampler_up2.c \ +silk/silk_scale_copy_vector16.c \ +silk/silk_scale_vector.c \ +silk/silk_schur64.c \ +silk/silk_schur.c \ +silk/silk_sigm_Q15.c \ +silk/silk_sort.c \ +silk/silk_sum_sqr_shift.c \ +silk/silk_stereo_decode_pred.c \ +silk/silk_stereo_encode_pred.c \ +silk/silk_stereo_find_predictor.c \ +silk/silk_stereo_quant_pred.c if FIXED_POINT SILK_SOURCES += \ -silk/fixed/SKP_Silk_LTP_analysis_filter_FIX.c \ -silk/fixed/SKP_Silk_LTP_scale_ctrl_FIX.c \ -silk/fixed/SKP_Silk_corrMatrix_FIX.c \ -silk/fixed/SKP_Silk_encode_frame_FIX.c \ -silk/fixed/SKP_Silk_find_LPC_FIX.c \ -silk/fixed/SKP_Silk_find_LTP_FIX.c \ -silk/fixed/SKP_Silk_find_pitch_lags_FIX.c \ -silk/fixed/SKP_Silk_find_pred_coefs_FIX.c \ -silk/fixed/SKP_Silk_noise_shape_analysis_FIX.c \ -silk/fixed/SKP_Silk_prefilter_FIX.c \ -silk/fixed/SKP_Silk_process_gains_FIX.c \ -silk/fixed/SKP_Silk_regularize_correlations_FIX.c \ -silk/fixed/SKP_Silk_residual_energy16_FIX.c \ -silk/fixed/SKP_Silk_residual_energy_FIX.c \ -silk/fixed/SKP_Silk_solve_LS_FIX.c \ -silk/fixed/SKP_Silk_warped_autocorrelation_FIX.c +silk/fixed/silk_LTP_analysis_filter_FIX.c \ +silk/fixed/silk_LTP_scale_ctrl_FIX.c \ +silk/fixed/silk_corrMatrix_FIX.c \ +silk/fixed/silk_encode_frame_FIX.c \ +silk/fixed/silk_find_LPC_FIX.c \ +silk/fixed/silk_find_LTP_FIX.c \ +silk/fixed/silk_find_pitch_lags_FIX.c \ +silk/fixed/silk_find_pred_coefs_FIX.c \ +silk/fixed/silk_noise_shape_analysis_FIX.c \ +silk/fixed/silk_prefilter_FIX.c \ +silk/fixed/silk_process_gains_FIX.c \ +silk/fixed/silk_regularize_correlations_FIX.c \ +silk/fixed/silk_residual_energy16_FIX.c \ +silk/fixed/silk_residual_energy_FIX.c \ +silk/fixed/silk_solve_LS_FIX.c \ +silk/fixed/silk_warped_autocorrelation_FIX.c else SILK_SOURCES += \ -silk/float/SKP_Silk_apply_sine_window_FLP.c \ -silk/float/SKP_Silk_corrMatrix_FLP.c \ -silk/float/SKP_Silk_encode_frame_FLP.c \ -silk/float/SKP_Silk_find_LPC_FLP.c \ -silk/float/SKP_Silk_find_LTP_FLP.c \ -silk/float/SKP_Silk_find_pitch_lags_FLP.c \ -silk/float/SKP_Silk_find_pred_coefs_FLP.c \ -silk/float/SKP_Silk_LPC_analysis_filter_FLP.c \ -silk/float/SKP_Silk_LTP_analysis_filter_FLP.c \ -silk/float/SKP_Silk_LTP_scale_ctrl_FLP.c \ -silk/float/SKP_Silk_noise_shape_analysis_FLP.c \ -silk/float/SKP_Silk_prefilter_FLP.c \ -silk/float/SKP_Silk_process_gains_FLP.c \ -silk/float/SKP_Silk_regularize_correlations_FLP.c \ -silk/float/SKP_Silk_residual_energy_FLP.c \ -silk/float/SKP_Silk_solve_LS_FLP.c \ -silk/float/SKP_Silk_warped_autocorrelation_FLP.c \ -silk/float/SKP_Silk_wrappers_FLP.c \ -silk/float/SKP_Silk_autocorrelation_FLP.c \ -silk/float/SKP_Silk_burg_modified_FLP.c \ -silk/float/SKP_Silk_bwexpander_FLP.c \ -silk/float/SKP_Silk_energy_FLP.c \ -silk/float/SKP_Silk_inner_product_FLP.c \ -silk/float/SKP_Silk_k2a_FLP.c \ -silk/float/SKP_Silk_levinsondurbin_FLP.c \ -silk/float/SKP_Silk_LPC_inv_pred_gain_FLP.c \ -silk/float/SKP_Silk_pitch_analysis_core_FLP.c \ -silk/float/SKP_Silk_scale_copy_vector_FLP.c \ -silk/float/SKP_Silk_scale_vector_FLP.c \ -silk/float/SKP_Silk_schur_FLP.c \ -silk/float/SKP_Silk_sort_FLP.c +silk/float/silk_apply_sine_window_FLP.c \ +silk/float/silk_corrMatrix_FLP.c \ +silk/float/silk_encode_frame_FLP.c \ +silk/float/silk_find_LPC_FLP.c \ +silk/float/silk_find_LTP_FLP.c \ +silk/float/silk_find_pitch_lags_FLP.c \ +silk/float/silk_find_pred_coefs_FLP.c \ +silk/float/silk_LPC_analysis_filter_FLP.c \ +silk/float/silk_LTP_analysis_filter_FLP.c \ +silk/float/silk_LTP_scale_ctrl_FLP.c \ +silk/float/silk_noise_shape_analysis_FLP.c \ +silk/float/silk_prefilter_FLP.c \ +silk/float/silk_process_gains_FLP.c \ +silk/float/silk_regularize_correlations_FLP.c \ +silk/float/silk_residual_energy_FLP.c \ +silk/float/silk_solve_LS_FLP.c \ +silk/float/silk_warped_autocorrelation_FLP.c \ +silk/float/silk_wrappers_FLP.c \ +silk/float/silk_autocorrelation_FLP.c \ +silk/float/silk_burg_modified_FLP.c \ +silk/float/silk_bwexpander_FLP.c \ +silk/float/silk_energy_FLP.c \ +silk/float/silk_inner_product_FLP.c \ +silk/float/silk_k2a_FLP.c \ +silk/float/silk_levinsondurbin_FLP.c \ +silk/float/silk_LPC_inv_pred_gain_FLP.c \ +silk/float/silk_pitch_analysis_core_FLP.c \ +silk/float/silk_scale_copy_vector_FLP.c \ +silk/float/silk_scale_vector_FLP.c \ +silk/float/silk_schur_FLP.c \ +silk/float/silk_sort_FLP.c endif diff --git a/src/opus.h b/src/opus.h index 91048503..37c1129e 100644 --- a/src/opus.h +++ b/src/opus.h @@ -132,6 +132,11 @@ extern "C" { #define OPUS_GET_VBR_CONSTRAINT_REQUEST 21 #define OPUS_GET_VBR_CONSTRAINT(x) OPUS_GET_VBR_CONSTRAINT_REQUEST, __check_int_ptr(x) +#define OPUS_SET_FORCE_MONO_REQUEST 22 +#define OPUS_SET_FORCE_MONO(x) OPUS_SET_FORCE_MONO_REQUEST, __check_int(x) +#define OPUS_GET_FORCE_MONO_REQUEST 23 +#define OPUS_GET_FORCE_MONO(x) OPUS_GET_FORCE_MONO_REQUEST, __check_int_ptr(x) + typedef struct OpusEncoder OpusEncoder; typedef struct OpusDecoder OpusDecoder; diff --git a/src/opus.vcxproj b/src/opus.vcxproj index fddd0e46..5ae2988a 100644 --- a/src/opus.vcxproj +++ b/src/opus.vcxproj @@ -85,7 +85,7 @@ - + diff --git a/src/opus.vcxproj.filters b/src/opus.vcxproj.filters index 13c93ee2..269fde85 100644 --- a/src/opus.vcxproj.filters +++ b/src/opus.vcxproj.filters @@ -35,10 +35,10 @@ Header Files - + Header Files - + Header Files diff --git a/src/opus_decoder.c b/src/opus_decoder.c index 6c07517c..c47517cf 100644 --- a/src/opus_decoder.c +++ b/src/opus_decoder.c @@ -37,7 +37,7 @@ #include "opus_decoder.h" #include "entdec.h" #include "modes.h" -#include "SKP_Silk_SDK_API.h" +#include "silk_API.h" #define MAX_PACKET (1275) @@ -52,7 +52,7 @@ int opus_decoder_get_size(int channels) { int silkDecSizeBytes, celtDecSizeBytes; int ret; - ret = SKP_Silk_SDK_Get_Decoder_Size( &silkDecSizeBytes ); + ret = silk_Get_Decoder_Size( &silkDecSizeBytes ); if(ret) return 0; silkDecSizeBytes = align(silkDecSizeBytes); @@ -69,7 +69,7 @@ OpusDecoder *opus_decoder_init(OpusDecoder *st, int Fs, int channels) memset(st, 0, sizeof(OpusDecoder)); /* Initialize SILK encoder */ - ret = SKP_Silk_SDK_Get_Decoder_Size( &silkDecSizeBytes ); + ret = silk_Get_Decoder_Size( &silkDecSizeBytes ); if( ret ) { return NULL; } @@ -84,7 +84,7 @@ OpusDecoder *opus_decoder_init(OpusDecoder *st, int Fs, int channels) st->Fs = Fs; /* Reset decoder */ - ret = SKP_Silk_SDK_InitDecoder( silk_dec ); + ret = silk_InitDecoder( silk_dec ); if( ret ) { goto failure; } @@ -149,7 +149,7 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data, CELTDecoder *celt_dec; int i, silk_ret=0, celt_ret=0; ec_dec dec; - SKP_SILK_SDK_DecControlStruct DecControl; + silk_DecControlStruct DecControl; SKP_int32 silk_frame_size; short pcm_celt[960*2]; short pcm_transition[960*2]; @@ -183,9 +183,6 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data, mode = st->prev_mode; } - if (st->stream_channels > st->channels) - return OPUS_CORRUPTED_DATA; - if (data!=NULL && !st->prev_redundancy && mode != st->prev_mode && st->prev_mode > 0 && !(mode == MODE_SILK_ONLY && st->prev_mode == MODE_HYBRID) && !(mode == MODE_HYBRID && st->prev_mode == MODE_SILK_ONLY)) @@ -209,9 +206,11 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data, SKP_int16 *pcm_ptr = pcm; if (st->prev_mode==MODE_CELT_ONLY) - SKP_Silk_SDK_InitDecoder( silk_dec ); + silk_InitDecoder( silk_dec ); DecControl.API_sampleRate = st->Fs; + DecControl.nChannelsAPI = st->channels; + DecControl.nChannelsInternal = st->stream_channels; DecControl.payloadSize_ms = 1000 * audiosize / st->Fs; if( mode == MODE_SILK_ONLY ) { if( st->bandwidth == BANDWIDTH_NARROWBAND ) { @@ -228,14 +227,13 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data, /* Hybrid mode */ DecControl.internalSampleRate = 16000; } - DecControl.nChannels = st->channels; lost_flag = data == NULL ? 1 : 2 * decode_fec; decoded_samples = 0; do { /* Call SILK decoder */ int first_frame = decoded_samples == 0; - silk_ret = SKP_Silk_SDK_Decode( silk_dec, &DecControl, + silk_ret = silk_Decode( silk_dec, &DecControl, lost_flag, first_frame, &dec, pcm_ptr, &silk_frame_size ); if( silk_ret ) { fprintf (stderr, "SILK decode error\n"); @@ -318,10 +316,9 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data, /* Decode CELT */ celt_ret = celt_decode_with_ec(celt_dec, decode_fec?NULL:data, len, pcm_celt, frame_size, &dec); for (i=0;ichannels;i++) - pcm[i] = ADD_SAT16(pcm[i], pcm_celt[i]); + pcm[i] = SAT16(pcm[i] + (int)pcm_celt[i]); } - { const CELTMode *celt_mode; celt_decoder_ctl(celt_dec, CELT_GET_MODE(&celt_mode)); diff --git a/src/opus_decoder.h b/src/opus_decoder.h index c221210f..b198d823 100644 --- a/src/opus_decoder.h +++ b/src/opus_decoder.h @@ -50,9 +50,8 @@ struct OpusDecoder { #endif }; -inline short ADD_SAT16(short a, short b) { - int sum = a + b; - return sum > 32767 ? 32767 : sum < -32768 ? -32768 : (short)sum; +inline short SAT16(int x) { + return x > 32767 ? 32767 : x < -32768 ? -32768 : (short)x; }; #endif /* OPUS_DECODER_H */ diff --git a/src/opus_encoder.c b/src/opus_encoder.c index 33e568d2..4bc49501 100644 --- a/src/opus_encoder.c +++ b/src/opus_encoder.c @@ -37,14 +37,14 @@ #include "opus_encoder.h" #include "entenc.h" #include "modes.h" -#include "SKP_Silk_SDK_API.h" +#include "silk_API.h" /* Transition tables for the voice and audio modes. First column is the middle (memoriless) threshold. The second column is the hysteresis (difference with the middle) */ static const int voice_bandwidth_thresholds[10] = { - 11500, 1500, /* NB<->MB */ - 14500, 1500, /* MB<->WB */ + 11000, 1000, /* NB<->MB */ + 14000, 1000, /* MB<->WB */ 21000, 2000, /* WB<->SWB */ 29000, 2000, /* SWB<->FB */ }; @@ -66,7 +66,7 @@ int opus_encoder_get_size(int channels) { int silkEncSizeBytes, celtEncSizeBytes; int ret; - ret = SKP_Silk_SDK_Get_Encoder_Size( &silkEncSizeBytes ); + ret = silk_Get_Encoder_Size( &silkEncSizeBytes ); if(ret) return 0; silkEncSizeBytes = align(silkEncSizeBytes); @@ -84,7 +84,7 @@ OpusEncoder *opus_encoder_init(OpusEncoder* st, int Fs, int channels) memset(st, 0, sizeof(OpusEncoder)); /* Create SILK encoder */ - ret = SKP_Silk_SDK_Get_Encoder_Size( &silkEncSizeBytes ); + ret = silk_Get_Encoder_Size( &silkEncSizeBytes ); if( ret ) return NULL; silkEncSizeBytes = align(silkEncSizeBytes); @@ -98,20 +98,26 @@ OpusEncoder *opus_encoder_init(OpusEncoder* st, int Fs, int channels) st->Fs = Fs; - ret = SKP_Silk_SDK_InitEncoder( silk_enc, &st->silk_mode ); + ret = silk_InitEncoder( silk_enc, &st->silk_mode ); if( ret ) goto failure; /* default SILK parameters */ - st->silk_mode.API_sampleRate = st->Fs; - st->silk_mode.nChannels = channels; - st->silk_mode.maxInternalSampleRate = 16000; - st->silk_mode.minInternalSampleRate = 8000; - st->silk_mode.payloadSize_ms = 20; - st->silk_mode.packetLossPercentage = 0; - st->silk_mode.useInBandFEC = 0; - st->silk_mode.useDTX = 0; - st->silk_mode.complexity = 10; + st->silk_mode.nChannelsAPI = channels; + st->silk_mode.nChannelsInternal = channels; + st->silk_mode.API_sampleRate = st->Fs; + st->silk_mode.maxInternalSampleRate = 16000; + st->silk_mode.minInternalSampleRate = 8000; + st->silk_mode.desiredInternalSampleRate = 16000; + st->silk_mode.payloadSize_ms = 20; + st->silk_mode.bitRate = 25000; + st->silk_mode.packetLossPercentage = 0; + st->silk_mode.complexity = 10; + st->silk_mode.useInBandFEC = 0; + st->silk_mode.useDTX = 0; + st->silk_mode.useCBR = 0; + + st->hybrid_stereo_width_Q14 = 1 << 14; /* Create CELT encoder */ /* Initialize CELT encoder */ @@ -142,7 +148,7 @@ failure: OpusEncoder *opus_encoder_create(int Fs, int channels) { - char *raw_state = malloc(opus_encoder_get_size(channels)); + char *raw_state = (char *)malloc(opus_encoder_get_size(channels)); if (raw_state == NULL) return NULL; return opus_encoder_init((OpusEncoder*)raw_state, Fs, channels); @@ -166,8 +172,8 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size, int redundancy_bytes = 0; int celt_to_silk = 0; /* TODO: This is 60 only so we can handle 60ms speech/audio switching - it shouldn't bee too hard to reduce to 20 ms if needed */ - short pcm_buf[3*960*2]; + it shouldn't be too hard to reduce to 20 ms if needed */ + short pcm_buf[60*48*2]; int nb_compr_bytes; int to_celt = 0; celt_int32 mono_rate; @@ -180,8 +186,10 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size, else st->bitrate_bps = st->user_bitrate_bps; - /* Rete-dependent mono-stereo decision */ - if (st->channels == 2) + /* Rate-dependent mono-stereo decision */ + if (st->force_mono) + st->stream_channels = 1; + if (st->mode == MODE_CELT_ONLY && st->channels == 2) { celt_int32 decision_rate; decision_rate = st->bitrate_bps + st->voice_ratio*st->voice_ratio; @@ -195,7 +203,7 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size, else st->stream_channels = 1; } else { - st->stream_channels = 1; + st->stream_channels = st->channels; } /* Equivalent bit-rate for mono */ mono_rate = st->bitrate_bps; @@ -286,13 +294,13 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size, data += 1; if (st->mode != MODE_CELT_ONLY && st->prev_mode == MODE_CELT_ONLY) { - SKP_SILK_SDK_EncControlStruct dummy; - SKP_Silk_SDK_InitEncoder( silk_enc, &dummy); + silk_EncControlStruct dummy; + silk_InitEncoder( silk_enc, &dummy); prefill=1; } - if (st->prev_mode >0 && - ((st->mode != MODE_CELT_ONLY && st->prev_mode == MODE_CELT_ONLY) - || (st->mode == MODE_CELT_ONLY && st->prev_mode != MODE_CELT_ONLY))) + if (st->prev_mode > 0 && + ((st->mode != MODE_CELT_ONLY && st->prev_mode == MODE_CELT_ONLY) || + (st->mode == MODE_CELT_ONLY && st->prev_mode != MODE_CELT_ONLY))) { redundancy = 1; celt_to_silk = (st->mode != MODE_CELT_ONLY); @@ -316,6 +324,7 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size, { st->silk_mode.bitRate = st->bitrate_bps - 8*st->Fs/frame_size; if( st->mode == MODE_HYBRID ) { + st->silk_mode.bitRate /= st->stream_channels; if( st->bandwidth == BANDWIDTH_SUPERWIDEBAND ) { if( st->Fs == 100 * frame_size ) { /* 24 kHz, 10 ms */ @@ -333,6 +342,7 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size, st->silk_mode.bitRate = ( st->silk_mode.bitRate + 9000 + st->use_vbr * 1000 ) / 2; } } + st->silk_mode.bitRate *= st->stream_channels; /* don't let SILK use more than 80% */ if( st->silk_mode.bitRate > ( st->bitrate_bps - 8*st->Fs/frame_size ) * 4/5 ) { st->silk_mode.bitRate = ( st->bitrate_bps - 8*st->Fs/frame_size ) * 4/5; @@ -340,6 +350,8 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size, } st->silk_mode.payloadSize_ms = 1000 * frame_size / st->Fs; + st->silk_mode.nChannelsAPI = st->channels; + st->silk_mode.nChannelsInternal = st->stream_channels; if (st->bandwidth == BANDWIDTH_NARROWBAND) { st->silk_mode.desiredInternalSampleRate = 8000; } else if (st->bandwidth == BANDWIDTH_MEDIUMBAND) { @@ -361,10 +373,10 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size, if (prefill) { int zero=0; - SKP_Silk_SDK_Encode( silk_enc, &st->silk_mode, st->delay_buffer, st->encoder_buffer, NULL, &zero, 1 ); + silk_Encode( silk_enc, &st->silk_mode, st->delay_buffer, st->encoder_buffer, NULL, &zero, 1 ); } - ret = SKP_Silk_SDK_Encode( silk_enc, &st->silk_mode, pcm, frame_size, &enc, &nBytes, 0 ); + ret = silk_Encode( silk_enc, &st->silk_mode, pcm, frame_size, &enc, &nBytes, 0 ); if( ret ) { fprintf (stderr, "SILK encode error: %d\n", ret); /* Handle error */ @@ -455,6 +467,31 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size, pcm_buf[i] = st->delay_buffer[(st->encoder_buffer-st->delay_compensation)*st->channels+i]; for (;ichannels;i++) pcm_buf[i] = pcm[i-st->delay_compensation*st->channels]; + + if( st->mode == MODE_HYBRID && st->stream_channels == 2 ) { + /* Apply stereo width reduction (at low bitrates) */ + if( st->hybrid_stereo_width_Q14 < (1 << 14) || st->silk_mode.stereoWidth_Q14 < (1 << 14) ) { + int width_Q14, delta_Q14, nSamples_8ms, diff; + nSamples_8ms = ( st->Fs * 8 ) / 1000; + width_Q14 = (1 << 14 ) - st->hybrid_stereo_width_Q14; + delta_Q14 = ( st->hybrid_stereo_width_Q14 - st->silk_mode.stereoWidth_Q14 ) / nSamples_8ms; + for( i = 0; i < nSamples_8ms; i++ ) { + width_Q14 += delta_Q14; + diff = pcm_buf[ 2*i+1 ] - (int)pcm_buf[ 2*i ]; + diff = ( diff * width_Q14 ) >> 15; + pcm_buf[ 2*i ] = (short)( pcm_buf[ 2*i ] + diff ); + pcm_buf[ 2*i+1 ] = (short)( pcm_buf[ 2*i+1 ] - diff ); + } + for( ; i < frame_size; i++ ) { + diff = pcm_buf[ 2*i+1 ] - (int)pcm_buf[ 2*i ]; + diff = ( diff * width_Q14 ) >> 15; + pcm_buf[ 2*i ] = (short)( pcm_buf[ 2*i ] + diff ); + pcm_buf[ 2*i+1 ] = (short)( pcm_buf[ 2*i+1 ] - diff ); + } + st->hybrid_stereo_width_Q14 = st->silk_mode.stereoWidth_Q14; + } + } + if (st->mode != MODE_CELT_ONLY) { /* Check if we have a redundant 0-8 kHz band */ @@ -606,6 +643,18 @@ int opus_encoder_ctl(OpusEncoder *st, int request, ...) *value = st->bitrate_bps; } break; + case OPUS_SET_FORCE_MONO_REQUEST: + { + int value = va_arg(ap, int); + st->force_mono = value; + } + break; + case OPUS_GET_FORCE_MONO_REQUEST: + { + int *value = va_arg(ap, int*); + *value = !!st->force_mono; + } + break; case OPUS_SET_BANDWIDTH_REQUEST: { int value = va_arg(ap, int); diff --git a/src/opus_encoder.h b/src/opus_encoder.h index 4d74c25f..ca1e28ae 100644 --- a/src/opus_encoder.h +++ b/src/opus_encoder.h @@ -30,24 +30,26 @@ #include "celt.h" #include "opus.h" -#include "SKP_Silk_SDK_API.h" +#include "silk_API.h" /* FIXME: This is only valid for 48 kHz */ #define MAX_ENCODER_BUFFER 480 struct OpusEncoder { - int celt_enc_offset; - int silk_enc_offset; - SKP_SILK_SDK_EncControlStruct silk_mode; - int channels; - int stream_channels; + int celt_enc_offset; + int silk_enc_offset; + silk_EncControlStruct silk_mode; + int hybrid_stereo_width_Q14; + int channels; + int stream_channels; int mode; int user_mode; + int force_mono; int prev_mode; - int bandwidth; - int user_bandwidth; - int voice_ratio; + int bandwidth; + int user_bandwidth; + int voice_ratio; /* Sampling rate (at the API level) */ int Fs; int use_vbr; diff --git a/src/test_opus.c b/src/test_opus.c index acd61b09..1461716b 100644 --- a/src/test_opus.c +++ b/src/test_opus.c @@ -35,7 +35,7 @@ #include #include #include "opus.h" -#include "SKP_debug.h" +#include "silk_debug.h" #define MAX_PACKET 1500 @@ -52,6 +52,7 @@ void print_usage( char* argv[] ) fprintf(stderr, "-max_payload : maximum payload size in bytes, default: 1024\n" ); fprintf(stderr, "-complexity : complexity, 0 (lowest) ... 10 (highest); default: 10\n" ); fprintf(stderr, "-inbandfec : enable SILK inband FEC\n" ); + fprintf(stderr, "-forcemono : force mono encoding, even for stereo input\n" ); fprintf(stderr, "-dtx : enable SILK DTX\n" ); fprintf(stderr, "-loss : simulate packet loss, in percent (0-100); default: 0\n" ); } @@ -82,6 +83,7 @@ int main(int argc, char *argv[]) int complexity; int use_inbandfec; int use_dtx; + int forcemono; int cvbr = 0; int packet_loss_perc; int count=0, count_act=0, k; @@ -125,6 +127,7 @@ int main(int argc, char *argv[]) max_payload_bytes = MAX_PACKET; complexity = 10; use_inbandfec = 0; + forcemono = 0; use_dtx = 0; packet_loss_perc = 0; @@ -177,6 +180,9 @@ int main(int argc, char *argv[]) } else if( STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-inbandfec" ) == 0 ) { use_inbandfec = 1; args++; + } else if( STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-forcemono" ) == 0 ) { + forcemono = 1; + args++; } else if( STR_CASEINSENSITIVE_COMPARE( argv[ args ], "-cvbr" ) == 0 ) { cvbr = 1; args++; @@ -236,6 +242,7 @@ int main(int argc, char *argv[]) opus_encoder_ctl(enc, OPUS_SET_VBR_CONSTRAINT(cvbr)); opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY(complexity)); opus_encoder_ctl(enc, OPUS_SET_INBAND_FEC_FLAG(use_inbandfec)); + opus_encoder_ctl(enc, OPUS_SET_FORCE_MONO(forcemono)); opus_encoder_ctl(enc, OPUS_SET_DTX_FLAG(use_dtx)); opus_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(packet_loss_perc)); @@ -326,7 +333,7 @@ int main(int argc, char *argv[]) #if OPUS_TEST_RANGE_CODER_STATE /* compare final range encoder rng values of encoder and decoder */ if( !lost && !lost_prev && opus_decoder_get_final_range( dec ) != enc_final_range[toggle^use_inbandfec] ) { - fprintf (stderr, "Error: Range coder state mismatch between encoder and decoder.\n"); + fprintf (stderr, "Error: Range coder state mismatch between encoder and decoder in frame %d.\n", count); return 0; } #endif @@ -354,8 +361,8 @@ int main(int argc, char *argv[]) fprintf (stderr, "active bitrate: %7.3f kb/s\n", 1e-3*bits_act*sampling_rate/(frame_size*(double)count_act)); fprintf (stderr, "bitrate standard deviation: %7.3f kb/s\n", 1e-3*sqrt(bits2/count - bits*bits/(count*(double)count))*sampling_rate/frame_size); /* Close any files to which intermediate results were stored */ - DEBUG_STORE_CLOSE_FILES - SKP_TimerSave("opus_timing.txt"); + SILK_DEBUG_STORE_CLOSE_FILES + silk_TimerSave("opus_timing.txt"); opus_encoder_destroy(enc); opus_decoder_destroy(dec); free(data[0]);