From c902c9dd26617b6171a70fc724a27efc4b58428d Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 19 Nov 2025 14:36:45 +0100 Subject: [PATCH 1/2] revision of constants and includes --- apps/renderer.c | 2 + lib_com/cnst.h | 1506 +++++++---------- lib_com/ivas_agc_com_fx.c | 4 +- lib_com/ivas_cnst.h | 132 +- lib_com/ivas_cov_smooth_fx.c | 2 +- lib_com/ivas_dirac_com_fx.c | 2 - lib_com/ivas_entropy_coder_common_fx.c | 1 - lib_com/ivas_fb_mixer_fx.c | 2 - lib_com/ivas_ism_com_fx.c | 2 - lib_com/ivas_lfe_com_fx.c | 4 +- lib_com/ivas_limiter_fx.c | 9 +- lib_com/ivas_masa_com_fx.c | 1 - lib_com/ivas_mc_com_fx.c | 1 - lib_com/ivas_mc_param_com_fx.c | 1 - lib_com/ivas_mdft_imdft_fx.c | 8 +- lib_com/ivas_omasa_com_fx.c | 2 +- lib_com/ivas_osba_com_fx.c | 2 - lib_com/ivas_qmetadata_com_fx.c | 2 - lib_com/ivas_qspherical_com_fx.c | 2 - lib_com/ivas_rom_com.h | 1 - lib_com/ivas_rom_com_fx.c | 1 - lib_com/ivas_rotation_com_fx.c | 10 +- lib_com/ivas_sba_config_fx.c | 3 - lib_com/ivas_sns_com_fx.c | 4 +- lib_com/ivas_spar_com_fx.c | 4 +- lib_com/ivas_spar_com_quant_util_fx.c | 1 - lib_com/ivas_stat_com.h | 1 - lib_com/ivas_stereo_dft_com_fx.c | 1 - lib_com/ivas_stereo_eclvq_com_fx.c | 2 +- lib_com/ivas_stereo_ica_com_fx.c | 4 +- lib_com/ivas_stereo_td_bit_alloc_fx.c | 1 - lib_com/ivas_tools_fx.c | 6 +- lib_com/ivas_transient_det_fx.c | 2 +- lib_debug/debug.h | 3 + lib_debug/sba_debug.c | 1 + lib_dec/ivas_agc_dec_fx.c | 2 - lib_dec/ivas_binRenderer_internal_fx.c | 4 +- lib_dec/ivas_core_dec_fx.c | 3 +- lib_dec/ivas_cpe_dec_fx.c | 3 - lib_dec/ivas_dirac_dec_fx.c | 2 - lib_dec/ivas_dirac_output_synthesis_cov_fx.c | 5 - lib_dec/ivas_init_dec_fx.c | 4 +- lib_dec/ivas_ism_dtx_dec_fx.c | 1 - lib_dec/ivas_ism_metadata_dec_fx.c | 2 - lib_dec/ivas_ism_param_dec_fx.c | 5 +- lib_dec/ivas_ism_renderer_fx.c | 2 - lib_dec/ivas_jbm_dec_fx.c | 4 - lib_dec/ivas_lfe_dec_fx.c | 1 - lib_dec/ivas_lfe_plc_fx.c | 1 - lib_dec/ivas_masa_dec_fx.c | 5 +- lib_dec/ivas_mc_param_dec_fx.c | 9 +- lib_dec/ivas_mc_paramupmix_dec_fx.c | 4 - lib_dec/ivas_mct_core_dec_fx.c | 7 +- lib_dec/ivas_mct_dec_fx.c | 3 - lib_dec/ivas_mdct_core_dec_fx.c | 7 +- lib_dec/ivas_mono_dmx_renderer_fx.c | 4 - lib_dec/ivas_objectRenderer_internal_fx.c | 3 +- lib_dec/ivas_omasa_dec_fx.c | 2 - lib_dec/ivas_out_setup_conversion_fx.c | 6 +- lib_dec/ivas_pca_dec_fx.c | 2 +- lib_dec/ivas_post_proc_fx.c | 2 - lib_dec/ivas_qmetadata_dec_fx.c | 1 - lib_dec/ivas_range_uni_dec_fx.c | 2 - lib_dec/ivas_rom_dec_fx.c | 3 - lib_dec/ivas_sba_dec_fx.c | 6 +- lib_dec/ivas_sba_dirac_stereo_dec_fx.c | 12 +- lib_dec/ivas_sba_rendering_internal_fx.c | 2 +- lib_dec/ivas_sce_dec_fx.c | 2 - lib_dec/ivas_sns_dec_fx.c | 3 +- lib_dec/ivas_spar_decoder_fx.c | 4 - lib_dec/ivas_spar_md_dec_fx.c | 2 +- lib_dec/ivas_stereo_cng_dec_fx.c | 2 - lib_dec/ivas_stereo_dft_dec_dmx_fx.c | 2 - lib_dec/ivas_stereo_dft_dec_fx.c | 4 - lib_dec/ivas_stereo_dft_plc_fx.c | 3 +- lib_dec/ivas_stereo_ica_dec_fx.c | 3 - lib_dec/ivas_stereo_icbwe_dec_fx.c | 2 - lib_dec/ivas_stereo_mdct_core_dec_fx.c | 4 +- lib_dec/ivas_stereo_mdct_stereo_dec_fx.c | 2 - lib_dec/ivas_stereo_switching_dec_fx.c | 5 +- lib_dec/ivas_stereo_td_dec_fx.c | 3 - lib_dec/ivas_svd_dec_fx.c | 5 +- lib_dec/ivas_tcx_core_dec_fx.c | 6 +- lib_dec/ivas_td_low_rate_dec_fx.c | 2 - lib_dec/lib_dec_fx.c | 1 - lib_enc/enc_acelp_fx.c | 2 +- lib_enc/igf_enc_fx.c | 2 +- lib_enc/ivas_agc_enc_fx.c | 3 - lib_enc/ivas_core_enc_fx.c | 4 - lib_enc/ivas_core_pre_proc_front_fx.c | 6 - lib_enc/ivas_core_pre_proc_fx.c | 3 - lib_enc/ivas_corecoder_enc_reconfig_fx.c | 5 +- lib_enc/ivas_cpe_enc_fx.c | 4 - lib_enc/ivas_decision_matrix_enc_fx.c | 6 +- lib_enc/ivas_dirac_enc_fx.c | 2 - lib_enc/ivas_enc_fx.c | 4 +- lib_enc/ivas_entropy_coder_fx.c | 2 +- lib_enc/ivas_front_vad_fx.c | 5 - lib_enc/ivas_ism_dtx_enc_fx.c | 1 - lib_enc/ivas_ism_metadata_enc_fx.c | 1 - lib_enc/ivas_ism_param_enc_fx.c | 2 - lib_enc/ivas_lfe_enc_fx.c | 2 +- lib_enc/ivas_masa_enc_fx.c | 1 - lib_enc/ivas_mc_param_enc_fx.c | 6 +- lib_enc/ivas_mc_paramupmix_enc_fx.c | 5 +- lib_enc/ivas_mct_core_enc_fx.c | 4 +- lib_enc/ivas_mct_enc_fx.c | 3 - lib_enc/ivas_mct_enc_mct_fx.c | 1 - lib_enc/ivas_mdct_core_enc_fx.c | 5 +- lib_enc/ivas_omasa_enc_fx.c | 1 - lib_enc/ivas_osba_enc_fx.c | 1 - lib_enc/ivas_pca_enc_fx.c | 2 - lib_enc/ivas_qmetadata_enc_fx.c | 1 - lib_enc/ivas_qspherical_enc_fx.c | 1 - lib_enc/ivas_range_uni_enc_fx.c | 2 - lib_enc/ivas_rom_enc_fx.c | 1 - lib_enc/ivas_sba_enc_fx.c | 4 - lib_enc/ivas_sce_enc_fx.c | 3 - lib_enc/ivas_sns_enc_fx.c | 3 - lib_enc/ivas_spar_encoder_fx.c | 1 - lib_enc/ivas_spar_md_enc_fx.c | 2 +- lib_enc/ivas_stereo_adapt_GR_enc_fx.c | 3 +- lib_enc/ivas_stereo_classifier_fx.c | 35 +- lib_enc/ivas_stereo_cng_enc_fx.c | 3 - lib_enc/ivas_stereo_dft_enc_fx.c | 8 +- lib_enc/ivas_stereo_dft_enc_itd_fx.c | 21 +- lib_enc/ivas_stereo_dft_td_itd_fx.c | 3 - lib_enc/ivas_stereo_dmx_evs_fx.c | 4 - lib_enc/ivas_stereo_eclvq_enc_fx.c | 1 - lib_enc/ivas_stereo_ica_enc_fx.c | 3 - lib_enc/ivas_stereo_icbwe_enc_fx.c | 2 - lib_enc/ivas_stereo_mdct_core_enc_fx.c | 6 +- lib_enc/ivas_stereo_mdct_igf_enc_fx.c | 5 +- lib_enc/ivas_stereo_mdct_stereo_enc_fx.c | 3 - lib_enc/ivas_stereo_switching_enc_fx.c | 3 +- lib_enc/ivas_stereo_td_analysis_fx.c | 3 - lib_enc/ivas_stereo_td_enc_fx.c | 4 +- lib_enc/ivas_tcx_core_enc_fx.c | 5 +- lib_enc/ivas_td_low_rate_enc_fx.c | 2 - lib_enc/lib_enc_fx.c | 2 +- lib_enc/lp_exc_e_fx.c | 2 +- lib_isar/isar_cnst.h | 2 + lib_isar/isar_rom_post_rend.c | 2 +- lib_rend/ivas_allrad_dec_fx.c | 1 - lib_rend/ivas_cldfb_ring_buffer.c | 2 +- lib_rend/ivas_crend_fx.c | 2 - .../ivas_dirac_dec_binaural_functions_fx.c | 5 +- lib_rend/ivas_dirac_decorr_dec_fx.c | 9 +- lib_rend/ivas_dirac_onsets_dec_fx.c | 1 - lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 2 - lib_rend/ivas_dirac_rend_fx.c | 2 - lib_rend/ivas_efap_fx.c | 2 +- lib_rend/ivas_masa_merge_fx.c | 3 +- lib_rend/ivas_mcmasa_ana_fx.c | 7 +- lib_rend/ivas_objectRenderer_fx.c | 3 +- lib_rend/ivas_objectRenderer_hrFilt_fx.c | 2 +- lib_rend/ivas_objectRenderer_sfx_fx.c | 6 - lib_rend/ivas_objectRenderer_sources_fx.c | 1 - lib_rend/ivas_objectRenderer_vec_fx.c | 1 - lib_rend/ivas_omasa_ana_fx.c | 3 +- lib_rend/ivas_orient_trk_fx.c | 2 +- lib_rend/ivas_reflections_fx.c | 4 +- lib_rend/ivas_reverb_delay_line_fx.c | 4 + lib_rend/ivas_reverb_fft_filter_fx.c | 4 +- lib_rend/ivas_reverb_filter_design_fx.c | 1 - lib_rend/ivas_reverb_fx.c | 4 +- lib_rend/ivas_reverb_iir_filter_fx.c | 5 + lib_rend/ivas_reverb_utils_fx.c | 1 - lib_rend/ivas_rom_TdBinauralRenderer.h | 1 - lib_rend/ivas_rom_TdBinauralRenderer_fx.c | 1 - lib_rend/ivas_rom_binauralRenderer.h | 1 - lib_rend/ivas_rom_binauralRenderer_fx.c | 1 - lib_rend/ivas_rotation_fx.c | 9 +- lib_rend/ivas_sba_rendering_fx.c | 3 +- lib_rend/ivas_shoebox_fx.c | 1 - lib_rend/ivas_stat_rend.h | 2 - lib_rend/ivas_td_decorr_fx.c | 49 +- lib_rend/ivas_vbap_fx.c | 2 +- lib_rend/lib_rend.h | 1 - lib_rend/lib_rend_fx.c | 14 +- lib_util/ambi_convert.c | 5 +- lib_util/ambi_convert.h | 5 +- lib_util/ivas_rtp_pi_data.c | 11 +- 183 files changed, 911 insertions(+), 1399 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 8256f1e46..404c1bbcf 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -99,6 +99,8 @@ static * Local structures *------------------------------------------------------------------------------------------*/ +typedef float IVAS_REND_LfePanMtx[RENDERER_MAX_INPUT_LFE_CHANNELS][RENDERER_MAX_OUTPUT_CHANNELS]; + typedef struct { uint32_t frameCounter; diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 8aecbedaf..26ade8800 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -42,113 +42,11 @@ #include "stl.h" /* clang-format off */ -#define MATRIX_CONSTANT (759250113) -#define NUM_SAMPLES_960 (960) -#define NUM_SAMPLES_720 (720) -#define NUM_SAMPLES_640 (640) -#define NUM_SAMPLES_320 (320) -#define NUM_SAMPLES_160 (160) -#define L_SUBFRAME_48k (240) -#define L_SUBFRAME_32k (160) -#define L_SUBFRAME_16k (80) -#define L_SUBFRAME_8k (40) -#define Q31_BY_NUM_SAMPLES_960 ( 2239294 ) /* 1/959 in Q31 */ -#define Q31_BY_NUM_SAMPLES_720 ( 2986764 ) /* 1/719 in Q31 */ -#define Q31_BY_NUM_SAMPLES_640 ( 3360694 ) /* 1/639 in Q31 */ -#define Q31_BY_NUM_SAMPLES_320 ( 6731924 ) /* 1/319 in Q31 */ -#define Q31_BY_NUM_SAMPLES_160 ( 13506186 ) /* 1/159 in Q31 */ -#define Q31_BY_SUB_FRAME_240 ( 8985287 ) /* 1/239 in Q31 */ -#define Q31_BY_SUB_FRAME_180 ( 11997115 ) /* 1/179 in Q31 */ -#define Q31_BY_SUB_FRAME_80 ( 27183337 ) /* 1/79 in Q31 */ -#define Q31_BY_SUB_FRAME_40 ( 55063683 ) /* 1/39 in Q31 */ - -/*----------------------------------------------------------------------------------* - *Q values - *----------------------------------------------------------------------------------*/ - -#define Q1 1 -#define Q2 2 -#define Q3 3 -#define Q4 4 -#define Q5 5 -#define Q6 6 -#define Q7 7 -#define Q8 8 -#define Q9 9 -#define Q10 10 -#define Q11 11 -#define Q12 12 -#define Q13 13 -#define Q14 14 -#define Q15 15 -#define Q16 16 -#define Q17 17 -#define Q18 18 -#define Q19 19 -#define Q20 20 -#define Q21 21 -#define Q22 22 -#define Q23 23 -#define Q24 24 -#define Q25 25 -#define Q26 26 -#define Q27 27 -#define Q28 28 -#define Q29 29 -#define Q30 30 -#define Q31 31 - -/*----------------------------------------------------------------------------------* - * one in Q - *----------------------------------------------------------------------------------*/ - -#define ONE_IN_Q1 2 -#define ONE_IN_Q2 4 -#define ONE_IN_Q3 8 -#define ONE_IN_Q4 16 -#define ONE_IN_Q5 32 -#define ONE_IN_Q6 64 -#define ONE_IN_Q7 128 -#define ONE_IN_Q8 256 -#define ONE_IN_Q9 512 -#define ONE_IN_Q10 1024 -#define ONE_IN_Q11 2048 -#define ONE_IN_Q12 4096 -#define ONE_IN_Q13 8192 -#define ONE_IN_Q14 16384 -#define ONE_IN_Q15 32768 -#define ONE_IN_Q16 65536 -#define ONE_IN_Q17 131072 -#define ONE_IN_Q18 262144 -#define ONE_IN_Q19 524288 -#define ONE_IN_Q20 1048576 -#define ONE_IN_Q21 2097152 -#define ONE_IN_Q22 4194304 -#define ONE_IN_Q23 8388608 -#define ONE_IN_Q24 16777216 -#define ONE_IN_Q25 33554432 -#define ONE_IN_Q26 67108864 -#define ONE_IN_Q27 134217728 -#define ONE_IN_Q28 268435456 -#define ONE_IN_Q29 536870912 -#define ONE_IN_Q30 1073741824 -#define ONE_IN_Q31 0x7fffffff -#define MINUS_ONE_IN_Q31 (-2147483647 - 1) -#define TWO_IN_Q29 1073741824 -#define FOUR_IN_Q28 1073741824 - -#define MAX_WORD16 32767 -#define ONE_IN_Q45 (Word64)0x200000000000 -#define ONE_IN_Q62 (Word64)0x4000000000000000 /*----------------------------------------------------------------------------------* * General constants *----------------------------------------------------------------------------------*/ -#define DEGREE_90_Q_22 377487360 -#define DEGREE_180_Q_22 754974720 -#define DEGREE_360_Q_22 1509949440 - #define MODE1 1 #define MODE2 2 @@ -156,28 +54,18 @@ #define PI2 ( 2 * EVS_PI ) #define RANDOM_INITSEED 21845 /* Seed for random generators */ -#ifndef FLT_MIN -#define FLT_MIN ( 1.175494351e-38F ) -#define FLT_MIN_10_EXP (-37) // min decimal exponent -#define FLT_MIN_EXP (-125) // min binary exponent -#endif -#ifndef FLT_MAX -#define FLT_MAX ( 3.402823466e+38F ) -#endif +//#define FLT_MIN ( 1.175494351e-38F ) +//#define FLT_MAX ( 3.402823466e+38F ) #define TRUE 1 #define FALSE 0 #define MAX16B 32767 #define MIN16B ( -32768 ) -#define MAX16B_FLT 32767.0f -#define MIN16B_FLT ( -32768.0f ) -#define MIN16B_FLT_FX -32768 //Q0 -#define MIN16B_FLT_FX_IN_Q11 -67108864//Q11 -#define MIN16B_FLT_FX_IN_Q15 -1073741824//Q15 -#define PCM16_TO_FLT_FAC 32768.0f -#define PCM16_TO_FLT_FAC_FX 32768 //Q0 -#define PCM16_TO_FLT_FAC_FX_Q15 1073741824L //16Q15 -#define MDFT_NORM_SCALING ( 1.0f / PCM16_TO_FLT_FAC ) +#define MIN16B_FLT_FX -32768 //Q0 +#define MIN16B_FLT_FX_IN_Q11 -67108864//Q11 +#define MIN16B_FLT_FX_IN_Q15 -1073741824//Q15 +#define PCM16_TO_FLT_FAC_FX 32768 //Q0 +#define PCM16_TO_FLT_FAC_FX_Q15 1073741824L //16Q15 #define MDFT_NORM_SCALING_FX 65536 //Q31 #define LOG2_MDFT_NORM_SCALING_FX -503316448 //Q25 #define MAX_FRAME_COUNTER 200 @@ -626,7 +514,7 @@ enum #define N_WS2N_FRAMES 40 /* number of frames for attenuation during the band-width switching */ #define N_NS2W_FRAMES 20 /* number of frames for attenuation during the band-width switching */ -#define ONE_BY_N_NS2W_FRAMES_Q15 ( 1638 ) +#define ONE_BY_N_NS2W_FRAMES_Q15 ( 1638 ) /*----------------------------------------------------------------------------------* * Coder types (only for ACELP core when not running in AMR-WB IO mode) @@ -708,14 +596,14 @@ enum #define AUTO_REGRESSIVE 2 #define INT_FS_12k8 12800 /* internal sampling frequency */ -#define ONE_BY_INT_FS_12k8_Q42 343597384 /* internal sampling frequency */ +#define ONE_BY_INT_FS_12k8_Q42 343597384 /* internal sampling frequency */ #define M 16 /* order of the LP filter @ 12.8kHz */ #define L_FRAME 256 /* frame size at 12.8kHz */ #define NB_SUBFR 4 /* number of subframes per frame */ #define L_SUBFR ( L_FRAME / NB_SUBFR ) /* subframe size */ #define L_SUBFR_LOG2 6 /* To be used for shift operation instead of division */ -#define L_SUBFR_Q6 ((L_FRAME/NB_SUBFR)*64) /* subframe size */ -#define L_SUBFR_Q16 ((L_FRAME/NB_SUBFR)*65536) /* subframe size */ +#define L_SUBFR_Q6 ((L_FRAME/NB_SUBFR)*64) /* subframe size */ +#define L_SUBFR_Q16 ((L_FRAME/NB_SUBFR)*65536) /* subframe size */ #define L_INP_MEM ( L_LOOK_16k + ( ( L_LP_16k - ( NS2SA( INT_FS_16k, ACELP_LOOK_NS ) + L_SUBFR16k / 2 ) ) - 3 * L_SUBFR16k / 2 ) ) /*=240 samples length of memory of input signal, given by the Look-Ahead + the past memory (max needed for the LP window at 16 kHz) */ #define L_INP_12k8 ( L_INP_MEM + L_FRAME ) /* length of input signal buffer @12.8kHz */ @@ -736,8 +624,7 @@ enum #define OLD_SYNTH_SIZE_ENC L_FRAME32k + L_FRAME32k / 4 /* encoder synth memory */ #define OLD_EXC_SIZE_DEC ( 3 * L_FRAME_MAX / 2 + 2 * L_FIR_FER2 ) /*old excitation needed for decoder for PLC*/ -#define TILT_CODE_FLT 0.3f /* ACELP code preemphasis factor */ -#define TILT_CODE 9830 /* ACELP code preemphasis factor ~=0.3f (0Q15) (=0.299987792968750) */ +#define TILT_CODE 9830 /* ACELP code preemphasis factor ~=0.3f (0Q15) (=0.299987792968750) */ #define L_SUBFR16k ( L_FRAME16k / NB_SUBFR ) /* subframe size at 16kHz */ #define L_HALFR16k ( 2 * L_SUBFR16k ) /* half-frame size at 16kHz */ @@ -745,34 +632,27 @@ enum #define MAX_LP_FILTER_ORDER 20 /* Max order of an LP filter */ #define L_INTERPOL2 16 /* Length of filter for interpolation */ #define L_INTERPOL ( L_INTERPOL2 + 1 ) /* Length of filter for interpolation */ -#define TILT_FAC 0.68f /* tilt factor (denominator) */ -#define TILT_FAC_FX 22282 /* tilt factor (denominator) fixed-point*/ +#define TILT_FAC_FX 22282 /* tilt factor (denominator) fixed-point, 0.68f */ #define M16k 20 /* order of the LP filter @ 16kHz */ -#define PIT_SHARP 0.85f /* pitch sharpening factor */ -#define PIT_SHARP_fx 27853 /* pitch sharpening factor */ +#define PIT_SHARP_fx 27853 /* pitch sharpening factor, 0.85f */ #define PIT_UP_SAMP 4 /* upsampling factor for 1/4 interpolation filter */ -#define UP_SAMP 4 /* upsampling factor for 1/4 interpolation filter */ +#define UP_SAMP 4 /* upsampling factor for 1/4 interpolation filter */ #define PIT_L_INTERPOL2 16 #define PIT_FIR_SIZE2 ( PIT_UP_SAMP * PIT_L_INTERPOL2 + 1 ) #define PIT_UP_SAMP6 6 #define PIT_L_INTERPOL6_2 17 #define PIT_FIR_SIZE6_2 ( PIT_UP_SAMP6 * PIT_L_INTERPOL6_2 + 1 ) -#define E_MIN 0.0035f /* minimum allowable energy */ -#define E_MIN_Q11_FX 7 /* minimum allowable energy in Q11*/ -#define E_MIN_Q27_FX 469762 /* minimum allowable energy in Q27*/ -#define STEP_DELTA 0.0625f /* quantization step for tilt compensation of gaussian cb. excitation */ -#define GAMMA_EV 0.92f /* weighting factor for core synthesis error weighting */ -#define FORMANT_SHARPENING_NOISE_THRESHOLD 21.0f /* lp_noise level above which formant sharpening is deactivated */ -#define E_MIN_FX 1 /* QSCALE (Q7)*/ -#define E_MIN_IVAS_FX 1835 /* (Q19) (E12) */ -#define E_MIN_IVAS_FX_Q31 7516193 /* (Q31) (0.0035f) */ - -#define STEP_DELTA_FX 11 -#define FORMANT_SHARPENING_NOISE_THRESHOLD_FX 5376 /* 21 (!8)lp_noise level above which formant sharpening is deactivated - at this level most of 20 dB SNR office noisy speech still uses sharpening */ - -#define LP_NOISE_THRESH_FLT 20.f -#define LP_NOISE_THRESH 167772160l/*20.f Q23*/ -#define LFAC 160 /* FAC maximum frame length */ +#define E_MIN_Q11_FX 7 /* minimum allowable energy, 0.0035f in Q11 */ +#define E_MIN_Q27_FX 469762 /* minimum allowable energy, 0.0035f in Q27 */ +#define E_MIN_FX 1 /* QSCALE (Q7)*/ +#define E_MIN_IVAS_FX 1835 /* (Q19) (E12) */ +#define E_MIN_IVAS_FX_Q31 7516193 /* (Q31) (0.0035f) */ + +#define STEP_DELTA_FX 11 /* quantization step for tilt compensation of gaussian cb. excitation, 0.0625f */ +#define FORMANT_SHARPENING_NOISE_THRESHOLD_FX 5376 /* 21.f (!8)lp_noise level above which formant sharpening is deactivated - at this level most of 20 dB SNR office noisy speech still uses sharpening */ + +#define LP_NOISE_THRESH 167772160l /* 20.f Q23 */ +#define LFAC 160 /* FAC maximum frame length */ #define L_FILT_UP8k 24 /* Resampling - delay of filter for 8 kHz output signals (at 12.8 kHz sampling rate) */ #define LEN_WIN_SSS 120 @@ -818,36 +698,22 @@ typedef enum } CLDFB_PROTOTYPE; /* pre-calculated scale values for the cldfb filter prototypes - values are calculated like this: sqrt( 6400 / no_cldfb_channels * sum(filter[k]**2)) */ -#define CLDFB80_10_SCALE 88.293854f -#define CLDFB80_16_SCALE 88.299622f -#define CLDFB80_20_SCALE 88.300926f -#define CLDFB80_30_SCALE 88.234489f -#define CLDFB80_32_SCALE 88.303848f -#define CLDFB80_40_SCALE 88.304726f -#define CLDFB80_60_SCALE 88.028412f -#define CLDFB80_10_SCALE_FX_Q8 ( 22603 ) -#define CLDFB80_16_SCALE_FX_Q8 ( 22605 ) -#define CLDFB80_20_SCALE_FX_Q8 ( 22605 ) -#define CLDFB80_30_SCALE_FX_Q8 ( 22588 ) -#define CLDFB80_32_SCALE_FX_Q8 ( 22606 ) -#define CLDFB80_40_SCALE_FX_Q8 ( 22606 ) -#define CLDFB80_60_SCALE_FX_Q8 ( 22535 ) - -#define LDQMF_10_SCALE 84.567841f -#define LDQMF_16_SCALE 84.567932f -#define LDQMF_20_SCALE 84.567963f -#define LDQMF_30_SCALE 84.501907f -#define LDQMF_32_SCALE 84.568001f -#define LDQMF_40_SCALE 84.567986f -#define LDQMF_60_SCALE 84.303284f -#define LDQMF_10_SCALE_FX_Q8 ( 21649 ) -#define LDQMF_16_SCALE_FX_Q8 ( 21649 ) -#define LDQMF_20_SCALE_FX_Q8 ( 21649 ) -#define LDQMF_30_SCALE_FX_Q8 ( 21632 ) -#define LDQMF_32_SCALE_FX_Q8 ( 21649 ) -#define LDQMF_40_SCALE_FX_Q8 ( 21649 ) -#define LDQMF_60_SCALE_FX_Q8 ( 21582 ) + values are calculated like this: sqrt( 6400 / no_cldfb_channels * sum(filter[k]**2)) */ +#define CLDFB80_10_SCALE_FX_Q8 ( 22603 ) /* 88.293854f */ +#define CLDFB80_16_SCALE_FX_Q8 ( 22605 ) /* 88.299622f */ +#define CLDFB80_20_SCALE_FX_Q8 ( 22605 ) /* 88.300926f */ +#define CLDFB80_30_SCALE_FX_Q8 ( 22588 ) /* 88.234489f */ +#define CLDFB80_32_SCALE_FX_Q8 ( 22606 ) /* 88.303848f */ +#define CLDFB80_40_SCALE_FX_Q8 ( 22606 ) /* 88.304726f */ +#define CLDFB80_60_SCALE_FX_Q8 ( 22535 ) /* 88.028412f */ + +#define LDQMF_10_SCALE_FX_Q8 ( 21649 ) /* 84.567841f */ +#define LDQMF_16_SCALE_FX_Q8 ( 21649 ) /* 84.567932f */ +#define LDQMF_20_SCALE_FX_Q8 ( 21649 ) /* 84.567963f */ +#define LDQMF_30_SCALE_FX_Q8 ( 21632 ) /* 84.501907f */ +#define LDQMF_32_SCALE_FX_Q8 ( 21649 ) /* 84.568001f */ +#define LDQMF_40_SCALE_FX_Q8 ( 21649 ) /* 84.567986f */ +#define LDQMF_60_SCALE_FX_Q8 ( 21582 ) /* 84.303284f */ #define L_FFT 256 /* Spectral analysis - length of the FFT */ #define LOG2_L_FFT 8 /* Spectral analysis - log2 of L_FFT */ @@ -860,16 +726,14 @@ typedef enum #define VOIC_BAND_8k 17 /* Spectral analysis - number of critical bands considered as voiced in NB (related to VOIC_BINS_8k) */ #define N_SPEC (L_FFT/2) /* number of spectral bins */ -#define M_ALPHA 0.9f /* Multi-harm analysis - forgetting factor of LT correlation map */ -#define M_GAMMA 0.99f /* Multi-harm analysis - forgetting factor of active speech decision predictor */ #define THR_CORR 56 /* Multi-harm analysis - starting threshold of multi-harm. correlation */ -#define M_GAMMA_FX 32440 /* Q15 - forgetting factor of active speech decision predictor */ -#define M_ALPHA_FX 29491 /* Q15 - forgetting factor of LT correlation map */ -#define ONE_MINUS_M_ALPHA 3277 /* Q15 - one minus forgetting factor of LT correlation map */ -#define THR_CORR_INIT_FX (56<<9 ) /* Q9 - starting threshold of multi-harm. correlation */ -#define THR_NCHAR_WB_FX 2048 /* Q11 threshold for noise character (WB) */ -#define THR_NCHAR_NB_FX 2048 /* Q11 threshold for noise character (NB) */ +#define M_GAMMA_FX 32440 /* 0.99f in Q15 - forgetting factor of active speech decision predictor */ +#define M_ALPHA_FX 29491 /* 0.9f in Q15 - forgetting factor of LT correlation map */ +#define ONE_MINUS_M_ALPHA 3277 /* Q15 - one minus forgetting factor of LT correlation map */ +#define THR_CORR_INIT_FX (56<<9 ) /* Q9 - starting threshold of multi-harm. correlation */ +#define THR_NCHAR_WB_FX 2048 /* Q11 threshold for noise character (WB) */ +#define THR_NCHAR_NB_FX 2048 /* Q11 threshold for noise character (NB) */ #define L_LP 320 /* LP analysis - LP window size */ @@ -877,7 +741,7 @@ typedef enum #define L_LP_AMR_WB 384 /* LP analysis - windows size (only for AMR-WB IO mode) */ #define GRID50_POINTS 51 /* LP analysis - half-number of points to evaluate Chebyshev polynomials used in the LP coefs. conversion */ #define GRID40_POINTS 41 /* LP analysis - half-number of points to evaluate Chebyshev polynomials used in the LP coefs. conversion */ -#define GRID80_POINTS 80 /* LP analysis - number of points to evaluate Chebyshev polynomials used in the LP coefs. conversion */ +#define GRID80_POINTS 80 /* LP analysis - number of points to evaluate Chebyshev polynomials used in the LP coefs. conversion */ #define GRID100_POINTS 100 /* LP analysis - number of points to evaluate Chebyshev polynomials */ #define PIT_MIN 34 /* OL pitch analysis - Minimum pitch lag */ @@ -910,7 +774,7 @@ typedef enum #define PIT_MAX_32k 577 #define PIT_FR1_8b_32k 75 #define PIT_MAX_MAX PIT_MAX_32k -#define PIT_MAX_16k 289 +#define PIT_MAX_16k 289 #define PIT_FR1_8b 92 /* Pitch encoding - Minimum pitch lag with resolution 1 */ #define PIT_FR2_9b 128 /* Pitch encoding - Minimum pitch lag with resolution 1/2 */ @@ -942,25 +806,20 @@ typedef enum #define DTX_THR 5 /* DTX - lp_noise threshold for DTX at higher bitrates */ #define DTX_HIST_SIZE 8 /* CNG & DTX - number of last signal frames used for CNG averaging */ -#define CNG_ISF_FACT 0.9f /* CNG & DTX - CNG spectral envelope smoothing factor */ -#define STEP_AMR_WB_SID 2.625f /* CNG & DTX - CNG energy quantization step */ -#define CNG_ISF_FACT_FX 29491 /* Q15(0.9), CNG & DTX - CNG spectral envelope smoothing factor*/ -#define STEP_AMR_WB_SID_FX 10752 /* Q12 */ +#define CNG_ISF_FACT_FX 29491 /* Q15 (0.9f), CNG & DTX - CNG spectral envelope smoothing factor*/ +#define STEP_AMR_WB_SID_FX 10752 /* Q12 (2.625f), CNG & DTX - CNG energy quantization step */ #define HO_HIST_SIZE 8 /* CNG & DTX - maximal number of hangover frames used for averaging */ #define NUM_ENV_CNG 20 -#define BUF_L_NRG 0.7f /* CNG & DTX - lower threshold factor for hangover updates */ -#define BUF_H_NRG 1.03f /* CNG & DTX - higher threshold factor for hangover updates */ #define CNG_TYPE_HO 20 /* CNG & DTX - hangover for switching between CNG types */ -#define BUF_L_NRG_FX 22938 /* Q15(0.7), CNG & DTX - lower threshold offset for hangover updates */ -#define ONE_OVER_BUF_H_NRG_FX 31814 /* Q15(1/1.03), CNG & DTX - inverse of higher threshold offset for hangover updates */ -#define HO_ATT_FAC_FX 3277 /* Q15(0.1), CNG & DTX - Hangover frame attenuation rate factor */ +#define BUF_L_NRG_FX 22938 /* Q15(0.7), CNG & DTX - lower threshold offset for hangover updates */ +#define ONE_OVER_BUF_H_NRG_FX 31814 /* Q15(1/1.03), CNG & DTX - inverse of higher threshold offset for hangover updates */ +#define HO_ATT_FAC_FX 3277 /* Q15(0.1), CNG & DTX - Hangover frame attenuation rate factor */ #define BUF_DEC_RATE 25 /* CNG & DTX - buffer size decrease rate for active frames */ -#define STEP_SID 5.25f /* CNG & DTX - CNG energy quantization step */ -#define STEP_SID_FX 21504 /* Q12 */ -#define ISTEP_SID_FX 6242 /* Inverse of CNG & DTX - CNG energy quantization step in Q15(1/5.25 in Q15)*/ -#define ISTEP_AMR_WB_SID_FX 12483 /* Q15(1/2.625) Inverse of CNG & DTX - CNG energy quantization step */ +#define STEP_SID_FX 21504 /* CNG & DTX - CNG energy quantization step, 5.25f in Q12 */ +#define ISTEP_SID_FX 6242 /* Inverse of CNG & DTX - CNG energy quantization step in Q15(1/5.25 in Q15)*/ +#define ISTEP_AMR_WB_SID_FX 12483 /* Q15(1/2.625) Inverse of CNG & DTX - CNG energy quantization step */ #define MIN_ACT_CNG_UPD 20 /* DTX - Minimum number of consecutive active frames for CNG mode update */ @@ -968,11 +827,10 @@ typedef enum #define TOTALNOISE_HIST_SIZE 4 -#define SUBFFT_QIN 10 -#define DATAFFT_Q 5 -#define SUBFFT_QOUT SUBFFT_QIN-DATAFFT_Q -#define SPECAMP_Q SUBFFT_QIN - +#define SUBFFT_QIN 10 +#define DATAFFT_Q 5 +#define SUBFFT_QOUT SUBFFT_QIN-DATAFFT_Q +#define SPECAMP_Q SUBFFT_QIN #define UNKNOWN_NOISE 0 /* unknown noisy type */ #define SILENCE 1 /* speech with high SNR */ @@ -985,10 +843,8 @@ typedef enum #define PRE_SNR_NUM 32 /* number of snr to calculate average SNR of all sub-bands */ #define POWER_NUM 56 /* number of energy of several frames*/ #define PRE_SPEC_DIF_NUM 56 /* number of energy of several frames*/ -#define CLDFBVAD_VAD_ON 1 -#define COM_VAD_ON 2 - - +#define CLDFBVAD_VAD_ON 1 +#define COM_VAD_ON 2 #define MAX_SUBBAND_NUM 12 /* max number of sub-band divided non-uniformly*/ #define BG_ENG_NUM MAX_SUBBAND_NUM /* number of energy of sub-band divided non-uniformly*/ @@ -998,19 +854,17 @@ typedef enum #define STABLE_NUM 4 /* number of time-domain stable rate*/ #define SFM_NUM 3 /* number of spectral flatness */ -#define MAX_CORR_SHIFT_FX 16384 /* corrshift limit, 0.5 in Q15 */ - +#define MAX_CORR_SHIFT_FX 16384 /* corrshift limit, 0.5 in Q15 */ #define START_NG 5 /* Stationary noise UV modification */ #define FULL_NG 10 /* Stationary noise UV modification */ -#define ISP_SMOOTHING_QUANT_A1 0.9f /* Stationary noise UV modification */ -#define ISP_SMOOTHING_QUANT_A1_FX 29491 /* 0.9f in Q15 */ /* Stationary noise UV modification */ +#define ISP_SMOOTHING_QUANT_A1_FX 29491 /* Stationary noise UV modification, 0.9f in Q15 */ -#define KP559016994_FX 18318 /* EDCT & EMDCT constants */ -#define KP951056516_FX 31164 /* EDCT & EMDCT constants */ -#define KP587785252_FX 19261 /* EDCT & EMDCT constants */ -#define KP866025403_FX 28378 /* EDCT & EMDCT constants */ -#define KP250000000_FX 8192 /* EDCT & EMDCT constants */ +#define KP559016994_FX 18318 /* EDCT & EMDCT constants */ +#define KP951056516_FX 31164 /* EDCT & EMDCT constants */ +#define KP587785252_FX 19261 /* EDCT & EMDCT constants */ +#define KP866025403_FX 28378 /* EDCT & EMDCT constants */ +#define KP250000000_FX 8192 /* EDCT & EMDCT constants */ #define FEC_BITS_CLS 2 /* FEC - number of bits for clas information */ #define FEC_BITS_ENR 5 /* FEC - number of bits for energy information */ @@ -1032,34 +886,23 @@ typedef enum #define BWS_TRAN_PERIOD 5 /* BWS - number of frames for transition period */ #define ONE_BY_BWS_TRAN_PERIOD_Q15 6554 -#define PREEMPH_FAC_FLT 0.68f /* preemphasis factor at 12.8kHz */ -#define PREEMPH_FAC_16k_FLT 0.72f -#define PREEMPH_FAC_SWB_FLT 0.9f /* preemphasis factor for super wide band */ -#define GAMMA1_FLT 0.92f /* weighting factor (numerator) default:0.92 */ -#define GAMMA16k_FLT 0.94f - -#define FORMANT_SHARPENING_G1_FLT 0.75f /* Formant sharpening numerator weighting at 12.8kHz */ -#define FORMANT_SHARPENING_G2_FLT 0.9f /* Formant sharpening denominator weighting at 12.8kHz */ -#define FORMANT_SHARPENING_G1_16k_FLT 0.8f /* Formant sharpening numerator weighting at 16kHz */ -#define FORMANT_SHARPENING_G2_16k_FLT 0.92f /* Formant sharpening denominator weighting at 16kHz */ - -#define PREEMPH_FAC 22282 /* preemphasis factor at 12.8kHz (0.68f in 0Q15) */ -#define PREEMPH_FAC_16k 23593 /* preemphasis factor at 16kHz (0.72f in 0Q15) */ -#define PREEMPH_FAC_SWB 29491 /* preemphasis factor for super wide band (0.9f in 0Q15) */ -#define GAMMA1 30147 /* weighting factor (numerator) default:0.92 (0Q15format) */ -#define GAMMA1_INV 17809 /* weighting factor (numerator) default:0.92 (1Q14format) */ -#define GAMMA16k 30802 /* weighting factor (numerator) default:0.94 (0Q15format) */ -#define GAMMA16k_INV 17430 /* weighting factor (numerator) default:0.94 (1Q14format) */ - -#define FORMANT_SHARPENING_G1 24576 /* Formant sharpening numerator weighting at 12.8kHz (0.75f) */ -#define FORMANT_SHARPENING_G2 29491 /* Formant sharpening denominator weighting at 12.8kHz (0.9f) */ -#define FORMANT_SHARPENING_G1_16k 26214 /* Formant sharpening numerator weighting at 16kHz (0.8f) */ -#define FORMANT_SHARPENING_G2_16k 30147 /* Formant sharpening denominator weighting at 16kHz (0.92f) */ - -#define LD_FSCALE_DENOM 9 +#define PREEMPH_FAC 22282 /* preemphasis factor at 12.8kHz (0.68f in 0Q15) */ +#define PREEMPH_FAC_16k 23593 /* preemphasis factor at 16kHz (0.72f in 0Q15) */ +#define PREEMPH_FAC_SWB 29491 /* preemphasis factor for super wide band (0.9f in 0Q15) */ +#define GAMMA1 30147 /* weighting factor (numerator) default:0.92 (0Q15format) */ +#define GAMMA1_INV 17809 /* weighting factor (numerator) default:0.92 (1Q14format) */ +#define GAMMA16k 30802 /* weighting factor (numerator) default:0.94 (0Q15format) */ +#define GAMMA16k_INV 17430 /* weighting factor (numerator) default:0.94 (1Q14format) */ + +#define FORMANT_SHARPENING_G1 24576 /* Formant sharpening numerator weighting at 12.8kHz (0.75f) */ +#define FORMANT_SHARPENING_G2 29491 /* Formant sharpening denominator weighting at 12.8kHz (0.9f) */ +#define FORMANT_SHARPENING_G1_16k 26214 /* Formant sharpening numerator weighting at 16kHz (0.8f) */ +#define FORMANT_SHARPENING_G2_16k 30147 /* Formant sharpening denominator weighting at 16kHz (0.92f) */ + +#define LD_FSCALE_DENOM 9 #define FSCALE_DENOM (1 << LD_FSCALE_DENOM) -#define FSCALE_DENOM_HALF FSCALE_DENOM/2 -#define FSCALE_E 2 +#define FSCALE_DENOM_HALF FSCALE_DENOM/2 +#define FSCALE_E 2 #define ACELP_FIXED_CDK_NB 41 #define ACELP_FIXED_CDK_BITS( n ) PulseConfTable[n].bits @@ -1103,69 +946,43 @@ enum #define PIT16k_FR2_EXTEND_10b 264 /* Minimum 10 bit pitch lag with resolution 1/2 of extended range @16kHz */ #define WIDTH_BAND 8 /* sub-band width in AVQ coding */ -#define G_AVQ_MIN 0.80f /* lower limit for gain Q in higher-rate ACELP contribution */ -#define G_AVQ_MAX 96.0f /* upper limit for gain Q in higher-rate ACELP contribution */ -#define FAC_PRE_AVQ 0.3f /* preemhasis factor in ACELP pre-quantizer */ -#define G_AVQ_MIN_FX 6554 /* Q13 */ -#define G_AVQ_MIN_DIV10_FX 655 /* Q13 */ -#define G_AVQ_MAX_FX 6144 /* Q6 */ -#define FAC_PRE_AVQ_FX 9830 /* preemhasis factor in ACELP pre-quantizer (0.3 in Q15) */ - - - -#define G_AVQ_MIN_INACT 0.70f /* lower limit for gain Q in higher-rate ACELP contribution, inactive segments */ -#define G_AVQ_MAX_INACT 4.1f /* upper limit for gain Q in higher-rate ACELP contribution, inactive segments */ -#define G_AVQ_MIN_INACT_48k 0.35f /* lower limit for gain Q in higher-rate ACELP contribution, inactive segments, 48 kbps */ -#define G_AVQ_MAX_INACT_48k 2.8f /* upper limit for gain Q in higher-rate ACELP contribution, inactive segments, 48 kbps */ -#define G_AVQ_MIN_INACT_64k 0.25f /* lower limit for gain Q in higher-rate ACELP contribution, inactive segments, 64 kbps */ -#define G_AVQ_MAX_INACT_64k 1.5f /* upper limit for gain Q in higher-rate ACELP contribution, inactive segments, 64 kbps */ -#define G_AVQ_MIN_INACT_Q12 2867 /* lower limit for gain Q in higher-rate ACELP contribution, inactive segments (0.7 in Q12) */ -#define G_AVQ_MIN_INACT_48k_Q12 1434 /* lower limit for gain Q in higher-rate ACELP contribution, inactive segments, 48 kbit/s (0.35 in Q12) */ -#define G_AVQ_MIN_INACT_64k_Q12 1024 /* lower limit for gain Q in higher-rate ACELP contribution, inactive segments, 64 kbit/s (0.25 in Q12 )*/ -#define G_AVQ_DELTA_INACT_Q12 221 /* (4.1 - 0.7) / ((1 << G_AVQ_BITS) - 1) in Q12 */ -#define G_AVQ_DELTA_INACT_48k_Q12 159 /* (2.8 - 0.35) / ((1 << G_AVQ_BITS) - 1) */ -#define G_AVQ_DELTA_INACT_64k_Q12 81 /*(1.5 - 0.25) / ((1 << G_AVQ_BITS) - 1) */ -#define G_AVQ_DELTA_INACT_48k ( G_AVQ_MAX_INACT_48k - G_AVQ_MIN_INACT_48k ) / ( ( 1 << G_AVQ_BITS ) - 1 ) -#define G_AVQ_DELTA_INACT_64k ( G_AVQ_MAX_INACT_64k - G_AVQ_MIN_INACT_64k ) / ( ( 1 << G_AVQ_BITS ) - 1 ) +#define G_AVQ_MIN_FX 6554 /* lower limit for gain Q in higher-rate ACELP contribution, 0.80f in Q13 */ +#define G_AVQ_MIN_DIV10_FX 655 /* Q13 */ +#define G_AVQ_MAX_FX 6144 /* upper limit for gain Q in higher-rate ACELP contribution, 96.0f in Q6 */ +#define FAC_PRE_AVQ_FX 9830 /* preemhasis factor in ACELP pre-quantizer (0.3 in Q15) */ + +#define G_AVQ_MIN_INACT_Q12 2867 /* lower limit for gain Q in higher-rate ACELP contribution, inactive segments (0.7 in Q12) */ +#define G_AVQ_MIN_INACT_48k_Q12 1434 /* lower limit for gain Q in higher-rate ACELP contribution, inactive segments, 48 kbit/s (0.35 in Q12) */ +#define G_AVQ_MIN_INACT_64k_Q12 1024 /* lower limit for gain Q in higher-rate ACELP contribution, inactive segments, 64 kbit/s (0.25 in Q12 )*/ +#define G_AVQ_DELTA_INACT_Q12 221 /* (4.1 - 0.7) / ((1 << G_AVQ_BITS) - 1) in Q12 */ +#define G_AVQ_DELTA_INACT_48k_Q12 159 /* (2.8 - 0.35) / ((1 << G_AVQ_BITS) - 1) */ +#define G_AVQ_DELTA_INACT_64k_Q12 81 /*(1.5 - 0.25) / ((1 << G_AVQ_BITS) - 1) */ #define G_AVQ_BITS 6 /* number of bits to quantize the AVQ gain in higher-rate ACELP contribtuion */ -#define G_AVQ_DELTA ( G_AVQ_MAX - G_AVQ_MIN ) / ( ( 1 << G_AVQ_BITS ) - 1 ) -#define G_AVQ_DELTA_INACT ( G_AVQ_MAX_INACT - G_AVQ_MIN_INACT ) / ( ( 1 << G_AVQ_BITS ) - 1 ) - -#define G_PITCH_MIN 0.00f /* SQ of gains: pitch gain lower limit */ -#define G_PITCH_MAX 1.22f /* SQ of gains: pitch gain upper limit */ -#define G_CODE_MIN 0.02f /* SQ of gains: code gain lower limit */ -#define G_CODE_MAX 5.00f /* SQ of gains: code gain upper limit */ -#define G_PITCH_MIN_TC192 0.1f -#define G_PITCH_MAX_TC192 0.95f -#define G_CODE_MIN_TC192 0.6f -#define G_CODE_MAX_TC192 41.0f +#define G_PITCH_MIN_Q14 0 /* SQ of gains: pitch gain lower limit */ +#define G_PITCH_MAX_Q13 9994 /* SQ of gains: pitch gain upper limit, 1.22 */ +#define G_PITCH_MAX_Q14 19988 /* SQ of gains: pitch gain upper limit, 1.22 in Q14 */ +#define G_CODE_MIN_FX 164 /* SQ of gains: code gain lower limit, 0.02f in Q13 */ +#define G_CODE_MAX_FX 320 /* SQ of gains: code gain upper limit, 5.0f in Q6 */ -#define G_PITCH_MIN_Q14 0 -#define G_PITCH_MAX_Q13 9994/*1.22 */ -#define G_PITCH_MAX_Q14 19988 /* 1.22 in Q14 */ - -#define G_CODE_MIN_FX 164 /* Q13 */ -#define G_CODE_MAX_FX 320 /* Q6 */ - -#define G_PITCH_MIN_TC192_Q14 1638 -#define G_PITCH_MAX_TC192_Q14 15565 /* 0.95 in Q14 */ -#define G_PITCH_MAX_MINUS_MIN_TC192_Q13 6963/*(G_PITCH_MAX_TC192 - G_PITCH_MIN_TC192) */ -#define G_CODE_MIN_TC192_Q15 19661 -#define G_CODE_MIN_TC192_FX 4915 /* Q13 */ -#define G_CODE_MAX_TC192_Q0 41 +#define G_PITCH_MIN_TC192_Q14 1638 /* 0.1f in Q14 */ +#define G_PITCH_MAX_TC192_Q14 15565 /* 0.95 in Q14 */ +#define G_PITCH_MAX_MINUS_MIN_TC192_Q13 6963 /*(G_PITCH_MAX_TC192 - G_PITCH_MIN_TC192) */ +#define G_CODE_MIN_TC192_Q15 19661 /* 0.6f in Q15 */ +#define G_CODE_MIN_TC192_FX 4915 /* 41 in Q13 */ +#define G_CODE_MAX_TC192_Q0 41 #define BIT_SAVING_LOW_THR 10 #define BIT_SAVING_HIGH_THR 80 + /*--------------------------------------------------------------* * ACELP constants *---------------------------------------------------------------*/ -#define MODE_MAX 15 - -#define NB_PULSES_MAX 15 -#define ACELP_GAINS_CONST 0.8f /* ACELP - adaptive codebook gain constraint */ +#define MODE_MAX 15 +#define NB_PULSES_MAX 15 +#define ACELP_GAINS_CONST_Q31 1717986944l /* ACELP - adaptive codebook gain constraint, 0.8f in Q31 */ /*--------------------------------------------------------------* * TCX constants @@ -1195,7 +1012,7 @@ enum #define N_MAX_ARI 800 #define N_LTP_GAIN_MEMS 4 -#define SPEC_EXP_DEC 20 /* initial decoder spectrum exponent */ +#define SPEC_EXP_DEC 20 /* initial decoder spectrum exponent */ #define N_TCX_STARTLINE_NOISE_WB 11 @@ -1238,41 +1055,31 @@ enum #define NC16k ( M16k / 2 ) #define NO_ITER 4 /* number of iterations for tracking the root */ -#define SPC 0.0234952f -#define SPC_plus SPC * 1.001f -#define ALPHA_SQ ( ( 0.5f / PI2 ) * ( 0.5f / PI2 ) ) -#define ALPHA_SQ_Q30 (6799549) /* ( ( 0.5f / PI2 ) * ( 0.5f / PI2 ) ) in Q30 */ +#define ALPHA_SQ_Q30 (6799549) /* ( ( 0.5f / PI2 ) * ( 0.5f / PI2 ) ) in Q30 */ #define NC M / 2 -#define LSF_GAP 50.0f -#define SPC_FX 770 /* q15 */ -#define SPC_PLUS_FX 771 +#define SPC_FX 770 /* 0.0234952f in q15 */ +#define SPC_PLUS_FX 771 /* SPC * 1.001f */ -#define LSF_GAP_FX 128 /*50.0f x 2.56*/ -#define MODE1_LSF_GAP_FX 179 /* MODE1_LSF_GAP*2.56 */ /* Minimum LSF separation for end-frame ISFs */ -#define FREQ_MAX 16384 /*6400Hz in 14Q1*1.28 */ -#define FREQ_DIV 800 /*400.0f in 14Q1 */ +#define LSF_GAP_FX 128 /*50.0f x 2.56*/ +#define MODE1_LSF_GAP_FX 179 /* MODE1_LSF_GAP*2.56 */ /* Minimum LSF separation for end-frame ISFs */ +#define FREQ_MAX 16384 /*6400Hz in 14Q1*1.28 */ +#define FREQ_DIV 800 /*400.0f in 14Q1 */ #define LSF_BITS_CNG 29 #define MU_MA ( 1.0f / 3.0f ) /* original prediction factor (only for AMR-WB IO mode) */ #define ISF_GAP 50 /* Minimum ISF separation for end-frame ISFs (only in AMR-WB IO mode) */ -#define LSF_GAP_MID 80.0f /* Minimum LSF separation for mid-frame LSFs */ -#define MODE1_LSF_GAP 70.0f /* Minimum LSF separation for end-frame ISFs */ -#define PREFERSFNET 1.05 -#define ISF_GAP_FX 128 /* Minimum ISF separation for end-frame ISFs (only in AMR-WB IO mode) */ -#define LSF_GAP_MID_FX 205 /* 80.0 * 2.56 */ /* Minimum LSF separation for mid-frame LSFs */ -#define PREFERSFNET_FX 1638 /* 0.05 in Q16*/ - -#define SFNETLOWLIMIT_WB_FLT 35000 /* new sampling rate dependent thresholds used in LSF codebook decision logic, WB case */ -#define SFNETLOWLIMIT_NB_FLT 38000 /* new sampling rate dependent thresholds used in LSF codebook decision logic, NB case */ -#define SFNETLOWLIMIT_WB 3670016 /* 2.56x2.56*Q4 LSF quantizer - new sampling rate dependent thresholds used in LSF codebook decision logic, WB case */ -#define SFNETLOWLIMIT_NB 3984589 /* 2.56x2.56*Q4 LSF quantizer - new sampling rate dependent thresholds used in LSF codebook decision logic, NB case */ +#define ISF_GAP_FX 128 /* Minimum ISF separation for end-frame ISFs (only in AMR-WB IO mode) */ +#define LSF_GAP_MID_FX 205 /* 80.0 * 2.56 */ /* Minimum LSF separation for mid-frame LSFs */ +#define PREFERSFNET_FX 1638 /* 1.05 in Q16*/ + +#define SFNETLOWLIMIT_WB 3670016 /* 35000*2.56x2.56*Q4 LSF quantizer - new sampling rate dependent thresholds used in LSF codebook decision logic, WB case */ +#define SFNETLOWLIMIT_NB 3984589 /* 38000*2.56x2.56*Q4 LSF quantizer - new sampling rate dependent thresholds used in LSF codebook decision logic, NB case */ #define LSFMBEST 2 /* number of survivors from one stage to another */ #define STREAKLEN 3 /* Allow this many predictive frames, before starting limiting */ -#define STREAKMULT 0.8f /* Exponential limiting multiplier */ -#define STREAKMULT_FX 26214 /* Exponential limiting multiplier */ +#define STREAKMULT_FX 26214 /* Exponential limiting multiplier, 0.8f */ #define LSFMBEST_MAX 16 @@ -1280,14 +1087,12 @@ enum #define TCXLPC_NUMBITS 13 #define TCXLPC_IND_NUMSTAGES 1 #define TCXLPC_IND_NUMBITS 2 -#define TCXLPC_LSF_GAP_FLT 80.0f -#define TCXLPC_LSF_GAP 204 /* 80 in 14Q1*1.28 */ -#define kMaxC 8 - +#define TCXLPC_LSF_GAP 204 /* 80 in 14Q1*1.28 */ +#define kMaxC 8 #define MAX_VQ_STAGES 4 -#define MAX_VQ_STAGES_USED 9 /* this is the maximum number of stages currently used and changing this will affect the memory allocated \ - MAX_VQ_STAGES is also used as offset for addressing some arrays, so this should NOT be changed*/ +#define MAX_VQ_STAGES_USED 9 /* this is the maximum number of stages currently used and changing this will affect the memory allocated \ + MAX_VQ_STAGES is also used as offset for addressing some arrays, so this should NOT be changed*/ #define MIDLSF_NBITS 5 #define ENDLSF_NBITS 31 @@ -1299,11 +1104,11 @@ enum #define MAX_NO_VALS 4 #define WB_LIMIT_LSF 6350 #define CNG_LVQ_MODES 16 -#define MAX_NO_MODES_IVAS 169 +#define MAX_NO_MODES_IVAS 169 #define MAX_NO_MODES 128 -#define START_CNG_IVAS MAX_NO_MODES_IVAS - CNG_LVQ_MODES +#define START_CNG_IVAS MAX_NO_MODES_IVAS - CNG_LVQ_MODES #define START_CNG 112 -#define MAX_NO_MODES_p_IVAS 237 +#define MAX_NO_MODES_p_IVAS 237 #define MAX_NO_MODES_p 145 #define NO_CODING_MODES 6 #define LVQ_COD_MODES 18 @@ -1315,8 +1120,7 @@ enum #define N_STAGE_VQ 8 #define N_DIM 2 #define NUM_SUBSET 8 -#define OP_LOOP_THR_HVO_FLT 3784536.3f /* 80% : Open-loop Threshold */ -#define OP_LOOP_THR_HVO 1550146 /* 80% : Open-loop Threshold 2.56*2.56/16 */ +#define OP_LOOP_THR_HVO 1550146 /* 80% : Open-loop Threshold 3784536.3f*2.56*2.56/16 */ #define NUM_STATE 16 /* BC-TCQ - Number of state of the Trellis */ #define N_STAGE 16 /* BC-TCQ - Smaple number in a frame */ @@ -1344,10 +1148,10 @@ enum #define MAX_TD_DELAY 2 * NSUBBLOCKS /* Maximum allowed delay (in number of subblocks) of the transient detection, affects required memory */ #define NSUBBLOCKS_SHIFT 3 /* Number of subblocks which are shifter betwen TD dectector and TCX-LTP */ -#define NO_TCX 0 -#define TCX_20 1 -#define TCX_10 2 -#define TCX_5 3 +#define NO_TCX 0 +#define TCX_20 1 +#define TCX_10 2 +#define TCX_5 3 #define TRANSITION_OVERLAP ( -2 ) #define RECTANGULAR_OVERLAP ( -1 ) @@ -1356,12 +1160,12 @@ enum #define MIN_OVERLAP 2 #define HALF_OVERLAP 3 #define ALDO_WINDOW 4 -#define WINDECAY48 1230 -#define WINDECAY48_256 656 -#define WINDECAY16 410 -#define N16_CORE_SW 90 -#define N_ZERO_8 45 -#define N_ZERO_BY_FS 9216 /* == N_ZERO_MDCT_NS / FRAME_SIZE_NS in Q15 */ +#define WINDECAY48 1230 +#define WINDECAY48_256 656 +#define WINDECAY16 410 +#define N16_CORE_SW 90 +#define N_ZERO_8 45 +#define N_ZERO_BY_FS 9216 /* == N_ZERO_MDCT_NS / FRAME_SIZE_NS in Q15 */ #define SWITCH_OVERLAP_8k 15 /* == NS2SA(8000, SWITCH_GAP_LENGTH_NS) - NS2SA(8000, 10000000.0f - N_ZERO_MDCT_NS) */ #define SWITCH_GAP_LENGTH_8k 50 @@ -1388,35 +1192,25 @@ enum #define INACTIVE_CLAS 6 /* Inactive frame (used only in decoder) */ #define AUDIO_CLAS 7 /* Audio frame (used only in AMR-WB IO mode) */ -#define BETA_FEC 0.75f /* FEC - weighting factor for LSF estimation in FER */ -#define STAB_FAC_LIMIT 0.25f /* FEC - limit at which safety net is forced for next frame */ -#define BETA_FEC_FX 24576 /* FEC - weighting factor for LSF estimation in FER */ -#define STAB_FAC_LIMIT_FX 8192 /* FEC - limit at which safety net is forced for next frame */ +#define BETA_FEC_FX 24576 /* FEC - weighting factor for LSF estimation in FER, 0.75f */ +#define STAB_FAC_LIMIT_FX 8192 /* FEC - limit at which safety net is forced for next frame, 0.25f */ #define MODE1_L_FIR_FER 5 /* FEC - impulse response length for low- and high-pass filters in FEC */ #define L_FIR_FER 3 /* impulse response length for low- & high-pass filters in FER concealment */ #define L_FIR_FER2 11 /* new filter tuning: 11*/ #define MAX_UPD_CNT 5 /* FEC - maximum number of frames since last pitch update */ -#define ALPHA_S 0.6f /* FEC - damping factor for SIN_ONSET frames */ -#define ALPHA_V 1.0f /* FEC - damping factor for VOICED_CLAS frames */ -#define ALPHA_VT 0.4f /* FEC - damping factor for VOICED_TRANSITION frames */ -#define ALPHA_UT 0.8f /* FEC - damping factor for UNVOICED_TRANSITION frames */ -#define ALPHA_U 0.4f /* FEC - damping factor for UNVOICED_CLAS frames */ -#define ALPHA_UU 1.0f /* FEC - damping factor for UNVOICED_CLAS frames */ - /* attenuation strategy in case of FER */ -#define _ALPHA_S_FX 19661 -#define _ALPHA_V_FX 32767 -#define _ALPHA_VT_FX 13107 -#define _ALPHA_UT_FX 26214 -#define _ALPHA_U_FX 13107 -#define _ALPHA_U_FX_X_2 26214 -#define _ALPHA_UU_FX 32767 +#define _ALPHA_S_FX 19661 /* FEC - damping factor for SIN_ONSET frames, 0.6f */ +#define _ALPHA_V_FX 32767 /* FEC - damping factor for VOICED_CLAS frames, 1.0f */ +#define _ALPHA_VT_FX 13107 /* FEC - damping factor for VOICED_TRANSITION frames, 0.4f */ +#define _ALPHA_UT_FX 26214 /* FEC - damping factor for UNVOICED_TRANSITION frames, 0.8f */ +#define _ALPHA_U_FX 13107 /* FEC - damping factor for UNVOICED_CLAS frames, 0.4f */ +#define _ALPHA_U_FX_X_2 26214 /* FEC - damping factor for UNVOICED_CLAS frames, 1.0f */ +#define _ALPHA_UU_FX 32767 #define AGC 0.98f -#define PLC_MIN_CNG_LEV_FLT 0.01f /* minimum background level */ -#define PLC_MIN_CNG_LEV 328/*0.01f Q15*/ -#define PLC_MIN_CNG_LEV_Q21 20992/*0.01f Q21*/ +#define PLC_MIN_CNG_LEV 328 /* minimum background level, 0.01f Q15*/ +#define PLC_MIN_CNG_LEV_Q21 20992 /* minimum background level, 0.01f Q21*/ #define PLC_MIN_STAT_BUFF_SIZE 50 /* buffer size for minimum statistics */ #define G_LPC_RECOVERY_BITS 1 @@ -1429,9 +1223,9 @@ enum #define TC_SUBFR2IDX_16KHZ( x ) ( x == 0 ? 0 : x == 64 ? 1 : x == 128 ? 2 : x == 192 ? 3 : x == 256 ? 4 : 0 ) -#define TC_SUBFR2IDX_16KHZ_fx(x) mac_r(1024L, (x), 512) /* -1 => 0, 0 => 0, 64 => 1, 128 => 2, 192 => 3, 256 => 4 */ +#define TC_SUBFR2IDX_16KHZ_fx(x) mac_r(1024L, (x), 512) /* -1 => 0, 0 => 0, 64 => 1, 128 => 2, 192 => 3, 256 => 4 */ -#define TC_SUBFR2IDX_fx(x) add(s_min(3, s_max(0, sub((x), 1))), TC_SUBFR2IDX_16KHZ_fx(x)) +#define TC_SUBFR2IDX_fx(x) add(s_min(3, s_max(0, sub((x), 1))), TC_SUBFR2IDX_16KHZ_fx(x)) #define L_IMPULSE 17 /* TC - length of one prototype impulse */ @@ -1487,10 +1281,10 @@ enum * TCQ constants *----------------------------------------------------------------------------------*/ -#define MAX_PULSES 560 -#define MAX_POS 320 -#define MAX_LEN MAX_PULSES -#define NUM_ENG_PACKED_WORDS 20 /* Storage for variable rate quantizer bits */ +#define MAX_PULSES 560 +#define MAX_POS 320 +#define MAX_LEN MAX_PULSES +#define NUM_ENG_PACKED_WORDS 20 /* Storage for variable rate quantizer bits */ #define NORMAL_HQ_CORE 0 /* Signal use of Normal HQ core */ #define LOW_RATE_HQ_CORE 1 /* Signal use of Low Rate MDCT core */ @@ -1543,7 +1337,6 @@ enum #define LPC_SHB_ORDER 10 #define LPC_WHTN_ORDER 4 /* Order of whitening filter for SHB excitation */ #define SHB_OVERLAP_LEN ( L_FRAME16k - L_SHB_LAHEAD ) / ( NUM_SHB_SUBFR - 1 ) -#define QUANT_DIST_INIT ( 10000000000.0f ) /* Quantiser search distance initialisation */ #define HIBND_ACB_L_FAC 5 / 2 /* SHB Interpolation Factor */ #define HIBND_ACB_L_FAC_Q1 ( 5 ) /* SHB Interpolation Factor Q1 */ #define NUM_HILBERTS 2 @@ -1558,8 +1351,7 @@ enum #define NUM_BITS_SHB_FrameGain 6 #define NUM_BITS_SHB_FrameGain_LBR_WB 4 -#define RECIP_ROOT_EIGHT 0.3535534f /* 1.0 / sqrt(8.0) - constant Gain Shape over TD BWE subframes */ -#define RECIP_ROOT_EIGHT_FX 11585 /* 1.0 / sqrt(8.0) - constant Gain Shape over TD BWE subframes */ +#define RECIP_ROOT_EIGHT_FX 11585 /* 1.0 / sqrt(8.0) - constant Gain Shape over TD BWE subframes */ #define LPC_SHB_ORDER_WB 6 #define LPC_WHTN_ORDER_WB 2 /* Order of whitening filter for WB excitation */ @@ -1578,88 +1370,65 @@ enum #define NUM_BITS_SHB_RES_GS 3 #define NUM_BITS_SHB_VF 3 #define NUM_BITS_SHB_SUBGAINS_RF 5 /* Number of bits for subframe gains for SWB in RF */ -#define SHB_GAIN_QLOW -1.0f /* SHB gain lowest scalar quantizer value */ -#define SHB_GAIN_QDELTA 0.15f /* SHB gain scalar quantizer stepsize */ -#define SHB_GAIN_QLOW_1k75 0.0f /* SHB gain lowest scalar quantizer value */ -#define SHB_GAIN_QDELTA_1k75 0.08f /* SHB gain scalar quantizer stepsize */ -#define SHB_GAIN_QLOW_1k75_FX 0 /* SHB gain lowest scalar quantizer value */ -#define SHB_GAIN_QDELTA_1k75_FX 10486 /* SHB gain scalar quantizer stepsize Q17 */ -#define SHB_GAIN_QDELTA_1k75_FX_15 2622 /* SHB gain scalar quantizer stepsize */ -#define SHB_GAIN_QLOW_FX -262144 /* Q18*/ /* SHB gain lowest scalar quantizer value */ -#define SHB_GAIN_QLOW_FX_16 -65536 /* SHB gain lowest scalar quantizer value */ -#define SHB_GAIN_QDELTA_FX_15 4915 /* SHB gain scalar quantizer step size */ -#define SHB_GAIN_QDELTA_FX_16 9830 -#define SHB_GAIN_QDELTA_FX 19661 /* 0.15 in Q17*/ +#define SHB_GAIN_QLOW_1k75_FX 0 /* SHB gain lowest scalar quantizer value */ +#define SHB_GAIN_QDELTA_1k75_FX 10486 /* SHB gain scalar quantizer stepsize, 0.08f Q17 */ +#define SHB_GAIN_QDELTA_1k75_FX_15 2622 /* SHB gain scalar quantizer stepsize, 0.08f */ +#define SHB_GAIN_QLOW_FX -262144 /* -SHB gain lowest scalar quantizer value, 1.0f in Q18 */ +#define SHB_GAIN_QLOW_FX_16 -65536 /* SHB gain lowest scalar quantizer value */ +#define SHB_GAIN_QDELTA_FX_15 4915 /* SHB gain scalar quantizer step size, 0.15f */ +#define SHB_GAIN_QDELTA_FX_16 9830 /* 0.15f in Q16 */ +#define SHB_GAIN_QDELTA_FX 19661 /* 0.15 in Q17 */ #define NUM_Q_LSF 5 /* Number of quantized LSFs */ #define MIRROR_POINT_BITS 2 /* Number of bits used to quantize mirror point */ #define MIRROR_POINT_Q_CB_SIZE 4 /* Size of codebook used to quantize mirror point */ -#define MAX_LSF 0.5f /* Maximum value of the LSFs */ -#define MAX_LSF_FX_2 8192 /* Maximum value of the LSFs */ -#define MAX_LSF_FX 16384 /* Maximum value of the LSFs */ -#define MAX_LSF_FX_BY_2 8192 /* Maximum value of the LSFs */ +#define MAX_LSF_FX_2 8192 /* Maximum value of the LSFs */ +#define MAX_LSF_FX 16384 /* Maximum value of the LSFs, 0.5f */ +#define MAX_LSF_FX_BY_2 8192 /* Maximum value of the LSFs */ #define NUM_MAP_LSF 5 /* Number of mapped LSFs */ #define NUM_LSF_GRIDS 4 /* Number of LSF grids */ #define NUM_LSF_GRID_BITS 2 /* Number of bits used for the LSF grids */ #define NUM_BITS_SHB_MSLVQ 20 /* Number of bits for the MSLVQ quantizer */ -#define VF_0th_PARAM 0.34f -#define VF_1st_PARAM 0.5f -#define VF_2nd_PARAM ( VF_1st_PARAM - VF_0th_PARAM ) -#define VF_0th_PARAM_FX 11141 /*.34*/ -#define VF_1st_PARAM_FX 16384 /*.5*/ -#define VF_2nd_PARAM_FX (VF_1st_PARAM_FX - VF_0th_PARAM_FX) - - -#define GAMMA0 0.65f /* Mean value of gamma1/gamma2 for formant PF */ -#define GAMMA_SHARP 0.15f /* Largest sharpening for gamma1/gamma2 (0.83/0.67)*/ -#define SWB_NOISE_MIX_FAC 0.15f /* Noise mixing adjustment factor for active PF */ -#define SWB_TILT_LOW 1.0f /* Lower threshold for PF tilt adaptation */ -#define SWB_TILT_HIGH 2.0f /* Higher threshold for PF tilt adaptation */ -#define SWB_TILT_DELTA ( 1.0f / ( SWB_TILT_HIGH - SWB_TILT_LOW ) ) /* Inclination between thresholds */ -#define GAMMA3_PLUS_WB 0.65f /* WB post-filter */ -#define GAMMA3_MINUS_WB 0.85f /* WB post-filter */ -#define AGC_FAC_WB 0.85f /* WB post-filter - gain adjustment factor */ -#define AGC_FAC1_WB ( 1.0f - AGC_FAC_WB ) /* WB post-filter - gain adjustment factor complement */ - -#define GAMMA0_FX 21299 /* Mean value of gamma1/gamma2 for formant PF */ -#define GAMMA_SHARP_FX 4915 /* Largest sharpening for gamma1/gamma2 (0.83/0.67)*/ -#define SWB_NOISE_MIX_FAC_FX 4915 /* 0.15f in Q15 */ -#define SWB_TILT_LOW_FX 4096 /* Q12 1.0f Lower threshold for PF tilt adaptation */ -#define SWB_TILT_HIGH_FX 8192 /* Q12 2.0f Higher threshold for PF tilt adaptation */ -#define SWB_TILT_DELTA_FX 32767 /* Q15 (1.0f/(SWB_TILT_HIGH-SWB_TILT_LOW)) Inclination between thresholds */ -#define HALF_POINT_FX (16384) -#define GAMMA3_PLUS_FX 6554 /* NB post-filter - tilt weighting factor when k1>0 */ -#define GAMMA3_MINUS_FX 29491 /* NB post-filter - tilt weighting factor when k1<0 */ -#define GAMMA3_PLUS_WB_FX 21299 /* WB post-filter */ -#define GAMMA3_MINUS_WB_FX 27853 /* WB post-filter */ -#define AGC_FAC_WB_FX 27853 /* WB post-filter - gain adjustment factor */ -#define AGC_FAC1_WB_FX (Word16)(32768L-AGC_FAC_WB_FX) /* WB post-filter - gain adjustment factor complement */ +#define VF_0th_PARAM_FX 11141 /*.34*/ +#define VF_1st_PARAM_FX 16384 /*.5*/ +#define VF_2nd_PARAM_FX (VF_1st_PARAM_FX - VF_0th_PARAM_FX) + +#define GAMMA0_FX 21299 /* Mean value of gamma1/gamma2 for formant PF, 0.65f */ +#define GAMMA_SHARP_FX 4915 /* Largest sharpening for gamma1/gamma2 (0.83/0.67=0.15f)*/ +#define SWB_NOISE_MIX_FAC_FX 4915 /* 0.15f in Q15 */ +#define SWB_TILT_LOW_FX 4096 /* Q12 1.0f Lower threshold for PF tilt adaptation */ +#define SWB_TILT_HIGH_FX 8192 /* Q12 2.0f Higher threshold for PF tilt adaptation */ +#define SWB_TILT_DELTA_FX 32767 /* Q15 (1.0f/(SWB_TILT_HIGH-SWB_TILT_LOW)) Inclination between thresholds */ +#define HALF_POINT_FX (16384) +#define GAMMA3_PLUS_FX 6554 /* NB post-filter - tilt weighting factor when k1>0 */ +#define GAMMA3_MINUS_FX 29491 /* NB post-filter - tilt weighting factor when k1<0 */ +#define GAMMA3_PLUS_WB_FX 21299 /* WB post-filter, 0.65f */ +#define GAMMA3_MINUS_WB_FX 27853 /* WB post-filter, 0.85f */ +#define AGC_FAC_WB_FX 27853 /* WB post-filter - gain adjustment factor, 0.85f */ +#define AGC_FAC1_WB_FX (Word16)(32768L-AGC_FAC_WB_FX) /* WB post-filter - gain adjustment factor complement */ #define MAX_LEN_MA_FILTER 20 /* maximum length of the MA filter for SHB TD envelope calculation */ #define TABLE_CUMSUM_MAX_N 320 /* maximum length of cumsum(i) and cumsum(i*i) tables */ #define NUM_BITS_FB_FRAMEGAIN_TBE 4 /* Number of bits for framegain for FB TBE */ -/* SWB TBE, FX only constants */ -#define NOISE_QFAC 6 -#define NOISE_QADJ (15-NOISE_QFAC) + + /* SWB TBE, FX only constants */ +#define NOISE_QFAC 6 +#define NOISE_QADJ (15-NOISE_QFAC) /*----------------------------------------------------------------------------------* * SWB BWE constants *----------------------------------------------------------------------------------*/ -#define INV_L_SUBFR16k 0.0125f -#define INV_L_SUBFR16k_FX 410 /*Q15 */ +#define INV_L_SUBFR16k_FX 410 /* 0.0125f in Q15 */ #define SWB_L_SUBFR 160 #define FB_L_SUBFR 240 #define SWB_FENV 14 -#define FB_GAIN_QLOW 0.0f -#define FB_GAIN_QDELTA 0.03125f -#define FB_GAIN_QLOW_FX 0 -#define FB_GAIN_QDELTA_FX 512 /*Q14 */ -#define FB_MAX_GAIN_VAR 0.5f +#define FB_GAIN_QLOW_FX 0 +#define FB_GAIN_QDELTA_FX 512 /* 0.03125f in Q14 */ #define NUM_BITS_FB_FRAMEGAIN 4 /* Number of bits for framegain for FB BWE */ @@ -1728,19 +1497,13 @@ enum #define NBITS_THRESH_BWE_HR 400 /* BWE HR number of bits threshold */ #define NBITS_HF_GAIN_BWE_HR 2 /* number of bits for HF (noncoded) energy estimation */ -#define BWE_HR_TRANS_EN_LIMIT1 0.1f /* HF (noncoded) energy equalization limit 1, transient frames */ -#define BWE_HR_TRANS_EN_LIMIT2 0.3f /* HF (noncoded) energy equalization limit 2, transient frames */ -#define BWE_HR_TRANS_EN_LIMIT3 0.5f /* HF (noncoded) energy equalization limit 3, transient frames */ -#define BWE_HR_NONTRANS_EN_LIMIT1 0.5f /* HF (noncoded) energy equalization limit 1, non-transient frames */ -#define BWE_HR_NONTRANS_EN_LIMIT2 1.2f /* HF (noncoded) energy equalization limit 2, non-transient frames */ -#define BWE_HR_NONTRANS_EN_LIMIT3 0.8f /* HF (noncoded) energy equalization limit 3, non-transient frames */ -#define BWE_HR_TRANS_EN_LIMIT1_FX_Q16 6554 -#define BWE_HR_TRANS_EN_LIMIT2_FX_Q16 19661 -#define BWE_HR_TRANS_EN_LIMIT3_FX_Q16 32767 -#define BWE_HR_NONTRANS_EN_LIMIT1_FX_Q15 16384 /* 0.5 */ -#define BWE_HR_NONTRANS_EN_LIMIT2_FX_Q14 19661 /* 1.2 */ -#define BWE_HR_NONTRANS_EN_LIMIT2_FX_Q15 16384 -#define BWE_HR_NONTRANS_EN_LIMIT3_FX_Q15 26214 /* 0.8 */ +#define BWE_HR_TRANS_EN_LIMIT1_FX_Q16 6554 /* 0.1, HF (noncoded) energy equalization limit 1, transient frames */ +#define BWE_HR_TRANS_EN_LIMIT2_FX_Q16 19661 /* 0.3, HF (noncoded) energy equalization limit 2, transient frames */ +#define BWE_HR_TRANS_EN_LIMIT3_FX_Q16 32767 /* 0.5, HF (noncoded) energy equalization limit 3, transient frames */ +#define BWE_HR_NONTRANS_EN_LIMIT1_FX_Q15 16384 /* 0.5, HF (noncoded) energy equalization limit 1, non-transient frames */ +#define BWE_HR_NONTRANS_EN_LIMIT2_FX_Q14 19661 /* 1.2, HF (noncoded) energy equalization limit 2, non-transient frames */ +#define BWE_HR_NONTRANS_EN_LIMIT2_FX_Q15 16384 /* 1.2, HF (noncoded) energy equalization limit 2, non-transient frames */ +#define BWE_HR_NONTRANS_EN_LIMIT3_FX_Q15 26214 /* 0.8, HF (noncoded) energy equalization limit 3, non-transient frames */ /*----------------------------------------------------------------------------------* * FD CNG @@ -1759,21 +1522,14 @@ enum #define FD_CNG_stages_37bits 6 #define FD_CNG_JOINT_stages_25bits 4 -#define OUTMAX_INV 0.000030517578125f /* 1/2^15 */ -#define OUTMAX_INV_FX 65536 /* 1/2^15 (Q31) */ #define ONE_BY_NS2A_8K_ST_DFT32MS_OVL_NS (Word16)(0x051E) -#define OUTMAX_INV_FX_16 (Word16)(0x0001) /* 1/2^15 */ -#define OUTMAX_SQ 1073741824.f /* 2^30 */ -#define OUTMAX_SQ_INV 0.00000000093132257461547852f /* 1/2^30 */ -#define DELTA ( 1e-20f ) -#define DELTA_FX ( 1 ) -#define DELTA_MANTISSA_W16 0x5e73 -#define DELTA_MANTISSA_W32 0x5e728433 -#define DELTA_EXPONENT (-66) +#define DELTA_FX ( 1 ) +#define DELTA_MANTISSA_W16 0x5e73 +#define DELTA_MANTISSA_W32 0x5e728433 +#define DELTA_EXPONENT (-66) -#define CLDFB_SCALING_FLT ( 1.5f ) -#define CLDFB_SCALING 24576/*1.5 Q14*/ /* Q 2.14 */ +#define CLDFB_SCALING 24576 /*1.5 Q14*/ /* Q 2.14 */ #define FFTLEN 640 #define FFTLEN2 ( FFTLEN / 2 ) @@ -1785,13 +1541,13 @@ enum #define NPARTCLDFB 10 #define NPART_SHAPING 62 -#define FDCNG_VQ_MAX_LEN FD_CNG_maxN_37bits -#define FDCNG_VQ_DCT_NSEGM 4 -#define FDCNG_VQ_DCT_MINTRUNC 8 -#define FDCNG_VQ_DCT_MAXTRUNC 18 -#define FDCNG_VQ_MAX_LEN_WB 21 +#define FDCNG_VQ_MAX_LEN FD_CNG_maxN_37bits +#define FDCNG_VQ_DCT_NSEGM 4 +#define FDCNG_VQ_DCT_MINTRUNC 8 +#define FDCNG_VQ_DCT_MAXTRUNC 18 +#define FDCNG_VQ_MAX_LEN_WB 21 -#define FDCNG_VQ_DCT_NPOST 8 +#define FDCNG_VQ_DCT_NPOST 8 typedef enum _DCTTYPE { @@ -1806,59 +1562,44 @@ typedef enum _DCTTYPE #define MSNUMSUBFR 6 #define MSBUFLEN 5 -#define NOISE_HEADROOM 5 /* headroom of noise in generate_masking_noise_fx */ - -#define MSALPHACORALPHA_FLT 0.7f -#define MSALPHACORMAX_FLT 0.3f -#define MSALPHAMAX_FLT 0.96f -#define MSALPHAHATMIN_FLT 0.05f /* It is used for all bands except the first one to get a stable bass */ -#define MSQEQINVMAX_FLT ( 1.f / 5.f ) -#define MSAV_FLT 2.12f -#define MSBETAMAX_FLT 0.8f -#define MSSNREXP_FLT ( -0.02f / 0.064f ) -#define MSALPHACORALPHA 22938/*0.7f Q15*/ -#define MSALPHACORALPHA2 9830/*0.3f Q15*/ -#define MSALPHACORMAX 9830/*0.3f Q15*/ -#define MSALPHAMAX 31457/*0.96f Q15*/ -#define MSALPHAHATMIN 107374184l/*0.05f Q31*/ -#define MSQEQINVMAX 6554/*1.f/5.f Q15*/ -#define MSAV 17367/*2.12f Q13*/ -#define MSAV_EXP 2 -#define MSBETAMAX 1717986944l/*0.8f Q31*/ -#define MSBETAMAX_SQRT 1920767767l/*0.894427191 Q31*/ /* sqrt(MSBETAMAX) */ -#define MSSNREXP -10240/*-0.02f/0.064f Q15*/ - -#define NB_LAST_BAND_SCALE_FLT 0.8f -#define SWB_13k2_LAST_BAND_SCALE_FLT 0.8f -#define NB_LAST_BAND_SCALE 26214/*0.8f Q15*/ -#define SWB_13k2_LAST_BAND_SCALE 26214/*0.8f Q15*/ - -#define CNG_LOG_SCALING 512.f /*2^9*/ +#define NOISE_HEADROOM 5 /* headroom of noise in generate_masking_noise_fx */ + +#define MSALPHACORALPHA 22938 /*0.7f Q15*/ +#define MSALPHACORALPHA2 9830 /*0.3f Q15*/ +#define MSALPHACORMAX 9830 /*0.3f Q15*/ +#define MSALPHAMAX 31457 /*0.96f Q15*/ +#define MSALPHAHATMIN 107374184l /*0.05f Q31*/ +#define MSQEQINVMAX 6554 /*1.f/5.f Q15*/ +#define MSAV 17367 /*2.12f Q13*/ +#define MSAV_EXP 2 +#define MSBETAMAX 1717986944l /*0.8f Q31*/ +#define MSBETAMAX_SQRT 1920767767l /*0.894427191 Q31*/ /* sqrt(MSBETAMAX) */ +#define MSSNREXP -10240 /*-0.02f/0.064f Q15*/ + +#define NB_LAST_BAND_SCALE 26214 /*0.8f Q15*/ +#define SWB_13k2_LAST_BAND_SCALE 26214 /*0.8f Q15*/ #define M_MAX 32 -#define NSTAGES_MAX 9 -#define MBEST_MAX 8 +#define NSTAGES_MAX 9 +#define MBEST_MAX 8 #define N_GAIN_MIN 4 #define N_GAIN_MAX 17 -#define numSlots_inv_EXP (-3) -#define PREEMPH_COMPENSATION_EXP 4 +#define PREEMPH_COMPENSATION_EXP 4 #define CHEAP_NORM_SIZE 161 -#define CLDFBscalingFactor_EXP (-15) -#define CLDFBinvScalingFactor_EXP ( 16) +#define CLDFBscalingFactor_EXP (-15) +#define CLDFBinvScalingFactor_EXP ( 16) -#define CNG_NORM_RECIPROCAL_RANGE_SHIFT 2 -#define CNG_RAND_GAUSS_SHIFT 2 +#define CNG_NORM_RECIPROCAL_RANGE_SHIFT 2 +#define CNG_RAND_GAUSS_SHIFT 2 #define CNA_MAX_BRATE ACELP_13k20 #define CNA_INIT_NBANDS 6 -#define GAIN_Q_OFFSET_EVS 60.f -#define GAIN_Q_OFFSET_EVS_FX_Q0 60 -#define GAIN_Q_OFFSET_IVAS 45.f -#define GAIN_Q_OFFSET_IVAS_FX_Q0 45 +#define GAIN_Q_OFFSET_EVS_FX_Q0 60 +#define GAIN_Q_OFFSET_IVAS_FX_Q0 45 /*----------------------------------------------------------------------------------* * Bass post-filter constants @@ -1871,30 +1612,20 @@ typedef enum _DCTTYPE * NB post-filter constants *----------------------------------------------------------------------------------*/ -#define THRESCRIT 0.5f /* NB post-filter - threshold LT pst switch off */ -#define AGC_FAC 0.9875f /* NB post-filter - gain adjustment factor */ -#define AGC_FAC1 ( 1.0f - AGC_FAC ) /* NB post-filter - gain adjustment factor complement */ #define LONG_H_ST 20 /* NB post-filter - impulse response length */ -#define POST_G1 0.75f /* NB post-filter - denominator weighting factor 12kbps */ -#define POST_G2 0.7f /* NB post-filter - numerator weighting factor 12kbps */ -#define GAMMA1_PST12K_FX 24576 /* denominator weighting factor 12K (0.75 in Q15) */ -#define GAMMA2_PST12K_FX 22938 /* numerator weighting factor 12K (0.7 in Q15) */ -#define POST_G1_FX GAMMA1_PST12K_FX /* 12 kbps default */ -#define POST_G2_FX GAMMA2_PST12K_FX /* 12 kbps default */ - -#define GAMMA1_PST 0.7f /* denominator weighting factor */ -#define GAMMA2_PST 0.55f /* numerator weighting factor */ -#define GAMMA3_PLUS 0.2f /* NB post-filter - tilt weighting factor when k1>0 */ -#define GAMMA3_MINUS 0.9f /* NB post-filter - tilt weighting factor when k1<0 */ -#define GAMMA1_PST12K_MIN_FX 21299 /* 0.65 in Q15 */ -#define GAMMA2_PST12K_MIN_FX 18022 /* 0.55 in Q15 */ -#define GAMMA1_PST12K_NOIS_FX 4915 /* 0.15 in Q15 */ -#define GAMMA2_PST12K_NOIS_FX 3277 /* 0.10 in Q15 */ +#define GAMMA1_PST12K_FX 24576 /* denominator weighting factor 12K (0.75 in Q15) */ +#define GAMMA2_PST12K_FX 22938 /* numerator weighting factor 12K (0.7 in Q15) */ +#define POST_G1_FX GAMMA1_PST12K_FX /* 12 kbps default */ +#define POST_G2_FX GAMMA2_PST12K_FX /* 12 kbps default */ + +#define GAMMA1_PST12K_MIN_FX 21299 /* 0.65 in Q15 */ +#define GAMMA2_PST12K_MIN_FX 18022 /* 0.55 in Q15 */ +#define GAMMA1_PST12K_NOIS_FX 4915 /* 0.15 in Q15 */ +#define GAMMA2_PST12K_NOIS_FX 3277 /* 0.10 in Q15 */ #define F_UP_PST 8 /* NB post-filter - resolution for fractionnal delay */ #define LH2_S 4 /* NB post-filter - length of INT16 interp. subfilters */ #define LH2_L 16 /* NB post-filter - length of long interp. subfilters */ -#define MIN_GPLT ( 1.0f / 1.5f ) /* NB post-filter - LT gain minimum */ #define LH_UP_S ( LH2_S / 2 ) #define LH_UP_L ( LH2_L / 2 ) #define LH2_L_P1 ( LH2_L + 1 ) @@ -1903,24 +1634,13 @@ typedef enum _DCTTYPE #define SIZ_Y_UP ( ( F_UP_PST - 1 ) * ( L_SUBFR + 1 ) ) #define SIZ_TAB_HUP_L ( ( F_UP_PST - 1 ) * LH2_L ) #define SIZ_TAB_HUP_S ( ( F_UP_PST - 1 ) * LH2_S ) -#define POST_G1_MIN 0.65f -#define POST_G2_MIN 0.55f -#define POST_G1_NOIS 0.15f -#define POST_G2_NOIS 0.10f -#define BG1 ( -0.01f ) -#define BG2 ( -0.05f ) -#define CG1 0.9f -#define CG2 1.45f -#define C_LP_NOISE ( 0.1f / 4.0f ) -#define K_LP_NOISE 15.0f -#define LP_NOISE_THR 25.0f -#define BG1_FX -328 /* -0.01 in Q15 */ -#define BG2_FX -1638 /* -0.05 in Q15 */ -#define CG1_FX 29491 /* 0.9 in Q15 */ -#define CG2_FX 47514L /* 1.45 in Q15 */ -#define C_LP_NOISE_FX 819 /* 0.1/4.0 in Q15 */ -#define CK_LP_NOISE_FX 6291456L /* 15.0 * 0.1/4 in Q8 * 65536 */ -#define LP_NOISE_THR_FX 6400 /* 25.0 in Q8 */ +#define BG1_FX -328 /* -0.01 in Q15 */ +#define BG2_FX -1638 /* -0.05 in Q15 */ +#define CG1_FX 29491 /* 0.9 in Q15 */ +#define CG2_FX 47514L /* 1.45 in Q15 */ +#define C_LP_NOISE_FX 819 /* 0.1/4.0 in Q15 */ +#define CK_LP_NOISE_FX 6291456L /* 15.0 * 0.1/4 in Q8 * 65536 */ +#define LP_NOISE_THR_FX 6400 /* 25.0 in Q8 */ /*----------------------------------------------------------------------------------* * Stability estimation @@ -1928,16 +1648,11 @@ typedef enum _DCTTYPE #define NB_BFI_THR 2 /* threshold for counter of last bad frames */ #define MAX_LT 40 -#define INV_MAX_LT ( 1.0f / MAX_LT ) -#define TH_0_MIN 2.5f -#define TH_1_MIN 1.875f -#define TH_2_MIN 1.5625f -#define TH_3_MIN 1.3125f -#define TH_0_MIN_FX 5120 /* 2.5f in Q11 */ -#define TH_1_MIN_FX 3840 /* 1.875f in Q11 */ -#define TH_2_MIN_FX 3200 /* 1.5625f in Q11 */ -#define TH_3_MIN_FX 2688 /* 1.3125f in Q11 */ +#define TH_0_MIN_FX 5120 /* 2.5f in Q11 */ +#define TH_1_MIN_FX 3840 /* 1.875f in Q11 */ +#define TH_2_MIN_FX 3200 /* 1.5625f in Q11 */ +#define TH_3_MIN_FX 2688 /* 1.3125f in Q11 */ /*----------------------------------------------------------------------------------* * Speech/music classifier constants @@ -1956,12 +1671,12 @@ typedef enum _DCTTYPE #define N_SMC_MIXTURES 6 /* number of mixtures */ #define N_PCA_COEF 12 /* number of PCA components */ #define HALF_N_PCA_COEF_LOG_P12_Q18 2890731 //Q18 of (0.5f * N_PCA_COEF *logf( PI2 )) -#define SMC_ST_MEAN_RSHIFT_FACT_FX 1 /* SMC_ST_MEAN_FACT equivalent right shift factor */ +#define SMC_ST_MEAN_RSHIFT_FACT_FX 1 /* SMC_ST_MEAN_FACT equivalent right shift factor */ #define M_LSP_SPMUS 6 /* number of LSPs used in speech/music classifier */ #define NB_BANDS_SPMUS 15 #define START_BAND_SPMUS 2 -#define N_OLD_BIN_E 42 /* == (L_FFT/2-2)/3 */ +#define N_OLD_BIN_E 42 /* == (L_FFT/2-2)/3 */ #define LOWEST_FBIN 3 /* lowest frequency bin for feature vector preparation */ #define HIGHEST_FBIN 70 /* highest frequency bin for feature vector preparation */ @@ -1970,18 +1685,14 @@ typedef enum _DCTTYPE #define BUF_LEN 60 #define L_OVR 8 -#define N_FEATURES_2 3 /* number of features */ +#define N_FEATURES_2 3 /* number of features */ #define ATT_NSEG 32 /* strong attack detection - number of time blocks */ #define TOD_NSPEC 80 /* number of spectral bins of the tonal detector */ #define TOD_NSPEC_INV_Q31 26843546 /* inverse of number of spectral bins of the tonal detector */ -#define TOD_THR_MASS 0.86f /* initial value for the adaptive threshold of the tonal detector */ -#define TOD_THR_MASS_FX_Q22 3607101 /* initial value for the adaptive threshold of the tonal detector */ -#define P2A_FACT 0.9f /* long-term averaging factor for peak-to-average ratio */ -#define P2A_FACT_FX_Q15 29491 /* long-term averaging factor for peak-to-average ratio */ -#define THR_P2A_HIGH 95.0f /* higher threshold to detect strongly peaky signals at low bitrates*/ -#define THR_P2A 80.0f /* lower threshold to detect strongly peaky signals at higher bitrates */ +#define TOD_THR_MASS_FX_Q22 3607101 /* initial value for the adaptive threshold of the tonal detector, 0.86f in Q22 */ +#define P2A_FACT_FX_Q15 29491 /* long-term averaging factor for peak-to-average ratio, 0.9f in Q15 */ #define THR_P2A_HIGH_FX 95 /* Q0, higher threshold to detect strongly peaky signals at low bitrates*/ #define THR_P2A_FX 80 /* Q0, lower threshold to detect strongly peaky signals at higher bitrates */ @@ -2031,11 +1742,8 @@ typedef enum _DCTTYPE #define MBANDS_GN 16 /* Number of band for gain coding in GSC */ #define MBANDS_GN_BITALLOC16k 20 /* Number of band for gain coding in GSC */ #define BAND1k2 3 -#define DSR_NB_PULSE ( 4.5f ) -#define DSR_NB_PULSE_Q18 ( 1179648 ) -#define MAX_EQ_LF 1.0f +#define DSR_NB_PULSE_Q18 ( 1179648 ) /* 4.5f*/ #define MBANDS_LOC ( MBANDS_GN - 1 ) -#define BIN_SIZE 25.0f #define SWNB_SUBFR 1 #define MIN_RATE_4SBFR ACELP_16k40 @@ -2070,16 +1778,14 @@ typedef enum _DCTTYPE #define HQ_GEN_FB 5 #define PREECHO_SMOOTH_LEN 20 -#define INV_PREECHO_SMOOTH_LENP1 ( 1 / ( PREECHO_SMOOTH_LEN + 1.0 ) ); -#define EPSILON 0.000000000000001f +//#define EPSILON 0.000000000000001f #define EPSILON_FX_SMALL 1 #define EPSILON_FIX (1) #define EPSILON_FX (Word32)1 #define EPSILON_FX_M 1208925819 #define EPSILON_FX_E -49 - #define MAX_SEGMENT_LENGTH 480 #define NUM_TIME_SWITCHING_BLOCKS 4 #define NUM_MAP_BANDS 20 @@ -2118,7 +1824,7 @@ typedef enum _DCTTYPE #define HVQ_PVQ_BUF_LEN ( HVQ_PVQ_COEFS * ( MAX_PVQ_BANDS - 1 ) + HQ_MAX_BAND_LEN ) /* 24*7+96 = 216 */ #define QBIT_MAX2 9 -#define Q_PVQ_OUT 10 +#define Q_PVQ_OUT 10 #define FLAGN_BITS 1 #define GAIN0_BITS 5 @@ -2140,15 +1846,12 @@ typedef enum _DCTTYPE #define HUFF_THR 10 #define NOSUPERPOSITION 40 -#define MAXVALUEOFFIRSTGAIN 2.5f -#define MINVALUEOFFIRSTGAIN -2.5f -#define MAXVALUEOFFIRSTGAIN_FX 20480 /*2.5f in Q13 */ -#define MINVALUEOFFIRSTGAIN_FX -20480 +#define MAXVALUEOFFIRSTGAIN_FX 20480 /* 2.5f in Q13 */ +#define MINVALUEOFFIRSTGAIN_FX -20480 /* -2.5f in Q13 */ #define NOOFGAINBITS1 6 #define AUDIODELAYBITS 6 -#define DELTAOFFIRSTGAIN (float) ( MAXVALUEOFFIRSTGAIN - MINVALUEOFFIRSTGAIN ) / (float) ( ( 1 << NOOFGAINBITS1 ) - 1 ) -#define DELTAOFFIRSTGAIN_FX 2601 /*Q15 */ +#define DELTAOFFIRSTGAIN_FX 2601 /*Q15 */ #define MAX_D1M_16k ( ( L_FRAME16k >> 1 ) - NS2SA( 16000, SWITCH_GAP_LENGTH_NS ) - 16 ) #define MAX_D1M_12k8 ( ( L_FRAME16k >> 1 ) - NS2SA( 16000, SWITCH_GAP_LENGTH_NS ) - 20 ) @@ -2160,30 +1863,23 @@ typedef enum _DCTTYPE #define ENV_ADJ_START 6 /* Number of consecutive bands for which the attenuation is maximum */ #define ENV_ADJ_INCL 5 /* Inclination for mapping between attenuation region width and attenuation limit */ -#define ENV_SMOOTH_FAC 0.1f /* Smoothing factor for envelope stability measure */ -#define ENV_SMOOTH_FAC_FX ((Word16)0x0CCD) +#define ENV_SMOOTH_FAC_FX ((Word16)0x0CCD) /* Smoothing factor for envelope stability measure, 0.1f */ #define L_STAB_TBL 10 /* Number of elements in stability transition table */ -#define LUMPED_ENV_SMOOTH_FAC_FX ((Word16)10089) /* Q19 (no typo error), 0.1/sqrt(27) */ -#define CMPLMNT_ENV_SMOOTH_FAC_FX ((Word16)29491) /* Q15 0.9 */ +#define LUMPED_ENV_SMOOTH_FAC_FX ((Word16)10089) /* Q19 (no typo error), 0.1/sqrt(27) */ +#define CMPLMNT_ENV_SMOOTH_FAC_FX ((Word16)29491) /* Q15 0.9 */ #define M_STAB_TBL_FX ( (Word16) 21068 ) /* Q13, 2.571756 */ #define D_STAB_TBL_FX ( (Word16) 845 ) /* Q13 0.1013138 */ #define HALF_D_STAB_TBL_FX ( (Word16) 422 ) /* Q13 0.1013138/2.0 */ #define NUM_ENV_STAB_PLC_STATES 2 /* Number of states of markov model */ -#define INV_NUM_ENV_STAB_PLC_STATES 16384 /* Q15 */ -#define INV_STAB_TRANS_FX 16497 /* Q14. Equal to 1.0f/(1-2*stab_trans_fx[L_STAB_TBL-1]) */ - -#define ENV_STAB_EST1 2.93f /* env_stab estimation coefficient 1 */ -#define ENV_STAB_EST2 (-2.20f) /* env_stab estimation coefficient 2 */ -#define ENV_STAB_EST3 0.741f /* env_stab estimation coefficient 3 */ -#define ENV_STAB_EST1_FX 12001 /* env_stab estimation coefficient 1 *//*Q-12*/ -#define ENV_STAB_EST2_FX (-9011) /* env_stab estimation coefficient 2 *//*Q-12*/ -#define ENV_STAB_EST3_FX 3035 /* env_stab estimation coefficient 3 *//*Q-12*/ -#define STAB_FAC_EST1 1.093f /* stab_fac HQ estimation coefficient 1 */ -#define STAB_FAC_EST2 (-5.84e-05f) /* stab_fac HQ estimation coefficient 2, including Q12 scaling */ -#define STAB_FAC_EST3 0.125f /* stab_fac HQ estimation coefficient 3 */ -#define STAB_FAC_EST1_FX ((Word32)0x45F3B646) /* stab_fac HQ estimation coefficient 1 */ -#define STAB_FAC_EST2_FX ((Word32)0xFFFF0B0D) /* stab_fac HQ estimation coefficient 2, including Q12 scaling */ -#define STAB_FAC_EST3_FX ((Word32)0x10000000) /* stab_fac HQ estimation coefficient 3 */ +#define INV_NUM_ENV_STAB_PLC_STATES 16384 /* Q15 */ +#define INV_STAB_TRANS_FX 16497 /* Q14. Equal to 1.0f/(1-2*stab_trans_fx[L_STAB_TBL-1]) */ + +#define ENV_STAB_EST1_FX 12001 /* env_stab estimation coefficient 1, 2.93f *//*Q-12*/ +#define ENV_STAB_EST2_FX (-9011) /* env_stab estimation coefficient 2, -2.20f *//*Q-12*/ +#define ENV_STAB_EST3_FX 3035 /* env_stab estimation coefficient 3, 0.741f *//*Q-12*/ +#define STAB_FAC_EST1_FX ((Word32)0x45F3B646) /* stab_fac HQ estimation coefficient 1, 1.093f */ +#define STAB_FAC_EST2_FX ((Word32)0xFFFF0B0D) /* stab_fac HQ estimation coefficient 2, (-5.84e-05f), including Q12 scaling */ +#define STAB_FAC_EST3_FX ((Word32)0x10000000) /* stab_fac HQ estimation coefficient 3, 0.125f */ #define ATT_LIM_HANGOVER 150 /* Number of hangover frames for disabling stability dependent attenuation */ #define DELTA_TH 5.0f /* Delta energy threshold for transient detection for envelope stability */ @@ -2216,8 +1912,6 @@ typedef enum _DCTTYPE #define HQ_GENERIC_EXC1 1 #define HQ_GENERIC_SP_EXC 2 -#define LF_EMP_FAC 1.2f - #define DIM_FB 3 #define HQ_FB_FENV SWB_FENV + DIM_FB #define N_CB_FB 32 @@ -2255,52 +1949,37 @@ typedef enum _DCTTYPE #define HVQ_NEW_BAND_BIT_THR 30 #define HVQ_NF_GROUPS 2 -#define HVQ_NF_WEIGHT1 0.9578f /* HVQ Classifier - Noise floor estimate weight 1 */ -#define HVQ_NF_WEIGHT2 0.6472f /* HVQ Classifier - Noise floor estimate weight 2 */ -#define HVQ_PE_WEIGHT1 0.42237f /* HVQ Classifier - Peak envelope estimate weight 1 */ -#define HVQ_PE_WEIGHT2 0.80285f /* HVQ Classifier - Peak envelope estimate weight 2 */ -#define HVQ_THR_POW 0.88f /* HVQ Classifier power factor for threshold calc */ #define HVQ_SHARP_THRES 9 /* HVQ Classifier - Sharpness threshold */ -#define HVQ_NF_WEIGHT1_FX 31385 /* Q15 0.9578 - HVQ Classifier - Noise floor estimate weight 1 */ -#define HVQ_NF_WEIGHT1B 1383 /* Q15, 1 - HVQ_NF_WEIGHT1_FX */ -#define HVQ_NF_WEIGHT2_FX 21207 /* Q15 0.6472 - HVQ Classifier - Noise floor estimate weight 2 */ -#define HVQ_NF_WEIGHT2B 11561 /* Q15 1 - HVQ_NF_WEIGHT2_FX */ -#define HVQ_PE_WEIGHT1_FX 13840 /* Q15 0.42237 - HVQ Classifier - Peak envelope estimate weight 1 */ -#define HVQ_PE_WEIGHT1B 18928 /* Q15, 1 - HVQ_PE_WEIGHT1_FX */ -#define HVQ_PE_WEIGHT2_FX 26308 /* Q15 0.80285 - HVQ Classifier - Peak envelope estimate weight 2 */ -#define HVQ_PE_WEIGHT2B 6460 /* Q15, 1 - HVQ_PE_WEIGHT2_FX */ -#define HVQ_SHARP_THRES_FX 576 /*9 in Q6 */ - -#define HVQ_PA_FAC 0.7071f /* HVQ Classifier peak allocation factor */ -#define HVQ_PA_FAC_FX 23170 /* Q15 0.7071 - HVQ Classifier peak allocation factor */ +#define HVQ_NF_WEIGHT1_FX 31385 /* Q15 0.9578 - HVQ Classifier - Noise floor estimate weight 1 */ +#define HVQ_NF_WEIGHT1B 1383 /* Q15, 1 - HVQ_NF_WEIGHT1_FX */ +#define HVQ_NF_WEIGHT2_FX 21207 /* Q15 0.6472 - HVQ Classifier - Noise floor estimate weight 2 */ +#define HVQ_NF_WEIGHT2B 11561 /* Q15 1 - HVQ_NF_WEIGHT2_FX */ +#define HVQ_PE_WEIGHT1_FX 13840 /* Q15 0.42237 - HVQ Classifier - Peak envelope estimate weight 1 */ +#define HVQ_PE_WEIGHT1B 18928 /* Q15, 1 - HVQ_PE_WEIGHT1_FX */ +#define HVQ_PE_WEIGHT2_FX 26308 /* Q15 0.80285 - HVQ Classifier - Peak envelope estimate weight 2 */ +#define HVQ_PE_WEIGHT2B 6460 /* Q15, 1 - HVQ_PE_WEIGHT2_FX */ +#define HVQ_SHARP_THRES_FX 576 /* 9 in Q6 */ + +#define HVQ_PA_FAC_FX 23170 /* Q15 0.7071 - HVQ Classifier peak allocation factor */ #define HVQ_PA_PEAKS_SHARP1 9 /* HVQ Classifier - Maximum number of peaks for band with high sharpness */ #define HVQ_PA_PEAKS_SHARP2 3 /* HVQ Classifier - Maximum number of peaks for band with medium sharpness */ #define HVQ_PA_PEAKS_SHARP3 2 /* HVQ Classifier - Maximum number of peaks for band with low sharpness */ -#define HVQ_PA_SHARP_THRES2 16.0f /* HVQ Classifier - Sharpness threshold for band with medium sharpness */ -#define HVQ_PA_SHARP_THRES3 12.0f /* HVQ Classifier - Sharpness threshold for band with low sharpness */ -#define HVQ_PA_SHARP_THRES2_FX 1024 /* Q6 16.0 - HVQ Classifier - Sharpness threshold for band with medium sharpness */ -#define HVQ_PA_SHARP_THRES3_FX 768 /* Q6 12.0 - HVQ Classifier - Sharpness threshold for band with low sharpness */ +#define HVQ_PA_SHARP_THRES2_FX 1024 /* Q6 16.0 - HVQ Classifier - Sharpness threshold for band with medium sharpness */ +#define HVQ_PA_SHARP_THRES3_FX 768 /* Q6 12.0 - HVQ Classifier - Sharpness threshold for band with low sharpness */ #define HVQ_BW 32 /* HVQ Classifier subband bandwidth */ #define HVQ_NSUB_32k 10 #define HVQ_NSUB_24k 7 /* HVQ Classifier number of subbands */ -#define HQ_CREST_THRESHOLD 7.0f /* HQ harmonic high band classifier, crest threshold */ -#define HQ_CREST_THRESHOLD_FX 1879048192 //7.0f in Q28 /* HQ harmonic high band classifier, crest threshold */ -#define HQ_CREST_MOD_THRESHOLD 2.128f /* HQ harmonic high band classifier, modified crest threshold */ -#define HQ_CREST_MOD_THRESHOLD_FX 1142461301 //2.128f in Q29 /* HQ harmonic high band classifier, modified crest threshold */ -#define HQ_CREST_FAC_SM 0.97f /* HQ harmonic high band classifier, smoothing factor */ -#define HQ_CREST_FAC_SM_FX 2083059139 //0.97f in Q31 /* HQ harmonic high band classifier, smoothing factor */ +#define HQ_CREST_THRESHOLD_FX 1879048192 /* HQ harmonic high band classifier, crest threshold, 7.0f in Q28 */ +#define HQ_CREST_MOD_THRESHOLD_FX 1142461301 /* HQ harmonic high band classifier, modified crest threshold, 2.128f in Q29 */ +#define HQ_CREST_FAC_SM_FX 2083059139 /* HQ harmonic high band classifier, smoothing factor, 0.97f in Q31 */ #define HVQ_BWE_NOISE_BANDS 2 /* Number of BWE noise bands */ -#define HVQ_BWE_WEIGHT1 0.95f -#define HVQ_BWE_WEIGHT2 0.2f -#define HVQ_NFPE_FACTOR 6.4f -#define HVQ_LB_NFPE_FACTOR 3.2f -#define HVQ_BWE_WEIGHT1_FX ((Word16)31130) /* 0.95 in Q15 */ -#define HVQ_BWE_WEIGHT2_FX ((Word16)6554) /* 0.2 in Q15 */ -#define HVQ_NFPE_FACTOR_CUBE_FX ((Word16)16777) /* 6.4^3 in Q6 */ -#define HVQ_LB_NFPE_FACTOR_CUBE_FX ((Word16)16777) /* 3.2^3 in Q9 */ +#define HVQ_BWE_WEIGHT1_FX ((Word16)31130) /* 0.95 in Q15 */ +#define HVQ_BWE_WEIGHT2_FX ((Word16)6554) /* 0.2 in Q15 */ +#define HVQ_NFPE_FACTOR_CUBE_FX ((Word16)16777) /* 6.4^3 in Q6 */ +#define HVQ_LB_NFPE_FACTOR_CUBE_FX ((Word16)16777) /* 3.2^3 in Q9 */ #define HVQ_VQ_DIM 5 /* HVQ peak VQ dimension */ #define HVQ_PVQ_GAIN_BITS 5 /* Number of bits to encode PVQ gains in HVQ */ @@ -2344,9 +2023,9 @@ enum QuantaMode #define KMAX 512 #define KMAX_NON_DIRECT 96 /* max K for non-direct indexing recursion rows */ #define ODD_DIV_SIZE 48 /* ind0=1/1 ind1 =1/3 ... ind47=1/95 */ -#define KMAX_FX 512 -#define KMAX_NON_DIRECT_FX 96 /* max K for non-direct indexing recursion rows is 1+KMAX_NON_DIRECT +1 */ -#define ODD_DIV_SIZE_FX 48 /* ind0=1/1 ind1 =1/3 ... ind47=1/95 */ +#define KMAX_FX 512 +#define KMAX_NON_DIRECT_FX 96 /* max K for non-direct indexing recursion rows is 1+KMAX_NON_DIRECT +1 */ +#define ODD_DIV_SIZE_FX 48 /* ind0=1/1 ind1 =1/3 ... ind47=1/95 */ /* TCQ */ #define TCQ_MAX_BAND_SIZE 120 /* Maxiumum supported band size for TCQ+USQ search */ @@ -2503,8 +2182,7 @@ enum QuantaMode #define MAX_PLOCS L_PROT48k / 4 + 1 /* maximum number of spectral peaks to be searched */ #define QUOT_LPR_LTR 4 #define LGW_MAX 9 /* maximum number frequency group widths */ -#define BETA_MUTE_FAC_INI_FLT 0.5f /* initial noise attenuation factor */ -#define BETA_MUTE_FAC_INI 16384 /* Q15, initial noise attenuation factor */ +#define BETA_MUTE_FAC_INI 16384 /* 0.5f in Q15, initial noise attenuation factor */ #define L_TRANA32k ( L_PROT32k / QUOT_LPR_LTR ) /* transient analysis frame length */ #define L_TRANA16k ( L_TRANA32k / 2 ) #define L_TRANA8k ( L_TRANA32k / 4 ) @@ -2520,16 +2198,11 @@ enum QuantaMode #define OFF_FRAMES_LIMIT 30 /* HQ phase ECU, burst length for muting to zero */ #define PH_ECU_MUTE_START 15 /* HQ phase ECU, burst length to start steep muting */ -#define SCALE_DOWN_3dB 0.7071f -#define MAX_TILT 0.f -#define ED_THRES 1.0f +//#define SCALE_DOWN_3dB 0.7071f -#define ED_THRES_12P 0.032209f -#define ED_THRES_50P 0.159063f -#define ED_THRES_90P 0.532669 -#define ED_THRES_12P_fx 66 -#define ED_THRES_50P_fx 326 -#define ED_THRES_90P_fx 1091 +#define ED_THRES_12P_fx 66 /* 0.032209f */ +#define ED_THRES_50P_fx 326 /* 0.159063f */ +#define ED_THRES_90P_fx 1091 /* 0.532669f */ #define MAXDELAY_FEC 224 @@ -2547,26 +2220,19 @@ enum QuantaMode #define GROUP_LENGTH 7 #define MAX_PEAKS_FROM_PITCH 10 #define LAST_HARMONIC_POS_TO_CHECK 128 /* 128 because we check harmonics only up to 3.2 kHz */ -#define ALLOWED_SIDE_LOBE_FLUCTUATION_FLT 3.0f /* 4.8 dB */ -#define ALLOWED_SIDE_LOBE_FLUCTUATION 24576/*3.0f Q13*/ /* 4.8 dB */ -#define ALLOWED_SIDE_LOBE_FLUCTUATION_EXP 2 -#define LEVEL_ABOVE_ENVELOPE_FLT 7.59f /* 8.8 dB */ -#define UNREACHABLE_THRESHOLD_FLT 16.0f /* 12 dB Increase of LEVEL_ABOVE_ENVELOPE_FLT so that the threshold is not reached */ -#define SMALL_THRESHOLD_FLT 1.10f /* 0.41 dB Increase of LEVEL_ABOVE_ENVELOPE_FLT for the peak detection at a definitive peak in the estimated spectrum */ -#define BIG_THRESHOLD_FLT 1.5f /* 1.76 dB Increase of LEVEL_ABOVE_ENVELOPE_FLT for the peak detection at a probable peak in the estimated spectrum */ -#define LEVEL_ABOVE_ENVELOPE 7.59f /* 8.8 dB */ -#define UNREACHABLE_THRESHOLD 16384/*16.0f Q10*/ /* 12 dB Increase of LEVEL_ABOVE_ENVELOPE so that the threshold is not reached */ -#define SMALL_THRESHOLD 1126/*1.10f Q10*/ /* 0.41 dB Increase of LEVEL_ABOVE_ENVELOPE for the peak detection at a definitive peak in the estimated spectrum */ -#define BIG_THRESHOLD 1536/*1.5f Q10*/ /* 1.76 dB Increase of LEVEL_ABOVE_ENVELOPE for the peak detection at a probable peak in the estimated spectrum */ - -#define kSmallerLagsTargetBitsThreshold 150 -#define kCtxHmOlRSThr_FLT 2.6f -#define kLtpHmGainThr_FLT 0.46f /* Use the LTP pitch lag in the harmonic model? */ -#define kLtpHmGainThr 0x3AE1 /* 0.46f */ -#define kCtxHmOlRSThr 0x5333 /* 2.6f (2Q13) */ - -#define kTcxHmSnrOffsetGc 8/*0.03125f Q8*/ -#define kTcxHmSnrOffsetVc 0 +#define ALLOWED_SIDE_LOBE_FLUCTUATION 24576 /*3.0f Q13*/ /* 4.8 dB */ +#define ALLOWED_SIDE_LOBE_FLUCTUATION_EXP 2 +#define LEVEL_ABOVE_ENVELOPE 7.59f /* 8.8 dB */ +#define UNREACHABLE_THRESHOLD 16384 /* 16.0f Q10*/ /* 12 dB Increase of LEVEL_ABOVE_ENVELOPE so that the threshold is not reached */ +#define SMALL_THRESHOLD 1126 /* 1.10f Q10*/ /* 0.41 dB Increase of LEVEL_ABOVE_ENVELOPE for the peak detection at a definitive peak in the estimated spectrum */ +#define BIG_THRESHOLD 1536 /* 1.5f Q10*/ /* 1.76 dB Increase of LEVEL_ABOVE_ENVELOPE for the peak detection at a probable peak in the estimated spectrum */ + +#define kSmallerLagsTargetBitsThreshold 150 +#define kLtpHmGainThr 0x3AE1 /* 0.46f, Use the LTP pitch lag in the harmonic model? */ +#define kCtxHmOlRSThr 0x5333 /* 2.6f (2Q13) */ + +#define kTcxHmSnrOffsetGc 8 /* 0.03125f Q8 */ +#define kTcxHmSnrOffsetVc 0 #define kTcxHmNumGainBits 2 /* Number of bits for the gain index */ #define kTcxHmParabolaHalfWidth 4 /* Parabola half width */ @@ -2673,13 +2339,9 @@ enum #define CUTFREE_ABS_RANGE 6 #define CUTFREE_REL_RANGE 0.25 -#define VBR_ADR_MAX_TARGET 6.15f /* max target ADR for VBR. This rate is used in the closed loop rate control */ +#define PPP_LAG_THRLD_Q6 180*64 #define PPP_LAG_THRLD 180 /* max lag allowed for PPP coding */ - -#define PPP_LAG_THRLD_Q6 180*64 -#define PPP_LAG_THRLD 180 -#define SNR_THLD_FX_Q8 17152 /* Threshold is upscaled to Q8 to compared with st->vadsnr*/ - +#define SNR_THLD_FX_Q8 17152 /* Threshold is upscaled to Q8 to compared with st->vadsnr*/ #define MAXLAG_WI ( PPP_LAG_THRLD / 2 + 12 ) /* Maximum lag used in waveform interpolation */ #define MAX_LAG_PIT ( PPP_LAG_THRLD + 21 ) /* Max possible pitch lag after adding delta lag */ @@ -2690,21 +2352,21 @@ enum #define Q_SCALE 7 -#define CONST_1_16_Q14 19005 /* 1.16*16384 */ -#define CONST_1_37_Q14 22446 /* 1.37*16384 */ -#define SCALE_DOWN_ERAS_Q15 26214 /* 0.8*32768 */ -#define SHAPE1_COEF_QF 15 /* shape1 num and den coeffcient Q format */ -#define SHAPE2_COEF_QF 15 /* shape2 num and den coeffcient Q format */ -#define SHAPE3_COEF_QF 15 /* shape3 num and den coeffcient Q format */ -#define BP1_COEF_WB_QF 14 /* wb num and den coeffcient Q format */ -#define BP1_COEF_NB_QF_ORDER7 13 /* nb num and den coeffcient Q format */ +#define CONST_1_16_Q14 19005 /* 1.16*16384 */ +#define CONST_1_37_Q14 22446 /* 1.37*16384 */ +#define SCALE_DOWN_ERAS_Q15 26214 /* 0.8*32768 */ +#define SHAPE1_COEF_QF 15 /* shape1 num and den coeffcient Q format */ +#define SHAPE2_COEF_QF 15 /* shape2 num and den coeffcient Q format */ +#define SHAPE3_COEF_QF 15 /* shape3 num and den coeffcient Q format */ +#define BP1_COEF_WB_QF 14 /* wb num and den coeffcient Q format */ +#define BP1_COEF_NB_QF_ORDER7 13 /* nb num and den coeffcient Q format */ /*----------------------------------------------------------------------------------* * JBM *----------------------------------------------------------------------------------*/ -#define MAX_JBM_SLOTS 100 /* every primary copy and partial copy stored in JBM needs one slot */ -#define MAX_AU_SIZE ( ( MAX_BITS_PER_FRAME + 7 ) / 8 ) /* max frame size in bytes */ +#define MAX_JBM_SLOTS 100 /* every primary copy and partial copy stored in JBM needs one slot */ +#define MAX_AU_SIZE ( ( MAX_BITS_PER_FRAME + 7 ) / 8 ) /* max frame size in bytes */ #define ACTIVE 4 #define BACKGROUND 1 @@ -2718,99 +2380,99 @@ enum /*------------------------------------------------------------------------------------* FEC_clas_estim constants *-------------------------------------------------------------------------------------*/ + #define Q_MAX 12 -#define LG10 24660 /* 10*log10(2) in Q13 */ +#define LG10 24660 /* 10*log10(2) in Q13 */ #define L_Q_MEM 5 #define GE_SHIFT 6 #define LSF_1_OVER_256SQ 5000 #define LSF_1_OVER_256SQSQ 763 -#define G_CODE_MIN_TC_Q15 655 /*0.02 Q15*/ +#define G_CODE_MIN_TC_Q15 655 /*0.02 Q15*/ #define G_CODE_MAX_TC_Q0 5 -#define G_PITCH_MIN_Q14 0 /* SQ of gains: pitch gain lower limit (0.0 in Q13) */ -#define G_PITCH_MAX_MINUS_MIN_Q13 9994 /* SQ of gains: pitch gain upper limit (1.22-0 in Q13) */ +#define G_PITCH_MIN_Q14 0 /* SQ of gains: pitch gain lower limit (0.0 in Q13) */ +#define G_PITCH_MAX_MINUS_MIN_Q13 9994 /* SQ of gains: pitch gain upper limit (1.22-0 in Q13) */ /* higher ACELP constants */ -#define G_AVQ_MIN_32kbps_Q15 2621 /* lower limit for gain Q in higher-rate ACELP contribtuion @32kbps (0.08 in Q15) */ -#define G_AVQ_MIN_Q15 26214 /* lower limit for gain Q in higher-rate ACELP contribtuion (0.8 in Q15) */ -#define G_AVQ_MAX_Q0 96 /* upper limit for gain Q in higher-rate ACELP contribtuion */ - -#define LG10_G_AVQ_MIN_32kbps_Q14 (-17972) /* log10(0.08) lower limit for gain Q in higher-rate ACELP contribtuion @32kbps (0.08 in Q15) */ -#define LG10_G_AVQ_MIN_Q14 (-1588) /* log10(0.8) lower limit for gain Q in higher-rate ACELP contribtuion (0.8 in Q15) */ -#define LG10_G_AVQ_MAX_Q13 16239 /* log10(96) upper limit for gain Q in higher-rate ACELP contribtuion */ -#define LG10_G_CODE_MIN_TC192_Q14 (-3635) /* log10(0.6) */ -#define LG10_G_CODE_MAX_TC192_Q13 13212 /* log10(41) */ -#define LG10_G_CODE_MAX_Q13 5726 /* log10(5) SQ of gains: code gain upper limit */ -#define LG10_G_CODE_MIN_Q14 (-27836) /* log10(0.02) SQ of gains: code gain lower limit */ -#define LG10_G_CODE_MIN_TC_Q14 LG10_G_CODE_MIN_Q14 /* log10(0.02) Q15*/ -#define LG10_G_CODE_MAX_TC_Q13 LG10_G_CODE_MAX_Q13 - -#define LN_2_Q31 (1488521848 ) +#define G_AVQ_MIN_32kbps_Q15 2621 /* lower limit for gain Q in higher-rate ACELP contribtuion @32kbps (0.08 in Q15) */ +#define G_AVQ_MIN_Q15 26214 /* lower limit for gain Q in higher-rate ACELP contribtuion (0.8 in Q15) */ +#define G_AVQ_MAX_Q0 96 /* upper limit for gain Q in higher-rate ACELP contribtuion */ + +#define LG10_G_AVQ_MIN_32kbps_Q14 (-17972) /* log10(0.08) lower limit for gain Q in higher-rate ACELP contribtuion @32kbps (0.08 in Q15) */ +#define LG10_G_AVQ_MIN_Q14 (-1588) /* log10(0.8) lower limit for gain Q in higher-rate ACELP contribtuion (0.8 in Q15) */ +#define LG10_G_AVQ_MAX_Q13 16239 /* log10(96) upper limit for gain Q in higher-rate ACELP contribtuion */ +#define LG10_G_CODE_MIN_TC192_Q14 (-3635) /* log10(0.6) */ +#define LG10_G_CODE_MAX_TC192_Q13 13212 /* log10(41) */ +#define LG10_G_CODE_MAX_Q13 5726 /* log10(5) SQ of gains: code gain upper limit */ +#define LG10_G_CODE_MIN_Q14 (-27836) /* log10(0.02) SQ of gains: code gain lower limit */ +#define LG10_G_CODE_MIN_TC_Q14 LG10_G_CODE_MIN_Q14 /* log10(0.02) Q15*/ +#define LG10_G_CODE_MAX_TC_Q13 LG10_G_CODE_MAX_Q13 + +#define LN_2_Q31 (1488521848 ) /* AVQ (RE8) related consatnts */ -#define QR 32768 -#define Q_AVQ_OUT 6 /* AVQ_output scaling currently Q9, but may change */ -#define Q_AVQ_OUT_DEC 10 +#define QR 32768 +#define Q_AVQ_OUT 6 /* AVQ_output scaling currently Q9, but may change */ +#define Q_AVQ_OUT_DEC 10 -#define PIT_DECODE_2XL_SUBFR (2*L_SUBFR) -#define PIT_FR1_8b_MINUS_PIT_MIN_X2 ((PIT_FR1_8b-PIT_MIN)*2) +#define PIT_DECODE_2XL_SUBFR (2*L_SUBFR) +#define PIT_FR1_8b_MINUS_PIT_MIN_X2 ((PIT_FR1_8b-PIT_MIN)*2) #define PIT_FR1_8b_MINUS_PIT_FR1_8b_MINUS_PIT_MIN_X2 (PIT_FR1_8b-PIT_FR1_8b_MINUS_PIT_MIN_X2) -#define PIT_FR2_9b_MINUS_PIT_MIN_X4 ((PIT_FR2_9b-PIT_MIN)*4) -#define PIT_FR1_EXT8b_MINUS_PIT_MIN_EXT_X2 ((PIT_FR1_EXTEND_8b-PIT_MIN_EXTEND)*2) -#define PIT_FR2_EXT9b_MINUS_PIT_MIN_EXT_X4 ((PIT_FR2_EXTEND_9b-PIT_MIN_EXTEND)*4) -#define PIT_FR1_EXT9b_MINUS_PIT_FR2_EXT9b_X2 ((PIT_FR1_EXTEND_9b-PIT_FR2_EXTEND_9b)*2) -#define PIT_FR1_DEXT8b_MINUS_PIT_MIN_DEXT_X2 ((PIT_FR1_DOUBLEEXTEND_8b-PIT_MIN_DOUBLEEXTEND)*2 ) -#define PIT_FR2_DEXT9b_MINUS_PIT_MIN_DEXT_X4 ((PIT_FR2_DOUBLEEXTEND_9b-PIT_MIN_DOUBLEEXTEND)*4 ) - -#define PIT_DECODE_1 ((PIT_FR2_9b-PIT_MIN)*4 + (PIT_FR1_9b-PIT_FR2_9b)*2) -#define PIT_DECODE_2 ((PIT_FR2_9b-PIT_MIN)*4) -#define PIT_DECODE_3 (PIT_FR1_9b - ((PIT_FR2_9b-PIT_MIN)*4) - ((PIT_FR1_9b-PIT_FR2_9b)*2)) -#define PIT_DECODE_7 (PIT_FR1_EXTEND_9b - (PIT_FR2_EXT9b_MINUS_PIT_MIN_EXT_X4) - (PIT_FR1_EXT9b_MINUS_PIT_FR2_EXT9b_X2)) -#define PIT_DECODE_8 (PIT_FR1_DOUBLEEXTEND_8b - ((PIT_FR1_DOUBLEEXTEND_8b-PIT_MIN_DOUBLEEXTEND)*2)) -#define PIT_DECODE_9 (( (PIT_FR2_DOUBLEEXTEND_9b-PIT_MIN_DOUBLEEXTEND)*4 + (PIT_FR1_DOUBLEEXTEND_9b-PIT_FR2_DOUBLEEXTEND_9b)*2)) -#define PIT_DECODE_10 (PIT_FR1_DOUBLEEXTEND_9b - ((PIT_FR2_DOUBLEEXTEND_9b-PIT_MIN_DOUBLEEXTEND)*4) - ((PIT_FR1_DOUBLEEXTEND_9b-PIT_FR2_DOUBLEEXTEND_9b)*2)) - -#define BIN4_FX 800 -#define TH_COR_FX 19661 /* Q15 Minimum correlation for per bin processing */ -#define TH_D_FX 800 /* 50 (Q4) Difference limit between nearest harmonic and a frequency bin */ -#define TH_PIT_FX 128 /* (Fs / (2.0f * TH_D)) Maximum pitch for per bin processing */ - -#define GUESS_TBL_SZ 256 -#define INT_FS_FX 12800 /* internal sampling frequency */ -#define INT_FS_16k_FX 16000 /* CELP core internal sampling frequency @16kHz */ - -#define WB_LIMIT_LSF_FX 16256 -#define Fs_2 16384 /* lsf max value (Use in reorder_fx.c) */ -#define Fs_2_16k 20480 /* lsf max value (Use in reorder_fx.c) */ - -#define LG10 24660 /* 10*log10(2) in Q13 */ -#define TEN_MULT_LOG10_2_IN_Q29 1616142464 /* (10 * log10(2)) = 3.0103 (in Q29) */ -#define LG10_s3_0 16440 /* 10*log10(2)/1.55 = 1.00343331 in Q14 */ -#define LOG2_10 27213 /* log base 2 of 10 in Q12 */ -#define LOG2_10_Q29 1783446566 /* log base 2 of 10 in Q12 */ -#define LOG10_2_Q31 646456993 /* inverse log base 10 of 2 in Q31 */ +#define PIT_FR2_9b_MINUS_PIT_MIN_X4 ((PIT_FR2_9b-PIT_MIN)*4) +#define PIT_FR1_EXT8b_MINUS_PIT_MIN_EXT_X2 ((PIT_FR1_EXTEND_8b-PIT_MIN_EXTEND)*2) +#define PIT_FR2_EXT9b_MINUS_PIT_MIN_EXT_X4 ((PIT_FR2_EXTEND_9b-PIT_MIN_EXTEND)*4) +#define PIT_FR1_EXT9b_MINUS_PIT_FR2_EXT9b_X2 ((PIT_FR1_EXTEND_9b-PIT_FR2_EXTEND_9b)*2) +#define PIT_FR1_DEXT8b_MINUS_PIT_MIN_DEXT_X2 ((PIT_FR1_DOUBLEEXTEND_8b-PIT_MIN_DOUBLEEXTEND)*2 ) +#define PIT_FR2_DEXT9b_MINUS_PIT_MIN_DEXT_X4 ((PIT_FR2_DOUBLEEXTEND_9b-PIT_MIN_DOUBLEEXTEND)*4 ) + +#define PIT_DECODE_1 ((PIT_FR2_9b-PIT_MIN)*4 + (PIT_FR1_9b-PIT_FR2_9b)*2) +#define PIT_DECODE_2 ((PIT_FR2_9b-PIT_MIN)*4) +#define PIT_DECODE_3 (PIT_FR1_9b - ((PIT_FR2_9b-PIT_MIN)*4) - ((PIT_FR1_9b-PIT_FR2_9b)*2)) +#define PIT_DECODE_7 (PIT_FR1_EXTEND_9b - (PIT_FR2_EXT9b_MINUS_PIT_MIN_EXT_X4) - (PIT_FR1_EXT9b_MINUS_PIT_FR2_EXT9b_X2)) +#define PIT_DECODE_8 (PIT_FR1_DOUBLEEXTEND_8b - ((PIT_FR1_DOUBLEEXTEND_8b-PIT_MIN_DOUBLEEXTEND)*2)) +#define PIT_DECODE_9 (( (PIT_FR2_DOUBLEEXTEND_9b-PIT_MIN_DOUBLEEXTEND)*4 + (PIT_FR1_DOUBLEEXTEND_9b-PIT_FR2_DOUBLEEXTEND_9b)*2)) +#define PIT_DECODE_10 (PIT_FR1_DOUBLEEXTEND_9b - ((PIT_FR2_DOUBLEEXTEND_9b-PIT_MIN_DOUBLEEXTEND)*4) - ((PIT_FR1_DOUBLEEXTEND_9b-PIT_FR2_DOUBLEEXTEND_9b)*2)) + +#define BIN4_FX 800 +#define TH_COR_FX 19661 /* Q15 Minimum correlation for per bin processing */ +#define TH_D_FX 800 /* 50 (Q4) Difference limit between nearest harmonic and a frequency bin */ +#define TH_PIT_FX 128 /* (Fs / (2.0f * TH_D)) Maximum pitch for per bin processing */ + +#define GUESS_TBL_SZ 256 +#define INT_FS_FX 12800 /* internal sampling frequency */ +#define INT_FS_16k_FX 16000 /* CELP core internal sampling frequency @16kHz */ + +#define WB_LIMIT_LSF_FX 16256 +#define Fs_2 16384 /* lsf max value (Use in reorder_fx.c) */ +#define Fs_2_16k 20480 /* lsf max value (Use in reorder_fx.c) */ + +#define LG10 24660 /* 10*log10(2) in Q13 */ +#define TEN_MULT_LOG10_2_IN_Q29 1616142464 /* (10 * log10(2)) = 3.0103 (in Q29) */ +#define LG10_s3_0 16440 /* 10*log10(2)/1.55 = 1.00343331 in Q14 */ +#define LOG2_10 27213 /* log base 2 of 10 in Q12 */ +#define LOG2_10_Q29 1783446566 /* log base 2 of 10 in Q12 */ +#define LOG10_2_Q31 646456993 /* inverse log base 10 of 2 in Q31 */ #ifdef FIX_2210_ASSERT_IN_BW_DETEC_FX_FOR_OMASA -#define INV_LOG2_10 9864 /* 1/log2(10), Q15*/ +#define INV_LOG2_10 9864 /* 1/log2(10), Q15*/ #endif -#define MU_MA_FX 10923 /* original prediction factor for the AMR WB tables (Q15) */ +#define MU_MA_FX 10923 /* original prediction factor for the AMR WB tables (Q15) */ -#define E_MIN_FXQ15 115 /* Q15*/ -#define E_MIN_FXQ31 7516193 /* 0.0035d in Q31*/ +#define E_MIN_FXQ15 115 /* Q15*/ +#define E_MIN_FXQ31 7516193 /* 0.0035d in Q31*/ -#define MAX_DYNAMIC_FX (82*128) -#define MIN_DYNAMIC_FX (50*128) -#define DYNAMIC_RANGE_FX (MAX_DYNAMIC_FX-MIN_DYNAMIC_FX) -#define MAX_GSC_NF_BITS 3 -//#define GSC_NF_STEPS (1 << MAX_GSC_NF_BITS) -#define GSF_NF_DELTA_FX (DYNAMIC_RANGE_FX/GSC_NF_STEPS) +#define MAX_DYNAMIC_FX (82*128) +#define MIN_DYNAMIC_FX (50*128) +#define DYNAMIC_RANGE_FX (MAX_DYNAMIC_FX-MIN_DYNAMIC_FX) +#define MAX_GSC_NF_BITS 3 +#define GSF_NF_DELTA_FX (DYNAMIC_RANGE_FX/GSC_NF_STEPS) /*----------------------------------------------------------------------------------* * AVQ constants *----------------------------------------------------------------------------------*/ -#define MIN_GLOB_GAIN_BWE_HR_FX 24576 /* Q13 */ -#define MAX_GLOB_GAIN_BWE_HR_FX 32000 /* Q6 */ +#define MIN_GLOB_GAIN_BWE_HR_FX 24576 /* Q13 */ +#define MAX_GLOB_GAIN_BWE_HR_FX 32000 /* Q6 */ #define LG10_MIN_GLOB_GAIN_BWE_HR_Q14 7817 #define LG10_MAX_GLOB_GAIN_BWE_HR_Q13 22110 @@ -2819,186 +2481,187 @@ enum * LD music post-filter constants *----------------------------------------------------------------------------------*/ -#define BIN_16kdct_fx (6400/DCT_L_POST) -#define E_MIN_Q15 14680 /* 0.0035 -> Q22 */ +#define BIN_16kdct_fx (6400/DCT_L_POST) +#define E_MIN_Q15 14680 /* 0.0035 -> Q22 */ -#define QSCALE 7 -#define MODE2_E_MIN 4/*0.03f Q0*/ /* 0.03f in QSCALE */ -#define MODE2_E_MIN_Q15 983/*0.03f Q15*/ /* 0.03f in Q15*/ +#define QSCALE 7 +#define MODE2_E_MIN 4 /*0.03f Q0*/ /* 0.03f in QSCALE */ +#define MODE2_E_MIN_Q15 983 /*0.03f Q15*/ /* 0.03f in Q15*/ /* long term pst parameters : */ -#define L2_LH2_L 4 /* log2(LH2_L) */ -#define MIN_GPLT_FX 21845 /* LT gain minimum 1/1.5 (Q15) */ +#define L2_LH2_L 4 /* log2(LH2_L) */ +#define MIN_GPLT_FX 21845 /* LT gain minimum 1/1.5 (Q15) */ -#define AGC_FAC_FX 32358 /* gain adjustment factor 0.9875 (Q15) */ -#define AGC_FAC1_FX (Word16)(32768L - AGC_FAC_FX) +#define AGC_FAC_FX 32358 /* gain adjustment factor 0.9875 (Q15) */ +#define AGC_FAC1_FX (Word16)(32768L - AGC_FAC_FX) -#define DOWNMIX_12k8_FX 1850 +#define DOWNMIX_12k8_FX 1850 /*----------------------------------------------------------------------------------* * HQ Constants *----------------------------------------------------------------------------------*/ -#define INV2POWHALF 23170 /* Q15, sqrt(2)/2 */ -#define EPSILLON_FX (Word16) 1 -#define MAX_SFM_LEN_FX 96 -#define MAX_P_ATT_FX (Word16) 40 /* Maximum number of pulses for gain attenuation factor */ -#define MAX_PHG_FX (Word16) 10 /* Q0, Maximum number of pulses for which to apply pulse height dependent gain */ -#define PHG_START_FX (Word16) 3277 /* Q15, 0.1f */ -#define PHG_DELTA_FX (Word16) 2621 /* Q15, ((PHG_END-PHG_START)/MAX_PHG) */ -#define ENV_ADJ_START_FX (Word16) 6 /* Q0, Number of consecutive bands for which the attenuation is maximum */ -#define ENV_ADJ_INV_INCL_FX (Word16) 6554 /* Q15, 1/5.0f, Inverse inclination for mapping between attenuation region width and attenuation limit */ - -#define INV_HVQ_THRES_BIN_24k 9362 /* 1/224 in Q21 */ -#define INV_HVQ_THRES_BIN_32k 6554 /* 1/320 in Q21 */ -#define INV_BANDS_PER_SUBFRAMES 14564 /* 1/9 in Q17 */ -#define NUM_SUBFRAMES 4 -#define BANDS_PER_SUBFRAMES 9 -#define ENERGY_TH_NUM_SUBFRAMES 1638400L /* 400 in Q12 */ -#define INV_SFM_N_ENV_STAB 19418 /* 1/27 in Q19 */ -#define ENERGY_TH_FX 819200L /* 100 in Q13 */ -#define ENERGY_LT_BETA_FX 30474 /* 0.93 in Q15 - Smoothing factor for long-term energy measure */ -#define ENERGY_LT_BETA_1_FX 2294 /* 0.07 i Q15 - (1 - ENERGY_LT_BETA_FX) */ -#define INV_DELTA_TH 13107 /* 1/5 in Q16 - Inverse Delta energy threshold for transient detection for envelope stability */ - -#define ONE_OVER_HVQ_BAND_MAX_BITS_24k_FX ((Word16) 410) /* Q15, 1/80 = 0.0125 */ -#define ONE_OVER_HVQ_BAND_MAX_BITS_32k_FX ((Word16) 345) /* Q15, 1/95 = 0.010526315 */ - -#define INV_PREECHO_SMOOTH_LENP1_FX 1560 /*(32768 / (PREECHO_SMOOTH_LEN + 1.0));*/ - -#define INV_HVQ_BW 1024 /* Q15 1/32 */ - -#define ACELP_48k_BITS 960 /* Q0 - ACELP_48k / 50 */ +#define INV2POWHALF 23170 /* Q15, sqrt(2)/2 */ +#define EPSILLON_FX (Word16) 1 +#define MAX_SFM_LEN_FX 96 +#define MAX_P_ATT_FX (Word16) 40 /* Maximum number of pulses for gain attenuation factor */ +#define MAX_PHG_FX (Word16) 10 /* Q0, Maximum number of pulses for which to apply pulse height dependent gain */ +#define PHG_START_FX (Word16) 3277 /* Q15, 0.1f */ +#define PHG_DELTA_FX (Word16) 2621 /* Q15, ((PHG_END-PHG_START)/MAX_PHG) */ +#define ENV_ADJ_START_FX (Word16) 6 /* Q0, Number of consecutive bands for which the attenuation is maximum */ +#define ENV_ADJ_INV_INCL_FX (Word16) 6554 /* Q15, 1/5.0f, Inverse inclination for mapping between attenuation region width and attenuation limit */ + +#define INV_HVQ_THRES_BIN_24k 9362 /* 1/224 in Q21 */ +#define INV_HVQ_THRES_BIN_32k 6554 /* 1/320 in Q21 */ +#define INV_BANDS_PER_SUBFRAMES 14564 /* 1/9 in Q17 */ +#define NUM_SUBFRAMES 4 +#define BANDS_PER_SUBFRAMES 9 +#define ENERGY_TH_NUM_SUBFRAMES 1638400L /* 400 in Q12 */ +#define INV_SFM_N_ENV_STAB 19418 /* 1/27 in Q19 */ +#define ENERGY_TH_FX 819200L /* 100 in Q13 */ +#define ENERGY_LT_BETA_FX 30474 /* 0.93 in Q15 - Smoothing factor for long-term energy measure */ +#define ENERGY_LT_BETA_1_FX 2294 /* 0.07 i Q15 - (1 - ENERGY_LT_BETA_FX) */ +#define INV_DELTA_TH 13107 /* 1/5 in Q16 - Inverse Delta energy threshold for transient detection for envelope stability */ + +#define ONE_OVER_HVQ_BAND_MAX_BITS_24k_FX ((Word16) 410) /* Q15, 1/80 = 0.0125 */ +#define ONE_OVER_HVQ_BAND_MAX_BITS_32k_FX ((Word16) 345) /* Q15, 1/95 = 0.010526315 */ + +#define INV_PREECHO_SMOOTH_LENP1_FX 1560 /*(32768 / (PREECHO_SMOOTH_LEN + 1.0));*/ + +#define INV_HVQ_BW 1024 /* Q15 1/32 */ + +#define ACELP_48k_BITS 960 /* Q0 - ACELP_48k / 50 */ /*----------------------------------------------------------------------------------* * ISF quantizer constants *----------------------------------------------------------------------------------*/ - /*qlpc_avq, lsf_msvq_ma*/ -#define W_MODE0 0x1333 /*60.0f/FREQ_DIV in 0Q15*/ -#define W_MODE1 0x14CD /*65.0f/FREQ_DIV in 0Q15*/ -#define W_MODE2 0x147B /*64.0f/FREQ_DIV in 0Q15*/ -#define W_MODE_ELSE 0x1429 /*60.0f/FREQ_DIV in 0Q15*/ -/* qmc_cng_common.h */ -/* codec side */ -#define SCALE_TABLE_SHIFT_FACTOR (31-23) - -/* parameter_bitmapping.h */ -#define NPARAMS_MAX 10 + +#define W_MODE0 0x1333 /*60.0f/FREQ_DIV in 0Q15*/ +#define W_MODE1 0x14CD /*65.0f/FREQ_DIV in 0Q15*/ +#define W_MODE2 0x147B /*64.0f/FREQ_DIV in 0Q15*/ +#define W_MODE_ELSE 0x1429 /*60.0f/FREQ_DIV in 0Q15*/ +#define SCALE_TABLE_SHIFT_FACTOR (31-23) + +#define NPARAMS_MAX 10 /* Flags for CLDFB intialization */ /* Flag indicating that the states should be kept. */ -#define CLDFB_FLAG_KEEP_STATES 8 +#define CLDFB_FLAG_KEEP_STATES 8 /* Flag indicating 2.5 ms setup */ -#define CLDFB_FLAG_2_5MS_SETUP 128 +#define CLDFB_FLAG_2_5MS_SETUP 128 + typedef enum SIGNAL_CLASSIFER_MODE { CLASSIFIER_ACELP, CLASSIFIER_TCX } SIGNAL_CLASSIFIER_MODE; -#define CNT0P1 1717986918 /* 0.1*2^34 */ -#define CNT0P001 1099511627 /* 0.001*2^40 */ -#define CNT0P0001 1759218604 /* 0.0001*2^44 */ +#define CNT0P1 1717986918 /* 0.1*2^34 */ +#define CNT0P001 1099511627 /* 0.001*2^40 */ +#define CNT0P0001 1759218604 /* 0.0001*2^44 */ -#define CNT0P05 1717986918 /* 0.05*2^35 */ +#define CNT0P05 1717986918 /* 0.05*2^35 */ -#define CNT1DIV28 1227133513 /* (1/28)*2^35 */ -#define CNT1DIV14 1227133513 /* (1/14)*2^34 */ -#define CNT1DIV8 1073741824 /* (1/8)*2^33 */ +#define CNT1DIV28 1227133513 /* (1/28)*2^35 */ +#define CNT1DIV14 1227133513 /* (1/14)*2^34 */ +#define CNT1DIV8 1073741824 /* (1/8)*2^33 */ + +#define SP_CENTER_Q 10 +#define ITD_STABLE_RATE_Q 15 +#define SPEC_AMP_Q 14 +#define SFM_Q 15 +#define TONA_Q 14 +#define lt_bg_highf_eng_Q 16 -#define SP_CENTER_Q 10 -#define ITD_STABLE_RATE_Q 15 -#define SPEC_AMP_Q 14 -#define SFM_Q 15 -#define TONA_Q 14 -#define lt_bg_highf_eng_Q 16 /*----------------------------------------------------------------------------------* * TEC/TFA *----------------------------------------------------------------------------------*/ -#define DELAY_TEMP_ENV_BUFF_TEC 9 -#define EXT_DELAY_HI_TEMP_ENV 2 - - - /************************************************************************/ - /* CLDFB */ - /************************************************************************/ -#define SCALE_MODULATION ( 1 ) - -#define SCALE_GAIN_ANA_10 ( 4 ) -#define SCALE_GAIN_ANA_16 ( 3 ) -#define SCALE_GAIN_ANA_20 ( 3 ) -#define SCALE_GAIN_ANA_32 ( 2 ) -#define SCALE_GAIN_ANA_30 ( 2 ) -#define SCALE_GAIN_ANA_40 ( 2 ) -#define SCALE_GAIN_ANA_60 ( 1 ) - -#define SCALE_GAIN_SYN (-6 ) - -#define SCALE_CLDFB_ANA_10 ( SCALE_MODULATION + SCALE_GAIN_ANA_10 ) -#define SCALE_CLDFB_ANA_16 ( SCALE_MODULATION + SCALE_GAIN_ANA_16 ) -#define SCALE_CLDFB_ANA_20 ( SCALE_MODULATION + SCALE_GAIN_ANA_20 ) -#define SCALE_CLDFB_ANA_32 ( SCALE_MODULATION + SCALE_GAIN_ANA_32 ) -#define SCALE_CLDFB_ANA_40 ( SCALE_MODULATION + SCALE_GAIN_ANA_40 ) -#define SCALE_CLDFB_ANA_60 ( SCALE_MODULATION + SCALE_GAIN_ANA_60 ) -#define SCALE_CLDFB_ANA_30 ( SCALE_MODULATION + SCALE_GAIN_ANA_30 ) - -#define SCALE_CLDFB_SYN_10 ( SCALE_MODULATION + SCALE_GAIN_SYN ) -#define SCALE_CLDFB_SYN_16 ( SCALE_MODULATION + SCALE_GAIN_SYN ) -#define SCALE_CLDFB_SYN_20 ( SCALE_MODULATION + SCALE_GAIN_SYN ) -#define SCALE_CLDFB_SYN_32 ( SCALE_MODULATION + SCALE_GAIN_SYN ) -#define SCALE_CLDFB_SYN_40 ( SCALE_MODULATION + SCALE_GAIN_SYN ) -#define SCALE_CLDFB_SYN_60 ( SCALE_MODULATION + SCALE_GAIN_SYN ) -#define SCALE_CLDFB_SYN_30 ( SCALE_MODULATION + SCALE_GAIN_SYN ) - -/************************************************************************/ -/* FFT */ -/************************************************************************/ -#define SCALEFACTORN2 ( 3) -#define SCALEFACTOR2 ( 2) -#define SCALEFACTOR3 ( 3) -#define SCALEFACTOR4 ( 3) -#define SCALEFACTOR5 ( 4) -#define SCALEFACTOR8 ( 4) -#define SCALEFACTOR10 ( 5) -#define SCALEFACTOR12 ( 5) -#define SCALEFACTOR15 ( 5) -#define SCALEFACTOR16_5 ( 5) -#define SCALEFACTOR20_5 ( 5) -#define SCALEFACTOR24 ( 6) -#define SCALEFACTOR30 ( 6) -#define SCALEFACTOR30_1 ( 5) -#define SCALEFACTOR30_2 ( 1) -#define SCALEFACTOR32 ( 6) -#define SCALEFACTOR32_1 ( 5) -#define SCALEFACTOR32_2 ( 1) -#define SCALEFACTOR40 ( 7) -#define SCALEFACTOR60 ( 7) -#define SCALEFACTOR64 ( 7) -#define SCALEFACTOR80 ( 8) -#define SCALEFACTOR100 (10) -#define SCALEFACTOR120 ( 8) -#define SCALEFACTOR128 ( 8) -#define SCALEFACTOR160 ( 8) -#define SCALEFACTOR192 (10) -#define SCALEFACTOR200 (10) -#define SCALEFACTOR240 ( 9) -#define SCALEFACTOR256 ( 9) -#define SCALEFACTOR320 (10) -#define SCALEFACTOR400 (10) -#define SCALEFACTOR480 (11) -#define SCALEFACTOR600 (10) - -#define BASOP_CFFT_MAX_LENGTH 600 +#define DELAY_TEMP_ENV_BUFF_TEC 9 +#define EXT_DELAY_HI_TEMP_ENV 2 + + +/*----------------------------------------------------------------------------------* + * CLDFB + *----------------------------------------------------------------------------------*/ + +#define SCALE_MODULATION ( 1 ) + +#define SCALE_GAIN_ANA_10 ( 4 ) +#define SCALE_GAIN_ANA_16 ( 3 ) +#define SCALE_GAIN_ANA_20 ( 3 ) +#define SCALE_GAIN_ANA_32 ( 2 ) +#define SCALE_GAIN_ANA_30 ( 2 ) +#define SCALE_GAIN_ANA_40 ( 2 ) +#define SCALE_GAIN_ANA_60 ( 1 ) + +#define SCALE_GAIN_SYN (-6 ) + +#define SCALE_CLDFB_ANA_10 ( SCALE_MODULATION + SCALE_GAIN_ANA_10 ) +#define SCALE_CLDFB_ANA_16 ( SCALE_MODULATION + SCALE_GAIN_ANA_16 ) +#define SCALE_CLDFB_ANA_20 ( SCALE_MODULATION + SCALE_GAIN_ANA_20 ) +#define SCALE_CLDFB_ANA_32 ( SCALE_MODULATION + SCALE_GAIN_ANA_32 ) +#define SCALE_CLDFB_ANA_40 ( SCALE_MODULATION + SCALE_GAIN_ANA_40 ) +#define SCALE_CLDFB_ANA_60 ( SCALE_MODULATION + SCALE_GAIN_ANA_60 ) +#define SCALE_CLDFB_ANA_30 ( SCALE_MODULATION + SCALE_GAIN_ANA_30 ) + +#define SCALE_CLDFB_SYN_10 ( SCALE_MODULATION + SCALE_GAIN_SYN ) +#define SCALE_CLDFB_SYN_16 ( SCALE_MODULATION + SCALE_GAIN_SYN ) +#define SCALE_CLDFB_SYN_20 ( SCALE_MODULATION + SCALE_GAIN_SYN ) +#define SCALE_CLDFB_SYN_32 ( SCALE_MODULATION + SCALE_GAIN_SYN ) +#define SCALE_CLDFB_SYN_40 ( SCALE_MODULATION + SCALE_GAIN_SYN ) +#define SCALE_CLDFB_SYN_60 ( SCALE_MODULATION + SCALE_GAIN_SYN ) +#define SCALE_CLDFB_SYN_30 ( SCALE_MODULATION + SCALE_GAIN_SYN ) + + +/*----------------------------------------------------------------------------------* + * FFT + *----------------------------------------------------------------------------------*/ + +#define SCALEFACTORN2 ( 3) +#define SCALEFACTOR2 ( 2) +#define SCALEFACTOR3 ( 3) +#define SCALEFACTOR4 ( 3) +#define SCALEFACTOR5 ( 4) +#define SCALEFACTOR8 ( 4) +#define SCALEFACTOR10 ( 5) +#define SCALEFACTOR12 ( 5) +#define SCALEFACTOR15 ( 5) +#define SCALEFACTOR16_5 ( 5) +#define SCALEFACTOR20_5 ( 5) +#define SCALEFACTOR24 ( 6) +#define SCALEFACTOR30 ( 6) +#define SCALEFACTOR30_1 ( 5) +#define SCALEFACTOR30_2 ( 1) +#define SCALEFACTOR32 ( 6) +#define SCALEFACTOR32_1 ( 5) +#define SCALEFACTOR32_2 ( 1) +#define SCALEFACTOR40 ( 7) +#define SCALEFACTOR60 ( 7) +#define SCALEFACTOR64 ( 7) +#define SCALEFACTOR80 ( 8) +#define SCALEFACTOR100 (10) +#define SCALEFACTOR120 ( 8) +#define SCALEFACTOR128 ( 8) +#define SCALEFACTOR160 ( 8) +#define SCALEFACTOR192 (10) +#define SCALEFACTOR200 (10) +#define SCALEFACTOR240 ( 9) +#define SCALEFACTOR256 ( 9) +#define SCALEFACTOR320 (10) +#define SCALEFACTOR400 (10) +#define SCALEFACTOR480 (11) +#define SCALEFACTOR600 (10) + +#define BASOP_CFFT_MAX_LENGTH 600 /*----------------------------------------------------------------------------------* * BASOP ROM Tables *----------------------------------------------------------------------------------*/ -#define LD_INT_TAB_LEN 120 -#define INV_TABLE_SIZE 256 -#define SQRT_TABLE_SIZE 256 +#define INV_TABLE_SIZE 256 +#define SQRT_TABLE_SIZE 256 /*----------------------------------------------------------------------------------* @@ -3053,67 +2716,36 @@ enum VOIP_RTPDUMP }; -//EVS macros -#define LT_UV_THR_FX (100*64) /* in Q6 */ -#define INV_MAX_LT_FX (Word16)((1.0f/MAX_LT)*32768) -#define EVS_PI 3.14159265358979323846264338327950288f -#define EVS_PI_FX 25736 /* pi in Q13 */ -#define EVS_2PI_FX 51472 /* 2 * pi in Q13 */ -#define EVS_PI_FX_Q27 421657428 /* pi in Q28 */ -#define EVS_2PI_FX_Q27 843314856 /* 2 * pi in Q28 */ -#define EVS_PI_BY_2_FX (Word16)(0x3244) // Q13 -//#define EVS_PI_FX (Word16)(0x6488) -#define EVS_PI_FX16 (Word16)(0x6488) -#define PI2_FX 1686629713 //Q28 +/*----------------------------------------------------------------------------------* + * EVS macros + *----------------------------------------------------------------------------------*/ -#define LG10 24660 /* 10*log10(2) in Q13 */ +#define LT_UV_THR_FX (100*64) /* in Q6 */ +#define INV_MAX_LT_FX (Word16)((1.0f/MAX_LT)*32768) +#define LG10 24660 /* 10*log10(2) in Q13 */ -#define EVS_LW_MIN (Word32)0x80000000 -#define EVS_LW_MAX (Word32)0x7fffffff +#define EVS_LW_MIN (Word32)0x80000000 +#define EVS_LW_MAX (Word32)0x7fffffff -#define EVS_SW_MAX (Word16)0x7fff /* largest Ram */ +#define EVS_SW_MAX (Word16)0x7fff /* largest Ram */ -#define SYNC_GOOD_FRAME (UWord16) 0x6B21 /* synchronization word of a "good" frame */ -#define SYNC_BAD_FRAME (UWord16) 0x6B20 /* synchronization word of a "bad" frame */ -#define G192_BIN0 (UWord16) 0x007F /* binary "0" according to ITU-T G.192 */ -#define G192_BIN1 (UWord16) 0x0081 /* binary "1" according to ITU-T G.192 */ -#define DEGREE_180 (Word32)(180.0 *ONE_IN_Q22) -#define DEGREE_360 (Word32)(360.0 *ONE_IN_Q22) extern const Word16 Idx2Freq_Tbl[]; - #define chk_fs(fs) /* 'x' is converted to Q6, 'Freq_Tbl'/1000 in Q9 */ /* only works for 'fs' = [8000,12800,16000,25600,32000,48000] (unpredictable otherwise) */ /* 15625 is 1000000.0f/Q6 but we use the calculated value to avoid float point code */ -#define NS2SA_FX2(fs,x) (chk_fs(fs) mult((&Idx2Freq_Tbl[-2])[L_and(L_shr(fs,8),7)], (Word16)((x)/15625))) - -#define L_FRAME_12k8 256 /* Frame size at 12k8Hz: 20ms = 256 samples */ -#define L_FRAME_16k 320 /* Frame size at 16kHz: 20ms = 320 samples */ -#define L_NEXT_MAX_12k8 112 /* maximum encoder lookahead at 12k8Hz */ -#define L_PAST_MAX_12k8 144 /* maximum encoder past samples at 12k8Hz */ -#define L_DIV 256 /* 20ms frame size (ACELP or short TCX frame) */ -#define L_DIV_MAX 320 - +#define NS2SA_FX2(fs,x) (chk_fs(fs) mult((&Idx2Freq_Tbl[-2])[L_and(L_shr(fs,8),7)], (Word16)((x)/15625))) -//tbs_vase.c -#define PRED_GAIN_E 8 +#define L_FRAME_12k8 256 /* Frame size at 12k8Hz: 20ms = 256 samples */ +#define L_FRAME_16k 320 /* Frame size at 16kHz: 20ms = 320 samples */ +#define L_NEXT_MAX_12k8 112 /* maximum encoder lookahead at 12k8Hz */ +#define L_PAST_MAX_12k8 144 /* maximum encoder past samples at 12k8Hz */ +#define L_DIV 256 /* 20ms frame size (ACELP or short TCX frame) */ +#define L_DIV_MAX 320 -#define FS_48K_IN_NS_Q31 103079 -#define FS_32K_IN_NS_Q31 68719 -#define FS_16K_IN_NS_Q31 34360 +#define PRED_GAIN_E 8 -#define ONE_BY_THREE_Q15 10923 /* 1/3.f in Q15 */ -#define ONE_BY_TEN_Q15 3277 /* 1/10.f in Q15 */ -#define THREE_Q21 6291456 -#define SIX_Q21 12582912 - -typedef enum -{ - MCT_CHAN_MODE_REGULAR, - MCT_CHAN_MODE_LFE, - MCT_CHAN_MODE_IGNORE -} MCT_CHAN_MODE; /* clang-format on */ #endif /* CNST_H */ diff --git a/lib_com/ivas_agc_com_fx.c b/lib_com/ivas_agc_com_fx.c index 3f6e181ef..567adeb6b 100644 --- a/lib_com/ivas_agc_com_fx.c +++ b/lib_com/ivas_agc_com_fx.c @@ -32,13 +32,13 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" #include "ivas_prot_fx.h" -#include #include "wmc_auto.h" #include "prot_fx.h" #include "rom_com.h" + + /*------------------------------------------------------------------------------------------* * Local constants *------------------------------------------------------------------------------------------*/ diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index b8415b7fd..64225a0f6 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -204,8 +204,6 @@ typedef enum #define EDIT_GAIN_MAX_Q12 16306 /* Maximum allowed object gain edit in Q12: 3.9810719f, +12 dB */ #endif - - typedef enum { TC_BUFFER_MODE_RENDERER, @@ -646,9 +644,6 @@ typedef enum #define SBA_DIRAC_NRG_SMOOTH_LONG 10 #define SBA_DIRAC_NRG_SMOOTH_SHORT 3 -#define SBA_DIRAC_NRG_SMOOTH_SHORT_BY_LONG_FX ((Word16)0x2667) -#define SBA_DIRAC_NRG_SMOOTH_LONG_BY_LONG_SHORT_FX ((Word32)0x5B6DB6DB) - /* PLC for DFT Stereo residual */ #define STEREO_DFT_RES_N_PEAKS_MAX 15 /*Maximum number of peaks within residual signal in each frame (res_cod_band_max == 6 in 48kHz)*/ @@ -819,7 +814,6 @@ enum fea_names #define STEREO_BITS_ICBWE_DFT ( STEREO_ICBWE_SPBITS_DFT + STEREO_ICBWE_GSBITS_DFT + STEREO_ICBWE_REFBITS ) #define MAX_DELAYREGLEN 12 /* max regression length */ -#define INV_MAX_DELAYREGLEN 0.083333333333333f /* (1/MAX_DELAYREGLEN) */ #define INV_MAX_DELAYREGLEN_FX_Q15 2731 /* (1/MAX_DELAYREGLEN) in Q15 */ #define MAX_INTERPOLATE 11 #define ADDED_MEM_DS 40 @@ -1269,7 +1263,7 @@ enum #define MASA_BIT_REDUCT_PARAM 10 #define MASA_MAXIMUM_TWO_DIR_BANDS 24 #define NBITS_HR_COH 4 -#define OMASA_TDREND_MATCHING_GAIN_FX 26026 +#define OMASA_TDREND_MATCHING_GAIN_FX 26026 #define OMASA_GAIN_EDIT_THR_Q12 246 /* OMASA gain change threshold, 0.06f in Q12 */ #define OMASA_AZI_EDIT_THR_Q22 ONE_IN_Q22 /* OMASA-DISC azimuth change threshold, 1.0f in Q22 */ @@ -1278,8 +1272,7 @@ enum #define MASA_INV_ANGLE_AT_EQUATOR_DEG_Q30 1453366656l /* 1.353553128183453f in Q30 */ #define MASA_JBM_RINGBUFFER_FRAMES 3 -#define TOLERANCE_360_Q22 1510033326 /* 360 in Q22 + 0.02 in Q22*/ -#define MINUS_TOLERANCE_360_Q22 -1510033326 /* - (360 in Q22 + 0.02 in Q22) */ + typedef enum { MASA_STEREO_NOT_DEFINED, @@ -1366,6 +1359,13 @@ typedef enum #define MCT_NUM_BLOCK_DATA_BITS 4 +typedef enum +{ + MCT_CHAN_MODE_REGULAR, + MCT_CHAN_MODE_LFE, + MCT_CHAN_MODE_IGNORE +} MCT_CHAN_MODE; + /*----------------------------------------------------------------------------------* * MC Param-Upmix Mode Constants @@ -1543,6 +1543,10 @@ typedef enum #define VBAP_NUM_SEARCH_SECTORS 4 +#define DEGREE_90_Q_22 377487360 +#define DEGREE_180_Q_22 754974720 +#define DEGREE_360_Q_22 1509949440 + /*----------------------------------------------------------------------------------* * Binaural Rendering Constants @@ -1600,8 +1604,8 @@ typedef enum #define ONE_BY_360_Q15 ( 91 ) /* Q15 */ #define ONE_BY_180_Q31 ( 11930465 ) /* Q31 */ -#define RESAMPLE_FACTOR_16_48_FX ( 5461 ) // Q14 -#define RESAMPLE_FACTOR_32_48_FX ( 10922 ) // Q14 +#define RESAMPLE_FACTOR_16_48_FX ( 5461 ) // Q14 +#define RESAMPLE_FACTOR_32_48_FX ( 10922 ) // Q14 /* ----- Enums - TD Renderer ----- */ @@ -1852,6 +1856,112 @@ typedef enum } STEREO_DMX_EVS_PRC; + +/*----------------------------------------------------------------------------------* + * Q values + *----------------------------------------------------------------------------------*/ + +#define Q1 1 +#define Q2 2 +#define Q3 3 +#define Q4 4 +#define Q5 5 +#define Q6 6 +#define Q7 7 +#define Q8 8 +#define Q9 9 +#define Q10 10 +#define Q11 11 +#define Q12 12 +#define Q13 13 +#define Q14 14 +#define Q15 15 +#define Q16 16 +#define Q17 17 +#define Q18 18 +#define Q19 19 +#define Q20 20 +#define Q21 21 +#define Q22 22 +#define Q23 23 +#define Q24 24 +#define Q25 25 +#define Q26 26 +#define Q27 27 +#define Q28 28 +#define Q29 29 +#define Q30 30 +#define Q31 31 + +/*----------------------------------------------------------------------------------* + * One (1) in Q + *----------------------------------------------------------------------------------*/ + +#define ONE_IN_Q1 2 +#define ONE_IN_Q2 4 +#define ONE_IN_Q3 8 +#define ONE_IN_Q4 16 +#define ONE_IN_Q5 32 +#define ONE_IN_Q6 64 +#define ONE_IN_Q7 128 +#define ONE_IN_Q8 256 +#define ONE_IN_Q9 512 +#define ONE_IN_Q10 1024 +#define ONE_IN_Q11 2048 +#define ONE_IN_Q12 4096 +#define ONE_IN_Q13 8192 +#define ONE_IN_Q14 16384 +#define ONE_IN_Q15 32768 +#define ONE_IN_Q16 65536 +#define ONE_IN_Q17 131072 +#define ONE_IN_Q18 262144 +#define ONE_IN_Q19 524288 +#define ONE_IN_Q20 1048576 +#define ONE_IN_Q21 2097152 +#define ONE_IN_Q22 4194304 +#define ONE_IN_Q23 8388608 +#define ONE_IN_Q24 16777216 +#define ONE_IN_Q25 33554432 +#define ONE_IN_Q26 67108864 +#define ONE_IN_Q27 134217728 +#define ONE_IN_Q28 268435456 +#define ONE_IN_Q29 536870912 +#define ONE_IN_Q30 1073741824 +#define ONE_IN_Q31 0x7fffffff +#define ONE_IN_Q45 (Word64)0x200000000000 +#define ONE_IN_Q62 (Word64)0x4000000000000000 + +#define MAX_WORD16 32767 + +/*----------------------------------------------------------------------------------* + * General constants + *----------------------------------------------------------------------------------*/ + +#define L_SUBFRAME_48k 240 +#define L_SUBFRAME_32k 160 +#define L_SUBFRAME_16k 80 +#define L_SUBFRAME_8k 40 + +#define Q31_BY_SUB_FRAME_240 8985287 /* 1/239 in Q31 */ +#define Q31_BY_SUB_FRAME_160 13506186 /* 1/159 in Q31 */ +#define Q31_BY_SUB_FRAME_80 27183337 /* 1/79 in Q31 */ +#define Q31_BY_SUB_FRAME_40 55063683 /* 1/39 in Q31 */ + +#define EVS_PI_FX 25736 /* pi in Q13 */ +#define EVS_2PI_FX 51472 /* 2 * pi in Q13 */ +#define EVS_PI_FX_Q27 421657428 /* pi in Q28 */ +#define EVS_2PI_FX_Q27 843314856 /* 2 * pi in Q28 */ +#define EVS_PI_BY_2_FX (Word16)(0x3244)/* Q13 */ + + +#define FS_48K_IN_NS_Q31 103079 +#define FS_32K_IN_NS_Q31 68719 +#define FS_16K_IN_NS_Q31 34360 + +#define ONE_BY_THREE_Q15 10923 /* 1/3.f in Q15 */ +#define ONE_BY_TEN_Q15 3277 /* 1/10.f in Q15 */ +#define THREE_Q21 6291456 + #endif /* clang-format on */ /* IVAS_CNST_H */ diff --git a/lib_com/ivas_cov_smooth_fx.c b/lib_com/ivas_cov_smooth_fx.c index 9a8de3c1f..422717f8e 100644 --- a/lib_com/ivas_cov_smooth_fx.c +++ b/lib_com/ivas_cov_smooth_fx.c @@ -32,7 +32,7 @@ #include #include "options.h" -#include "cnst.h" +#include "ivas_cnst.h" #include "wmc_auto.h" #include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_dirac_com_fx.c b/lib_com/ivas_dirac_com_fx.c index cba992070..35a2cd4aa 100644 --- a/lib_com/ivas_dirac_com_fx.c +++ b/lib_com/ivas_dirac_com_fx.c @@ -33,11 +33,9 @@ #include #include #include "options.h" -#include #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "prot_fx.h" -#include "cnst.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_entropy_coder_common_fx.c b/lib_com/ivas_entropy_coder_common_fx.c index f52d59859..7519e9703 100644 --- a/lib_com/ivas_entropy_coder_common_fx.c +++ b/lib_com/ivas_entropy_coder_common_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include "ivas_rom_com.h" -#include "math.h" #include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_fb_mixer_fx.c b/lib_com/ivas_fb_mixer_fx.c index c860b354e..2dcd8476b 100644 --- a/lib_com/ivas_fb_mixer_fx.c +++ b/lib_com/ivas_fb_mixer_fx.c @@ -32,10 +32,8 @@ #include #include -#include #include "options.h" #include "prot_fx.h" -#include "rom_com.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_ism_com_fx.c b/lib_com/ivas_ism_com_fx.c index ea276c944..10c1f04b2 100644 --- a/lib_com/ivas_ism_com_fx.c +++ b/lib_com/ivas_ism_com_fx.c @@ -32,9 +32,7 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_stat_com.h" #include "ivas_rom_com.h" diff --git a/lib_com/ivas_lfe_com_fx.c b/lib_com/ivas_lfe_com_fx.c index d515cc5fb..03b92a10f 100644 --- a/lib_com/ivas_lfe_com_fx.c +++ b/lib_com/ivas_lfe_com_fx.c @@ -31,13 +31,11 @@ *******************************************************************************************************/ #include -#include "math.h" #include "options.h" #include "ivas_stat_com.h" #include "prot_fx.h" -#include "rom_com.h" #include "ivas_rom_com.h" -#include "cnst.h" +#include "ivas_cnst.h" #include #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_limiter_fx.c b/lib_com/ivas_limiter_fx.c index a293b629c..fdd1bb97c 100644 --- a/lib_com/ivas_limiter_fx.c +++ b/lib_com/ivas_limiter_fx.c @@ -32,15 +32,17 @@ #include #include "options.h" -#include #include "prot_fx.h" -#include "ivas_prot_rend_fx.h" -#include "ivas_rom_rend.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include #include "ivas_prot_fx.h" + +/*-----------------------------------------------------------------------* + * Local constants + *-----------------------------------------------------------------------*/ + #define RELEASE_CNST_20MS ( 85899345 ) // Q30 #define RELEASE_CNST_2_20MS ( 21474836 ) // Q30 #define RELEASE_CNST_10MS ( 42949672 ) // Q30 @@ -52,6 +54,7 @@ #define ATTACK_CNST_16k ( 2027355264 ) // Q31 #define ATTACK_CNST_8k ( 1913946752 ) // Q31 + /*-------------------------------------------------------------------* * detect_strong_saturations() * diff --git a/lib_com/ivas_masa_com_fx.c b/lib_com/ivas_masa_com_fx.c index 9c706bc74..f55e99153 100644 --- a/lib_com/ivas_masa_com_fx.c +++ b/lib_com/ivas_masa_com_fx.c @@ -33,7 +33,6 @@ #include #include #include "options.h" -#include #include "prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_com/ivas_mc_com_fx.c b/lib_com/ivas_mc_com_fx.c index 8201037a1..c04ded09c 100644 --- a/lib_com/ivas_mc_com_fx.c +++ b/lib_com/ivas_mc_com_fx.c @@ -33,7 +33,6 @@ #include #include #include "options.h" -#include #include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_mc_param_com_fx.c b/lib_com/ivas_mc_param_com_fx.c index e3827c568..7cb186b58 100644 --- a/lib_com/ivas_mc_param_com_fx.c +++ b/lib_com/ivas_mc_param_com_fx.c @@ -32,7 +32,6 @@ #include #include -#include #include "options.h" #include "ivas_cnst.h" #include "prot_fx.h" diff --git a/lib_com/ivas_mdft_imdft_fx.c b/lib_com/ivas_mdft_imdft_fx.c index 1d07ab133..d80d8a156 100644 --- a/lib_com/ivas_mdft_imdft_fx.c +++ b/lib_com/ivas_mdft_imdft_fx.c @@ -29,19 +29,20 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ -#include +#include #include #include "options.h" #include "prot_fx.h" #include "ivas_rom_com.h" #include #include "wmc_auto.h" -#include -#include +#ifdef DEBUGGING #include "debug.h" +#endif #include "ivas_prot_fx.h" + /*-----------------------------------------------------------------------------------------* * Local constants *-----------------------------------------------------------------------------------------*/ @@ -52,6 +53,7 @@ #define IVAS_ONE_BY_240_Q37 572662306 #define IVAS_ONE_BY_160_Q37 858993459 #define IVAS_ONE_BY_80_Q37 1717986918 + /*-----------------------------------------------------------------------------------------* * Function ivas_get_mdft_twid_factors() * diff --git a/lib_com/ivas_omasa_com_fx.c b/lib_com/ivas_omasa_com_fx.c index 1c1d4bf6c..7bbf287ac 100644 --- a/lib_com/ivas_omasa_com_fx.c +++ b/lib_com/ivas_omasa_com_fx.c @@ -37,7 +37,7 @@ #include "prot_fx.h" #include "ivas_rom_com.h" #include "rom_com.h" -#include + /*--------------------------------------------------------------- * Local constants diff --git a/lib_com/ivas_osba_com_fx.c b/lib_com/ivas_osba_com_fx.c index 79ce8443a..2f81a9574 100644 --- a/lib_com/ivas_osba_com_fx.c +++ b/lib_com/ivas_osba_com_fx.c @@ -33,8 +33,6 @@ #include "options.h" #include "ivas_cnst.h" #include "ivas_prot_fx.h" -#include "prot_fx.h" -#include "ivas_rom_com.h" #ifdef DEBUGGING #include "debug.h" #endif diff --git a/lib_com/ivas_qmetadata_com_fx.c b/lib_com/ivas_qmetadata_com_fx.c index 906277f54..f1a0a7609 100644 --- a/lib_com/ivas_qmetadata_com_fx.c +++ b/lib_com/ivas_qmetadata_com_fx.c @@ -32,12 +32,10 @@ #include #include -#include #include "options.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "prot_fx.h" -#include "cnst.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_qspherical_com_fx.c b/lib_com/ivas_qspherical_com_fx.c index 7d7c159b3..6a965850e 100644 --- a/lib_com/ivas_qspherical_com_fx.c +++ b/lib_com/ivas_qspherical_com_fx.c @@ -33,11 +33,9 @@ #include #include #include "options.h" -#include #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "prot_fx.h" -#include "cnst.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index 9773d0715..56dbeb50b 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -35,7 +35,6 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" #include "stat_com.h" #include "ivas_stat_com.h" diff --git a/lib_com/ivas_rom_com_fx.c b/lib_com/ivas_rom_com_fx.c index a5af89655..1d19e657a 100644 --- a/lib_com/ivas_rom_com_fx.c +++ b/lib_com/ivas_rom_com_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include -#include "cnst.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_com/ivas_rotation_com_fx.c b/lib_com/ivas_rotation_com_fx.c index d399c6a66..199af90d3 100644 --- a/lib_com/ivas_rotation_com_fx.c +++ b/lib_com/ivas_rotation_com_fx.c @@ -34,8 +34,6 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #ifdef DEBUGGING @@ -46,11 +44,19 @@ #include "enh64.h" +/*-------------------------------------------------------------------* + * Local constants + *-------------------------------------------------------------------*/ + +#define DEGREE_180 ( Word32 )( 180.0 * ONE_IN_Q22 ) +#define DEGREE_360 ( Word32 )( 360.0 * ONE_IN_Q22 ) + /*------------------------------------------------------------------------- * Euler2Quat() * * Calculate corresponding Quaternion from Euler angles in radians *------------------------------------------------------------------------*/ + void Euler2Quat_fx( const Word32 yaw, /* i : yaw (x) Q22 */ const Word32 pitch, /* i : pitch (y) Q22 */ diff --git a/lib_com/ivas_sba_config_fx.c b/lib_com/ivas_sba_config_fx.c index 4caa22da2..7e1fac44b 100644 --- a/lib_com/ivas_sba_config_fx.c +++ b/lib_com/ivas_sba_config_fx.c @@ -32,11 +32,8 @@ #include #include -#include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_stat_com.h" #include "ivas_rom_com.h" diff --git a/lib_com/ivas_sns_com_fx.c b/lib_com/ivas_sns_com_fx.c index 48be0cfd0..57c4cd66e 100644 --- a/lib_com/ivas_sns_com_fx.c +++ b/lib_com/ivas_sns_com_fx.c @@ -32,15 +32,15 @@ #include #include "options.h" -#include "cnst.h" +#include "ivas_cnst.h" #include "prot_fx.h" #include "rom_com.h" #include "ivas_rom_com.h" -#include #include #include "wmc_auto.h" #include "ivas_prot_fx.h" + /*------------------------------------------------------------------- * sns_compute_scf_fx() * diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c index afb639ef0..4b70d277a 100644 --- a/lib_com/ivas_spar_com_fx.c +++ b/lib_com/ivas_spar_com_fx.c @@ -31,14 +31,12 @@ *******************************************************************************************************/ #include -#include "math.h" #include "options.h" #include "basop_util.h" #include "ivas_stat_com.h" #include "prot_fx.h" -#include "rom_com.h" #include "ivas_rom_com.h" -#include "cnst.h" +#include "ivas_cnst.h" #include #include "wmc_auto.h" #include "basop_util.h" diff --git a/lib_com/ivas_spar_com_quant_util_fx.c b/lib_com/ivas_spar_com_quant_util_fx.c index 8e84e4e37..7ea6feb05 100644 --- a/lib_com/ivas_spar_com_quant_util_fx.c +++ b/lib_com/ivas_spar_com_quant_util_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "math.h" #include "prot_fx.h" #include "ivas_rom_com.h" #include diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 65a081c9c..9bee290e6 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -36,7 +36,6 @@ #include #include "options.h" #include "typedef.h" -#include "cnst.h" #include "ivas_cnst.h" diff --git a/lib_com/ivas_stereo_dft_com_fx.c b/lib_com/ivas_stereo_dft_com_fx.c index 6d63bc6d1..a23b5b700 100644 --- a/lib_com/ivas_stereo_dft_com_fx.c +++ b/lib_com/ivas_stereo_dft_com_fx.c @@ -36,7 +36,6 @@ #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "prot_fx.h" -#include "cnst.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_com/ivas_stereo_eclvq_com_fx.c b/lib_com/ivas_stereo_eclvq_com_fx.c index 958781473..8328e220f 100644 --- a/lib_com/ivas_stereo_eclvq_com_fx.c +++ b/lib_com/ivas_stereo_eclvq_com_fx.c @@ -32,13 +32,13 @@ #include #include "options.h" -#include #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include #include "prot_fx.h" #include "wmc_auto.h" + /*--------------------------------------------------------------- * ECSQ_init_instance_fx() * diff --git a/lib_com/ivas_stereo_ica_com_fx.c b/lib_com/ivas_stereo_ica_com_fx.c index 11f16d0a5..8b5e15908 100644 --- a/lib_com/ivas_stereo_ica_com_fx.c +++ b/lib_com/ivas_stereo_ica_com_fx.c @@ -32,16 +32,14 @@ #include #include -#include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" #include "wmc_auto.h" -#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_prot_fx.h" + /*--------------------------------------------------------------- * interpTargetChannel_fx() * diff --git a/lib_com/ivas_stereo_td_bit_alloc_fx.c b/lib_com/ivas_stereo_td_bit_alloc_fx.c index fe18e7bad..52933a593 100644 --- a/lib_com/ivas_stereo_td_bit_alloc_fx.c +++ b/lib_com/ivas_stereo_td_bit_alloc_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "cnst.h" #include "stat_enc.h" #include "rom_com.h" #include "ivas_rom_com.h" diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index bc080f2f8..8cf54ec92 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -33,12 +33,16 @@ #include #include #include "options.h" -#include #include "prot_fx.h" #include "wmc_auto.h" #include "ivas_rom_com.h" #include "ivas_prot_fx.h" + +/*-----------------------------------------------------------------------* + * Local constants + *-----------------------------------------------------------------------*/ + #define ANGLE_90_DEG_Q22 377487360 #define ANGLE_180_DEG_Q22 754974720 #define ANGLE_360_DEG_Q22 1509949440 diff --git a/lib_com/ivas_transient_det_fx.c b/lib_com/ivas_transient_det_fx.c index 39dee9314..f7613a023 100644 --- a/lib_com/ivas_transient_det_fx.c +++ b/lib_com/ivas_transient_det_fx.c @@ -32,13 +32,13 @@ #include #include "options.h" -#include "math.h" #include "wmc_auto.h" #include "prot_fx.h" #include "ivas_cnst.h" #include "ivas_prot_fx.h" #include "ivas_stat_com.h" + /*------------------------------------------------------------------------------------------* * Local constants *------------------------------------------------------------------------------------------*/ diff --git a/lib_debug/debug.h b/lib_debug/debug.h index c79ff6046..f1a40606b 100644 --- a/lib_debug/debug.h +++ b/lib_debug/debug.h @@ -70,6 +70,9 @@ char *fname( char *dir, char *file, const int16_t n, const int16_t id, const int #define FORCE_DIR_MAX_LENGTH 255 /* maximum length of the directory for modes/parameters enforcement */ #endif +#define MAX16B_FLT 32767.0f +#define MIN16B_FLT ( -32768.0f ) + /*------------------------------------------------------------------------------------------* * Read/write I/O tool *------------------------------------------------------------------------------------------*/ diff --git a/lib_debug/sba_debug.c b/lib_debug/sba_debug.c index c05ae96ef..18892a0d5 100644 --- a/lib_debug/sba_debug.c +++ b/lib_debug/sba_debug.c @@ -38,6 +38,7 @@ #include "options.h" #include "ivas_cnst.h" #include "sba_debug.h" +#include "debug.h" #include #include "wmc_auto.h" #ifdef DEBUG_SBA diff --git a/lib_dec/ivas_agc_dec_fx.c b/lib_dec/ivas_agc_dec_fx.c index a196a1abd..eb6f6693f 100644 --- a/lib_dec/ivas_agc_dec_fx.c +++ b/lib_dec/ivas_agc_dec_fx.c @@ -31,12 +31,10 @@ *******************************************************************************************************/ #include -#include #include #include "options.h" #include "prot_fx.h" #include "ivas_prot_fx.h" -#include "rom_com.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_binRenderer_internal_fx.c b/lib_dec/ivas_binRenderer_internal_fx.c index 5d4a6d964..0fbaea450 100644 --- a/lib_dec/ivas_binRenderer_internal_fx.c +++ b/lib_dec/ivas_binRenderer_internal_fx.c @@ -32,10 +32,8 @@ #include #include "options.h" -#include #include "prot_fx.h" #include "ivas_prot_rend_fx.h" -#include "cnst.h" #include "ivas_cnst.h" #include "ivas_rom_rend.h" #include "ivas_rom_dec.h" @@ -43,7 +41,9 @@ #include "ivas_rom_binauralRenderer.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" +#ifdef DEBUGGING #include "debug.h" +#endif /*----------------------------------------------------------------------------------* diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 23f75172a..81740977f 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -33,8 +33,7 @@ #include #include "options.h" #include -#include -#include "cnst.h" +#include "ivas_cnst.h" #include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index 7a134d59b..8e94de138 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -33,14 +33,11 @@ #include #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "wmc_auto.h" -#include /*--------------------------------------------------------------------------* diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 11d80c14f..f2ce9dd3c 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -33,8 +33,6 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" diff --git a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c index c53f66138..7d389ec0f 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov_fx.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov_fx.c @@ -37,18 +37,13 @@ #include #include #include -#include #include "options.h" -#include "cnst.h" -#include "rom_enc.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" #include "wmc_auto.h" -#include "rom_dec.h" #include "ivas_prot_fx.h" /*-----------------------------------------------------------------------* diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index b6e7a558e..0713bd8f1 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -31,12 +31,10 @@ *******************************************************************************************************/ #include -#include #include #include "options.h" #include "ivas_cnst.h" #include "ivas_prot_rend_fx.h" -#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_stat_enc.h" #include "prot_fx.h" @@ -112,7 +110,7 @@ ivas_error ivas_dec_get_format_fx( Word16 sba_order, sba_planar, sba_analysis_order; Word32 ivas_total_brate; #ifdef DECODER_FORMAT_SWITCHING - int16_t Opt_tsm; + Word16 Opt_tsm; #endif UWord16 *bit_stream_orig; diff --git a/lib_dec/ivas_ism_dtx_dec_fx.c b/lib_dec/ivas_ism_dtx_dec_fx.c index 19d99a0bb..162cc42ed 100644 --- a/lib_dec/ivas_ism_dtx_dec_fx.c +++ b/lib_dec/ivas_ism_dtx_dec_fx.c @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include -#include #include "options.h" #include "ivas_prot_fx.h" #include "prot_fx.h" diff --git a/lib_dec/ivas_ism_metadata_dec_fx.c b/lib_dec/ivas_ism_metadata_dec_fx.c index 54cc5da15..3ca9f4aac 100644 --- a/lib_dec/ivas_ism_metadata_dec_fx.c +++ b/lib_dec/ivas_ism_metadata_dec_fx.c @@ -30,7 +30,6 @@ *******************************************************************************************************/ -#include "move.h" #include #include "options.h" #include "ivas_cnst.h" @@ -38,7 +37,6 @@ #include "ivas_rom_com.h" #include "prot_fx.h" #include "ivas_stat_enc.h" -#include #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 6af94ea97..e8398c83e 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -32,16 +32,15 @@ #include #include -#include #include "options.h" #include "ivas_prot_rend_fx.h" #include "prot_fx.h" -#include "rom_com.h" #include "ivas_rom_com.h" -#include "ivas_rom_dec.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" +#ifdef DEBUGGING #include "debug.h" +#endif /*-----------------------------------------------------------------------* diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index 2e2a257a1..beee3ee1a 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -38,9 +38,7 @@ #include "ivas_prot_rend_fx.h" #include "ivas_stat_com.h" #include "ivas_rom_com.h" -#include "rom_com.h" #include "ivas_rom_dec.h" -#include #include "wmc_auto.h" diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index f8664b60b..2aa202738 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -32,16 +32,12 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_rom_com.h" -#include #include "wmc_auto.h" -#include "ivas_prot_fx.h" #ifdef DEBUGGING #include "debug.h" #endif diff --git a/lib_dec/ivas_lfe_dec_fx.c b/lib_dec/ivas_lfe_dec_fx.c index 74d8de662..a4ead6946 100644 --- a/lib_dec/ivas_lfe_dec_fx.c +++ b/lib_dec/ivas_lfe_dec_fx.c @@ -36,7 +36,6 @@ #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "rom_com.h" -#include "math.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_lfe_plc_fx.c b/lib_dec/ivas_lfe_plc_fx.c index ac6da6759..b50fe2120 100755 --- a/lib_dec/ivas_lfe_plc_fx.c +++ b/lib_dec/ivas_lfe_plc_fx.c @@ -34,7 +34,6 @@ #include "options.h" #include "prot_fx.h" #include "ivas_rom_com.h" -#include #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index b41036a5d..fd9eda8fb 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -31,12 +31,10 @@ *******************************************************************************************************/ #include -#include #include #include "options.h" #include "ivas_cnst.h" #include "ivas_prot_rend_fx.h" -#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_stat_dec.h" #include "prot_fx.h" @@ -51,6 +49,9 @@ #define SPAR_META_DELAY_SUBFRAMES 2 /* Number of subframes to delay the SPAR metadata */ #define SPH_IDX_FRONT ( MASA_NO_POINTS_EQUATOR / 2 ) /* Spherical index corresponding to front direction for setting as default value */ +#define TOLERANCE_360_Q22 1510033326 /* 360 in Q22 + 0.02 in Q22*/ +#define MINUS_TOLERANCE_360_Q22 -1510033326 /* - (360 in Q22 + 0.02 in Q22) */ + /*-----------------------------------------------------------------------* * Local function prototypes diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index ca35d80e7..1f33f4875 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -33,25 +33,20 @@ #include #include "options.h" #include -#include "cnst.h" -#include "rom_enc.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" -#include "math.h" #include "wmc_auto.h" -#include "rom_dec.h" #include "ivas_prot_fx.h" -#define INV_EPSILON_MANT 214748365 - /*-----------------------------------------------------------------------* * Local constants *-----------------------------------------------------------------------*/ +#define INV_EPSILON_MANT 214748365 + #define PARAM_MC_LOCAL_SZ_LFE_MAP 5 /*-----------------------------------------------------------------------* diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index b80a08286..a2afc331a 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -33,17 +33,13 @@ #include #include #include "options.h" -#include "cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" -#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" -#include "math.h" #include "wmc_auto.h" -#include "rom_dec.h" /*-----------------------------------------------------------------------* diff --git a/lib_dec/ivas_mct_core_dec_fx.c b/lib_dec/ivas_mct_core_dec_fx.c index f96a20126..5f764533a 100644 --- a/lib_dec/ivas_mct_core_dec_fx.c +++ b/lib_dec/ivas_mct_core_dec_fx.c @@ -34,15 +34,12 @@ #include #include "options.h" #include "prot_fx.h" -#include "rom_com.h" #include "wmc_auto.h" -#include "cnst.h" +#include "ivas_cnst.h" #include "basop_proto_func.h" -#include "stat_com.h" -#include "ivas_stat_dec.h" -#include "ivas_stat_com.h" #include "ivas_prot_fx.h" + /*-----------------------------------------------------------------* * ivas_mct_side_bits() * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 49b4edb18..f5cf8364f 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -33,10 +33,7 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_mdct_core_dec_fx.c b/lib_dec/ivas_mdct_core_dec_fx.c index f9d738695..98beb0a5e 100644 --- a/lib_dec/ivas_mdct_core_dec_fx.c +++ b/lib_dec/ivas_mdct_core_dec_fx.c @@ -34,15 +34,10 @@ #include #include "options.h" #include "prot_fx.h" -#include "rom_com.h" +#include "ivas_cnst.h" #include "ivas_rom_com.h" #include "wmc_auto.h" -#include "cnst.h" #include "basop_proto_func.h" -#include "stat_com.h" -#include "ivas_stat_dec.h" -#include "ivas_stat_com.h" -#include #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_mono_dmx_renderer_fx.c b/lib_dec/ivas_mono_dmx_renderer_fx.c index 6c64eee81..d08105470 100644 --- a/lib_dec/ivas_mono_dmx_renderer_fx.c +++ b/lib_dec/ivas_mono_dmx_renderer_fx.c @@ -32,13 +32,9 @@ #include #include "options.h" -#include -#include "cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" -#include "ivas_rom_com.h" -#include "ivas_rom_dec.h" #include "wmc_auto.h" diff --git a/lib_dec/ivas_objectRenderer_internal_fx.c b/lib_dec/ivas_objectRenderer_internal_fx.c index 069e2c0eb..428c6512e 100644 --- a/lib_dec/ivas_objectRenderer_internal_fx.c +++ b/lib_dec/ivas_objectRenderer_internal_fx.c @@ -34,11 +34,12 @@ #include "options.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" -#include #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" +#ifdef DEBUGGING #include "debug.h" +#endif /*---------------------------------------------------------------------* diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 0c6c13d19..ca0061785 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -32,14 +32,12 @@ #include "options.h" #include -#include #include "ivas_cnst.h" #include "ivas_prot_fx.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_rom_com.h" #include "wmc_auto.h" -#include "ivas_prot_fx.h" /*------------------------------------------------------------------------- diff --git a/lib_dec/ivas_out_setup_conversion_fx.c b/lib_dec/ivas_out_setup_conversion_fx.c index 339d6eb4b..01f78da05 100644 --- a/lib_dec/ivas_out_setup_conversion_fx.c +++ b/lib_dec/ivas_out_setup_conversion_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include #include #include "prot_fx.h" #include "ivas_prot_rend_fx.h" @@ -40,14 +39,15 @@ #include "ivas_rom_rend.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" - +#ifdef DEBUGGING #include "debug.h" +#endif + /*----------------------------------------------------------------------------------* * Local constants *----------------------------------------------------------------------------------*/ - #define LS_OUT_CONV_SMOOTHING_FACTOR_Q31 93415539 #define LS_OUT_CONV_CLIP_FACTOR_MAX_Q30 2147483647 #define LS_OUT_CONV_CLIP_FACTOR_MIN_Q30 322122547 diff --git a/lib_dec/ivas_pca_dec_fx.c b/lib_dec/ivas_pca_dec_fx.c index 98611ab7c..fc531c34d 100644 --- a/lib_dec/ivas_pca_dec_fx.c +++ b/lib_dec/ivas_pca_dec_fx.c @@ -36,9 +36,9 @@ #include #include "ivas_cnst.h" #include "wmc_auto.h" -#include "math.h" #include "ivas_prot_fx.h" + /*-----------------------------------------------------------------------* * Local function definitions *-----------------------------------------------------------------------*/ diff --git a/lib_dec/ivas_post_proc_fx.c b/lib_dec/ivas_post_proc_fx.c index f3254c4a5..02be03d21 100644 --- a/lib_dec/ivas_post_proc_fx.c +++ b/lib_dec/ivas_post_proc_fx.c @@ -33,8 +33,6 @@ #include #include #include "options.h" -#include "cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" diff --git a/lib_dec/ivas_qmetadata_dec_fx.c b/lib_dec/ivas_qmetadata_dec_fx.c index cc98c6ec4..261133d93 100644 --- a/lib_dec/ivas_qmetadata_dec_fx.c +++ b/lib_dec/ivas_qmetadata_dec_fx.c @@ -33,7 +33,6 @@ #include #include #include "options.h" -#include #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" diff --git a/lib_dec/ivas_range_uni_dec_fx.c b/lib_dec/ivas_range_uni_dec_fx.c index 9a49680e8..7b6d428db 100644 --- a/lib_dec/ivas_range_uni_dec_fx.c +++ b/lib_dec/ivas_range_uni_dec_fx.c @@ -33,8 +33,6 @@ #include #include "ivas_cnst.h" #include "ivas_stat_dec.h" -#include "cnst.h" -#include "rom_com.h" #include #include "options.h" #include "prot_fx.h" diff --git a/lib_dec/ivas_rom_dec_fx.c b/lib_dec/ivas_rom_dec_fx.c index 016335004..3209278ed 100644 --- a/lib_dec/ivas_rom_dec_fx.c +++ b/lib_dec/ivas_rom_dec_fx.c @@ -32,11 +32,8 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include #include "wmc_auto.h" -#include "ivas_stat_dec.h" /* clang-format off */ diff --git a/lib_dec/ivas_sba_dec_fx.c b/lib_dec/ivas_sba_dec_fx.c index c4a1b0de1..90cca6855 100644 --- a/lib_dec/ivas_sba_dec_fx.c +++ b/lib_dec/ivas_sba_dec_fx.c @@ -34,21 +34,21 @@ #include #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" -#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" -#include #include "wmc_auto.h" #include "ivas_prot_fx.h" + + /*-------------------------------------------------------------------* * ivas_sba_set_cna_cng_flag() * * Set CNA/CNG flags in IVAS SBA decoder *-------------------------------------------------------------------*/ + void ivas_sba_set_cna_cng_flag( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index 42a2524f1..0c380ea5c 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -29,22 +29,28 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ + #include -#include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" -#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" #include "wmc_auto.h" +/*-----------------------------------------------------------------------* + * Local constants + *-----------------------------------------------------------------------*/ + #define SIN_NEG_30_DEGREES_Q15 ( (Word16) 0xC000 ) #define SIN_30_DEGREES_Q15 ( (Word16) 0x4000 ) +#define SBA_DIRAC_NRG_SMOOTH_SHORT_BY_LONG_FX ( (Word16) 0x2667 ) +#define SBA_DIRAC_NRG_SMOOTH_LONG_BY_LONG_SHORT_FX ( (Word32) 0x5B6DB6DB ) + + /*-------------------------------------------------------------------* * ivas_get_sba_dirac_stereo_flag() * diff --git a/lib_dec/ivas_sba_rendering_internal_fx.c b/lib_dec/ivas_sba_rendering_internal_fx.c index d9f7b26be..552b478d2 100644 --- a/lib_dec/ivas_sba_rendering_internal_fx.c +++ b/lib_dec/ivas_sba_rendering_internal_fx.c @@ -36,13 +36,13 @@ #include "ivas_prot_rend_fx.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" -#include #include "wmc_auto.h" #include "ivas_prot_fx.h" #ifdef DEBUGGING #include "debug.h" #endif + /*-------------------------------------------------------------------------* * ivas_sba2MC_cldfb() * diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index 77c53c5ef..a889c505d 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -33,9 +33,7 @@ #include #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_sns_dec_fx.c b/lib_dec/ivas_sns_dec_fx.c index 05bf47cb9..0425cb7ac 100644 --- a/lib_dec/ivas_sns_dec_fx.c +++ b/lib_dec/ivas_sns_dec_fx.c @@ -33,13 +33,12 @@ #include #include "options.h" #include "prot_fx.h" -#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" -#include #include "wmc_auto.h" #include "ivas_prot_fx.h" + /*------------------------------------------------------------------- * sns_1st_dec_fx() * diff --git a/lib_dec/ivas_spar_decoder_fx.c b/lib_dec/ivas_spar_decoder_fx.c index 864d05438..7cb1297a7 100644 --- a/lib_dec/ivas_spar_decoder_fx.c +++ b/lib_dec/ivas_spar_decoder_fx.c @@ -31,18 +31,14 @@ *******************************************************************************************************/ #include -#include #include #include "options.h" #include "ivas_stat_dec.h" #include "prot_fx.h" -#include "string.h" #include "ivas_prot_rend_fx.h" -#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" #include "ivas_stat_com.h" -#include "stat_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" #ifdef DEBUGGING diff --git a/lib_dec/ivas_spar_md_dec_fx.c b/lib_dec/ivas_spar_md_dec_fx.c index 248518134..64c4375a5 100644 --- a/lib_dec/ivas_spar_md_dec_fx.c +++ b/lib_dec/ivas_spar_md_dec_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "math.h" #include "prot_fx.h" #include "ivas_rom_com.h" #include @@ -44,6 +43,7 @@ /*------------------------------------------------------------------------------------------* * Local constants *------------------------------------------------------------------------------------------*/ + #define DEG180_BY_PI_Q24 ( (Word32) 0x394BB835 ) /* 180.0/PI in Q24) */ #define IVAS_DEFAULT_DTX_CNG_RAMP ( 8 ) diff --git a/lib_dec/ivas_stereo_cng_dec_fx.c b/lib_dec/ivas_stereo_cng_dec_fx.c index 124f89c5a..2a652a573 100644 --- a/lib_dec/ivas_stereo_cng_dec_fx.c +++ b/lib_dec/ivas_stereo_cng_dec_fx.c @@ -32,8 +32,6 @@ #include #include "options.h" -#include -#include "cnst.h" #include "prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_stereo_dft_dec_dmx_fx.c b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c index 9b166c41a..32321454c 100644 --- a/lib_dec/ivas_stereo_dft_dec_dmx_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_dmx_fx.c @@ -33,8 +33,6 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index b5e19dad5..33a1eb80b 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -33,17 +33,13 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "rom_com.h" -#include "rom_dec.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_rom_dec.h" #include "wmc_auto.h" -#include "ivas_prot_fx.h" #include "basop_util.h" #ifdef DEBUGGING #include "debug.h" diff --git a/lib_dec/ivas_stereo_dft_plc_fx.c b/lib_dec/ivas_stereo_dft_plc_fx.c index 93588a356..720d43d19 100644 --- a/lib_dec/ivas_stereo_dft_plc_fx.c +++ b/lib_dec/ivas_stereo_dft_plc_fx.c @@ -32,14 +32,13 @@ #include #include "options.h" -#include "cnst.h" #include "prot_fx.h" #include "ivas_cnst.h" #include "ivas_prot_fx.h" -#include "math.h" #include "wmc_auto.h" #include "basop_util.h" + /*--------------------------------------------------------------- * Local constants * ---------------------------------------------------------------*/ diff --git a/lib_dec/ivas_stereo_ica_dec_fx.c b/lib_dec/ivas_stereo_ica_dec_fx.c index 96458c4f2..069f42bca 100644 --- a/lib_dec/ivas_stereo_ica_dec_fx.c +++ b/lib_dec/ivas_stereo_ica_dec_fx.c @@ -33,12 +33,9 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" #include "wmc_auto.h" -#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_prot_fx.h" #include "basop32.h" diff --git a/lib_dec/ivas_stereo_icbwe_dec_fx.c b/lib_dec/ivas_stereo_icbwe_dec_fx.c index 647ad6e77..8cf565a5e 100644 --- a/lib_dec/ivas_stereo_icbwe_dec_fx.c +++ b/lib_dec/ivas_stereo_icbwe_dec_fx.c @@ -33,8 +33,6 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_stereo_mdct_core_dec_fx.c b/lib_dec/ivas_stereo_mdct_core_dec_fx.c index 4d5996bb6..d8c1ad18f 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_core_dec_fx.c @@ -33,10 +33,8 @@ #include #include #include "options.h" -#include #include "prot_fx.h" -#include "cnst.h" -#include "stat_com.h" +#include "ivas_cnst.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c index 725211758..d48954e86 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec_fx.c @@ -32,11 +32,9 @@ #include #include -#include #include "options.h" #include "ivas_cnst.h" #include "prot_fx.h" -#include "rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_dec/ivas_stereo_switching_dec_fx.c b/lib_dec/ivas_stereo_switching_dec_fx.c index 76e4d226d..529a46ac9 100644 --- a/lib_dec/ivas_stereo_switching_dec_fx.c +++ b/lib_dec/ivas_stereo_switching_dec_fx.c @@ -32,15 +32,12 @@ #include #include "options.h" -#include "cnst.h" -#include "rom_com.h" +#include "ivas_cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "assert.h" #include "wmc_auto.h" -#include -#include "ivas_prot_fx.h" /*-------------------------------------------------------------------* diff --git a/lib_dec/ivas_stereo_td_dec_fx.c b/lib_dec/ivas_stereo_td_dec_fx.c index ec135d7a0..0c91bd3c4 100644 --- a/lib_dec/ivas_stereo_td_dec_fx.c +++ b/lib_dec/ivas_stereo_td_dec_fx.c @@ -32,9 +32,6 @@ #include #include "options.h" -#include -#include "cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" diff --git a/lib_dec/ivas_svd_dec_fx.c b/lib_dec/ivas_svd_dec_fx.c index d6811d2df..b7a0eaedf 100755 --- a/lib_dec/ivas_svd_dec_fx.c +++ b/lib_dec/ivas_svd_dec_fx.c @@ -29,15 +29,16 @@ the United Nations Convention on Contracts on the International Sales of Goods. *******************************************************************************************************/ + #include #include "options.h" #include "prot_fx.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" -#include #include "wmc_auto.h" #include "ivas_prot_fx.h" + /*-----------------------------------------------------------------------* * Local constants *-----------------------------------------------------------------------*/ @@ -48,6 +49,8 @@ #define SVD_ZERO_FLUSH_THRESHOLD_FX ( 0 ) #define CONVERGENCE_FACTOR_FX 214748 /* factor for SVD convergence (as per latest float code: 1.0e-04f) */ +#define MINUS_ONE_IN_Q31 ( -2147483647 - 1 ) + /*-----------------------------------------------------------------------* * Local function prototypes *-----------------------------------------------------------------------*/ diff --git a/lib_dec/ivas_tcx_core_dec_fx.c b/lib_dec/ivas_tcx_core_dec_fx.c index 01f47c906..dc09cb9b5 100644 --- a/lib_dec/ivas_tcx_core_dec_fx.c +++ b/lib_dec/ivas_tcx_core_dec_fx.c @@ -33,22 +33,20 @@ #include #include #include "options.h" -#include #include "prot_fx.h" #include "rom_com.h" -#include "stat_dec.h" #include "wmc_auto.h" #include "basop_proto_func.h" -#include "stat_com.h" #include "ivas_prot_fx.h" /*-------------------------------------------------------------* * Local prototypes *-------------------------------------------------------------*/ - static void dec_prm_tcx_ivas_fx( Decoder_State *st, Word16 param[], Word16 param_lpc[], Word16 *total_nbbits, const Word16 last_element_mode, Word16 *bitsRead ); static void stereo_tcx_dec_mode_switch_reconf_ivas_fx( Decoder_State *st, const Word16 MCT_flag, const Word16 last_element_mode, Word16 *Q_syn_Overl_TDAC, Word16 *Q_fer_samples, Word16 *Q_syn_Overl, Word16 *Q_syn_Overl_TDACFB, Word16 *Q_syn_OverlFB, Word16 *Q_old_out, Word16 *Q_old_outLB, Word16 *Q_old_Aq_12_8 ); + + /*-------------------------------------------------------------* * stereo_tcx_init_dec() * diff --git a/lib_dec/ivas_td_low_rate_dec_fx.c b/lib_dec/ivas_td_low_rate_dec_fx.c index 32b5b3f87..8ed51cdab 100644 --- a/lib_dec/ivas_td_low_rate_dec_fx.c +++ b/lib_dec/ivas_td_low_rate_dec_fx.c @@ -32,8 +32,6 @@ #include #include "options.h" -#include "cnst.h" -#include "stat_enc.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 8ac73cb85..cb36de1c1 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -44,7 +44,6 @@ #ifdef IVAS_RTPDUMP #include "ivas_rtp_pi_data.h" #endif -#include #include #ifdef DEBUGGING #include "float_to_fix_ops.h" diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index ca4c399b0..54e9893f9 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -615,7 +615,7 @@ Word16 E_ACELP_xy1_corr_fx( /* Note: shl works as shl or shr. */ exp_tmp = sub( exp_tmp, 1 ); BASOP_SATURATE_WARNING_OFF_EVS - tmp = round_fx_sat( L_shl_sat( Mpy_32_16_1( 1717986944l /*ACELP_GAINS_CONST Q31*/, tmp ), exp_tmp ) ); /*Q14*/ + tmp = round_fx_sat( L_shl_sat( Mpy_32_16_1( ACELP_GAINS_CONST_Q31, tmp ), exp_tmp ) ); /*Q14*/ BASOP_SATURATE_WARNING_ON_EVS gain = s_min( gain, tmp ); /*Q14*/ diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index a9c7d768b..30bdf2ffa 100755 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -3320,7 +3320,7 @@ static void IGF_Whitening_ivas_fx( FOR( sb = hGrid->tile[p]; sb < hGrid->tile[p + 1]; sb++ ) { IF( LT_32( powerSpectrum[sb], 1 ) ) - hPrivateData->logSpec[sb] = 0; /* max(0,FLT_MIN_EXP )*/ + hPrivateData->logSpec[sb] = 0; /* max(0,FLT_MIN_EXP=-125 )*/ ELSE hPrivateData->logSpec[sb] = extract_l( L_max( 0, L_shr( L_add( BASOP_Util_Log2( powerSpectrum[sb] ), L_shl( powerSpectrum_e[sb], Q25 ) ), Q25 ) ) ); move16(); diff --git a/lib_enc/ivas_agc_enc_fx.c b/lib_enc/ivas_agc_enc_fx.c index 10d7cb8c7..e5af93e39 100644 --- a/lib_enc/ivas_agc_enc_fx.c +++ b/lib_enc/ivas_agc_enc_fx.c @@ -30,13 +30,10 @@ *******************************************************************************************************/ - #include -#include #include #include "options.h" #include "prot_fx.h" -#include "rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" #include "basop_util.h" diff --git a/lib_enc/ivas_core_enc_fx.c b/lib_enc/ivas_core_enc_fx.c index 96bbca887..2ee800325 100644 --- a/lib_enc/ivas_core_enc_fx.c +++ b/lib_enc/ivas_core_enc_fx.c @@ -32,15 +32,11 @@ #include #include "options.h" -#include "cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_cnst.h" #include "wmc_auto.h" -#include #include "prot_fx_enc.h" #include "ivas_prot_fx.h" -#include "prot_fx_enc.h" #ifdef DEBUGGING #include "debug.h" #endif diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index efa5e9a0a..b5fb1a476 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -32,22 +32,16 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_enc.h" -#include "rom_com.h" #include "prot_fx.h" #include "prot_fx_enc.h" #include "ivas_prot_fx.h" #include "wmc_auto.h" -#include #ifdef DEBUGGING #include "debug.h" #include "string.h" #endif -#include "prot_fx_enc.h" -#include "ivas_prot_fx.h" /*---------------------------------------------------------------* * Local constants diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 840165824..3d3b9f19b 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -32,10 +32,7 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_enc.h" -#include "rom_com.h" #include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_corecoder_enc_reconfig_fx.c b/lib_enc/ivas_corecoder_enc_reconfig_fx.c index a277c965b..2efae00e2 100644 --- a/lib_enc/ivas_corecoder_enc_reconfig_fx.c +++ b/lib_enc/ivas_corecoder_enc_reconfig_fx.c @@ -37,17 +37,18 @@ #include "prot_fx_enc.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "math.h" #include "wmc_auto.h" #if defined( DEBUGGING ) && defined( DBG_BITSTREAM_ANALYSIS ) #include #endif + + /*-------------------------------------------------------------------* * ivas_corecoder_enc_reconfig() * * Allocate, initialize, and configure SCE/CPE/MCT handles in case of bitrate switching *-------------------------------------------------------------------*/ -/* Some float operations are still pending */ + ivas_error ivas_corecoder_enc_reconfig_fx( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ const Word16 nSCE_old, /* i : number of SCEs in previous frame Q0*/ diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index 8bd84e031..1396f2e0d 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -33,18 +33,14 @@ #include #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_com.h" #include "prot_fx.h" -#include "prot_fx_enc.h" #include "ivas_rom_com.h" #ifdef DEBUGGING #include "debug.h" #endif #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "ivas_rom_enc.h" #include "prot_fx_enc.h" diff --git a/lib_enc/ivas_decision_matrix_enc_fx.c b/lib_enc/ivas_decision_matrix_enc_fx.c index 42e2f446e..17704e9bf 100644 --- a/lib_enc/ivas_decision_matrix_enc_fx.c +++ b/lib_enc/ivas_decision_matrix_enc_fx.c @@ -32,15 +32,11 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_com.h" #include "prot_fx.h" -#include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" /* Function prototypes */ -#include "ivas_prot_fx.h" /* Function prototypes */ -#include "prot_fx_enc.h" /* Function prototypes */ + /*-----------------------------------------------------------------* * ivas_decision_matrix_enc() diff --git a/lib_enc/ivas_dirac_enc_fx.c b/lib_enc/ivas_dirac_enc_fx.c index 0264a2199..e9fd93723 100644 --- a/lib_enc/ivas_dirac_enc_fx.c +++ b/lib_enc/ivas_dirac_enc_fx.c @@ -33,8 +33,6 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" diff --git a/lib_enc/ivas_enc_fx.c b/lib_enc/ivas_enc_fx.c index ffd32570f..7595ef26c 100644 --- a/lib_enc/ivas_enc_fx.c +++ b/lib_enc/ivas_enc_fx.c @@ -31,11 +31,8 @@ *******************************************************************************************************/ #include -#include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_rom_com.h" #ifdef DEBUGGING @@ -44,6 +41,7 @@ #include "wmc_auto.h" #include "ivas_prot_fx.h" + /*-------------------------------------------------------------------* * ivas_enc() * diff --git a/lib_enc/ivas_entropy_coder_fx.c b/lib_enc/ivas_entropy_coder_fx.c index 3c8cf92e2..ddd4df2de 100644 --- a/lib_enc/ivas_entropy_coder_fx.c +++ b/lib_enc/ivas_entropy_coder_fx.c @@ -36,13 +36,13 @@ #include "ivas_cnst.h" #include "prot_fx.h" #include "ivas_rom_com.h" -#include "math.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" #ifdef DEBUGGING #include "debug.h" #endif + /*-----------------------------------------------------------------------------------------* * Function ivas_get_dyn_freq_model_fx() * diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index 35400f652..6f1f7f5bf 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -32,15 +32,10 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_enc.h" -#include "rom_com.h" #include "prot_fx.h" -#include "prot_fx_enc.h" #include #include "wmc_auto.h" -#include #include "prot_fx_enc.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_ism_dtx_enc_fx.c b/lib_enc/ivas_ism_dtx_enc_fx.c index 3474b218b..72f362fd7 100644 --- a/lib_enc/ivas_ism_dtx_enc_fx.c +++ b/lib_enc/ivas_ism_dtx_enc_fx.c @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include -#include #include "options.h" #include "ivas_cnst.h" #include "prot_fx.h" diff --git a/lib_enc/ivas_ism_metadata_enc_fx.c b/lib_enc/ivas_ism_metadata_enc_fx.c index e68556664..65d6452da 100644 --- a/lib_enc/ivas_ism_metadata_enc_fx.c +++ b/lib_enc/ivas_ism_metadata_enc_fx.c @@ -38,7 +38,6 @@ #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "prot_fx.h" -#include #include "wmc_auto.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_ism_param_enc_fx.c b/lib_enc/ivas_ism_param_enc_fx.c index 47da31a1a..c21098774 100644 --- a/lib_enc/ivas_ism_param_enc_fx.c +++ b/lib_enc/ivas_ism_param_enc_fx.c @@ -31,12 +31,10 @@ *******************************************************************************************************/ #include -#include #include #include "options.h" #include "ivas_prot_fx.h" #include "prot_fx.h" -#include "cnst.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_lfe_enc_fx.c b/lib_enc/ivas_lfe_enc_fx.c index 96959c9dd..6261bb39e 100644 --- a/lib_enc/ivas_lfe_enc_fx.c +++ b/lib_enc/ivas_lfe_enc_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "math.h" #include "prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" @@ -45,6 +44,7 @@ * * LFE Arithmetic coding block. Writes encoded data to bitstream. *-----------------------------------------------------------------------------------------*/ + static void ivas_lfe_arith_coding_fx( LFE_ENC_HANDLE hLFE, BSTR_ENC_HANDLE hBstr, diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index 5613866cc..cb3b6e563 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include -#include #include "options.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_mc_param_enc_fx.c b/lib_enc/ivas_mc_param_enc_fx.c index 67353a279..0c4073fc0 100644 --- a/lib_enc/ivas_mc_param_enc_fx.c +++ b/lib_enc/ivas_mc_param_enc_fx.c @@ -45,19 +45,15 @@ y_fx = W_extract_h( W_shl( x_64, norm ) ); \ y_e = sub( sub35gb, norm ); \ } -#include + #include #include "options.h" -#include "cnst.h" -#include "rom_enc.h" #include "ivas_rom_enc.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "wmc_auto.h" - #include "prot_fx_enc.h" /*------------------------------------------------------------------------- diff --git a/lib_enc/ivas_mc_paramupmix_enc_fx.c b/lib_enc/ivas_mc_paramupmix_enc_fx.c index 0e8c845e1..7e9af16a3 100644 --- a/lib_enc/ivas_mc_paramupmix_enc_fx.c +++ b/lib_enc/ivas_mc_paramupmix_enc_fx.c @@ -30,12 +30,8 @@ *******************************************************************************************************/ -#include #include #include "options.h" -#include "cnst.h" -#include "rom_enc.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "basop_util.h" @@ -47,6 +43,7 @@ #include "debug.h" #endif + /*------------------------------------------------------------------------- * Local function prototypes *------------------------------------------------------------------------*/ diff --git a/lib_enc/ivas_mct_core_enc_fx.c b/lib_enc/ivas_mct_core_enc_fx.c index 9bbf1260c..d4fd50dbf 100644 --- a/lib_enc/ivas_mct_core_enc_fx.c +++ b/lib_enc/ivas_mct_core_enc_fx.c @@ -33,13 +33,11 @@ #include #include #include "options.h" -#include "cnst.h" +#include "ivas_cnst.h" #include "prot_fx.h" -#include "rom_com.h" #include "wmc_auto.h" #include "prot_fx_enc.h" #include "ivas_prot_fx.h" -#include /*----------------------------------------------------------* diff --git a/lib_enc/ivas_mct_enc_fx.c b/lib_enc/ivas_mct_enc_fx.c index 39735ad03..88e88a865 100644 --- a/lib_enc/ivas_mct_enc_fx.c +++ b/lib_enc/ivas_mct_enc_fx.c @@ -33,14 +33,11 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" #include "prot_fx_enc.h" -#include "rom_com.h" /*-----------------------------------------------------------------------* diff --git a/lib_enc/ivas_mct_enc_mct_fx.c b/lib_enc/ivas_mct_enc_mct_fx.c index d402d834f..de906bde1 100644 --- a/lib_enc/ivas_mct_enc_mct_fx.c +++ b/lib_enc/ivas_mct_enc_mct_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include #include "ivas_cnst.h" #include "ivas_prot_fx.h" #include "prot_fx.h" diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index b4eba6201..81d8757e0 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -30,14 +30,11 @@ *******************************************************************************************************/ -#include "ivas_cnst.h" #include #include #include "options.h" -#include -#include "cnst.h" +#include "ivas_cnst.h" #include "prot_fx.h" -#include "rom_com.h" #include "ivas_rom_com.h" #include "wmc_auto.h" #include "prot_fx_enc.h" diff --git a/lib_enc/ivas_omasa_enc_fx.c b/lib_enc/ivas_omasa_enc_fx.c index 1311181dd..4a620db48 100644 --- a/lib_enc/ivas_omasa_enc_fx.c +++ b/lib_enc/ivas_omasa_enc_fx.c @@ -33,7 +33,6 @@ #include "options.h" #include #include -#include #include "ivas_cnst.h" #include "ivas_prot_fx.h" #include "prot_fx.h" diff --git a/lib_enc/ivas_osba_enc_fx.c b/lib_enc/ivas_osba_enc_fx.c index 3629b8562..5f0ec3319 100644 --- a/lib_enc/ivas_osba_enc_fx.c +++ b/lib_enc/ivas_osba_enc_fx.c @@ -33,7 +33,6 @@ #include "options.h" #include #include -#include #include "ivas_cnst.h" #include "prot_fx.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_pca_enc_fx.c b/lib_enc/ivas_pca_enc_fx.c index 7eb4f18e7..e9fbfac46 100644 --- a/lib_enc/ivas_pca_enc_fx.c +++ b/lib_enc/ivas_pca_enc_fx.c @@ -34,10 +34,8 @@ #include "options.h" #include "prot_fx.h" #include "ivas_cnst.h" -#include #include #include "wmc_auto.h" - #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index 3f1852774..4753e5276 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -33,7 +33,6 @@ #include #include #include "options.h" -#include #include "ivas_cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_qspherical_enc_fx.c b/lib_enc/ivas_qspherical_enc_fx.c index 3f17a423e..09d61c610 100644 --- a/lib_enc/ivas_qspherical_enc_fx.c +++ b/lib_enc/ivas_qspherical_enc_fx.c @@ -33,7 +33,6 @@ #include #include #include "options.h" -#include #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "ivas_stat_enc.h" diff --git a/lib_enc/ivas_range_uni_enc_fx.c b/lib_enc/ivas_range_uni_enc_fx.c index 6c322a3d9..949625722 100644 --- a/lib_enc/ivas_range_uni_enc_fx.c +++ b/lib_enc/ivas_range_uni_enc_fx.c @@ -34,8 +34,6 @@ #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include "ivas_stat_enc.h" -#include "cnst.h" -#include "rom_com.h" #include #include "options.h" #include "prot_fx.h" diff --git a/lib_enc/ivas_rom_enc_fx.c b/lib_enc/ivas_rom_enc_fx.c index 1b7bed210..671e20a00 100644 --- a/lib_enc/ivas_rom_enc_fx.c +++ b/lib_enc/ivas_rom_enc_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" #include #include "wmc_auto.h" diff --git a/lib_enc/ivas_sba_enc_fx.c b/lib_enc/ivas_sba_enc_fx.c index e630a70d9..574d10f96 100644 --- a/lib_enc/ivas_sba_enc_fx.c +++ b/lib_enc/ivas_sba_enc_fx.c @@ -32,16 +32,12 @@ #include #include -#include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "wmc_auto.h" -#include "ivas_prot_fx.h" /*-------------------------------------------------------------------* diff --git a/lib_enc/ivas_sce_enc_fx.c b/lib_enc/ivas_sce_enc_fx.c index fa58f2674..2457fef6e 100644 --- a/lib_enc/ivas_sce_enc_fx.c +++ b/lib_enc/ivas_sce_enc_fx.c @@ -33,9 +33,7 @@ #include #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "prot_fx_enc.h" #include "ivas_rom_com.h" @@ -44,7 +42,6 @@ #endif #include "wmc_auto.h" #include "ivas_prot_fx.h" -#include "prot_fx_enc.h" /*-------------------------------------------------------------------* diff --git a/lib_enc/ivas_sns_enc_fx.c b/lib_enc/ivas_sns_enc_fx.c index 0e3c0bd40..0beb13759 100644 --- a/lib_enc/ivas_sns_enc_fx.c +++ b/lib_enc/ivas_sns_enc_fx.c @@ -33,11 +33,8 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" -#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_spar_encoder_fx.c b/lib_enc/ivas_spar_encoder_fx.c index 2abe06776..884d44d00 100644 --- a/lib_enc/ivas_spar_encoder_fx.c +++ b/lib_enc/ivas_spar_encoder_fx.c @@ -37,7 +37,6 @@ #include "prot_fx.h" #include "ivas_rom_com.h" #include "ivas_stat_com.h" -#include "math.h" #include "wmc_auto.h" #include "prot_fx_enc.h" #ifdef DEBUGGING diff --git a/lib_enc/ivas_spar_md_enc_fx.c b/lib_enc/ivas_spar_md_enc_fx.c index be07b38cb..f5cc2ba80 100644 --- a/lib_enc/ivas_spar_md_enc_fx.c +++ b/lib_enc/ivas_spar_md_enc_fx.c @@ -35,11 +35,11 @@ #include "options.h" #include "prot_fx.h" #include "ivas_prot_fx.h" -#include "math.h" #include "ivas_rom_com.h" #include #include "wmc_auto.h" + /*------------------------------------------------------------------------------------------* * PreProcessor *------------------------------------------------------------------------------------------*/ diff --git a/lib_enc/ivas_stereo_adapt_GR_enc_fx.c b/lib_enc/ivas_stereo_adapt_GR_enc_fx.c index 8e79b2288..3e4a5040d 100644 --- a/lib_enc/ivas_stereo_adapt_GR_enc_fx.c +++ b/lib_enc/ivas_stereo_adapt_GR_enc_fx.c @@ -32,9 +32,8 @@ #include #include "options.h" -#include "cnst.h" +#include "ivas_cnst.h" #include "prot_fx.h" -#include "stat_enc.h" #include "wmc_auto.h" #include "ivas_rom_com.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_stereo_classifier_fx.c b/lib_enc/ivas_stereo_classifier_fx.c index 2c1bc0317..88469e818 100644 --- a/lib_enc/ivas_stereo_classifier_fx.c +++ b/lib_enc/ivas_stereo_classifier_fx.c @@ -31,13 +31,10 @@ *******************************************************************************************************/ #include -#include #include "options.h" #ifdef DEBUGGING #include "debug.h" #endif -#include "cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_rom_com.h" #include "ivas_rom_enc.h" @@ -45,33 +42,24 @@ #include "wmc_auto.h" #include "ivas_prot_fx.h" + /*-------------------------------------------------------------------* * Local constants *-------------------------------------------------------------------*/ -#define RC_FACT_UP 0.3f -#define RC_FACT_UP_Q31 644245094 -#define RC_FACT_DOWN 0.7f -#define RC_FACT_DOWN_Q31 1503238554 -#define UNCLR_SCORE_THR 4.0f -#define UNCLR_SCORE_THR_Q28 ( 1073741824 ) -#define XTALK_SCORE_THR_DFT 4.0f -#define XTALK_SCORE_THR_DFT_Q27 ( 1 << 29 ) -#define XTALK_SCORE_THR_TD_UP 3.0f -#define XTALK_SCORE_THR_TD_UP_Q28 ( 805306368 ) +#define RC_FACT_UP_Q31 644245094 /* 0.3f */ +#define RC_FACT_DOWN_Q31 1503238554 /* 0.7f */ +#define UNCLR_SCORE_THR_Q28 ( 1073741824 ) /* 4.0f */ +#define XTALK_SCORE_THR_DFT_Q27 ( 1 << 29 ) /* 4.0f */ +#define XTALK_SCORE_THR_TD_UP_Q28 ( 805306368 ) /* 3.0f */ #define ONE_BY_XTALK_SCORE_THR_TD_UP_Q31 ( 715827882 ) -#define XTALK_SCORE_THR_TD_DN 4.0f -#define XTALK_SCORE_THR_TD_DN_Q28 ( 1073741824 ) +#define XTALK_SCORE_THR_TD_DN_Q28 ( 1073741824 ) /* 4.0f */ #define ONE_BY_XTALK_SCORE_THR_TD_DN_Q31 ( 536870912 ) -#define UNCLR_INTERCEPT_TD 0.780313f -#define UNCLR_INTERCEPT_TD_Q28 ( 209463676 ) -#define UNCLR_INTERCEPT_DFT 1.226513f -#define UNCLR_INTERCEPT_DFT_Q30 1316958306 -#define XTALK_INTERCEPT_TD -1.770983f -#define XTALK_INTERCEPT_TD_Q28 ( -475394629 ) -#define XTALK_INTERCEPT_DFT -0.758556f -#define XTALK_INTERCEPT_DFT_Q31 -1628986606 +#define UNCLR_INTERCEPT_TD_Q28 ( 209463676 ) /* 0.780313f */ +#define UNCLR_INTERCEPT_DFT_Q30 1316958306 /* 1.226513f */ +#define XTALK_INTERCEPT_TD_Q28 ( -475394629 ) /* -1.770983f */ +#define XTALK_INTERCEPT_DFT_Q31 -1628986606 /*-0.758556f */ #define XTALK_INTERCEPT_DFT_Q27 -101811663 #define EDGE_MAX_LEN 30 /* maximum length of buffer for edge detection */ @@ -83,6 +71,7 @@ /*-------------------------------------------------------------------* * Local function prototypes *-------------------------------------------------------------------*/ + static void rc_filter_fx( const Word32 x, Word32 *y, const Word16 order, const Word32 tau ); static void edge_detect_fx( const Word32 *inp, const Word16 len, const Word32 inp_min, const Word32 inp_max, Word16 *edge_str, Word16 *edge_type ); diff --git a/lib_enc/ivas_stereo_cng_enc_fx.c b/lib_enc/ivas_stereo_cng_enc_fx.c index b73a57f46..929d35b91 100644 --- a/lib_enc/ivas_stereo_cng_enc_fx.c +++ b/lib_enc/ivas_stereo_cng_enc_fx.c @@ -32,9 +32,6 @@ #include #include "options.h" -#include -#include "cnst.h" -#include "rom_enc.h" #include "rom_com.h" #include "prot_fx.h" #include "ivas_cnst.h" diff --git a/lib_enc/ivas_stereo_dft_enc_fx.c b/lib_enc/ivas_stereo_dft_enc_fx.c index e5522fb37..3a0e19bb4 100644 --- a/lib_enc/ivas_stereo_dft_enc_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_fx.c @@ -33,9 +33,6 @@ #include #include #include "options.h" -#include -#include "cnst.h" -#include "rom_enc.h" #include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_fx.h" @@ -51,7 +48,7 @@ #define STEREO_DFT_NRG_PAST_MAX_BAND 9 #define STEREO_DFT_NRG_PAST_MAX_BAND_LB 4 -#define STEREO_DFT_DMX_CROSSOVER ( Word16 )( 132 * ( (float) ( STEREO_DFT_N_NS_ENC ) / STEREO_DFT_N_NS ) + 0.5f ) /* crossover bin between binwise and bandwise DMX */ +#define STEREO_DFT_DMX_CROSSOVER 211 /* crossover bin between binwise and bandwise DMX, ( 132 * ( (float) ( STEREO_DFT_N_NS_ENC ) / STEREO_DFT_N_NS ) + 0.5f ) */ #define ITD_VAD_E_BAND_N_INIT 200000 #define ITD_SID_PREV_FRAMES 5 @@ -393,8 +390,7 @@ ivas_error stereo_dft_enc_create_fx( stereo_dft_enc_open_fx( hStereoDft_loc, input_Fs, max_bwidth ); - stereo_dft_hybrid_ITD_flag_fx( hStereoDft_loc->hConfig, input_Fs, - hStereoDft_loc->hItd->hybrid_itd_max ); + stereo_dft_hybrid_ITD_flag_fx( hStereoDft_loc->hConfig, input_Fs, hStereoDft_loc->hItd->hybrid_itd_max ); *hStereoDft = hStereoDft_loc; diff --git a/lib_enc/ivas_stereo_dft_enc_itd_fx.c b/lib_enc/ivas_stereo_dft_enc_itd_fx.c index eb23e9d01..09d5f0c91 100644 --- a/lib_enc/ivas_stereo_dft_enc_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_itd_fx.c @@ -33,9 +33,6 @@ #include #include #include "options.h" -#include -#include "cnst.h" -#include "rom_enc.h" #include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_fx.h" @@ -49,10 +46,8 @@ * Local constants *------------------------------------------------------------------------*/ -#define LP_GCC_PHAT_UP 0.9f /* LP filter coefficient, going up */ -#define LP_GCC_PHAT_UP_Q31 1932735283 /* LP filter coefficient, going up */ -#define LP_GCC_PHAT_DOWN 0.1f /* LP filter coefficient, going down */ -#define LP_GCC_PHAT_DOWN_Q31 214748365 /* LP filter coefficient, going down */ +#define LP_GCC_PHAT_UP_Q31 1932735283 /* LP filter coefficient, going up, 0.9f */ +#define LP_GCC_PHAT_DOWN_Q31 214748365 /* LP filter coefficient, going down, 0.1f */ #define ITD_CNT_MAX 2 /* Minimum number of consecutive ITD estimates for ITD hangover */ #define ITD_HO_GCC_PHAT_MAX 0.6f /* LP GCC PHAT value which gives zero hangover */ #define ITD_HO_GCC_PHAT_MIN 0.3f /* LP GCC PHAT value which gives ITD_HO_MAX ITD hangover frames */ @@ -61,26 +56,20 @@ #define ITD_HO_GCC_PHAT_INCL_Q26 -1118481021 #define ITD_HO_GCC_PHAT_OFFS ( -ITD_HO_GCC_PHAT_INCL * ITD_HO_GCC_PHAT_MAX + 1 ) #define ITD_HO_GCC_PHAT_OFFS_Q26 738197504 -#define SFM_PROD_GRP 4 /*maximum grouping of products for calculating SFM in ITD estimation*/ -#define B_DENOM 0.083333333333333f -#define B_DENOM_Q31 178956971 +#define SFM_PROD_GRP 4 /*maximum grouping of products for calculating SFM in ITD estimation*/ +#define B_DENOM_Q31 178956971 /* 0.083333333333333f */ #define L_SAMPLES 20 #define SUBDIV ( 2 * STEREO_DFT_ITD_MAX_ANA / L_SAMPLES ) #define DENOM 0.05f #define DENOM_Q31 107374182 -#define XSPEC_ALPHA ( 1.f / 32 ) #define XSPEC_ALPHA_Q31 ONE_IN_Q26 -#define CORR_FILT 0.8f -#define CORR_FILT_Q31 1717986918 +#define CORR_FILT_Q31 1717986918 /* 0.8f */ #define CORR_RESET_FRAMES_MAX 20 #define ITD_VAD_NOISE_INIT_FRAMES 30 -#define ITD_VAD_THRSHOLD 0.001f #define ITD_VAD_THRSHOLD_Q31 INV_1000_Q31 -#define ITD_VAD_MS_SNR_UPDATE_THRESH 15.0f #define ITD_VAD_MS_SNR_UPDATE_THRESH_FX 15 -#define HIGHT_SNR_VOICE_TH 10000.0f #define HIGHT_SNR_VOICE_TH_FX 10000 #define MAX_ITD_VAD_HANGOVER 10 diff --git a/lib_enc/ivas_stereo_dft_td_itd_fx.c b/lib_enc/ivas_stereo_dft_td_itd_fx.c index 2c044625c..94a57b036 100644 --- a/lib_enc/ivas_stereo_dft_td_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_td_itd_fx.c @@ -33,10 +33,7 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "prot_fx.h" -#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_stat_enc.h" #include "ivas_cnst.h" diff --git a/lib_enc/ivas_stereo_dmx_evs_fx.c b/lib_enc/ivas_stereo_dmx_evs_fx.c index 73f7e246c..398fe88fd 100644 --- a/lib_enc/ivas_stereo_dmx_evs_fx.c +++ b/lib_enc/ivas_stereo_dmx_evs_fx.c @@ -31,17 +31,13 @@ *******************************************************************************************************/ #include -#include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_rom_com.h" #include "ivas_rom_enc.h" #include "wmc_auto.h" -#include "ivas_prot_fx.h" /*-----------------------------------------------------------------------* diff --git a/lib_enc/ivas_stereo_eclvq_enc_fx.c b/lib_enc/ivas_stereo_eclvq_enc_fx.c index a09daffe0..05f9dc80d 100644 --- a/lib_enc/ivas_stereo_eclvq_enc_fx.c +++ b/lib_enc/ivas_stereo_eclvq_enc_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include #include "ivas_prot_fx.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" diff --git a/lib_enc/ivas_stereo_ica_enc_fx.c b/lib_enc/ivas_stereo_ica_enc_fx.c index 924de4d65..32d70a8b7 100644 --- a/lib_enc/ivas_stereo_ica_enc_fx.c +++ b/lib_enc/ivas_stereo_ica_enc_fx.c @@ -33,12 +33,9 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" #include "wmc_auto.h" -#include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_prot_fx.h" diff --git a/lib_enc/ivas_stereo_icbwe_enc_fx.c b/lib_enc/ivas_stereo_icbwe_enc_fx.c index f6bf1a099..2d6c17d9f 100644 --- a/lib_enc/ivas_stereo_icbwe_enc_fx.c +++ b/lib_enc/ivas_stereo_icbwe_enc_fx.c @@ -32,8 +32,6 @@ #include #include "options.h" -#include -#include "cnst.h" #include "ivas_cnst.h" #include "prot_fx.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_stereo_mdct_core_enc_fx.c b/lib_enc/ivas_stereo_mdct_core_enc_fx.c index 6bb6af1b3..e764649df 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_core_enc_fx.c @@ -33,20 +33,20 @@ #include #include #include "options.h" -#include -#include "cnst.h" +#include "ivas_cnst.h" #include "prot_fx.h" -#include "rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" #include "prot_fx_enc.h" + /*-------------------------------------------------------------------* * sync_tcx_mode() * * Synchronize under certain conditions the tcx modes and set overlap * windows accordingly *-------------------------------------------------------------------*/ + static void sync_tcx_mode_fx( Encoder_State **st /* i/o: Encoder state */ ) diff --git a/lib_enc/ivas_stereo_mdct_igf_enc_fx.c b/lib_enc/ivas_stereo_mdct_igf_enc_fx.c index d22e1b885..39f4f4149 100644 --- a/lib_enc/ivas_stereo_mdct_igf_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_igf_enc_fx.c @@ -33,14 +33,13 @@ #include #include #include "options.h" -#include #include "prot_fx.h" -#include "cnst.h" -#include "stat_enc.h" +#include "ivas_cnst.h" #include "ivas_stat_enc.h" #include "ivas_prot_fx.h" #include "wmc_auto.h" + /*-------------------------------------------------------------------* * Local constants *-------------------------------------------------------------------*/ diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c index d53eb365d..055e22593 100644 --- a/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c +++ b/lib_enc/ivas_stereo_mdct_stereo_enc_fx.c @@ -33,15 +33,12 @@ #include #include #include "options.h" -#include #include "ivas_cnst.h" #include "ivas_prot_fx.h" #include "prot_fx.h" -#include "prot_fx_enc.h" #include "ivas_rom_com.h" #include "ivas_rom_enc.h" #include "wmc_auto.h" -#include "stat_enc.h" /*-------------------------------------------------------------------* diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 0b27de0f6..8440a8263 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -32,8 +32,7 @@ #include #include "options.h" -#include "cnst.h" -#include "rom_com.h" +#include "ivas_cnst.h" #include "prot_fx.h" #include "ivas_rom_com.h" #include "assert.h" diff --git a/lib_enc/ivas_stereo_td_analysis_fx.c b/lib_enc/ivas_stereo_td_analysis_fx.c index ab28f7f7e..1eff3cd9e 100644 --- a/lib_enc/ivas_stereo_td_analysis_fx.c +++ b/lib_enc/ivas_stereo_td_analysis_fx.c @@ -32,9 +32,6 @@ #include #include "options.h" -#include -#include "cnst.h" -#include "rom_com.h" #include "prot_fx.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" diff --git a/lib_enc/ivas_stereo_td_enc_fx.c b/lib_enc/ivas_stereo_td_enc_fx.c index bad9370b4..029537a4e 100644 --- a/lib_enc/ivas_stereo_td_enc_fx.c +++ b/lib_enc/ivas_stereo_td_enc_fx.c @@ -31,10 +31,8 @@ *******************************************************************************************************/ #include -#include #include "options.h" -#include "cnst.h" -#include "rom_com.h" +#include "ivas_cnst.h" #include "prot_fx.h" #include "ivas_rom_com.h" #include "wmc_auto.h" diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c index 7c5972545..ea7a011c5 100644 --- a/lib_enc/ivas_tcx_core_enc_fx.c +++ b/lib_enc/ivas_tcx_core_enc_fx.c @@ -33,15 +33,14 @@ #include #include #include "options.h" -#include -#include "cnst.h" +#include "ivas_cnst.h" #include "prot_fx.h" #include "rom_com.h" #include "basop_proto_func.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" #include "prot_fx_enc.h" -#include "ivas_prot_fx.h" + /*-------------------------------------------------------------------* * stereo_tcx_init_enc() diff --git a/lib_enc/ivas_td_low_rate_enc_fx.c b/lib_enc/ivas_td_low_rate_enc_fx.c index 21fa71312..8947bfb64 100644 --- a/lib_enc/ivas_td_low_rate_enc_fx.c +++ b/lib_enc/ivas_td_low_rate_enc_fx.c @@ -32,8 +32,6 @@ #include #include "options.h" -#include "cnst.h" -#include "stat_enc.h" #include "rom_com.h" #include "ivas_rom_com.h" #include "ivas_cnst.h" diff --git a/lib_enc/lib_enc_fx.c b/lib_enc/lib_enc_fx.c index 245e5679a..91aeca920 100644 --- a/lib_enc/lib_enc_fx.c +++ b/lib_enc/lib_enc_fx.c @@ -30,7 +30,6 @@ *******************************************************************************************************/ -#include #include #include #include @@ -45,6 +44,7 @@ #include "wmc_auto.h" #include "ivas_rom_enc.h" + /*---------------------------------------------------------------------* * Local struct *---------------------------------------------------------------------*/ diff --git a/lib_enc/lp_exc_e_fx.c b/lib_enc/lp_exc_e_fx.c index 5ce75c3ac..e9fee4d2e 100644 --- a/lib_enc/lp_exc_e_fx.c +++ b/lib_enc/lp_exc_e_fx.c @@ -389,7 +389,7 @@ Word16 corr_xy1_fx( /* Note: shl works as shl or shr. */ exp_xx = sub( exp_xx, 1 ); BASOP_SATURATE_WARNING_OFF_EVS - gain_p_snr = round_fx_sat( L_shl_sat( Mpy_32_16_1( 1717986944l /*ACELP_GAINS_CONST Q31*/, tmp ), exp_xx ) ); + gain_p_snr = round_fx_sat( L_shl_sat( Mpy_32_16_1( ACELP_GAINS_CONST_Q31, tmp ), exp_xx ) ); BASOP_SATURATE_WARNING_ON_EVS gain = s_min( gain, gain_p_snr ); // Q14 diff --git a/lib_isar/isar_cnst.h b/lib_isar/isar_cnst.h index 40d6c3938..f666b453e 100644 --- a/lib_isar/isar_cnst.h +++ b/lib_isar/isar_cnst.h @@ -41,6 +41,8 @@ * Split Binaural Rendering Constants *----------------------------------------------------------------------------------*/ +#define PI2_FX 1686629713 //Q28 + typedef enum { PCM_INT16, diff --git a/lib_isar/isar_rom_post_rend.c b/lib_isar/isar_rom_post_rend.c index 954d89f63..5591fbb3a 100644 --- a/lib_isar/isar_rom_post_rend.c +++ b/lib_isar/isar_rom_post_rend.c @@ -35,7 +35,7 @@ #ifdef DEBUGGING #include "debug.h" #endif -#include "cnst.h" +#include "ivas_cnst.h" #include "isar_cnst.h" #include #include "wmc_auto.h" diff --git a/lib_rend/ivas_allrad_dec_fx.c b/lib_rend/ivas_allrad_dec_fx.c index 5023bee34..a93f3092a 100644 --- a/lib_rend/ivas_allrad_dec_fx.c +++ b/lib_rend/ivas_allrad_dec_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" -#include #include #include "prot_fx.h" #include "ivas_prot_rend_fx.h" diff --git a/lib_rend/ivas_cldfb_ring_buffer.c b/lib_rend/ivas_cldfb_ring_buffer.c index 49d88e8f3..98d07346f 100644 --- a/lib_rend/ivas_cldfb_ring_buffer.c +++ b/lib_rend/ivas_cldfb_ring_buffer.c @@ -32,7 +32,7 @@ #include #include "options.h" -#include "cnst.h" +#include "ivas_cnst.h" #include "prot_fx.h" #include "ivas_prot_fx.h" #include diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 9c3379527..5084ef138 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include -#include #include "options.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" @@ -39,7 +38,6 @@ #include "ivas_rom_rend.h" #include "ivas_rom_binaural_crend_head.h" #include "ivas_stat_rend.h" -#include "lib_rend.h" #include "ivas_prot_fx.h" #include "wmc_auto.h" #ifdef DEBUGGING diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 9683cd743..d81534764 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -33,7 +33,6 @@ #include #include "options.h" #include -#include #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" @@ -42,15 +41,15 @@ #include "ivas_rom_rend.h" #include "ivas_rom_com.h" #include "ivas_prot_fx.h" - #include "wmc_auto.h" -Word16 slot_fx[4] = { 32767, 16384, 10922, 8192 }; /*------------------------------------------------------------------------- * Local constants *------------------------------------------------------------------------*/ +static Word16 slot_fx[4] = { 32767, 16384, 10922, 8192 }; + #define STEREO_PREPROCESS_IIR_FACTOR_Q15 ( 29491 ) // 0.9f in Q15 /* powf(0.95f, 4.0f) for sub-frame smoothing instead of CLDFB slot */ #define ADAPT_HTPROTO_ROT_LIM_0_FX 429496736 // 0.4f in Q30 diff --git a/lib_rend/ivas_dirac_decorr_dec_fx.c b/lib_rend/ivas_dirac_decorr_dec_fx.c index acbfb3bd2..a4f703a28 100644 --- a/lib_rend/ivas_dirac_decorr_dec_fx.c +++ b/lib_rend/ivas_dirac_decorr_dec_fx.c @@ -33,8 +33,6 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" @@ -42,6 +40,7 @@ #include "wmc_auto.h" #include "ivas_prot_fx.h" + /*------------------------------------------------------------------------- * Local constants *------------------------------------------------------------------------*/ @@ -49,10 +48,8 @@ #define DIRAC_MAX_DECORR_CLDFB_BANDS_AMBI 22 #define DIRAC_MAX_DECORR_CLDFB_BANDS 15 -#define DIRAC_DUCK_ALPHA 0.8f -#define DIRAC_DUCK_GAMMA 1.5f -#define DIRAC_DUCK_GAMMA_FX 1610612736 /* Q30 */ -#define DIRAC_DUCK_ALPHA_FX 1717986944 /* Q31 */ +#define DIRAC_DUCK_GAMMA_FX 1610612736 /* 1.5f in Q30 */ +#define DIRAC_DUCK_ALPHA_FX 1717986944 /* 0.8f in Q31 */ #define ONE_M_DIRAC_DUCK_ALPHA 429496736 /* Q31 */ /* Maximal useful q-format, represents range of 2^-126 (float min) */ diff --git a/lib_rend/ivas_dirac_onsets_dec_fx.c b/lib_rend/ivas_dirac_onsets_dec_fx.c index 80adebfdd..1e105ba22 100644 --- a/lib_rend/ivas_dirac_onsets_dec_fx.c +++ b/lib_rend/ivas_dirac_onsets_dec_fx.c @@ -33,7 +33,6 @@ #include #include #include "options.h" -#include "cnst.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 29184695c..de25c56e5 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -33,8 +33,6 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_stat_dec.h" diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index bde35181e..83ce8af45 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -33,8 +33,6 @@ #include #include #include "options.h" -#include -#include "cnst.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" diff --git a/lib_rend/ivas_efap_fx.c b/lib_rend/ivas_efap_fx.c index 23ffbe0bd..c85d89b85 100644 --- a/lib_rend/ivas_efap_fx.c +++ b/lib_rend/ivas_efap_fx.c @@ -31,7 +31,6 @@ *******************************************************************************************************/ #include -#include #include #include #include "options.h" @@ -42,6 +41,7 @@ #include "wmc_auto.h" #include "ivas_prot_fx.h" + /*-----------------------------------------------------------------------* * Local constants *-----------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_masa_merge_fx.c b/lib_rend/ivas_masa_merge_fx.c index efffccf84..1e6e13ee4 100644 --- a/lib_rend/ivas_masa_merge_fx.c +++ b/lib_rend/ivas_masa_merge_fx.c @@ -30,9 +30,7 @@ *******************************************************************************************************/ -#include #include "options.h" -#include "lib_rend.h" #include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" #include "prot_fx.h" @@ -42,6 +40,7 @@ #endif #include "ivas_prot_fx.h" + #define INV_UINT8_MAX 8421505 /* 1/UINT8_MAX in Q31 */ /*---------------------------------------------------------------------* diff --git a/lib_rend/ivas_mcmasa_ana_fx.c b/lib_rend/ivas_mcmasa_ana_fx.c index e31241a53..c402ad1c3 100644 --- a/lib_rend/ivas_mcmasa_ana_fx.c +++ b/lib_rend/ivas_mcmasa_ana_fx.c @@ -30,7 +30,6 @@ *******************************************************************************************************/ -#include #include #include #include "ivas_cnst.h" @@ -47,10 +46,8 @@ * Local constants *------------------------------------------------------------------------*/ -#define NEAR_HORIZONTAL_PLANE_ELEVATION 17.5f -#define NEAR_HORIZONTAL_PLANE_ELEVATION_FX 73400320 /*Q22*/ -#define VERTICAL_ENERGY_RATIO_OFFSET 0.15f -#define VERTICAL_ENERGY_RATIO_OFFSET_FX 4915 /*Q15*/ +#define NEAR_HORIZONTAL_PLANE_ELEVATION_FX 73400320 /* 17.5f in Q22 */ +#define VERTICAL_ENERGY_RATIO_OFFSET_FX 4915 /* 0.15f in Q15 */ /*------------------------------------------------------------------------- diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index dd99c0070..658ff6b0f 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -35,11 +35,12 @@ #include "options.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" -#include #include "ivas_rom_com.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" +#ifdef DEBUGGING #include "debug.h" +#endif /*---------------------------------------------------------------------* diff --git a/lib_rend/ivas_objectRenderer_hrFilt_fx.c b/lib_rend/ivas_objectRenderer_hrFilt_fx.c index 2a67d7a39..00036a8cd 100644 --- a/lib_rend/ivas_objectRenderer_hrFilt_fx.c +++ b/lib_rend/ivas_objectRenderer_hrFilt_fx.c @@ -34,12 +34,12 @@ #include #include "options.h" #include "prot_fx.h" -#include #include "ivas_prot_rend_fx.h" #include "ivas_rom_rend.h" #include "ivas_cnst.h" #include "wmc_auto.h" + /*---------------------------------------------------------------------* * Local function prototypes *---------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_objectRenderer_sfx_fx.c b/lib_rend/ivas_objectRenderer_sfx_fx.c index 361cc403d..185cba09e 100644 --- a/lib_rend/ivas_objectRenderer_sfx_fx.c +++ b/lib_rend/ivas_objectRenderer_sfx_fx.c @@ -32,18 +32,12 @@ #include #include "options.h" -#include #include "ivas_prot_rend_fx.h" #include "ivas_rom_rend.h" #include "prot_fx.h" #include "wmc_auto.h" -/*---------------------------------------------------------------------* - * Local constants - *---------------------------------------------------------------------*/ - - /*---------------------------------------------------------------------* * Local function prototypes *---------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_objectRenderer_sources_fx.c b/lib_rend/ivas_objectRenderer_sources_fx.c index 33c519c8e..015d227a2 100644 --- a/lib_rend/ivas_objectRenderer_sources_fx.c +++ b/lib_rend/ivas_objectRenderer_sources_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_objectRenderer_vec_fx.c b/lib_rend/ivas_objectRenderer_vec_fx.c index 140861539..ded14eb09 100644 --- a/lib_rend/ivas_objectRenderer_vec_fx.c +++ b/lib_rend/ivas_objectRenderer_vec_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_omasa_ana_fx.c b/lib_rend/ivas_omasa_ana_fx.c index 9c209f036..384e8529e 100644 --- a/lib_rend/ivas_omasa_ana_fx.c +++ b/lib_rend/ivas_omasa_ana_fx.c @@ -32,7 +32,6 @@ #include "options.h" #include -#include #include "ivas_cnst.h" #include "ivas_prot_rend_fx.h" #include "ivas_prot_fx.h" @@ -41,11 +40,11 @@ #include "ivas_rom_com.h" #include "wmc_auto.h" + /*------------------------------------------------------------------------- * Local function prototypes *------------------------------------------------------------------------*/ - static void ivas_omasa_dmx_fx( Word32 data_in_f_fx[][L_FRAME48k], Word16 *data_in_q, diff --git a/lib_rend/ivas_orient_trk_fx.c b/lib_rend/ivas_orient_trk_fx.c index ee91e7060..201f5a826 100644 --- a/lib_rend/ivas_orient_trk_fx.c +++ b/lib_rend/ivas_orient_trk_fx.c @@ -36,11 +36,11 @@ #include "ivas_prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" -#include #include #include "wmc_auto.h" #include "prot_fx.h" + /*------------------------------------------------------------------------------------------* * Local constants *------------------------------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_reflections_fx.c b/lib_rend/ivas_reflections_fx.c index 3bf9f7169..c342d5ca2 100644 --- a/lib_rend/ivas_reflections_fx.c +++ b/lib_rend/ivas_reflections_fx.c @@ -32,16 +32,16 @@ #include "options.h" #include -#include #include "prot_fx.h" #include "rom_dec.h" -#include "lib_rend.h" #include "ivas_prot_rend_fx.h" #include "ivas_stat_rend.h" #include "ivas_cnst.h" #include "ivas_rom_com.h" #include "wmc_auto.h" +#ifdef DEBUGGING #include "debug.h" +#endif /*-----------------------------------------------------------------------------------------* diff --git a/lib_rend/ivas_reverb_delay_line_fx.c b/lib_rend/ivas_reverb_delay_line_fx.c index d2a6a0c44..5e7b206c8 100644 --- a/lib_rend/ivas_reverb_delay_line_fx.c +++ b/lib_rend/ivas_reverb_delay_line_fx.c @@ -35,7 +35,11 @@ #include "ivas_prot_rend_fx.h" #include "prot_fx.h" #include "wmc_auto.h" +#ifdef DEBUGGING #include "debug.h" +#endif + + /*-----------------------------------------------------------------------------------------* * Function ivas_rev_delay_line_init() * diff --git a/lib_rend/ivas_reverb_fft_filter_fx.c b/lib_rend/ivas_reverb_fft_filter_fx.c index b7f890ec3..6453b32d7 100644 --- a/lib_rend/ivas_reverb_fft_filter_fx.c +++ b/lib_rend/ivas_reverb_fft_filter_fx.c @@ -34,10 +34,10 @@ #include "options.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" -#include #include "wmc_auto.h" +#ifdef DEBUGGING #include "debug.h" - +#endif /*------------------------------------------------------------------------------------------* * Static functions declarations diff --git a/lib_rend/ivas_reverb_filter_design_fx.c b/lib_rend/ivas_reverb_filter_design_fx.c index e826596ba..3b896a137 100644 --- a/lib_rend/ivas_reverb_filter_design_fx.c +++ b/lib_rend/ivas_reverb_filter_design_fx.c @@ -35,7 +35,6 @@ #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include -#include #include #include "wmc_auto.h" diff --git a/lib_rend/ivas_reverb_fx.c b/lib_rend/ivas_reverb_fx.c index 6ab0c7a63..ba4159ba8 100644 --- a/lib_rend/ivas_reverb_fx.c +++ b/lib_rend/ivas_reverb_fx.c @@ -35,11 +35,12 @@ #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_cnst.h" -#include "math.h" #include "ivas_rom_rend.h" #include #include "wmc_auto.h" +#ifdef DEBUGGING #include "debug.h" +#endif /* The reverberator structure implemented here is described in detail in: @@ -86,6 +87,7 @@ static const Word16 default_loop_delay_48k[IVAS_REV_MAX_NR_BRANCHES] = { 2309, 1 static const Word16 default_loop_delay_32k[IVAS_REV_MAX_NR_BRANCHES] = { 1531, 1237, 1013, 839, 709, 613, 541, 479 }; static const Word16 default_loop_delay_16k[IVAS_REV_MAX_NR_BRANCHES] = { 769, 619, 509, 421, 353, 307, 269, 239 }; +#define MATRIX_CONSTANT ( 759250113 ) /*------------------------------------------------------------------------------------------* * Local Struct definition diff --git a/lib_rend/ivas_reverb_iir_filter_fx.c b/lib_rend/ivas_reverb_iir_filter_fx.c index 981a40466..f4f0cf516 100644 --- a/lib_rend/ivas_reverb_iir_filter_fx.c +++ b/lib_rend/ivas_reverb_iir_filter_fx.c @@ -35,9 +35,14 @@ #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "wmc_auto.h" +#ifdef DEBUGGING #include "debug.h" +#endif + + #define float_to_fix( n, factor ) ( round( n * ( 1 << factor ) ) ) #define fix_to_float( n, factor ) ( (float) n / ( 1 << factor ) ) + /*-----------------------------------------------------------------------------------------* * Function ivas_reverb_iir_filt_init() * diff --git a/lib_rend/ivas_reverb_utils_fx.c b/lib_rend/ivas_reverb_utils_fx.c index 6433da819..52cb0f130 100644 --- a/lib_rend/ivas_reverb_utils_fx.c +++ b/lib_rend/ivas_reverb_utils_fx.c @@ -35,7 +35,6 @@ #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_rom_rend.h" -#include #include "wmc_auto.h" diff --git a/lib_rend/ivas_rom_TdBinauralRenderer.h b/lib_rend/ivas_rom_TdBinauralRenderer.h index ed4ece7b6..f3d675a99 100644 --- a/lib_rend/ivas_rom_TdBinauralRenderer.h +++ b/lib_rend/ivas_rom_TdBinauralRenderer.h @@ -35,7 +35,6 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" /*------------------------------------------------------------------------- diff --git a/lib_rend/ivas_rom_TdBinauralRenderer_fx.c b/lib_rend/ivas_rom_TdBinauralRenderer_fx.c index 531c45f83..954ae2759 100644 --- a/lib_rend/ivas_rom_TdBinauralRenderer_fx.c +++ b/lib_rend/ivas_rom_TdBinauralRenderer_fx.c @@ -34,7 +34,6 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_rom_binauralRenderer.h b/lib_rend/ivas_rom_binauralRenderer.h index f7ecc3dda..30746b3d8 100644 --- a/lib_rend/ivas_rom_binauralRenderer.h +++ b/lib_rend/ivas_rom_binauralRenderer.h @@ -35,7 +35,6 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" /*------------------------------------------------------------------------- diff --git a/lib_rend/ivas_rom_binauralRenderer_fx.c b/lib_rend/ivas_rom_binauralRenderer_fx.c index 3357eaeb8..3c090f204 100644 --- a/lib_rend/ivas_rom_binauralRenderer_fx.c +++ b/lib_rend/ivas_rom_binauralRenderer_fx.c @@ -32,7 +32,6 @@ #include #include "options.h" -#include "cnst.h" #include "ivas_cnst.h" #include "wmc_auto.h" diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index c05ed40c3..9c204af31 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -35,14 +35,13 @@ #include "basop_util.h" #include "ivas_cnst.h" #include "options.h" -#include -#include "cnst.h" #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "wmc_auto.h" -#include #include "ivas_prot_fx.h" +#ifdef DEBUGGING #include "debug.h" +#endif #include "ivas_rom_binaural_crend_head.h" @@ -719,7 +718,7 @@ void rotateFrame_shd( move32(); BREAK; case L_SUBFRAME_32k: - tmp = Q31_BY_NUM_SAMPLES_160; + tmp = Q31_BY_SUB_FRAME_160; move32(); BREAK; case L_SUBFRAME_16k: @@ -856,7 +855,7 @@ void rotateFrame_sd( move32(); BREAK; case L_SUBFRAME_32k: - tmp = Q31_BY_NUM_SAMPLES_160; + tmp = Q31_BY_SUB_FRAME_160; move32(); BREAK; case L_SUBFRAME_16k: diff --git a/lib_rend/ivas_sba_rendering_fx.c b/lib_rend/ivas_sba_rendering_fx.c index ff077e63e..c60e68090 100644 --- a/lib_rend/ivas_sba_rendering_fx.c +++ b/lib_rend/ivas_sba_rendering_fx.c @@ -36,15 +36,16 @@ #include "ivas_prot_rend_fx.h" #include "ivas_stat_dec.h" #include "ivas_cnst.h" -#include #include "wmc_auto.h" #include "ivas_prot_fx.h" + /*-------------------------------------------------------------------* * ivas_sba_prototype_renderer() * * Render prototype audio signals using SBA mixing matrices *-------------------------------------------------------------------*/ + void ivas_sba_prototype_renderer_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ Word32 inRe_fx[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real Q(q_cldfb[][])*/ diff --git a/lib_rend/ivas_shoebox_fx.c b/lib_rend/ivas_shoebox_fx.c index 36af55838..631e5351e 100644 --- a/lib_rend/ivas_shoebox_fx.c +++ b/lib_rend/ivas_shoebox_fx.c @@ -32,7 +32,6 @@ #include "options.h" #include -#include #include "ivas_prot_rend_fx.h" #include "ivas_stat_rend.h" #include "ivas_prot_fx.h" diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index 87f4e0832..4d0dec7a6 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -37,8 +37,6 @@ #include #include "options.h" #include "ivas_cnst.h" -#include "ivas_stat_com.h" // note: needed for DIRAC_DEC_BIN_HANDLE until #156 is solved -#include "stat_com.h" /* Note: Currently needed for CLDFB. */ #include "common_api_types.h" #include "isar_stat.h" diff --git a/lib_rend/ivas_td_decorr_fx.c b/lib_rend/ivas_td_decorr_fx.c index 14795da41..4f51a8b5f 100644 --- a/lib_rend/ivas_td_decorr_fx.c +++ b/lib_rend/ivas_td_decorr_fx.c @@ -36,43 +36,48 @@ #include "prot_fx.h" #include "ivas_prot_fx.h" #include "ivas_prot_rend_fx.h" -#include "math.h" #include "wmc_auto.h" #ifdef DEBUGGING #include "debug.h" #endif + /*------------------------------------------------------------------------------------------* * Local constants *------------------------------------------------------------------------------------------*/ -static const Word16 ivas_hadamard_decorr_APD_coeff[IVAS_APD_16_SECT][IVAS_APD_16_SECT] = { /* Q15 */ - { 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107 }, - { 13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107 }, - { 13107, 13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107, -13107, -13107 }, - { 13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107 }, - { 13107, 13107, 13107, 13107, -13107, -13107, -13107, -13107, 13107, 13107, 13107, 13107, -13107, -13107, -13107, -13107 }, - { 13107, -13107, 13107, -13107, -13107, 13107, -13107, 13107, 13107, -13107, 13107, -13107, -13107, 13107, -13107, 13107 }, - { 13107, 13107, -13107, -13107, -13107, -13107, 13107, 13107, 13107, 13107, -13107, -13107, -13107, -13107, 13107, 13107 }, - { 13107, -13107, -13107, 13107, -13107, 13107, 13107, -13107, 13107, -13107, -13107, 13107, -13107, 13107, 13107, -13107 }, - { 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, -13107, -13107, -13107, -13107, -13107, -13107, -13107, -13107 }, - { 13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107, 13107 }, - { 13107, 13107, -13107, -13107, 13107, 13107, -13107, -13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107 }, - { 13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107, -13107 }, - { 13107, 13107, 13107, 13107, -13107, -13107, -13107, -13107, -13107, -13107, -13107, -13107, 13107, 13107, 13107, 13107 }, - { 13107, -13107, 13107, -13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107, 13107, 13107, -13107, 13107, -13107 }, - { 13107, 13107, -13107, -13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107, 13107, 13107, -13107, -13107 }, - { 13107, -13107, -13107, 13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107, -13107, 13107, -13107, -13107, 13107 } + +static const Word16 ivas_hadamard_decorr_APD_coeff[IVAS_APD_16_SECT][IVAS_APD_16_SECT] = { + /* Q15 */ + { 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107 }, + { 13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107 }, + { 13107, 13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107, -13107, -13107 }, + { 13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107 }, + { 13107, 13107, 13107, 13107, -13107, -13107, -13107, -13107, 13107, 13107, 13107, 13107, -13107, -13107, -13107, -13107 }, + { 13107, -13107, 13107, -13107, -13107, 13107, -13107, 13107, 13107, -13107, 13107, -13107, -13107, 13107, -13107, 13107 }, + { 13107, 13107, -13107, -13107, -13107, -13107, 13107, 13107, 13107, 13107, -13107, -13107, -13107, -13107, 13107, 13107 }, + { 13107, -13107, -13107, 13107, -13107, 13107, 13107, -13107, 13107, -13107, -13107, 13107, -13107, 13107, 13107, -13107 }, + { 13107, 13107, 13107, 13107, 13107, 13107, 13107, 13107, -13107, -13107, -13107, -13107, -13107, -13107, -13107, -13107 }, + { 13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107, 13107 }, + { 13107, 13107, -13107, -13107, 13107, 13107, -13107, -13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107 }, + { 13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107, -13107 }, + { 13107, 13107, 13107, 13107, -13107, -13107, -13107, -13107, -13107, -13107, -13107, -13107, 13107, 13107, 13107, 13107 }, + { 13107, -13107, 13107, -13107, -13107, 13107, -13107, 13107, -13107, 13107, -13107, 13107, 13107, -13107, 13107, -13107 }, + { 13107, 13107, -13107, -13107, -13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107, 13107, 13107, -13107, -13107 }, + { 13107, -13107, -13107, 13107, -13107, 13107, 13107, -13107, -13107, 13107, 13107, -13107, 13107, -13107, -13107, 13107 } }; /* For R = 3.^([0:obj.parm_APD_nSections-1]/4); Q22 */ -static const Word32 ivas_three_pow_frac[IVAS_MAX_DECORR_APD_SECTIONS] = { /* Q22 */ - 4194304, 5520015, 7264748, 9560946, 12582912, 16560043, 21794242, - 28682836, 37748736, 49680132, 65382728, 86048512, 113246208, - 149040384, 196148192, 258145536 +static const Word32 ivas_three_pow_frac[IVAS_MAX_DECORR_APD_SECTIONS] = { + /* Q22 */ + 4194304, 5520015, 7264748, 9560946, 12582912, 16560043, 21794242, + 28682836, 37748736, 49680132, 65382728, 86048512, 113246208, + 149040384, 196148192, 258145536 }; #define IVAS_TDET_DUCK_MULT_FAC_PARA_BIN ( 1073741824 ) // Q29 #define IVAS_TDET_DUCK_MULT_FAC_PARA_BIN_LOW_BR ( 1610612736 ) // Q29 + + /*------------------------------------------------------------------------------------------* * Local functions declaration *------------------------------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_vbap_fx.c b/lib_rend/ivas_vbap_fx.c index ec24a3362..fdbd4f530 100644 --- a/lib_rend/ivas_vbap_fx.c +++ b/lib_rend/ivas_vbap_fx.c @@ -33,13 +33,13 @@ #include #include "options.h" #include -#include #include "prot_fx.h" #include "ivas_prot_rend_fx.h" #include "ivas_stat_dec.h" #include "wmc_auto.h" #include "ivas_prot_fx.h" + /*-----------------------------------------------------------------------* * Local constants *-----------------------------------------------------------------------*/ diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index 1dd238afd..9519a0bb9 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -58,7 +58,6 @@ * Renderer structures *---------------------------------------------------------------------*/ -typedef float IVAS_REND_LfePanMtx[RENDERER_MAX_INPUT_LFE_CHANNELS][RENDERER_MAX_OUTPUT_CHANNELS]; typedef Word32 IVAS_REND_LfePanMtx_fx[RENDERER_MAX_INPUT_LFE_CHANNELS][RENDERER_MAX_OUTPUT_CHANNELS]; typedef struct diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index b70cdcadb..4bf93f011 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -33,7 +33,6 @@ #include "basop32.h" #include "basop_util.h" #include "options.h" -#include "cnst.h" #include "common_api_types.h" #include "enh32.h" #include "lib_rend.h" @@ -50,13 +49,13 @@ #include "stl.h" #include "typedef.h" #include -#include #include #include "wmc_auto.h" #ifdef DEBUGGING #include "debug.h" #endif + /*-------------------------------------------------------------------* * Local constants *-------------------------------------------------------------------*/ @@ -5931,6 +5930,17 @@ ivas_error IVAS_REND_SetReverbRoomSize( This function takes 2 gain vectors - one for the beginning and one for the end of the buffer. Gain values are lineraly interpolated for all samples in between. */ +#define NUM_SAMPLES_960 ( 960 ) +#define NUM_SAMPLES_720 ( 720 ) +#define NUM_SAMPLES_640 ( 640 ) +#define NUM_SAMPLES_320 ( 320 ) +#define NUM_SAMPLES_160 ( 160 ) +#define Q31_BY_NUM_SAMPLES_960 ( 2239294 ) /* 1/959 in Q31 */ +#define Q31_BY_NUM_SAMPLES_720 ( 2986764 ) /* 1/719 in Q31 */ +#define Q31_BY_NUM_SAMPLES_640 ( 3360694 ) /* 1/639 in Q31 */ +#define Q31_BY_NUM_SAMPLES_320 ( 6731924 ) /* 1/319 in Q31 */ +#define Q31_BY_NUM_SAMPLES_160 ( 13506186 ) /* 1/159 in Q31 */ + static void renderBufferChannelLerp_fx( const IVAS_REND_AudioBuffer inAudio, const Word32 inChannelIdx, diff --git a/lib_util/ambi_convert.c b/lib_util/ambi_convert.c index 6b506e7ed..713e88f60 100644 --- a/lib_util/ambi_convert.c +++ b/lib_util/ambi_convert.c @@ -59,6 +59,9 @@ #define INV_SQRT_8_OVER_5_Q29 424433728l /* 1.0f/INV_SQRT_8_OVER_5_Q29 */ #define INV_SQRT_45_OVER_32_Q29 452729280l /* 1.0f/SQRT_45_OVER_32_Q29 */ +#define MAX16B 32767 +#define MIN16B ( -32768 ) + /* -------------------------------- normalization conversion tables @@ -425,7 +428,7 @@ AMBI_CONVERT_ERROR renormalize_channels( Word64 tmp; tmp = W_mult0_32_32( (Word32) in[i_chan][i], conversion_factor ); /* tmp = W_add( tmp, ONE_OVER_2_Q29); */ /* rounding up */ - outval = W_extract_l( W_shr( tmp, Q29 ) ); + outval = W_extract_l( W_shr( tmp, 29 ) ); minval = L_min( minval, outval ); maxval = L_min( maxval, outval ); outval = L_min( MAX16B, L_max( MIN16B, outval ) ); /* saturation */ diff --git a/lib_util/ambi_convert.h b/lib_util/ambi_convert.h index cbb50af3f..95a447f15 100644 --- a/lib_util/ambi_convert.h +++ b/lib_util/ambi_convert.h @@ -33,11 +33,10 @@ #ifndef AMBI_CONVERT_H #define AMBI_CONVERT_H -#include "options.h" +#include "common_api_types.h" #include "stl.h" -#include "cnst.h" -#define AMBI_MAX_FRAME_LENGTH 960 /* 20ms at 48 kHz Sampling rate */ +#define AMBI_MAX_FRAME_LENGTH IVAS_MAX_FRAME_SIZE /* = 960 == 20ms at 48 kHz Sampling rate */ #define AMBI_MAX_CHANNELS 16 typedef enum diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index 0a23a6d7b..31fc024e9 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -48,11 +48,6 @@ #endif -#ifdef IVAS_RTPDUMP_ACOUSTIC_ENVIRONMENT -#include "cnst.h" -#include -#endif - #ifdef IVAS_RTPDUMP /* Generic PI data packing/unpacking functions */ @@ -71,6 +66,10 @@ static __inline int16_t readInt16( const uint8_t *buffer ) return (int16_t) ( (uint16_t) buffer[0] << 8 ) | ( (uint16_t) buffer[1] ); } +#define ONE_IN_Q22 4194304 +#define ONE_IN_Q26 67108864 +#define ONE_IN_Q30 1073741824 + /*-----------------------------------------------------------------------* * ivasPayload_convertToQ15() * @@ -417,7 +416,7 @@ static ivas_error unpackAcousticEnvironment( const uint8_t *buffer, uint32_t num aeEnv->roomDimensions.x_fx = (Word32) ( aeEnv->roomDimensions.x * ONE_IN_Q22 ); /* Q22 */ aeEnv->roomDimensions.y_fx = (Word32) ( aeEnv->roomDimensions.y * ONE_IN_Q22 ); aeEnv->roomDimensions.z_fx = (Word32) ( aeEnv->roomDimensions.z * ONE_IN_Q22 ); - aeEnv->roomDimensions.q_fact = Q22; + aeEnv->roomDimensions.q_fact = 22; aeEnv->absorbCoeffs_fx[IVAS_PI_AE_FRONT] = (Word32) ( aeEnv->absorbCoeffs[IVAS_PI_AE_FRONT] * ONE_IN_Q30 ); /* Q30 */ aeEnv->absorbCoeffs_fx[IVAS_PI_AE_BACK] = (Word32) ( aeEnv->absorbCoeffs[IVAS_PI_AE_BACK] * ONE_IN_Q30 ); -- GitLab From 17860a518c599ca091ee03d29551ffcf9de6aba6 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 27 Nov 2025 17:27:52 +0100 Subject: [PATCH 2/2] clang=format --- lib_util/ivas_rtp_pi_data.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index f137440d6..c521bd795 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -44,7 +44,6 @@ #endif - /* Generic PI data packing/unpacking functions */ typedef ivas_error ( *PACK_PI_FN )( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ); typedef ivas_error ( *UNPACK_PI_FN )( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ); -- GitLab