diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index e334a8cda710a8f1b77644f9c9fdd5177922aa5d..a1b484f6db3d0b97aa836ee217f5c7cfeec73d16 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -606,7 +606,9 @@ Word64 dot_product_cholesky_fixed( { Word16 i, j; Word64 suma, tmp_sum; +#ifndef OPT_MCT_ENC_V3_BE Word32 mul; +#endif Word32 tmp; const Word32 *pt_x, *pt_A; pt_A = A; @@ -621,12 +623,20 @@ Word64 dot_product_cholesky_fixed( FOR( j = 0; j <= i; j++ ) { +#ifdef OPT_MCT_ENC_V3_BE + tmp_sum = W_add( tmp_sum, Mpy_32_32( *pt_x++, *pt_A++ ) ); +#else mul = Mpy_32_32( *pt_x++, *pt_A++ ); tmp_sum = W_add( tmp_sum, W_deposit32_l( mul ) ); +#endif } +#ifdef OPT_MCT_ENC_V3_BE + tmp = W_shl_sat_l( tmp_sum, -4 ); // to make sure that the tmp_sum will not overflow +#else tmp_sum = W_shr( tmp_sum, 4 ); // to make sure that the tmp_sum will not overflow tmp = W_extract_l( tmp_sum ); +#endif suma = W_mac_32_32( suma, tmp, tmp ); } diff --git a/lib_com/options.h b/lib_com/options.h index 48d8593c8dce8115c797c9c7d4d6d06bad3390a1..90f1239d80f74e63a6f678ed46db56b1f316f2b9 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -79,6 +79,7 @@ /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ +#define OPT_MCT_ENC_V3_BE #define OPT_MCT_ENC_V3_NBE #define OPT_MCT_ENC_V2_BE #define OPT_BIN_REND_V2_NBE diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index 0d42e5ff219f881f2fed2fb8bfb20cf00e109df0..48ed114c714a04829f3e88aaf4d633c9368461d6 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -727,6 +727,9 @@ static void ivas_find_enr( Word32 min_ener; Word16 shift = 0; move16(); +#ifdef OPT_MCT_ENC_V3_BE + Word16 tmp_shift; +#endif ptR = &data[1]; /* first real */ ptI = &data[L_FFT - 1]; /* first imaginary */ @@ -756,13 +759,20 @@ static void ivas_find_enr( freq = BIN_FREQ_FX; move16(); +#ifdef OPT_MCT_ENC_V3_BE + tmp_shift = sub( -Q16, shift ); // 16 - shift - 32 +#endif FOR( i = 0; i < voic_band; i++ ) /* up to maximum allowed voiced critical band */ { band_ener = 0; move64(); start_freq = freq; move16(); +#ifdef OPT_MCT_ENC_V3_BE + FOR( ; LE_32( freq, crit_bands_fx[i] ); ) +#else WHILE( LE_32( freq, crit_bands_fx[i] ) ) +#endif { /* *ptE = *ptR * *ptR + *ptI * *ptI; @@ -795,7 +805,11 @@ static void ivas_find_enr( freq = add( freq, BIN_FREQ_FX ); } +#ifdef OPT_MCT_ENC_V3_BE + band[i] = W_shl_sat_l( band_ener, tmp_shift ); // *q_band +#else band[i] = W_extract_h( W_shl( band_ener, sub( Q16, shift ) ) ); // *q_band +#endif move32(); band_energies[i] = band[i]; /* per band energy without E_MIN */ // *q_band @@ -820,7 +834,11 @@ static void ivas_find_enr( move64(); start_freq = freq; move16(); +#ifdef OPT_MCT_ENC_V3_BE + FOR( ; LE_32( freq, crit_bands_fx[i] ); ) +#else WHILE( LE_32( freq, crit_bands_fx[i] ) ) +#endif { /* *Bin_E = *ptR * *ptR + *ptI * *ptI; @@ -851,7 +869,11 @@ static void ivas_find_enr( freq = add( freq, BIN_FREQ_FX ); } +#ifdef OPT_MCT_ENC_V3_BE + band[i] = W_shl_sat_l( band_ener, tmp_shift ); // *q_band +#else band[i] = W_extract_h( W_shl_nosat( band_ener, sub( Q16, shift ) ) ); // *q_band +#endif move32(); band_energies[i] = band[i]; /* per band energy without E_MIN */ // *q_band diff --git a/lib_enc/igf_enc.c b/lib_enc/igf_enc.c index 7da9fa6cfa2608c3c955f520764f18ce653a2ea5..0a01dfe6667897772df2872ff2d6089504db72c5 100644 --- a/lib_enc/igf_enc.c +++ b/lib_enc/igf_enc.c @@ -135,7 +135,11 @@ static Word16 IGF_getCrest_new_fx( { x = logSpec[i]; move16(); +#ifdef OPT_MCT_ENC_V3_BE + x_eff = L_mac0( x_eff, x, x ); +#else x_eff = L_add( x_eff, L_mult0( x, x ) ); +#endif if ( GT_16( x, x_max ) ) { diff --git a/lib_enc/ivas_sns_enc_fx.c b/lib_enc/ivas_sns_enc_fx.c index e74e2297c4fb0c7af7587e200d944308c10ef6b8..610f39b1b2f0610a24bd4764d3cfd61ee0dfa108 100644 --- a/lib_enc/ivas_sns_enc_fx.c +++ b/lib_enc/ivas_sns_enc_fx.c @@ -258,7 +258,7 @@ static Word16 sns_1st_cod_fx( } /* for second split shift by five bits to store both indices as one 10 bit value */ - IF( EQ_16( split, 1 ) ) + if ( EQ_16( split, 1 ) ) { index_split = shl( index_split, 5 ); } diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 6ce40b00e3de8307ef7e00fd28acc788b6ca0243..cd4c0729710d1cfbe6e20dc56291699d9f15bbbf 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -2725,15 +2725,15 @@ void tcx_noise_factor_ivas_fx( IF( LE_16( nTransWidth, 3 ) ) { tmp2 = sub( k, c1 ); - IF( tmp2 > 0 ) + if ( tmp2 > 0 ) { n = L_msu( n, k, (Word16) 0x8000 ); } - IF( tmp2 > 0 ) + if ( tmp2 > 0 ) { n = L_mac( n, nTransWidth_1, (Word16) 0x8000 ); } - IF( tmp2 <= 0 ) + if ( tmp2 <= 0 ) { n = L_mac( n, int_sqr[k], c2 ); } @@ -2741,15 +2741,15 @@ void tcx_noise_factor_ivas_fx( ELSE { tmp2 = sub( k, 12 ); - IF( tmp2 > 0 ) + if ( tmp2 > 0 ) { n = L_msu( n, k, (Word16) 0x8000 ); } - IF( tmp2 > 0 ) + if ( tmp2 > 0 ) { n = L_sub( n, 0x70000 ); } - IF( tmp2 <= 0 ) + if ( tmp2 <= 0 ) { n = L_mac( n, int_sqr[k], 1152 /*0.03515625f Q15*/ ); } @@ -2777,7 +2777,7 @@ void tcx_noise_factor_ivas_fx( } ELSE /* current line is zero, so update pointers & segment sum */ { - IF( LT_16( win, nTransWidth ) ) + if ( LT_16( win, nTransWidth ) ) { win = add( win, 1 ); } @@ -2794,15 +2794,15 @@ void tcx_noise_factor_ivas_fx( IF( LE_16( nTransWidth, 3 ) ) { tmp2 = sub( k, c1 ); - IF( tmp2 > 0 ) + if ( tmp2 > 0 ) { n = L_msu( n, k, (Word16) 0x8000 ); } - IF( tmp2 > 0 ) + if ( tmp2 > 0 ) { n = L_mac( n, nTransWidth_1, (Word16) 0x8000 ); } - IF( tmp2 <= 0 ) + if ( tmp2 <= 0 ) { n = L_mac( n, int_sqr[k], c2 ); } @@ -2810,15 +2810,15 @@ void tcx_noise_factor_ivas_fx( ELSE { tmp2 = sub( k, 12 ); - IF( tmp2 > 0 ) + if ( tmp2 > 0 ) { n = L_msu( n, k, (Word16) 0x8000 ); } - IF( tmp2 > 0 ) + if ( tmp2 > 0 ) { n = L_sub( n, 0x70000 ); } - IF( tmp2 <= 0 ) + if ( tmp2 <= 0 ) { n = L_mac( n, int_sqr[k], 1152 /*0.03515625f Q15*/ ); } @@ -3663,7 +3663,10 @@ Word16 tcx_res_Q_spec_ivas_fx( Word16 s, s2, lf_deemph_factor; Word16 c; Word32 thres; - +#ifdef OPT_MCT_ENC_V3_BE + Word16 cmp_1, cmp_2; + Word32 tmp32_1, tmp32_2; +#endif /* Limit the number of residual bits */ sqTargetBits = s_min( sqTargetBits, NPRM_RESQ ); @@ -3679,16 +3682,28 @@ Word16 tcx_res_Q_spec_ivas_fx( move16(); s2 = sub( x_Q_e, 1 ); +#ifdef OPT_MCT_ENC_V3_BE + cmp_1 = sub( sqTargetBits, kMaxEstimatorUndershoot ); + cmp_2 = s_min( NPRM_RESQ, add( sqTargetBits, kMaxEstimatorOvershoot ) ); +#endif FOR( i = 0; i < L_frame; i++ ) { +#ifdef OPT_MCT_ENC_V3_BE + IF( GE_16( bits, cmp_1 ) ) +#else IF( GE_16( bits, sub( sqTargetBits, kMaxEstimatorUndershoot ) ) ) +#endif { fac_m = 0; move16(); fac_p = 0; move16(); +#ifdef OPT_MCT_ENC_V3_BE + IF( GE_16( bits, cmp_2 ) ) +#else IF( GE_16( bits, s_min( NPRM_RESQ, add( sqTargetBits, kMaxEstimatorOvershoot ) ) ) ) +#endif { BREAK; } @@ -3700,11 +3715,11 @@ Word16 tcx_res_Q_spec_ivas_fx( { tmp1 = L_add( x_orig[i], 0 ); tmp2 = Mpy_32_16_1( x_Q[i], sqGain ); - IF( s > 0 ) + if ( s > 0 ) { tmp2 = L_shr( tmp2, s ); } - IF( s < 0 ) + if ( s < 0 ) { tmp1 = L_shl( tmp1, s ); } @@ -3721,11 +3736,11 @@ Word16 tcx_res_Q_spec_ivas_fx( move16(); bits = add( bits, 1 ); - IF( x_Q[i] > 0 ) + if ( x_Q[i] > 0 ) { tmp1 = L_mult( fac_m, lf_deemph_factor ); } - IF( x_Q[i] < 0 ) + if ( x_Q[i] < 0 ) { tmp1 = L_mult( fac_p, lf_deemph_factor ); } @@ -3738,11 +3753,11 @@ Word16 tcx_res_Q_spec_ivas_fx( move16(); bits = add( bits, 1 ); - IF( x_Q[i] > 0 ) + if ( x_Q[i] > 0 ) { tmp1 = L_mult( fac_p, lf_deemph_factor ); } - IF( x_Q[i] < 0 ) + if ( x_Q[i] < 0 ) { tmp1 = L_mult( fac_m, lf_deemph_factor ); } @@ -3755,12 +3770,17 @@ Word16 tcx_res_Q_spec_ivas_fx( /*Quantize zeroed-line of the spectrum*/ c = sub( 21627 /*0.66f Q15*/, mult_r( sq_round, 21627 /*0.66f Q15*/ ) ); +#ifdef OPT_MCT_ENC_V3_BE + FOR( i = 0; ( i < L_frame ) && ( bits < ( sqTargetBits - 2 ) ); i++ ) + { +#else FOR( i = 0; i < L_frame; i++ ) { IF( GE_16( bits, sub( sqTargetBits, 2 ) ) ) { BREAK; } +#endif test(); test(); @@ -3777,8 +3797,15 @@ Word16 tcx_res_Q_spec_ivas_fx( tmp1 = Mpy_32_16_1( thres, sqGain ); +#ifdef OPT_MCT_ENC_V3_BE + tmp32_1 = L_shl( x_orig[i], sub( x_orig_e, shift_tmp ) ); + tmp32_2 = L_shl( tmp1, sub( sqGain_e, shift_tmp ) ); + IF( GT_32( tmp32_1, tmp32_2 ) ) + { +#else IF( GT_32( L_shl( x_orig[i], sub( x_orig_e, shift_tmp ) ), L_shl( tmp1, sub( sqGain_e, shift_tmp ) ) ) ) { +#endif prm[bits] = 1; move16(); bits = add( bits, 1 ); @@ -3790,7 +3817,11 @@ Word16 tcx_res_Q_spec_ivas_fx( x_Q[i] = L_shl( thres, sub( 1, x_Q_e ) ); move32(); } +#ifdef OPT_MCT_ENC_V3_BE + ELSE IF( L_add( tmp32_1, tmp32_2 ) < 0 ) +#else ELSE IF( L_add( L_shl( x_orig[i], sub( x_orig_e, shift_tmp ) ), L_shl( tmp1, sub( sqGain_e, shift_tmp ) ) ) < 0 ) +#endif { prm[bits] = 1; move16();