diff --git a/apps/decoder.c b/apps/decoder.c index 0073ad93508926ed913586bbffa91f5afa3e49e5..2588e8d3c037be52ed142b53ecb874b4721fe915 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3195,7 +3195,7 @@ static ivas_error decodeVoIP( #ifdef SUPPORT_JBM_TRACEFILE if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered, ¶metersAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK ) #else - if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, &bitstreamReadDone, &nSamplesRendered, ¶metersAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, &bitstreamReadDone, ¶metersAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK ) #endif { fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); diff --git a/lib_basop/basop32.c b/lib_basop/basop32.c index 1b9ef845d8792aba2a0b89569d297bc7d1f8e8ca..64360e3c107d4bf9e5f178927de1c88bf6ee2532 100644 --- a/lib_basop/basop32.c +++ b/lib_basop/basop32.c @@ -1224,6 +1224,52 @@ Word16 extract_l( Word32 L_var1 ) return ( var_out ); } +#ifdef FIX_2493_CHECK_EXTRACT_L +/*___________________________________________________________________________ + | | + | Function Name : extract_l2 | + | | + | Purpose : | + | | + | Return the 16 LSB of L_var1. Check range. | + | | + | Complexity weight : 1 | + | | + | Inputs : | + | | + | L_var1 | + | 32 bit long signed integer (Word32 ) whose value falls in the | + | range : 0xffff 8000 <= L_var1 <= 0x0000 7fff. | + | | + | Outputs : | + | | + | none | + | | + | Return Value : | + | | + | var_out | + | 16 bit short signed integer (Word16) whose value falls in the | + | range : 0xffff 8000 <= var_out <= 0x0000 7fff. | + |___________________________________________________________________________| +*/ +Word16 extract_l2( Word32 L_var1 ) +{ + Word16 var_out; + + assert( L_var1 <=(Word32)MAX_16 && L_var1 >= (Word32)(Word16)MIN_16 ); + + var_out = (Word16) L_var1; + +#ifdef WMOPS + multiCounter[currCounter].extract_l++; +#endif + + BASOP_CHECK(); + + + return ( var_out ); +} +#endif /*___________________________________________________________________________ | | diff --git a/lib_basop/basop32.h b/lib_basop/basop32.h index 7fe294167c38a962ea16d6b8dfbbdb14cb52384b..dbabf94009b31534a24870fd5522f86ace039397 100644 --- a/lib_basop/basop32.h +++ b/lib_basop/basop32.h @@ -129,6 +129,9 @@ Word32 L_mult( Word16 var1, Word16 var2 ); /* Word16 negate( Word16 var1 ); /* Short negate, 1 */ Word16 extract_h( Word32 L_var1 ); /* Extract high, 1 */ Word16 extract_l( Word32 L_var1 ); /* Extract low, 1 */ +#ifdef FIX_2493_CHECK_EXTRACT_L +Word16 extract_l2( Word32 L_var1 ); /* Extract low and check range 1 */ +#endif Word16 round_fx( Word32 L_var1 ); /* Round, 1 */ Word32 L_mac( Word32 L_var3, Word16 var1, Word16 var2 ); /* Mac, 1 */ Word32 L_msu( Word32 L_var3, Word16 var1, Word16 var2 ); /* Msu, 1 */ diff --git a/lib_basop/enh64.c b/lib_basop/enh64.c index 8bffb620cc8dfb0b2164e718b83fa365fb048430..6acc843599c4bb2b484c615d610e1d21fd418bf9 100644 --- a/lib_basop/enh64.c +++ b/lib_basop/enh64.c @@ -18,6 +18,10 @@ #include #include "stl.h" +#ifdef FIX_2493_CHECK_64BIT +#include +#endif + #define WMC_TOOL_SKIP /***************************************************************************** @@ -74,7 +78,9 @@ Word64 W_add_nosat( Word64 L64_var1, Word64 L64_var2 ) { Word64 L64_var_out; - +#ifdef FIX_2493_CHECK_64BIT + assert( W_abs( ( ( L64_var1 + L64_var2 ) >> 1 ) - ( ( L64_var1 >> 1 ) + ( L64_var2 >> 1 ) ) ) < 2 ); +#endif L64_var_out = L64_var1 + L64_var2; #ifdef WMOPS @@ -117,7 +123,9 @@ Word64 W_add_nosat( Word64 L64_var1, Word64 L64_var2 ) Word64 W_sub_nosat( Word64 L64_var1, Word64 L64_var2 ) { Word64 L64_var_out; - +#ifdef FIX_2493_CHECK_64BIT + assert( W_abs( ( ( L64_var1 - L64_var2 ) >> 1 ) - ( ( L64_var1 >> 1 ) - ( L64_var2 >> 1 ) ) ) < 2 ); +#endif L64_var_out = L64_var1 - L64_var2; #ifdef WMOPS @@ -316,6 +324,9 @@ Word64 W_shl_nosat( Word64 L64_var1, Word16 var2 ) } else { +#ifdef FIX_2493_CHECK_64BIT + assert( ( ( L64_var1 << var2 ) >> var2 ) == L64_var1 ); +#endif L64_var_out = L64_var1 << var2; } #ifdef WMOPS @@ -369,6 +380,9 @@ Word64 W_shr_nosat( Word64 L64_var1, Word16 var2 ) if ( var2 < 0 ) { var2 = -var2; +#ifdef FIX_2493_CHECK_64BIT + assert( ( ( L64_var1 << var2 ) >> var2 ) == L64_var1 ); +#endif L64_var_out = L64_var1 << var2; } else @@ -423,6 +437,9 @@ Word64 W_shr_nosat( Word64 L64_var1, Word16 var2 ) Word64 W_mac_32_16( Word64 L64_var1, Word32 L_var2, Word16 var3 ) { Word64 L64_var_out = ( (Word64) L_var2 * var3 ) << 1; +#ifdef FIX_2493_CHECK_64BIT + assert( W_abs( ( ( L64_var_out + L64_var1 ) >> 1 ) - ( ( L64_var_out >> 1 ) + ( L64_var1 >> 1 ) ) ) < 2 ); +#endif L64_var_out += L64_var1; #ifdef WMOPS multiCounter[currCounter].W_mac_32_16++; @@ -470,6 +487,9 @@ Word64 W_mac_32_16( Word64 L64_var1, Word32 L_var2, Word16 var3 ) Word64 W_msu_32_16( Word64 L64_var1, Word32 L_var2, Word16 var3 ) { Word64 L64_var_out = ( (Word64) L_var2 * var3 ) << 1; +#ifdef FIX_2493_CHECK_64BIT + assert( W_abs( ( ( L64_var1 - L64_var_out ) >> 1 ) - ( ( L64_var1 >> 1 ) - ( L64_var_out >> 1 ) ) ) < 2 ); +#endif L64_var_out = L64_var1 - L64_var_out; #ifdef WMOPS multiCounter[currCounter].W_msu_32_16++; @@ -596,6 +616,9 @@ Word64 W_mult0_16_16( Word16 var1, Word16 var2 ) Word64 W_mac0_16_16( Word64 L64_var1, Word16 var2, Word16 var3 ) { Word64 L64_var_out = (Word64) var2 * var3; +#ifdef FIX_2493_CHECK_64BIT + assert( W_abs( ( ( L64_var_out + L64_var1 ) >> 1 ) - ( ( L64_var_out >> 1 ) + ( L64_var1 >> 1 ) ) ) < 2 ); +#endif L64_var_out += L64_var1; #ifdef WMOPS multiCounter[currCounter].W_mac0_16_16++; @@ -642,6 +665,9 @@ Word64 W_mac0_16_16( Word64 L64_var1, Word16 var2, Word16 var3 ) Word64 W_msu0_16_16( Word64 L64_var1, Word16 var2, Word16 var3 ) { Word64 L64_var_out = (Word64) var2 * var3; +#ifdef FIX_2493_CHECK_64BIT + assert( W_abs( ( ( L64_var1 - L64_var_out ) >> 1 ) - ( ( L64_var1 >> 1 ) - ( L64_var_out >> 1 ) ) ) < 2 ); +#endif L64_var_out = L64_var1 - L64_var_out; #ifdef WMOPS multiCounter[currCounter].W_msu0_16_16++; @@ -868,6 +894,52 @@ Word32 W_extract_l( Word64 L64_var1 ) return ( L_var_out ); } +#ifdef FIX_2493_CHECK_EXTRACT_L + +#include + +/*__________________________________________________________________________________ +| | +| Function Name : W_extract_l | +| | +| Purpose : | +| | +| Return the 32 LSB of L64_var1 and check the range | +| | +| Complexity weight : 1 | +| | +| Inputs : | +| | +| L64_var1 | +| 64 bit long long signed integer (Word64) whose value falls in | +| range : 0x00000000 80000000LL <= L64_var1 <= 0xffffffff 7fffffffLL. | +| | +| Outputs : | +| | +| none | +| | +| Return Value : | +| | +| L_var_out | +| 32 bit long signed integer (Word32) whose value falls in the | +| range : 0x8000 0000 <= L_var_out <= 0x7fff 0000. | +|__________________________________________________________________________________| +*/ +Word32 W_extract_l2( Word64 L64_var1 ) +{ + Word32 L_var_out; + + assert( L64_var1 <= (Word64) MAX_32 && L64_var1 >= (Word64) (Word32) MIN_32 ); + + L_var_out = (Word32) L64_var1; + +#ifdef WMOPS + multiCounter[currCounter].W_extract_l++; +#endif /* if WMOPS */ + + return ( L_var_out ); +} +#endif /*__________________________________________________________________________________ | | diff --git a/lib_basop/enh64.h b/lib_basop/enh64.h index c3896bb0d257aa053df48da5c84948b8255e0401..7a326738fc3b205384598608b26e42bc50c7b435 100644 --- a/lib_basop/enh64.h +++ b/lib_basop/enh64.h @@ -47,6 +47,9 @@ Word32 W_sat_m( Word64 L64_var ); Word32 W_shl_sat_l( Word64 L64_var, Word16 n ); Word32 W_extract_l( Word64 L64_var1 ); +#ifdef FIX_2493_CHECK_EXTRACT_L +Word32 W_extract_l2( Word64 L64_var1 ); +#endif Word32 W_extract_h( Word64 L64_var1 ); Word32 W_round48_L( Word64 L64_var1 ); diff --git a/lib_com/cng_exc_fx.c b/lib_com/cng_exc_fx.c index 5ba48494eea584f46abc58840f6f013747489a9e..1c90b58b701a77bef7552b2f75353350c97ac0b9 100644 --- a/lib_com/cng_exc_fx.c +++ b/lib_com/cng_exc_fx.c @@ -690,7 +690,11 @@ void cng_params_postupd_fx( exp_pow = sub( 14, temp_hi_fx ); L_tmp = Pow2( 14, temp_lo_fx ); /* Qexp_pow */ L_tmp = L_shl( L_tmp, sub( 13, exp_pow ) ); /* Q13 */ - tmp = extract_l( L_tmp ); /* Q13 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l2( L_tmp ); /* Q13 */ +#else + tmp = extract_l( L_tmp ); /* Q13 */ +#endif exp1 = norm_s( tmp ); tmp = shl( tmp, exp1 ); /*Q(exp1+13) */ @@ -889,7 +893,11 @@ void cng_params_upd_fx( exp_pow = sub( 14, temp_hi_fx ); L_tmp = Pow2( 14, temp_lo_fx ); /* Qexp_pow */ L_tmp = L_shl( L_tmp, sub( 13, exp_pow ) ); /* Q13 */ - tmp = extract_l( L_tmp ); /* Q13 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l2( L_tmp ); /* Q13 */ +#else + tmp = extract_l( L_tmp ); /* Q13 */ +#endif exp1 = norm_s( tmp ); tmp = shl( tmp, exp1 ); /*Q(exp1+13) */ diff --git a/lib_com/fft_fx_evs.c b/lib_com/fft_fx_evs.c index 5cbfbc2503a3549140d1299ed0d513f7dd40b7d6..5f99375b7580c984daf998a1e9e8f2885eef3915 100644 --- a/lib_com/fft_fx_evs.c +++ b/lib_com/fft_fx_evs.c @@ -511,8 +511,13 @@ static void cft1st_fx( move16(); wk1i = w[k2 + 1]; move16(); +#ifdef FIX_2493_CHECK_EXTRACT_L + wk3r = extract_l2( L_sub( L_deposit_l( wk1r ), L_shr( L_mult( wk2i, wk1i ), 14 ) ) ); + wk3i = extract_l2( L_msu0( L_shr( L_mult( wk2i, wk1r ), 14 ), wk1i, 1 ) ); +#else wk3r = extract_l( L_sub( L_deposit_l( wk1r ), L_shr( L_mult( wk2i, wk1i ), 14 ) ) ); wk3i = extract_l( L_msu0( L_shr( L_mult( wk2i, wk1r ), 14 ), wk1i, 1 ) ); +#endif x0r = L_add( a[j], a[j + 2] ); x0i = L_add( a[j + 1], a[j + 3] ); x1r = L_sub( a[j], a[j + 2] ); @@ -548,8 +553,13 @@ static void cft1st_fx( move16(); wk1i = w[k2 + 3]; move16(); +#ifdef FIX_2493_CHECK_EXTRACT_L + wk3r = extract_l2( L_sub( L_deposit_l( wk1r ), L_shr( L_mult( wk2r, wk1i ), 14 ) ) ); + wk3i = extract_l2( L_msu0( L_shr( L_mult( wk2r, wk1r ), 14 ), wk1i, 1 ) ); +#else wk3r = extract_l( L_sub( L_deposit_l( wk1r ), L_shr( L_mult( wk2r, wk1i ), 14 ) ) ); wk3i = extract_l( L_msu0( L_shr( L_mult( wk2r, wk1r ), 14 ), wk1i, 1 ) ); +#endif x0r = L_add( a[j + 8], a[j + 10] ); x0i = L_add( a[j + 9], a[j + 11] ); x1r = L_sub( a[j + 8], a[j + 10] ); @@ -686,8 +696,13 @@ static void cftmdl_fx( move16(); wk1i = w[k2 + 1]; move16(); +#ifdef FIX_2493_CHECK_EXTRACT_L + wk3r = extract_l2( L_sub( L_deposit_l( wk1r ), L_shr( L_mult( wk2i, wk1i ), 14 ) ) ); + wk3i = extract_l2( L_msu0( L_shr( L_mult( wk2i, wk1r ), 14 ), wk1i, 1 ) ); +#else wk3r = extract_l( L_sub( L_deposit_l( wk1r ), L_shr( L_mult( wk2i, wk1i ), 14 ) ) ); wk3i = extract_l( L_msu0( L_shr( L_mult( wk2i, wk1r ), 14 ), wk1i, 1 ) ); +#endif tmp = add( l, k ); FOR( j = k; j < tmp; j += 2 ) @@ -731,8 +746,13 @@ static void cftmdl_fx( move16(); wk1i = w[k2 + 3]; move16(); +#ifdef FIX_2493_CHECK_EXTRACT_L + wk3r = extract_l2( L_sub( L_deposit_l( wk1r ), L_shr( L_mult( wk2r, wk1i ), 14 ) ) ); + wk3i = extract_l2( L_msu0( L_shr( L_mult( wk2r, wk1r ), 14 ), wk1i, 1 ) ); +#else wk3r = extract_l( L_sub( L_deposit_l( wk1r ), L_shr( L_mult( wk2r, wk1i ), 14 ) ) ); wk3i = extract_l( L_msu0( L_shr( L_mult( wk2r, wk1r ), 14 ), wk1i, 1 ) ); +#endif tmp = add( l, add( k, m ) ); FOR( j = k + m; j < tmp; j += 2 ) @@ -2017,7 +2037,9 @@ static void cftmdl_16fx( Word16 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i; Word16 tmp, tmp2; Word32 L_tmp; +#ifndef NONBE_FIX_2493_EXTRACT_L_cftmdl_16fx Word32 L_x0r, L_x0i; +#endif m = shl( l, 2 ); FOR( j = 0; j < l; j += 2 ) @@ -2167,10 +2189,20 @@ static void cftmdl_16fx( a[j1 + 1] = round_fx_sat( L_shl_sat( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ move16(); +#ifdef NONBE_FIX_2493_EXTRACT_L_cftmdl_16fx + x0r = add_sat( x1r, x3i ); + x0i = sub_sat( x1i, x3r ); +#else L_x0r = L_add( (Word32) x1r, (Word32) x3i ); L_x0i = L_sub( (Word32) x1i, (Word32) x3r ); +#ifdef FIX_2493_CHECK_EXTRACT_L_EVS + x0r = extract_l2( L_x0r ); + x0i = extract_l2( L_x0i ); +#else x0r = extract_l( L_x0r ); x0i = extract_l( L_x0i ); +#endif +#endif L_tmp = Mult_32_16( wk3r, x0r ); /*Q(15+Qx+Q_edct) */ L_tmp = Msub_32_16( L_tmp, wk3i, x0i ); /*Q(15+Qx+Q_edct) */ a[j3] = round_fx_sat( L_shl_sat( L_tmp, 1 ) ); /*Q(Qx+Q_edct) */ diff --git a/lib_com/gs_bitallocation_fx.c b/lib_com/gs_bitallocation_fx.c index 3bea7756b8aac348b325cc0573e12b9b38a8fad3..fab4f031151ba98914a67cedb1f3d1c472ec9c7a 100644 --- a/lib_com/gs_bitallocation_fx.c +++ b/lib_com/gs_bitallocation_fx.c @@ -196,14 +196,22 @@ void bands_and_bit_alloc_fx( { /* *bit = (short)(core_brate*(1.0f/50) + 0.5f) - bits_used - 25; */ L_tmp = Mult_32_16( core_brate, 20971 /*1/50 in Q20*/ ); +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l2( L_shr_r( L_tmp, 5 ) ); +#else tmp = extract_l( L_shr_r( L_tmp, 5 ) ); +#endif *bit = sub( sub( tmp, bits_used ), 25 ); /*Q0*/ move16(); } ELSE { L_tmp = Mult_32_16( core_brate, 20971 /*1/50 in Q20*/ ); +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l2( L_shr_r( L_tmp, 5 ) ); +#else tmp = extract_l( L_shr_r( L_tmp, 5 ) ); +#endif *bit = sub( sub( tmp, bits_used ), 21 ); /*Q0*/ move16(); } @@ -215,7 +223,11 @@ void bands_and_bit_alloc_fx( /* *bit = (short)(core_brate*(1.0f/50) + 0.5f) - bits_used - GSC_freq_bits[bit_index]; */ L_tmp = Mult_32_16( core_brate, 20971 /*1/50 in Q20*/ ); +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l2( L_shr_r( L_tmp, 5 ) ); +#else tmp = extract_l( L_shr_r( L_tmp, 5 ) ); +#endif *bit = sub( sub( tmp, bits_used ), GSC_freq_bits[bit_index] ); move16(); } @@ -548,7 +560,11 @@ void bands_and_bit_alloc_fx( { bits_per_bands[j] = L_add( bits_per_bands[j], L_shl( etmp, Q3 ) ); /* Q18 */ move32(); +#ifdef FIX_2493_CHECK_EXTRACT_L + etmp = extract_l2( L_add( etmp, L_shr( bit_fracf, Q3 ) ) ); +#else etmp = extract_l( L_add( etmp, L_shr( bit_fracf, Q3 ) ) ); +#endif } } ELSE @@ -731,7 +747,11 @@ void bands_and_bit_alloc_fx( move16(); FOR( i = 0; i < nb_bands; i++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + out_bits_per_bands[i] = shl( extract_l2( L_shr( bits_per_bands[i], 18 ) ), 3 ); +#else out_bits_per_bands[i] = shl( extract_l( L_shr( bits_per_bands[i], 18 ) ), 3 ); +#endif move16(); w_sum_bit = add( w_sum_bit, out_bits_per_bands[i] ); /* Q3 */ } diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index c1654b43384778914ec6e1e71f04fbfcf5649491..eaf11eb6c0fd9dc0ea303ca7e6220865c8e852ab 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -125,9 +125,15 @@ Word16 Comp_and_apply_gain_fx( L32 = L_mult( L16, 27213 ); /* 3.321928 in Q13 -> Q26 */ L32 = L_shr( L32, 10 ); /* From Q26 to Q16 */ frac = L_Extract_lc( L32, &exp1 ); /* Extract exponent of gcode0 */ - y_gain = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ - /* output of Pow2() will be: */ - /* 16384 < Pow2() <= 32767 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + y_gain = extract_l2( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ + /* output of Pow2() will be: */ + /* 16384 < Pow2() <= 32767 */ +#else + y_gain = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ + /* output of Pow2() will be: */ + /* 16384 < Pow2() <= 32767 */ +#endif Ener_per_bd_yQ[i_band] = shl_sat( y_gain, sub( exp1, 13 ) ); move16(); /*Q1 */ tmp_exp = add( add( exp1, 1 ), sub( Q_exc, Qexc_diff ) ); diff --git a/lib_com/gs_inact_switching_fx.c b/lib_com/gs_inact_switching_fx.c index db833220ebac37463ea5236e561ab17c4043374a..fa5670cc78de5628fd64ab072f8fbf44c4aa8ea3 100644 --- a/lib_com/gs_inact_switching_fx.c +++ b/lib_com/gs_inact_switching_fx.c @@ -122,10 +122,14 @@ void Inac_switch_ematch_fx( /* ftmp = (float)pow(10, ftmp);= pow(2,3.321928*ftmp);*/ - L_tmp = L_mult( 27213, ftmp ); /*Q(13+12+1)=Q26 ; 27213=3.321928 in Q13 */ - L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */ - frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of ftmp */ + L_tmp = L_mult( 27213, ftmp ); /*Q(13+12+1)=Q26 ; 27213=3.321928 in Q13 */ + L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */ + frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of ftmp */ +#ifdef FIX_2493_CHECK_EXTRACT_L + ftmp = extract_l2( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#else ftmp = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#endif /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index 534f9edc224ed1c82fc4ec102ad014adbcf4a589..7118b33a091bc76b5914e443408014dbede9de51 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -348,7 +348,11 @@ void freq_dnw_scaling_fx( ELSE { /*sc_dyn = (float)(NOISE_LEVEL_SP3 - noise_lev)/10.0f + 0.4f;*/ +#ifdef FIX_2493_CHECK_EXTRACT_L + sc_dyn = extract_l2( L_mac( 13107, sub( NOISE_LEVEL_SP3, noise_lev ), 1638 ) ); /*Q0*Q14x2+Q15 =Q15*/ +#else sc_dyn = extract_l( L_mac( 13107, sub( NOISE_LEVEL_SP3, noise_lev ), 1638 ) ); /*Q0*Q14x2+Q15 =Q15*/ +#endif start_sc = add( 112, shl( sub( NOISE_LEVEL_SP3, noise_lev ), 4 ) ); if ( EQ_16( noise_lev, NOISE_LEVEL_SP0 ) ) { @@ -552,8 +556,12 @@ static void envelop_modify_fx( /*Ener1 = (float)(0.4f*pow(10, Ener_per_bd_iQ[i+1])); */ L_tmp = L_shr( L_mult0( Ener_per_bd_iQ_fx[i + 1], 27213 ), 9 ); /* 3.321928 in Q13 -> Q16 */ - frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */ + frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l2( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#else tmp = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#endif /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp = sub( exp, 14 ); @@ -562,9 +570,17 @@ static void envelop_modify_fx( FOR( j = 0; j < 16; j++ ) { /**src = Ener1*(weight*(*src)*Ener + (1.0f-weight)*own_random(seed_tcx)/32768.0f); */ - L_tmp = Mult_32_16( Ener_fx, *src_fx ); /*Q(31-exp+Q_exc-15) -> Q(16-exp+Q_exc) */ + L_tmp = Mult_32_16( Ener_fx, *src_fx ); /*Q(31-exp+Q_exc-15) -> Q(16-exp+Q_exc) */ +#ifdef NONBE_FIX_2493_EXTRACT_L_envelop_modify_fx + tmp = extract_h( Mpy_32_16_1( L_shr( L_tmp, add( 4, sub( Q_exc, exp1 ) ) ), weight_fx ) ); /*Q12 */ +#else +#ifdef FIX_2493_CHECK_EXTRACT_L_EVS + tmp = extract_l2( L_shr( L_tmp, add( 4, sub( Q_exc, exp1 ) ) ) ); /*Q12 */ +#else tmp = extract_l( L_shr( L_tmp, add( 4, sub( Q_exc, exp1 ) ) ) ); /*Q12 */ - tmp = mult_r( weight_fx, tmp ); /*Q12 */ +#endif + tmp = mult_r( weight_fx, tmp ); /*Q12 */ +#endif L_tmp = L_mult0( sub( 32767, weight_fx ), Random( seed_tcx ) ); /*Q30 */ tmp1 = round_fx( L_shr( L_tmp, 2 ) ); @@ -578,8 +594,12 @@ static void envelop_modify_fx( /*Ener1 = (float)(0.4f*pow(10, Ener_per_bd_iQ[15])); */ L_tmp = L_shr( L_mult0( Ener_per_bd_iQ_fx[15], 27213 ), 9 ); /* 3.321928 in Q13 -> Q16 */ - frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */ + frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l2( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#else tmp = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#endif /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp = sub( exp, 14 ); @@ -589,9 +609,13 @@ static void envelop_modify_fx( FOR( j = 0; j < 32; j++ ) { /**src = Ener1*(weight*(*src)*Ener + (1.0f-weight)*own_random(seed_tcx)/32768.0f); */ - L_tmp = Mult_32_16( Ener_fx, *src_fx ); /*Q(31-exp+Q_exc-15) -> Q(16-exp+Q_exc) */ + L_tmp = Mult_32_16( Ener_fx, *src_fx ); /*Q(31-exp+Q_exc-15) -> Q(16-exp+Q_exc) */ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l2( L_shr( L_tmp, add( 4, sub( Q_exc, exp1 ) ) ) ); /*Q12 */ +#else tmp = extract_l( L_shr( L_tmp, add( 4, sub( Q_exc, exp1 ) ) ) ); /*Q12 */ - tmp = mult_r( weight_fx, tmp ); /*Q12 */ +#endif + tmp = mult_r( weight_fx, tmp ); /*Q12 */ L_tmp = L_mult0( sub( 32767, weight_fx ), Random( seed_tcx ) ); /*Q30 */ tmp1 = round_fx( L_shr( L_tmp, 2 ) ); /*Q12 */ @@ -618,7 +642,11 @@ static void envelop_modify_fx( move16(); FOR( i = start_band; i < L_FRAME; i++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + exc_diffQ_fx[i] = extract_l2( L_exc_diffQ_fx[i] ); +#else exc_diffQ_fx[i] = extract_l( L_exc_diffQ_fx[i] ); +#endif move16(); } } @@ -629,7 +657,11 @@ static void envelop_modify_fx( move16(); FOR( i = start_band; i < L_FRAME; i++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + exc_diffQ_fx[i] = extract_l2( L_shr( L_exc_diffQ_fx[i], Q_tmp ) ); +#else exc_diffQ_fx[i] = extract_l( L_shr( L_exc_diffQ_fx[i], Q_tmp ) ); +#endif move16(); } } @@ -693,8 +725,12 @@ void highband_exc_dct_in_fx( L_tmp = L_mult( Ener_per_bd_iQ[j], 27213 ); /* 3.321928 in Q13 -> Q27 */ L_tmp = L_shr( L_tmp, 10 ); /* From Q27 to Q16 */ - frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */ + frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l2( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#else tmp = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#endif /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp = sub( exp, 14 ); diff --git a/lib_com/hq2_core_com_fx.c b/lib_com/hq2_core_com_fx.c index b8ae7880de966f9c8f81877cd86ac98214a53533..d9b74d6116f04fb3820d5ef8574f4a94c690428a 100644 --- a/lib_com/hq2_core_com_fx.c +++ b/lib_com/hq2_core_com_fx.c @@ -120,7 +120,11 @@ void mdct_spectrum_denorm_fx( L_temp = L_shr( L_band_energy[k], sub( SWB_BWE_LR_Qbe, 16 ) ); /* Q16 */ temp_lo_fx = L_Extract_lc( L_temp, &temp_hi_fx ); Qpow = sub( 14, temp_hi_fx ); +#ifdef FIX_2493_CHECK_EXTRACT_L + pow_fx = extract_l2( Pow2( 14, temp_lo_fx ) ); /* Qpow */ +#else pow_fx = extract_l( Pow2( 14, temp_lo_fx ) ); /* Qpow */ +#endif /* Div part ( pow (2.0f, band_energy[i])/Eyy ) */ exp_normn = norm_s( pow_fx ); @@ -185,7 +189,11 @@ void mdct_spectrum_denorm_fx( /* Pow part */ temp_lo_fx = L_Extract_lc( L_tmp, &temp_hi_fx ); Qtweak = sub( 14, temp_hi_fx ); +#ifdef FIX_2493_CHECK_EXTRACT_L + gain_tweak_fx = extract_l2( Pow2( 14, temp_lo_fx ) ); +#else gain_tweak_fx = extract_l( Pow2( 14, temp_lo_fx ) ); +#endif /*gamma *= gain_tweak; */ L_tmp = L_mult( gamma_fx, gain_tweak_fx ); /* Qgamma+Qtweak+1 */ @@ -720,7 +728,11 @@ void bit_allocation_second_fx( tmp = div_s( 16384, tmp ); /*Q(15+14-exp = 29-exp) */ L_tmp = Mult_32_16( Rk_sort[k], tmp ); /* Q(16+29-exp-15 = 30-exp) */ tmp = sub( 18, exp ); +#ifdef FIX_2493_CHECK_EXTRACT_L + ever_bits[k] = extract_l2( L_shr( L_tmp, tmp ) ); /*Q12 */ +#else ever_bits[k] = extract_l( L_shr( L_tmp, tmp ) ); /*Q12 */ +#endif IF( LT_16( ever_bits[k], rk_temp ) ) { rk_temp = ever_bits[k]; /* Q12 */ @@ -745,7 +757,11 @@ void bit_allocation_second_fx( tmp = div_s( 16384, tmp ); /*Q(15+14-exp = 29-exp) */ L_tmp = Mult_32_16( Rk_sort[k], tmp ); /* Q(16+29-exp-15 = 30-exp) */ tmp = sub( 18, exp ); +#ifdef FIX_2493_CHECK_EXTRACT_L + ever_sort[k] = extract_l2( L_shr( L_tmp, tmp ) ); /*Q12 */ +#else ever_sort[k] = extract_l( L_shr( L_tmp, tmp ) ); /*Q12 */ +#endif IF( LT_16( ever_sort[k], ever_temp ) ) { ever_temp = ever_sort[k]; /* Q12 */ diff --git a/lib_com/hq2_noise_inject_fx.c b/lib_com/hq2_noise_inject_fx.c index c3b373d51d2efde69fa8044f047776fdf0eea8d1..4b59a9f600f85f168da2d2a23407b2a298237b34 100644 --- a/lib_com/hq2_noise_inject_fx.c +++ b/lib_com/hq2_noise_inject_fx.c @@ -253,8 +253,11 @@ void hq2_noise_inject_fx( L_tmp2x = Mult_32_16( Ep_fx[k], tmp ); /* Q(Q_Ep_fx[k]+29-Q_speech-15 = Q_Ep_fx[k]-Q_speech+14) */ tmp = sub( Q_Ep_fx[k], Q_speech ); tmpx = add( tmp, 1 ); +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp2 = extract_l2( L_shr( L_tmp2x, s_min( tmpx, 31 ) ) ); /*Q13 Ep[k]/peak[k] */ +#else tmp2 = extract_l( L_shr( L_tmp2x, s_min( tmpx, 31 ) ) ); /*Q13 Ep[k]/peak[k] */ - +#endif IF( EQ_16( hqswb_clas, HQ_HARMONIC ) ) { tmp = sub( 1536 /* 1.5 in Q10 */, pd_fx[k] ); /*Q10 */ @@ -414,7 +417,11 @@ void hq2_noise_inject_fx( L_tmp2 = Mult_32_16( Ep_fx[k], tmp ); /* Q(Q_Ep_fx[k]+29-Q_speech-15 = Q_Ep_fx[k]-Q_speech+14) */ tmp = sub( Q_Ep_fx[k], Q_speech ); tmp = add( tmp, 1 ); - tmp = extract_l( L_shr( L_tmp2, tmp ) ); /*Q13 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l2( L_shr( L_tmp2, tmp ) ); /*Q13 */ +#else + tmp = extract_l( L_shr( L_tmp2, tmp ) ); /*Q13 */ +#endif tmp = sub( 16384 /* 2 in Q13 */, tmp ); /*Q13 */ fac_fx = extract_h( L_shl( L_mult( fac_fx, tmp ), 2 ) ); /*Q12*/ } diff --git a/lib_com/hq_tools_fx.c b/lib_com/hq_tools_fx.c index 1128ec0c67cf77be5f872d391132f8ec7e31275c..f47a3a390e701d9a611a613eb45b0bba174261d1 100644 --- a/lib_com/hq_tools_fx.c +++ b/lib_com/hq_tools_fx.c @@ -651,8 +651,12 @@ void hvq_bwe_fine_fx( tmp = div_s( 1 << 14, tmp ); /* 15+14-(-4+s)=Q(33-s) */ Mpy_32_16_ss( L_coeff[i], tmp, &L_tmp, &lsb ); /* 12+33-s+1-16=Q(30-s) */ shift2 = add( shift, 1 ); - tmp = round_fx( L_shl( L_tmp, shift2 ) ); /* 30-s+s+1-16=Q(15) */ + tmp = round_fx( L_shl( L_tmp, shift2 ) ); /* 30-s+s+1-16=Q(15) */ +#ifdef FIX_2493_CHECK_EXTRACT_L + SWB_signal[i] = add( tmp, extract_l2( L_shr( lsb, sub( 32, shift2 ) ) ) ); /* Q15 */ +#else SWB_signal[i] = add( tmp, extract_l( L_shr( lsb, sub( 32, shift2 ) ) ) ); /* Q15 */ +#endif move16(); /*SWB_signal[i] = round_fx(L_shl(L_tmp, add(shift, 1))); // 30-s+s+1-16=Q(15) */ } diff --git a/lib_com/ivas_masa_com_fx.c b/lib_com/ivas_masa_com_fx.c index d83ae1d32c90c32b7484529809f6ed8f43ba58df..a0a030d08dfc8567c7f887b41389cc925a6d890b 100644 --- a/lib_com/ivas_masa_com_fx.c +++ b/lib_com/ivas_masa_com_fx.c @@ -1327,7 +1327,11 @@ void reconstruct_ism_ratios_fx( FOR( i = 0; i < nchan_ism - 1; i++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + q_energy_ratio_ism[i] = W_extract_l2( W_shr( W_mult_32_16( step, ratio_ism_idx[i] ), 2 ) ); // q0 + q31 + 1 - 2 = q30; +#else q_energy_ratio_ism[i] = W_extract_l( W_shr( W_mult_32_16( step, ratio_ism_idx[i] ), 2 ) ); // q0 + q31 + 1 - 2 = q30; +#endif move32(); sum = L_add( sum, q_energy_ratio_ism[i] ); // Q30 diff --git a/lib_com/ivas_spar_com_fx.c b/lib_com/ivas_spar_com_fx.c index 4733e4fa086c6a370344255238982d9180b38088..dde392180730956892755f43f5c88555059bd256 100644 --- a/lib_com/ivas_spar_com_fx.c +++ b/lib_com/ivas_spar_com_fx.c @@ -819,7 +819,10 @@ static void ivas_get_pred_coeffs_enc_fx( { tmp_shift = 32; move16(); +#ifdef FIX_2493_CHECK_EXTRACT_L +#else den_f = W_extract_l( dm_y ); +#endif } ELSE { @@ -2143,7 +2146,11 @@ static void ivas_calc_post_pred_per_band_fx( tmp_re = 0; move64(); } +#ifdef FIX_2493_CHECK_EXTRACT_L + temp_mat[i][j] = W_extract_l2( W_shr( tmp_re, q_mixer_mat ) ); // Q = (q_cov_real - guard_bits) +#else temp_mat[i][j] = W_extract_l( W_shr( tmp_re, q_mixer_mat ) ); // Q = (q_cov_real - guard_bits) +#endif move32(); max_val = L_max( max_val, L_abs( temp_mat[i][j] ) ); // Q = (q_cov_real - guard_bits) } @@ -2181,7 +2188,11 @@ static void ivas_calc_post_pred_per_band_fx( move64(); } +#ifdef FIX_2493_CHECK_EXTRACT_L + postpred_cov_re[i][j] = W_extract_l2( W_shr( tmp_re, q_mixer_mat ) ); /*q_temp_mat-guard_bits*/ +#else postpred_cov_re[i][j] = W_extract_l( W_shr( tmp_re, q_mixer_mat ) ); /*q_temp_mat-guard_bits*/ +#endif move32(); } } @@ -2743,6 +2754,15 @@ static void ivas_calc_p_coeffs_per_band_fx( { Word32 re1, re2; +#ifdef FIX_2493_CHECK_EXTRACT_L + re1 = W_extract_l2( W_shr( W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], cov_dd_re[0][0] ), q_C_re ) ); // q_cov_uu_re + re2 = W_extract_l2( W_shr( W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[1][0], cov_dd_re[0][0] ), q_C_re ) ); // q_cov_uu_re + + recon_uu_re[0][0] = W_extract_l2( W_shr( W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], re1 ), q_C_re ) ); // q_cov_uu_re + recon_uu_re[0][1] = W_extract_l2( W_shr( W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[1][0], re1 ), q_C_re ) ); // q_cov_uu_re + recon_uu_re[1][0] = W_extract_l2( W_shr( W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], re2 ), q_C_re ) ); // q_cov_uu_re + recon_uu_re[1][1] = W_extract_l2( W_shr( W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[1][0], re2 ), q_C_re ) ); // q_cov_uu_re +#else re1 = W_extract_l( W_shr( W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], cov_dd_re[0][0] ), q_C_re ) ); // q_cov_uu_re re2 = W_extract_l( W_shr( W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[1][0], cov_dd_re[0][0] ), q_C_re ) ); // q_cov_uu_re @@ -2750,6 +2770,7 @@ static void ivas_calc_p_coeffs_per_band_fx( recon_uu_re[0][1] = W_extract_l( W_shr( W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[1][0], re1 ), q_C_re ) ); // q_cov_uu_re recon_uu_re[1][0] = W_extract_l( W_shr( W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], re2 ), q_C_re ) ); // q_cov_uu_re recon_uu_re[1][1] = W_extract_l( W_shr( W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[1][0], re2 ), q_C_re ) ); // q_cov_uu_re +#endif move32(); move32(); move32(); @@ -2774,17 +2795,29 @@ static void ivas_calc_p_coeffs_per_band_fx( FOR( k = 0; k < 2; k++ ) { Word32 re; +#ifdef FIX_2493_CHECK_EXTRACT_L + re = W_extract_l2( W_shr( W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][k], cov_dd_re[k][j] ), q_C_re ) ); // q_cov_uu_re +#else re = W_extract_l( W_shr( W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][k], cov_dd_re[k][j] ), q_C_re ) ); // q_cov_uu_re - re1[j] = L_add( re1[j], re ); // q_cov_uu_re +#endif + re1[j] = L_add( re1[j], re ); // q_cov_uu_re move32(); } } +#ifdef FIX_2493_CHECK_EXTRACT_L + re2 = W_extract_l2( W_shr( W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], re1[0] ), q_C_re ) ); // q_cov_uu_re +#else re2 = W_extract_l( W_shr( W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], re1[0] ), q_C_re ) ); // q_cov_uu_re - recon_uu_re[0][0] = re2; // q_cov_uu_re +#endif + recon_uu_re[0][0] = re2; // q_cov_uu_re move32(); +#ifdef FIX_2493_CHECK_EXTRACT_L + re2 = W_extract_l2( W_shr( W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][1], re1[1] ), q_C_re ) ); // q_cov_uu_re +#else re2 = W_extract_l( W_shr( W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][1], re1[1] ), q_C_re ) ); // q_cov_uu_re - recon_uu_re[0][0] = L_add( recon_uu_re[0][0], re2 ); // q_cov_uu_re +#endif + recon_uu_re[0][0] = L_add( recon_uu_re[0][0], re2 ); // q_cov_uu_re move32(); cov_uu_re[0][0] = L_sub( cov_uu_re[0][0], recon_uu_re[0][0] ); // q_cov_uu_re @@ -2802,8 +2835,12 @@ static void ivas_calc_p_coeffs_per_band_fx( { FOR( k = 0; k < num_dmx - 1; k++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + re = W_extract_l2( W_shr( W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[i][k], cov_dd_re[k][m] ), q_C_re ) ); // q_cov_uu_re +#else re = W_extract_l( W_shr( W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[i][k], cov_dd_re[k][m] ), q_C_re ) ); // q_cov_uu_re - re1[m] = L_add( re1[m], re ); // q_cov_uu_re +#endif + re1[m] = L_add( re1[m], re ); // q_cov_uu_re move32(); } } @@ -2811,8 +2848,12 @@ static void ivas_calc_p_coeffs_per_band_fx( { FOR( m = 0; m < num_dmx - 1; m++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + re = W_extract_l2( W_shr( W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[j][m], re1[m] ), q_C_re ) ); // q_cov_uu_re +#else re = W_extract_l( W_shr( W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[j][m], re1[m] ), q_C_re ) ); // q_cov_uu_re - recon_uu_re[i][j] = L_add( recon_uu_re[i][j], re ); // q_cov_uu_re +#endif + recon_uu_re[i][j] = L_add( recon_uu_re[i][j], re ); // q_cov_uu_re move32(); } } @@ -2864,7 +2905,11 @@ static void ivas_calc_p_coeffs_per_band_fx( IF( EQ_16( i, j ) ) { /* force diagonal to be real */ +#ifdef FIX_2493_CHECK_EXTRACT_L + cov_uu_re[i - num_dmx][j - num_dmx] = W_extract_l2( W_shr( W_mult0_32_32( cov_uu_re[i - num_dmx][j - num_dmx], factor ), tmp ) ); // q_cov_uu_re +#else cov_uu_re[i - num_dmx][j - num_dmx] = W_extract_l( W_shr( W_mult0_32_32( cov_uu_re[i - num_dmx][j - num_dmx], factor ), tmp ) ); // q_cov_uu_re +#endif move32(); } ELSE @@ -3051,7 +3096,11 @@ static void ivas_calc_c_coeffs_per_band_enc_fx( { FOR( j = 0; j < sub( num_dmx, 1 ); j++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + pSparMd->band_coeffs[b_ts_idx].C_re_fx[i][j] = W_extract_l2( W_shr( C_re_fx[i][j], tmp ) ); // q_post_pred_cov_re+q_cov_dd_re_inv-tmp +#else pSparMd->band_coeffs[b_ts_idx].C_re_fx[i][j] = W_extract_l( W_shr( C_re_fx[i][j], tmp ) ); // q_post_pred_cov_re+q_cov_dd_re_inv-tmp +#endif move32(); } } @@ -3177,7 +3226,11 @@ static void ivas_calc_c_coeffs_per_band_fx( { FOR( j = 0; j < sub( num_dmx, 1 ); j++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + pSparMd->band_coeffs[b_ts_idx].C_re_fx[i][j] = W_extract_l2( W_shr( C_re_fx[i][j], tmp ) ); // q_post_pred_cov_re+q_cov_dd_re_inv-tmp +#else pSparMd->band_coeffs[b_ts_idx].C_re_fx[i][j] = W_extract_l( W_shr( C_re_fx[i][j], tmp ) ); // q_post_pred_cov_re+q_cov_dd_re_inv-tmp +#endif move32(); } } @@ -3480,11 +3533,19 @@ static void ivas_calc_mat_inv_fx( det_re = W_shr( det_re, q_tmp ); /*q_det_re-q_tmp*/ q_det_re = sub( q_det_re, q_tmp ); +#ifdef FIX_2493_CHECK_EXTRACT_L + det = W_mult0_32_32( W_extract_l2( det_re ), W_extract_l2( det_re ) ); /* 2*q_det_re */ +#else det = W_mult0_32_32( W_extract_l( det_re ), W_extract_l( det_re ) ); /* 2*q_det_re */ +#endif /* assert to catch cases when input is singular matrix*/ assert( det > 0 ); +#ifdef FIX_2493_CHECK_EXTRACT_L + one_by_det = BASOP_Util_Divide3232_Scale( 1, W_extract_l2( det_re ), &q_tmp ); // Q = (15 - (q_tmp + q_det_re)) +#else one_by_det = BASOP_Util_Divide3232_Scale( 1, W_extract_l( det_re ), &q_tmp ); // Q = (15 - (q_tmp + q_det_re)) +#endif out_re[0][0] = Mpy_32_16_1( in_re[1][1], one_by_det ); /*q_in_re+(15 - (q_tmp + q_det_re)) -15=>q_in_re-(q_tmp + q_det_re)*/ @@ -3523,7 +3584,11 @@ static void ivas_calc_mat_inv_fx( move64(); } +#ifdef FIX_2493_CHECK_EXTRACT_L + one_by_det = BASOP_Util_Divide3232_Scale( 1, W_extract_l2( det_re ), &q_tmp ); /*15-(q_tmp-(0-q_det_re))*/ +#else one_by_det = BASOP_Util_Divide3232_Scale( 1, W_extract_l( det_re ), &q_tmp ); /*15-(q_tmp-(0-q_det_re))*/ +#endif q_one_by_det = sub( 15, add( q_tmp, q_det_re ) ); FOR( i = 0; i < dim; i++ ) @@ -3535,7 +3600,11 @@ static void ivas_calc_mat_inv_fx( out_re[j][i] = Mpy_32_16_1( W_extract_h( W_tmp ), one_by_det ); /*q_W_tmp-32+q_one_by_det-15*/ move32(); +#ifdef FIX_2493_CHECK_EXTRACT_L + out_re[j][i] = W_extract_l2( W_mult0_32_32( out_re[j][i], sign ) ); /*q_W_tmp-32+q_one_by_det-15*/ +#else out_re[j][i] = W_extract_l( W_mult0_32_32( out_re[j][i], sign ) ); /*q_W_tmp-32+q_one_by_det-15*/ +#endif move32(); IF( s_and( add( i, j ), 1 ) == 0 ) @@ -3587,7 +3656,11 @@ static Word16 ivas_is_mat_inv_fx( det_re = W_shr( det_re, tmp ); /*q_det_re-tmp*/ q_det_re = sub( q_det_re, tmp ); +#ifdef FIX_2493_CHECK_EXTRACT_L + det = W_mult0_32_32( W_extract_l2( det_re ), W_extract_l2( det_re ) ); /*2*q_det_re*/ +#else det = W_mult0_32_32( W_extract_l( det_re ), W_extract_l( det_re ) ); /*2*q_det_re*/ +#endif if ( LE_64( det, IVAS_FIX_EPS ) ) { @@ -3664,7 +3737,11 @@ void ivas_compute_spar_params_enc_fx( FOR( i = 0; i < num_ch; i++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + mixer_mat_fx[0][i][b] = W_extract_l2( W_shr( W_mult0_32_32( mixer_mat_fx[0][i][b], pWscale[b] ), q_Wscale[b] ) ); /*q_mixer_mat*/ +#else mixer_mat_fx[0][i][b] = W_extract_l( W_shr( W_mult0_32_32( mixer_mat_fx[0][i][b], pWscale[b] ), q_Wscale[b] ) ); /*q_mixer_mat*/ +#endif move32(); } } @@ -3746,7 +3823,11 @@ void ivas_compute_spar_params_fx( FOR( i = 0; i < num_ch; i++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + mixer_mat_fx[0][i][b] = W_extract_l2( W_shr( W_mult0_32_32( mixer_mat_fx[0][i][b], pWscale_fx[b] ), q_pWscale[b] ) ); /*q_mixer_mat*/ +#else mixer_mat_fx[0][i][b] = W_extract_l( W_shr( W_mult0_32_32( mixer_mat_fx[0][i][b], pWscale_fx[b] ), q_pWscale[b] ) ); /*q_mixer_mat*/ +#endif move32(); } } @@ -4504,7 +4585,11 @@ void ivas_get_spar_md_from_dirac_fx( { temp = W_add( temp, W_deposit32_l( response_fx[block][ch] ) ); // q30 } +#ifdef FIX_2493_CHECK_EXTRACT_L + response_avg_fx[ch] = W_extract_l2( W_shr( temp, 2 ) ); // q30 +#else response_avg_fx[ch] = W_extract_l( W_shr( temp, 2 ) ); // q30 +#endif move32(); } diff --git a/lib_com/ivas_spar_com_quant_util_fx.c b/lib_com/ivas_spar_com_quant_util_fx.c index 50820e240f241b69348a9e1d683e943dc218b542..cb65abf88a2ff5611440aa436f1499f6bece37ba 100644 --- a/lib_com/ivas_spar_com_quant_util_fx.c +++ b/lib_com/ivas_spar_com_quant_util_fx.c @@ -358,21 +358,36 @@ void ivas_map_prior_coeffs_quant( { Word32 trial1 = L_mult0( sub( qs.PR.q_levels[0], 1 ), pSpar_md_prior->band_coeffs_idx[i].pred_index_re[j] ); /*q0*/ trial1 = L_shl( trial1, 16 ); /*q16*/ - trial1 = round_fx( Mpy_32_32( trial1, one_by_q_lvl_PR_fx ) ); /*q16+q31-31-16->0*/ - pSpar_md_prior->band_coeffs_idx_mapped[i].pred_index_re[j] = extract_l( trial1 ); /*q0*/ +#ifdef FIX_2493_CHECK_EXTRACT_L_FIX_INSTRUMENTATION + trial1 = Mpy_32_32( trial1, one_by_q_lvl_PR_fx ); /*q16+q31-31-16->0*/ + pSpar_md_prior->band_coeffs_idx_mapped[i].pred_index_re[j] = round_fx( trial1 ); /*q0*/ +#else + trial1 = round_fx( Mpy_32_32( trial1, one_by_q_lvl_PR_fx ) ); /*q16+q31-31-16->0*/ + pSpar_md_prior->band_coeffs_idx_mapped[i].pred_index_re[j] = extract_l( trial1 ); /*q0*/ +#endif move16(); Word32 trial2 = L_mult0( sub( qs.P_r.q_levels[0], 1 ), pSpar_md_prior->band_coeffs_idx[i].decd_index_re[j] ); /*q0*/ trial2 = L_shl( trial2, 16 ); /*q16*/ - trial2 = round_fx( Mpy_32_32( trial2, one_by_q_lvl_P_r_fx ) ); /*q16+q31-31-16->0*/ - pSpar_md_prior->band_coeffs_idx_mapped[i].decd_index_re[j] = extract_l( trial2 ); /*q0*/ +#ifdef FIX_2493_CHECK_EXTRACT_L_FIX_INSTRUMENTATION + trial2 = Mpy_32_32( trial2, one_by_q_lvl_P_r_fx ); /*q16+q31-31-16->0*/ + pSpar_md_prior->band_coeffs_idx_mapped[i].decd_index_re[j] = round_fx( trial2 ); /*q0*/ +#else + trial2 = round_fx( Mpy_32_32( trial2, one_by_q_lvl_P_r_fx ) ); /*q16+q31-31-16->0*/ + pSpar_md_prior->band_coeffs_idx_mapped[i].decd_index_re[j] = extract_l( trial2 ); /*q0*/ +#endif move16(); } FOR( j = 0; j < IVAS_SPAR_MAX_C_COEFF; j++ ) { Word32 trial1 = L_mult0( sub( qs.C.q_levels[0], 1 ), pSpar_md_prior->band_coeffs_idx[i].drct_index_re[j] ); /*q0*/ trial1 = L_shl( trial1, 16 ); /*q16*/ - trial1 = round_fx( Mpy_32_32( trial1, one_by_q_lvl_C_fx ) ); /*q16+q31-31-16->0*/ - pSpar_md_prior->band_coeffs_idx_mapped[i].drct_index_re[j] = extract_l( trial1 ); /*q0*/ +#ifdef FIX_2493_CHECK_EXTRACT_L_FIX_INSTRUMENTATION + trial1 = Mpy_32_32( trial1, one_by_q_lvl_C_fx ); /*q16+q31-31-16->0*/ + pSpar_md_prior->band_coeffs_idx_mapped[i].drct_index_re[j] = round_fx( trial1 ); /*q0*/ +#else + trial1 = round_fx( Mpy_32_32( trial1, one_by_q_lvl_C_fx ) ); /*q16+q31-31-16->0*/ + pSpar_md_prior->band_coeffs_idx_mapped[i].drct_index_re[j] = extract_l( trial1 ); /*q0*/ +#endif move16(); } } diff --git a/lib_com/ivas_stereo_ica_com_fx.c b/lib_com/ivas_stereo_ica_com_fx.c index 705c1756d66f540acf9149f56233e2443dc81a47..926613c7d8d75de5b3b4c0204cff561c4d38f013 100644 --- a/lib_com/ivas_stereo_ica_com_fx.c +++ b/lib_com/ivas_stereo_ica_com_fx.c @@ -261,8 +261,12 @@ static void interpTargetChannel_fx( Word64 res_a, res_b, res_c, res_d; Word64 tempa, tempb; Word64 mult_a_D1, mult_b_D2; - local_int_scaled = L_shl( local_int, 12 ); // Q12 - lim1 = extract_l( local_int ); // Q0 + local_int_scaled = L_shl( local_int, 12 ); // Q12 +#ifdef FIX_2493_CHECK_EXTRACT_L + lim1 = extract_l2( local_int ); // Q0 +#else + lim1 = extract_l( local_int ); // Q0 +#endif if ( L_sub( local_int_scaled, local ) > 0 ) // Q12 { lim1 = sub( lim1, 1 ); // Q0 @@ -314,19 +318,31 @@ static void interpTargetChannel_fx( tempa = W_sub( res_a, res_b ); // qsynth+8 tempb = W_sub( res_c, res_d ); // qsynth+8 - mult_a_D1 = W_shr( ( tempD1_fx * W_shr( tempa, 14 ) ), 15 ); // Q38 - mult_b_D2 = W_shr( ( tempD2_fx * W_shr( tempb, 14 ) ), 15 ); // Q38 + mult_a_D1 = W_shr( ( tempD1_fx * W_shr( tempa, 14 ) ), 15 ); // Q38 + mult_b_D2 = W_shr( ( tempD2_fx * W_shr( tempb, 14 ) ), 15 ); // Q38 +#ifdef FIX_2493_CHECK_EXTRACT_L + ptr2_fx[k] = W_extract_l2( ( W_shr( W_add( mult_a_D1, mult_b_D2 ), 14 ) ) ); // 38-14 +#else ptr2_fx[k] = W_extract_l( ( W_shr( W_add( mult_a_D1, mult_b_D2 ), 14 ) ) ); // 38-14 +#endif move32(); IF( EQ_16( signShift, 1 ) ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + tempF1_fx = W_extract_l2( W_add( tempF1_fx, L_sub( factor_fx, ONE_IN_Q12 ) ) ); // Q12 +#else tempF1_fx = W_extract_l( W_add( tempF1_fx, L_sub( factor_fx, ONE_IN_Q12 ) ) ); // Q12 +#endif move32(); } ELSE { +#ifdef FIX_2493_CHECK_EXTRACT_L + tempF1_fx = W_extract_l2( W_add( tempF1_fx, L_sub( factor_fx, -ONE_IN_Q12 ) ) ); // Q12 +#else tempF1_fx = W_extract_l( W_add( tempF1_fx, L_sub( factor_fx, -ONE_IN_Q12 ) ) ); // Q12 +#endif move32(); } } diff --git a/lib_com/ivas_tools_fx.c b/lib_com/ivas_tools_fx.c index 753c3ae296d58ece183562f08f139bc9bd288bc3..9a94bfe8d7a6fce5fb2d2c84362d2800c615e2c9 100644 --- a/lib_com/ivas_tools_fx.c +++ b/lib_com/ivas_tools_fx.c @@ -1935,7 +1935,11 @@ void lls_interp_n_fx( } ELSE { +#ifdef FIX_2493_CHECK_EXTRACT_L + x_fx[i] = extract_l2( L_add_sat( imult3216( slope_fx, i ), offset_fx ) ); /*Q15*/ +#else x_fx[i] = extract_l( L_add_sat( imult3216( slope_fx, i ), offset_fx ) ); /*Q15*/ +#endif move16(); } } diff --git a/lib_com/low_rate_band_att_fx.c b/lib_com/low_rate_band_att_fx.c index ecb48c49ef75f952318cd966941d91bfccc4390e..8774b684fd967471da75fec03638df795d6c3200 100644 --- a/lib_com/low_rate_band_att_fx.c +++ b/lib_com/low_rate_band_att_fx.c @@ -217,7 +217,11 @@ void fine_gain_dec_fx( L_tmp = L_shr( L_tmp, 15 ); tmp1 = L_Extract_lc( L_tmp, &exp1 ); tmp1 = abs_s( tmp1 ); +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp1 = extract_l2( Pow2( 14, tmp1 ) ); +#else tmp1 = extract_l( Pow2( 14, tmp1 ) ); +#endif exp1 = sub( 14, exp1 ); L_tmp = L_mult0( fg_pred[band], tmp1 ); /*12+exp1 */ diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c index c69503350f8320bcd8cde9f92f1f44a16dd62e1c..4e972784b7abc1b82ccaedb85041c38fb48c0387 100644 --- a/lib_com/lsf_tools_fx.c +++ b/lib_com/lsf_tools_fx.c @@ -290,16 +290,28 @@ void E_LPC_a_isp_conversion( const Word16 a[], Word16 isp[], const Word16 old_is tmp = shl( tmp, exp ); tmp = div_s( (Word16) 16383, tmp ); t0 = L_mult( x, tmp ); +#ifdef NONBE_FIX_2493_EXTRACT_L_E_LPC_a_isp_conversion + t0 = L_shr_sat( t0, sub( 20 - 16, exp ) ); + tmp = extract_h( t0 ); /* y = (xhigh-xlow)/(yhigh-ylow) in Q11 */ +#else t0 = L_shr( t0, sub( 20, exp ) ); +#ifdef FIX_2493_CHECK_EXTRACT_L_EVS + tmp = extract_l2( t0 ); /* y = (xhigh-xlow)/(yhigh-ylow) in Q11 */ +#else tmp = extract_l( t0 ); /* y = (xhigh-xlow)/(yhigh-ylow) in Q11 */ - +#endif +#endif /* Restore Sign */ if ( y < 0 ) tmp = negate( tmp ); - t0 = L_mult( ylow, tmp ); /* result in Q26 */ - t0 = L_shr( t0, 11 ); /* result in Q15 */ + t0 = L_mult( ylow, tmp ); /* result in Q26 */ + t0 = L_shr( t0, 11 ); /* result in Q15 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + xlow = sub( xlow, extract_l2( t0 ) ); /* xint = xlow - ylow*y */ +#else xlow = sub( xlow, extract_l( t0 ) ); /* xint = xlow - ylow*y */ +#endif } isp[nf++] = xlow; @@ -1148,16 +1160,29 @@ void E_LPC_a_lsp_conversion( tmp = shl( tmp, exp ); tmp = div_s( (Word16) 16383 / 2, tmp ); t0 = L_mult( x, tmp ); +#ifdef NONBE_FIX_2493_EXTRACT_L_E_LPC_a_isp_conversion + t0 = L_shr_sat( t0, sub( 20 - 16, exp ) ); + tmp = extract_h( t0 ); /* y = (xhigh-xlow)/(yhigh-ylow) in Q11 */ +#else t0 = L_shr( t0, sub( 20, exp ) ); +#ifdef FIX_2493_CHECK_EXTRACT_L_EVS + tmp = extract_l2( t0 ); /* y = (xhigh-xlow)/(yhigh-ylow) in Q11 */ +#else tmp = extract_l( t0 ); /* y = (xhigh-xlow)/(yhigh-ylow) in Q11 */ +#endif +#endif /* Restore Sign */ if ( y < 0 ) tmp = negate( tmp ); - t0 = L_mult( ylow, tmp ); /* result in Q26 */ - t0 = L_shr( t0, 11 ); /* result in Q15 */ + t0 = L_mult( ylow, tmp ); /* result in Q26 */ + t0 = L_shr( t0, 11 ); /* result in Q15 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + xlow = sub( xlow, extract_l2( t0 ) ); /* xint = xlow - ylow*y */ +#else xlow = sub( xlow, extract_l( t0 ) ); /* xint = xlow - ylow*y */ +#endif } lsp[nf++] = xlow; move16(); @@ -1700,7 +1725,11 @@ Word16 xsp_to_xsf( Word16 lsp ) L_tmp = L_shr( L_tmp, 12 ); /* (lsp-cos_table_129[ind]) * acos_slope[ind]) >> 11 */ L_tmp = L_mac0( L_tmp, ind, 128 ); +#ifdef FIX_2493_CHECK_EXTRACT_L + return extract_l2( L_tmp ); +#else return extract_l( L_tmp ); +#endif } @@ -2550,9 +2579,18 @@ void lsp2lsf_fx( L_tmp = sub_lsp2lsf_fx( lsp[i] ); IF( EQ_32( int_fs, INT_FS_16k_FX ) ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + L_tmp = L_shr( L_mult0( extract_l2( L_tmp ), 5 ), 2 ); +#else L_tmp = L_shr( L_mult0( extract_l( L_tmp ), 5 ), 2 ); +#endif } + +#ifdef FIX_2493_CHECK_EXTRACT_L + lsf[i] = extract_l2( L_tmp ); +#else lsf[i] = extract_l( L_tmp ); +#endif move16(); } } diff --git a/lib_com/nelp_fx.c b/lib_com/nelp_fx.c index 4a4cb66b121dec3ac1fdc6054836618411a69c2d..f539824e77cf39fa8ea50421795277584b0173ac 100644 --- a/lib_com/nelp_fx.c +++ b/lib_com/nelp_fx.c @@ -127,7 +127,11 @@ Word16 dequantize_uvg_fx( L_tmp = L_mult( UVG1CB[iG1][i], 27213 ); /* Q(13+13+1)->Q27 */ L_tmp = L_shr_r( L_tmp, 11 ); /* Q16 */ frac = L_Extract_lc( L_tmp, &exp ); +#ifdef FIX_2493_CHECK_EXTRACT_L + frac = extract_l2( Pow2( 14, frac ) ); +#else frac = extract_l( Pow2( 14, frac ) ); +#endif G[i * 5 + k] = round_fx( L_shl( L_mult( frac, UVG2CB1[iG2[i]][k] ), sub( exp, sc ) ) ); /* Q0 */ move16(); } @@ -136,7 +140,11 @@ Word16 dequantize_uvg_fx( L_tmp = L_mult( UVG1CB[iG1][i], 27213 ); /* Q(13+13+1)->Q27 */ L_tmp = L_shr_r( L_tmp, 11 ); /* Q16 */ frac = L_Extract_lc( L_tmp, &exp ); +#ifdef FIX_2493_CHECK_EXTRACT_L + frac = extract_l2( Pow2( 14, frac ) ); +#else frac = extract_l( Pow2( 14, frac ) ); +#endif G[i * 5 + k] = round_fx( L_shl( L_mult( frac, UVG2CB2[iG2[i]][k] ), sub( exp, sc ) ) ); /* Q0 */ move16(); } diff --git a/lib_com/options.h b/lib_com/options.h index a1ce299e394898127214eddb8f0313005081fcb8..374cd9ef6c2f6ee7585214e97372344990853a0c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -40,9 +40,7 @@ /* clang-format off */ /* ################### Start compiler switches ######################## */ -#ifndef NO_SUPPORT_JBM_TRACEFILE #define SUPPORT_JBM_TRACEFILE /* support for JBM tracefile, which is needed for 3GPP objective/subjective testing, but not relevant for real-world implementations */ -#endif /* #################### End compiler switches ######################### */ @@ -104,6 +102,16 @@ #define FIX_1576_LCLD_CRASH_DIFFERENT_CODEC_ISAR_FRAME_SIZE /* Dolby: float issue 1576: fix for crash in LCLD mode when codec frame size is less than isar frame size */ #define NONBE_FIX_ISSUE_2206_MDCT_STEREO_FIX_2549 /* FhG: Correct scale inconsistency of old_inp_16k_fx buffer scale. */ +#define FIX_2493_CHECK_EXTRACT_L /* FhG: Verify that extract_l, W_extract_l etc. do not encounter an overflow. */ +#define FIX_2493_CHECK_SCALE_NOSAT /* FhG: Verify that no saturation scaling do not encounter an overflow. */ +#define FIX_2493_CHECK_64BIT /* FhG: Verify that 64 bit ops do not encounter an overflow. */ +#define FIX_2493_CHECK_EXTRACT_L_EVS /* FhG: Verify that extract_l, W_extract_l etc. do not encounter an overflow for EVS only modes. */ +#define NONBE_FIX_2493_EXTRACT_L_EnhanceClass_fx /* FhG: Fix extract_l overflow inside EnhanceClass_fx() (EVS). Saturation, not a optimal fix. */ +#define NONBE_FIX_2493_EXTRACT_L_decoder_tcx_post_fx /* FhG: Fix extract_l overflow inside decoder_tcx_post_fx() (EVS). Saturation, not a optimal fix. */ +#define NONBE_FIX_2493_EXTRACT_L_WB_BWE_gain_pred_fx /* FhG: Fix extract_l overflow inside WB_BWE_gain_pred_fx() (EVS). Saturation, not a optimal fix. */ +#define NONBE_FIX_2493_EXTRACT_L_cftmdl_16fx /* FhG: Fix extract_l overflow inside cftmdl_16fx() (EVS). Saturation, not a optimal fix. */ +#define NONBE_FIX_2493_EXTRACT_L_E_LPC_a_isp_conversion /* FhG: Fix extract_l overflow inside E_LPC_a_isp_conversion() (EVS). Saturation, not a optimal fix. */ +#define NONBE_FIX_2493_EXTRACT_L_envelop_modify_fx /* FhG: Fix extract_l overflow inside envelop_modify_fx() (EVS). */ #define FIX_2585_BIT_ALLOCATION_DIFF /* VA : issue 2585, bit allocation different behaviors between float and fixed-point for corner cases */ #define FIX_BASOP_2592_OVERFLOW /* FhG: BASOP #2592: fix overflow in GetF0() */ #define FIX_BASOP_2591_EDGE_DETECT_COMP /* FhG: BASOP #2591: Wrong comparison in edge_detect_fx() */ diff --git a/lib_com/pvq_com_fx.c b/lib_com/pvq_com_fx.c index f86e66f60a549202713cca61951766ab3244ec92..66a78d522842a34d909bfbb317f20107efd9018b 100644 --- a/lib_com/pvq_com_fx.c +++ b/lib_com/pvq_com_fx.c @@ -70,7 +70,11 @@ static void nearProjQ15_fx( b = L_add( L_deposit_l( a[2] ), b ); /* Q15 */ Mpy_32_16_ss( b, x, &b, &lsb ); /* Q15 */ b = L_add( L_deposit_l( a[3] ), b ); /* Q15 */ - *result = extract_l( b ); /* Q15 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + *result = extract_l2( b ); /* Q15 */ +#else + *result = extract_l( b ); /* Q15 */ +#endif move16(); return; } diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index a77f6a24ae465b2f70ed896003305fd1b81f178c..c7431a6a12faec6917a7ebad02cb25844b3e8039 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -115,7 +115,11 @@ Word16 WB_BWE_gain_pred_fx( } L_tmp = sum16_32_fx( voice_factors, 4 ); +#ifdef FIX_2493_CHECK_EXTRACT_L + voice_factor = extract_l2( L_shr( L_tmp, 2 ) ); /*Q13 */ +#else voice_factor = extract_l( L_shr( L_tmp, 2 ) ); /*Q13 */ +#endif Copy_Scale_sig( pitch_buf, pitch_buf_tmp, 4, -1 ); pitch = sum16_fx( pitch_buf_tmp, 4 ); /*Q5 */ @@ -135,8 +139,12 @@ Word16 WB_BWE_gain_pred_fx( tmp = extract_h( L_shl( L_WB_fenv0, exp ) ); tmp = div_s( 16384 /* 1 in Q14 */, tmp ); /*Q(15+14-2*Q_syn-exp) */ L_tmp = L_shr( Mult_32_16( L_shl( L_WB_fenv1, 1 ), tmp ), sub( 15, exp ) ); /*2*Q_syn+15+exp-15->2*Q_syn+exp */ - /*L_tmp Q15 */ + /*L_tmp Q15 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l2( L_tmp ); +#else tmp = extract_l( L_tmp ); +#endif alfa = s_max( tmp, 3277 /* 0.1 in Q15 */ ); /*Q15 */ L_WB_fenv0 = Mult_32_16( L_WB_fenv0, alfa ); /*2*Q_syn+15-15->2*Q_syn */ } @@ -146,8 +154,12 @@ Word16 WB_BWE_gain_pred_fx( tmp = extract_h( L_shl( L_WB_fenv1, exp ) ); tmp = div_s( 16384 /* 1 in Q14 */, tmp ); /*Q(15+14-2*Q_syn-exp) */ L_tmp = L_shr( Mult_32_16( L_shl( L_WB_fenv0, 1 ), tmp ), sub( 15, exp ) ); /*2*Q_syn+15+exp-15->2*Q_syn+exp */ - /*L_tmp Q15 */ + /*L_tmp Q15 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l2( L_tmp ); +#else tmp = extract_l( L_tmp ); +#endif alfa = s_max( tmp, 3277 /* 0.1 in Q15 */ ); /*Q15 */ L_WB_fenv1 = Mult_32_16( L_WB_fenv1, alfa ); /*2*Q_syn+15-15->2*Q_syn */ } @@ -214,7 +226,11 @@ Word16 WB_BWE_gain_pred_fx( tmp = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 2 ) ) ); /*Q12 */ tmp = s_min( tmp, 16384 /*4 in Q12*/ ); L_tmp = L_shr( L_mult0( tmp, WB_fenv[0] ), 12 ); /*Q15 */ - WB_fenv[0] = extract_l( L_tmp ); /*Q3 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + WB_fenv[0] = extract_l2( L_tmp ); /*Q3 */ +#else + WB_fenv[0] = extract_l( L_tmp ); /*Q3 */ +#endif move16(); } @@ -227,7 +243,11 @@ Word16 WB_BWE_gain_pred_fx( } L_tmp = L_mult0( voice_factor, 77 ); +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp1 = extract_l2( L_shr( L_tmp, 13 ) ); +#else tmp1 = extract_l( L_shr( L_tmp, 13 ) ); +#endif exp = norm_s( pitch ); tmp = div_s( shl( 1, sub( 14, exp ) ), pitch ); /*Q(29-exp-5) */ @@ -238,7 +258,15 @@ Word16 WB_BWE_gain_pred_fx( L_tmp = L_mult0( alfa, WB_fenv[0] ); /*Q14+Q3->Q17 */ L_tmp = L_shr( L_tmp, 14 ); /*Q3 */ +#ifdef NONBE_FIX_2493_EXTRACT_L_WB_BWE_gain_pred_fx + tmp = extract_h( L_shl_sat( L_tmp, 16 ) ); +#else +#ifdef FIX_2493_CHECK_EXTRACT_L_EVS + tmp = extract_l2( L_tmp ); +#else tmp = extract_l( L_tmp ); +#endif +#endif enerL = L_deposit_l( enerL_16 ); enerL = L_shl( enerL, 6 ); /*Q6 */ @@ -262,7 +290,11 @@ Word16 WB_BWE_gain_pred_fx( tmp = round_fx_sat( L_shl_sat( L_tmp, sub( exp, 2 ) ) ); /*Q12 */ tmp = s_min( tmp, 16384 /*4 in Q12*/ ); L_tmp = L_shr( L_mult0( tmp, WB_fenv[0] ), 12 ); /*Q3 */ - WB_fenv[0] = extract_l( L_tmp ); /*Q3 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + WB_fenv[0] = extract_l2( L_tmp ); /*Q3 */ +#else + WB_fenv[0] = extract_l( L_tmp ); /*Q3 */ +#endif move16(); IF( GT_16( WB_fenv[0], prev_WB_fenv ) ) { @@ -695,7 +727,11 @@ Word16 calc_tilt_bwe_fx_32( tmp1 = L_abs( tmp1 ); /* to Get either 0 or -1 in 'tmp2' */ tmp2 = L_shr( tmp2, 31 ); +#ifdef FIX_2493_CHECK_EXTRACT_L + sign = extract_l2( L_shl( tmp2, Q15 ) ); +#else sign = extract_l( L_shl( tmp2, Q15 ) ); +#endif /* this allows this code */ L_ener = Msub_32_16( L_ener, tmp1, sign ); /* instead of this one */ @@ -910,12 +946,20 @@ void WB_BWE_decoding_fx( L_tmp = Mult_32_16( L_tmp, 14746 ); /* Q_syn */ L_tmp1 = L_deposit_l( WB_signal[n_freq] ); /* Q_syn */ L_tmp = L_sub( L_tmp1, L_tmp ); /* Q_syn */ - WB_signal[n_freq] = extract_l( L_tmp ); /* Q_syn */ +#ifdef FIX_2493_CHECK_EXTRACT_L + WB_signal[n_freq] = extract_l2( L_tmp ); /* Q_syn */ +#else + WB_signal[n_freq] = extract_l( L_tmp ); /* Q_syn */ +#endif move16(); IF( L_tmp > 0 ) { - tmp = sub( 18022, weight ); /* Q15 */ + tmp = sub( 18022, weight ); /* Q15 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + WB_signal[n_freq] = extract_l2( Mult_32_16( L_tmp, tmp ) ); /* Q_syn */ +#else WB_signal[n_freq] = extract_l( Mult_32_16( L_tmp, tmp ) ); /* Q_syn */ +#endif move16(); } @@ -937,7 +981,11 @@ void WB_BWE_decoding_fx( exp = sub( sub( 30, exp ), Q_syn ); tmp = div_s( 16384, tmp ); L_tmp = L_shr( L_mult0( WB_signal[n_freq], tmp ), add( exp, Q_syn ) ); /*Q15 */ - WB_signal[n_freq] = extract_l( L_tmp ); /*Q15 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + WB_signal[n_freq] = extract_l2( L_tmp ); /*Q15 */ +#else + WB_signal[n_freq] = extract_l( L_tmp ); /*Q15 */ +#endif move16(); } ELSE @@ -1380,7 +1428,11 @@ void SWB_BWE_decoding_fx( exp = sub( sub( 30, exp ), Q_syn ); tmp = div_s( 16384 /* 0.5 in Q15 */, tmp ); /*Q(15+exp) */ L_tmp = L_shr( L_mult0( SWB_signal[n_freq], tmp ), add( exp, Q_syn ) ); /*Q15 */ - SWB_signal[n_freq] = extract_l( L_tmp ); /*Q15 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + SWB_signal[n_freq] = extract_l2( L_tmp ); /*Q15 */ +#else + SWB_signal[n_freq] = extract_l( L_tmp ); /*Q15 */ +#endif move16(); } ELSE @@ -1677,13 +1729,21 @@ void SWB_BWE_decoding_fx( L_tmp = L_sub( L_tmp1, L_tmp ); /* Q_syn */ IF( L_tmp > 0 ) { - tmp = shr( weight, 1 ); /* Q14 */ - tmp = sub( 19661, tmp ); /* Q14 */ + tmp = shr( weight, 1 ); /* Q14 */ + tmp = sub( 19661, tmp ); /* Q14 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + SWB_signal[n_freq] = extract_l2( L_shl( Mult_32_16( L_tmp, tmp ), 1 ) ); /* Q_syn */ +#else SWB_signal[n_freq] = extract_l( L_shl( Mult_32_16( L_tmp, tmp ), 1 ) ); /* Q_syn */ +#endif } ELSE { +#ifdef FIX_2493_CHECK_EXTRACT_L + SWB_signal[n_freq] = extract_l2( L_tmp ); /* Q_syn */ +#else SWB_signal[n_freq] = extract_l( L_tmp ); /* Q_syn */ +#endif } move16(); IF( NE_16( signum[n_freq], 1 ) ) @@ -1701,7 +1761,11 @@ void SWB_BWE_decoding_fx( exp = sub( sub( 30, exp ), Q_syn ); tmp = div_s( 16384 /* 0.5 in Q15*/, tmp ); /* Q(15+exp) */ L_tmp = L_shr( L_mult0( SWB_signal[n_freq], tmp ), add( exp, Q_syn ) ); /* Q15 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + SWB_signal[n_freq] = extract_l2( L_tmp ); +#else SWB_signal[n_freq] = extract_l( L_tmp ); +#endif move16(); /* Q15 */ } ELSE @@ -1734,7 +1798,11 @@ IF( EQ_16( mode, HARMONIC ) ) L_mean = L_add( L_mean, abs_s( *pit1 ) ); /*Q15 */ pit1++; } +#ifdef FIX_2493_CHECK_EXTRACT_L + mean = extract_l2( Mult_32_16( L_mean, 2048 /* 1/16 in Q15 */ ) ); /*Q15 */ +#else mean = extract_l( Mult_32_16( L_mean, 2048 /* 1/16 in Q15 */ ) ); /*Q15 */ +#endif pit1 -= 16; FOR( n_freq = 0; n_freq < 16; n_freq++ ) { diff --git a/lib_com/swb_bwe_com_lr_fx.c b/lib_com/swb_bwe_com_lr_fx.c index 9b6c6cd8e021ac2dff10fb1a42a1d353fba12f79..bf47a6c50e1e5dc627adb800720529a5028c1fba 100644 --- a/lib_com/swb_bwe_com_lr_fx.c +++ b/lib_com/swb_bwe_com_lr_fx.c @@ -1416,13 +1416,21 @@ void SpectrumSmoothing_nss_fx( move32(); FOR( k = 0; k < L_SB_NSS_HALF; k++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L_FIX_INSTRUMENTATION + L_temp_sum_1[i] = L_add( L_temp_sum_1[i], L_deposit_l( abs_s( inBufw_fx[k + L_SB_NSS * i] ) ) ); /* Qm */ +#else L_temp_sum_1[i] = L_add( L_temp_sum_1[i], extract_l( abs_s( inBufw_fx[k + L_SB_NSS * i] ) ) ); /* Qm */ +#endif move32(); } FOR( k = L_SB_NSS_HALF; k < L_SB_NSS; k++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L_FIX_INSTRUMENTATION + L_temp_sum_2[i] = L_add( L_temp_sum_2[i], L_deposit_l( abs_s( inBufw_fx[k + L_SB_NSS * i] ) ) ); /* Qm */ +#else L_temp_sum_2[i] = L_add( L_temp_sum_2[i], extract_l( abs_s( inBufw_fx[k + L_SB_NSS * i] ) ) ); /* Qm */ +#endif move32(); } @@ -1454,7 +1462,11 @@ void SpectrumSmoothing_nss_fx( temp_lo = L_Extract_lc( L_temp1, &temp_hi ); Qsumdiv[i] = sub( 14, temp_hi ); move16(); +#ifdef FIX_2493_CHECK_EXTRACT_L + temp_sum_div_fx[i] = extract_l2( Pow2( 14, temp_lo ) ); /* Qsumdiv[i] */ +#else temp_sum_div_fx[i] = extract_l( Pow2( 14, temp_lo ) ); /* Qsumdiv[i] */ +#endif move16(); exp_norm = norm_s( temp_sum_div_fx[i] ); temp_sum_div_fx[i] = shl( temp_sum_div_fx[i], exp_norm ); @@ -1966,7 +1978,11 @@ void GetlagGains_fx( L_temp = L_shr( L_band_energy[sb], sub( Qbe, 16 ) ); /* Qbe -> Q16 */ temp_lo_fx = L_Extract_lc( L_temp, &temp_hi_fx ); Qpow = sub( 14, temp_hi_fx ); +#ifdef FIX_2493_CHECK_EXTRACT_L + pow_fx = extract_l2( Pow2( 14, temp_lo_fx ) ); /* Qpow */ +#else pow_fx = extract_l( Pow2( 14, temp_lo_fx ) ); /* Qpow */ +#endif /* Div part ( pow (2.0f, band_energy[i])/lagEenegy ) */ exp_normn = norm_s( pow_fx ); @@ -2931,7 +2947,11 @@ void FindNBiggest2_simple_fx_har( get_sigma_fx_har( L_abs_in, Qabs_in, avg_in_fx, Qavg_in, nIdx_fx, &sigma_fx, &Qsigma ); temp_fx = mult_r( sigma_fx, 18841 ); /* 18841 = 1.15(Q14) Qsigma + Q14 + 1 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + L_thr = L_add( extract_l2( avg_in_fx ), L_shr( extract_l2( temp_fx ), sub( sub( Qsigma, 1 ), Qavg_in ) ) ); +#else L_thr = L_add( extract_l( avg_in_fx ), L_shr( extract_l( temp_fx ), sub( sub( Qsigma, 1 ), Qavg_in ) ) ); +#endif L_thr = L_shr( L_thr, sub( Qavg_in, Qabs_in ) ); IF( LT_16( peak_cnt_fx, n_nbiggestsearch ) ) diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 70684ccd5050dc0aeb077d7ae52e2d54db6cac76..022b2933ef3c8639a5c5448bdae529a7b8d99ecc 100644 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -136,9 +136,13 @@ Word16 tbe_celp_exc_offset( tmp_fac = 256; move16(); /*2.0 in Q7*/ } +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp_fx = extract_l2( L_mult( T0_frac_fx, 32 ) ); /*Q8, 0.25 in Q7*/ +#else tmp_fx = extract_l( L_mult( T0_frac_fx, 32 ) ); /*Q8, 0.25 in Q7*/ - tmp_fx = add( 512, tmp_fx ); /*Q8; 2 in Q8*/ - tmp_fx = mult_r( tmp_fx, tmp_fac ); /*Q16->Q0; 2.5 in Q7 or 2.0 in Q7 */ +#endif + tmp_fx = add( 512, tmp_fx ); /*Q8; 2 in Q8*/ + tmp_fx = mult_r( tmp_fx, tmp_fac ); /*Q16->Q0; 2.5 in Q7 or 2.0 in Q7 */ tmp1_fx = sub( T0_fx, 2 ); /*Q0*/ @@ -206,11 +210,17 @@ void tbe_celp_exc_fx( bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC] = bwe_exc_fx[i + i_subfr_fx * HIBND_ACB_L_FAC - offset_fx + tmp_fx]; move16(); } +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp_fx = extract_l2( L_mult( T0_frac_fx, 1 ) ); /*Q3; 0.25 in Q2*/ + tmp_fx = add( shl( T0_fx, 3 ), tmp_fx ); /*Q3*/ + tmp_fx = extract_l2( L_mult( tmp_fx, 5 ) ); /*Q5, 2.5 in Q1*/ +#else tmp_fx = extract_l( L_mult( T0_frac_fx, 1 ) ); /*Q3; 0.25 in Q2*/ tmp_fx = add( shl( T0_fx, 3 ), tmp_fx ); /*Q3*/ tmp_fx = extract_l( L_mult( tmp_fx, 5 ) ); /*Q5, 2.5 in Q1*/ - tmp_fx = sub( shl( offset_fx, 5 ), tmp_fx ); /*Q5*/ - *error_fx = add( *error_fx, tmp_fx ); /*Q5*/ +#endif + tmp_fx = sub( shl( offset_fx, 5 ), tmp_fx ); /*Q5*/ + *error_fx = add( *error_fx, tmp_fx ); /*Q5*/ move16(); } ELSE @@ -236,11 +246,15 @@ void tbe_celp_exc_fx( } /* error += (float) offset - (float) T0 * 2 - 0.5f * (float) T0_frac;*/ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp_fx = extract_l2( L_mult( T0_frac_fx, 2 ) ); /*Q3; 0.5 in Q2*/ +#else tmp_fx = extract_l( L_mult( T0_frac_fx, 2 ) ); /*Q3; 0.5 in Q2*/ - tmp_fx = add( shl( T0_fx, 4 ), tmp_fx ); /* now tmp_fx = "T0_fx*2+ 0.5f*T0_frac_fx" in Q3*/ - tmp_fx = shl( tmp_fx, 2 ); /*now above tmp_fx in Q5*/ - tmp_fx = sub( shl( offset_fx, 5 ), tmp_fx ); /*move offset_fx to Q5, tmp_fx in Q5, ans tmp_fx in Q5*/ - *error_fx = add( *error_fx, tmp_fx ); /*error_fx in Q5*/ +#endif + tmp_fx = add( shl( T0_fx, 4 ), tmp_fx ); /* now tmp_fx = "T0_fx*2+ 0.5f*T0_frac_fx" in Q3*/ + tmp_fx = shl( tmp_fx, 2 ); /*now above tmp_fx in Q5*/ + tmp_fx = sub( shl( offset_fx, 5 ), tmp_fx ); /*move offset_fx to Q5, tmp_fx in Q5, ans tmp_fx in Q5*/ + *error_fx = add( *error_fx, tmp_fx ); /*error_fx in Q5*/ move16(); } @@ -1032,8 +1046,13 @@ void flip_spectrum_and_decimby4_fx( factor = div_s( 4, length ); /* Q15 */ FOR( i = 0; i < length / 4; i += 2 ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp1 = extract_l2( L_mult0( i, factor ) ); /* Q15 */ + tmp2 = extract_l2( L_mult0( add( i, 1 ), factor ) ); /*Q15 */ +#else tmp1 = extract_l( L_mult0( i, factor ) ); /* Q15 */ tmp2 = extract_l( L_mult0( add( i, 1 ), factor ) ); /*Q15 */ +#endif input_change[i] = negate( mult_r( input[i], tmp1 ) ); move16(); input_change[i + 1] = mult_r( input[i + 1], tmp2 ); @@ -4416,7 +4435,11 @@ void non_linearity_fx( frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l2( Pow2( 14, frac ) ); +#else tmp = extract_l( Pow2( 14, frac ) ); +#endif scale_step = shl_sat( tmp, exp ); /* Q14 */ } } @@ -4507,7 +4530,11 @@ void non_linearity_fx( /* (log2(scale / prev_scale))/length */ L_tmp = L_shl_sat( Mult_32_16( L_tmp, tmp ), sub( exp, 14 ) ); /*Q(16+29-exp+1-16+exp-14)->Q16 */ frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l2( Pow2( 14, frac ) ); +#else tmp = extract_l( Pow2( 14, frac ) ); +#endif scale_step = shl_sat( tmp, exp ); /*Q14 */ } } @@ -4950,6 +4977,16 @@ void elliptic_bpf_48k_generic_fx( } /*IsUpsampled3*/ +#ifdef FIX_2493_CHECK_EXTRACT_L_FIX_INSTRUMENTATION + memory_fx2[0][0] = L_deposit_l( input_fx[L_FRAME48k - 4] ); + memory_fx2[0][1] = L_deposit_l( input_fx[L_FRAME48k - 3] ); + memory_fx2[0][2] = L_deposit_l( input_fx[L_FRAME48k - 2] ); + memory_fx2[0][3] = L_deposit_l( input_fx[L_FRAME48k - 1] ); + move32(); + move32(); + move32(); + move32(); +#else memory_fx2[0][0] = input_fx[L_FRAME48k - 4]; memory_fx2[0][1] = input_fx[L_FRAME48k - 3]; memory_fx2[0][2] = input_fx[L_FRAME48k - 2]; @@ -4959,6 +4996,7 @@ void elliptic_bpf_48k_generic_fx( move32(); move32(); move32(); +#endif L_tmpMax = L_add( 0, 0 ); IF( element_mode ) diff --git a/lib_com/syn_filt_fx.c b/lib_com/syn_filt_fx.c index 58592f6177f17c555400fac2795a0f8987bcea27..03dc8b92f81f577168768d3c9c613a4875243167 100644 --- a/lib_com/syn_filt_fx.c +++ b/lib_com/syn_filt_fx.c @@ -277,7 +277,11 @@ void syn_filt_fx32( s = W_deposit32_l( x[i] ); FOR( j = 1; j <= m; j++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + s = W_sub( s, W_mult0_32_32( a[j], W_extract_l2( W_shr( yy[i - j], sub( 31, a_e ) ) ) ) ); +#else s = W_sub( s, W_mult0_32_32( a[j], W_extract_l( W_shr( yy[i - j], sub( 31, a_e ) ) ) ) ); +#endif } yy[i] = s; @@ -292,7 +296,11 @@ void syn_filt_fx32( FOR( i = 0; i < l; i++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + y[i] = W_extract_l2( W_shr( yy[i], sub( 32, norm ) ) ); +#else y[i] = W_extract_l( W_shr( yy[i], sub( 32, norm ) ) ); +#endif } *y_e = sub( 31, add( sub( 31, x_e ), sub( norm, 32 ) ) ); /*------------------------------------------------------------------* @@ -303,7 +311,11 @@ void syn_filt_fx32( { FOR( i = 0; i < m; i++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + mem[i] = W_extract_l2( W_shr( yy[l - m + i], sub( 32, norm ) ) ); +#else mem[i] = W_extract_l( W_shr( yy[l - m + i], sub( 32, norm ) ) ); +#endif } *mem_e = sub( 31, add( sub( 31, x_e ), sub( norm, 32 ) ) ); } diff --git a/lib_com/tcx_utils_fx.c b/lib_com/tcx_utils_fx.c index 6ebd1dbf5b02b650624a82e4c978d605c4fc4a80..a066a96ae4e16e8835508d4c1eb1726aa5ea55b6 100644 --- a/lib_com/tcx_utils_fx.c +++ b/lib_com/tcx_utils_fx.c @@ -1748,7 +1748,11 @@ void tcx_noise_filling( } tmp2 = mult( tmp1, inv_int[nTransWidth] ); +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp1 = extract_l2( L_mult0( tmp2, win ) ); +#else tmp1 = extract_l( L_mult0( tmp2, win ) ); +#endif FOR( m = sub( i, win ); m < i; m++ ) { Q[m] = L_shl( Mpy_32_16_1( Q[m], tmp1 ), s ); /*Q31 - Q_e*/ @@ -1903,7 +1907,11 @@ void tcx_noise_filling_with_shift( } tmp2 = mult( tmp1, inv_int[nTransWidth] ); /*Q15 - s*/ - tmp1 = extract_l( L_mult0( tmp2, win ) ); /*Q15 - s*/ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp1 = extract_l2( L_mult0( tmp2, win ) ); /*Q15 - s*/ +#else + tmp1 = extract_l( L_mult0( tmp2, win ) ); /*Q15 - s*/ +#endif FOR( m = sub( i, win ); m < i; m++ ) { Word16 nrm = 31; diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index e15184cbaa4b89174dc1a79a7e576cddfefe1541..7556d0795ad3e9902ce0fc0f682a26c58147ae1e 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -1411,8 +1411,13 @@ void Copy_Scale_sig_16_32_no_sat( FOR( i = 0; i < lg; i++ ) { // y[i] = L_mult0(x[i], L_tmp); +#ifdef FIX_2493_CHECK_SCALE_NOSAT + y[i] = W_extract_l2( W_mult_32_16( L_tmp, x[i] ) ); + move32(); +#else y[i] = W_extract_l( W_mult_32_16( L_tmp, x[i] ) ); move32(); /* Overflow can occur here */ +#endif } return; } @@ -1477,7 +1482,11 @@ void Copy_Scale_sig_32_16_nosat( { FOR( i = 0; i < lg; i++ ) { +#ifdef FIX_2493_CHECK_SCALE_NOSAT + y[i] = round_fx_sat( L_shl( x[i], tmp ) ); +#else y[i] = round_fx_sat( L_shl_sat( x[i], tmp ) ); +#endif move16(); } } @@ -1650,7 +1659,11 @@ Word16 mean_no_sat_fx( } L_tmp = Mpy_32_16_1( L_tmp, div_s( 1, lvec_fx ) ); /* Qx */ +#ifdef FIX_2493_CHECK_EXTRACT_L + return extract_l2( L_tmp ); +#else return extract_l( L_tmp ); +#endif } /* o : mean of vector Qx */ diff --git a/lib_com/wi_fx.c b/lib_com/wi_fx.c index ce5a0e7f0c25ff1615f973f2b5c6bab746b2e940..8ff7537c4105a2ce958ebb232b5757430e6d0a1a 100644 --- a/lib_com/wi_fx.c +++ b/lib_com/wi_fx.c @@ -1466,18 +1466,30 @@ void DTFS_adjustLag_fx( tmp = div_s( shl( 1, sub( 14, exp ) ), X_DTFS_FX->lag_fx ); /* 29 - exp */ L_tmp = L_mult0( 12800, tmp ); temp32_fx = L_shl( L_tmp, sub( exp, 23 ) ); +#ifdef FIX_2493_CHECK_EXTRACT_L + diff_fx = extract_l2( L_shl( L_tmp, sub( exp, 29 ) ) ); +#else diff_fx = extract_l( L_shl( L_tmp, sub( exp, 29 ) ) ); +#endif exp = norm_s( diff_fx ); tmp = div_s( shl( 1, sub( 14, exp ) ), diff_fx ); /* 29 - exp */ L_tmp = L_mult0( X_DTFS_FX->upper_cut_off_freq_fx, tmp ); +#ifdef FIX_2493_CHECK_EXTRACT_L + X_DTFS_FX->nH_fx = extract_l2( L_shl( L_tmp, sub( exp, 29 ) ) ); +#else X_DTFS_FX->nH_fx = extract_l( L_shl( L_tmp, sub( exp, 29 ) ) ); +#endif move16(); L_tmp = L_mult0( 4000, tmp ); tempnH_fx = L_shl( L_tmp, sub( exp, 23 ) ); +#ifdef FIX_2493_CHECK_EXTRACT_L + X_DTFS_FX->nH_4kHz_fx = extract_l2( L_shl( L_tmp, sub( exp, 29 ) ) ); +#else X_DTFS_FX->nH_4kHz_fx = extract_l( L_shl( L_tmp, sub( exp, 29 ) ) ); +#endif move16(); IF( GE_16( sub( X_DTFS_FX->upper_cut_off_freq_fx, shr( extract_l( L_mult( diff_fx, X_DTFS_FX->nH_fx ) ), 1 ) ), diff_fx ) ) diff --git a/lib_dec/FEC_HQ_core_fx.c b/lib_dec/FEC_HQ_core_fx.c index 641f6005913ec14383212465558f765c5cd7975c..0b231413bcdd069003ba1b1bf3982346822125d3 100644 --- a/lib_dec/FEC_HQ_core_fx.c +++ b/lib_dec/FEC_HQ_core_fx.c @@ -354,7 +354,11 @@ void HQ_FEC_processing_fx( } ELSE { +#ifdef FIX_2493_CHECK_EXTRACT_L + norm_p_fx[i] = L_add( r_p_fx[0], L_mult0( extract_l2( r_p_fx[1] ), sub( add( st_fx->nbLostCmpt, num_pgf ), 1 ) ) ); +#else norm_p_fx[i] = L_add( r_p_fx[0], L_mult0( extract_l( r_p_fx[1] ), sub( add( st_fx->nbLostCmpt, num_pgf ), 1 ) ) ); +#endif move32(); } @@ -758,7 +762,11 @@ static Word16 find_best_delay_fx( ELSE { /*d1m *= delta; */ +#ifdef FIX_2493_CHECK_EXTRACT_L + d1m = extract_l2( L_mult0( d1m, delta ) ); +#else d1m = extract_l( L_mult0( d1m, delta ) ); +#endif exp1 = sub( norm_l( min_sq_cross_fx ), 1 ); exp2 = norm_l( min_corr_fx ); @@ -933,12 +941,20 @@ static Word16 FEC_phase_matching_fx( /* OldauOut without windowing */ FOR( i = N_ZERO_NB; i < L / 2; i++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + OldauOutnoWin_fx[i - N_ZERO_NB] = extract_l2( L_shr( L_negate( st_fx->oldIMDCTout_fx[L / 2 - 1 - i] ), 6 ) ); // Q6 -> Q0 +#else OldauOutnoWin_fx[i - N_ZERO_NB] = extract_l( L_shr( L_negate( st_fx->oldIMDCTout_fx[L / 2 - 1 - i] ), 6 ) ); // Q6 -> Q0 +#endif move16(); } FOR( i = 0; i < L / 2; i++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + OldauOutnoWin_fx[i + N_ZERO_O_NB] = extract_l2( L_shr( L_negate( st_fx->oldIMDCTout_fx[i] ), 6 ) ); // Q6 -> Q0 +#else OldauOutnoWin_fx[i + N_ZERO_O_NB] = extract_l( L_shr( L_negate( st_fx->oldIMDCTout_fx[i] ), 6 ) ); // Q6 -> Q0 +#endif move16(); } @@ -986,10 +1002,17 @@ static Word16 FEC_phase_matching_fx( FOR( i = 0; i < shr( L, 1 ); i++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + OldauOut2_fx[i] = extract_l2( L_shr( L_negate( ImdctOut_fx[L / 2 - 1 - i] ), 6 ) ); + move16(); + OldauOut2_fx[L / 2 + i] = extract_l2( L_shr( L_negate( ImdctOut_fx[i] ), 6 ) ); + move16(); +#else OldauOut2_fx[i] = extract_l( L_shr( L_negate( ImdctOut_fx[L / 2 - 1 - i] ), 6 ) ); move16(); OldauOut2_fx[L / 2 + i] = extract_l( L_shr( L_negate( ImdctOut_fx[i] ), 6 ) ); move16(); +#endif } Smoothing_vector_NB_fx( &ImdctOutWin_fx[N_Z_L_O_NB], &OldauOut2_fx[N_ZERO_NB], SmoothingWin_NB3_fx, &OldauOut_pha_fx[1][0], L_overlap ); @@ -1126,10 +1149,17 @@ static void FEC_phase_matching_burst_fx( { /* OldauOut2[i] = -ImdctOut[L/2 - 1 - i];*/ /* OldauOut2[L/2+i] = -ImdctOut[i];*/ +#ifdef FIX_2493_CHECK_EXTRACT_L + OldauOut2_fx[i] = extract_l2( L_shr( L_negate( ImdctOut_fx[L / 2 - 1 - i] ), 6 ) ); // Q6 -> Q0 + move16(); + OldauOut2_fx[L / 2 + i] = extract_l2( L_shr( L_negate( ImdctOut_fx[i] ), 6 ) ); // Q6 -> Q0 + move16(); +#else OldauOut2_fx[i] = extract_l( L_shr( L_negate( ImdctOut_fx[L / 2 - 1 - i] ), 6 ) ); // Q6 -> Q0 move16(); OldauOut2_fx[L / 2 + i] = extract_l( L_shr( L_negate( ImdctOut_fx[i] ), 6 ) ); // Q6 -> Q0 move16(); +#endif } Smoothing_vector_NB_fx( &ImdctOutWin_fx[N_Z_L_O_NB], &OldauOut2_fx[N_ZERO_NB], SmoothingWin_NB3_fx, &OldauOut_pha_fx[1][0], L_overlap ); @@ -1172,13 +1202,21 @@ static void Repetition_smoothing_nextgood_fx( FOR( i = N_ZERO_NB; i < L / 2; i++ ) { /*OldauOut[i-N_ZERO_NB] = -OldImdctOut[L/2 - 1 - i];*/ +#ifdef FIX_2493_CHECK_EXTRACT_L + OldauOut_fx[i - N_ZERO_NB] = extract_l2( L_shr( L_negate( OldImdctOut_fx[L / 2 - 1 - i] ), 6 ) ); /* Q6 -> Q0 */ +#else OldauOut_fx[i - N_ZERO_NB] = extract_l( L_shr( L_negate( OldImdctOut_fx[L / 2 - 1 - i] ), 6 ) ); /* Q6 -> Q0 */ +#endif move16(); } FOR( i = 0; i < L / 4; i++ ) { /*OldauOut[i+N_ZERO_O_NB] = -OldImdctOut[i];*/ +#ifdef FIX_2493_CHECK_EXTRACT_L + OldauOut_fx[i + N_ZERO_O_NB] = extract_l2( L_shr( L_negate( OldImdctOut_fx[i] ), 6 ) ); /* Q6 -> Q0 */ +#else OldauOut_fx[i + N_ZERO_O_NB] = extract_l( L_shr( L_negate( OldImdctOut_fx[i] ), 6 ) ); /* Q6 -> Q0 */ +#endif move16(); } @@ -1191,12 +1229,20 @@ static void Repetition_smoothing_nextgood_fx( FOR( i = N_ZERO_NB; i < L / 2; i++ ) { /* ImdctOutWin[i+L] = -ImdctOut[L/2 - 1 - i]; */ +#ifdef FIX_2493_CHECK_EXTRACT_L + ImdctOutWin_fx[add( i, L )] = extract_l2( L_shr( L_negate( ImdctOut_fx[L / 2 - 1 - i] ), 6 ) ); /* Q6 -> Q0 */ +#else ImdctOutWin_fx[add( i, L )] = extract_l( L_shr( L_negate( ImdctOut_fx[L / 2 - 1 - i] ), 6 ) ); /* Q6 -> Q0 */ +#endif move16(); } FOR( i = 0; i < L / 2; i++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + ImdctOutWin_fx[i + 3 * L / 2] = extract_l2( L_shr( L_negate( ImdctOut_fx[i] ), 6 ) ); /* Q6 -> Q0 */ +#else ImdctOutWin_fx[i + 3 * L / 2] = extract_l( L_shr( L_negate( ImdctOut_fx[i] ), 6 ) ); /* Q6 -> Q0 */ +#endif move16(); } @@ -1273,12 +1319,20 @@ static Word16 Repetition_smoothing_fx( /* OldauOut without windowing */ FOR( i = N_ZERO_NB; i < L / 2; i++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + OldauOutnoWin_fx[i - N_ZERO_NB] = extract_l2( L_shr( L_negate( OldImdctOut_fx[L / 2 - 1 - i] ), 6 ) ); /* Q6 -> Q0 */ +#else OldauOutnoWin_fx[i - N_ZERO_NB] = extract_l( L_shr( L_negate( OldImdctOut_fx[L / 2 - 1 - i] ), 6 ) ); /* Q6 -> Q0 */ +#endif move16(); } FOR( i = 0; i < L / 2; i++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + OldauOutnoWin_fx[i + N_ZERO_O_NB] = extract_l2( L_shr( L_negate( OldImdctOut_fx[i] ), 6 ) ); /* Q6 -> Q0 */ +#else OldauOutnoWin_fx[i + N_ZERO_O_NB] = extract_l( L_shr( L_negate( OldImdctOut_fx[i] ), 6 ) ); /* Q6 -> Q0 */ +#endif move16(); } @@ -1378,7 +1432,11 @@ static void Windowing_1st_NB_fx( FOR( i = N_ZERO_NB; i < L / 2; i++ ) { /*ImdctOutWin[i] = ImdctOut[L/2 + i] * win[(2*L-1-i)-N_LEAD_O_NB];*/ +#ifdef FIX_2493_CHECK_EXTRACT_L + ImdctOutWin_fx[i] = extract_l2( L_shr( Mult_32_16( ImdctOut_fx[L / 2 + i], win_fx[( 2 * L - 1 - i ) - N_LEAD_O_NB] ), 6 ) ); // Q6 -> Q0 +#else ImdctOutWin_fx[i] = extract_l( L_shr( Mult_32_16( ImdctOut_fx[L / 2 + i], win_fx[( 2 * L - 1 - i ) - N_LEAD_O_NB] ), 6 ) ); // Q6 -> Q0 +#endif move16(); } @@ -1386,29 +1444,47 @@ static void Windowing_1st_NB_fx( { /*ImdctOutWin[L/2 + i] = -ImdctOut[L - 1 - i] * win[(3*L/2-1-i)-N_LEAD_O_NB];*/ /*ImdctOutWin[3*L/2 + i] = -ImdctOut[i] * win[(L/2-i-1)];*/ +#ifdef FIX_2493_CHECK_EXTRACT_L + ImdctOutWin_fx[L / 2 + i] = extract_l2( L_shr( Mult_32_16( L_negate( ImdctOut_fx[L - 1 - i] ), win_fx[( 3 * L / 2 - 1 - i ) - N_LEAD_O_NB] ), 6 ) ); // Q6 -> Q0 + move16(); + ImdctOutWin_fx[3 * L / 2 + i] = extract_l2( L_shr( Mult_32_16( L_negate( ImdctOut_fx[i] ), win_fx[( L / 2 - i - 1 )] ), 6 ) ); // Q6 -> Q0 + move16(); +#else ImdctOutWin_fx[L / 2 + i] = extract_l( L_shr( Mult_32_16( L_negate( ImdctOut_fx[L - 1 - i] ), win_fx[( 3 * L / 2 - 1 - i ) - N_LEAD_O_NB] ), 6 ) ); // Q6 -> Q0 move16(); ImdctOutWin_fx[3 * L / 2 + i] = extract_l( L_shr( Mult_32_16( L_negate( ImdctOut_fx[i] ), win_fx[( L / 2 - i - 1 )] ), 6 ) ); // Q6 -> Q0 move16(); +#endif } } ELSE { FOR( i = N_ZERO_NB; i < L / 2; i++ ) { - /*ImdctOutWin[i] = ImdctOut[L/2 + i] * smoothingWin[(i-N_ZERO_NB)];*/ /*win[(2*L-i)*decimate-1-decay-14*L_FRAME48k/20];*/ + /*ImdctOutWin[i] = ImdctOut[L/2 + i] * smoothingWin[(i-N_ZERO_NB)];*/ /*win[(2*L-i)*decimate-1-decay-14*L_FRAME48k/20];*/ +#ifdef FIX_2493_CHECK_EXTRACT_L + ImdctOutWin_fx[i] = extract_l2( L_shr( Mult_32_16( ImdctOut_fx[L / 2 + i], smoothingWin_fx[( i - N_ZERO_NB )] ), 6 ) ); /*win[(2*L-i)*decimate-1-decay-14*L_FRAME48k/20];*/ +#else ImdctOutWin_fx[i] = extract_l( L_shr( Mult_32_16( ImdctOut_fx[L / 2 + i], smoothingWin_fx[( i - N_ZERO_NB )] ), 6 ) ); /*win[(2*L-i)*decimate-1-decay-14*L_FRAME48k/20];*/ +#endif move16(); } FOR( i = 0; i < N_ZERO_O_NB; i++ ) { /*ImdctOutWin[L/2 + i] = -ImdctOut[L - 1 - i] * smoothingWin[(i+N_ZERO_O_NB)];*/ /*win[(3*L/2-1-i)*decimate+decay-L_FRAME48k*14/20];*/ - /*ImdctOutWin[3*L/2 + i] = -ImdctOut[i] * win[(L/2-i-1)];*/ + /*ImdctOutWin[3*L/2 + i] = -ImdctOut[i] * win[(L/2-i-1)];*/ +#ifdef FIX_2493_CHECK_EXTRACT_L + ImdctOutWin_fx[L / 2 + i] = extract_l2( L_shr( Mult_32_16( L_negate( ImdctOut_fx[L - 1 - i] ), smoothingWin_fx[( i + N_ZERO_O_NB )] ), 6 ) ); /*win[(3*L/2-1-i)*decimate+decay-L_FRAME48k*14/20];*/ // Q6 -> Q0 + move16(); + ImdctOutWin_fx[3 * L / 2 + i] = extract_l2( L_shr( Mult_32_16( L_negate( ImdctOut_fx[i] ), win_fx[( L / 2 - i - 1 )] ), 6 ) ); // Q6 -> Q0 + move16(); +#else ImdctOutWin_fx[L / 2 + i] = extract_l( L_shr( Mult_32_16( L_negate( ImdctOut_fx[L - 1 - i] ), smoothingWin_fx[( i + N_ZERO_O_NB )] ), 6 ) ); /*win[(3*L/2-1-i)*decimate+decay-L_FRAME48k*14/20];*/ // Q6 -> Q0 move16(); ImdctOutWin_fx[3 * L / 2 + i] = extract_l( L_shr( Mult_32_16( L_negate( ImdctOut_fx[i] ), win_fx[( L / 2 - i - 1 )] ), 6 ) ); // Q6 -> Q0 move16(); +#endif } } @@ -1429,23 +1505,38 @@ static void Windowing_2nd_NB_fx( { /*ImdctOutWin[L/2 + i] = -ImdctOut[L - 1 - i];*/ /*ImdctOutWin[3*L/2 + i] = -ImdctOut[i] * win[L/2-i-1];*/ +#ifdef FIX_2493_CHECK_EXTRACT_L + ImdctOutWin_fx[L / 2 + i] = extract_l2( L_shr( L_negate( ImdctOut_fx[L - 1 - i] ), 6 ) ); + move16(); + ImdctOutWin_fx[3 * L / 2 + i] = extract_l2( L_shr( Mult_32_16( L_negate( ImdctOut_fx[i] ), win_fx[L / 2 - i - 1] ), 6 ) ); + move16(); +#else ImdctOutWin_fx[L / 2 + i] = extract_l( L_shr( L_negate( ImdctOut_fx[L - 1 - i] ), 6 ) ); move16(); ImdctOutWin_fx[3 * L / 2 + i] = extract_l( L_shr( Mult_32_16( L_negate( ImdctOut_fx[i] ), win_fx[L / 2 - i - 1] ), 6 ) ); move16(); +#endif } FOR( i = 0; i < N_ZERO_NB; i++ ) { /*ImdctOutWin[L + i] = -ImdctOut[L/2 - 1 - i];*/ +#ifdef FIX_2493_CHECK_EXTRACT_L + ImdctOutWin_fx[L + i] = extract_l2( L_shr( L_negate( ImdctOut_fx[L / 2 - 1 - i] ), 6 ) ); +#else ImdctOutWin_fx[L + i] = extract_l( L_shr( L_negate( ImdctOut_fx[L / 2 - 1 - i] ), 6 ) ); +#endif move16(); } FOR( i = N_ZERO_NB; i < L / 2; i++ ) { /*ImdctOutWin[L + i] = -ImdctOut[L/2 - 1 - i] * win[L - 1 - i];*/ +#ifdef FIX_2493_CHECK_EXTRACT_L + ImdctOutWin_fx[L + i] = extract_l2( L_shr( Mult_32_16( L_negate( ImdctOut_fx[L / 2 - 1 - i] ), win_fx[L - 1 - i] ), 6 ) ); +#else ImdctOutWin_fx[L + i] = extract_l( L_shr( Mult_32_16( L_negate( ImdctOut_fx[L / 2 - 1 - i] ), win_fx[L - 1 - i] ), 6 ) ); +#endif move16(); } diff --git a/lib_dec/FEC_clas_estim_fx.c b/lib_dec/FEC_clas_estim_fx.c index 946f770e8f47dec5f09ef005179bd0e5f831e321..3be1c527ca5045daaabd815bcb6917f7a4b184ca 100644 --- a/lib_dec/FEC_clas_estim_fx.c +++ b/lib_dec/FEC_clas_estim_fx.c @@ -328,7 +328,11 @@ void FEC_clas_estim_fx( move16(); IF( j > 0 ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + voicing = extract_l2( Mult_32_16( Ltmp, j ) ); +#else voicing = extract_l( Mult_32_16( Ltmp, j ) ); +#endif } /*------------------------------------------------------------------------* * Compute pitch coherence diff --git a/lib_dec/bass_psfilter_fx.c b/lib_dec/bass_psfilter_fx.c index d2558f47c1f1bc9a5ff1b5dca78acb5763eeff17..189e900514cfc3e1e17f880142784ce864d54aa8 100644 --- a/lib_dec/bass_psfilter_fx.c +++ b/lib_dec/bass_psfilter_fx.c @@ -1011,8 +1011,12 @@ Word16 res_bpf_adapt_ivas_fx( W_tmp = W_add_nosat( W_tmp, W_mult0_32_32( res_buf[i], res_buf[i] ) ); } +#ifdef FIX_2493_CHECK_EXTRACT_L + res_hb_nrg = W_extract_l2( W_shr( W_tmp, shl( q_res, 1 ) ) ); // Q0 +#else res_hb_nrg = W_extract_l( W_shr( W_tmp, shl( q_res, 1 ) ) ); // Q0 - res_hb_nrg = Mpy_32_16_1( res_hb_nrg, bw_inv ); // Q0 +#endif + res_hb_nrg = Mpy_32_16_1( res_hb_nrg, bw_inv ); // Q0 res_hb_nrg = L_add( Mpy_32_16_1( res_hb_nrg, STEREO_DFT_BPF_ADAPT_ALPHA_FX ), Mpy_32_16_1( hStereoDft->res_hb_nrg_mem_fx, sub( MAX_16, STEREO_DFT_BPF_ADAPT_ALPHA_FX ) ) ); hStereoDft->res_hb_nrg_mem_fx = res_hb_nrg; move32(); diff --git a/lib_dec/cng_dec_fx.c b/lib_dec/cng_dec_fx.c index 56d2bd29c3e33ac9724922d7936ab0c301c0c909..018cd64c80e8511226d9524015e12d09142a1aa4 100644 --- a/lib_dec/cng_dec_fx.c +++ b/lib_dec/cng_dec_fx.c @@ -484,7 +484,11 @@ void CNG_dec_fx( L_tmp1 = L_sub( L_tmp1, L_deposit_l( tmp[max_idx[0] * M + i] ) ); tmpv = div_s( 1, sub( m, 1 ) ); /*Q15*/ L_tmp1 = Mpy_32_16_1( L_tmp1, tmpv ); /*Q15*/ - lsp_tmp[i] = extract_l( L_tmp1 ); /*Q15*/ +#ifdef FIX_2493_CHECK_EXTRACT_L + lsp_tmp[i] = extract_l2( L_tmp1 ); /*Q15*/ +#else + lsp_tmp[i] = extract_l( L_tmp1 ); /*Q15*/ +#endif move16(); } } @@ -502,7 +506,11 @@ void CNG_dec_fx( L_tmp1 = L_sub( L_tmp1, L_add( L_deposit_l( tmp[max_idx[0] * M + i] ), L_deposit_l( tmp[max_idx[1] * M + i] ) ) ); /*Q15*/ tmpv = div_s( 1, sub( m, 2 ) ); /*Q15*/ L_tmp1 = Mpy_32_16_1( L_tmp1, tmpv ); /*Q15*/ - lsp_tmp[i] = extract_l( L_tmp1 ); /*Q15*/ +#ifdef FIX_2493_CHECK_EXTRACT_L + lsp_tmp[i] = extract_l2( L_tmp1 ); /*Q15*/ +#else + lsp_tmp[i] = extract_l( L_tmp1 ); /*Q15*/ +#endif move16(); } } @@ -793,8 +801,12 @@ static void shb_CNG_decod_fx( /* de-quantization of SHB CNG parameters */ IF( st->element_mode == EVS_MONO ) { - L_tmp = L_mult( idx_ener, 27400 ); /*Q14 */ + L_tmp = L_mult( idx_ener, 27400 ); /*Q14 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + hTdCngDec->last_shb_cng_ener_fx = extract_l2( L_shr( L_sub( L_tmp, 295924 ), 6 ) ); /*Q8 */ +#else hTdCngDec->last_shb_cng_ener_fx = extract_l( L_shr( L_sub( L_tmp, 295924 ), 6 ) ); /*Q8 */ +#endif move16(); } ELSE @@ -1124,7 +1136,11 @@ static void shb_CNG_decod_fx( FOR( i = 0; i < L_FRAME16k; i++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + shb_syn16k_fx[i] = extract_l2( L_shr( Mpy_32_16_1( L_gain_fx, excSHB_fx[i] ), sub( 5, tmp_16 ) ) ); /*Q3 = 31-Qtmp-8-15-5+Qtmp */ +#else shb_syn16k_fx[i] = extract_l( L_shr( Mpy_32_16_1( L_gain_fx, excSHB_fx[i] ), sub( 5, tmp_16 ) ) ); /*Q3 = 31-Qtmp-8-15-5+Qtmp */ +#endif move16(); } diff --git a/lib_dec/d_gain2p_fx.c b/lib_dec/d_gain2p_fx.c index c9a35c181692332fca1e9078f4f584dc7a0a28d4..d3e0afe0b27fc3664e831b46f9a0cb823cd28a6e 100644 --- a/lib_dec/d_gain2p_fx.c +++ b/lib_dec/d_gain2p_fx.c @@ -401,7 +401,11 @@ void d_gain_pred_fx( IF( GT_16( nrg_mode, 2 ) ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + *Es_pred = extract_l2( L_mac( -335544320l /* -20.f Q24*/, indice, 224 /* 1.75f Q7*/ ) ); /*(Q8 - ((Q0*Q7)=Q8))*/ +#else *Es_pred = extract_l( L_mac( -335544320l /* -20.f Q24*/, indice, 224 /* 1.75f Q7*/ ) ); /*(Q8 - ((Q0*Q7)=Q8))*/ +#endif move16(); } diff --git a/lib_dec/dec_higher_acelp_fx.c b/lib_dec/dec_higher_acelp_fx.c index 842749fa411665f0da5ffffda9c534e278ce87cf..0a23c67519085d1d3b2f08876b50f2e1ee270530 100644 --- a/lib_dec/dec_higher_acelp_fx.c +++ b/lib_dec/dec_higher_acelp_fx.c @@ -291,8 +291,12 @@ Word16 gain_dequant_fx( = pow(2,3.321928*y) */ - tmp = div_s( 1, sub( levels, 1 ) ); /*Q15*/ + tmp = div_s( 1, sub( levels, 1 ) ); /*Q15*/ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l2( L_shr( L_mult( index, tmp ), 1 ) ); /*Q15*/ +#else tmp = extract_l( L_shr( L_mult( index, tmp ), 1 ) ); /*Q15*/ +#endif e_tmp = norm_l( max_val ); f_tmp = Log2_norm_lc( L_shl( max_val, e_tmp ) ); @@ -314,7 +318,11 @@ Word16 gain_dequant_fx( frac = L_Extract_lc( L_tmp, expg ); /* Extract exponent of gcode0 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + gain = extract_l2( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#else gain = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#endif /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ *expg = sub( *expg, 14 ); diff --git a/lib_dec/dec_post_fx.c b/lib_dec/dec_post_fx.c index 829005b0a27e59cc76ade322fde9f508af3909cc..d8d53d1d534f95cadfeb07fd9e52693f3777492e 100644 --- a/lib_dec/dec_post_fx.c +++ b/lib_dec/dec_post_fx.c @@ -606,7 +606,11 @@ static void pst_ltp_fx( /* select short filter */ temp = sub( phase, 1 ); L_temp = L_mult0( temp, L_SUBFR + 1 ); +#ifdef FIX_2493_CHECK_EXTRACT_L + temp = extract_l2( L_temp ); +#else temp = extract_l( L_temp ); +#endif temp = add( temp, off_yup ); /* ptr_y_up = y_up + (phase-1) * (L_SUBFR+1) + off_yup */ @@ -741,7 +745,11 @@ static void search_del_fx( sh_ener = sub( 16, norm_l( L_acc ) ); /* save energy for final decision */ sh_ener = s_max( 0, sh_ener ); +#ifdef FIX_2493_CHECK_EXTRACT_L + ener = extract_l2( L_shr( L_acc, sh_ener ) ); +#else ener = extract_l( L_shr( L_acc, sh_ener ) ); +#endif /*------------------------------------- * Selects best of 3 integer delays @@ -933,10 +941,17 @@ static void search_del_fx( /* for non null phases */ /* Initialize with null phase */ +#ifdef FIX_2493_CHECK_EXTRACT_L + L_acc = L_shr( L_den_int, sh_den ); /* sh_den > 0 */ + den_max = extract_l2( L_acc ); + L_acc = L_shr( L_num_int, sh_num ); /* sh_num > 0 */ + num_max = extract_l2( L_acc ); +#else L_acc = L_shr( L_den_int, sh_den ); /* sh_den > 0 */ den_max = extract_l( L_acc ); L_acc = L_shr( L_num_int, sh_num ); /* sh_num > 0 */ num_max = extract_l( L_acc ); +#endif L_numsq_max = L_mult( num_max, num_max ); phi_max = 0; @@ -963,14 +978,22 @@ static void search_del_fx( } L_acc = L_shr( L_acc, sh_num ); /* sh_num > 0 */ L_acc = L_max( 0, L_acc ); +#ifdef FIX_2493_CHECK_EXTRACT_L + num = extract_l2( L_acc ); +#else num = extract_l( L_acc ); +#endif /* selection if num**2/den0 max */ L_temp1 = L_mult( num, num ); L_temp0 = Mpy_32_16_1( L_temp1, den_max ); L_acc = L_add( *ptr_L_den0++, 0 ); L_acc = L_shr( L_acc, sh_den ); /* sh_den > 0 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + den0 = extract_l2( L_acc ); +#else den0 = extract_l( L_acc ); +#endif L_temp = Msub_32_16( L_temp0, L_numsq_max, den0 ); IF( L_temp > 0L ) { @@ -996,14 +1019,22 @@ static void search_del_fx( } L_acc = L_shr( L_acc, sh_num ); /* sh_num > 0 */ L_acc = L_max( 0, L_acc ); +#ifdef FIX_2493_CHECK_EXTRACT_L + num = extract_l2( L_acc ); +#else num = extract_l( L_acc ); +#endif /* selection if num**2/den1 max */ L_temp1 = L_mult( num, num ); L_temp0 = Mpy_32_16_1( L_temp1, den_max ); L_acc = L_add( *ptr_L_den1++, 0 ); L_acc = L_shr( L_acc, sh_den ); /* sh_den > 0 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + den1 = extract_l2( L_acc ); +#else den1 = extract_l( L_acc ); +#endif L_temp = Msub_32_16( L_temp0, L_numsq_max, den1 ); IF( L_temp > 0L ) { @@ -1193,7 +1224,11 @@ static void compute_ltp_l_fx( temp = sub( 16, norm_l( L_acc ) ); temp = s_max( temp, 0 ); L_acc = L_shr( L_acc, temp ); /* with temp >= 0 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + *num = extract_l2( L_acc ); +#else *num = extract_l( L_acc ); +#endif *sh_num = temp; move16(); move16(); @@ -1208,7 +1243,11 @@ static void compute_ltp_l_fx( temp = sub( 16, norm_l( L_acc ) ); temp = s_max( temp, 0 ); L_acc = L_shr( L_acc, temp ); /* with temp >= 0 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + *den = extract_l2( L_acc ); +#else *den = extract_l( L_acc ); +#endif *sh_den = temp; move16(); move16(); diff --git a/lib_dec/dec_tcx_fx.c b/lib_dec/dec_tcx_fx.c index db29982a550bcb839fb727e49f2fb957841cbe9f..6a19e814273e2ff3c8fcda71527842d640ba5a46 100644 --- a/lib_dec/dec_tcx_fx.c +++ b/lib_dec/dec_tcx_fx.c @@ -283,8 +283,11 @@ void decoder_tcx_fx( noise_filling_index = prm[1]; move16(); - +#ifdef FIX_2493_CHECK_EXTRACT_L + fac_ns = extract_l2( L_shr( L_mult0( noise_filling_index, 0x6000 ), NBITS_NOISE_FILL_LEVEL ) ); +#else fac_ns = extract_l( L_shr( L_mult0( noise_filling_index, 0x6000 ), NBITS_NOISE_FILL_LEVEL ) ); +#endif } ELSE { @@ -1320,7 +1323,15 @@ void decoder_tcx_post_fx( Decoder_State *st_fx, FOR( i = 0; i < st_fx->L_frame; i++ ) { tmp32 = L_shl( tmp32_1 /*Q28*/, -( 28 - 15 ) ); /*16Q15*/ +#ifdef NONBE_FIX_2493_EXTRACT_L_decoder_tcx_post_fx + xn_buf[i] = extract_h( L_shl_sat( Mpy_32_16_1( tmp32, xn_buf[i] ), 16 ) ); +#else +#ifdef FIX_2493_CHECK_EXTRACT_L_EVS + xn_buf[i] = extract_l2( Mpy_32_16_1( tmp32, xn_buf[i] ) ); +#else xn_buf[i] = extract_l( Mpy_32_16_1( tmp32, xn_buf[i] ) ); +#endif +#endif move16(); tmp32_1 = L_sub( tmp32_1, tmp32_2 ); } @@ -1707,7 +1718,11 @@ void decoder_tcx_post_ivas_fx( Decoder_State *st_fx, { // gainCNG *= 1.f - (float) sub( st_fx->nbLostCmpt, MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME ) / MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN; tmp32 = L_sub( ONE_IN_Q31, imult3216( 107374182 /* 1 / MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN in Q31*/, sub( st_fx->nbLostCmpt, MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME ) ) ); /* Q31 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + gainCNG = extract_l2( Mpy_32_32( gainCNG, tmp32 ) ); +#else gainCNG = extract_l( Mpy_32_32( gainCNG, tmp32 ) ); +#endif } } } @@ -4740,7 +4755,11 @@ void decoder_tcx_noisefilling_fx( IF( bfi == 0 ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + fac_ns = extract_l2( L_shr( L_mult0( hTcxDec->noise_filling_index[frame_cnt], 0x6000 /* 0.75f in Q15 */ ), NBITS_NOISE_FILL_LEVEL ) ); +#else fac_ns = extract_l( L_shr( L_mult0( hTcxDec->noise_filling_index[frame_cnt], 0x6000 /* 0.75f in Q15 */ ), NBITS_NOISE_FILL_LEVEL ) ); +#endif } ELSE { diff --git a/lib_dec/dec_uv_fx.c b/lib_dec/dec_uv_fx.c index 3ae142064c88dd494808563c76a36e653af81b7c..263c86bacc76e813c3afdeeb4f42ddc4af9f8160 100644 --- a/lib_dec/dec_uv_fx.c +++ b/lib_dec/dec_uv_fx.c @@ -145,9 +145,14 @@ void decod_unvoiced_fx( exc2[i + i_subfr] += gain_code2 * code2[i]; //Q16 exc[i + i_subfr] = exc2[i + i_subfr] + gain_code * code[i];*/ // Q16 - exc2_fx[i + i_subfr_fx] = shl( mult_r( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 2 ); // Q_exc + exc2_fx[i + i_subfr_fx] = shl( mult_r( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 2 ); // Q_exc +#ifdef FIX_2493_CHECK_EXTRACT_L + exc2_fx[i + i_subfr_fx] = add( exc2_fx[i + i_subfr_fx], extract_l2( L_shr( Mpy_32_16_1( gain_code2_fx, code2_fx[i] ), sub( Q10, st_fx->Q_exc ) ) ) ); // Q_exc + exc_fx[i + i_subfr_fx] = add( exc2_fx[i + i_subfr_fx], extract_l2( L_shr( Mpy_32_16_1( gain_code_fx, code_fx[i] ), sub( Q10, st_fx->Q_exc ) ) ) ); // Q_exc +#else exc2_fx[i + i_subfr_fx] = add( exc2_fx[i + i_subfr_fx], extract_l( L_shr( Mpy_32_16_1( gain_code2_fx, code2_fx[i] ), sub( Q10, st_fx->Q_exc ) ) ) ); // Q_exc exc_fx[i + i_subfr_fx] = add( exc2_fx[i + i_subfr_fx], extract_l( L_shr( Mpy_32_16_1( gain_code_fx, code_fx[i] ), sub( Q10, st_fx->Q_exc ) ) ) ); // Q_exc +#endif move16(); move16(); move16(); diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index b6f5823c3e036d5a3707e6d9b7e79fcec5285a88..600e25148f03ca323e2e3cd31f5ce95e947780de 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -726,7 +726,11 @@ void con_tcx_fx( { // gainCNG *= 1.f - (float)(st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME) / MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN; L_tmp = L_sub( ONE_IN_Q31, imult3216( 107374182 /* 1 / MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN in Q31*/, sub( st->nbLostCmpt, MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME ) ) ); /* Q31 */ - gainCNG = extract_l( Mpy_32_32( gainCNG, L_tmp ) ); /*Q15-gainCNG_e*/ +#ifdef FIX_2493_CHECK_EXTRACT_L + gainCNG = extract_l2( Mpy_32_32( gainCNG, L_tmp ) ); /*Q15-gainCNG_e*/ +#else + gainCNG = extract_l( Mpy_32_32( gainCNG, L_tmp ) ); /*Q15-gainCNG_e*/ +#endif } } } @@ -749,7 +753,11 @@ void con_tcx_fx( IF( GT_32( L_shl( L_deposit_h( gainCNG ), sub( gainCNG_e, 31 - 16 ) /*Q16*/ ), L_tmp ) ) { gainCNG_e = sub( 15 + 1, norm_l( L_tmp ) ); +#ifdef FIX_2493_CHECK_EXTRACT_L + gainCNG = extract_l2( L_shr( L_tmp, gainCNG_e ) ); /*Q15,gainCNG_e*/ +#else gainCNG = extract_l( L_shr( L_tmp, gainCNG_e ) ); /*Q15,gainCNG_e*/ +#endif gainCNG_e = sub( gainCNG_e, 1 ); } diff --git a/lib_dec/gain_dec_fx.c b/lib_dec/gain_dec_fx.c index 90d065b0a9f45b5e3a40297e386c0761eb49206a..e9edf3657af47f5db3bcb605aaf977b2a8b3f26f 100644 --- a/lib_dec/gain_dec_fx.c +++ b/lib_dec/gain_dec_fx.c @@ -156,7 +156,11 @@ void gain_dec_tc_fx( L_tmp = L_mult( gcode0_fx, 21771 ); /* *0.166096 in Q17 -> Q26 */ L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */ frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + gcode0_fx = extract_l2( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#else gcode0_fx = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#endif /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp_gcode0 = sub( exp_gcode0, 14 ); @@ -334,7 +338,11 @@ void gain_dec_mless_fx( L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */ frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + gcode0_fx = extract_l2( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#else gcode0_fx = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#endif /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp_gcode0 = sub( exp_gcode0, 14 ); @@ -445,7 +453,11 @@ void gain_dec_mless_fx( L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */ frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + gcode0_fx = extract_l2( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#else gcode0_fx = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#endif /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp_gcode0 = sub( exp_gcode0, 14 ); @@ -610,7 +622,11 @@ void gain_dec_lbr_fx( L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */ frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + gcode0_fx = extract_l2( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#else gcode0_fx = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#endif /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp_gcode0 = sub( exp_gcode0, 14 ); @@ -682,7 +698,11 @@ void gain_dec_lbr_fx( L_tmp = L_shr( L_tmp, 7 ); /* From Q23 to Q16 */ frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + gcode0_fx = extract_l2( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#else gcode0_fx = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#endif /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp_gcode0 = sub( exp_gcode0, 14 ); @@ -756,7 +776,11 @@ void gain_dec_lbr_fx( L_tmp = L_shr( L_tmp, 7 ); /* From Q23 to Q16 */ frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + gcode0_fx = extract_l2( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#else gcode0_fx = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#endif /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp_gcode0 = sub( exp_gcode0, 14 ); @@ -838,7 +862,11 @@ void gain_dec_lbr_fx( L_tmp = L_shr( L_tmp, 7 ); /* From Q23 to Q16 */ frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + gcode0_fx = extract_l2( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#else gcode0_fx = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#endif /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp_gcode0 = sub( exp_gcode0, 14 ); @@ -1140,7 +1168,11 @@ void gain_dec_SQ_fx( L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */ frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + gcode0 = extract_l2( Pow2( 14, frac ) ); /* Put 14 as exponent so that output of Pow2() will be: 16384 < Pow2() <= 32767 */ +#else gcode0 = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that output of Pow2() will be: 16384 < Pow2() <= 32767 */ +#endif exp_gcode0 = sub( exp_gcode0, 14 ); /*-----------------------------------------------------------------* @@ -1248,7 +1280,11 @@ void gain_dec_amr_wb_fx( L_tmp = L_shr( L_tmp, 9 + 2 ); /* From Q27 to Q16 */ L_Extract( L_tmp, &exp_gcode0, &fracg ); /* Extract exponent of gcode0 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + gcode0 = extract_l2( Pow2( 14, fracg ) ); /* Put 14 as exponent so that */ +#else gcode0 = extract_l( Pow2( 14, fracg ) ); /* Put 14 as exponent so that */ +#endif /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp_gcode0 = sub( exp_gcode0, 14 ); diff --git a/lib_dec/hf_synth_fx.c b/lib_dec/hf_synth_fx.c index f2be9219ded15eccf1a30b5b69fc241aa738f919..a7f0e711fa21914cbcee8505a2b0afb7dda80077 100644 --- a/lib_dec/hf_synth_fx.c +++ b/lib_dec/hf_synth_fx.c @@ -646,7 +646,11 @@ void hf_synth_amr_wb_fx( } L_tmp = L_mult( fmerit_w, add_sat( 16384, voice_fac ) ); /* Q14 */ - fmerit_w = extract_l( L_shr( L_tmp, 15 ) ); /*Q14 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + fmerit_w = extract_l2( L_shr( L_tmp, 15 ) ); /*Q14 */ +#else + fmerit_w = extract_l( L_shr( L_tmp, 15 ) ); /*Q14 */ +#endif /**fmerit_w_sm = add(mult_r(*fmerit_w_sm, 29491), mult_r(fmerit_w, 3277)); //Q14 */ hAmrwb_IO->fmerit_w_sm_fx = round_fx( L_mac( L_mult( hAmrwb_IO->fmerit_w_sm_fx, 29491 ), fmerit_w, 3277 ) ); /*Q14 */ move16(); @@ -686,8 +690,12 @@ void hf_synth_amr_wb_fx( *pt1 = add( *pt1, tmp1 ); move16(); /*Q13 */ - L_tmp = L_mult0( *pt1, fmerit_m ); /*Q13+14 */ + L_tmp = L_mult0( *pt1, fmerit_m ); /*Q13+14 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + *pt1++ = extract_l2( L_shr( L_tmp, 14 ) ); /*Q13 */ +#else *pt1++ = extract_l( L_shr( L_tmp, 14 ) ); /*Q13 */ +#endif move16(); } /* predict LPC coefficents and calculate sub-frame gains */ @@ -872,7 +880,11 @@ void hf_synth_amr_wb_fx( move16(); *pt3 = add_sat( *pt1, *pt2 ); move16(); +#ifdef FIX_2493_CHECK_EXTRACT_L + *pt3 = extract_l2( L_mult0( *pt3, *pt4 ) ); /*qdct */ +#else *pt3 = extract_l( L_mult0( *pt3, *pt4 ) ); /*qdct */ +#endif move16(); pt1++; pt2++; @@ -1266,13 +1278,25 @@ static Word16 EnhanceClass_fx( L_tmp = L_sub( 32768 /* 1.0 in Q15 */, *voice_fac_fx ); /*Q15 */ L_tmp = Mult_32_16( L_tmp, tmp ); /*Q13 */ - tmp = extract_l( L_tmp ); /*Q13 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l2( L_tmp ); /*Q13 */ +#else + tmp = extract_l( L_tmp ); /*Q13 */ +#endif tmp1 = mult_r( tilt_fx, 21845 ); /*Q15->1/1.5 ->Q13+15-15->Q13 */ tmp1 = s_min( tmp1, 8192 /* 1.0f in Q13 */ ); - L_tmp = L_mult( tmp, tmp1 ); /*Q13+Q13+1 */ + L_tmp = L_mult( tmp, tmp1 ); /*Q13+Q13+1 */ +#ifdef NONBE_FIX_2493_EXTRACT_L_EnhanceClass_fx + unvoicing_tmp_fx = extract_h( L_shl_sat( L_tmp, 16 - 12 ) ); /*Q15 */ +#else +#ifdef FIX_2493_CHECK_EXTRACT_L_EVS + unvoicing_tmp_fx = extract_l2( L_shr( L_tmp, 12 ) ); /*Q15 */ +#else unvoicing_tmp_fx = extract_l( L_shr( L_tmp, 12 ) ); /*Q15 */ +#endif +#endif /**unvoicing_fx = add(mult_r(16384, *unvoicing_fx), mult_r(16384, unvoicing_tmp_fx)); //Q15 */ *unvoicing_fx = round_fx( L_mac( L_mult( 16384 /* 0.5 in Q15 */, *unvoicing_fx ), 16384 /* 0.5 in Q15 */, unvoicing_tmp_fx ) ); /*Q15 */ @@ -1660,10 +1684,16 @@ static void AdaptiveStartBand_fx( *pt1++ = sub( *pt2++, *pt3++ ); move16(); /*Q2 */ } +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp1 = extract_l2( Mult_32_16( core_rate, 27046 /* 0.00005 in Q29 */ ) ); /*Q14 */ + L_tmp = L_shr( L_mult0( tmp1, 22370 /* 1/6000 in Q27 */ ), 15 ); /*Q27->1/6000 ->Q26 */ + tmp2 = extract_l2( L_tmp ); /*Q26 */ +#else tmp1 = extract_l( Mult_32_16( core_rate, 27046 /* 0.00005 in Q29 */ ) ); /*Q14 */ L_tmp = L_shr( L_mult0( tmp1, 22370 /* 1/6000 in Q27 */ ), 15 ); /*Q27->1/6000 ->Q26 */ tmp2 = extract_l( L_tmp ); /*Q26 */ - W_fx = mult_r( tmp1, tmp2 ); /*Q25 */ +#endif + W_fx = mult_r( tmp1, tmp2 ); /*Q25 */ IF( EQ_16( clas, AUDIO_CLAS ) ) { diff --git a/lib_dec/hq_hr_dec_fx.c b/lib_dec/hq_hr_dec_fx.c index 0c9fb88d6b802d346ee07ecbf1a17a4277579938..609fcb9fc428593cfbf6a866155c52db40dc3514 100644 --- a/lib_dec/hq_hr_dec_fx.c +++ b/lib_dec/hq_hr_dec_fx.c @@ -55,8 +55,12 @@ void hq_pred_hb_bws_fx( { L_tmp = L_add( L_tmp, SWB_fenv[i] ); /*Q1*/ } - L_tmp = Mpy_32_16_1( L_tmp, 2979 ); // Q1 + L_tmp = Mpy_32_16_1( L_tmp, 2979 ); // Q1 +#ifdef FIX_2493_CHECK_EXTRACT_L + st_fx->prev_ener_shb_fx = extract_l2( L_tmp ); /*Q1*/ +#else st_fx->prev_ener_shb_fx = extract_l( L_tmp ); /*Q1*/ +#endif move16(); } } diff --git a/lib_dec/hq_lr_dec_fx.c b/lib_dec/hq_lr_dec_fx.c index 7ec1d15db8f0c23719b047d6ddce8b52e86d542d..0f9cd80cee4b8bff1feb90a2b991383e7ea062ef 100644 --- a/lib_dec/hq_lr_dec_fx.c +++ b/lib_dec/hq_lr_dec_fx.c @@ -503,8 +503,12 @@ void hq_lr_dec_fx( tmp = Calc_inv( L_shl_sat( L_tmp, 14 ), &exp ); L_tmp = L_shl_sat( Mult_32_16( Ep_avrg_fx, tmp ), sub( 14, exp ) ); /*Q(13+exp-15 +14-exp+2 = 14) */ L_tmp = L_max( L_tmp, 16384 ); /*14 */ - tmp = extract_l( L_min( L_tmp, beta_fx ) ); /*14 */ - alpha_fx = shl( mult( alpha_fx, tmp ), 1 ); /*14+14-15 +1=14 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l2( L_min( L_tmp, beta_fx ) ); /*14 */ +#else + tmp = extract_l( L_min( L_tmp, beta_fx ) ); /*14 */ +#endif + alpha_fx = shl( mult( alpha_fx, tmp ), 1 ); /*14+14-15 +1=14 */ } ELSE { @@ -718,7 +722,11 @@ void hq_lr_dec_fx( L_tmp = L_shl( L_tmp, sub( 14, exp ) ); /*Q14 */ tmp = extract_l( L_min( L_max( L_tmp, 16384 ), 20480 ) ); /*Q14 */ L_tmp = L_mult( alpha_fx, tmp ); /*Q(14+14+1=29) */ - alpha_fx = extract_l( L_shr( L_tmp, 15 ) ); /*Q14 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + alpha_fx = extract_l2( L_shr( L_tmp, 15 ) ); /*Q14 */ +#else + alpha_fx = extract_l( L_shr( L_tmp, 15 ) ); /*Q14 */ +#endif } ELSE { @@ -745,7 +753,11 @@ void hq_lr_dec_fx( L_tmp = L_shl( L_tmp, sub( 29, exp ) ); /*Q14 */ tmp = extract_l( L_min( L_max( L_tmp, 13926 ), 16384 ) ); /*Q14 */ L_tmp = L_mult( alpha_fx, tmp ); /*Q(14+14+1=29) */ - alpha_fx = extract_l( L_shr( L_tmp, 15 ) ); /*Q14 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + alpha_fx = extract_l2( L_shr( L_tmp, 15 ) ); /*Q14 */ +#else + alpha_fx = extract_l( L_shr( L_tmp, 15 ) ); /*Q14 */ +#endif } } L_tmp = Mult_32_16( L_band_energy_tmp[i], alpha_fx ); /*Q(Q_band_energy+14-15=Q_band_energy-1) */ @@ -903,7 +915,11 @@ void hq_lr_dec_fx( tmp = div_s( 1, sub( bands_fx, k1_fx ) ); /*Q15 */ L_tmp = L_add( L_tmp, Mult_32_16( Ep_tmp_fx[i], tmp ) ); /*Q15 */ } +#ifdef FIX_2493_CHECK_EXTRACT_L + st_fx->prev_ener_shb_fx = extract_l2( L_shr( L_tmp, 14 ) ); /* Q1 */ +#else st_fx->prev_ener_shb_fx = extract_l( L_shr( L_tmp, 14 ) ); /* Q1 */ +#endif move16(); } test(); @@ -1317,7 +1333,11 @@ static void mdct_spectrum_fine_gain_dec_fx( L_temp = L_shr( L_shr( L_q, 1 ), sub( 29, 16 ) ); temp_lo_fx = L_Extract_lc( L_temp, &temp_hi_fx ); Qgt = sub( 14, temp_hi_fx ); +#ifdef FIX_2493_CHECK_EXTRACT_L + gain_table_fx[i] = extract_l2( Pow2( 14, temp_lo_fx ) ); /* Qgt */ +#else gain_table_fx[i] = extract_l( Pow2( 14, temp_lo_fx ) ); /* Qgt */ +#endif move16(); /*q += delta; */ diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index 06ae20608b82181b76d4c810bcc7be040174b1c8..32a55505212aa19e4313822771d6faa88e10875c 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -266,7 +266,11 @@ ivas_error ivas_core_dec_fx( L_tmp = Mpy_32_16_1( conceal_eof_gain32, st->hHQ_core->old_out_fx[i] ); // Q0 (15+1+0 - (15 + 1) L_tmp = Mpy_32_16_1( L_tmp, st->last_concealed_gain_syn_deemph ); // Q(0+15 - last_concealed_gain_syn_deemph_e -15) L_tmp = L_shl( L_tmp, st->last_concealed_gain_syn_deemph_e ); // Q0 (-last_concealed_gain_syn_deemph_e +last_concealed_gain_syn_deemph_e) - st->hHQ_core->old_out_fx[i] = extract_l( L_tmp ); // Q0 +#ifdef FIX_2493_CHECK_EXTRACT_L + st->hHQ_core->old_out_fx[i] = extract_l2( L_tmp ); // Q0 +#else + st->hHQ_core->old_out_fx[i] = extract_l( L_tmp ); // Q0 +#endif move16(); } @@ -275,7 +279,11 @@ ivas_error ivas_core_dec_fx( L_tmp = Mpy_32_16_1( conceal_eof_gain32, st->hHQ_core->old_out_LB_fx[i] ); // Q0 (15+1+0 - (15 + 1) L_tmp = Mpy_32_16_1( L_tmp, st->last_concealed_gain_syn_deemph ); // Q(0+15 - last_concealed_gain_syn_deemph_e -15) L_tmp = L_shl( L_tmp, st->last_concealed_gain_syn_deemph_e ); // Q0 (-last_concealed_gain_syn_deemph_e +last_concealed_gain_syn_deemph_e) - st->hHQ_core->old_out_LB_fx[i] = extract_l( L_tmp ); // Q0 +#ifdef FIX_2493_CHECK_EXTRACT_L + st->hHQ_core->old_out_LB_fx[i] = extract_l2( L_tmp ); // Q0 +#else + st->hHQ_core->old_out_LB_fx[i] = extract_l( L_tmp ); // Q0 +#endif move16(); } } @@ -579,7 +587,11 @@ ivas_error ivas_core_dec_fx( st->hTcxDec->conLastFrameLevel = st->hTcxDec->LastFrameLevel_bfi_fx; move16(); } +#ifdef FIX_2493_CHECK_EXTRACT_L + st->hBPF->pst_mem_deemp_err_fx = extract_l2( st->mem_error ); +#else st->hBPF->pst_mem_deemp_err_fx = extract_l( st->mem_error ); +#endif move16(); } diff --git a/lib_dec/ivas_lfe_plc_fx.c b/lib_dec/ivas_lfe_plc_fx.c index a088b44adb6063c327e6caab8516257d3a47f3c4..06c723d8e5dba3ee86460ca3e3b4fba396b533b1 100755 --- a/lib_dec/ivas_lfe_plc_fx.c +++ b/lib_dec/ivas_lfe_plc_fx.c @@ -656,7 +656,11 @@ static void d_syn_filt_fx( move32(); yy_q_fx[i] = sub( s_q_fx, 32 ); move16(); +#ifdef FIX_2493_CHECK_EXTRACT_L + y_fx[i] = W_extract_l2( W_shr( s_fx, sub( s_q_fx, Q5 ) ) ); +#else y_fx[i] = W_extract_l( W_shr( s_fx, sub( s_q_fx, Q5 ) ) ); +#endif move32(); } *y_q_fx = Q5; diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index 6c80c617ddccb00968e4742551397dace09d2122..c98eff20377e3a12dd9b30a32c5f52bab1e2382b 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -1654,11 +1654,15 @@ static Word16 decode_lfe_to_total_energy_ratio_fx( } ELSE { +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp16 = shr( extract_l2( L_shr_r( McMASA_LFEGain_vectors_fx[4 * lfeToTotalEnergyRatioIndices[2] + i], Q12 ) ), 1 ); /* Q12 */ +#else tmp16 = shr( extract_l( L_shr_r( McMASA_LFEGain_vectors_fx[4 * lfeToTotalEnergyRatioIndices[2] + i], Q12 ) ), 1 ); /* Q12 */ - tmp16 = add( log2LFEaverage_fx, tmp16 ); /* Q12 */ - tmp32 = BASOP_util_Pow2( L_deposit_h( tmp16 ), 15 - Q12, &exp ); /* Q(31 - exp) */ - tmp16 = round_fx( tmp32 ); /* Q(31-exp) -> Q(15 - exp) */ - hMasaLfeSynth->lfeToTotalEnergyRatio_fx[i] = shr_sat( tmp16, sub( 1, exp ) ); /* should saturate. Q(15 - exp) - (1 - exp) -> Q14 */ +#endif + tmp16 = add( log2LFEaverage_fx, tmp16 ); /* Q12 */ + tmp32 = BASOP_util_Pow2( L_deposit_h( tmp16 ), 15 - Q12, &exp ); /* Q(31 - exp) */ + tmp16 = round_fx( tmp32 ); /* Q(31-exp) -> Q(15 - exp) */ + hMasaLfeSynth->lfeToTotalEnergyRatio_fx[i] = shr_sat( tmp16, sub( 1, exp ) ); /* should saturate. Q(15 - exp) - (1 - exp) -> Q14 */ move16(); } diff --git a/lib_dec/lsf_dec_fx.c b/lib_dec/lsf_dec_fx.c index 8022cc7d3fc92facc4d040a481a14bcb432124f8..b44441aaa07e70b31e1286fa30fc740e20454639 100644 --- a/lib_dec/lsf_dec_fx.c +++ b/lib_dec/lsf_dec_fx.c @@ -409,12 +409,7 @@ void lsf_end_dec_fx( test(); test(); -#ifndef FIX_2588_MISSING_CONDITIONS IF( ( EQ_16( coder_type_org, GENERIC ) ) && ( EQ_32( st->sr_core, INT_FS_16k ) ) && ( mode2_flag == 0 ) ) -#else - test(); - IF( ( EQ_16( coder_type_org, GENERIC ) ) && ( EQ_32( st->sr_core, INT_FS_16k ) ) && ( mode2_flag == 0 ) && st->idchan == 0 ) -#endif { /* this bit is used only for primary channel or mono */ coder_type = (Word16) get_next_indice_fx( st, 1 ); /* Q0 */ diff --git a/lib_enc/acelp_core_enc_fx.c b/lib_enc/acelp_core_enc_fx.c index 8d9bf9f1f1d00b22ace4fd03bdb9410e2bf5300c..26a62a71ba524142b94904ceed32007bdd4966df 100644 --- a/lib_enc/acelp_core_enc_fx.c +++ b/lib_enc/acelp_core_enc_fx.c @@ -381,8 +381,12 @@ ivas_error acelp_core_enc_fx( enr = cng_energy_fx( st->element_mode, st->bwidth, st->hDtxEnc->CNG_mode, /*st->hTdCngEnc->CNG_att*/ 0, exc_fx, st->L_frame, Q_new ); // Q8 /* calculate the energy quantization index */ - enr_index = add( enr, 512 /* Q8(2.0) */ ); /* enr + 2.0 */ + enr_index = add( enr, 512 /* Q8(2.0) */ ); /* enr + 2.0 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + enr_index = extract_l2( L_shr( L_mult0( enr_index, STEP_SID_FX ), 12 + 8 ) ); /* Q0 (8+12-(8+12)) */ +#else enr_index = extract_l( L_shr( L_mult0( enr_index, STEP_SID_FX ), 12 + 8 ) ); /* Q0 (8+12-(8+12)) */ +#endif /* limit the energy quantization index */ enr_index = s_min( enr_index, 127 ); // Q0 @@ -438,8 +442,12 @@ ivas_error acelp_core_enc_fx( enr = cng_energy_fx( st->element_mode, st->bwidth, st->hDtxEnc->CNG_mode, st->hTdCngEnc->CNG_att_fx, exc_fx, st->L_frame, Q_new ); /* Q8 */ /* calculate the energy quantization index */ - enr_index = add( enr, 512 /* Q8(2.0) */ ); /* enr + 2.0 */ + enr_index = add( enr, 512 /* Q8(2.0) */ ); /* enr + 2.0 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + enr_index = extract_l2( L_shr( L_mult0( enr_index, STEP_SID_FX ), 12 + 8 ) ); /* Q0 (8+12-(8+12)) */ +#else enr_index = extract_l( L_shr( L_mult0( enr_index, STEP_SID_FX ), 12 + 8 ) ); /* Q0 (8+12-(8+12)) */ +#endif /* limit the energy quantization index */ enr_index = s_min( enr_index, 127 ); /* Q0 */ diff --git a/lib_enc/analy_sp_fx.c b/lib_enc/analy_sp_fx.c index e7d09c786d06b16f010c79b5529d09ca260195f1..6453575571aeccca344988fca7593ecdc9cc4b27 100644 --- a/lib_enc/analy_sp_fx.c +++ b/lib_enc/analy_sp_fx.c @@ -148,7 +148,11 @@ void analy_sp_fx( Ltmp = Mpy_32( exp_etot, frac_etot, LG10, 0 ); /*Q8 Averaged the total energy over both half-frames in log10 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + *Etot = extract_l2( L_shr( Ltmp, 14 - 8 ) ); /* Q8 */ +#else *Etot = extract_l( L_shr( Ltmp, 14 - 8 ) ); /* Q8 */ +#endif Bin_E[L_FFT / 2 - 1] = Bin_E[L_FFT / 2 - 2]; move32(); diff --git a/lib_enc/avq_cod_fx.c b/lib_enc/avq_cod_fx.c index e54dfeda293c25c78b4754231af24600de21acb7..aafda10493f428a3bb35161a9022d17770c26b17 100644 --- a/lib_enc/avq_cod_fx.c +++ b/lib_enc/avq_cod_fx.c @@ -119,7 +119,11 @@ void AVQ_cod_fx( /* estimated gain (when offset=0, estimated gain=1) */ f_tmp = L_Extract_lc( Ltmp, &e_tmp ); +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp16 = extract_l2( Pow2( 14, f_tmp ) ); +#else tmp16 = extract_l( Pow2( 14, f_tmp ) ); +#endif Lgain = L_shl_sat( tmp16, e_tmp ); /* gain_inv = 1.0f / gain */ e_tmp = norm_l( Lgain ); diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c index ff60b94d0f10249e90497150a0953e745b6aa3c6..e0484e3ceaabc3c10ff1393aac6d76171a9e41fc 100644 --- a/lib_enc/bw_detect_fx.c +++ b/lib_enc/bw_detect_fx.c @@ -413,11 +413,17 @@ void bw_detect_fx( cldfb_ener_offset_32 = L_deposit_l( cldfb_ener_offset ); /* Q14 in 32bit var */ cldfb_ener_offset_32 = L_shl( cldfb_ener_offset_32, 25 - 14 ); /* Q14 -> Q25 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + mean_NB = extract_l2( L_shr( L_add( mean_NB32, cldfb_ener_offset_32 ), 25 - 11 ) ); /* (Q25 + Q25) -> Q11 */ + max_NB = extract_l2( L_shr( L_add( max_NB32, cldfb_ener_offset_32 ), 25 - 11 ) ); /* (Q25 + Q25) -> Q11 */ + mean_WB = extract_l2( L_shr( L_add( mean_WB32, cldfb_ener_offset_32 ), 25 - 11 ) ); /* (Q25 + Q25) -> Q11 */ + max_WB = extract_l2( L_shr( L_add( max_WB32, cldfb_ener_offset_32 ), 25 - 11 ) ); /* (Q25 + Q25) -> Q11 */ +#else mean_NB = extract_l( L_shr( L_add( mean_NB32, cldfb_ener_offset_32 ), 25 - 11 ) ); /* (Q25 + Q25) -> Q11 */ max_NB = extract_l( L_shr( L_add( max_NB32, cldfb_ener_offset_32 ), 25 - 11 ) ); /* (Q25 + Q25) -> Q11 */ mean_WB = extract_l( L_shr( L_add( mean_WB32, cldfb_ener_offset_32 ), 25 - 11 ) ); /* (Q25 + Q25) -> Q11 */ max_WB = extract_l( L_shr( L_add( max_WB32, cldfb_ener_offset_32 ), 25 - 11 ) ); /* (Q25 + Q25) -> Q11 */ - +#endif /*if WB */ IF( EQ_32( st->input_Fs, 16000 ) ) @@ -453,8 +459,13 @@ void bw_detect_fx( L_tmp = L_add( L_tmp, L_shr( *pt32++, 2 ) ); mean_SWB32 = L_add( L_tmp, L_shr( *pt32++, 2 ) ); +#ifdef FIX_2493_CHECK_EXTRACT_L + mean_SWB = extract_l2( L_shr( L_add( mean_SWB32, cldfb_ener_offset_32 ), 25 - 11 ) ); /* (Q25 + Q25) -> Q11 */ + max_SWB = extract_l2( L_shr( L_add( max_SWB32, cldfb_ener_offset_32 ), 25 - 11 ) ); /* (Q25 + Q25) -> Q11 */ +#else mean_SWB = extract_l( L_shr( L_add( mean_SWB32, cldfb_ener_offset_32 ), 25 - 11 ) ); /* (Q25 + Q25) -> Q11 */ max_SWB = extract_l( L_shr( L_add( max_SWB32, cldfb_ener_offset_32 ), 25 - 11 ) ); /* (Q25 + Q25) -> Q11 */ +#endif } ELSE { /* FB */ @@ -467,8 +478,13 @@ void bw_detect_fx( L_tmp = L_add( L_tmp, L_shr( *pt32++, 2 ) ); mean_SWB32 = L_add( L_tmp, L_shr( *pt32++, 2 ) ); +#ifdef FIX_2493_CHECK_EXTRACT_L + mean_SWB = extract_l2( L_shr( L_add( mean_SWB32, cldfb_ener_offset_32 ), 25 - 11 ) ); /* (Q25 + Q25) -> Q11 */ + max_SWB = extract_l2( L_shr( L_add( max_SWB32, cldfb_ener_offset_32 ), 25 - 11 ) ); /* (Q25 + Q25) -> Q11 */ +#else mean_SWB = extract_l( L_shr( L_add( mean_SWB32, cldfb_ener_offset_32 ), 25 - 11 ) ); /* (Q25 + Q25) -> Q11 */ max_SWB = extract_l( L_shr( L_add( max_SWB32, cldfb_ener_offset_32 ), 25 - 11 ) ); /* (Q25 + Q25) -> Q11 */ +#endif /* FB: 16,4 - 19,6 kHz, 8 cldfb-bands (2 bins) */ @@ -478,8 +494,13 @@ void bw_detect_fx( L_tmp = L_shr( *pt32++, 1 ); mean_FB32 = L_add( L_tmp, L_shr( *pt32++, 1 ) ); +#ifdef FIX_2493_CHECK_EXTRACT_L + mean_FB = extract_l2( L_shr( L_add( mean_FB32, cldfb_ener_offset_32 ), 25 - 11 ) ); /* (Q25 + Q25) -> Q11 */ + max_FB = extract_l2( L_shr( L_add( max_FB32, cldfb_ener_offset_32 ), 25 - 11 ) ); /* (Q25 + Q25) -> Q11 */ +#else mean_FB = extract_l( L_shr( L_add( mean_FB32, cldfb_ener_offset_32 ), 25 - 11 ) ); /* (Q25 + Q25) -> Q11 */ max_FB = extract_l( L_shr( L_add( max_FB32, cldfb_ener_offset_32 ), 25 - 11 ) ); /* (Q25 + Q25) -> Q11 */ +#endif } } } diff --git a/lib_enc/cng_enc_fx.c b/lib_enc/cng_enc_fx.c index c28d008abbd43c157e985030dbc931603e0b0ea5..bf28eac76fade33059c1b0fe0b76497cd1f60e37 100644 --- a/lib_enc/cng_enc_fx.c +++ b/lib_enc/cng_enc_fx.c @@ -349,7 +349,11 @@ void CNG_enc_fx( L_tmp = L_sub( L_tmp, L_add( L_deposit_l( hTdCngEnc->cng_lsp_hist_fx[max_idx[0] * M + i] ), L_deposit_l( hTdCngEnc->cng_lsp_hist_fx[max_idx[1] * M + i] ) ) ); /*Q15 */ tmpv = div_s( 1, sub( hDtxEnc->cng_hist_size, 2 ) ); /*Q15 */ L_tmp = Mpy_32_16_1( L_tmp, tmpv ); /*Q15 */ - lsp_new[i] = extract_l( L_tmp ); /*Q15 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + lsp_new[i] = extract_l2( L_tmp ); /*Q15 */ +#else + lsp_new[i] = extract_l( L_tmp ); /*Q15 */ +#endif move16(); } max_idx1[0] = max_idx[0]; @@ -696,7 +700,11 @@ void CNG_enc_fx( L_tmp = L_sub( L_tmp, L_deposit_l( tmp[max_idx[0] * M + i] ) ); tmpv = div_s( 1, sub( m, 1 ) ); /*Q15 */ L_tmp = Mpy_32_16_1( L_tmp, tmpv ); /*Q15 */ - lsp_tmp[i] = extract_l( L_tmp ); /*Q15 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + lsp_tmp[i] = extract_l2( L_tmp ); /*Q15 */ +#else + lsp_tmp[i] = extract_l( L_tmp ); /*Q15 */ +#endif move16(); } } @@ -713,7 +721,11 @@ void CNG_enc_fx( L_tmp = L_sub( L_tmp, L_add( L_deposit_l( tmp[max_idx[0] * M + i] ), L_deposit_l( tmp[max_idx[1] * M + i] ) ) ); /*Q15 */ tmpv = div_s( 1, sub( m, 2 ) ); /*Q15 */ /*Q15 */ L_tmp = Mpy_32_16_1( L_tmp, tmpv ); /*Q15 */ /*Q15 */ - lsp_tmp[i] = extract_l( L_tmp ); /*Q15 */ /*Q15 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + lsp_tmp[i] = extract_l2( L_tmp ); /*Q15 */ /*Q15 */ +#else + lsp_tmp[i] = extract_l( L_tmp ); /*Q15 */ /*Q15 */ +#endif move16(); } } @@ -859,9 +871,13 @@ void CNG_enc_fx( move16(); } - att = mult( ftmp_fx, 5461 ); /* Q15 */ - L_tmp = L_mult( att, 8 ); /* Q16 */ + att = mult( ftmp_fx, 5461 ); /* Q15 */ + L_tmp = L_mult( att, 8 ); /* Q16 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp1 = extract_l2( L_shr( L_tmp, 2 ) ); /* Q14 */ +#else tmp1 = extract_l( L_shr( L_tmp, 2 ) ); /* Q14 */ +#endif tmp1 = add( 16384, tmp1 ); att = div_s( 16374, tmp1 ); /* Q15 */ @@ -1151,8 +1167,12 @@ void CNG_enc_fx( } /* calculate the energy quantization index */ - enr_index = add( enr, 512 /* Q8(2.0) */ ); /* enr + 2.0 */ + enr_index = add( enr, 512 /* Q8(2.0) */ ); /* enr + 2.0 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + enr_index = extract_l2( L_shr( L_mult0( enr_index, step ), 12 + 8 ) ); /* Q0 (8+12-(8+12)) */ +#else enr_index = extract_l( L_shr( L_mult0( enr_index, step ), 12 + 8 ) ); /* Q0 (8+12-(8+12)) */ +#endif /* limit the energy quantization index */ enr_index = s_min( enr_index, maxl ); @@ -1736,7 +1756,11 @@ static Word16 shb_DTX_fx( apply_scale( &att_fx32, st->hFdCngEnc->hFdCngCom->CngBandwidth, st->hFdCngEnc->hFdCngCom->CngBitrate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO ); // Q23; +#ifdef FIX_2493_CHECK_EXTRACT_L + att_fx = extract_l2( L_shr( att_fx32, 15 ) ); // Q8 +#else att_fx = extract_l( L_shr( att_fx32, 15 ) ); // Q8 +#endif } ELSE { diff --git a/lib_enc/cod4t64_fast_fx.c b/lib_enc/cod4t64_fast_fx.c index c6a2811e0675130380e40cbc121cb0d4b1b4c48d..406a13451e22da131e93d7a303f94f6042ae5aa9 100644 --- a/lib_enc/cod4t64_fast_fx.c +++ b/lib_enc/cod4t64_fast_fx.c @@ -401,7 +401,11 @@ void acelp_fast_fx( { s64 = W_mac0_16_16( s64, H[j], H[j - i] ); /* Q = shift + 6*/ } +#ifdef FIX_2493_CHECK_EXTRACT_L + *alp = extract_l2( W_extract_l2( W_shr( s64, shift ) ) ); /*Q6*/ +#else *alp = extract_l( W_extract_l( W_shr( s64, shift ) ) ); /*Q6*/ +#endif move16(); alp_buf[L_subfr - i] = *alp++; /*Q6*/ move16(); diff --git a/lib_enc/cor_shif_fx.c b/lib_enc/cor_shif_fx.c index c98afa1ee0781b5a73a43cf362a980152864282d..68e4d7f930a4b850c161cbd84f99d97b8a39166e 100644 --- a/lib_enc/cor_shif_fx.c +++ b/lib_enc/cor_shif_fx.c @@ -38,7 +38,11 @@ Word16 correlation_shift_fx( /* o : noise dependent Ltmp = L_mult( totalNoise_fx, 7545 ); /* Q24 */ Ltmp = L_shr( Ltmp, 8 ); /* Q24 -> Q16 */ f_Noise = L_Extract_lc( Ltmp, &e_Noise ); +#ifdef FIX_2493_CHECK_EXTRACT_L + wtmp = extract_l2( Pow2( 14, f_Noise ) ); /* Put 14 as exponent */ +#else wtmp = extract_l( Pow2( 14, f_Noise ) ); /* Put 14 as exponent */ +#endif e_Noise = sub( e_Noise, 14 ); /* Retreive exponent of wtmp */ Ltmp = Mpy_32_16( 8, 837, wtmp ); /* 2.4492e-4(Q31) * exp(0.1596*totalNoise) */ diff --git a/lib_enc/detect_transient_fx.c b/lib_enc/detect_transient_fx.c index 173092cdf8562ab854f5c880534346183d0c701f..cd3b23013ce82f1e5859b8b6ac09ebd510e298ca 100644 --- a/lib_enc/detect_transient_fx.c +++ b/lib_enc/detect_transient_fx.c @@ -166,7 +166,11 @@ Word16 detect_transient_fx( Energy_in_fx[blk + 1] = L_deposit_l( 0 ); FOR( i = 0; i < L / 4; i++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + temp16 = extract_l2( L_shr( out_filt_fx[i + blk * ( L / 4 )], 12 ) ); +#else temp16 = extract_l( L_shr( out_filt_fx[i + blk * ( L / 4 )], 12 ) ); +#endif Energy_fx = L_add_sat( Energy_fx, L_mult0( temp16, temp16 ) ); temp16 = shr( in_fx[i + blk * ( L / 4 )], Q_new ); /*Q0*/ Energy_in_fx[blk + 1] = L_add_sat( Energy_in_fx[blk + 1], L_mult0( temp16, temp16 ) ); /*Q0*/ diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index 52e42582c3ce33e25db2f2105b03646f7eb01624..2fbbd98da6579c754fd6bdf7b60d81c89c9e1850 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -270,7 +270,11 @@ static void E_ACELP_2pulse_search( assert( check ); /* debug code not instrumented */ - ps2 = extract_l( xy_save ); /*Qdn*/ +#ifdef FIX_2493_CHECK_EXTRACT_L + ps2 = extract_l2( xy_save ); /*Qdn*/ +#else + ps2 = extract_l( xy_save ); /*Qdn*/ +#endif *iy = s_and( ps2, L_SUBFR - 1 ); /*Q0*/ move16(); *ix = lshr( ps2, 6 ); /*Q0*/ diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c index a5b11f3b06ca27d9da208a793c7c7d8a54d0d14c..5ab1db0a02068ea5caae142bf5ca69d38cac9d44 100644 --- a/lib_enc/enc_acelpx_fx.c +++ b/lib_enc/enc_acelpx_fx.c @@ -237,7 +237,11 @@ static void E_ACELP_2pulse_searchx_fx( assert( ( ( s >= 0 && i == 0 && y == track_y ) ) || ( y > track_y ) || ( i > 0 ) ); } } +#ifdef FIX_2493_CHECK_EXTRACT_L + ps1 = extract_l2( xy_save ); +#else ps1 = extract_l( xy_save ); +#endif pos[1] = s_and( ps1, L_SUBFR - 1 ); move16(); pos[0] = lshr( ps1, 6 ); /* Q0 */ diff --git a/lib_enc/enc_higher_acelp_fx.c b/lib_enc/enc_higher_acelp_fx.c index f17d166712fe295df2fe532481e8a3f7c36b6182..e326a0f601fdf71ad93189db8fc387db6f59838d 100644 --- a/lib_enc/enc_higher_acelp_fx.c +++ b/lib_enc/enc_higher_acelp_fx.c @@ -523,7 +523,11 @@ Word16 gain_quant_fx( frac = L_Extract_lc( L_tmp, expg ); /* Extract exponent of gcode0 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + *gain16 = extract_l2( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#else *gain16 = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#endif /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ *expg = sub( *expg, 14 ); diff --git a/lib_enc/eval_pit_contr_fx.c b/lib_enc/eval_pit_contr_fx.c index b9c56e401cf126f9496ff5c219dc6da4409fb48d..f1605ce95fd1fbef9d18e9c08baebf6b99f0338e 100644 --- a/lib_enc/eval_pit_contr_fx.c +++ b/lib_enc/eval_pit_contr_fx.c @@ -112,7 +112,11 @@ Word16 Pit_exc_contribution_len_fx( F1st_harm = shr_r( tmp, sub( 5, exp1 ) ); /*Q4*/ /*F8th_harm = 8.0f*F1st_harm;*/ +#ifdef FIX_2493_CHECK_EXTRACT_L + F8th_harm = extract_l2( L_shr_r( L_mult0( F1st_harm, 8 ), 2 ) ); /*Q2*/ +#else F8th_harm = extract_l( L_shr_r( L_mult0( F1st_harm, 8 ), 2 ) ); /*Q2*/ +#endif freq = 0; move16(); diff --git a/lib_enc/ext_sig_ana_fx.c b/lib_enc/ext_sig_ana_fx.c index 33c2aa8f5f0cfb994620bb29f14447e4e6502e75..08ba139e622e2d056ebdb7dcf29d36ce7e343c7f 100644 --- a/lib_enc/ext_sig_ana_fx.c +++ b/lib_enc/ext_sig_ana_fx.c @@ -1125,7 +1125,11 @@ void core_signal_analysis_high_bitrate_ivas_fx( L_tmp = L_mult( hTcxEnc->speech_TCX[-1 - i], st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] ); // (q_inp, Q15) -> Q16 + q_inp L_tmp = Mpy_32_16_1( L_tmp, st->hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i].v.im ); // (Q16 + q_inp, Q15) -> Q16 + q_inp L_tmp = L_shl( L_tmp, shift ); // q_mdstWin - mdstWin[left_overlap + i] = add( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // q_mdstWin +#ifdef FIX_2493_CHECK_EXTRACT_L + mdstWin[left_overlap + i] = add( mdstWin[left_overlap + i], extract_l2( L_tmp ) ); // q_mdstWin +#else + mdstWin[left_overlap + i] = add( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // q_mdstWin +#endif move32(); } FOR( i = tmp - 1; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */ @@ -1133,7 +1137,11 @@ void core_signal_analysis_high_bitrate_ivas_fx( L_tmp = L_mult( hTcxEnc->speech_TCX[-1 - i], st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] ); // (q_inp, Q15) -> Q16 + q_inp L_tmp = Mpy_32_16_1( L_tmp, st->hTcxCfg->tcx_mdct_window_minimumFB[i].v.re ); // (Q16 + q_inp, Q15) -> Q16 + q_inp L_tmp = L_shl( L_tmp, shift ); // q_mdstWin - mdstWin[left_overlap + i] = add( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // q_mdstWin +#ifdef FIX_2493_CHECK_EXTRACT_L + mdstWin[left_overlap + i] = add( mdstWin[left_overlap + i], extract_l2( L_tmp ) ); // q_mdstWin +#else + mdstWin[left_overlap + i] = add( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // q_mdstWin +#endif move32(); } } @@ -1213,7 +1221,11 @@ void core_signal_analysis_high_bitrate_ivas_fx( L_tmp = L_mult( hTcxEnc->speech_TCX[-1 - i], st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] ); // (q_inp, Q15) -> Q16 + q_inp L_tmp = Mpy_32_16_1( L_tmp, st->hTcxCfg->tcx_mdct_window_minimumFB[minWindowLen - i].v.im ); // (Q16 + q_inp, Q15) -> Q16 + q_inp L_tmp = L_shl( L_tmp, shift ); // q_mdstWin - mdstWin[left_overlap + i] = add( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // q_mdstWin +#ifdef FIX_2493_CHECK_EXTRACT_L + mdstWin[left_overlap + i] = add( mdstWin[left_overlap + i], extract_l2( L_tmp ) ); // q_mdstWin +#else + mdstWin[left_overlap + i] = add( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // q_mdstWin +#endif move32(); } FOR( i = tmp - 1; i >= 0; i-- ) /* outer left folding of shortened long ALDO slope */ @@ -1221,7 +1233,11 @@ void core_signal_analysis_high_bitrate_ivas_fx( L_tmp = L_mult( hTcxEnc->speech_TCX[-1 - i], st->hTcxCfg->tcx_aldo_window_1_FB[left_overlap / 2 + minWindowLen - i] ); // (q_inp, Q15) -> Q16 + q_inp L_tmp = Mpy_32_16_1( L_tmp, st->hTcxCfg->tcx_mdct_window_minimumFB[i].v.re ); // (Q16 + q_inp, Q15) -> Q16 + q_inp L_tmp = L_shl( L_tmp, shift ); // q_mdstWin - mdstWin[left_overlap + i] = add( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // q_mdstWin +#ifdef FIX_2493_CHECK_EXTRACT_L + mdstWin[left_overlap + i] = add( mdstWin[left_overlap + i], extract_l2( L_tmp ) ); // q_mdstWin +#else + mdstWin[left_overlap + i] = add( mdstWin[left_overlap + i], extract_l( L_tmp ) ); // q_mdstWin +#endif move32(); } } diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index d954a658a59b718a11b5a814d59fbd3cf454eead..53e2e2085779a39b068e11155b124f5dc1dbf20f 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -2485,7 +2485,11 @@ void FdCngEncodeDiracMDCTStereoSID_fx( apply_scale( &gain_fx[0], sts[0]->hFdCngEnc->hFdCngCom->CngBandwidth, sts[0]->hDtxEnc->last_active_brate, scaleTableStereo, SIZE_SCALE_TABLE_STEREO ); /* quantize gain */ +#ifdef FIX_2493_CHECK_EXTRACT_L + gain_idx[0] = extract_l2( Mpy_32_32_r( L_add( gain_fx[0], 251658240 ), 384 ) ); +#else gain_idx[0] = extract_l( Mpy_32_32_r( L_add( gain_fx[0], 251658240 ), 384 ) ); +#endif move16(); gain_idx[0] = s_max( 0, s_min( 127, gain_idx[0] ) ); move16(); diff --git a/lib_enc/gain_enc_fx.c b/lib_enc/gain_enc_fx.c index 3e3c763230a571a5cd5e0486d3452c7a955585a7..87fc688251529f5131119102223002462a4825e6 100644 --- a/lib_enc/gain_enc_fx.c +++ b/lib_enc/gain_enc_fx.c @@ -108,7 +108,11 @@ void Es_pred_enc_fx( } s0 = sub( s0, add( Q_res, 6 ) ); Ltmp = Mpy_32_16( s0, s1, LG10 ); +#ifdef FIX_2493_CHECK_EXTRACT_L + ener_dB = extract_l2( L_shr( Ltmp, 14 - 8 ) ); /* Q8 Energy in log10 */ +#else ener_dB = extract_l( L_shr( Ltmp, 14 - 8 ) ); /* Q8 Energy in log10 */ +#endif test(); if ( ( ener_dB < 0 ) && ( no_ltp == 0 ) ) { @@ -316,7 +320,11 @@ void gain_enc_mless_fx( L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */ frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + gcode0 = extract_l2( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#else gcode0 = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#endif /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp_gcode0 = sub( exp_gcode0, 14 ); @@ -649,7 +657,11 @@ void gain_enc_SQ_fx( L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */ frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + gcode0 = extract_l2( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#else gcode0 = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#endif /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp_gcode0 = sub( exp_gcode0, 14 ); @@ -844,7 +856,11 @@ Word16 gain_enc_gaus_fx( wtmp = sub( wenr, lowBound ); /* Q8 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + index = extract_l2( L_shr( L_mac( 8388608, wtmp, inv_stepSize ), 16 + 8 ) ); // Q0 +#else index = extract_l( L_shr( L_mac( 8388608, wtmp, inv_stepSize ), 16 + 8 ) ); // Q0 +#endif /* index [0 (1< Q26 */ L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */ frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + gcode0_fx = extract_l2( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#else gcode0_fx = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#endif exp_gcode0 = sub( exp_gcode0, 14 ); IF( GT_16( nBits, 3 ) ) { @@ -1412,7 +1432,11 @@ void gain_enc_lbr_fx( L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */ frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + gcode0 = extract_l2( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#else gcode0 = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#endif /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp_gcode0 = sub( exp_gcode0, 14 ); @@ -1480,7 +1504,11 @@ void gain_enc_lbr_fx( L_tmp = L_shr( L_tmp, 7 ); /* From Q23 to Q16 */ frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + gcode0 = extract_l2( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#else gcode0 = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#endif /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp_gcode0 = sub( exp_gcode0, 14 ); @@ -1551,7 +1579,11 @@ void gain_enc_lbr_fx( L_tmp = L_shr( L_tmp, 7 ); /* From Q23 to Q16 */ frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + gcode0 = extract_l2( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#else gcode0 = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#endif /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp_gcode0 = sub( exp_gcode0, 14 ); @@ -1660,7 +1692,11 @@ void gain_enc_lbr_fx( L_tmp = L_shr( L_tmp, 7 ); /* From Q23 to Q16 */ frac = L_Extract_lc( L_tmp, &exp_gcode0 ); /* Extract exponent of gcode0 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + gcode0 = extract_l2( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#else gcode0 = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#endif /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp_gcode0 = sub( exp_gcode0, 14 ); @@ -1855,7 +1891,11 @@ void gain_enc_amr_wb_fx( L_tmp = L_shr( L_tmp, 8 ); /* From Q24 to Q16 */ L_Extract( L_tmp, &exp_gcode0, &frac ); /* Extract exponent of gcode0 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + gcode0 = extract_l2( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#else gcode0 = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ +#endif /* output of Pow2() will be: */ /* 16384 < Pow2() <= 32767 */ exp_gcode0 = sub( exp_gcode0, 14 ); @@ -1992,7 +2032,11 @@ void gain_enc_amr_wb_fx( exp = sub( exp, 11 ); L_tmp = Mpy_32_16( exp, frac, 24660 ); /* x 6.0206 in Q12 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + qua_ener = extract_l2( L_shr( L_tmp, 3 ) ); /* result in Q10 */ +#else qua_ener = extract_l( L_shr( L_tmp, 3 ) ); /* result in Q10 */ +#endif /*----------------------------------------------------------------* * update table of past quantized energies diff --git a/lib_enc/gaus_enc_fx.c b/lib_enc/gaus_enc_fx.c index 5c53881cd0943f595f435c5d628ce3646b1cfbb2..7fd6371f8f7114ed92d6507dbdc237210dabb141 100644 --- a/lib_enc/gaus_enc_fx.c +++ b/lib_enc/gaus_enc_fx.c @@ -663,7 +663,11 @@ static Word16 cod_2pos_fx( /* o : codebook quantization in } } +#ifdef FIX_2493_CHECK_EXTRACT_L + index = extract_l2( L_mult( i1, n ) ); +#else index = extract_l( L_mult( i1, n ) ); +#endif index = add( index, shl( i2, 1 ) ); index = add( index, s1 ); diff --git a/lib_enc/gp_clip_fx.c b/lib_enc/gp_clip_fx.c index 11f5fe90c065742fa8f21e9ab0ae3bd667d88a5f..f4678511464caa541f8de906b41b5e97ad12e0f1 100644 --- a/lib_enc/gp_clip_fx.c +++ b/lib_enc/gp_clip_fx.c @@ -121,7 +121,11 @@ Word16 gp_clip_fx( test(); IF( EQ_32( core_brate, ACELP_6k60 ) || EQ_32( core_brate, ACELP_8k85 ) || element_mode > EVS_MONO ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + thres = add( 14746 /* 0.9 in Q14 */, mult( 1638 /* 0.1 in Q14 */, extract_l2( L_mult( mem[0], (Word16) ( 16384 / DIST_ISF_MAX_IO ) ) ) ) ); /* clipping is activated when filtered pitch gain > threshold (0.94 to 1 in Q14) */ +#else thres = add( 14746 /* 0.9 in Q14 */, mult( 1638 /* 0.1 in Q14 */, extract_l( L_mult( mem[0], (Word16) ( 16384 / DIST_ISF_MAX_IO ) ) ) ) ); /* clipping is activated when filtered pitch gain > threshold (0.94 to 1 in Q14) */ +#endif if ( GT_16( mem[1], thres ) ) { clip = 1; diff --git a/lib_enc/hq_classifier_enc_fx.c b/lib_enc/hq_classifier_enc_fx.c index 642c503fec5f8a346719a7a26986959bcbea5f55..8bb28a54277e1bf3f2b05adb0eaae99d97160f84 100644 --- a/lib_enc/hq_classifier_enc_fx.c +++ b/lib_enc/hq_classifier_enc_fx.c @@ -690,8 +690,11 @@ static void hvq_classifier_fx( } } - +#ifdef FIX_2493_CHECK_EXTRACT_L + peak_th = extract_l2( BASOP_Util_Divide3232_Scale( L_add( W_extract_l2( W_mult0_32_32( L_core_brate, HVQ_PEAKS_PER_DELTA_THR ) ), HVQ_PEAKS_PER_DELTA_THR_OFFS ), HVQ_PEAKS_BPS_DELTA, &temp_e ) ); +#else peak_th = extract_l( BASOP_Util_Divide3232_Scale( L_add( W_extract_l( W_mult0_32_32( L_core_brate, HVQ_PEAKS_PER_DELTA_THR ) ), HVQ_PEAKS_PER_DELTA_THR_OFFS ), HVQ_PEAKS_BPS_DELTA, &temp_e ) ); +#endif peak_th = shr( peak_th, sub( 15, temp_e ) ); /* Find peaks */ pindx = maximum_32_fx( L_input_abs, num_peak_cands, &L_m ); @@ -817,7 +820,11 @@ static void hvq_classifier_fx( temp_e = 0; move16(); Word16 Npeaks_temp = *Npeaks; +#ifdef FIX_2493_CHECK_EXTRACT_L + *Npeaks = BASOP_Util_Divide3232_Scale( L_add( W_extract_l2( W_mult0_32_32( L_core_brate, HVQ_PEAKS_PER_DELTA ) ), HVQ_PEAKS_PER_DELTA_OFFS ), HVQ_PEAKS_BPS_DELTA, &temp_e ); +#else *Npeaks = BASOP_Util_Divide3232_Scale( L_add( W_extract_l( W_mult0_32_32( L_core_brate, HVQ_PEAKS_PER_DELTA ) ), HVQ_PEAKS_PER_DELTA_OFFS ), HVQ_PEAKS_BPS_DELTA, &temp_e ); +#endif *Npeaks = s_min( shr( *Npeaks, sub( 15, temp_e ) ), Npeaks_temp ); move16(); } diff --git a/lib_enc/hq_lr_enc_fx.c b/lib_enc/hq_lr_enc_fx.c index 9165eb8423403618d01f77721c1c124a90363877..a5841af767b3a3f3f6582149de4f5a46e9ce7bf3 100644 --- a/lib_enc/hq_lr_enc_fx.c +++ b/lib_enc/hq_lr_enc_fx.c @@ -467,9 +467,13 @@ void hq_lr_enc_fx( exp = 0; move16(); } - L_tmp = L_shl( Mult_32_16( Ep_avrg_fx, tmp ), sub( 13, exp ) ); /*Q(13+exp-15 +13-exp +4 = 15) */ - L_tmp2 = L_add( L_tmp, 13107 ); /*15 */ - tmp2 = extract_l( L_min( L_max( L_tmp2, 16384 ), gama_fx ) ); /*15 = 15 */ + L_tmp = L_shl( Mult_32_16( Ep_avrg_fx, tmp ), sub( 13, exp ) ); /*Q(13+exp-15 +13-exp +4 = 15) */ + L_tmp2 = L_add( L_tmp, 13107 ); /*15 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp2 = extract_l2( L_min( L_max( L_tmp2, 16384 ), gama_fx ) ); /*15 = 15 */ +#else + tmp2 = extract_l( L_min( L_max( L_tmp2, 16384 ), gama_fx ) ); /*15 = 15 */ +#endif L_band_energy_tmp[i] = Mult_32_16( L_band_energy_tmp[i], tmp2 ); /*Q(Q_band_energy+15-15 = Q_band_energy) */ move32(); } @@ -522,7 +526,11 @@ void hq_lr_enc_fx( L_tmp2 = Mult_32_16( Ep_vari_fx, 6554 ); /*13+15-15=13 */ L_tmp2 = L_shl_sat( Mult_32_16( L_tmp2, tmp2 ), sub( 13, exp ) ); /*Q(13+exp-15 +13-exp +3 = 14) */ L_tmp = L_min( L_tmp, L_tmp2 ); /*Q14 */ - tmp = extract_l( L_min( L_tmp, 13107 ) ); /*Q14 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l2( L_min( L_tmp, 13107 ) ); /*Q14 */ +#else + tmp = extract_l( L_min( L_tmp, 13107 ) ); /*Q14 */ +#endif alpha_fx = add( 16384, tmp ); } IF( EQ_16( hHQ_core->last_bitalloc_max_band[j++], 1 ) ) @@ -545,8 +553,12 @@ void hq_lr_enc_fx( } L_tmp = L_shl_sat( Mult_32_16( Ep_avrg_fx, tmp ), sub( 14, exp ) ); /*Q(13+exp-15 +14-exp+2 = 14) */ L_tmp = L_max( L_tmp, 16384 ); /*Q14 */ - tmp = extract_l( L_min( L_tmp, beta_fx ) ); /*Q14 */ - alpha_fx = shl( mult( alpha_fx, tmp ), 1 ); /*14+14-15 +1=Q14 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l2( L_min( L_tmp, beta_fx ) ); /*Q14 */ +#else + tmp = extract_l( L_min( L_tmp, beta_fx ) ); /*Q14 */ +#endif + alpha_fx = shl( mult( alpha_fx, tmp ), 1 ); /*14+14-15 +1=Q14 */ } ELSE { @@ -569,8 +581,12 @@ void hq_lr_enc_fx( L_tmp = L_shl_sat( Mult_32_16( Ep_tmp_fx[i], tmp2 ), sub( 19, exp ) ); /*Q(13+exp-15 +19-exp +3 = 20) */ L_tmp = Mult_32_16( L_tmp, shl( sub( bands_fx, lowband ), 9 ) ); /*20 +9 -15 =Q14 */ L_tmp = L_max( L_tmp, 13926 ); /*Q14 */ - tmp2 = extract_l( L_min( L_tmp, 16384 ) ); /*Q14 */ - alpha_fx = shl( mult( alpha_fx, tmp2 ), 1 ); /*14+14-15+1 =Q14 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp2 = extract_l2( L_min( L_tmp, 16384 ) ); /*Q14 */ +#else + tmp2 = extract_l( L_min( L_tmp, 16384 ) ); /*Q14 */ +#endif + alpha_fx = shl( mult( alpha_fx, tmp2 ), 1 ); /*14+14-15+1 =Q14 */ } L_band_energy_tmp[i] = L_shl( Mult_32_16( L_band_energy_tmp[i], alpha_fx ), 1 ); /*Q(Q_band_energy+14-15 +1= Q_band_energy) */ move32(); @@ -622,11 +638,15 @@ void hq_lr_enc_fx( exp = 0; move16(); } - L_tmp = Mult_32_16( Ep_peak_fx, tmp ); /*Q(13+exp-15+4 = exp+2) */ - L_tmp = Mult_32_16( L_tmp, lowband ); /*Q(exp+2+0-15 = exp-13) */ - L_tmp = Mult_32_16( L_tmp, 18842 ); /*Q(exp-13+16-16 = exp-13) */ - L_tmp = L_shl( L_tmp, sub( 27, exp ) ); /*Q14 0.5 */ - tmp2 = extract_l( L_min( L_tmp, 19661 ) ); /*Q14 */ + L_tmp = Mult_32_16( Ep_peak_fx, tmp ); /*Q(13+exp-15+4 = exp+2) */ + L_tmp = Mult_32_16( L_tmp, lowband ); /*Q(exp+2+0-15 = exp-13) */ + L_tmp = Mult_32_16( L_tmp, 18842 ); /*Q(exp-13+16-16 = exp-13) */ + L_tmp = L_shl( L_tmp, sub( 27, exp ) ); /*Q14 0.5 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp2 = extract_l2( L_min( L_tmp, 19661 ) ); /*Q14 */ +#else + tmp2 = extract_l( L_min( L_tmp, 19661 ) ); /*Q14 */ +#endif L_tmp = Mult_32_16( L_band_energy_tmp[i], tmp2 ); /*Q(Q_band_energy+14-15 = Q_band_energy-1) */ L_band_energy_tmp[i] = L_shl( L_tmp, 1 ); /*Q_band_energy */ } @@ -722,16 +742,24 @@ void hq_lr_enc_fx( exp = 0; move16(); } - L_tmp = Mult_32_16( Ep_tmp_fx[i], tmp1 ); /*Q(15+exp-15 = exp) */ - L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(exp+0-15 = exp-15) */ - L_tmp = Mult_32_16( L_tmp, 16384 ); /*Q(exp-15+13-15 = exp-17) */ - L_tmp = L_shl( L_tmp, sub( 32, exp ) ); /*Q15 */ - tmp = extract_l( L_min( L_tmp, 6554 ) ); /*Q15 */ - L_tmp = Mult_32_16( Ep_vari_fx, tmp1 ); /*Q(15+exp-15 = exp) */ - L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(exp+15-15 = exp) */ - L_tmp = L_shl( L_tmp, sub( 15, exp ) ); /*Q15 */ + L_tmp = Mult_32_16( Ep_tmp_fx[i], tmp1 ); /*Q(15+exp-15 = exp) */ + L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(exp+0-15 = exp-15) */ + L_tmp = Mult_32_16( L_tmp, 16384 ); /*Q(exp-15+13-15 = exp-17) */ + L_tmp = L_shl( L_tmp, sub( 32, exp ) ); /*Q15 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l2( L_min( L_tmp, 6554 ) ); /*Q15 */ +#else + tmp = extract_l( L_min( L_tmp, 6554 ) ); /*Q15 */ +#endif + L_tmp = Mult_32_16( Ep_vari_fx, tmp1 ); /*Q(15+exp-15 = exp) */ + L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(exp+15-15 = exp) */ + L_tmp = L_shl( L_tmp, sub( 15, exp ) ); /*Q15 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l2( L_shr( L_min( L_tmp, 13107 ), 1 ) ); /*Q14 */ +#else tmp = extract_l( L_shr( L_min( L_tmp, 13107 ), 1 ) ); /*Q14 */ - alpha_fx = add( tmp, 16384 ); /*Q14 */ +#endif + alpha_fx = add( tmp, 16384 ); /*Q14 */ } ELSE { @@ -761,11 +789,19 @@ void hq_lr_enc_fx( exp = 0; move16(); } - L_tmp = Mult_32_16( Ep_avrg_fx, tmp ); /*Q(15+exp-15 = exp) */ - L_tmp = L_shl( L_tmp, sub( 14, exp ) ); /*Q14 */ + L_tmp = Mult_32_16( Ep_avrg_fx, tmp ); /*Q(15+exp-15 = exp) */ + L_tmp = L_shl( L_tmp, sub( 14, exp ) ); /*Q14 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l2( L_min( L_max( L_tmp, 16384 ), 20480 ) ); /*Q14 */ +#else tmp = extract_l( L_min( L_max( L_tmp, 16384 ), 20480 ) ); /*Q14 */ - L_tmp = L_mult( alpha_fx, tmp ); /*Q(14+14+1=29) */ - alpha_fx = extract_l( L_shr( L_tmp, 15 ) ); /*Q14 */ +#endif + L_tmp = L_mult( alpha_fx, tmp ); /*Q(14+14+1=29) */ +#ifdef FIX_2493_CHECK_EXTRACT_L + alpha_fx = extract_l2( L_shr( L_tmp, 15 ) ); /*Q14 */ +#else + alpha_fx = extract_l( L_shr( L_tmp, 15 ) ); /*Q14 */ +#endif } ELSE { @@ -786,12 +822,20 @@ void hq_lr_enc_fx( exp = 0; move16(); } - L_tmp = Mult_32_16( Ep_tmp_fx[i], tmp1 ); /*Q(15+exp-15 = exp) */ - L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(exp+0-15 = exp-15) */ - L_tmp = L_shl( L_tmp, sub( 29, exp ) ); /*Q14 */ + L_tmp = Mult_32_16( Ep_tmp_fx[i], tmp1 ); /*Q(15+exp-15 = exp) */ + L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(exp+0-15 = exp-15) */ + L_tmp = L_shl( L_tmp, sub( 29, exp ) ); /*Q14 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l2( L_min( L_max( L_tmp, 13926 ), 16384 ) ); /*Q14 */ +#else tmp = extract_l( L_min( L_max( L_tmp, 13926 ), 16384 ) ); /*Q14 */ - L_tmp = L_mult( alpha_fx, tmp ); /*Q(14+14+1=29) */ - alpha_fx = extract_l( L_shr( L_tmp, 15 ) ); /*Q14 */ +#endif + L_tmp = L_mult( alpha_fx, tmp ); /*Q(14+14+1=29) */ +#ifdef FIX_2493_CHECK_EXTRACT_L + alpha_fx = extract_l2( L_shr( L_tmp, 15 ) ); /*Q14 */ +#else + alpha_fx = extract_l( L_shr( L_tmp, 15 ) ); /*Q14 */ +#endif } } L_tmp = Mult_32_16( L_band_energy_tmp[i], alpha_fx ); /*Q(Q_band_energy+14-15=Q_band_energy-1) */ @@ -850,10 +894,14 @@ void hq_lr_enc_fx( exp = 0; move16(); } - L_tmp = Mult_32_16( Ep_peak_fx, tmp ); /*Q(15+exp-15 = exp) */ - L_tmp = Mult_32_16( L_tmp, lowband ); /*Q(exp+0-15 = exp-15) */ - L_tmp = L_shl( L_tmp, sub( 28, exp ) ); /*Q14 0.5 */ - tmp = extract_l( L_min( L_tmp, 19661 ) ); /*//Q14 */ + L_tmp = Mult_32_16( Ep_peak_fx, tmp ); /*Q(15+exp-15 = exp) */ + L_tmp = Mult_32_16( L_tmp, lowband ); /*Q(exp+0-15 = exp-15) */ + L_tmp = L_shl( L_tmp, sub( 28, exp ) ); /*Q14 0.5 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l2( L_min( L_tmp, 19661 ) ); /*//Q14 */ +#else + tmp = extract_l( L_min( L_tmp, 19661 ) ); /*//Q14 */ +#endif L_tmp = Mult_32_16( L_band_energy_tmp[i], tmp ); /*Q(Q_band_energy+14-15 = Q_band_energy-1) */ L_band_energy_tmp[i] = L_shl( L_tmp, 1 ); /*Q_band_energy */ move32(); @@ -1857,7 +1905,11 @@ static void mdct_spectrum_fine_gain_enc_fx( L_temp = L_shr( L_shr( L_q, 1 ), sub( 29, 16 ) ); /* Q16 */ temp_lo_fx = L_Extract_lc( L_temp, &temp_hi_fx ); Qgt = sub( 14, temp_hi_fx ); +#ifdef FIX_2493_CHECK_EXTRACT_L + gain_table_fx[i] = extract_l2( Pow2( 14, temp_lo_fx ) ); /* Qgt */ +#else gain_table_fx[i] = extract_l( Pow2( 14, temp_lo_fx ) ); /* Qgt */ +#endif move16(); /*q += delta; */ diff --git a/lib_enc/hvq_enc_fx.c b/lib_enc/hvq_enc_fx.c index c570a6e49596ffd27709fba8fba1bae2aeabbacc..6f86a55a1f5bb1bef1794f651747c72847deba81 100644 --- a/lib_enc/hvq_enc_fx.c +++ b/lib_enc/hvq_enc_fx.c @@ -151,7 +151,11 @@ Word16 hvq_enc_fx( tmp16 = mult_r( manNfpe, manNfpe ); /* in Q(14+14+1-16) = Q13 */ tmp16 = mult_r( tmp16, manNfpe ); /* in Q(13+14+1-16) = Q12 */ acc = L_mult( tmp16, HVQ_NFPE_FACTOR_CUBE_FX ); /* in Q(12+6+1) = Q19 */ - expNfpe3 = extract_l( L_mult0( expNfpe, 3 ) ); /* Cube operation */ +#ifdef FIX_2493_CHECK_EXTRACT_L + expNfpe3 = extract_l2( L_mult0( expNfpe, 3 ) ); /* Cube operation */ +#else + expNfpe3 = extract_l( L_mult0( expNfpe, 3 ) ); /* Cube operation */ +#endif /* Number of bits required to adjust to Q15 */ adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ @@ -182,7 +186,11 @@ Word16 hvq_enc_fx( tmp16 = mult_r( man, man ); /* in Q(14+14+1-16) = Q13 */ tmp16 = mult_r( tmp16, man ); /* in Q(13+14+1-16) = Q12 */ acc = L_mult( tmp16, HVQ_LB_NFPE_FACTOR_CUBE_FX ); /* in Q(12+9+1) = Q22 */ - expo3 = extract_l( L_mult0( expo, 3 ) ); /* Cube operation. */ +#ifdef FIX_2493_CHECK_EXTRACT_L + expo3 = extract_l2( L_mult0( expo, 3 ) ); /* Cube operation. */ +#else + expo3 = extract_l( L_mult0( expo, 3 ) ); /* Cube operation. */ +#endif /* Number of bits required to adjust to Q15 */ adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ lb_nfpe = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index 27c3a7f2fc2e4bc34f27d5dc3e3fa9f733b531bd..af37818061b2f03130668d1e1f33e64595f49a0e 100644 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -671,7 +671,11 @@ static Word16 IGF_getCrest_new_fx( x_eff = L_shr( x_eff, sub( 15, temp_e ) ); temp_e = 15; move16(); +#ifdef FIX_2493_CHECK_EXTRACT_L + temp = Sqrt16( extract_l2( x_eff ), &temp_e ); +#else temp = Sqrt16( extract_l( x_eff ), &temp_e ); +#endif test(); IF( x_eff > 0 && x_max > 0 ) @@ -746,7 +750,11 @@ static Word16 IGF_getSFM_new_fx( tmp = BASOP_util_Pow2( L_add( numf, shl_sat( 1, sub( 14, numf_e ) ) ), add( 16, numf_e ), &tmp_e ); sfm = BASOP_Util_Divide3232_Scale( tmp, denom, &sfm_e ); sfm_e = add( sfm_e, sub( tmp_e, denom_e ) ); +#ifdef FIX_2493_CHECK_EXTRACT_L + sfm = shl_sat( extract_l2( L_min( sfm, L_shl_sat( 1, sub( 15, sfm_e ) ) ) ), sfm_e ); +#else sfm = shl_sat( extract_l( L_min( sfm, L_shl_sat( 1, sub( 15, sfm_e ) ) ) ), sfm_e ); +#endif } return sfm; @@ -864,7 +872,11 @@ static void IGF_Whitening( move16(); IF( GE_32( powerSpectrum[sb], 1 ) ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + hPrivateData->logSpec[sb] = extract_l2( L_max( 0, L_shr( L_add( BASOP_Util_Log2( powerSpectrum[sb] ), L_shl( powerSpectrum_e[sb], Q25 ) ), Q25 ) ) ); +#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 ) ) ); +#endif } } } @@ -1043,7 +1055,11 @@ static void IGF_Whitening( { Word32 temp; temp = L_add( L_shl( tmp, sub( tmp_e, 2 ) ), L_add( L_shr( hPrivateData->prevSFM_FIR[p], 3 ), L_shr( hPrivateData->prevSFM_IIR[p], 1 ) ) ); +#ifdef FIX_2493_CHECK_EXTRACT_L + SFM = extract_l2( L_min( 22118 /*2.7*/, temp ) ); /*2Q13*/ +#else SFM = extract_l( L_min( 22118 /*2.7*/, temp ) ); /*2Q13*/ +#endif } IF( EQ_16( element_mode, EVS_MONO ) ) { @@ -1952,7 +1968,11 @@ static void IGF_CalculateEnvelope_fx( { IF( LT_32( 1, pPowerSpectrum_fx[sb] ) ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + hPrivateData->logSpec[sb] = s_max( 0, extract_l2( W_extract_l2( W_shr( W_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), W_shl( e_ps[sb], Q25 ) ), Q25 ) ) ) ); +#else hPrivateData->logSpec[sb] = s_max( 0, extract_l( W_extract_l( W_shr( W_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), W_shl( e_ps[sb], Q25 ) ), Q25 ) ) ) ); +#endif move16(); } ELSE @@ -2242,7 +2262,11 @@ static void IGF_CalculateEnvelope_fx( } ELSE { +#ifdef FIX_2493_CHECK_EXTRACT_L + y = imult1616( 20, extract_l2( L_shr( Mult_32_16( ( L_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), L_shl( e_ps[sb], Q25 ) ) ), INV_Log2_10_Q15 ), Q25 ) ) ); /*Q0*/ +#else y = imult1616( 20, extract_l( L_shr( Mult_32_16( ( L_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), L_shl( e_ps[sb], Q25 ) ) ), INV_Log2_10_Q15 ), Q25 ) ) ); /*Q0*/ +#endif } mean_y_fx_tmp = L_mac0( mean_y_fx_tmp, y, 1 ); /*Q0*/ mean_xy_fx = L_add( mean_xy_fx, L_mult0( y, x ) ); /*Q0*/ @@ -2296,7 +2320,11 @@ static void IGF_CalculateEnvelope_fx( { // alpha = min( 320.f / (float) swb_offset[sfb + 1], 1.25f ); temp = BASOP_Util_Divide1616_Scale( 320, swb_offset[sfb + 1], &alpha_e ); +#ifdef FIX_2493_CHECK_EXTRACT_L + alpha = extract_l2( L_min( temp, L_shl( 20480 /*1.25 Q14*/, sub( 1, alpha_e ) ) ) ); // alpha_e +#else alpha = extract_l( L_min( temp, L_shl( 20480 /*1.25 Q14*/, sub( 1, alpha_e ) ) ) ); // alpha_e +#endif // currDampingFactor = expf( 1.25f * alpha * logf( hPrivateData->SFM_tb[sfb] / hPrivateData->SFM_sb[sfb] ) ); temp = BASOP_Util_Divide1616_Scale( hPrivateData->SFM_tb_fx[sfb], hPrivateData->SFM_sb_fx[sfb], &tmp_e ); // tmp_e @@ -2320,7 +2348,11 @@ static void IGF_CalculateEnvelope_fx( { // currDampingFactor += 0.03f * ( ( 10 + adap ) - tonalToNoise ); Word32 temp2 = BASOP_Util_Add_Mant32Exp( L_add( L_shl( 10, sub( 15, adap_e ) ) /*exp:adap_e*/, adap ), add( adap_e, 16 ), L_negate( tonalToNoise ), tonalToNoise_e, &tmp_e ); // tmp_e - currDampingFactor_e = BASOP_Util_Add_MantExp( currDampingFactor, currDampingFactor_e, extract_l( Mult_32_32( 983 /*0.03f Q15*/, temp2 ) ), tmp_e, &currDampingFactor ); // currDampingFactor_e +#ifdef FIX_2493_CHECK_EXTRACT_L + currDampingFactor_e = BASOP_Util_Add_MantExp( currDampingFactor, currDampingFactor_e, extract_l2( Mult_32_32( 983 /*0.03f Q15*/, temp2 ) ), tmp_e, &currDampingFactor ); // currDampingFactor_e +#else + currDampingFactor_e = BASOP_Util_Add_MantExp( currDampingFactor, currDampingFactor_e, extract_l( Mult_32_32( 983 /*0.03f Q15*/, temp2 ) ), tmp_e, &currDampingFactor ); // currDampingFactor_e +#endif } } @@ -2356,7 +2388,11 @@ static void IGF_CalculateEnvelope_fx( dampingFactor_e = BASOP_Util_Add_MantExp( currDampingFactor, currDampingFactor_e, hPrivateData->prevDampingFactor_IIR_fx[sfb], hPrivateData->prevDampingFactor_IIR_e[sfb], &dampingFactor ); // dampingFactor_e dampingFactor = shr( dampingFactor, 1 ); +#ifdef FIX_2493_CHECK_EXTRACT_L + gain = Mult_32_16( gain, shl_sat( extract_l2( L_min( L_add( dampingFactor, Mult_32_16( L_shl( hPrivateData->dampingFactorSmoothing[sfb], sub( 15, dampingFactor_e ) ) /*Q:15-dampingFactor_e*/, 3277 /*0.1f Q15*/ ) /*Q:15-dampingFactor_e*/ ), shl_sat( 1, sub( 15, dampingFactor_e ) ) ) ), dampingFactor_e ) /*Q15*/ ); +#else gain = Mult_32_16( gain, shl_sat( extract_l( L_min( L_add( dampingFactor, Mult_32_16( L_shl( hPrivateData->dampingFactorSmoothing[sfb], sub( 15, dampingFactor_e ) ) /*Q:15-dampingFactor_e*/, 3277 /*0.1f Q15*/ ) /*Q:15-dampingFactor_e*/ ), shl_sat( 1, sub( 15, dampingFactor_e ) ) ) ), dampingFactor_e ) /*Q15*/ ); +#endif hPrivateData->prevDampingFactor_IIR_fx[sfb] = dampingFactor; move16(); @@ -2512,7 +2548,11 @@ static void IGF_CalculateEnvelope_fx( gain = L_max( gain, 0 ); gain_e = 8; /* stores exponent for gain_fx*/ move16(); +#ifdef FIX_2493_CHECK_EXTRACT_L + hPrivateData->igfScfQuantized[sfb] = extract_l2( L_shr( gain, Q23 ) ); /*Q0*/ +#else hPrivateData->igfScfQuantized[sfb] = extract_l( L_shr( gain, Q23 ) ); /*Q0*/ +#endif move16(); } ELSE @@ -2890,7 +2930,11 @@ static void IGF_CalculateStereoEnvelope_fx( } ELSE { +#ifdef FIX_2493_CHECK_EXTRACT_L + y = imult1616( 20, extract_l2( L_shr( Mult_32_16( ( L_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), L_shl( pPowerSpectrum_e[sb], Q25 ) ) ), INV_Log2_10_Q15 ), 25 ) ) ); /*Q0*/ +#else y = imult1616( 20, extract_l( L_shr( Mult_32_16( ( L_add( BASOP_Util_Log2( pPowerSpectrum_fx[sb] ), L_shl( pPowerSpectrum_e[sb], Q25 ) ) ), INV_Log2_10_Q15 ), 25 ) ) ); /*Q0*/ +#endif } mean_y_fx = add( mean_y_fx, y ); /*Q0*/ mean_xy_fx = L_add( mean_xy_fx, L_mult0( y, x ) ); /*Q0*/ @@ -2944,7 +2988,11 @@ static void IGF_CalculateStereoEnvelope_fx( // alpha = min( 320.f / (float) swb_offset[sfb + 1], 1.25f ); temp = BASOP_Util_Divide1616_Scale( 320, swb_offset[sfb + 1], &alpha_e ); +#ifdef FIX_2493_CHECK_EXTRACT_L + alpha_fx = extract_l2( L_min( temp, L_shl( 20480 /*1.25 Q14*/, sub( 1, alpha_e ) ) ) ); /* exponent is alpha_e*/ +#else alpha_fx = extract_l( L_min( temp, L_shl( 20480 /*1.25 Q14*/, sub( 1, alpha_e ) ) ) ); /* exponent is alpha_e*/ +#endif temp = BASOP_Util_Divide1616_Scale( hPrivateData->SFM_tb_fx[sfb], hPrivateData->SFM_sb_fx[sfb], &tmp_e ); tmp_e = add( tmp_e, sub( hPrivateData->sfb_tb_e[sfb], hPrivateData->sfb_sb_e[sfb] ) ); /* stores resultant exponent for temp */ @@ -2991,7 +3039,11 @@ static void IGF_CalculateStereoEnvelope_fx( { // currDampingFactor += 0.1f * ( ( 10 + adap ) - tonalToNoise ); Word32 temp2 = BASOP_Util_Add_Mant32Exp( L_add( L_shl( 10, sub( 15, adap_e ) ) /*exp:adap_e*/, adap ), add( adap_e, 16 ), L_negate( tonalToNoise ), tonalToNoise_e, &tmp_e ); /* resultant exp is tmp_e*/ +#ifdef FIX_2493_CHECK_EXTRACT_L + currDampingFactor_e = BASOP_Util_Add_MantExp( currDampingFactor_fx, currDampingFactor_e, extract_l2( Mult_32_16( temp2, 3277 /*0.1f Q15*/ ) ), tmp_e, &currDampingFactor_fx ); /*stores resultant exp for currDampingFactor_fx*/ +#else currDampingFactor_e = BASOP_Util_Add_MantExp( currDampingFactor_fx, currDampingFactor_e, extract_l( Mult_32_16( temp2, 3277 /*0.1f Q15*/ ) ), tmp_e, &currDampingFactor_fx ); /*stores resultant exp for currDampingFactor_fx*/ +#endif } } @@ -3013,7 +3065,11 @@ static void IGF_CalculateStereoEnvelope_fx( dampingFactor_e = 0; move16(); } +#ifdef FIX_2493_CHECK_EXTRACT_L + gain_fx = Mult_32_16( gain_fx, shl_sat( extract_l2( L_min( L_add( dampingFactor_fx, Mult_32_16( L_shl( hPrivateData->dampingFactorSmoothing[sfb], sub( 15, dampingFactor_e ) ) /*Q:15-dampingFactor_e*/, 3277 /*0.1f Q15*/ ) /*Q:15-dampingFactor_e*/ ), shl_sat( 1, sub( 15, dampingFactor_e ) ) ) ), dampingFactor_e ) /*Q15*/ ); +#else gain_fx = Mult_32_16( gain_fx, shl_sat( extract_l( L_min( L_add( dampingFactor_fx, Mult_32_16( L_shl( hPrivateData->dampingFactorSmoothing[sfb], sub( 15, dampingFactor_e ) ) /*Q:15-dampingFactor_e*/, 3277 /*0.1f Q15*/ ) /*Q:15-dampingFactor_e*/ ), shl_sat( 1, sub( 15, dampingFactor_e ) ) ) ), dampingFactor_e ) /*Q15*/ ); +#endif hPrivateData->prevDampingFactor_IIR_fx[sfb] = dampingFactor_fx; hPrivateData->prevDampingFactor_IIR_e[sfb] = dampingFactor_e; @@ -3452,7 +3508,11 @@ void IGFEncApplyStereo_fx( } FOR( ch = 0; ch < CPE_CHANNELS; ch++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + last_core_acelp = extract_l2( EQ_16( sts[ch]->last_core, ACELP_CORE ) ); +#else last_core_acelp = extract_l( EQ_16( sts[ch]->last_core, ACELP_CORE ) ); +#endif IGF_UpdateInfo( hIGFEnc[ch], igfGridIdx ); IGF_CalculateStereoEnvelope_fx( hIGFEnc[ch], sts[ch]->hTcxEnc->spectrum_fx[frameno], sts[ch]->hTcxEnc->spectrum_e[frameno], inv_spectrum_fx[ch][frameno], diff --git a/lib_enc/ivas_agc_enc_fx.c b/lib_enc/ivas_agc_enc_fx.c index 4d003b56855c5ac3eaed71baea7dd6ac78e637fc..899ac9efef3f52316af7527471c0f98348373e7c 100644 --- a/lib_enc/ivas_agc_enc_fx.c +++ b/lib_enc/ivas_agc_enc_fx.c @@ -64,7 +64,11 @@ static Word16 ceil_fx_loc( { ret_32 = L_add( inp, sub( shl( 1, Q ), 1 ) ); //(inp+(pow(2,q)-1))/pow(2,q)// ret_32 = L_shr( ret_32, Q ); +#ifdef FIX_2493_CHECK_EXTRACT_L + return extract_l2( ret_32 ); +#else return extract_l( ret_32 ); +#endif } } ELSE diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index 0cb69bfdec2075472ef8dee0efc065ccaf1b6b78..488dde989bad7585446c9013760e233fe320cd35 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -1729,7 +1729,11 @@ static void calculate_energy_buffer_ivas_fx( FOR( i = 0; i < no_channels; i++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + stop = extract_l2( L_shr( L_add( Mpy_32_16_1( chan_width_bins_fx, add( i, 1 ) ), 1 ), 1 ) ); /* Q0 */ +#else stop = extract_l( L_shr( L_add( Mpy_32_16_1( chan_width_bins_fx, add( i, 1 ) ), 1 ), 1 ) ); /* Q0 */ +#endif FOR( j = start; j < stop; j++ ) { *p_nrg_DMX_fx = W_add( *p_nrg_DMX_fx, W_shr( W_mult_32_32( pDFT_DMX_fx[2 * j], pDFT_DMX_fx[2 * j] ), guard_bits ) ); /* 2 * q_DFT_DMX_fx + 1 - guard_bits */ diff --git a/lib_enc/ivas_ism_param_enc_fx.c b/lib_enc/ivas_ism_param_enc_fx.c index 5ec986ec75f9f28fdc8acac08f44b3129e00f7fd..4c7ae6258084df76104c56aecfb5ffbc5567c48d 100644 --- a/lib_enc/ivas_ism_param_enc_fx.c +++ b/lib_enc/ivas_ism_param_enc_fx.c @@ -292,7 +292,11 @@ void ivas_param_ism_stereo_dmx_fx( { tmp = L_add( tmp, 2 * EVS_PI_FX ); } +#ifdef FIX_2493_CHECK_EXTRACT_L + cardioid_left[i] = mac_r( L_mult( alpha, 16384 ), sub( ONE_IN_Q15 - 1, alpha ), getCosWord16( extract_l2( tmp ) ) ); // Q14 +#else cardioid_left[i] = mac_r( L_mult( alpha, 16384 ), sub( ONE_IN_Q15 - 1, alpha ), getCosWord16( extract_l( tmp ) ) ); // Q14 +#endif move16(); IF( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame > 0 ) @@ -311,13 +315,21 @@ void ivas_param_ism_stereo_dmx_fx( { tmp = data[i][j]; move32(); +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = W_extract_l2( W_shr( W_mult_32_32( tmp, L_add( last_cardioid_left, L_shr( Mpy_32_32( L_shl( j, 22 ), grad_32 ), 7 ) ) ), 15 ) ); /* Qx DMX Left */ +#else tmp = W_extract_l( W_shr( W_mult_32_32( tmp, L_add( last_cardioid_left, L_shr( Mpy_32_32( L_shl( j, 22 ), grad_32 ), 7 ) ) ), 15 ) ); /* Qx DMX Left */ - stereo_dmx[0][j] = L_add( stereo_dmx[0][j], tmp ); /* Qx DMX Left */ +#endif + stereo_dmx[0][j] = L_add( stereo_dmx[0][j], tmp ); /* Qx DMX Left */ move32(); tmp = data[i][j]; move32(); +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = W_extract_l2( W_shr( W_mult_32_32( tmp, L_add( last_cardioid_right, L_shr( L_negate( Mpy_32_32( L_shl( j, 22 ), grad_32 ) ), 7 ) ) ), 15 ) ); /* Qx DMX Right */ +#else tmp = W_extract_l( W_shr( W_mult_32_32( tmp, L_add( last_cardioid_right, L_shr( L_negate( Mpy_32_32( L_shl( j, 22 ), grad_32 ) ), 7 ) ) ), 15 ) ); /* Qx DMX Right */ - stereo_dmx[1][j] = L_add( stereo_dmx[1][j], tmp ); /* Qx DMX Right */ +#endif + stereo_dmx[1][j] = L_add( stereo_dmx[1][j], tmp ); /* Qx DMX Right */ move32(); ene_data = W_add( ene_data, W_mult_32_32( data[i][j], data[i][j] ) ); /* 2 * Qx + 1 energy of all objects combined */ } @@ -325,13 +337,21 @@ void ivas_param_ism_stereo_dmx_fx( { tmp = data[i][j]; move32(); +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = W_extract_l2( W_shr( W_mult_32_16( tmp, cardioid_left[i] ), 15 ) ); /* Qx DMX Left */ +#else tmp = W_extract_l( W_shr( W_mult_32_16( tmp, cardioid_left[i] ), 15 ) ); /* Qx DMX Left */ - stereo_dmx[0][j] = L_add( stereo_dmx[0][j], tmp ); /* Qx DMX Left */ +#endif + stereo_dmx[0][j] = L_add( stereo_dmx[0][j], tmp ); /* Qx DMX Left */ move32(); tmp = data[i][j]; move32(); +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = W_extract_l2( W_shr( W_mult_32_16( tmp, cardioid_right[i] ), 15 ) ); /* Qx DMX Right */ +#else tmp = W_extract_l( W_shr( W_mult_32_16( tmp, cardioid_right[i] ), 15 ) ); /* Qx DMX Right */ - stereo_dmx[1][j] = L_add( stereo_dmx[1][j], tmp ); /* Qx DMX Right */ +#endif + stereo_dmx[1][j] = L_add( stereo_dmx[1][j], tmp ); /* Qx DMX Right */ move32(); ene_data = W_add( ene_data, W_mult_32_32( data[i][j], data[i][j] ) ); /* 2 * Qx + 1 energy of all objects combined */ } @@ -346,13 +366,21 @@ void ivas_param_ism_stereo_dmx_fx( { tmp = data[i][j]; move32(); +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = W_extract_l2( W_shr( W_mult_32_16( tmp, cardioid_left[i] ), 15 ) ); /* Qx DMX Left */ +#else tmp = W_extract_l( W_shr( W_mult_32_16( tmp, cardioid_left[i] ), 15 ) ); /* Qx DMX Left */ - stereo_dmx[0][j] = L_add( stereo_dmx[0][j], tmp ); /* Qx DMX Left */ +#endif + stereo_dmx[0][j] = L_add( stereo_dmx[0][j], tmp ); /* Qx DMX Left */ move32(); tmp = data[i][j]; move32(); +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = W_extract_l2( W_shr( W_mult_32_16( tmp, cardioid_right[i] ), 15 ) ); /* Qx DMX Right */ +#else tmp = W_extract_l( W_shr( W_mult_32_16( tmp, cardioid_right[i] ), 15 ) ); /* Qx DMX Right */ - stereo_dmx[1][j] = L_add( stereo_dmx[1][j], tmp ); /* Qx DMX Right */ +#endif + stereo_dmx[1][j] = L_add( stereo_dmx[1][j], tmp ); /* Qx DMX Right */ move32(); ene_data = W_add( ene_data, W_mult_32_32( data[i][j], data[i][j] ) ); /* 2 * Qx + 1 energy of all objects combined */ } @@ -379,25 +407,43 @@ void ivas_param_ism_stereo_dmx_fx( { dmx_gain_e = BASOP_Util_Add_MantExp( mult( 24576 /* 0.75f */, dmx_gain ), dmx_gain_e, mult( 8192 /* 0.25f */, last_dmx_gain ), last_dmx_gain_e, &dmx_gain ); /* 10ms ramp */ - tmp = L_shl( last_dmx_gain, last_dmx_gain_e ); // Q15 + tmp = L_shl( last_dmx_gain, last_dmx_gain_e ); // Q15 +#ifdef FIX_2493_CHECK_EXTRACT_L + grad = extract_l2( Mpy_32_16_r( L_sub( L_shl( dmx_gain, dmx_gain_e ), tmp ), shl( one_by_input_frame, 1 ) /* 2.0f / (float) input_frame*/ ) ); /* Q15 */ /* slope between two consecutive gains, 480 samples length */ +#else grad = extract_l( Mpy_32_16_r( L_sub( L_shl( dmx_gain, dmx_gain_e ), tmp ), shl( one_by_input_frame, 1 ) /* 2.0f / (float) input_frame*/ ) ); /* Q15 */ /* slope between two consecutive gains, 480 samples length */ +#endif tmp_1 = 15 + 1; move16(); FOR( i = 0; i < ( input_frame >> 1 ); i++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + stereo_dmx[0][i] = W_extract_l2( W_shr( W_mult_32_32( stereo_dmx[0][i], L_add( tmp, mult0( i, grad ) ) ), tmp_1 ) ); // Qx + move32(); + stereo_dmx[1][i] = W_extract_l2( W_shr( W_mult_32_32( stereo_dmx[1][i], L_add( tmp, mult0( i, grad ) ) ), tmp_1 ) ); // Qx + move32(); +#else stereo_dmx[0][i] = W_extract_l( W_shr( W_mult_32_32( stereo_dmx[0][i], L_add( tmp, mult0( i, grad ) ) ), tmp_1 ) ); // Qx move32(); stereo_dmx[1][i] = W_extract_l( W_shr( W_mult_32_32( stereo_dmx[1][i], L_add( tmp, mult0( i, grad ) ) ), tmp_1 ) ); // Qx move32(); +#endif } tmp_1 = add( sub( 15, dmx_gain_e ), 1 ); FOR( ; i < input_frame; i++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + stereo_dmx[0][i] = W_extract_l2( W_shr( W_mult_32_16( stereo_dmx[0][i], dmx_gain ), tmp_1 ) ); // Qx + move32(); + stereo_dmx[1][i] = W_extract_l2( W_shr( W_mult_32_16( stereo_dmx[1][i], dmx_gain ), tmp_1 ) ); // Qx + move32(); +#else stereo_dmx[0][i] = W_extract_l( W_shr( W_mult_32_16( stereo_dmx[0][i], dmx_gain ), tmp_1 ) ); // Qx move32(); stereo_dmx[1][i] = W_extract_l( W_shr( W_mult_32_16( stereo_dmx[1][i], dmx_gain ), tmp_1 ) ); // Qx move32(); +#endif } } ELSE @@ -405,10 +451,17 @@ void ivas_param_ism_stereo_dmx_fx( tmp_1 = add( sub( 15, dmx_gain_e ), 1 ); FOR( j = 0; j < input_frame; j++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + stereo_dmx[0][j] = W_extract_l2( W_shr( W_mult_32_16( stereo_dmx[0][j], dmx_gain ), tmp_1 ) ); // Qx + move32(); + stereo_dmx[1][j] = W_extract_l2( W_shr( W_mult_32_16( stereo_dmx[1][j], dmx_gain ), tmp_1 ) ); // Qx + move32(); +#else stereo_dmx[0][j] = W_extract_l( W_shr( W_mult_32_16( stereo_dmx[0][j], dmx_gain ), tmp_1 ) ); // Qx move32(); stereo_dmx[1][j] = W_extract_l( W_shr( W_mult_32_16( stereo_dmx[1][j], dmx_gain ), tmp_1 ) ); // Qx move32(); +#endif } } st_ivas->hParamIsm->last_dmx_gain_fx = dmx_gain; diff --git a/lib_enc/ivas_lfe_enc_fx.c b/lib_enc/ivas_lfe_enc_fx.c index 0aeb6107780f87aef0fd0f66b260b6d051bcad58..8524d31d14c2936cda3c2be15f5d3e7b1257c921 100644 --- a/lib_enc/ivas_lfe_enc_fx.c +++ b/lib_enc/ivas_lfe_enc_fx.c @@ -197,7 +197,11 @@ static void ivas_lfe_enc_quant_fx( q_lfe_abs_sum = sub( q_lfe_abs_sum, q_tmp ); } +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( max_value, W_extract_l2( lfe_abs_sum ), &q_tmp ) ); +#else tmp = L_deposit_h( BASOP_Util_Divide3232_Scale( max_value, W_extract_l( lfe_abs_sum ), &q_tmp ) ); +#endif // tmp = L_shl( tmp, sub( q_lfe_abs_sum, sub( 15, q_tmp ) ) ); /* Q0 (max_value / lfe_abs_sum) */ q_tmp = sub( Q16, sub( q_lfe_abs_sum, sub( 15, q_tmp ) ) ); @@ -208,7 +212,11 @@ static void ivas_lfe_enc_quant_fx( /* IVAS_LFE_SHIFTS_PER_DOUBLE * log2_f(max_value / lfe_abs_sum) */ tmp = Mpy_32_16_1( tmp, IVAS_LFE_SHIFTS_PER_DOUBLE ); /* 25-15 -> Q10 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + shift = extract_l2( L_shr( tmp, 10 ) ); /* Q0 */ +#else shift = extract_l( L_shr( tmp, 10 ) ); /* Q0 */ +#endif } shift = s_max( imult1616( min_shift, IVAS_LFE_SHIFTS_PER_DOUBLE ), s_min( max_shift, shift ) ); @@ -240,12 +248,20 @@ static void ivas_lfe_enc_quant_fx( IF( tmp < 0 ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + values[i] = add( extract_l2( L_shr( L_sub( tmp, L_shl( 1 /*0.5 Q1-> 1*/, sub( q_tmp, 1 ) ) ), q_tmp ) ), 1 ); +#else values[i] = add( extract_l( L_shr( L_sub( tmp, L_shl( 1 /*0.5 Q1-> 1*/, sub( q_tmp, 1 ) ) ), q_tmp ) ), 1 ); +#endif move16(); } ELSE { +#ifdef FIX_2493_CHECK_EXTRACT_L + values[i] = extract_l2( L_shr( L_add( tmp, L_shl( 1 /*0.5 Q1-> 1*/, sub( q_tmp, 1 ) ) ), q_tmp ) ); +#else values[i] = extract_l( L_shr( L_add( tmp, L_shl( 1 /*0.5 Q1-> 1*/, sub( q_tmp, 1 ) ) ), q_tmp ) ); +#endif move16(); } diff --git a/lib_enc/ivas_mdct_core_enc_fx.c b/lib_enc/ivas_mdct_core_enc_fx.c index bae3e6f55affe3b42b01e91c4543630fa4482801..9b1c887b860b58f0480bd74766f25d53996c04f1 100644 --- a/lib_enc/ivas_mdct_core_enc_fx.c +++ b/lib_enc/ivas_mdct_core_enc_fx.c @@ -213,12 +213,21 @@ static Word16 kernel_switch_detect_fx( q_shift = s_min( q_shift, W_norm( W_sumR1 ) ); q_shift = s_min( q_shift, W_norm( W_sumI0 ) ); q_shift = s_min( q_shift, W_norm( W_sumI1 ) ); +#ifdef FIX_2493_CHECK_EXTRACT_L + cov00 = W_extract_l2( W_shl( W_cov00, sub( q_shift, 32 ) ) ); // 2 * q_in + q_shift - 32 + cov90 = W_extract_l2( W_shl( W_cov90, sub( q_shift, 32 ) ) ); // 2 * q_in + q_shift - 32 + sumR0 = W_extract_l2( W_shl( W_sumR0, sub( q_shift, 32 ) ) ); // 2 * q_in + q_shift - 32 + sumR1 = W_extract_l2( W_shl( W_sumR1, sub( q_shift, 32 ) ) ); // 2 * q_in + q_shift - 32 + sumI0 = W_extract_l2( W_shl( W_sumI0, sub( q_shift, 32 ) ) ); // 2 * q_in + q_shift - 32 + sumI1 = W_extract_l2( W_shl( W_sumI1, sub( q_shift, 32 ) ) ); // 2 * q_in + q_shift - 32 +#else cov00 = W_extract_l( W_shl( W_cov00, sub( q_shift, 32 ) ) ); // 2 * q_in + q_shift - 32 cov90 = W_extract_l( W_shl( W_cov90, sub( q_shift, 32 ) ) ); // 2 * q_in + q_shift - 32 sumR0 = W_extract_l( W_shl( W_sumR0, sub( q_shift, 32 ) ) ); // 2 * q_in + q_shift - 32 sumR1 = W_extract_l( W_shl( W_sumR1, sub( q_shift, 32 ) ) ); // 2 * q_in + q_shift - 32 sumI0 = W_extract_l( W_shl( W_sumI0, sub( q_shift, 32 ) ) ); // 2 * q_in + q_shift - 32 sumI1 = W_extract_l( W_shl( W_sumI1, sub( q_shift, 32 ) ) ); // 2 * q_in + q_shift - 32 +#endif q_com = add( shl( q_in, 1 ), sub( q_shift, 32 ) ); // cov00 /= ( sqrtf( sumR0 * sumR1 ) + sqrtf( sumI0 * sumI1 ) + 1.f ); @@ -427,11 +436,15 @@ static void kernel_switch_update_transforms_fx( Word32 factor; n = extract_l( Mpy_32_32( s, 603979776 /* N_ZERO_MDCT_NS / FRAME_SIZE_NS in Q31 */ ) ); - Scale_sig( &tcxTimeSignal[n - s], add( sub( shl( s, 1 ), n ), 1 ), sub( -Q1, q_speech ) ); // q_speech -> Q-1 + Scale_sig( &tcxTimeSignal[n - s], add( sub( shl( s, 1 ), n ), 1 ), sub( -Q1, q_speech ) ); // q_speech -> Q-1 +#ifdef FIX_2493_CHECK_EXTRACT_L + wtda_ext_fx( tcxTimeSignal, windowedTimeSignal_16, extract_l2( windowedTimeSignal[0] ), extract_l2( windowedTimeSignal[1] ), s, kernelType ); // Q-2 +#else wtda_ext_fx( tcxTimeSignal, windowedTimeSignal_16, extract_l( windowedTimeSignal[0] ), extract_l( windowedTimeSignal[1] ), s, kernelType ); // Q-2 - Scale_sig( &tcxTimeSignal[n - s], add( sub( shl( s, 1 ), n ), 1 ), sub( q_speech, -Q1 ) ); // Q-1 -> q_speech - Copy_Scale_sig_16_32_no_sat( windowedTimeSignal_16 /* Q(-2) */, windowedTimeSignal, s, Q16 ); // Q14 - scale_sig32( windowedTimeSignal, s, -Q8 /* guard bits */ ); // Q6 +#endif + Scale_sig( &tcxTimeSignal[n - s], add( sub( shl( s, 1 ), n ), 1 ), sub( q_speech, -Q1 ) ); // Q-1 -> q_speech + Copy_Scale_sig_16_32_no_sat( windowedTimeSignal_16 /* Q(-2) */, windowedTimeSignal, s, Q16 ); // Q14 + scale_sig32( windowedTimeSignal, s, -Q8 /* guard bits */ ); // Q6 edxt_fx( windowedTimeSignal, sigR, s, kernelType, FALSE ); tmp = BASOP_Util_Divide1616_Scale( NORM_MDCT_FACTOR, s, &exp_tmp ); @@ -455,7 +468,11 @@ static void kernel_switch_update_transforms_fx( move16(); move16(); +#ifdef FIX_2493_CHECK_EXTRACT_L + tcx_get_windows( hTcxCfg, extract_l2( windowedTimeSignal[0] ), extract_l2( windowedTimeSignal[1] ), &leftOverlap, &left_win, &rightOverlap, &right_win, 1 ); +#else tcx_get_windows( hTcxCfg, extract_l( windowedTimeSignal[0] ), extract_l( windowedTimeSignal[1] ), &leftOverlap, &left_win, &rightOverlap, &right_win, 1 ); +#endif test(); test(); test(); @@ -1297,7 +1314,11 @@ void ivas_mdct_core_whitening_enc_fx( move32(); move32(); +#ifdef FIX_2493_CHECK_EXTRACT_L + sts[0]->hTcxEnc->tcxltp_norm_corr_past = sts[1]->hTcxEnc->tcxltp_norm_corr_past = extract_l2( L_shr( L_add( sts[0]->hTcxEnc->tcxltp_norm_corr_past, sts[1]->hTcxEnc->tcxltp_norm_corr_past ), 1 ) ); // Q15 +#else sts[0]->hTcxEnc->tcxltp_norm_corr_past = sts[1]->hTcxEnc->tcxltp_norm_corr_past = extract_l( L_shr( L_add( sts[0]->hTcxEnc->tcxltp_norm_corr_past, sts[1]->hTcxEnc->tcxltp_norm_corr_past ), 1 ) ); // Q15 +#endif move16(); move16(); @@ -1424,7 +1445,11 @@ void ivas_mdct_core_whitening_enc_fx( move16(); } +#ifdef FIX_2493_CHECK_EXTRACT_L + nrg_fx = extract_l2( L_shr( L_add( L_add( L_add( hTcxEnc0->tcxltp_norm_corr_past, hTcxEnc0->tcxltp_norm_corr_mem ), hTcxEnc1->tcxltp_norm_corr_past ), hTcxEnc1->tcxltp_norm_corr_mem ), 2 ) ); /* normalized correlation of the current frame */ +#else nrg_fx = extract_l( L_shr( L_add( L_add( L_add( hTcxEnc0->tcxltp_norm_corr_past, hTcxEnc0->tcxltp_norm_corr_mem ), hTcxEnc1->tcxltp_norm_corr_past ), hTcxEnc1->tcxltp_norm_corr_mem ), 2 ) ); /* normalized correlation of the current frame */ +#endif L_subframe = s_max( 512, L_subframe ); diff --git a/lib_enc/ivas_qmetadata_enc_fx.c b/lib_enc/ivas_qmetadata_enc_fx.c index f466654409f3de0c4f8d4d5b250d29314be839cb..f22f548ec88eae2a0490b463e5df43103f831afc 100644 --- a/lib_enc/ivas_qmetadata_enc_fx.c +++ b/lib_enc/ivas_qmetadata_enc_fx.c @@ -3226,8 +3226,12 @@ static Word16 truncGR0_fx( move16(); bits = add( bits, ivas_qmetadata_encode_extended_gr_length_fx( data_idx[i], 8, 0 ) ); // diff[i] = -st[i] - ct[i] * cosf( PI_OVER_180 * ( data[i] - data_hat[i] ) ); /*(data[i] - data_hat[i])*(data[i] - data_hat[i]);*/ +#ifdef FIX_2493_CHECK_EXTRACT_L + L_temp = L_deposit_h( getCosWord16R2( extract_l2( L_shr( Mpy_32_16_1( L_sub( data_fx[i], data_hat_fx[i] ), 91 ), 7 ) ) ) ); // Q31 +#else L_temp = L_deposit_h( getCosWord16R2( extract_l( L_shr( Mpy_32_16_1( L_sub( data_fx[i], data_hat_fx[i] ), 91 ), 7 ) ) ) ); // Q31 - diff_fx[i] = L_negate( L_add( L_shr( st_fx[i], 1 ), L_shr( Mpy_32_32( ct_fx[i], L_temp ), 1 ) ) ); // Q30 +#endif + diff_fx[i] = L_negate( L_add( L_shr( st_fx[i], 1 ), L_shr( Mpy_32_32( ct_fx[i], L_temp ), 1 ) ) ); // Q30 move32(); } @@ -3251,7 +3255,11 @@ static Word16 truncGR0_fx( move16(); bits = add( bits, ivas_qmetadata_encode_extended_gr_length_fx( data_idx[indx[i]], 8, 0 ) ); // diff[indx[i]] = -st[i] - ct[i] * cosf( PI_OVER_180 * ( data[indx[i]] - data_hat[indx[i]] ) ); +#ifdef FIX_2493_CHECK_EXTRACT_L + L_temp = L_deposit_h( getCosWord16R2( extract_l2( L_shr( Mpy_32_16_1( L_sub( data_fx[indx[i]], data_hat_fx[indx[i]] ), 91 ), 7 ) ) ) ); // Q31 +#else L_temp = L_deposit_h( getCosWord16R2( extract_l( L_shr( Mpy_32_16_1( L_sub( data_fx[indx[i]], data_hat_fx[indx[i]] ), 91 ), 7 ) ) ) ); // Q31 +#endif diff_fx[indx[i]] = L_negate( L_add( L_shr( st_fx[i], 1 ), L_shr( Mpy_32_32( ct_fx[i], L_temp ), 1 ) ) ); // Q30 move32(); @@ -3292,7 +3300,11 @@ static Word16 truncGR0_fx( bits = add( bits, ivas_qmetadata_encode_extended_gr_length_fx( data_idx[indx[i]], 8, 0 ) ); // diff[indx[i]] = -st[i] - ct[i] * cosf( PI_OVER_180 * ( data[indx[i]] - data_hat[indx[i]] ) ); +#ifdef FIX_2493_CHECK_EXTRACT_L + L_temp = L_deposit_h( getCosWord16R2( extract_l2( L_shr( Mpy_32_16_1( L_sub( data_fx[indx[i]], data_hat_fx[indx[i]] ), 91 ), 7 ) ) ) ); // Q31 +#else L_temp = L_deposit_h( getCosWord16R2( extract_l( L_shr( Mpy_32_16_1( L_sub( data_fx[indx[i]], data_hat_fx[indx[i]] ), 91 ), 7 ) ) ) ); // Q31 +#endif diff_fx[indx[i]] = L_negate( L_add( L_shr( st_fx[i], 1 ), L_shr( Mpy_32_32( ct_fx[i], L_temp ), 1 ) ) ); // Q30 move32(); @@ -3385,8 +3397,12 @@ static Word16 truncGR0_chan_fx( move16(); bits = add( bits, ivas_qmetadata_encode_extended_gr_length_fx( data_idx[i], 9, 0 ) ); // diff[i] = -st[i] - ct[i] * cosf( ( data[i] - data_hat[i] ) * PI_OVER_180 ); +#ifdef FIX_2493_CHECK_EXTRACT_L + L_temp = L_deposit_h( getCosWord16R2( extract_l2( L_shr( Mpy_32_16_1( L_sub( data_fx[i], data_hat_fx[i] ), 91 ), 7 ) ) ) ); // Q31 +#else L_temp = L_deposit_h( getCosWord16R2( extract_l( L_shr( Mpy_32_16_1( L_sub( data_fx[i], data_hat_fx[i] ), 91 ), 7 ) ) ) ); // Q31 - diff_fx[i] = L_negate( L_add( L_shr( st_fx[i], 1 ), L_shr( Mpy_32_32( ct_fx[i], L_temp ), 1 ) ) ); // Q30 +#endif + diff_fx[i] = L_negate( L_add( L_shr( st_fx[i], 1 ), L_shr( Mpy_32_32( ct_fx[i], L_temp ), 1 ) ) ); // Q30 move32(); } @@ -3405,8 +3421,12 @@ static Word16 truncGR0_chan_fx( IF( data_idx[i] > 0 ) { // sort_diff[i] = -st[i] - ct[i] * cosf( ( fabsf( data[i] ) - cb_azi_chan[( ( data_idx[i] + 1 ) >> 1 ) - 1] ) * PI_OVER_180 ); +#ifdef FIX_2493_CHECK_EXTRACT_L + L_temp = L_deposit_h( getCosWord16R2( extract_l2( L_shr( Mpy_32_16_1( L_sub( L_abs( data_fx[i] ), cb_azi_chan_fx[( ( data_idx[i] + 1 ) >> 1 ) - 1] ), 91 ), 7 ) ) ) ); // Q31 +#else L_temp = L_deposit_h( getCosWord16R2( extract_l( L_shr( Mpy_32_16_1( L_sub( L_abs( data_fx[i] ), cb_azi_chan_fx[( ( data_idx[i] + 1 ) >> 1 ) - 1] ), 91 ), 7 ) ) ) ); // Q31 - sort_diff_fx[i] = L_negate( L_add( L_shr( st_fx[i], 1 ), L_shr( Mpy_32_32( ct_fx[i], L_temp ), 1 ) ) ); // Q30 +#endif + sort_diff_fx[i] = L_negate( L_add( L_shr( st_fx[i], 1 ), L_shr( Mpy_32_32( ct_fx[i], L_temp ), 1 ) ) ); // Q30 move32(); sum_diff_fx = sum2_f_32_fx( sort_diff_fx, len, gb ); // Q(2*Q30-31-gb)= Q(Q29-gb) Word16 flag = BASOP_Util_Cmp_Mant32Exp( sum_diff_fx, sub( Q31, sub( Q29, gb ) ), min_diff_fx, min_diff_e ); @@ -3430,7 +3450,11 @@ static Word16 truncGR0_chan_fx( move16(); bits = add( bits, ivas_qmetadata_encode_extended_gr_length_fx( data_idx[idx_crt], 9, 0 ) ); // diff[idx_crt] = -st[idx_crt] - ct[idx_crt] * cosf( ( data[idx_crt] - data_hat[idx_crt] ) * PI_OVER_180 ); +#ifdef FIX_2493_CHECK_EXTRACT_L + L_temp = L_deposit_h( getCosWord16R2( extract_l2( L_shr( Mpy_32_16_1( L_sub( data_fx[idx_crt], data_hat_fx[idx_crt] ), 91 ), 7 ) ) ) ); // Q31 +#else L_temp = L_deposit_h( getCosWord16R2( extract_l( L_shr( Mpy_32_16_1( L_sub( data_fx[idx_crt], data_hat_fx[idx_crt] ), 91 ), 7 ) ) ) ); // Q31 +#endif diff_fx[idx_crt] = L_negate( L_add( L_shr( st_fx[idx_crt], 1 ), L_shr( Mpy_32_32( ct_fx[idx_crt], L_temp ), 1 ) ) ); // Q30 move32(); @@ -3514,7 +3538,11 @@ static Word16 common_direction_fx( FOR( i = 0; i < len; i++ ) { // ct[i] = cosf( elevation_orig[i] * PI_OVER_180 ); +#ifdef FIX_2493_CHECK_EXTRACT_L + ct_fx[i] = L_deposit_h( getCosWord16R2( extract_l2( L_shr( Mpy_32_16_1( elevation_orig_fx[i], 91 ), 7 ) ) ) ); // Q31 +#else ct_fx[i] = L_deposit_h( getCosWord16R2( extract_l( L_shr( Mpy_32_16_1( elevation_orig_fx[i], 91 ), 7 ) ) ) ); // Q31 +#endif move32(); } @@ -3594,7 +3622,11 @@ static Word16 common_direction_fx( FOR( i = 0; i < len; i++ ) { // ct[i] = cosf( elevation_orig[i] * PI_OVER_180 ); +#ifdef FIX_2493_CHECK_EXTRACT_L + ct_fx[i] = L_deposit_h( getCosWord16R2( extract_l2( L_shr( Mpy_32_16_1( elevation_orig_fx[i], 91 ), 7 ) ) ) ); // Q31 +#else ct_fx[i] = L_deposit_h( getCosWord16R2( extract_l( L_shr( Mpy_32_16_1( elevation_orig_fx[i], 91 ), 7 ) ) ) ); // Q31 +#endif move32(); } @@ -3626,16 +3658,29 @@ static Word16 common_direction_fx( return nbits; } +#ifdef FIX_2493_CHECK_EXTRACT_L + set_val_Word32( st_fx, L_deposit_h( getSineWord16R2( extract_l2( L_shr( Mpy_32_16_1( theta_cb_fx[id_th], 91 ), 7 ) ) ) ), len ); + set_val_Word32( ct_fx, L_deposit_h( getCosWord16R2( extract_l2( L_shr( Mpy_32_16_1( theta_cb_fx[id_th], 91 ), 7 ) ) ) ), len ); +#else set_val_Word32( st_fx, L_deposit_h( getSineWord16R2( extract_l( L_shr( Mpy_32_16_1( theta_cb_fx[id_th], 91 ), 7 ) ) ) ), len ); set_val_Word32( ct_fx, L_deposit_h( getCosWord16R2( extract_l( L_shr( Mpy_32_16_1( theta_cb_fx[id_th], 91 ), 7 ) ) ) ), len ); +#endif FOR( i = 0; i < len; i++ ) { // st[i] *= sinf( elevation_orig[i] * PI_OVER_180 ); +#ifdef FIX_2493_CHECK_EXTRACT_L + st_fx[i] = Mpy_32_32( st_fx[i], L_deposit_h( getSineWord16R2( extract_l2( L_shr( Mpy_32_16_1( elevation_orig_fx[i], 91 ), 7 ) ) ) ) ); // Q31; +#else st_fx[i] = Mpy_32_32( st_fx[i], L_deposit_h( getSineWord16R2( extract_l( L_shr( Mpy_32_16_1( elevation_orig_fx[i], 91 ), 7 ) ) ) ) ); // Q31; +#endif move32(); // ct[i] *= cosf( elevation_orig[i] * PI_OVER_180 ); +#ifdef FIX_2493_CHECK_EXTRACT_L + ct_fx[i] = Mpy_32_32( ct_fx[i], L_deposit_h( getCosWord16R2( extract_l2( L_shr( Mpy_32_16_1( elevation_orig_fx[i], 91 ), 7 ) ) ) ) ); // Q31; +#else ct_fx[i] = Mpy_32_32( ct_fx[i], L_deposit_h( getCosWord16R2( extract_l( L_shr( Mpy_32_16_1( elevation_orig_fx[i], 91 ), 7 ) ) ) ) ); // Q31; +#endif move32(); q_direction->band_data[band_idx].azimuth_index[i] = 0; move16(); @@ -4037,7 +4082,11 @@ static ivas_error requantize_direction_EC_3_fx( FOR( k = 0; k < no_subframes; k++ ) { // ct[k] = cosf( elevation_orig[j][k] * PI_OVER_180 ); +#ifdef FIX_2493_CHECK_EXTRACT_L + ct_fx[k] = L_deposit_h( getCosWord16R2( extract_l2( L_shr( Mpy_32_16_1( elevation_orig_fx[j][k], 91 ), 7 ) ) ) ); // Q31 +#else ct_fx[k] = L_deposit_h( getCosWord16R2( extract_l( L_shr( Mpy_32_16_1( elevation_orig_fx[j][k], 91 ), 7 ) ) ) ); // Q31 +#endif move32(); } @@ -4342,14 +4391,22 @@ static void calculate_two_distances_fx( IF( EQ_16( bits[i], 3 ) ) { // d1 += 1 - 0.7f * cosf( el[i] * PI_OVER_180 ); - temp = getCosWord16R2( extract_l( L_shr( Mpy_32_16_1( el_fx[i], 91 ), 7 ) ) ); // Q15 +#ifdef FIX_2493_CHECK_EXTRACT_L + temp = getCosWord16R2( extract_l2( L_shr( Mpy_32_16_1( el_fx[i], 91 ), 7 ) ) ); // Q15 +#else + temp = getCosWord16R2( extract_l( L_shr( Mpy_32_16_1( el_fx[i], 91 ), 7 ) ) ); // Q15 +#endif d1_fx = L_add( d1_fx, L_shr( L_sub( ONE_IN_Q30, L_shr( Mpy_32_16_1( 1503238554, temp ), 1 ) ), gb ) ); // 1503238554 = 0.7 in Q31 // Q30-gb } ELSE { // d1 += 1 - 0.92f * cosf( el[i] * PI_OVER_180 ); - temp = getCosWord16R2( extract_l( L_shr( Mpy_32_16_1( el_fx[i], 91 ), 7 ) ) ); // Q15 +#ifdef FIX_2493_CHECK_EXTRACT_L + temp = getCosWord16R2( extract_l2( L_shr( Mpy_32_16_1( el_fx[i], 91 ), 7 ) ) ); // Q15 +#else + temp = getCosWord16R2( extract_l( L_shr( Mpy_32_16_1( el_fx[i], 91 ), 7 ) ) ); // Q15 +#endif d1_fx = L_add( d1_fx, L_shr( L_sub( ONE_IN_Q30, L_shr( Mpy_32_16_1( 1975684956, temp ), 1 ) ), gb ) ); // 1975684956 = 0.92 in Q31 // Q30-gb } @@ -4359,15 +4416,24 @@ static void calculate_two_distances_fx( IF( EQ_16( bits[i], 3 ) ) { // d1 += 1 - sinf( el[i] * PI_OVER_180 ) * 0.7f * sign( el[i] ); - temp = getSineWord16R2( extract_l( L_shr( Mpy_32_16_1( el_fx[i], 91 ), 7 ) ) ); // Q15 +#ifdef FIX_2493_CHECK_EXTRACT_L + temp = getSineWord16R2( extract_l2( L_shr( Mpy_32_16_1( el_fx[i], 91 ), 7 ) ) ); // Q15 +#else + temp = getSineWord16R2( extract_l( L_shr( Mpy_32_16_1( el_fx[i], 91 ), 7 ) ) ); // Q15 +#endif d1_fx = L_add( d1_fx, L_shr( L_sub( ONE_IN_Q30, L_shr( Mpy_32_16_1( imult3216( 1503238554, sign_fx( el_fx[i] ) ), temp ), 1 ) ), gb ) ); // 1503238554 = 0.7 in Q31 // Q30-gb } ELSE { // d1 += 1 - 0.7f * 0.92f * cosf( el[i] * PI_OVER_180 ) - sinf( fabsf( el[i] * PI_OVER_180 ) ) * 0.7f; - temp = getCosWord16R2( extract_l( L_shr( Mpy_32_16_1( el_fx[i], 91 ), 7 ) ) ); // Q15 - temp1 = getSineWord16R2( extract_l( L_shr( Mpy_32_16_1( L_abs( el_fx[i] ), 91 ), 7 ) ) ); // Q15 +#ifdef FIX_2493_CHECK_EXTRACT_L + temp = getCosWord16R2( extract_l2( L_shr( Mpy_32_16_1( el_fx[i], 91 ), 7 ) ) ); // Q15 + temp1 = getSineWord16R2( extract_l2( L_shr( Mpy_32_16_1( L_abs( el_fx[i] ), 91 ), 7 ) ) ); // Q15 +#else + temp = getCosWord16R2( extract_l( L_shr( Mpy_32_16_1( el_fx[i], 91 ), 7 ) ) ); // Q15 + temp1 = getSineWord16R2( extract_l( L_shr( Mpy_32_16_1( L_abs( el_fx[i] ), 91 ), 7 ) ) ); // Q15 +#endif d1_fx = L_add( d1_fx, L_shr( L_sub( L_sub( ONE_IN_Q30, L_shr( Mpy_32_16_1( 1422493168, temp ), 1 ) ), L_shr( Mpy_32_16_1( 1503238554, temp1 ), 1 ) ), gb ) ); // 1422493168 = 0.92* 0.7 in Q31 ;1503238554 = 0.7 in Q31 // Q30-gb } @@ -4378,7 +4444,11 @@ static void calculate_two_distances_fx( IF( EQ_16( bits[i], 2 ) ) { // d1 += 1 - cosf( el[i] * PI_OVER_180 ) * 0.7f; - temp = getCosWord16R2( extract_l( L_shr( Mpy_32_16_1( el_fx[i], 91 ), 7 ) ) ); // Q15 +#ifdef FIX_2493_CHECK_EXTRACT_L + temp = getCosWord16R2( extract_l2( L_shr( Mpy_32_16_1( el_fx[i], 91 ), 7 ) ) ); // Q15 +#else + temp = getCosWord16R2( extract_l( L_shr( Mpy_32_16_1( el_fx[i], 91 ), 7 ) ) ); // Q15 +#endif d1_fx = L_add( d1_fx, L_shr( L_sub( ONE_IN_Q30, L_shr( Mpy_32_16_1( 1503238554, temp ), 1 ) ), gb ) ); // 1503238554 = 0.7 in Q31 // Q31-gb } @@ -4389,11 +4459,19 @@ static void calculate_two_distances_fx( } } // d2 += 1 - sinf( el_av * PI_OVER_180 ) * sinf( el[i] * PI_OVER_180 ) - cosf( el[i] * PI_OVER_180 ) * cosf( el_av * PI_OVER_180 ) * cos_delta_phi_cb[total_bits - 9]; +#ifdef FIX_2493_CHECK_EXTRACT_L + L_temp = L_deposit_h( getCosWord16R2( extract_l2( L_shr( Mpy_32_16_1( el_fx[i], 91 ), 7 ) ) ) ); //*91/7 to convert angle in Q22 to radians + // Q15 + L_temp1 = L_deposit_h( getSineWord16R2( extract_l2( L_shr( Mpy_32_16_1( el_fx[i], 91 ), 7 ) ) ) ); + L_temp2 = L_deposit_h( getSineWord16R2( extract_l2( L_shr( Mpy_32_16_1( el_av_fx, 91 ), 7 ) ) ) ); + L_temp3 = L_deposit_h( getCosWord16R2( extract_l2( L_shr( Mpy_32_16_1( el_av_fx, 91 ), 7 ) ) ) ); +#else L_temp = L_deposit_h( getCosWord16R2( extract_l( L_shr( Mpy_32_16_1( el_fx[i], 91 ), 7 ) ) ) ); //*91/7 to convert angle in Q22 to radians // Q15 L_temp1 = L_deposit_h( getSineWord16R2( extract_l( L_shr( Mpy_32_16_1( el_fx[i], 91 ), 7 ) ) ) ); L_temp2 = L_deposit_h( getSineWord16R2( extract_l( L_shr( Mpy_32_16_1( el_av_fx, 91 ), 7 ) ) ) ); L_temp3 = L_deposit_h( getCosWord16R2( extract_l( L_shr( Mpy_32_16_1( el_av_fx, 91 ), 7 ) ) ) ); +#endif // temp1f = sinf( el_av * PI_OVER_180 ) * sinf( el[i] * PI_OVER_180 ); // L_temp4 = Mpy_32_32( L_temp2, L_temp1 ); d2_fx = L_add( d2_fx, L_shr( L_sub( L_sub( ONE_IN_Q30, L_shr( Mpy_32_32( L_temp2, L_temp1 ), 1 ) ), L_shr( Mpy_32_32( Mpy_32_32( L_temp, L_temp3 ), cos_delta_phi_cb_fx[total_bits - 9] ), 1 ) ), gb ) ); // Q30-gb @@ -5872,18 +5950,30 @@ static Word16 ivas_qmetadata_quantize_coherence_fx( IF( write_flag ) { /* quantize first DCT parameter */ +#ifdef FIX_2493_CHECK_EXTRACT_L + dct_coh[j][0] = quantize_DCT_0_coh_fx( extract_l2( L_shr_r( dct_coh[j][0], 7 ) ), j, coherence_cb0_masa_Q14, MASA_DELTA_AZI_DCT0 << Q6, MASA_NO_CV_COH, q_direction, &idx_dct[k], &no_cb_vec[j], hrmasa_flag ); // Q21 +#else dct_coh[j][0] = quantize_DCT_0_coh_fx( extract_l( L_shr_r( dct_coh[j][0], 7 ) ), j, coherence_cb0_masa_Q14, MASA_DELTA_AZI_DCT0 << Q6, MASA_NO_CV_COH, q_direction, &idx_dct[k], &no_cb_vec[j], hrmasa_flag ); // Q21 +#endif move32(); } IF( LT_16( coding_subbands, coding_subbands_0 ) ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + idx_dct[k + coding_subbands] = squant_fx( extract_l2( L_shr_r( dct_coh[j][1], 6 ) ), &tmp16, &coherence_cb1_masa_Q15[MASA_grouping[two_dir_band[j]] * MASA_NO_CV_COH1], MASA_NO_CV_COH1 ); +#else idx_dct[k + coding_subbands] = squant_fx( extract_l( L_shr_r( dct_coh[j][1], 6 ) ), &tmp16, &coherence_cb1_masa_Q15[MASA_grouping[two_dir_band[j]] * MASA_NO_CV_COH1], MASA_NO_CV_COH1 ); +#endif move16(); } ELSE { +#ifdef FIX_2493_CHECK_EXTRACT_L + idx_dct[k + coding_subbands] = squant_fx( extract_l2( L_shr_r( dct_coh[j][1], 6 ) ), &tmp16, &coherence_cb1_masa_Q15[MASA_grouping[j] * MASA_NO_CV_COH1], MASA_NO_CV_COH1 ); +#else idx_dct[k + coding_subbands] = squant_fx( extract_l( L_shr_r( dct_coh[j][1], 6 ) ), &tmp16, &coherence_cb1_masa_Q15[MASA_grouping[j] * MASA_NO_CV_COH1], MASA_NO_CV_COH1 ); +#endif move16(); } dct_coh[j][1] = L_shl( tmp16, 6 ); diff --git a/lib_enc/ivas_stereo_classifier_fx.c b/lib_enc/ivas_stereo_classifier_fx.c index f38e7c9158f2670e404024ab06782860335b4334..0e9abb1914304cd2b7576272592b134d183bf1c9 100644 --- a/lib_enc/ivas_stereo_classifier_fx.c +++ b/lib_enc/ivas_stereo_classifier_fx.c @@ -1419,7 +1419,11 @@ void xtalk_classifier_dft_fx( ELSE { // score /= XTALK_SCORE_THR_DFT; +#ifdef FIX_2493_CHECK_EXTRACT_L + score = L_shl_sat( W_extract_l2( W_tmp ), 2 ); // Q27->Q31/XTALK_SCORE_THR_DFT +#else score = L_shl_sat( W_extract_l( W_tmp ), 2 ); // Q27->Q31/XTALK_SCORE_THR_DFT +#endif } /* raw score */ diff --git a/lib_enc/ivas_stereo_ica_enc_fx.c b/lib_enc/ivas_stereo_ica_enc_fx.c index de17deb22718c77bb8f335f0738566256e75c932..0a338f0058a57a58fa3930b4e9199da76e61e8e3 100644 --- a/lib_enc/ivas_stereo_ica_enc_fx.c +++ b/lib_enc/ivas_stereo_ica_enc_fx.c @@ -279,8 +279,12 @@ void spectral_balancer_fx16( x0 = signal[i]; /*Qx*/ move16(); // y0 = (y1 * a1) + (y2 * a2) + (x0 * b0) + (x1 * b1) + (x2 * b2); +#ifdef FIX_2493_CHECK_EXTRACT_L + y0 = extract_l2( W_extract_l2( W_shr( W_mac_32_16( W_mac_32_16( W_mac_32_16( W_mac_32_16( W_mult_32_16( a1, y1 ), a2, y2 ), b0, x0 ), b1, x1 ), b2, x2 ), 30 ) ) ); // Qx +#else y0 = extract_l( W_extract_l( W_shr( W_mac_32_16( W_mac_32_16( W_mac_32_16( W_mac_32_16( W_mult_32_16( a1, y1 ), a2, y2 ), b0, x0 ), b1, x1 ), b2, x2 ), 30 ) ) ); // Qx - signal[i] = y0; /*Qx*/ +#endif + signal[i] = y0; /*Qx*/ move16(); y2 = y1; /*Qx*/ move16(); @@ -361,8 +365,12 @@ void spectral_balancer_fx( move16(); x0 = signal[i]; /*Qx*/ move16(); +#ifdef FIX_2493_CHECK_EXTRACT_L + y0 = W_extract_l2( W_shr( W_mac_32_32( W_mac_32_32( W_mac_32_32( W_mac_32_32( W_mult_32_32( a1, y1 ), a2, y2 ), b0, x0 ), b1, x1 ), b2, x2 ), 30 ) ); // Qx +#else y0 = W_extract_l( W_shr( W_mac_32_32( W_mac_32_32( W_mac_32_32( W_mac_32_32( W_mult_32_32( a1, y1 ), a2, y2 ), b0, x0 ), b1, x1 ), b2, x2 ), 30 ) ); // Qx - signal[i] = y0; /*Qx*/ +#endif + signal[i] = y0; /*Qx*/ move16(); y2 = y1; /*Qx*/ move16(); @@ -744,7 +752,11 @@ static Word16 TRUNC_FX( Word32 inp /*Q31-exp*/, Word16 exp ) IF( NE_32( temp, L_shl_sat( 1, sub( 31, exp ) ) ) ) { Word32 temp1 = L_add_sat( inp, L_shl_sat( 1, sub( 31, add( exp, 1 ) ) ) ); /* Q31-exp */ - ouptut = extract_l( L_shr( temp1, sub( 31, exp ) ) ); /*Q0*/ +#ifdef FIX_2493_CHECK_EXTRACT_L + ouptut = extract_l2( L_shr( temp1, sub( 31, exp ) ) ); /*Q0*/ +#else + ouptut = extract_l( L_shr( temp1, sub( 31, exp ) ) ); /*Q0*/ +#endif IF( temp < 0 ) { @@ -753,7 +765,11 @@ static Word16 TRUNC_FX( Word32 inp /*Q31-exp*/, Word16 exp ) } ELSE { +#ifdef FIX_2493_CHECK_EXTRACT_L + ouptut = extract_l2( temp ); /*Q0*/ +#else ouptut = extract_l( temp ); /*Q0*/ +#endif move16(); } } @@ -1310,7 +1326,11 @@ static void estDownmixGain_fx( currentGain_log10 = BASOP_Util_Log10( L_deposit_h( currentGain ), currentGain_e ); // Output in Q25 // multiplication result will be Q25 should be fit to Q15 hence right shift by 10. // Q25 - Q10 = Q15 +#ifdef FIX_2493_CHECK_EXTRACT_L + currentGain = extract_l2( L_shr( Madd_32_16( Mpy_32_16_1( prevTargetGain_log10, alpha ), currentGain_log10, sub( MAX_16, alpha ) ), Q10 ) ); /* Q15 */ +#else currentGain = extract_l( L_shr( Madd_32_16( Mpy_32_16_1( prevTargetGain_log10, alpha ), currentGain_log10, sub( MAX_16, alpha ) ), Q10 ) ); /* Q15 */ +#endif currentGain_e = 0; move16(); @@ -1330,11 +1350,7 @@ static void estDownmixGain_fx( exp = 0; move16(); } -#ifdef FIX_BASOP_2599_TCA_OVERFLOW - unclr_instTargetGain = BASOP_Util_Log10( L_add_sat( unclr_instTargetGain, L_shr( MAX_32, sub( Q31, exp ) ) ), exp ); -#else unclr_instTargetGain = BASOP_Util_Log10( L_add( unclr_instTargetGain, L_shr( MAX_32, sub( Q31, exp ) ) ), exp ); -#endif // unclr_fv_fx is expected in Q15 - log result will be in Q25 - hence rightshift by 10. hStereoClassif->unclr_fv_fx[E_ica_instTargetGain] = L_shr( unclr_instTargetGain, Q10 ); /* Q15 */ move32(); @@ -1767,7 +1783,11 @@ void stereo_tca_enc_fx( IF( LT_32( input_Fs, 32000 ) ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + maxCorrStatsDev = extract_l2( Mpy_32_32( imult3216( input_Fs, maxCorrStatsDev ), 67109 /* 1/32000.0f in Q31*/ ) ); // Q0 +#else maxCorrStatsDev = extract_l( Mpy_32_32( imult3216( input_Fs, maxCorrStatsDev ), 67109 /* 1/32000.0f in Q31*/ ) ); // Q0 +#endif } musicMode = ( hCPE->hCoreCoder[0]->sp_aud_decision0 == 1 || sts[0]->last_core > ACELP_CORE ); diff --git a/lib_enc/ivas_tcx_core_enc_fx.c b/lib_enc/ivas_tcx_core_enc_fx.c index 74326d7dd57231d832f5363b8cc8dbfa9c930a55..14f5617b50dd23e074fc5af3767d2b5fa83cb9bc 100644 --- a/lib_enc/ivas_tcx_core_enc_fx.c +++ b/lib_enc/ivas_tcx_core_enc_fx.c @@ -667,7 +667,11 @@ void stereo_tcx_core_enc( lev_dur_fx( A_fx32, r_fx, M, NULL, Q12, Q_r ); FOR( Word16 j = 0; j < M; j++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + A_fx[j] = extract_l2( A_fx32[j] ); /* Q12 */ +#else A_fx[j] = extract_l( A_fx32[j] ); /* Q12 */ +#endif move16(); } E_LPC_a_lsp_conversion( A_fx, lsptmp_fx, lsp_new_fx, M ); diff --git a/lib_enc/swb_bwe_enc_fx.c b/lib_enc/swb_bwe_enc_fx.c index 31bcd1e8963174d5d616ed1e6feb384270f1e841..cfe15c438bce00bf6b05dca96d918550d7fcfe13 100644 --- a/lib_enc/swb_bwe_enc_fx.c +++ b/lib_enc/swb_bwe_enc_fx.c @@ -741,7 +741,11 @@ static void get_normalize_spec_fx( exp = sub( sub( 30, exp ), Q_new_lf ); tmp = div_s( 16384, tmp ); /*Q(15+exp) */ L_tmp_m = L_shr( L_mult0( SWB_signal[n_freq], tmp ), add( exp, Q_new_lf ) ); /*Q15 */ - SWB_signal[n_freq] = extract_l( L_tmp_m ); /*Q15 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + SWB_signal[n_freq] = extract_l2( L_tmp_m ); /*Q15 */ +#else + SWB_signal[n_freq] = extract_l( L_tmp_m ); /*Q15 */ +#endif move16(); } ELSE @@ -916,9 +920,13 @@ static Word16 FD_BWE_class_fx( IF( NE_32( mean[i], L_deposit_l( peak ) ) ) { - L_tmp = L_sub( mean[i], peak ); /*Q_syn */ - L_tmp = Mpy_32_16_1( L_tmp, 16913 ); /* 1/31->Q19 -> Q_syn+19-15 */ + L_tmp = L_sub( mean[i], peak ); /*Q_syn */ + L_tmp = Mpy_32_16_1( L_tmp, 16913 ); /* 1/31->Q19 -> Q_syn+19-15 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + den = extract_l2( L_shr( L_tmp, 4 ) ); /*Q_syn */ +#else den = extract_l( L_shr( L_tmp, 4 ) ); /*Q_syn */ +#endif if ( den == 0 ) { den = 1; @@ -3371,7 +3379,11 @@ void hq_generic_hf_encoding_fx( L_tmp = L_mult( tmp, 21771 ); /*26 */ L_tmp = L_shr( L_tmp, 10 ); /*16 */ L_Extract( L_tmp, &exp, &tmp ); /* */ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l2( Pow2( 13, tmp ) ); +#else tmp = extract_l( Pow2( 13, tmp ) ); +#endif exp = sub( exp, 13 ); hq_generic_fenv_fx[n_band] = shl_sat( tmp, add( exp, 1 ) ); /*1 */ move16(); @@ -3385,7 +3397,11 @@ void hq_generic_hf_encoding_fx( L_tmp = L_mult( tmp, 21771 ); /*25 */ L_tmp = L_shr( L_tmp, 9 ); /*16 */ L_Extract( L_tmp, &exp, &tmp ); +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l( Pow2( 13, tmp ) ); +#else tmp = extract_l( Pow2( 13, tmp ) ); +#endif exp = sub( exp, 13 ); hq_generic_fenv_fx[n_band + nenv] = shl( tmp, add( exp, 1 ) ); /*1 */ move16(); diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index c691af8ba3da056e8cd8a14b072fb6f169f286ef..7a3870aa3b7c234837675c3cd551330220c23b75 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -818,7 +818,11 @@ static void gethar_noisegn_fx( L_temp = L_shr( L_temp, 12 ); /* Q28-Q12 -> Q16 */ temp_lo = L_Extract_lc( L_temp, &temp_hi ); Qg = sub( 14, temp_hi ); +#ifdef FIX_2493_CHECK_EXTRACT_L + g_fx = extract_l2( Pow2( 14, temp_lo ) ); +#else g_fx = extract_l( Pow2( 14, temp_lo ) ); +#endif g_fx = shl( g_fx, sub( 11, Qg ) ); ton_ene_est_fx( diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index bd8a8b16070eff3013d6ce207d8b2219c1f2aaed..70c038ec13d9f38e7f15a7f273845d5dbfb5510f 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -1094,8 +1094,13 @@ void swb_pre_proc_fx( { FOR( ts = 0; ts < CLDFB_NO_COL_MAX; ts++ ) { +#if defined( FIX_2493_CHECK_EXTRACT_L ) + realQ_neg1 = extract_l2( L_shr( realBufferFlipped[ts][nB], 31 - ( 15 + cldfbScale->hb_scale ) + 1 ) ); + imagQ_neg1 = extract_l2( L_shr( imagBufferFlipped[ts][nB], 31 - ( 15 + cldfbScale->hb_scale ) + 1 ) ); /* Q(-1), headroom needed */ +#else realQ_neg1 = extract_l( L_shr( realBufferFlipped[ts][nB], 31 - ( 15 + cldfbScale->hb_scale ) + 1 ) ); imagQ_neg1 = extract_l( L_shr( imagBufferFlipped[ts][nB], 31 - ( 15 + cldfbScale->hb_scale ) + 1 ) ); /* Q(-1), headroom needed */ +#endif lbEner = L_mac0_o( lbEner, realQ_neg1, realQ_neg1, &Overflow ); lbEner = L_mac0_o( lbEner, imagQ_neg1, imagQ_neg1, &Overflow ); /* Q(-2) */ @@ -1247,8 +1252,13 @@ void swb_pre_proc_fx( { FOR( ts = 0; ts < CLDFB_NO_COL_MAX; ts++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + realQ_neg1 = extract_l2( L_shr( realBuffer[ts][nB], 16 ) ); + imagQ_neg1 = extract_l2( L_shr( imagBuffer[ts][nB], 16 ) ); /* Q(-1), headroom needed */ +#else realQ_neg1 = extract_l( L_shr( realBuffer[ts][nB], 16 ) ); imagQ_neg1 = extract_l( L_shr( imagBuffer[ts][nB], 16 ) ); /* Q(-1), headroom needed */ +#endif icbweRefEner_fx = L_mac0_o( icbweRefEner_fx, realQ_neg1, realQ_neg1, &Overflow ); icbweRefEner_fx = L_mac0_o( icbweRefEner_fx, imagQ_neg1, imagQ_neg1, &Overflow ); /* Q(-2) */ } @@ -1266,8 +1276,13 @@ void swb_pre_proc_fx( { FOR( ts = 0; ts < CLDFB_NO_COL_MAX; ts++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + realQ_neg1 = extract_l2( L_shr( realBuffer[ts][nB], 16 ) ); + imagQ_neg1 = extract_l2( L_shr( imagBuffer[ts][nB], 16 ) ); /* Q(-1), headroom needed */ +#else realQ_neg1 = extract_l( L_shr( realBuffer[ts][nB], 16 ) ); imagQ_neg1 = extract_l( L_shr( imagBuffer[ts][nB], 16 ) ); /* Q(-1), headroom needed */ +#endif lbEner = L_mac0_o( lbEner, realQ_neg1, realQ_neg1, &Overflow ); lbEner = L_mac0_o( lbEner, imagQ_neg1, imagQ_neg1, &Overflow ); /* Q(-2) */ diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 5128ca77f790a27f9d03869a8ded9f16402dd1cb..e728f5f57c857a7fd305410ea24c107add26958b 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -3027,7 +3027,11 @@ void swb_tbe_enc_fx( } ELSE IF( EQ_32( st_fx->extl_brate, SWB_TBE_1k10 ) || EQ_32( st_fx->extl_brate, SWB_TBE_1k75 ) ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + GainFrame_fx = Mpy_32_16_1( GainFrame_fx, extract_l2( L_shl( L_tmp, 2 ) ) ); +#else GainFrame_fx = Mpy_32_16_1( GainFrame_fx, extract_l( L_shl( L_tmp, 2 ) ) ); +#endif } ELSE { @@ -3943,7 +3947,11 @@ static void QuantizeSHBsubgains_fx( L_tmp = L_mult( subgains[i], 21771 ); /* *0.166096 in Q17 -> Q26 */ L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */ frac = L_Extract_lc( L_tmp, &exp ); +#ifdef FIX_2493_CHECK_EXTRACT_L + subgains[i] = extract_l2( Pow2( 14, frac ) ); +#else subgains[i] = extract_l( Pow2( 14, frac ) ); +#endif move16(); /* Put 14 as exponent so that */ /* output of Pow2() will be: */ @@ -3988,7 +3996,11 @@ static void QuantizeSHBsubgains_fx( L_tmp = L_mult( subgains[i], 27213 ); /* *3.321928 in Q13 -> Q26 */ L_tmp = L_shr( L_tmp, 10 ); /* From Q26 to Q16 */ frac = L_Extract_lc( L_tmp, &exp ); +#ifdef FIX_2493_CHECK_EXTRACT_L + subgains[i] = extract_l2( Pow2( 14, frac ) ); +#else subgains[i] = extract_l( Pow2( 14, frac ) ); +#endif move16(); /* Put 14 as exponent so that */ /* output of Pow2() will be: */ @@ -4060,7 +4072,11 @@ static void Quant_shb_ener_sf_fx( { L_tmp1 = Mpy_32_16( exp, frac, 308 ); /* 308=LOG10(2) in Q10, so answer Ltmp in Q11 */ +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l2( L_tmp1 ); /* tmp in Q11 */ +#else tmp = extract_l( L_tmp1 ); /* tmp in Q11 */ +#endif temp_shb_ener_sf_fx = 0; move16(); @@ -4249,7 +4265,11 @@ static void QuantizeSHBframegain_fx( exp = norm_s( SHB_GAIN_QDELTA_1k75_FX_15 ); tmp = div_s( shl( 1, sub( 14, exp ) ), SHB_GAIN_QDELTA_1k75_FX_15 ); L_tmp = Mpy_32_16_1( L_sub( GainFrameLog, SHB_GAIN_QLOW_1k75_FX ), tmp ); +#ifdef FIX_2493_CHECK_EXTRACT_L + idxFrameGain = extract_l2( L_shr( L_add( L_tmp, shl( 1, sub( 14, exp ) ) ), sub( 15, exp ) ) ); /*Q0*/ +#else idxFrameGain = extract_l( L_shr( L_add( L_tmp, shl( 1, sub( 14, exp ) ) ), sub( 15, exp ) ) ); /*Q0*/ +#endif IF( GT_16( idxFrameGain, ( 1 << NUM_BITS_SHB_FRAMEGAIN_1k75 ) - 1 ) ) { idxFrameGain = ( 1 << NUM_BITS_SHB_FRAMEGAIN_1k75 ) - 1; @@ -4273,7 +4293,11 @@ static void QuantizeSHBframegain_fx( exp = norm_s( SHB_GAIN_QDELTA_FX_15 ); tmp = div_s( shl( 1, sub( 14, exp ) ), SHB_GAIN_QDELTA_FX_15 ); L_tmp = Mpy_32_16_1( L_sub( GainFrameLog, SHB_GAIN_QLOW_FX_16 ), tmp ); +#ifdef FIX_2493_CHECK_EXTRACT_L + idxFrameGain = extract_l2( L_shr( L_add( L_tmp, shl( 1, sub( 14, exp ) ) ), sub( 15, exp ) ) ); /*Q0*/ +#else idxFrameGain = extract_l( L_shr( L_add( L_tmp, shl( 1, sub( 14, exp ) ) ), sub( 15, exp ) ) ); /*Q0*/ +#endif IF( GT_16( idxFrameGain, ( 1 << NUM_BITS_SHB_FRAMEGAIN ) - 1 ) ) { idxFrameGain = ( 1 << NUM_BITS_SHB_FRAMEGAIN ) - 1; @@ -4422,7 +4446,11 @@ static void determine_gain_weights_fx( move16(); L_tmp = Mpy_32_16( exp, frac, -29491 ); /* Q16 */ frac = L_Extract_lc( L_tmp, &exp ); +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l2( Pow2( 14, frac ) ); /* Q14 */ +#else tmp = extract_l( Pow2( 14, frac ) ); /* Q14 */ +#endif exp2 = sub( exp, 8 ); IF( LE_16( exp1, 21 ) ) diff --git a/lib_enc/tcq_core_enc_fx.c b/lib_enc/tcq_core_enc_fx.c index 517c1c0b49400fc77ded750bf8cb4924be12033e..b2269f6937b663ba90920dc17437059ee544a134 100644 --- a/lib_enc/tcq_core_enc_fx.c +++ b/lib_enc/tcq_core_enc_fx.c @@ -428,7 +428,11 @@ ivas_error tcq_core_LR_enc_fx( /* Loop through non-zero blocks */ FOR( i = 0; i < L_FRAME32k; i++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + coefs_norm_dec_fx[i] = extract_l2( L_mult0( coefs_norm_dec_fx[i], 5 ) ); +#else coefs_norm_dec_fx[i] = extract_l( L_mult0( coefs_norm_dec_fx[i], 5 ) ); +#endif move16(); } diff --git a/lib_enc/tcx_ltp_enc_fx.c b/lib_enc/tcx_ltp_enc_fx.c index 8b10a8f9b64be930b118ba2f2ad42df48999e88f..c4a2f808ea01af57ad0b91e398d6dc4ace4af675 100644 --- a/lib_enc/tcx_ltp_enc_fx.c +++ b/lib_enc/tcx_ltp_enc_fx.c @@ -205,8 +205,13 @@ static void tcx_ltp_pitch_search_fx( *pitch_fr = 0; move16(); +#ifdef FIX_2493_CHECK_EXTRACT_L + *index = add( sub( t1, pitfr1 ), extract_l2( L_mac0( L_mult0( sub( pitfr2, pitmin ), pitres ), + sub( pitfr1, pitfr2 ), shr( pitres, 1 ) ) ) ); +#else *index = add( sub( t1, pitfr1 ), extract_l( L_mac0( L_mult0( sub( pitfr2, pitmin ), pitres ), sub( pitfr1, pitfr2 ), shr( pitres, 1 ) ) ) ); +#endif move16(); return; @@ -279,9 +284,15 @@ static void tcx_ltp_pitch_search_fx( IF( GE_16( t0, pitfr2 ) ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + *index = add( extract_l2( L_mac0( L_mult0( sub( t0, pitfr2 ), shr( pitres, 1 ) ), + sub( pitfr2, pitmin ), pitres ) ), + shr( fraction, 1 ) ); +#else *index = add( extract_l( L_mac0( L_mult0( sub( t0, pitfr2 ), shr( pitres, 1 ) ), sub( pitfr2, pitmin ), pitres ) ), shr( fraction, 1 ) ); +#endif move16(); } ELSE diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 82ff1cb614ee9d6d5ed4cce42e1de2e4db2b4584..78a77fdb8284fa78ce09277c336467a9ba9a5aa2 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -1399,8 +1399,12 @@ Word16 tcx_scalar_quantization_rateloop_fx( sqBits = sqBits_in; move16(); +#ifdef FIX_2493_CHECK_EXTRACT_L + mod_adjust0 = extract_l2( L_shr( L_max( 0x10000, L_sub( 0x24CCD, L_mult( 0x0052, target ) ) ), 3 ) ); /* 2Q13 */ +#else mod_adjust0 = extract_l( L_shr( L_max( 0x10000, L_sub( 0x24CCD, L_mult( 0x0052, target ) ) ), 3 ) ); /* 2Q13 */ - mod_adjust1 = div_s( 0x2000, mod_adjust0 ); /* 0Q15 */ +#endif + mod_adjust1 = div_s( 0x2000, mod_adjust0 ); /* 0Q15 */ inv_target_e = 15; move16(); @@ -2046,7 +2050,11 @@ void tcx_noise_factor_fx( *quantized_fac_ns = tmp2; move16(); +#ifdef FIX_2493_CHECK_EXTRACT_L + *fac_ns = extract_l2( L_mult0( *quantized_fac_ns, shr( 24576 /*0.75f Q15*/, NBITS_NOISE_FILL_LEVEL ) ) ); +#else *fac_ns = extract_l( L_mult0( *quantized_fac_ns, shr( 24576 /*0.75f Q15*/, NBITS_NOISE_FILL_LEVEL ) ) ); +#endif return; } @@ -2352,7 +2360,11 @@ void tcx_noise_factor_ivas_fx( *quantized_fac_ns = tmp2; move16(); +#ifdef FIX_2493_CHECK_EXTRACT_L + *fac_ns = extract_l2( L_mult0( *quantized_fac_ns, shr( 24576 /*0.75f Q15*/, NBITS_NOISE_FILL_LEVEL ) ) ); +#else *fac_ns = extract_l( L_mult0( *quantized_fac_ns, shr( 24576 /*0.75f Q15*/, NBITS_NOISE_FILL_LEVEL ) ) ); +#endif move16(); return; diff --git a/lib_enc/transient_detection_fx.c b/lib_enc/transient_detection_fx.c index f68923d69a339041e405a1f04a8601c981947eaa..528ab45ba15f5173669ddf6b7676737e7a9e031f 100644 --- a/lib_enc/transient_detection_fx.c +++ b/lib_enc/transient_detection_fx.c @@ -422,7 +422,11 @@ Word16 GetTCXMaxenergyChange_fx( { FOR( i = 0; i < nTotBlocks; i++ ) { +#ifdef FIX_2493_CHECK_EXTRACT_L + maxEnergyChange = s_max( maxEnergyChange, extract_l2( L_shl_sat( pSubblockNrgChange_32[i], sub( pSubblockNrgChange_32_exp[i], 28 ) ) ) ); // Q3 +#else maxEnergyChange = s_max( maxEnergyChange, extract_l( L_shl_sat( pSubblockNrgChange_32[i], sub( pSubblockNrgChange_32_exp[i], 28 ) ) ) ); // Q3 +#endif } } ELSE diff --git a/lib_enc/transition_enc_fx.c b/lib_enc/transition_enc_fx.c index 00e047e16e6bfbc4f53e4b7b1fa9dc03710ef5e4..a2178f5d1ccc72f0f4cf052b1bb794daa4ad2fef 100644 --- a/lib_enc/transition_enc_fx.c +++ b/lib_enc/transition_enc_fx.c @@ -894,10 +894,13 @@ void transition_enc_fx( } offset = L_deposit_l( 0 ); - +#ifdef FIX_2493_CHECK_EXTRACT_L + tmp = extract_l2( L_mult( *T0_frac, 32 ) ); /*Q8, 0.25 in Q7*/ +#else tmp = extract_l( L_mult( *T0_frac, 32 ) ); /*Q8, 0.25 in Q7*/ - tmp = add( 512, tmp ); /*Q8; 2 in Q8*/ - tmp = mult_r( tmp, 256 ); /*Q16->Q0; 2 in Q7*/ +#endif + tmp = add( 512, tmp ); /*Q8; 2 in Q8*/ + tmp = mult_r( tmp, 256 ); /*Q16->Q0; 2 in Q7*/ tmp1 = sub( *T0, 2 ); /*Q0*/ tmp1 = shl( tmp1, 1 ); /*Q0 */ diff --git a/lib_enc/update_decision_fx.c b/lib_enc/update_decision_fx.c index e25e4d50c250291d5e8b2b90c69e463b5c380a25..06be4f3d3b350b138fb79e99756412c27a82212b 100644 --- a/lib_enc/update_decision_fx.c +++ b/lib_enc/update_decision_fx.c @@ -435,7 +435,11 @@ Word16 update_decision_fx( div_r = mult( div_r, 24576 ); div_r_32 = VAD_L_ADD( L_deposit_l( div_r ), add( sub( Q_sum, Q_counter ), 22 ), 9830, 15, &div_r_Q ); +#ifdef FIX_2493_CHECK_EXTRACT_L + div_r = extract_l2( L_shr( div_r_32, sub( div_r_Q, SP_CENTER_Q ) ) ); +#else div_r = extract_l( L_shr( div_r_32, sub( div_r_Q, SP_CENTER_Q ) ) ); +#endif test(); if ( ( GT_16( abs_s( sub( hVAD_CLDFB->sp_center[2], hVAD_CLDFB->lt_noise_sp_center0 ) ), div_r ) ) && ( GT_16( frameloop, 200 ) ) )