diff --git a/apps/renderer.c b/apps/renderer.c index 70e68c757d73716e18d248822b1f7dfc1b1f39d7..afaa180af9e7943db51f01eef7dcc4ba567472c5 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -87,11 +87,6 @@ static #define SEP_FOLDER '/' #endif -#ifndef _WIN32 -#define max( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) ) -#define min( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) ) -#endif - /*------------------------------------------------------------------------------------------* * Local structures @@ -660,8 +655,8 @@ static void setupWithSingleFormatInput( /* It is allowed on CLI to have no metadata for an ISM input - skip opening if string contains "NULL" */ char charBuf[FILENAME_MAX]; - strncpy( charBuf, args.inMetadataFilePaths[i], min( FILENAME_MAX, RENDERER_MAX_CLI_ARG_LENGTH ) - 1 ); - charBuf[min( FILENAME_MAX, RENDERER_MAX_CLI_ARG_LENGTH ) - 1] = '\0'; + strncpy( charBuf, args.inMetadataFilePaths[i], RENDERER_MAX_CLI_ARG_LENGTH - 1 ); + charBuf[RENDERER_MAX_CLI_ARG_LENGTH - 1] = '\0'; to_upper( charBuf ); if ( strncmp( charBuf, "NULL", 4 ) == 0 ) { diff --git a/lib_com/ari_hm_fx.c b/lib_com/ari_hm_fx.c index 87af1a8ebb95c0ef339d7724f96f7cff829d4b42..e35416e5ff223ad28cf3713e3fac1f745df2aee0 100644 --- a/lib_com/ari_hm_fx.c +++ b/lib_com/ari_hm_fx.c @@ -2,7 +2,6 @@ EVS Codec 3GPP TS26.452 Nov 04, 2021. Version 16.4.0 ====================================================================================*/ - #include #include #include "options.h" @@ -11,7 +10,7 @@ #include "rom_com.h" #include "prot_fx.h" -#define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) ) + void UnmapIndex( const Word16 PeriodicityIndex, /* Q0 */ const Word16 Bandwidth, /* Q0 */ diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 036602ddc50f5d9ecea8441809c8c3cfc56a794a..43c20a27a4c7015360831afeb1b5b08241d8e347 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -985,6 +985,9 @@ enum * TCX constants *---------------------------------------------------------------*/ +#define TCX_IMDCT_SCALE 15 +#define TCX_IMDCT_HEADROOM 1 + #define NBITS_TCX_GAIN 7 #define NOISE_FILL_RANGES 1 diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index ae44138e89d8659c0d39bdbd961f903624f09689..8af9b0247f6026667ae0ad3d600221c4f2b1b83b 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -561,7 +561,7 @@ typedef enum #define STEREO_DFT_ITD_FS 32000 #define STEREO_DFT_ITD_MAX 160 /*samples @ 32000*/ #define STEREO_DFT_ITD_MAX_ANA 200 -#define STEREO_DFT_ITD_MIN max( STEREO_DFT_ITD_MAX - 256 + 1, 1 ) /*STEREO_DFT_ITD_MAX-pow(2,STEREO_DFT_ITD_NBITS-1)+1*/ +#define STEREO_DFT_ITD_MIN 1 /* == max( STEREO_DFT_ITD_MAX - pow(2,STEREO_DFT_ITD_NBITS-1) + 1, 1 )*/ #define STEREO_DFT_ITD_NBITS 9 /* 1 bit for sign, the rest for the absolute value*/ #define STEREO_DFT_ITD_MODE_NBITS 1 diff --git a/lib_com/ivas_rotation_com_fx.c b/lib_com/ivas_rotation_com_fx.c index 199af90d3656641a0b68bc7bd1f0b654533034de..2377e272be6439d7e752af9411756d9b12889cd6 100644 --- a/lib_com/ivas_rotation_com_fx.c +++ b/lib_com/ivas_rotation_com_fx.c @@ -200,7 +200,7 @@ void Quat2EulerDegree_fx( Word32 tmp8 = W_extract_l( W_shr( W_mult0_32_32( quat.w_fx, quat.y_fx ), Q22 ) ); // Q22 Word32 tmp9 = W_extract_l( W_shr( W_mult0_32_32( quat.z_fx, quat.x_fx ), Q22 ) ); // Q22 p_fx = L_shl( L_sub( tmp8, tmp9 ), 1 ); - p_fx = max( L_negate( ONE_IN_Q22 ), min( ONE_IN_Q22, p_fx ) ); // Q22 + p_fx = L_max( L_negate( ONE_IN_Q22 ), L_min( ONE_IN_Q22, p_fx ) ); // Q22 Word32 p_fx_sq = W_extract_l( W_shr( W_mult0_32_32( p_fx, p_fx ), Q22 ) ); Word16 res_exp = 0; diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c index 4b70d277a46af08f4c2ae44e98bb9934f31d7d16..6ca8fcc3f346b7c600929a330b7024219f70342d 100644 --- a/lib_com/ivas_spar_com_fx.c +++ b/lib_com/ivas_spar_com_fx.c @@ -3843,7 +3843,8 @@ void ivas_get_spar_md_from_dirac_enc_fx( Word32 **ppMixer_mat_fx[IVAS_MAX_FB_MIXER_OUT_CH]; Word32 *pMixer_mat_fx[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH]; Word16 q_ppMixer_mat = 0; - Word32 en_ratio_fac_fx, diff_norm_order1_fx, diff_norm_order2_fx, diff_norm_order3_fx; + Word32 en_ratio_fac_fx; + Word16 diff_norm_order1_fx, diff_norm_order2_fx, diff_norm_order3_fx; Word16 active_w; move16(); move16(); @@ -3862,11 +3863,11 @@ void ivas_get_spar_md_from_dirac_enc_fx( foa_ch = FOA_CHANNELS; move16(); diff_norm_order1_fx = 3; - move32(); + move16(); diff_norm_order2_fx = 5; - move32(); + move16(); diff_norm_order3_fx = 7; - move32(); + move16(); FOR( i = 0; i < IVAS_MAX_FB_MIXER_OUT_CH; i++ ) { @@ -3898,7 +3899,7 @@ void ivas_get_spar_md_from_dirac_enc_fx( P_norm_fx[0] = L_add( P_norm_fx[0], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31 move32(); } - P_norm_fx[0] = Mpy_32_32( L_shl( P_norm_fx[0], 3 ), diff_norm_order1_table[min( diff_norm_order1_fx, max( 0, sub( foa_ch, ndm ) ) )] ); // 2*q_P_re - 31 + P_norm_fx[0] = Mpy_32_32( L_shl( P_norm_fx[0], 3 ), diff_norm_order1_table[s_min( diff_norm_order1_fx, s_max( 0, sub( foa_ch, ndm ) ) )] ); // 2*q_P_re - 31 move32(); P_norm_fx[1] = 0; @@ -3909,7 +3910,7 @@ void ivas_get_spar_md_from_dirac_enc_fx( P_norm_fx[1] = L_add( P_norm_fx[1], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31 move32(); } - P_norm_fx[1] = Mpy_32_32( L_shl( P_norm_fx[1], 3 ), diff_norm_order2_table[min( diff_norm_order2_fx, max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ) )] ); // 2*q_P_re - 31 + P_norm_fx[1] = Mpy_32_32( L_shl( P_norm_fx[1], 3 ), diff_norm_order2_table[s_min( diff_norm_order2_fx, s_max( 0, ( s_min( num_ch, hoa2_ch ) - ndm ) ) )] ); // 2*q_P_re - 31 move32(); P_norm_fx[2] = 0; @@ -3919,7 +3920,7 @@ void ivas_get_spar_md_from_dirac_enc_fx( P_norm_fx[2] = L_add( P_norm_fx[2], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31 move32(); } - P_norm_fx[2] = Mpy_32_32( L_shl( P_norm_fx[2], 3 ), diff_norm_order3_table[min( diff_norm_order3_fx, max( 0, ( num_ch - ndm ) ) )] ); // 2*q_P_re - 31 + P_norm_fx[2] = Mpy_32_32( L_shl( P_norm_fx[2], 3 ), diff_norm_order3_table[s_min( diff_norm_order3_fx, s_max( 0, ( num_ch - ndm ) ) )] ); // 2*q_P_re - 31 move32(); len = s_max( 0, sub( foa_ch, ndm ) ); FOR( i = 0; i < len; i++ ) // i < max( 0, ( foa_ch - ndm ) ) @@ -4291,7 +4292,8 @@ void ivas_get_spar_md_from_dirac_fx( Word32 **ppMixer_mat_fx[IVAS_MAX_FB_MIXER_OUT_CH]; Word32 *pMixer_mat_fx[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH]; Word16 q_ppMixer_mat = 0; - Word32 en_ratio_fac_fx, diff_norm_order1_fx, diff_norm_order2_fx, diff_norm_order3_fx; + Word32 en_ratio_fac_fx; + Word16 diff_norm_order1_fx, diff_norm_order2_fx, diff_norm_order3_fx; Word16 active_w; move16(); move16(); @@ -4310,11 +4312,11 @@ void ivas_get_spar_md_from_dirac_fx( foa_ch = FOA_CHANNELS; move16(); diff_norm_order1_fx = 3; - move32(); + move16(); diff_norm_order2_fx = 5; - move32(); + move16(); diff_norm_order3_fx = 7; - move32(); + move16(); FOR( i = 0; i < IVAS_MAX_FB_MIXER_OUT_CH; i++ ) { @@ -4346,7 +4348,7 @@ void ivas_get_spar_md_from_dirac_fx( P_norm_fx[0] = L_add( P_norm_fx[0], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31 move32(); } - P_norm_fx[0] = Mpy_32_32( L_shl( P_norm_fx[0], 3 ), diff_norm_order1_table[min( diff_norm_order1_fx, max( 0, sub( foa_ch, ndm ) ) )] ); // 2*q_P_re - 31 + P_norm_fx[0] = Mpy_32_32( L_shl( P_norm_fx[0], 3 ), diff_norm_order1_table[s_min( diff_norm_order1_fx, s_max( 0, sub( foa_ch, ndm ) ) )] ); // 2*q_P_re - 31 move32(); P_norm_fx[1] = 0; @@ -4357,7 +4359,7 @@ void ivas_get_spar_md_from_dirac_fx( P_norm_fx[1] = L_add( P_norm_fx[1], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31 move32(); } - P_norm_fx[1] = Mpy_32_32( L_shl( P_norm_fx[1], 3 ), diff_norm_order2_table[min( diff_norm_order2_fx, max( 0, ( min( num_ch, hoa2_ch ) - ndm ) ) )] ); // 2*q_P_re - 31 + P_norm_fx[1] = Mpy_32_32( L_shl( P_norm_fx[1], 3 ), diff_norm_order2_table[s_min( diff_norm_order2_fx, s_max( 0, ( s_min( num_ch, hoa2_ch ) - ndm ) ) )] ); // 2*q_P_re - 31 move32(); P_norm_fx[2] = 0; @@ -4367,7 +4369,7 @@ void ivas_get_spar_md_from_dirac_fx( P_norm_fx[2] = L_add( P_norm_fx[2], Mpy_32_32( hSpar_md->band_coeffs[start_band - 1].P_re_fx[i], hSpar_md->band_coeffs[start_band - 1].P_re_fx[i] ) ); // 2*q_P_re - 31 move32(); } - P_norm_fx[2] = Mpy_32_32( L_shl( P_norm_fx[2], 3 ), diff_norm_order3_table[min( diff_norm_order3_fx, max( 0, ( num_ch - ndm ) ) )] ); // 2*q_P_re - 31 + P_norm_fx[2] = Mpy_32_32( L_shl( P_norm_fx[2], 3 ), diff_norm_order3_table[s_min( diff_norm_order3_fx, s_max( 0, ( num_ch - ndm ) ) )] ); // 2*q_P_re - 31 move32(); len = s_max( 0, sub( foa_ch, ndm ) ); FOR( i = 0; i < len; i++ ) // i < max( 0, ( foa_ch - ndm ) ) diff --git a/lib_com/ivas_spar_com_quant_util_fx.c b/lib_com/ivas_spar_com_quant_util_fx.c index 7ea6feb059440e8f1f1f789fd492e140ad172bda..93a62acd2bd761c49589463e21c4ccf8170076b1 100644 --- a/lib_com/ivas_spar_com_quant_util_fx.c +++ b/lib_com/ivas_spar_com_quant_util_fx.c @@ -346,11 +346,11 @@ void ivas_map_prior_coeffs_quant( { ivas_quant_strat_t qs = pSpar_md_cfg->quant_strat[qsi]; ivas_quant_strat_t prev_qs = pSpar_md_cfg->quant_strat[pSpar_md_cfg->prev_quant_idx]; - Word32 one_by_q_lvl_PR_fx = one_by_q_level[max( ( prev_qs.PR.q_levels[0] - 1 ), 1 )]; /*q31*/ + Word32 one_by_q_lvl_PR_fx = one_by_q_level[s_max( ( prev_qs.PR.q_levels[0] - 1 ), 1 )]; /*q31*/ move32(); - Word32 one_by_q_lvl_C_fx = one_by_q_level[max( ( prev_qs.C.q_levels[0] - 1 ), 1 )]; /*q31*/ + Word32 one_by_q_lvl_C_fx = one_by_q_level[s_max( ( prev_qs.C.q_levels[0] - 1 ), 1 )]; /*q31*/ move32(); - Word32 one_by_q_lvl_P_r_fx = one_by_q_level[max( ( prev_qs.P_r.q_levels[0] - 1 ), 1 )]; /*q31*/ + Word32 one_by_q_lvl_P_r_fx = one_by_q_level[s_max( ( prev_qs.P_r.q_levels[0] - 1 ), 1 )]; /*q31*/ move32(); FOR( i = 0; i < nB; i++ ) { diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index 8cf54ec921780dad935de1e0c6a9abf36a03d82b..685508404b6e3ff3b83089b443ae4fbc99a08bad 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -605,7 +605,7 @@ void v_mult_mat_fx( pt_y++; } - MVR2R_WORD32( tmp_y, y, Nc ); /*Qx - guardbits*/ + Copy32( tmp_y, y, Nc ); /*Qx - guardbits*/ } diff --git a/lib_com/modif_fs_fx.c b/lib_com/modif_fs_fx.c index 9420d652307724fb98cc908441fc2e0b61a7e91e..97f4ef4135ba2434827ea79755800456d90043c7 100644 --- a/lib_com/modif_fs_fx.c +++ b/lib_com/modif_fs_fx.c @@ -168,7 +168,6 @@ Word16 modify_Fs_ivas_fx( /* o : length of output Q { autocorr_fx( signal_ana_fx + mem_len_ana + lg - LEN_WIN_SSS, 1, r_fx_h, r_fx_l, &Q_r, LEN_WIN_SSS, wind_sss_fx, 0, 0 ); - t1 = L_Comp( r_fx_h[1], r_fx_l[1] ); /* R[1] in Q31 */ t2 = L_abs( t1 ); /* abs R[1] */ t0 = L_deposit_l( 0 ); @@ -181,12 +180,10 @@ Word16 modify_Fs_ivas_fx( /* o : length of output Q t0 = L_negate( t0 ); /* R[1]/R[0] */ } - mu_preemph_fx = extract_h( t0 ); /*r_fx[1] / r_fx[0]; */ mem_preemph_fx = signal_ana_fx[mem_len_ana + lg - LEN_WIN_SSS - 1]; move16(); - PREEMPH_FX( signal_ana_fx + mem_len_ana + lg - LEN_WIN_SSS, mu_preemph_fx, LEN_WIN_SSS, &mem_preemph_fx ); - + preemph_fx( signal_ana_fx + mem_len_ana + lg - LEN_WIN_SSS, mu_preemph_fx, LEN_WIN_SSS, &mem_preemph_fx ); /* Autocorrelations */ autocorr_fx( signal_ana_fx + mem_len_ana + lg - LEN_WIN_SSS, M, r_fx_h, r_fx_l, &Q_r, @@ -449,7 +446,6 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */ { autocorr_fx( signal_ana_fx + sub( add( mem_len_ana, lg ), LEN_WIN_SSS ), 1, r_fx_h, r_fx_l, &Q_r, LEN_WIN_SSS, wind_sss_fx, 0, 0 ); - t1 = L_Comp( r_fx_h[1], r_fx_l[1] ); /* R[1] in Q31 */ t2 = L_abs( t1 ); /* abs R[1] */ t0 = L_deposit_l( 0 ); @@ -462,12 +458,10 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */ t0 = L_negate( t0 ); /* R[1]/R[0] */ } - mu_preemph_fx = extract_h( t0 ); /*r_fx[1] / r_fx[0]; */ mem_preemph_fx = signal_ana_fx[mem_len_ana + lg - LEN_WIN_SSS - 1]; move16(); - PREEMPH_FX( signal_ana_fx + sub( add( mem_len_ana, lg ), LEN_WIN_SSS ), mu_preemph_fx, LEN_WIN_SSS, &mem_preemph_fx ); - + preemph_fx( signal_ana_fx + sub( add( mem_len_ana, lg ), LEN_WIN_SSS ), mu_preemph_fx, LEN_WIN_SSS, &mem_preemph_fx ); /* Autocorrelations */ autocorr_fx( signal_ana_fx + sub( add( mem_len_ana, lg ), LEN_WIN_SSS ), M, r_fx_h, r_fx_l, &Q_r, diff --git a/lib_com/preemph_fx.c b/lib_com/preemph_fx.c index 9631c68596fe1934049cd1badd965b0801156e87..46c8ccc36b531cab8b599c1b576afde3c3b97a33 100644 --- a/lib_com/preemph_fx.c +++ b/lib_com/preemph_fx.c @@ -8,11 +8,44 @@ #include "wmc_auto.h" /*-------------------------------------------------------------* - * preemph_copy_fx() + * preemph_fx() * * Preemphasis: filtering through 1 - mu z^-1 *-------------------------------------------------------------*/ +void preemph_fx( + Word16 x[], /* i/o: input/output signal Qx */ + const Word16 mu, /* i : preemphasis coefficient Q15 */ + const Word16 lg, /* i : vector size Q0 */ + Word16 *mem /* i/o: memory (x[-1]) Qx */ +) +{ + Word16 i, temp; + + temp = x[lg - 1]; /* Qx */ + move16(); + + FOR( i = lg - 1; i > 0; i-- ) + { + x[i] = msu_r_sat( L_deposit_h( x[i] ), x[i - 1], mu ); /* Qx */ + move16(); + } + + x[0] = msu_r_sat( L_deposit_h( x[0] ), *mem, mu ); /* Qx */ + move16(); + + *mem = temp; /* Qx */ + move16(); + + return; +} + +/*-------------------------------------------------------------* + * preemph_copy_fx() + * + * Preemphasis + copy: filtering through 1 - mu z^-1 + *-------------------------------------------------------------*/ + void preemph_copy_fx( const Word16 x[], /* i : input signal Qx */ Word16 y[], /* o : output signal Qx */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index abb050c02ec7f9a2b17f7a25d946293ce351f86d..c62c8a8f0580e55b2fdf89893d929b61f12629e7 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -33,13 +33,6 @@ #ifndef PROT_FX2_H #define PROT_FX2_H -/*----------------------------------------------------------------------------------* - * Prototypes of RAM counting tool macros - *----------------------------------------------------------------------------------*/ - -#define MVR2R_WORD32( x, y, n ) Copy32( x, y, n ) -#define MVR2R_WORD16( x, y, n ) Copy( x, y, n ) - #include #include #include @@ -59,36 +52,19 @@ #include "complex_basop.h" -#define TCX_IMDCT_SCALE 15 -#define TCX_IMDCT_HEADROOM 1 - - /*----------------------------------------------------------------------------------* * Prototypes of global macros *----------------------------------------------------------------------------------*/ -#ifndef min -#define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) ) -#endif - -#ifndef max -#define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) ) -#endif - -#ifndef ABSVAL -#define ABSVAL( a ) ( ( a ) >= 0 ? ( a ) : ( -( a ) ) ) -#endif - -#ifndef SQR -#define SQR( a ) ( ( a ) * ( a ) ) -#endif - #ifndef SWAP #define SWAP( a, b ) \ { \ tempr = ( a ); \ ( a ) = ( b ); \ ( b ) = tempr; \ + move32(); \ + move32(); \ + move32(); \ } #endif @@ -99,6 +75,9 @@ u__p = x; \ x = y; \ y = u__p; \ + move32(); \ + move32(); \ + move32(); \ } #endif @@ -2699,9 +2678,12 @@ void lag_wind_32( Word16 strength /* input : LAGW_WEAK, LAGW_MEDIUM, or LAGW_STRONG */ ); -// preemp_fx.c -#define PREEMPH_FX( signal, mu, L, mem ) preemph_copy_fx( ( signal ), ( signal ), ( mu ), ( L ), ( mem ) ) -#define PREEMPH_32FX( signal, signal_out, mu, L, mem ) preemph_copy_32fx2( ( signal ), ( signal_out ), ( mu ), ( L ), ( mem ) ) +void preemph_fx( + Word16 x[], /* i/o: input/output signal Qx */ + const Word16 mu, /* i : preemphasis coefficient Q15 */ + const Word16 lg, /* i : vector size Q0 */ + Word16 *mem /* i/o: memory (x[-1]) Qx */ +); void preemph_copy_fx( const Word16 x[], /* i : i signal Qx */ @@ -9327,12 +9309,6 @@ void bpf_pitch_coherence_ivas_fx( const Word32 pitch_buf[] /* i : pitch for each subframe [0,1,2,3] */ ); -/* fft_rel.c */ - -#define SIZE_256 256 -#define NUM_STAGE_256 7 -#define SIZE2_256 ( SIZE_256 / 2 ) - void cldfbAnalysis_ivas_fx( const Word32 *timeIn_fx, /* i : time buffer Qx */ Word32 **realBuffer_fx, /* o : real value buffer Qx - 5*/ @@ -11327,7 +11303,8 @@ void UnmapIndex_fx( Word32 *Lag /* Q0 */ ); -#define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) ) +//#define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) ) +#define GET_ADJ2( T, L, F ) ( sub( shl( L, F ), T ) ) Word32 tcx_hm_render_fx( const Word32 lag, /* i: pitch lag Q0 */ diff --git a/lib_com/stat_noise_uv_mod_fx.c b/lib_com/stat_noise_uv_mod_fx.c index ad87695e831dd5092ddb9456261828e46ca5ec72..f9eff00b46a00ffabddadff7dfce83c498bd9802 100644 --- a/lib_com/stat_noise_uv_mod_fx.c +++ b/lib_com/stat_noise_uv_mod_fx.c @@ -158,7 +158,7 @@ void stat_noise_uv_mod_fx( { exctilt = calc_tilt_fx( &Exc2_local[i_subfr], En_shift, L_SUBFR ); /*Q15 */ exctilt = mult( shl_sat( sub( TILT_COMP_LIM_FX, min_alpha ), 2 ), exctilt ); /*Q15 */ - PREEMPH_FX( &Exc2_local[i_subfr], exctilt, L_SUBFR, exc_pe ); + preemph_fx( &Exc2_local[i_subfr], exctilt, L_SUBFR, exc_pe ); } } @@ -458,7 +458,7 @@ void stat_noise_uv_mod_ivas_fx( { exctilt = calc_tilt_fx( &Exc2_local[i_subfr], En_shift, L_SUBFR ); /*Q15 */ exctilt = mult( shl_sat( sub( TILT_COMP_LIM_FX, min_alpha ), 2 ), exctilt ); /*Q15 */ - PREEMPH_FX( &Exc2_local[i_subfr], exctilt, L_SUBFR, exc_pe ); + preemph_fx( &Exc2_local[i_subfr], exctilt, L_SUBFR, exc_pe ); } } diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 610b9cae0951e5c7147f633edb00726170b9347e..0ad2588f238d7e18092f3e45fe6993c50af42de2 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -2430,9 +2430,7 @@ prev_Q_bwe_exc_fb = *Q_bwe_exc_fb; move16(); *Q_bwe_exc_fb = sub( add( *Q_bwe_exc, Q_temp ), 13 ); move16(); -deemph_fx( White_exc16k, PREEMPH_FAC, L_FRAME16k, tbe_demph ); -/* i/o: White_exc16k (Q_bwe_exc-NOISE_QADJ) */ -/* i: tbe_demph (Q_bwe_exc-NOISE_QADJ) */ +deemph_fx( White_exc16k, PREEMPH_FAC, L_FRAME16k, tbe_demph ); // Q_bwe_exc-NOISE_QADJ { IF( EQ_16( coder_type, UNVOICED ) ) { @@ -2447,9 +2445,7 @@ deemph_fx( White_exc16k, PREEMPH_FAC, L_FRAME16k, tbe_demph ); move16(); /* exc16kWhtnd: Q_bwe_exc */ } - PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); - /* i/o: exc16kWhtnd (Q_bwe_exc) */ - /* i/o: tbe_premph (Q_bwe_exc) */ + preemph_fx( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); // Q_bwe_exc } ELSE { @@ -2529,9 +2525,7 @@ deemph_fx( White_exc16k, PREEMPH_FAC, L_FRAME16k, tbe_demph ); temp = div_s( temp, temp2 ); /* Q15 */ temp = mult_r( PREEMPH_FAC, temp ); - PREEMPH_FX( &exc16kWhtnd[i * lSubFr], temp, lSubFr, tbe_premph ); - /* exc16kWhtnd: Q_bwe_exc; - tbe_premph: Q_bwe_exc*/ + preemph_fx( &exc16kWhtnd[i * lSubFr], temp, lSubFr, tbe_premph ); // Q_bwe_exc } } } @@ -3404,8 +3398,8 @@ void GenShapedSHBExcitation_ivas_enc_fx( move16(); } } - // preemph(exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph); - PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); // Q_bwe_exc + + preemph_fx( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); // Q_bwe_exc } ELSE { @@ -3430,9 +3424,7 @@ void GenShapedSHBExcitation_ivas_enc_fx( Scale_sig( exc16kWhtnd, L_FRAME16k, sub( *Q_bwe_exc, Q_White_exc16k ) ); // Q_bwe_exc - PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); // Q_bwe_exc - /* i/o: exc16kWhtnd (Q_bwe_exc) */ - /* i/o: tbe_premph (Q_bwe_exc) */ + preemph_fx( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); // Q_bwe_exc } ELSE { @@ -3513,9 +3505,7 @@ void GenShapedSHBExcitation_ivas_enc_fx( temp = div_s( temp, temp2 ); /* Q15 */ temp = mult_r( PREEMPH_FAC, temp ); - PREEMPH_FX( &exc16kWhtnd[i * lSubFr], temp, lSubFr, tbe_premph ); // Q_bwe_exc - /* exc16kWhtnd: Q_bwe_exc; - tbe_premph: Q_bwe_exc*/ + preemph_fx( &exc16kWhtnd[i * lSubFr], temp, lSubFr, tbe_premph ); // Q_bwe_exc } } } @@ -4431,8 +4421,8 @@ void GenShapedSHBExcitation_ivas_dec_fx( move16(); } } - // preemph(exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph); - PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); + + preemph_fx( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); } ELSE { @@ -4452,9 +4442,7 @@ void GenShapedSHBExcitation_ivas_dec_fx( exc16kWhtnd[k] = mult_r_sat( White_exc16k[k], scale ); move16(); } - PREEMPH_FX( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); - /* i/o: exc16kWhtnd (Q_exc16kWhtnd) */ - /* i/o: tbe_premph (Q_exc16kWhtnd) */ + preemph_fx( exc16kWhtnd, PREEMPH_FAC, L_FRAME16k, tbe_premph ); // Q_exc16kWhtnd } ELSE { @@ -4534,9 +4522,7 @@ void GenShapedSHBExcitation_ivas_dec_fx( temp2 = add( temp, shl( temp1, -1 ) ); /* shift right by 1 to avoid overflow */ temp = div_s( temp, temp2 ); /* Q15 */ temp = mult_r( PREEMPH_FAC, temp ); - PREEMPH_FX( &exc16kWhtnd[i * lSubFr], temp, lSubFr, tbe_premph ); - /* exc16kWhtnd: Q_exc16kWhtnd; - tbe_premph: Q_exc16kWhtnd*/ + preemph_fx( &exc16kWhtnd[i * lSubFr], temp, lSubFr, tbe_premph ); // Q_exc16kWhtnd } } } diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index e163662c8d2a4a4f9b14b3103e64850f3146151c..dd89d78d58f637201501b3aee99fe5a4ff6f388b 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -968,7 +968,7 @@ ivas_error acelp_core_dec_fx( tmpF_fx = *old_exc_s_fx; st->mem_deemph_fx = shl_sat( old_exc_s_fx[st->L_frame - 1], st->Q_syn ); /* Q0 -> Q_syn */ move16(); - PREEMPH_FX( old_exc_s_fx, st->preemph_fac, st->L_frame, &tmpF_fx ); + preemph_fx( old_exc_s_fx, st->preemph_fac, st->L_frame, &tmpF_fx ); Copy( old_exc_s_fx + sub( st->L_frame, M ), st->mem_syn2_fx, M ); Scale_sig( st->mem_syn2_fx, M, st->Q_syn ); /* Q0 -> Q_syn */ Residu3_fx( Aq_fx, old_exc_s_fx, old_exc_fx + sub( L_EXC_MEM_DEC, st->L_frame ), st->L_frame, 0 ); diff --git a/lib_dec/dec_higher_acelp_fx.c b/lib_dec/dec_higher_acelp_fx.c index e6cc62e239e208d7f1c1dd6a225f7400570a57bc..5e02f9913af51236c2fd65bef4eb000879738288 100644 --- a/lib_dec/dec_higher_acelp_fx.c +++ b/lib_dec/dec_higher_acelp_fx.c @@ -197,7 +197,8 @@ void transf_cdbk_dec_fx( st_fx->last_code_preq = code_preQ[L_SUBFR - 1]; // q_Code_preQ move16(); - PREEMPH_FX( code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, &st_fx->mem_preemp_preQ_fx ); + preemph_fx( code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, &st_fx->mem_preemp_preQ_fx ); + /*--------------------------------------------------------------* * Compute normalized prequantizer excitation gain for FEC * diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index e7fec949230200a3fdbcccaff7a0d7fc188925e3..fba40748cd832d65b1b32a2a3ea0aac9ee6229a1 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -1838,11 +1838,11 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in FOR( tb = 0; tb < hopsize; tb++ ) { /* calculate of the current sfb width */ - width = sub( hGrid->swb_offset[min( sfb + tb + 1, stop_sfb )], /* 15Q0 | width is Q0 */ - hGrid->swb_offset[min( sfb + tb, stop_sfb )] ); + width = sub( hGrid->swb_offset[s_min( sfb + tb + 1, stop_sfb )], /* 15Q0 | width is Q0 */ + hGrid->swb_offset[s_min( sfb + tb, stop_sfb )] ); - tmp = dS[min( sfb + tb, stop_sfb - 1 )]; - tmp_e = dS_e[min( sfb + tb, stop_sfb - 1 )]; + tmp = dS[s_min( sfb + tb, stop_sfb - 1 )]; + tmp_e = dS_e[s_min( sfb + tb, stop_sfb - 1 )]; move16(); move16(); @@ -2507,11 +2507,11 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in FOR( tb = 0; tb < hopsize; tb++ ) { /* calculate of the current sfb width */ - width = sub( hGrid->swb_offset[min( sfb + tb + 1, stop_sfb )], /* 15Q0 | width is Q0 */ - hGrid->swb_offset[min( sfb + tb, stop_sfb )] ); + width = sub( hGrid->swb_offset[s_min( sfb + tb + 1, stop_sfb )], /* 15Q0 | width is Q0 */ + hGrid->swb_offset[s_min( sfb + tb, stop_sfb )] ); - tmp = dS[min( sfb + tb, stop_sfb - 1 )]; - tmp_e = dS_e[min( sfb + tb, stop_sfb - 1 )]; + tmp = dS[s_min( sfb + tb, stop_sfb - 1 )]; + tmp_e = dS_e[s_min( sfb + tb, stop_sfb - 1 )]; move16(); move16(); diff --git a/lib_dec/ivas_post_proc_fx.c b/lib_dec/ivas_post_proc_fx.c index 02be03d21234b92da0b72f18bf5b97b28ece6f40..b23cced7f0f9e77bcee8ad774aee9254e4e92353 100644 --- a/lib_dec/ivas_post_proc_fx.c +++ b/lib_dec/ivas_post_proc_fx.c @@ -584,7 +584,7 @@ void stereo_dft_dec_core_switching_fx( IF( EQ_16( st->core, TCX_20_CORE ) || EQ_16( st->core, TCX_10_CORE ) || EQ_16( st->core, HQ_CORE ) || ( EQ_16( st->bfi, 1 ) && EQ_16( st->core, ACELP_CORE ) && EQ_16( st->con_tcx, 1 ) ) ) { Word16 numZeros = (Word16) ( NS2SA_FX2( st->sr_core, N_ZERO_MDCT_NS ) ); /*Q0*/ - Word32 tmp_fade_fx[max( STEREO_DFT_ALLPASS_FADELEN_12k8, STEREO_DFT_ALLPASS_FADELEN_16k )]; + Word32 tmp_fade_fx[STEREO_DFT_ALLPASS_FADELEN_16k /*max( STEREO_DFT_ALLPASS_FADELEN_12k8, STEREO_DFT_ALLPASS_FADELEN_16k )*/]; Copy32( st->hHQ_core->old_out_LB_fx32 + numZeros, hCPE->hStereoDft->ap_fade_mem_fx, ap_fade_len ); /*st->hHQ_core->q_old_outLB_fx*/ hCPE->hStereoDft->q_ap_fade_mem_fx = st->hHQ_core->Q_old_out_fx32; diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 72527526a06700f007393df396a8c248fd2e1bb6..491dcca1ca7f1207f4019476d90a3b15f73de4e8 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -3766,8 +3766,11 @@ void stereo_dft_dec_sid_coh_fx( get_next_indice_fx( st, 1 ); ( *nb_bits )++; } + return; } + + void stereo_dft_dequantize_itd_fx( Word16 *ind, /* Q0 */ Word32 *out_fx, /* Q15 */ @@ -3784,13 +3787,16 @@ void stereo_dft_dequantize_itd_fx( { itd = imult1616( -1, itd ); /* Q0 */ } - assert( ( ABSVAL( itd ) <= STEREO_DFT_ITD_MAX ) && ( ABSVAL( itd ) >= STEREO_DFT_ITD_MIN ) ); + assert( ( abs_s( itd ) <= STEREO_DFT_ITD_MAX ) && ( abs_s( itd ) >= STEREO_DFT_ITD_MIN ) ); /*Convert back @ fs*/ *out_fx = L_mult( itd, divide3232( output_Fs, STEREO_DFT_ITD_FS << 1 ) ); /*Q15*/ move32(); + return; } + + /*------------------------------------------------------------------------- * stereo_dft_dec_read_BS() * diff --git a/lib_dec/ivas_stereo_ica_dec_fx.c b/lib_dec/ivas_stereo_ica_dec_fx.c index b6bdb559b33b23b4e13fa4ddd440de7ee0de1f69..fc02a8ba480e410cd9263d5fc16116a971c7b8ac 100644 --- a/lib_dec/ivas_stereo_ica_dec_fx.c +++ b/lib_dec/ivas_stereo_ica_dec_fx.c @@ -350,13 +350,10 @@ void stereo_tca_scale_R_channel_fx( test(); IF( EQ_16( hCPE->last_element_mode, IVAS_CPE_TD ) && EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) ) { - Word64 local_value; - // to be deleted next MR - // hCPE->hStereoDftDmx->prevTargetGain *= 2.0f; - // hCPE->hStereoDftDmx->prevTargetGain = min( hCPE->hStereoDftDmx->prevTargetGain, powf( 10, ( ( 1 << STEREO_BITS_TCA_GD ) - 1 ) * STEREO_TCA_GDSTEP + STEREO_TCA_GDMIN ) ); - local_value = W_shl( hCPE->hStereoDftDmx->prevTargetGain_fx, 1 ); /* Q29 */ - hCPE->hStereoDftDmx->prevTargetGain_fx = (Word32) min( local_value, MAX_TARGET_GAIN_Q29 ); /* Q29 */ - hCPE->hStereoDftDmx->targetGain_fx = ONE_IN_Q29; /* Q29 */ + Word32 local_value; + local_value = L_shl( hCPE->hStereoDftDmx->prevTargetGain_fx, 1 ); /* Q29 */ + hCPE->hStereoDftDmx->prevTargetGain_fx = L_min( local_value, MAX_TARGET_GAIN_Q29 ); /* Q29 */ + hCPE->hStereoDftDmx->targetGain_fx = ONE_IN_Q29; /* Q29 */ move32(); flat_old = NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS ); /* Q0 */ diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index eec8198bfcbfab63300ffc0b4063534776db28f1..93a5ab064261ff067116cc0ae0b1a43c248c0735 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -209,8 +209,8 @@ ivas_error TonalMDCTConceal_Init_ivas_fx( /* just the second half of the second last pcm output is needed */ set16_fx( hTonalMDCTConc->timeDataBuffer, 0, ( 3 * L_FRAME_MAX ) / 2 ); - hTonalMDCTConc->secondLastPcmOut = &hTonalMDCTConc->timeDataBuffer[( 3 * L_FRAME_MAX ) / 2 - ( 3 * min( L_FRAME_MAX, nSamples ) / 2 )]; - hTonalMDCTConc->lastPcmOut = &hTonalMDCTConc->timeDataBuffer[( 3 * L_FRAME_MAX ) / 2 - min( L_FRAME_MAX, nSamples )]; + hTonalMDCTConc->secondLastPcmOut = &hTonalMDCTConc->timeDataBuffer[( 3 * L_FRAME_MAX ) / 2 - ( 3 * s_min( L_FRAME_MAX, nSamples ) / 2 )]; + hTonalMDCTConc->lastPcmOut = &hTonalMDCTConc->timeDataBuffer[( 3 * L_FRAME_MAX ) / 2 - s_min( L_FRAME_MAX, nSamples )]; /* If the second last frame was lost, we reuse saved TonalComponentsInfo and don't update pcm buffers */ assert( sizeof( *hTonalMDCTConc->pTCI ) <= ( hTonalMDCTConc->lastPcmOut - hTonalMDCTConc->timeDataBuffer ) * sizeof( hTonalMDCTConc->timeDataBuffer[0] ) ); diff --git a/lib_dec/waveadjust_fec_dec_fx.c b/lib_dec/waveadjust_fec_dec_fx.c index f72dfde5cb9a448bfda91c4f4ab3a65da22e20fb..b103b4c93e7307a362754a10b346f55d51e2a1de 100644 --- a/lib_dec/waveadjust_fec_dec_fx.c +++ b/lib_dec/waveadjust_fec_dec_fx.c @@ -924,7 +924,7 @@ void concealment_decode_fix( IF( EQ_16( curr_mode, 1 ) ) { /* copy the data of the last frame */ - MVR2R_WORD32( hPlcInfo->data_reci2_fx, invkoef, N ); + Copy32( hPlcInfo->data_reci2_fx, invkoef, N ); *invkoef_scale = hPlcInfo->data_reci2_scale; move16(); /* sign randomization */ @@ -1404,7 +1404,7 @@ static Word16 waveform_adj_fix( /* maximum pitch lag is 3/4 Framesize; pitch125_data is reused for temporary storage, since outdata2 (holding the pcm data of the last good frame) is still needed and overlapbuf overlaps outdata2 */ - Copy( &sbuf[Framesize / 4], pitch125_data, shr( imult1616( 3, Framesize ), 2 ) ); + Copy( &sbuf[shr( Framesize, 2 )], pitch125_data, shr( imult1616( 3, Framesize ), 2 ) ); hPlcInfo->nsapp_gain_fx = 0; move16(); @@ -1416,10 +1416,10 @@ static Word16 waveform_adj_fix( add_noise( sbuf, &( hPlcInfo->outx_new_n1_fx ), outdata2, tmp, &( hPlcInfo->nsapp_gain_fx ), &( hPlcInfo->nsapp_gain_n_fx ), 1 ); /* save current (noisy) output from IMDCT */ - MVR2R_WORD16( outx_new, hPlcInfo->data_noise, tmp ); + Copy( outx_new, hPlcInfo->data_noise, tmp ); /* overlapbuf can now be filled with sbuf, needed for subsequently lost frames */ - Copy( pitch125_data, &overlapbuf[Framesize / 4], shr( imult1616( 3, Framesize ), 2 ) ); + Copy( pitch125_data, &overlapbuf[shr( Framesize, 2 )], shr( imult1616( 3, Framesize ), 2 ) ); } FOR( i = 0; i < Framesize; i++ ) { @@ -1482,7 +1482,7 @@ void waveform_adj2_fix( /* save current (noisy) output from IMDCT */ IF( bfi ) { - MVR2R_WORD16( outx_new, noise_ptr, size ); + Copy( outx_new, noise_ptr, size ); } } test(); diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index b612626cf8d9ed34c2a253ac14eede0580e822ff..367468db57108c14811c53d00f69257b593ac543 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -1294,7 +1294,7 @@ ivas_error acelp_core_enc_ivas_fx( /* Prepare ACB memory from last HQ frame */ tmpF_fx = hLPDmem->old_exc[0]; move16(); - PREEMPH_FX( hLPDmem->old_exc, st->preemph_fac, st->L_frame, &tmpF_fx ); + preemph_fx( hLPDmem->old_exc, st->preemph_fac, st->L_frame, &tmpF_fx ); Copy( hLPDmem->old_exc + sub( st->L_frame, M ), hLPDmem->mem_syn, M ); /* Q_new */ Scale_sig( st->hLPDmem->mem_syn, M, sub( st->hLPDmem->q_mem_syn, Q_new ) ); Residu3_fx( Aq, hLPDmem->old_exc, old_exc_fx, st->L_frame, 0 ); diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index 6909c512d280002efcc43550c36cd99802ec061f..e7d09c786d06b16f010c79b5529d09ca260195f1 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -20,6 +20,15 @@ static void find_enr( Word16 data[], Word32 band[], Word32 *ptE, Word32 *LEtot, static void ivas_find_enr( Word16 *data, Word16 q_data, Word32 *band, Word16 *q_band, Word32 *ptE, Word16 *q_ptE, Word64 *LEtot, const Word16 min_band, const Word16 max_band, Word32 *Bin_E, Word16 BIN_FREQ_FX, Word32 *band_energies ); +/*-------------------------------------------------------------------* + * Local constants + *-------------------------------------------------------------------*/ + +#define SIZE_256 256 +#define NUM_STAGE_256 7 +#define SIZE2_256 ( SIZE_256 / 2 ) + + /*-------------------------------------------------------------------* * analy_sp_fx() * @@ -404,7 +413,7 @@ static void find_enr_dft_ivas_fx( move16(); L_lerp_fx( BinE_fx, Bin_E_fx, L_FFT / 2, STEREO_DFT_N_12k8_ENC / 2, q_Bin_E ); - MVR2R_WORD32( Bin_E_fx, ptE_fx, VOIC_BINS ); // *q_Bin_E + Copy32( Bin_E_fx, ptE_fx, VOIC_BINS ); // *q_Bin_E *q_ptE = *q_Bin_E; move16(); @@ -593,10 +602,10 @@ void ivas_analy_sp_fx( hCPE->hStereoDft->DFT_fx_e[0] = sub( hCPE->hStereoDft->DFT_fx_e[0], exp ); move16(); find_enr_dft_ivas_fx( hCPE, input_Fs, hCPE->hStereoDft->DFT_fx[0], pt_bands, q_fr_bands, lf_E, q_lf_E, &LEtot, min_band, max_band, Bin_E, q_Bin_E, band_energies, sub( Q31, hCPE->hStereoDft->DFT_fx_e[0] ) ); - MVR2R_WORD32( lf_E, lf_E + VOIC_BINS, VOIC_BINS ); - MVR2R_WORD32( Bin_E, Bin_E + ( L_FFT / 2 ), L_FFT / 2 ); - MVR2R_WORD32( band_energies, band_energies + NB_BANDS, NB_BANDS ); - MVR2R_WORD32( pt_bands, pt_bands + NB_BANDS, NB_BANDS ); + Copy32( lf_E, lf_E + VOIC_BINS, VOIC_BINS ); + Copy32( Bin_E, Bin_E + ( L_FFT / 2 ), L_FFT / 2 ); + Copy32( band_energies, band_energies + NB_BANDS, NB_BANDS ); + Copy32( pt_bands, pt_bands + NB_BANDS, NB_BANDS ); /* Average total log energy over both half-frames */ *Etot = -838860800 /* 10.f * log10f(0.00001f) in Q24 : This is when LEtot is 0*/; diff --git a/lib_enc/enc_higher_acelp_fx.c b/lib_enc/enc_higher_acelp_fx.c index a7afd750c7374a8efb72ad654454eabb821d7928..913b208c084ad608dd5fa133e317fd087df5086e 100644 --- a/lib_enc/enc_higher_acelp_fx.c +++ b/lib_enc/enc_higher_acelp_fx.c @@ -331,7 +331,7 @@ void transf_cdbk_enc_fx( st_fx->last_nq_preQ = nq[7]; move16(); - PREEMPH_FX( code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, &( st_fx->mem_preemp_preQ_fx ) ); + preemph_fx( code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, &( st_fx->mem_preemp_preQ_fx ) ); /*--------------------------------------------------------------* * For inactive segments @@ -724,7 +724,7 @@ void transf_cdbk_enc_ivas_fx( st_fx->last_code_preq = shr( code_preQ[L_SUBFR - 1], 9 ); // Q0 move16(); - PREEMPH_FX( code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, &( st_fx->mem_preemp_preQ_fx ) ); + preemph_fx( code_preQ, FAC_PRE_AVQ_FX, L_SUBFR, &( st_fx->mem_preemp_preQ_fx ) ); /*--------------------------------------------------------------* * For inactive segments @@ -789,7 +789,7 @@ static void find_cn_fx( Copy( xn, tmp_fl + M, L_SUBFR ); /* Qx */ tmp = 0; move16(); - PREEMPH_FX( tmp_fl + M, PREEMPH_FAC_16k, L_SUBFR, &tmp ); + preemph_fx( tmp_fl + M, PREEMPH_FAC_16k, L_SUBFR, &tmp ); syn_filt_s_lc_fx( 0, Ap, tmp_fl + M, tmp_fl + M, L_SUBFR ); Residu3_lc_fx( p_Aq, M, tmp_fl + M, cn, L_SUBFR, 1 ); diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index c3958e543691816892627449daaefde7c8b388bf..b28c7f5584a85eb9a6bfc985c3adf283e8c7a886 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -424,7 +424,7 @@ void core_signal_analysis_high_bitrate_fx( interleaveBuf[2 * i + 1] = spectrum[frameno][tcx5SizeFB + i]; /* exp(spectrum_e) */ move32(); } - MVR2R_WORD32( interleaveBuf, spectrum[frameno], tcx10SizeFB ); + Copy32( interleaveBuf, spectrum[frameno], tcx10SizeFB ); } /*--------------------------------------------------------------* @@ -454,7 +454,7 @@ void core_signal_analysis_high_bitrate_fx( } /* Copy memory */ - MVR2R_WORD16( lsp_new, st->lspold_enc_fx, M ); /* Q15 */ + Copy( lsp_new, st->lspold_enc_fx, M ); /* Q15 */ } } @@ -599,7 +599,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( { Copy( st->speech_enc + st->encoderLookahead_enc, st->new_speech_enc_pe, L_frame ); // Assuming both exp_buf_speech_enc_pe and exp_buf_speech_enc are same - PREEMPH_FX( st->new_speech_enc_pe, st->preemph_fac, L_frame, &( st->mem_preemph_enc ) ); // using this to keep values alligned in Q-1 + preemph_fx( st->new_speech_enc_pe, st->preemph_fac, L_frame, &( st->mem_preemph_enc ) ); // using this to keep values alligned in Q-1 } /* Rescale Memory */ @@ -1221,7 +1221,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( interleaveBuf[2 * i + 1] = hTcxEnc->spectrum_fx[frameno][tcx5SizeFB + i]; /* hTcxEnc->spectrum_e */ move32(); } - MVR2R_WORD32( interleaveBuf, hTcxEnc->spectrum_fx[frameno], tcx10SizeFB ); + Copy32( interleaveBuf, hTcxEnc->spectrum_fx[frameno], tcx10SizeFB ); } /*--------------------------------------------------------------* @@ -1259,7 +1259,7 @@ void core_signal_analysis_high_bitrate_ivas_fx( IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) ) { /* Copy memory */ - MVR2R_WORD16( lsp_new, st->lspold_enc_fx, M ); + Copy( lsp_new, st->lspold_enc_fx, M ); } return; diff --git a/lib_enc/hq_hr_enc_fx.c b/lib_enc/hq_hr_enc_fx.c index 7f18bd48acb52566672112ce1bcd3cb09c5be3fb..d9a1dd5b744bf213905424ff0f267a3ea921cee6 100644 --- a/lib_enc/hq_hr_enc_fx.c +++ b/lib_enc/hq_hr_enc_fx.c @@ -477,7 +477,7 @@ void hq_hr_enc_ivas_fx( ivas_de_interleave_spectrum_fx( t_audio_q_fx, length ); } - MVR2R_WORD32( t_audio_q_fx, t_audio_fx, length ); + Copy32( t_audio_q_fx, t_audio_fx, length ); return; } diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index f6aa5e904c6fdf12012cee93b4f2f7688a1681a0..38c5abd23a5cf11a56b4c852e1c7bfbda47410f6 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -596,13 +596,11 @@ ivas_error pre_proc_front_ivas_fx( st->mem_preemph_DFT_fx_q_inp = old_inp_12k8_fx[L_INP_MEM - STEREO_DFT_OVL_12k8 + L_FRAME - 1]; /* st->q_inp */ move16(); - // PREEMPH_FX( new_inp_12k8_fx - STEREO_DFT_OVL_12k8, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx ); - PREEMPH_32FX( new_inp_12k8_fx - STEREO_DFT_OVL_12k8, sig_out, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx_q_inp ); + preemph_copy_32fx2( new_inp_12k8_fx - STEREO_DFT_OVL_12k8, sig_out, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx_q_inp ); dummy_fx = st->mem_preemph_fx_q_inp; move16(); - // PREEMPH_FX( new_inp_12k8_fx - STEREO_DFT_OVL_12k8 + L_FRAME, PREEMPH_FAC, STEREO_DFT_OVL_12k8, &dummy_fx ); - PREEMPH_32FX( new_inp_12k8_fx - STEREO_DFT_OVL_12k8 + L_FRAME, sig_out + L_FRAME, PREEMPH_FAC, STEREO_DFT_OVL_12k8, &dummy_fx ); + preemph_copy_32fx2( new_inp_12k8_fx - STEREO_DFT_OVL_12k8 + L_FRAME, sig_out + L_FRAME, PREEMPH_FAC, STEREO_DFT_OVL_12k8, &dummy_fx ); preemp_start_idx = new_inp_12k8_fx - STEREO_DFT_OVL_12k8; move16(); preemp_len = STEREO_DFT_OVL_12k8 + L_FRAME; @@ -617,8 +615,7 @@ ivas_error pre_proc_front_ivas_fx( st->mem_preemph_fx_q_inp = st->mem_preemph_DFT_fx_q_inp; /* st->q_inp */ move16(); Copy_Scale_sig( st->inp_12k8_mem_stereo_sw_fx, new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, sub( st->q_inp, Q_inp_const ) ); /* st->q_inp */ - // PREEMPH_FX( new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), PREEMPH_FAC, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, &st->mem_preemph_fx ); - PREEMPH_32FX( new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), sig_out, PREEMPH_FAC, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, &st->mem_preemph_fx_q_inp ); + preemph_copy_32fx2( new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ), sig_out, PREEMPH_FAC, STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT, &st->mem_preemph_fx_q_inp ); preemp_start_idx = new_inp_12k8_fx - L_MEM_RECALC_12K8 - ( STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT ); move16(); preemp_len = STEREO_DFT_OVL_12k8 - L_MEM_RECALC_12K8 - L_FILT; @@ -635,19 +632,16 @@ ivas_error pre_proc_front_ivas_fx( { Word16 length_12k8 = NS2SA( INT_FS_12k8, L_MEM_RECALC_SCH_NS ); move16(); - // PREEMPH_FX( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, PREEMPH_FAC, length_12k8, &st->mem_preemph_fx ); - PREEMPH_32FX( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, sig_out, PREEMPH_FAC, length_12k8, &st->mem_preemph_fx_q_inp ); + preemph_copy_32fx2( new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8, sig_out, PREEMPH_FAC, length_12k8, &st->mem_preemph_fx_q_inp ); preemp_start_idx = new_inp_12k8_fx - lMemRecalc_12k8 - length_12k8; preemp_len = length_12k8; move16(); } - // PREEMPH_FX( new_inp_12k8_fx - lMemRecalc_12k8, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx ); - PREEMPH_32FX( new_inp_12k8_fx - lMemRecalc_12k8, sig_out + preemp_len, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx_q_inp ); + preemph_copy_32fx2( new_inp_12k8_fx - lMemRecalc_12k8, sig_out + preemp_len, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx_q_inp ); dummy_fx = st->mem_preemph_fx_q_inp; /* st->q_inp */ move16(); - // PREEMPH_FX( new_inp_12k8_fx - lMemRecalc_12k8 + L_FRAME, PREEMPH_FAC, lMemRecalc_12k8 + L_FILT, &dummy_fx ); - PREEMPH_32FX( new_inp_12k8_fx - lMemRecalc_12k8 + L_FRAME, sig_out + preemp_len + L_FRAME, PREEMPH_FAC, lMemRecalc_12k8 + L_FILT, &dummy_fx ); + preemph_copy_32fx2( new_inp_12k8_fx - lMemRecalc_12k8 + L_FRAME, sig_out + preemp_len + L_FRAME, PREEMPH_FAC, lMemRecalc_12k8 + L_FILT, &dummy_fx ); test(); IF( preemp_start_idx && preemp_len ) @@ -664,12 +658,10 @@ ivas_error pre_proc_front_ivas_fx( } ELSE /* IVAS_SCE or IVAS_CPE_MDCT */ { - // PREEMPH_FX( new_inp_12k8_fx, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx ); - PREEMPH_32FX( new_inp_12k8_fx, sig_out, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx_q_inp ); + preemph_copy_32fx2( new_inp_12k8_fx, sig_out, PREEMPH_FAC, L_FRAME, &st->mem_preemph_fx_q_inp ); dummy_fx = st->mem_preemph_fx_q_inp; move16(); - // PREEMPH_FX( new_inp_12k8_fx + L_FRAME, PREEMPH_FAC, L_FILT, &dummy_fx ); - PREEMPH_32FX( new_inp_12k8_fx + L_FRAME, sig_out + L_FRAME, PREEMPH_FAC, L_FILT, &dummy_fx ); + preemph_copy_32fx2( new_inp_12k8_fx + L_FRAME, sig_out + L_FRAME, PREEMPH_FAC, L_FILT, &dummy_fx ); preemp_start_idx = new_inp_12k8_fx; preemp_len = L_FRAME + L_FILT; move16(); diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 7ba122dbd3cc9a5332a60166bf29f17f8d9f54d7..9857c3e1298835392a7c810be5476acb6e7b4d2d 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -965,13 +965,11 @@ ivas_error ivas_compute_core_buffers_fx( { Copy( new_inp_16k_fx - STEREO_DFT_OVL_16k, st->buf_speech_enc + L_FRAME16k - STEREO_DFT_OVL_16k, L_FRAME16k + STEREO_DFT_OVL_16k ); /* Q(-1) */ } - // PREEMPH_FX(new_inp_16k_fx - STEREO_DFT_OVL_16k, PREEMPH_FAC_16k, L_FRAME16k, &(st->mem_preemph16k_fx)); - PREEMPH_32FX( new_inp_16k_fx - STEREO_DFT_OVL_16k, sig_out, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) ); /* Q(-1) */ + preemph_copy_32fx2( new_inp_16k_fx - STEREO_DFT_OVL_16k, sig_out, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) ); /* Q(-1) */ tmp_fx = st->mem_preemph16k_fx; move16(); - // PREEMPH_FX(new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k, &tmp_fx); - PREEMPH_32FX( new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, sig_out + L_FRAME16k, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k, &tmp_fx ); /* Q(-1) */ + preemph_copy_32fx2( new_inp_16k_fx - STEREO_DFT_OVL_16k + L_FRAME16k, sig_out + L_FRAME16k, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k, &tmp_fx ); /* Q(-1) */ preemp_start_idx = new_inp_16k_fx - STEREO_DFT_OVL_16k; move16(); preemp_len = STEREO_DFT_OVL_16k + L_FRAME16k; @@ -983,9 +981,8 @@ ivas_error ivas_compute_core_buffers_fx( { st->mem_preemph16k_fx = st->mem_preemph16k_DFT_fx; move16(); - Copy( st->inp_16k_mem_stereo_sw_fx, new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ), STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ); /* Q(-1) */ - // PREEMPH_FX(new_inp_16k_fx - L_MEM_RECALC_16K - (STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k), PREEMPH_FAC_16k, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k, &st->mem_preemph16k_fx); - PREEMPH_32FX( new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ), sig_out, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k, &st->mem_preemph16k_fx ); /* Q(-1) */ + Copy( st->inp_16k_mem_stereo_sw_fx, new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ), STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ); /* Q(-1) */ + preemph_copy_32fx2( new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ), sig_out, PREEMPH_FAC_16k, STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k, &st->mem_preemph16k_fx ); /* Q(-1) */ preemp_start_idx = new_inp_16k_fx - L_MEM_RECALC_16K - ( STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k ); move16(); preemp_len = STEREO_DFT_OVL_16k - L_MEM_RECALC_16K - L_FILT16k; @@ -1001,8 +998,7 @@ ivas_error ivas_compute_core_buffers_fx( Word16 length_16k = NS2SA( INT_FS_16k, L_MEM_RECALC_SCH_NS - DELAY_FIR_RESAMPL_NS ); move16(); - // PREEMPH_FX(new_inp_16k_fx - lMemRecalc_16k - length_16k, PREEMPH_FAC, length_16k, &st->mem_preemph16k_fx); - PREEMPH_32FX( new_inp_16k_fx - lMemRecalc_16k - length_16k, sig_out, PREEMPH_FAC, length_16k, &st->mem_preemph16k_fx ); /* Q(-1) */ + preemph_copy_32fx2( new_inp_16k_fx - lMemRecalc_16k - length_16k, sig_out, PREEMPH_FAC, length_16k, &st->mem_preemph16k_fx ); /* Q(-1) */ preemp_start_idx = new_inp_16k_fx - lMemRecalc_16k - length_16k; preemp_len = length_16k; move16(); @@ -1012,12 +1008,10 @@ ivas_error ivas_compute_core_buffers_fx( { Copy( new_inp_16k_fx - lMemRecalc_16k, st->buf_speech_enc + sub( L_FRAME16k - L_FILT16k, lMemRecalc_16k ), add( lMemRecalc_16k, L_FRAME16k + L_FILT16k ) ); /* Q_new - 1 */ } - // PREEMPH_FX(new_inp_16k_fx - lMemRecalc_16k, PREEMPH_FAC_16k, L_FRAME16k, &(st->mem_preemph16k_fx)); - PREEMPH_32FX( new_inp_16k_fx - lMemRecalc_16k, sig_out + preemp_len, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) ); /* Q(-1) */ + preemph_copy_32fx2( new_inp_16k_fx - lMemRecalc_16k, sig_out + preemp_len, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) ); /* Q(-1) */ tmp_fx = st->mem_preemph16k_fx; move16(); - // PREEMPH_FX(new_inp_16k_fx - lMemRecalc_16k + L_FRAME16k, PREEMPH_FAC_16k, lMemRecalc_16k + L_FILT16k, &tmp_fx); - PREEMPH_32FX( new_inp_16k_fx - lMemRecalc_16k + L_FRAME16k, sig_out + preemp_len + L_FRAME16k, PREEMPH_FAC_16k, lMemRecalc_16k + L_FILT16k, &tmp_fx ); /* Q(-1) */ + preemph_copy_32fx2( new_inp_16k_fx - lMemRecalc_16k + L_FRAME16k, sig_out + preemp_len + L_FRAME16k, PREEMPH_FAC_16k, lMemRecalc_16k + L_FILT16k, &tmp_fx ); /* Q(-1) */ IF( preemp_start_idx && preemp_len ) { preemp_len = add( preemp_len, add( L_FRAME16k + L_FILT16k, lMemRecalc_16k ) ); @@ -1032,12 +1026,10 @@ ivas_error ivas_compute_core_buffers_fx( } ELSE IF( EQ_16( element_mode, IVAS_SCE ) ) { - // PREEMPH_FX(new_inp_16k_fx, PREEMPH_FAC_16k, L_FRAME16k, &(st->mem_preemph16k_fx)); - PREEMPH_32FX( new_inp_16k_fx, sig_out, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) ); /* Q(-1) */ + preemph_copy_32fx2( new_inp_16k_fx, sig_out, PREEMPH_FAC_16k, L_FRAME16k, &( st->mem_preemph16k_fx ) ); /* Q(-1) */ tmp_fx = st->mem_preemph16k_fx; move16(); - // PREEMPH_FX(new_inp_16k_fx + L_FRAME16k, PREEMPH_FAC_16k, L_FILT16k, &tmp_fx); - PREEMPH_32FX( new_inp_16k_fx + L_FRAME16k, sig_out + L_FRAME16k, PREEMPH_FAC_16k, L_FILT16k, &tmp_fx ); /* Q(-1) */ + preemph_copy_32fx2( new_inp_16k_fx + L_FRAME16k, sig_out + L_FRAME16k, PREEMPH_FAC_16k, L_FILT16k, &tmp_fx ); /* Q(-1) */ preemp_start_idx = new_inp_16k_fx; preemp_len = L_FRAME16k + L_FILT16k; move16(); diff --git a/lib_enc/ivas_dirac_enc_fx.c b/lib_enc/ivas_dirac_enc_fx.c index e9fd937238db6cc1919d3cc0c01842807d3f0243..91c44fcf74c6fffa40ab4778c5dfadca2b97f70c 100644 --- a/lib_enc/ivas_dirac_enc_fx.c +++ b/lib_enc/ivas_dirac_enc_fx.c @@ -231,7 +231,7 @@ ivas_error ivas_dirac_enc_reconfigure( } ELSE { - MVR2R_WORD16( DirAC_block_grouping_5ms_MDFT, hDirAC->block_grouping, MAX_PARAM_SPATIAL_SUBFRAMES + 1 ); + Copy( DirAC_block_grouping_5ms_MDFT, hDirAC->block_grouping, MAX_PARAM_SPATIAL_SUBFRAMES + 1 ); } return error; diff --git a/lib_enc/ivas_front_vad_fx.c b/lib_enc/ivas_front_vad_fx.c index 6f1f7f5bfe08574448462ad21f9bb0e2a437de20..f58f48e97ff8cad4ff29fa927b1e2ed9acbdbb4b 100644 --- a/lib_enc/ivas_front_vad_fx.c +++ b/lib_enc/ivas_front_vad_fx.c @@ -221,7 +221,7 @@ ivas_error front_vad_fx( /* Move previous frame 12k8 signal */ - MVR2R_WORD16( hFrontVad->buffer_12k8_fx + L_FFT, hFrontVad->buffer_12k8_fx, L_FFT / 2 ); + Copy( hFrontVad->buffer_12k8_fx + L_FFT, hFrontVad->buffer_12k8_fx, L_FFT / 2 ); /* Resample to 12k8 */ modify_Fs_ivas_fx( sts[n]->input_fx, input_frame, sts[0]->input_Fs, hFrontVad->buffer_12k8_fx + L_FFT / 2, INT_FS_12k8, hFrontVad->mem_decim_fx, ( sts[0]->max_bwidth == NB ), &Qband, &mem_decim_size ); @@ -232,7 +232,7 @@ ivas_error front_vad_fx( hFrontVad->q_mem_preemph_fx = add( Q_inp, Qband ); move16(); - PREEMPH_FX( hFrontVad->buffer_12k8_fx + L_FFT / 2, PREEMPH_FAC, L_FRAME, &hFrontVad->mem_preemph_fx ); + preemph_fx( hFrontVad->buffer_12k8_fx + L_FFT / 2, PREEMPH_FAC, L_FRAME, &hFrontVad->mem_preemph_fx ); Q_new = s_min( add( add( Q_inp, Qband ), Q_add ), Q_buffer[n] ); scale_sig( hFrontVad->buffer_12k8_fx, L_FFT / 2, sub( Q_new, Q_buffer[n] ) ); /* Q_new */ @@ -339,13 +339,12 @@ ivas_error front_vad_fx( IF( PS_out_fx != NULL ) { - MVR2R_WORD32( PS_fx, PS_out_fx, L_FRAME / 2 ); + Copy32( PS_fx, PS_out_fx, L_FRAME / 2 ); } IF( Bin_E_out_fx != NULL ) { - - MVR2R_WORD16( lgBin_E_fx, Bin_E_out_fx, L_FRAME / 2 ); + Copy( lgBin_E_fx, Bin_E_out_fx, L_FRAME / 2 ); } pop_wmops(); @@ -528,7 +527,7 @@ ivas_error front_vad_spar_fx( inp_12k8_fx = hFrontVad->buffer_12k8_fx; - MVR2R_WORD16( st->old_wsp_fx, old_wsp_fx, L_WSP_MEM ); + Copy( st->old_wsp_fx, old_wsp_fx, L_WSP_MEM ); wsp_fx = old_wsp_fx + L_WSP_MEM; st->core_brate = -1; /* updated in dtx() */ @@ -730,8 +729,9 @@ ivas_error front_vad_spar_fx( lf_E_fx[0], q_lf_E[0], &hFrontVad->hNoiseEst->harm_cor_cnt, extract_h( hFrontVad->hNoiseEst->Etot_l_lp_32fx ), hFrontVad->hNoiseEst->Etot_v_h2_32fx, &hFrontVad->hNoiseEst->bg_cnt, st->lgBin_E_fx, &sp_floor, S_map_fx, NULL, hFrontVad, hFrontVad->ini_frame ); - MVR2R_WORD16( st->pitch, st->pitch, 3 ); + Copy( st->pitch, st->pitch, 3 ); vad_param_updt_fx( st, st->pitch[1], corr_shift_fx, corr_shift_fx, A_fx, &hFrontVad, 1 ); + /* 1st stage speech/music classification (GMM model) */ /* run only to get 'high_lpn_flag' parameter */ SP_MUS_CLAS_HANDLE hSpMusClas = st->hSpMusClas; diff --git a/lib_enc/ivas_ism_metadata_enc_fx.c b/lib_enc/ivas_ism_metadata_enc_fx.c index f13b24b63937d3f487eec7619b570f1da159b5cd..5876f130facd8acb2f8a6672dc6cd9f36f6c7b5c 100644 --- a/lib_enc/ivas_ism_metadata_enc_fx.c +++ b/lib_enc/ivas_ism_metadata_enc_fx.c @@ -1074,7 +1074,7 @@ static void encode_radius_fx( nbits_diff_radius = 1; move16(); } - ELSE IF( LE_16( ABSVAL( diff ), ISM_MAX_RADIUS_DIFF_IDX ) ) + ELSE IF( LE_16( abs_s( diff ), ISM_MAX_RADIUS_DIFF_IDX ) ) { idx_radius = 2; // shl( 1, 1 ); move16(); diff --git a/lib_enc/ivas_osba_enc_fx.c b/lib_enc/ivas_osba_enc_fx.c index 044a42c17d7f6a21cb740221b131f96075817eb5..51ed0954ec9947db7946365550fa6e1dd4b8f892 100644 --- a/lib_enc/ivas_osba_enc_fx.c +++ b/lib_enc/ivas_osba_enc_fx.c @@ -427,7 +427,7 @@ void ivas_osba_enc_fx( /*keep the delay buffer up to date*/ FOR( n = 0; n < nchan_ism; n++ ) { - MVR2R_WORD32( &data_in_fx[n][input_frame - delay_s], hOSba->input_data_mem_fx[n], delay_s ); // Q_data + Copy32( &data_in_fx[n][input_frame - delay_s], hOSba->input_data_mem_fx[n], delay_s ); // Q_data } /* Convert ISM to SBA */ diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index b1e9751e8f4e60eb63ea92daa0a92cd0dd1a836f..a60539047bfb4baccf1a50c7a65c14c62f64ed44 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -2003,7 +2003,7 @@ Word16 ivas_smc_gmm_fx( temp32_log = Mpy_32_32( temp32_log, 1488522239 ); /*logf(x) = log2(x)*logf(2)*/ *pFV_fx++ = L_shr( temp32_log, Q5 ); // logf( ps_sta + 1e-5f ); move32(); - MVR2R_WORD32( &PS_norm_fx[LOWEST_FBIN], hSpMusClas->past_PS_fx, HIGHEST_FBIN - LOWEST_FBIN ); + Copy32( &PS_norm_fx[LOWEST_FBIN], hSpMusClas->past_PS_fx, HIGHEST_FBIN - LOWEST_FBIN ); /* save ps_diff and ps_sta features for XTALK and UNCLR classifier */ IF( hStereoClassif != NULL ) @@ -2108,7 +2108,8 @@ Word16 ivas_smc_gmm_fx( } /* update */ - MVR2R_WORD32( FV_fx, hSpMusClas->prev_FV_fx, N_SMC_FEATURES ); + Copy32( FV_fx, hSpMusClas->prev_FV_fx, N_SMC_FEATURES ); + /*------------------------------------------------------------------* * Non-linear power transformation (boxcox) on certain features *------------------------------------------------------------------*/ diff --git a/lib_enc/updt_enc_fx.c b/lib_enc/updt_enc_fx.c index 62af228a0c75fac8ba24e23c64a406ec0c29b2d5..2eb3e1a1763ad1d5afc89c7246329af7b8182338 100644 --- a/lib_enc/updt_enc_fx.c +++ b/lib_enc/updt_enc_fx.c @@ -193,11 +193,13 @@ void updt_IO_switch_enc_fx( hTdCngEnc->old_enr_index = s_min( mult( shl( hTdCngEnc->old_enr_index, 1 ), 32459 ), 127 ); /*32459 = 2/(STEP_SID/STEP_AMR_WB_SID)*/ move16(); } + /* Perform preemphasis of the old input signal @16kHz */ st->mem_preemph16k_fx = 0; move16(); - PREEMPH_FX( st->old_inp_16k_fx, PREEMPH_FAC_16k, L_INP_MEM, &( st->mem_preemph16k_fx ) ); + preemph_fx( st->old_inp_16k_fx, PREEMPH_FAC_16k, L_INP_MEM, &( st->mem_preemph16k_fx ) ); Scale_sig( st->old_inp_16k_fx, L_INP_MEM, st->prev_Q_new ); + /* reset TD BWE buffers */ set16_fx( hBWE_TD->old_speech_shb_fx, 0, L_LOOK_16k + L_SUBFR16k ); set16_fx( hBWE_TD->old_speech_wb_fx, 0, ( L_LOOK_12k8 + L_SUBFR ) * 5 / 16 ); diff --git a/lib_isar/isar_PredEncoder.c b/lib_isar/isar_PredEncoder.c index c933e7f36e926fc85681c343801e09958f5e1486..4a75ca0d825c328eb64dfaafc7066349311cd9b3 100644 --- a/lib_isar/isar_PredEncoder.c +++ b/lib_isar/isar_PredEncoder.c @@ -464,7 +464,7 @@ void ComputePredictors_fx( Word16 w_norm3 = W_norm( W_temp2 ); W_temp2 = W_shr( W_temp2, 32 - w_norm3 ); pfRxxImag_fx[1] = W_extract_l( W_temp2 ); - Word16 final_w_norm = min( w_norm1, min( w_norm2, w_norm3 ) ); + Word16 final_w_norm = s_min( w_norm1, s_min( w_norm2, w_norm3 ) ); pfRxxReal_fx[0] = L_shr( pfRxxReal_fx[0], w_norm1 - final_w_norm ); // Q8 + final_w_norm pfRxxReal_fx[1] = L_shr( pfRxxReal_fx[1], w_norm2 - final_w_norm ); // Q8 + final_w_norm pfRxxImag_fx[1] = L_shr( pfRxxImag_fx[1], w_norm3 - final_w_norm ); // Q8 + final_w_norm @@ -541,7 +541,7 @@ void ComputePredictors_fx( // fGain_fx = sub(sub(32767, extract_h(Mpy_32_32(fA1Real_fx, fA1Real_fx))), extract_h(Mpy_32_32(fA1Imag_fx, fA1Imag_fx))); // fGain_fx = extract_l(L_shl(L_temp, 2*sf_r)); fGain_fx = extract_l( L_temp ); - fGain_fx = max( 1, fGain_fx ); + fGain_fx = L_max( 1, fGain_fx ); fGain_fx = Inv16( extract_l( fGain_fx ), &exp ); // Q15 - exp // fGain_fx = L_shl(fGain_fx, exp); //Q15 // fBitGain = 0.65f * log2f(fGain) * (float)(iNumBlocksPerPredCoef)-(float)(PRED_QUNAT_FILTER_MAG_BITS + PRED_QUANT_FILTER_PHASE_BITS); // Wrong fix (iNumBlocks-1) diff --git a/lib_isar/isar_lc3plus_enc.c b/lib_isar/isar_lc3plus_enc.c index 60121a11f7e96c8bbb219bfdf1897513d0f1575f..54dd6df2386e9f9e78e6911932000eb119ba7eea 100644 --- a/lib_isar/isar_lc3plus_enc.c +++ b/lib_isar/isar_lc3plus_enc.c @@ -48,11 +48,11 @@ static int32_t limit_per_channel_bitrate( LC3PLUS_CONFIG config, switch ( config.lc3plus_frame_duration_us ) { case 10000: - return min( per_channel_bitrate, 500000 ); + return L_min( per_channel_bitrate, 500000 ); case 5000: - return min( per_channel_bitrate, 600000 ); + return L_min( per_channel_bitrate, 600000 ); case 2500: - return min( per_channel_bitrate, 672000 ); + return L_min( per_channel_bitrate, 672000 ); default: assert( false && "unreachable" ); } @@ -62,13 +62,13 @@ static int32_t limit_per_channel_bitrate( LC3PLUS_CONFIG config, { case 48000: case 32000: - return min( per_channel_bitrate, 320000 ); + return L_min( per_channel_bitrate, 320000 ); case 24000: - return min( per_channel_bitrate, 314400 ); + return L_min( per_channel_bitrate, 314400 ); case 16000: - return min( per_channel_bitrate, 221600 ); + return L_min( per_channel_bitrate, 221600 ); case 8000: - return min( per_channel_bitrate, 114400 ); + return L_min( per_channel_bitrate, 114400 ); default: assert( false && "unreachable" ); } @@ -558,7 +558,7 @@ ivas_error ISAR_LC3PLUS_ENC_Encode( FOR( UWord32 iSampleInt16 = 0; iSampleInt16 < numSamplesPerLC3plusChannel; iSampleInt16++ ) { ivasSampleIndex = iSampleInt16 + iMediaTime * numSamplesPerLC3plusChannel; - handle->pcm_conversion_buffer[iSampleInt16] = (Word16) max( INT16_MIN, min( L_shr( pcm_in[iEnc][ivasSampleIndex], q_in[iEnc] ), INT16_MAX ) ); + handle->pcm_conversion_buffer[iSampleInt16] = (Word16) L_max( INT16_MIN, L_min( L_shr( pcm_in[iEnc][ivasSampleIndex], q_in[iEnc] ), INT16_MAX ) ); } ftdIndex = iMediaTime * handle->num_encs + iEnc; diff --git a/lib_isar/isar_lcld_decoder.c b/lib_isar/isar_lcld_decoder.c index 85db837ce82f6937065fa00ea5d01e20bc8695d7..e706336698659e195034e259d8c0930acf70f233 100644 --- a/lib_isar/isar_lcld_decoder.c +++ b/lib_isar/isar_lcld_decoder.c @@ -1114,7 +1114,7 @@ Word32 DecodeLCLDFrame( } IF( NE_32( real_max, 0 ) || NE_32( imag_max, 0 ) ) { - exp = min( exp2, exp1 ); + exp = s_min( exp2, exp1 ); *Q_out = add( *Q_out, sub( exp, 3 ) ); FOR( n = 0; n < psLCLDDecoder->iChannels; n++ ) { diff --git a/lib_isar/isar_lcld_encoder.c b/lib_isar/isar_lcld_encoder.c index 760d653f5dff68f9ecaedd19fb23be97711ccbb1..e3296db25c5c38a074a1af880e5b593c42ae4af7 100644 --- a/lib_isar/isar_lcld_encoder.c +++ b/lib_isar/isar_lcld_encoder.c @@ -968,12 +968,12 @@ static Word32 MSModeCalculation_fx( iFBOffset++; } - Q_en_tmp = min( Q_en_tmp, W_norm( fLeftEnergy_fx64 ) ); - Q_en_tmp = min( Q_en_tmp, W_norm( fRightEnergy_fx64 ) ); - Q_en_tmp = min( Q_en_tmp, W_norm( fMidEnergy_fx64 ) ); - Q_en_tmp = min( Q_en_tmp, W_norm( fSideEnergy_fx64 ) ); - Q_en_tmp = min( Q_en_tmp, W_norm( fLRCovReal_fx64 ) ); - Q_en_tmp = min( Q_en_tmp, W_norm( fLRCovImag_fx64 ) ); + Q_en_tmp = s_min( Q_en_tmp, W_norm( fLeftEnergy_fx64 ) ); + Q_en_tmp = s_min( Q_en_tmp, W_norm( fRightEnergy_fx64 ) ); + Q_en_tmp = s_min( Q_en_tmp, W_norm( fMidEnergy_fx64 ) ); + Q_en_tmp = s_min( Q_en_tmp, W_norm( fSideEnergy_fx64 ) ); + Q_en_tmp = s_min( Q_en_tmp, W_norm( fLRCovReal_fx64 ) ); + Q_en_tmp = s_min( Q_en_tmp, W_norm( fLRCovImag_fx64 ) ); Q_en_tmp = sub( Q_en_tmp, 2 ); fLeftEnergy_fx = W_extract_h( W_shl( fLeftEnergy_fx64, Q_en_tmp ) ); fRightEnergy_fx = W_extract_h( W_shl( fRightEnergy_fx64, Q_en_tmp ) ); @@ -996,7 +996,7 @@ static Word32 MSModeCalculation_fx( fSideEnergyPred_fx = L_add( fSideEnergy_fx, L_sub( Mpy_32_32( Mpy_32_32( fPred_fx, fPred_fx ), fMidEnergy_fx ), L_shr( Mpy_32_32( fPred_fx, L_sub( fLeftEnergy_fx, fRightEnergy_fx ) ), 1 ) ) ); - fSideEnergyPred_fx = max( fSideEnergyPred_fx, 0 ); + fSideEnergyPred_fx = L_max( fSideEnergyPred_fx, 0 ); ppiMSPredCoefs[MS_PRED_ONLY][b] = iPred; move32(); @@ -1054,7 +1054,7 @@ static Word32 MSModeCalculation_fx( fSideEnergyPred_fx = L_add( fSideEnergyPred_fx, L_sub( Mpy_32_32( Mpy_32_32( fPred_fx, fPred_fx ), fMidEnergyPred_fx ), L_shr( Mpy_32_32( fPred_fx, L_sub( fLeftEnergy_fx, fRightEnergy_fx ) ), 1 ) ) ); - fSideEnergyPred_fx = max( fSideEnergyPred_fx, 0 ); + fSideEnergyPred_fx = L_max( fSideEnergyPred_fx, 0 ); /* -= fPred * fPred * fMidEnergyPred doesn't work because fPred is quantized and does not match MS/MM exactly */ ppiMSPredCoefs[MS_PHASE_AND_PRED][b] = iPred; move32(); @@ -1125,7 +1125,7 @@ static Word32 MSModeCalculation_fx( { piMsPredInfoBits[iMSPredType] = CountMSBits( iNumBands, MS_PRED, ppiMSPredFlags[iMSPredType], ppiMSPredPhase[iMSPredType], ppiMSPredCoefs[iMSPredType] ); // pfMSPredBitGain[iMSPredType] = max( pfMSPredBitGain[iMSPredType] - piMsPredInfoBits[iMSPredType], 0.0f ); - pfMSPredBitGain_fx[iMSPredType] = max( pfMSPredBitGain_fx[iMSPredType] - L_shl( piMsPredInfoBits[iMSPredType], q_pfMSPredBitGain_fx ), 0 ); + pfMSPredBitGain_fx[iMSPredType] = L_max( pfMSPredBitGain_fx[iMSPredType] - L_shl( piMsPredInfoBits[iMSPredType], q_pfMSPredBitGain_fx ), 0 ); } /* find the best M/S Pred type */ diff --git a/lib_isar/isar_splitRendererPLC.c b/lib_isar/isar_splitRendererPLC.c index 8c096da3df5bfda030153e8f49c0ae8c85000205..418242d6006f6a8460a1a18f712cf2493d442387 100644 --- a/lib_isar/isar_splitRendererPLC.c +++ b/lib_isar/isar_splitRendererPLC.c @@ -308,8 +308,8 @@ static void adaptive_polar_ext_plc_fx( fac_ph_real_fx = L_deposit_h( getCosWord16R2( dth16 ) ); fac_ph_imag_fx = L_deposit_h( getSineWord16R2( dth16 ) ); ///* calculate complex evolution factor */ - fac_real_fx = Mpy_32_32( min( L_shl( 1, drho_q ), drho_32 ), fac_ph_real_fx ); // Qdrho_exp - fac_imag_fx = Mpy_32_32( min( L_shl( 1, drho_q ), drho_32 ), fac_ph_imag_fx ); // Qdrho_exp + fac_real_fx = Mpy_32_32( L_min( L_shl( 1, drho_q ), drho_32 ), fac_ph_real_fx ); // Qdrho_exp + fac_imag_fx = Mpy_32_32( L_min( L_shl( 1, drho_q ), drho_32 ), fac_ph_imag_fx ); // Qdrho_exp #if START_VAL_AVG_LEN > 1 /* Calculate start value FOR evolution from last samples of previous frame */ fac_powj_real_fx = fac_real_fx; @@ -488,11 +488,11 @@ static void adaptive_polar_ext_plc_fx( IF( EQ_16( drho_q, 31 ) ) { - abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( min( ONE_IN_Q31, drho_32 ), max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e + abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( L_min( ONE_IN_Q31, drho_32 ), L_max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e } ELSE { - abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( min( L_shl( 1, drho_q ), drho_32 ), max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e + abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( L_min( L_shl( 1, drho_q ), drho_32 ), L_max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e } temp_16 = sub( add( drho_q, sqrt_exp ), tmp_e ); @@ -600,11 +600,11 @@ static void adaptive_polar_ext_plc_fx( IF( EQ_16( drho_q, 31 ) ) { - abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( min( ONE_IN_Q31, drho_32 ), max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e + abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( L_min( ONE_IN_Q31, drho_32 ), L_max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e } ELSE { - abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( min( L_shl( 1, drho_q ), drho_32 ), max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e + abs2inv_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( L_min( L_shl( 1, drho_q ), drho_32 ), L_max( 1, abs_temp_fx ), &tmp_e ) ); // +drho_q +sqrt_exp-tmp_e } temp_16 = sub( add( drho_q, sqrt_exp ), tmp_e ); rat_real_fx = W_mult_32_32( rat_real32_fx, abs2inv_fx ); diff --git a/lib_isar/isar_splitRendererPost.c b/lib_isar/isar_splitRendererPost.c index dbefc438600da70278290836b910ea43b4d38807..bb3a57a66d08c09094302da4779b4c2d4eb52c5a 100644 --- a/lib_isar/isar_splitRendererPost.c +++ b/lib_isar/isar_splitRendererPost.c @@ -1108,7 +1108,7 @@ static Word32 get_interp_fact_fx( IF( LT_32( interp_fact_fx, 0 ) ) { - d_fx = max( -( MAX_EXTRAPOLATION_ANGLE_Q22 ), ( min( ( MAX_EXTRAPOLATION_ANGLE_Q22 ), d_fx ) ) ); + d_fx = L_max( -( MAX_EXTRAPOLATION_ANGLE_Q22 ), ( L_min( ( MAX_EXTRAPOLATION_ANGLE_Q22 ), d_fx ) ) ); move32(); n_fx = L_deposit_h( getSineWord16R2( extract_l( L_shr( Mpy_32_32( n_fx, Q31_BY_360 ), 7 ) ) ) ); move32(); @@ -1358,8 +1358,8 @@ static void interpolate_pred_matrix_fx( { FOR( Word16 j = 0; j < BINAURAL_CHANNELS; j++ ) { - max_exp_re = max( max_exp_re, buff_exp_re[i][j] ); - max_exp_im = max( max_exp_im, buff_exp_im[i][j] ); + max_exp_re = s_max( max_exp_re, buff_exp_re[i][j] ); + max_exp_im = s_max( max_exp_im, buff_exp_im[i][j] ); } } FOR( Word16 i = 0; i < BINAURAL_CHANNELS; i++ ) @@ -1500,7 +1500,7 @@ static void interpolate_rend_md_fx( Word16 exp_tmp1 = 0; Word32 tmp1 = BASOP_Util_Add_Mant32Exp( gd1_fx, 31 - Q25, L_negate( tmp ), 6 + 31 - Q_pitch, &exp_tmp1 ); pitch_gain_l_fx = tmp1; - pitch_gain_l_fx = max( 0, pitch_gain_l_fx ); + pitch_gain_l_fx = L_max( 0, pitch_gain_l_fx ); exp_pitch_gain_l = exp_tmp1; diff_fx = L_sub( gd3_fx, gd4_fx ); @@ -1512,7 +1512,7 @@ static void interpolate_rend_md_fx( exp_tmp1 = 0; tmp1 = BASOP_Util_Add_Mant32Exp( gd3_fx, 31 - Q25, L_negate( tmp ), 6 + 31 - Q_pitch, &exp_tmp1 ); pitch_gain_r_fx = tmp1; - pitch_gain_r_fx = max( 0, pitch_gain_r_fx ); + pitch_gain_r_fx = L_max( 0, pitch_gain_r_fx ); exp_pitch_gain_r = exp_tmp1; FOR( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) @@ -1532,8 +1532,8 @@ static void interpolate_rend_md_fx( { FOR( Word16 j = 0; j < BINAURAL_CHANNELS; j++ ) { - max_exp_re = max( max_exp_re, exp_mat_re[i][j] ); - max_exp_im = max( max_exp_im, exp_mat_im[i][j] ); + max_exp_re = s_max( max_exp_re, exp_mat_re[i][j] ); + max_exp_im = s_max( max_exp_im, exp_mat_im[i][j] ); } } @@ -1655,7 +1655,7 @@ void isar_SplitRenderer_PostRenderer( { index_slot = slot_idx; /* TODO: can be cleaned up */ fade_fx = fade_table_fx[slot_idx]; - fade_fx = min( fade_fx, MAX_16 ); + fade_fx = s_min( fade_fx, MAX_16 ); FOR( b = 0; b < num_md_bands; b++ ) { FOR( ch_idx1 = 0; ch_idx1 < BINAURAL_CHANNELS; ch_idx1++ ) diff --git a/lib_isar/isar_splitRendererPre.c b/lib_isar/isar_splitRendererPre.c index 7255e7716cc404ca8bb3f20e8f84320214661652..df66a0517ff0e95da0c5f1be420fe0602e7ba46b 100644 --- a/lib_isar/isar_splitRendererPre.c +++ b/lib_isar/isar_splitRendererPre.c @@ -349,7 +349,7 @@ static void ComputePredMat_fx( { FOR( j = 0; j < 2; j++ ) { - max_exp = max( max_exp, buff_exp[i][j] ); + max_exp = s_max( max_exp, buff_exp[i][j] ); } } @@ -637,8 +637,8 @@ static void ComputeBandedCrossCov_fx( { FOR( Word16 j = 0; j < num_chs; j++ ) { - max_cov_re = max( max_cov_re, exp_buff_re[i][j] ); - max_cov_im = max( max_cov_im, exp_buff_im[i][j] ); + max_cov_re = s_max( max_cov_re, exp_buff_re[i][j] ); + max_cov_im = s_max( max_cov_im, exp_buff_im[i][j] ); } } FOR( Word16 i = 0; i < num_chs; i++ ) @@ -789,8 +789,8 @@ static void ComputeBandedCov_fx( { FOR( Word16 j = 0; j < BINAURAL_CHANNELS; j++ ) { - exp_max_re = max( exp_max_re, exp_buff_re[i][j] ); - exp_max_im = max( exp_max_im, exp_buff_im[i][j] ); + exp_max_re = s_max( exp_max_re, exp_buff_re[i][j] ); + exp_max_im = s_max( exp_max_im, exp_buff_im[i][j] ); } } @@ -1101,7 +1101,7 @@ static void get_lr_gains( Word16 max_gd_exp = MIN16B; FOR( i = 0; i < BINAURAL_CHANNELS; i++ ) { - max_gd_exp = max( max_gd_exp, exp_gd_tmp_buf[i] ); + max_gd_exp = s_max( max_gd_exp, exp_gd_tmp_buf[i] ); } exp_gd_tmp = max_gd_exp; diff --git a/lib_isar/lib_isar_post_rend.c b/lib_isar/lib_isar_post_rend.c index 61b4c02cb53772a283f24bc7ded7b4634ae78fa0..1f0b01a838835ccacd3e09c1cdebbc56e2844bab 100644 --- a/lib_isar/lib_isar_post_rend.c +++ b/lib_isar/lib_isar_post_rend.c @@ -310,8 +310,7 @@ static Word32 limitRendererOutput_fx( /* Apply clipping to buffer in case the limiter let through some samples > 1.0f */ FOR( i = 0; i < output_frame * num_channels; ++i ) { - - output[i] = min( max( L_shl( INT16_MIN, q_factor ), output[i] ), L_shl( INT16_MAX, q_factor ) ); + output[i] = L_min( L_max( L_shl( INT16_MIN, q_factor ), output[i] ), L_shl( INT16_MAX, q_factor ) ); } return numClipping; @@ -490,7 +489,7 @@ static ivas_error updateSplitPostRendPanGains( IF( GT_16( hRendCfg->codec_frame_size_ms, 0 ) ) { iNumLCLDIterationsPerFrame = (Word16) config.isar_frame_duration_us / ( 1000 * hRendCfg->codec_frame_size_ms ); - iNumLCLDIterationsPerFrame = max( 1, iNumLCLDIterationsPerFrame ); + iNumLCLDIterationsPerFrame = s_max( 1, iNumLCLDIterationsPerFrame ); iNumBlocksPerFrame = CLDFB_NO_COL_MAX * hRendCfg->codec_frame_size_ms / 20; } ELSE @@ -1003,7 +1002,7 @@ ivas_error ISAR_POST_REND_GetDelay( { latency_ns += IVAS_FB_DEC_DELAY_NS; } - max_latency_ns = max( max_latency_ns, latency_ns ); + max_latency_ns = L_max( max_latency_ns, latency_ns ); } } diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index f6fa52c29d0b7593b6ac204b4f89776ccad26627..e87ed4b9706f95ffb253fceaa8b115a8c5460464 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -6574,7 +6574,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( IF( GT_32( totalTargetEne, 0 ) ) { - tempDivisor = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q28, max( EPSILON_FX, totalTargetEne ), &temp_q ); + tempDivisor = BASOP_Util_Divide3232_Scale_newton( ONE_IN_Q28, L_max( EPSILON_FX, totalTargetEne ), &temp_q ); temp_q = sub( sub( Q31, temp_q ), sub( sub( Q31, Q28 ), sub( Q31, subQ ) ) ); @@ -6607,7 +6607,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( IF( enableCentering ) { temp1 = abs_s( sub( panEnesIn[ismDirIndex][0], panEnesOut[ismDirIndex][0] ) ); // 2*sub(enes) -> Q14 - centeringFactor = max( 0, sub( temp1, ONE_IN_Q14 ) ); // Q14 + centeringFactor = s_max( 0, sub( temp1, ONE_IN_Q14 ) ); // Q14 FOR( ch = 0; ch < 2; ch++ ) { diff --git a/lib_rend/ivas_output_init_fx.c b/lib_rend/ivas_output_init_fx.c index 95a225aba354bdc39baf7120a335f333f1d3f156..0ac341e39add2b5c711c585c32e6b7db2069876c 100644 --- a/lib_rend/ivas_output_init_fx.c +++ b/lib_rend/ivas_output_init_fx.c @@ -387,7 +387,7 @@ Word16 ivas_get_nchan_buffers_dec_fx( } ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) { - nchan_out_buff = max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); + nchan_out_buff = s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); IF( st_ivas->hOutSetup.separateChannelEnabled ) { @@ -408,7 +408,7 @@ Word16 ivas_get_nchan_buffers_dec_fx( test(); IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { - nchan_out_buff = max( nchan_out_buff, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS ); + nchan_out_buff = s_max( nchan_out_buff, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS ); } return nchan_out_buff; diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index eaed6ebf5dc4edbc6380504fb6c90b5517bc20a1..437c02f6ba00c9891f5fce5678cdd7ab4d146387 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -6385,7 +6385,7 @@ static ivas_error rotateFrameMc_fx( /* move gains to gains_prev */ FOR( i = 0; i < nchan; i++ ) { - MVR2R_WORD32( gains[i], gains_prev[i], nchan ); + Copy32( gains[i], gains_prev[i], nchan ); } } @@ -7462,7 +7462,7 @@ static ivas_error renderLfeToBinaural_fx( v_multc_fx( lfeInput, gain_fx, tmpLfeBuffer + num_cpy_smpl_prev_frame, num_cpy_smpl_cur_frame ); /* Qx - 1 */ /* Save remaining LFE samples of current frame for next frame */ - MVR2R_WORD32( lfeInput + num_cpy_smpl_cur_frame, mcInput->lfeDelayBuffer_fx, num_cpy_smpl_prev_frame ); + Copy32( lfeInput + num_cpy_smpl_cur_frame, mcInput->lfeDelayBuffer_fx, num_cpy_smpl_prev_frame ); r_shift = sub( sub( in_q, 1 ), out_q ); IF( r_shift != 0 ) diff --git a/lib_util/ivas_rtp_pi_data.c b/lib_util/ivas_rtp_pi_data.c index 6d93dc1f86d0dec13857f758f0b4ba49a705ae12..c4e377baeb4d642406ef6406f370e22b7524b800 100644 --- a/lib_util/ivas_rtp_pi_data.c +++ b/lib_util/ivas_rtp_pi_data.c @@ -41,11 +41,6 @@ #define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) ) #endif -#ifndef max -#define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) ) -#endif - - /* Generic PI data packing/unpacking functions */ typedef ivas_error ( *PACK_PI_FN )( const IVAS_PIDATA_GENERIC *piData, uint8_t *buffer, uint32_t maxDataBytes, uint32_t *nBytesWritten ); typedef ivas_error ( *UNPACK_PI_FN )( const uint8_t *buffer, uint32_t numDataBytes, IVAS_PIDATA_GENERIC *piData ); diff --git a/lib_util/obj_edit_file_reader.c b/lib_util/obj_edit_file_reader.c index 2d9a2fd6e084f7e07daa8feda60efe4bb8a4386b..fee43f23c1b006d3ff5691797e5486aeb121b9da 100644 --- a/lib_util/obj_edit_file_reader.c +++ b/lib_util/obj_edit_file_reader.c @@ -33,9 +33,16 @@ the United Nations Convention on Contracts on the International Sales of Goods. #include #include #include "obj_edit_file_reader.h" -#include "prot_fx.h" +#ifndef min +#define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) ) +#endif + +#ifndef max +#define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) ) +#endif + /*-----------------------------------------------------------------------* * ObjectEditFileReader_open() * diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 89fd65058725495b633e47079c60dc3c4943cca0..26291be99338cc7836c0d2d0fead3f9937b60382 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -87,14 +87,6 @@ #define FALSE 0 #endif -#ifndef min -#define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) ) -#endif - -#ifndef max -#define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) ) -#endif - /*------------------------------------------------------------------------------------------* * Local Type definitions @@ -661,8 +653,14 @@ static ivas_error read_bin_code_word( /* First read minLen bits, then add one bit per iteration to find the correct value */ for ( n = 0; n < size; n++ ) { - minLen = min( minLen, pLengths[n] ); - maxLen = max( maxLen, pLengths[n] ); + if ( minLen < pLengths[n] ) + { + minLen = pLengths[n]; + } + if ( pLengths[n] > maxLen ) + { + maxLen = pLengths[n]; + } } for ( len = minLen; len <= maxLen; len++ ) {