diff --git a/apps/renderer.c b/apps/renderer.c index 7137efd83570f6cf8da805c8c1745c1ee6805720..8e2254b5a70330e0b799907f10419848f7d8cd76 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -97,6 +97,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 320cac0810ca27cf11c07f3ba07a1195f3cb0600..03e9e1f64c42a9bed1fe0a1528f42b068070b80b 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,97 +2380,97 @@ 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 INV_LOG2_10 9864 /* 1/log2(10), 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 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 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 INV_LOG2_10 9864 /* 1/log2(10), 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 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 @@ -2817,186 +2479,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 /*----------------------------------------------------------------------------------* @@ -3051,67 +2714,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 3f6e181efb2154cf8fc2ce949321b0959c1dab90..567adeb6b06528b355800b2fb4870fa6cfdbee17 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 b4411fe50febb1c360e569c988fc2b04e206c903..4d496689a6731605a13c13f7a21463e1458eadc8 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -202,8 +202,6 @@ typedef enum #define EDIT_GAIN_MIN_Q12 258 /* Minimum allowed object gain edit with parametric modes in Q12: 0.0630957f, -24 dB */ #define EDIT_GAIN_MAX_Q12 16306 /* Maximum allowed object gain edit in Q12: 3.9810719f, +12 dB */ - - typedef enum { TC_BUFFER_MODE_RENDERER, @@ -642,9 +640,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)*/ @@ -815,7 +810,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 @@ -1263,7 +1257,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 */ @@ -1272,8 +1266,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, @@ -1356,6 +1349,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 @@ -1533,6 +1533,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 @@ -1590,8 +1594,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 ----- */ @@ -1836,6 +1840,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 9a8de3c1f055c1e3a119181c3c404a3a903242a7..422717f8e8db37d06a5cb04ca0be00173eafd107 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 cba992070911995e986aa23a6637d2802d189c5f..35a2cd4aa3ee53edcafb73ebfe5a3e5578bba4a1 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 f52d59859e7833964f125b0837b23a7d18c91dce..7519e9703d798fe9c19c9ce6b255a1b6cb565e56 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 c860b354e27a271e5a6384bde2e3e15f9512408e..2dcd8476b45a0c079fd1585889d8cbccbe34963e 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 ea276c944920f227648b8d0fccf79076571f0806..10c1f04b2c716dc7b534ce38a5553c2ce6d5899e 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 d515cc5fbc77ce306b43d6d8607a430a74c3f5b7..03b92a10ff26e1915be85548691c52a4037e5bf9 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 a293b629c189f7cedfff46ed6caf5e6b4213873d..fdd1bb97c9712613445febcef811a9d44b1fed28 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 9c706bc74a1dc6bfdeefea66b3835ef25fe0f2bd..f55e99153704d8e98e64e7726a5a0c3e531e1900 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 8201037a1a5f89eb53acb0e81787b0a87f68da5c..c04ded09c1ce8fedc0341313ec664c077735d15a 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 e3827c5685d146777de8975f73bd52b7b5791873..7cb186b583a5dfeebc34db2a5efbed21e46d39d9 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 1d07ab13356e8b5b418e841bd302a6dd002df1dd..d80d8a1561da6b2af4258d96149dd8cc480e4b38 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 1c1d4bf6cb6ca87def78b29f60c793547d2f3e4d..7bbf287ac356282574b6cbcf93b059ec898de8cf 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 79ce8443ace24e625bd32134f6817c56bd34b78c..2f81a95740cb0fece3ae4d04cfd4b7077b0b2b96 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 906277f54294d732a576187b64c798e8e375c836..f1a0a7609e9adff63897a8f26fc9f496bd54bd70 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 7d7c159b365ed4e89520a51b472381c25d7b7c8a..6a965850e2b521584bb630b39d13e441383b9460 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 bcc0c26f1317ae58ad3b105ed34120d462456be3..2a75593298e3aab395bb6fb9a77b93402fff7eea 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 f0ae9f8605f0da400355b3df2ce15ee083f64e3c..b9d4fba0d091baae38861ea0a189fc1e3fc83705 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 d399c6a660e352ebd6ad625d8d13753c88d432a0..199af90d3656641a0b68bc7bd1f0b654533034de 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 4caa22da2a0b258d80f3dcc3068db56af2c80911..7e1fac44b0d2c37097eec3c302e8ef45578e7f47 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 48be0cfd083000e5f134b7d50633a61a12d5ab67..57c4cd66e49a44ba58aaa2cbae80a0f0ebb3637e 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 afb639ef00c92528308d8e5ceabf7085007fd8c4..4b70d277a46af08f4c2ae44e98bb9934f31d7d16 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 8e84e4e374273d2b97988a01283fac18405d859d..7ea6feb059440e8f1f1f789fd492e140ad172bda 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 65a081c9c9884c49cda797f81a9889a55959c056..9bee290e642a86c5a91f9fc1d6d72faca30f5243 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 6d63bc6d1565160d0a3a3edb4f84b812077e882e..a23b5b700f1ed6478798e6e4e063496d674013f2 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 958781473910ff0f164ad50b9eb076fd3e0796e3..8328e220ff5eee94753aa6403ea2eb9f0a0a89f3 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 11f16d0a5fde3f8b3f14e48230b90860028650ce..8b5e1590867166e8952b4a399b722496e5183293 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 fe18e7bad6caea89ed7c019b09a57943b5499eeb..52933a5930a1461022e77deef6385f224ee83b2c 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 bc080f2f832a86c95ef4ee01a7b709ee6492da90..8cf54ec921780dad935de1e0c6a9abf36a03d82b 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 39dee9314d95f5acf0175589995418fc9918d52f..f7613a02356bf9cf3dda7706e7d7e4ef9b5d4545 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 c79ff60465cf7fc043aff2930846e853c02edde2..f1a40606b0b56ff98ca436fce7cac7c6b2bb65c4 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 c05ae96ef6279111db026a5dadff58fa2ce72045..18892a0d527981ebaf42e221c6e202849b229ddd 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 a196a1abdd8a157e472fdcf21913f8367fd42e63..eb6f6693f9db03a39b32165905ec2db17bbd2bfe 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 3ed7f6d88b1fac9aec549423c74a0999115fcb0f..1ac6d5bbf2d7eebde4d4d5a3b96428792b8a520f 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 37aa3747fc9d96f7d6300e0ec52cb1f1fe3fd72f..128373154e684d8bd1d8e39be3bd96dfbd26aac4 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 7a134d59bed246fc942c44990d849f1ae34fed71..8e94de138d99f5eb9f8059fea4f9fdd435581d82 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 9ddcfe4e564a8edac2744eb5b095e1ac07dc2a4e..14ec08659fb52955f87c2bba140556ebdf6001e7 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 c53f66138f70e7fa4e7d1786cdeb82a25652a8e9..7d389ec0f2797cbda3cf0f3baf069077cad11cee 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 de5d9e4707eb619e10ff2e38fbdc54431f34d629..710e881c9a86c5e31ac71067e2488b2c1dcaaa8d 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" @@ -111,7 +109,7 @@ ivas_error ivas_dec_get_format_fx( Word16 nchan_ism, element_mode_flag; Word16 sba_order, sba_planar, sba_analysis_order; Word32 ivas_total_brate; - int16_t Opt_tsm; + Word16 Opt_tsm; UWord16 *bit_stream_orig; AUDIO_CONFIG signaled_config; diff --git a/lib_dec/ivas_ism_dtx_dec_fx.c b/lib_dec/ivas_ism_dtx_dec_fx.c index 19d99a0bb1fe277e13efc6485f7230bb235ffcba..162cc42ed5ac60975c925ba61789c1846d45fefd 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 a193cba2efce288879215194b4ab1c2b75272f97..10aaa02bdb8293bab76a02d37fc56fb512dc5ee6 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 a342481a0ce8492aca79d7fe2bfdd4a66cfa32de..854fd8d981db120c9701be7d483f267922649f0e 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 2e2a257a11a96837fc296c79ea672c18ac0cc540..beee3ee1a84ac7b37bf63fb7ada55f0bf9fdceeb 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 c968e81b843a93e29e9f04f4a6a2977b87e34a57..68852530a15b733140fb079048b2410cdb329eae 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 74d8de662ea8aadd99c86363b514d42e8164fe1e..a4ead694667086f97ab213f1632273667f969d0d 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 ac6da67598a31774ff7531ede0ba5a9052886a02..b50fe21202c769645c6309f6a57e978464698fdc 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 b41036a5d6cfa4016b10116de0e2983b1ef7a529..fd9eda8fbb54db2add348960c9c4bda7d68b0d58 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 478a4d00d1579ae7e5504072b4bf5457c3af6db5..43937a0779c6b797d18a0698b14049f0dbbc2267 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 889a7b37829ffa2da94079ee20848198f8c53f1d..833947efd1bc7e6d7d90fdc3faa0f2d1a817e814 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 f96a20126250b065cfcc5d50b404ae4c780ba283..5f764533ade6a84ef4377ec59f516637d4a3952c 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 b88d95b18e324ebcdc056424793aa0d103634f84..3b2c60277eafb280e2a3ffbfe5b0caae8f7fe769 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 695051171fc29c24d3f1fe0fbc5f8a150733cad0..41fed3e0c0f7590fabdf779da3e4a3e33d3da6fe 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 6c64eee816fc5cfbb4db6c676a09e080e004d4bc..d08105470866333d56f9d99cf1bb283db04eb3d8 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 069e2c0eb4e1f730aa4208d8b385d13af8949eaf..428c6512ec2a3701d18263b831906708cd205d81 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 8b691a2794e418f350d4b8589e264b5e9efb4fa6..cc6117d43be2380a66a47579810fcd2bb3f674dc 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 339d6eb4b4642e1872c3f790ce9370cac9e52898..01f78da0528e18afe57b139d016211ac36746172 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 98611ab7cbcf9af52799eb55c91a6353ee726624..fc531c34deee6c308cca7c0ffbe211a7cd093995 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 f3254c4a547fa0f2d626ae87fe07da8b67067c98..02be03d21234b92da0b72f18bf5b97b28ece6f40 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 cc98c6ec494fba2b1fd1895bfb3e35de277421ce..261133d93088ff97e411f3751e199036b3cd6029 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 9a49680e874a2d665b7ba37e3e0c2c47334cc18a..7b6d428dbd007cdfd7f683333a67978f58e530ca 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 016335004b15655502a26eb2dca58deba1031052..3209278ed91737364e8355d988bc7be9a738c110 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 c4a1b0de109f168d1d6bdd22b9b9c2a4c7f0999b..90cca685536a087a41f21ac3207506ca4befa4e4 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 42a2524f1f6676a2f216159767685da2dbb0d4ae..0c380ea5cde44f3cbe054d3f1f14f1a9c6bee200 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 d9f7b26be0676b936f9d11c681b3001ed0332488..552b478d2fde281b98df6812cc4b75ba2a6051a3 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 77c53c5ef63d18306328a6c065a495908be58b4f..a889c505d8edc37f4147d4221f9690541477120b 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 05bf47cb98fcd38164633d75a1c62cb1beb5c214..0425cb7ac3196ab29e2129de09d67a9573dd42ab 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 864d0543821e666566163296335a36ffc999ea3b..7cb1297a7231e3a64544d95585a8f318af57eca4 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 248518134d1350dcc9022a80e7571d11a9c2033e..64c4375a5be4edc008f1a579f6e20a65bfe9d35d 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 124f89c5a12d3023a9aced6b273c902cc46bdf5c..2a652a573a35955595dde411016a5fb48bac7998 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 9b166c41a74204592214c56e42110a7c5ed592f2..32321454c9df7b60a31ac24c550328c5483648b5 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 625606678420527cd9d8340dce81de8872368578..046ac1042db502b6a16ffe20c6bcc5981f8675a7 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 6e4af32e5c6a1b0f13468ba98046cc7eafdfcc70..5eb94868e0a346f88b119d725260002515377645 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 96458c4f2e01a7822dfa22552a5447ec66c1b988..069f42bca2f078cee81a432d8aabfc43ca68bebd 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 647ad6e77f1ccb7f3a374f2a1fc804310a77a8b5..8cf565a5e5d6904a30e33fc3ab1dca27bcf7a038 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 4d5996bb6db4a85e1a527987c0b1da2e27f29473..d8c1ad18fc989a67a13eed14b9c1167384b32a47 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 1a639a3d7d4e79b5324f22361a7b1c97b31a5409..6808f056b6368e9a483af3e5fd6858e67019eaf4 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 237b5f9d5fac4fbf400b6cf7ef51d5d1fc58d5d7..a830980eb0bce96106dec12a2bc0c54ee6bf8511 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 ec135d7a0d634cef179b28bad1fe8fe4c4d6bded..0c91bd3c471142d49a89c3a963a4aaaf4929b5a4 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 d6811d2df5e53d7d48594daa858eefb15ef8dcd7..b7a0eaedfdaf03b493e01d1aebc78ff234b706be 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 d721d426aead1e2c24555a9535a4c0e3c59ad0ba..8ea1f4b54f55f4bcfaf94182bb44839d26f3ad9e 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 32b5b3f87d609a93a90e3c797645bf71f6f9b88d..8ed51cdab548697726070c48fe96262991bc444a 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 7954afd6905c9883c97087679645df5cd5e54354..ab4ccedc188e46b3624ad7fa1be0fec70b67aaf3 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -42,7 +42,6 @@ #include "jbm_pcmdsp_apa.h" #include "jbm_pcmdsp_fifo.h" #include "ivas_rtp_pi_data.h" -#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 ba09a659407b4a72e66fd6d7d7d62fca96c19229..bdbc32fec52c796dd776d963b7e3c080382baba1 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 d9d7c052585e634e0c97b1af28d8299bd8ae0f21..6c55e8b3114e4c40832bca74d7fe64226985b5fc 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 10d7cb8c71c2b736bc7fa24bbd467bed6f7dc94b..e5af93e39f2e1af6eac36e3085b4594a2e3fa837 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 96bbca887782fdb1e711c4ff9ae0b289ab940d66..2ee800325cef8975c0e7de509bf72419d0120ab9 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 d62fa49c181ebc85fddb0e74f850d3f1625d405a..f6aa5e904c6fdf12012cee93b4f2f7688a1681a0 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 cb5c157152f8b385d2db17db4f8dd8966a9fb57f..7ba122dbd3cc9a5332a60166bf29f17f8d9f54d7 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 a277c965bd63c9be6a5831cb589586b51c10fcc6..2efae00e2752c4c7100add8f563723bd078a33e3 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 c5eb5c67d0915dbec1a231934bb0e631b7d7ca16..43a524db56fa8651f14633ae92009ab8d2b327e8 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 42e2f446ef539a3105237d0597f67c086fd7cb42..17704e9bf604df17326cac07512bd874ce7012cb 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 0264a21994e7f06d2d79bece1d4c19210d8d1858..e9fd937238db6cc1919d3cc0c01842807d3f0243 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 34c6c320fcf380d3041a5c8344c9934a95a0e986..b206d8f8d338cb99a094ae8838200b6fc205df60 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 3c8cf92e2f2ef39cf45042599aa58217fad99328..ddd4df2de366405d8c491885750d5f06f600ea17 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 35400f652ca47ba8e9f04a4e195a6af7edad38f1..6f1f7f5bfe08574448462ad21f9bb0e2a437de20 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 3474b218bd411a2b07bd60a923f32d95a6260c5c..72f362fd709140f94a7bd8d223cdd60484a0b0af 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 e685566645353a7d5f81aa4b460be74ecaf11502..65d6452dae72254f0e10607fd6485f052ef09426 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 47da31a1ab0c03b5be9d96ed9d931e6e55ee11c1..c2109877446cc8638fa9709bbe186515585baae5 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 96959c9dd46fe0d60f391fcbb4c5da5f0e2d3f50..6261bb39e47dd0125476d63c89e83e3d20aac26f 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 5613866ccc57e63116e7c224fcdfba71db62d480..cb3b6e563b9c9f7e80642f4602afce5f54bd78fc 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 67353a279874abd481163efd96eeaadc75d37759..0c4073fc0b8f9e746e6a5fdd945f4790aab78098 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 0e8c845e145f04160a57bf7442cb56b6a4251643..7e9af16a369c5fabc7b4d40a98ab58eafc2021ed 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 9bbf1260c8ed61e487b4b01a99eb6c38ebaea869..d4fd50dbf1c919f7b55c1deee5c85a602756b8c6 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 39735ad030624045c49913f5a43e4c28e5f070b0..88e88a865b62de4d5faa6b037977603a83f519d9 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 d402d834f9fa1b5dcbd409f5902e09c25ee907da..de906bde1797f3dc1c52b87ad4fcde1c827430c9 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 b4eba62010700dd4e91a3944c7a4f0b6b936d6f9..81d8757e094da671c72d52683107926f204c1ee8 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 1311181dd78594bc9cfdcd78ed66741994668fd5..4a620db480f7bb2e4839f6458c3cd48f1443dda0 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 3629b856285ae840e4540f4f21685b290e1d624c..5f0ec331941e39284232c4a1aa8c995c1300634d 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 7eb4f18e71e4fc428d47427a68b9349633fd6667..e9fbfac46c4d20092bfa3b1cd924ade1f8f39f4a 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 3f18527746af83315451c5160e22d3e48c496f38..4753e5276f51f34644e69b2c03248b5854abab5e 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 3f17a423e7025e5e4e34de78a2d49c3f5305a7e1..09d61c6102e2c9beb332d777981d53cce8f21315 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 6c322a3d953bfa19abc3df4d0196203117d76867..949625722de05a1889375fb246877336268cf13a 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 1b7bed2106883a12aa346153477f04f065a94988..671e20a001473a6d88d56c5d439e7b1415f6dd91 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 e630a70d954f4e5764dba5b446df8b125884a346..574d10f966682a705c27b3301f7242bd9d58529a 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 fa58f267479a7a380618fd19f7063b0541fa3d30..2457fef6eaecb5a07271b118889a33d89a4fdf15 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 0e3c0bd405c51fedc3cdc397b35271b23f445391..0beb13759652c16f736a796bea6b6f172ff7796a 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 cb02abe16b2a64aee428d18c1deb79e6506d432b..14ea72446371b0ab7104504de159f52a7cc09a35 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 be07b38cbc7a47018b4e88b3523129d0661bf154..f5cc2ba8000856f43e00a17ded721113f4d2fef2 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 8e79b228875469ea0b56b50d505f7e59771346eb..3e4a5040dc006f73e6d1533d131d4222fe1d9d6d 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 2c1bc0317099125735d2d30683f03a2b4ff13592..88469e8182c8f04f2c75233c6e403279bd519f5d 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 b73a57f4690c86d566eb94bd7dadab969789f193..929d35b91d39dadfab3751eda40d38bc2e75f8ac 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 e5522fb377bf0ab53db392a8fae7c58230c46efa..3a0e19bb49a8b9aa276e9a258482aa9881e435f4 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 eb23e9d01862638d7789f34c293a2818b55ecdb9..09d5f0c91dd3dac7f1f4a11d4913d45881beb5e2 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 2c044625c9afe432e74c86ab81a9ddde7ce46d14..94a57b036412eba63005d00fae7964fc7985f6f2 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 d68976482a1c46f12c4eabeadb372a05cb60cf62..3689306bc8879b695f27251012c3f5687f02e4f2 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 a09daffe033c27d824800c93d8e8855231389091..05f9dc80d367a56ac6557607e4f56d3b4d7891cf 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 924de4d6595451430d5ab5a91f8c5a96fbd444fa..32d70a8b7159f96d03a80bc5488d321083a97f14 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 f6bf1a0999fecbf98301544fcca9ad8bb4e2f04d..2d6c17d9f84004d786d687199be8edc8c4a65b29 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 6bb6af1b3e249e69e1fa681a5250b752bf1095ac..e764649df8fd6a67d409b5185f0cb3fb8e977b91 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 d22e1b885b7791d5cdadd3e62de61d00262b0588..39f4f41494a3059231d215869c12d81abf31b59a 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 d53eb365d3dcca44ca72231143fec4127c002df0..055e22593242ee6869447b4636d4f9c887ddf567 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 c6fc59283718c838d40673904eceecad903811ad..107fb9681e09f49eea06b087308350d856ef8d6d 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 ab28f7f7e4e64c63a8d86c43f1751a5cbc9dd921..1eff3cd9e6aa17b991f185acc8186231bf9b7e8a 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 bad9370b4c7ec575732abc5572af095b14e87bd3..029537a4e2fbb643f7fe301a6d2152b0624fbf4d 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 8538f95d1c00e395975a3e95c2a409751952e513..95e52bc694249b1e1adf0fd8769b0991fac17c52 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 21fa7131243fcfef33162a6c624179eb68126900..8947bfb64903b670a123181f4939383d1a9ce04a 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 eaf16ab5c97e028fc40c813a6299e0e10720388a..f7d05ce2cb04731a7e899bcdc3b334daabe21689 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 fca0200f0bd3e05bd6c9160b6bfd35c1204fb704..81c9b43a6e2efb1dc91b2515e33e829771e51f42 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 40d6c393857ee28145728999a52dfded680ec8db..f666b453e8543423494b9603d6b496b800684f5a 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 954d89f639892eb743b15adc3dc29aac4e70c91f..5591fbb3a47fd96c1c81594c9c149872c6808fc0 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 5023bee34db1aafdbf965096cbbc3722f62ec191..a93f3092af492522705e319692149d37264176a6 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 6a3ee58ddcbbdb7d4a5206537c25c6ddd11a3ddd..c9fde3217600cf844103b708f26085a18ee29c21 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 9c3379527d84ee278052b0ce8099af94674a623c..5084ef1383e6f279b656537b790ea6d6237c83c8 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 b57f312be7a69650d27351fdbce66b543da2b583..a1a4baf8e69b6fcf16569d83bd1a533393a198a7 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 acbfb3bd2a5ca36e8b63b3ea9959d4c26272d66d..a4f703a28fdc0344b2c5c351e53dbb496247d7c0 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 80adebfdd18661e0160e31f6c753bfd60cd6930a..1e105ba223cb2607df3ecc8acd35e720ed9675b5 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 29184695ce35ebc52a47cfc9f626e504e1ca7f34..de25c56e5a6bbc074faaefc5bd2d7e103bca66ca 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 bde35181ee7c12d7d3da54a92c1be9e4cb051725..83ce8af453f5bff58ee24f6600117c887f39e919 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 23ffbe0bd17bffb0c2f17d128bac4ba46e9325d4..c85d89b8570ad56859b63f31fa73d2c8394146ec 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 6837a3e1ab982dc9031114b938ffdfe476dd82c4..bb2cd94c2fdb7273e5941e7691ef9aa0f63e86dc 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" @@ -40,6 +38,7 @@ #include "ivas_rom_com.h" #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 a6d9968406ddb669983ddd5a487fd76a7e4d99f8..b2a4e0d0066593cc3fbdbe466307f6db441a84cc 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 dd99c0070055fe74b7b4d7a45cb0d31a37d98cd7..658ff6b0f349cbdbcce2555f75679d211554ea7f 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 2a67d7a39a5277407bf20b818de4324978ac5b66..00036a8cd89d35f1316602185ca407744715534e 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 361cc403d19ccad22d98321d5b7c5da190877b9d..185cba09e42f81bfff0510c7ca37991a318890ca 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 33c519c8eb5f931bcb7f01f69f2e5ff463239ff1..015d227a216074730dbae380211acc9e1235deb0 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 140861539307a16b008dcd1fc0a29922d844c8b6..ded14eb095d07107379005d5d8ff3ff660105e6a 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 b95f5500df00136594444fc6f98909eb248c5c35..b1405a309551dfaa568a0866f5b8f209104ee581 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,6 +40,7 @@ #include "ivas_rom_com.h" #include "wmc_auto.h" + /*------------------------------------------------------------------------- * Local function prototypes *------------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_orient_trk_fx.c b/lib_rend/ivas_orient_trk_fx.c index ee91e7060e252c6d06e9827ba3f2e5d353710038..201f5a826fb1948701ecad7b0d5887ca1bd6624f 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 3bf9f71693b040f72bdd32bf21cdd60853a4b8f6..c342d5ca29660dc52269aa7b2ca6034ef4ca8b7f 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 d2a6a0c44e2c825c0e31dfb09dca6aeb337d502c..5e7b206c8d8cb22a0f8cd6bf367393e26065c634 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 b7f890ec39673d50daea8655d5a4bad9462be7e3..6453b32d7a4ab42d0714d8cf433f9b313643934f 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 e826596ba7b686df5683cee85499ded94bbf2265..3b896a137de40fce2f883d5d070cacc59cbb1250 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 6ab0c7a6355243b49f77be91ab4511707aec6c93..ba4159ba8271d76af1f572c15086821321fdf3c3 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 981a40466474a3b428557c4682243db0234cb885..f4f0cf51629086fb0e98f3194be49a07502caf5c 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 6433da8195e7deba7874d9b3b325bf6cc9b350f2..52cb0f1306b0060bf96c5a022aef3417a7832edc 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 ed4ece7b68432695c1a93c241c62a93bc2733b81..f3d675a99248ccb534ab3349ee01b6061eb0e5d7 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 531c45f83ff655c5775f70eada06f56194777f4d..954ae2759f6dd71316afa07963dc5fb8d85bced0 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 f7ecc3ddac87b8bdca88e061df55392e678b1d77..30746b3d87b02a9c1f54d5a2e4466e29afd7b04d 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 3357eaeb870713885171a0cf4246d69078168189..3c090f204bc6164868918aa7dbb2f1b79a53b5bb 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 4536b7b91f6a673038fc62c8ed8bab9211d3bc68..acdfd60c52a0d8c0c1d57d0a82c5cade19d20042 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" @@ -720,7 +719,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: @@ -857,7 +856,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 ff077e63ebe85d22865a09c14b7d8548f9826f49..c60e68090ed680ab388028c91352c585b1d59760 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 36af55838b6dcbb024b46d75b7bfaf320a90ebc8..631e5351e2cd01a72e3463b7893ad0e6e3df0b81 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 d84a00a1b9f3b9fb2dd2b5b3c9784d24fecd0043..a113298e809dc345fb96ae24e6ce8f6e3ad6e9f8 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 14795da41b11854851fec67f7a8b67321ef0c517..4f51a8b5f9dce089de95ace0a0de5eb72db1f5f1 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 ec24a33628bdabc5d80a5e854501304680790682..fdbd4f530274a9f4e83feb05b871101bead1ba76 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 84dc763f26476304e25890f5575e3c473989c10e..eed9d39462306e04a76af48d7268c29e102ed3fd 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 d45c79be014aa3f2fe0a777f8556ea48ea555328..37f927e049665e3276af1da24fb11ae6a1d7568d 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 *-------------------------------------------------------------------*/ @@ -5898,6 +5897,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 6b506e7edaeaaa4b559701d065c904e2e48d42a4..713e88f605dd45ed52b53bcdaa9c1ca6b8a5012f 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 cbb50af3fb2f999074cf067aadbc7c959b821bb5..95a447f151a6b54f8eff93424fa29548a77a050d 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 cea96e44144b59652fc7aed3931b6e717cd4ef8f..c521bd795a5472e7961a722f6e9f8256a14eadcb 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -44,10 +44,6 @@ #endif -#include "cnst.h" -#include - - /* 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 ); @@ -64,6 +60,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() * @@ -500,7 +500,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 );