From 96dca8531e9f6eee47b53a12a46fffbc1ab5331d Mon Sep 17 00:00:00 2001 From: gerstack Date: Tue, 26 Aug 2025 11:32:43 +0200 Subject: [PATCH 01/33] issue _1965_ fix --- lib_dec/er_dec_tcx_fx.c | 42 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index ae2ddc341..eb3460bba 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -15,23 +15,36 @@ ******************************************************/ static void calcGainc_fx( Word16 *exc, Word16 Q_exc, Word32 old_fpitch /*Q16*/, Word16 L_subfr /*Q0*/, Word32 lp_gainp /*Q16*/, Word32 *lp_gainc /*Q16*/ ) { - Word32 L_c; Word16 tmp16, tmp16_2, tmp16_3, tmp_e, tmp2_e, tmp_loop, i; +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW + Word32 L_c; Word32 L_acc, L_tmp; +#else + Word64 W_acc; + Word32 L_tmp; +#endif #ifdef BASOP_NOGLOB_DECLARE_LOCAL +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Flag Overflow = 0; Flag Carry = 0; +#endif move32(); move32(); #endif +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW L_acc = L_deposit_l( 0 ); L_c = L_deposit_l( 0 ); +#else + W_acc = 0; +#endif +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Overflow = 0; move16(); Carry = 0; move16(); +#endif tmp16 = round_fx( old_fpitch ); /*Q0*/ tmp_loop = shl( L_subfr, 1 ); @@ -52,14 +65,22 @@ static void calcGainc_fx( Word16 *exc, Word16 Q_exc, Word32 old_fpitch /*Q16*/, #else tmp16_3 = sub_o( exc[( i - ( L_subfr * 2 ) )] /*Q1*/, mult_r( tmp16_2 /*Q15*/, exc[( ( i - ( L_subfr * 2 ) ) - tmp16 )] /*Q1*/ ) /*Q1*/, &Overflow ); #endif +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW L_acc = L_macNs_co( L_acc, tmp16_3, tmp16_3, &Carry, &Overflow ); /*Q3*/ Overflow = 0; move16(); L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); /*Accumulate Carrys Q-1*/ Carry = 0; move16(); +#else + W_acc = W_mac_16_16( W_acc, tmp16_3, tmp16_3 ); /*Q3*/ +#endif } +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW L_tmp = norm_llQ31( L_c, L_acc, &tmp_e ); /*Q3,norm,tmp_e*/ +#else + L_tmp = w_norm_llQ31( W_acc, &tmp_e ); /*Q3,norm,tmp_e*/ +#endif tmp_e = add( tmp_e, 31 - ( add( shl( Q_exc, 1 ), 1 ) ) ); /*L_tmp is Q31, now*/ tmp16 = BASOP_Util_Divide3216_Scale( L_tmp /*Q31,norm,tmp_e*/, shl( L_subfr, 1 ) /*Q15,15*/, &tmp2_e ) /*Q15,tmp2_e+tmp_e-15*/; tmp_e = sub( add( tmp2_e, tmp_e ), 15 ); @@ -75,15 +96,23 @@ static void calcGainc_fx( Word16 *exc, Word16 Q_exc, Word32 old_fpitch /*Q16*/, static void calcGainc2_fx( Word16 *exc, Word16 Q_exc, Word16 L_subfr /*Q0*/, Word32 *lp_gainc /*Q16*/ ) { Word16 i, cnt, tmp16, tmp_e, tmp2_e; +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Word32 L_c, L_acc, L_tmp; +#else + Word64 W_acc; + Word32 L_tmp; +#endif #ifdef BASOP_NOGLOB_DECLARE_LOCAL +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Flag Overflow = 0; Flag Carry = 0; +#endif #endif move16(); move16(); +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Carry = 0; move16(); Overflow = 0; @@ -91,21 +120,32 @@ static void calcGainc2_fx( Word16 *exc, Word16 Q_exc, Word16 L_subfr /*Q0*/, Wor L_c = L_deposit_l( 0 ); L_acc = L_deposit_l( 0 ); +#else + W_acc = 0; +#endif cnt = shl( L_subfr, 1 ); FOR( i = 0; i < cnt; i++ ) { /* *gainc += ( exc[i-2*L_subfr] ) * ( exc[i-2*L_subfr]); */ +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW L_acc = L_macNs_co( L_acc, exc[( i - ( L_subfr * 2 ) )] /*Q1*/, exc[( i - ( L_subfr * 2 ) )] /*Q1*/, &Carry, &Overflow ); /*Q3*/ Overflow = 0; move16(); L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); /* Accumulate Carrys Q-1*/ Carry = 0; move16(); +#else + W_acc = W_mac_16_16( W_acc, exc[( i - ( L_subfr * 2 ) )] /*Q1*/, exc[( i - ( L_subfr * 2 ) )] /*Q1*/); /*Q3*/ +#endif } +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW L_tmp = norm_llQ31( L_c, L_acc, &tmp_e ); /*Q3,norm,tmp_e*/ +#else + L_tmp = w_norm_llQ31( W_acc, &tmp_e ); /*Q3,norm,tmp_e*/ +#endif tmp_e = add( tmp_e, sub( 31, ( add( shl( Q_exc, 1 ), 1 ) ) ) ); /*L_tmp is Q31, now*/ tmp16 = BASOP_Util_Divide3216_Scale( L_tmp /*Q31,norm,tmp_e*/, shl( L_subfr, 1 ) /*Q15,15*/, &tmp2_e ) /*Q15,tmp2_e+tmp_e-15*/; tmp_e = sub( add( tmp2_e, tmp_e ), 15 ); -- GitLab From 9bbde24863fc50e9df2add613122a87c79fca34b Mon Sep 17 00:00:00 2001 From: gerstack Date: Tue, 26 Aug 2025 11:47:25 +0200 Subject: [PATCH 02/33] issue _1965_ fix --- lib_dec/er_dec_tcx_fx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index eb3460bba..def5c4038 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -77,9 +77,9 @@ static void calcGainc_fx( Word16 *exc, Word16 Q_exc, Word32 old_fpitch /*Q16*/, #endif } #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW - L_tmp = norm_llQ31( L_c, L_acc, &tmp_e ); /*Q3,norm,tmp_e*/ + L_tmp = norm_llQ31( L_c, L_acc, &tmp_e ); /*Q3,norm,tmp_e*/ #else - L_tmp = w_norm_llQ31( W_acc, &tmp_e ); /*Q3,norm,tmp_e*/ + L_tmp = w_norm_llQ31( W_acc, &tmp_e ); /*Q3,norm,tmp_e*/ #endif tmp_e = add( tmp_e, 31 - ( add( shl( Q_exc, 1 ), 1 ) ) ); /*L_tmp is Q31, now*/ tmp16 = BASOP_Util_Divide3216_Scale( L_tmp /*Q31,norm,tmp_e*/, shl( L_subfr, 1 ) /*Q15,15*/, &tmp2_e ) /*Q15,tmp2_e+tmp_e-15*/; @@ -137,14 +137,14 @@ static void calcGainc2_fx( Word16 *exc, Word16 Q_exc, Word16 L_subfr /*Q0*/, Wor Carry = 0; move16(); #else - W_acc = W_mac_16_16( W_acc, exc[( i - ( L_subfr * 2 ) )] /*Q1*/, exc[( i - ( L_subfr * 2 ) )] /*Q1*/); /*Q3*/ + W_acc = W_mac_16_16( W_acc, exc[( i - ( L_subfr * 2 ) )] /*Q1*/, exc[( i - ( L_subfr * 2 ) )] /*Q1*/ ); /*Q3*/ #endif } #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW - L_tmp = norm_llQ31( L_c, L_acc, &tmp_e ); /*Q3,norm,tmp_e*/ + L_tmp = norm_llQ31( L_c, L_acc, &tmp_e ); /*Q3,norm,tmp_e*/ #else - L_tmp = w_norm_llQ31( W_acc, &tmp_e ); /*Q3,norm,tmp_e*/ + L_tmp = w_norm_llQ31( W_acc, &tmp_e ); /*Q3,norm,tmp_e*/ #endif tmp_e = add( tmp_e, sub( 31, ( add( shl( Q_exc, 1 ), 1 ) ) ) ); /*L_tmp is Q31, now*/ tmp16 = BASOP_Util_Divide3216_Scale( L_tmp /*Q31,norm,tmp_e*/, shl( L_subfr, 1 ) /*Q15,15*/, &tmp2_e ) /*Q15,tmp2_e+tmp_e-15*/; -- GitLab From 00bdb3d905f91d126c87ae2ef6eb3fa501ff2011 Mon Sep 17 00:00:00 2001 From: gerstack Date: Tue, 26 Aug 2025 12:17:43 +0200 Subject: [PATCH 03/33] issue _1965_ fix --- lib_com/options.h | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_com/options.h b/lib_com/options.h index 933e8f6b4..f32576da1 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -81,6 +81,7 @@ #define FIX_1917_DIRAC_RENDER_PTR_INCR /* FhG: fix wrong pointer increment in ivas_dirac_dec_render_sf_fx() for object rendering */ #define FIX_CDLFB_BUFFER_SCALING /* FhG: fix wrong buffer scaling in ivas_dirac_dec_render_sf_fx() for object rendering */ #define FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 1931 */ +#define FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 1931 */ #define NONBE_SVD_OPTIMIZATION /* FhG: reduce WMOPS of HouseHolderReduction() in ivas_svd_dec.c() by removing redundant mathematics and using 64 bit additions */ #define FIX_1766_TCX2ACELP_BWE_ISSUE /* VA : Fix rare BWE issue when switching from TCX to ACELP */ #define FIX_1781_SPECTRAL_GAPS /* FhG: Change internal calculation of tcx_noise_factor_ivas_fx() to 32-bit*/ -- GitLab From 9951e418805326e8292418479f08551c62998901 Mon Sep 17 00:00:00 2001 From: gerstack Date: Tue, 26 Aug 2025 13:08:18 +0200 Subject: [PATCH 04/33] issue _1965_ fix --- lib_dec/igf_dec_fx.c | 43 +++++++++++++++++++++---------------------- lib_enc/igf_enc_fx.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 22 deletions(-) diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index 2b1d207d3..c6a6f1bf3 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -1482,11 +1482,15 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in Word16 dS[IGF_MAX_SFB]; Word16 dS_e[IGF_MAX_SFB]; Word32 energyTmp[24]; +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Word32 L_c; +#endif Word16 Hr; #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Flag Carry = 0; +#endif move16(); move16(); #endif @@ -1565,6 +1569,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in &dE_e, negate( tmp ) ); +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW L_c = 0; move32(); FOR( tb = 0; tb < 24; tb++ ) @@ -1577,6 +1582,20 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); } L_tmp = norm_llQ31( L_c, L_tmp, &shift ); // Q31 +#else + { +#if 0 + Word16 shift2=shift; + + Word32 L_tmp2 = sum_array_norm(energyTmp, 24, &shift2); + if (L_tmp != L_tmp2 || shift != shift2) { + fprintf(stderr, "%s:%d: 0x%08X, %d, 0x%08X, %d\n", __FILE__,__LINE__, L_tmp,shift, L_tmp2,shift2); + } +#else + L_tmp = sum_array_norm(energyTmp, 24, &shift); +#endif + } +#endif /* float: dE = (float)sqrt(dE / 24.f); basop: */ shift = add( sub( shift, 4 ), dE_e ); /* x/24 = (x >> 4) * 1/1.5 */ dE = Sqrt16norm( extract_h( L_tmp ), &shift ); @@ -1884,12 +1903,8 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in sum = shl( sum, shift ); /* exponent of sum: sub(15, shift) */ /* divide E by sum */ -#ifdef ISSUE_1866_replace_overflow_libdec - tmp = div_s( shr( round_fx_sat( E ), 1 ), sum ); /* shift E 1 bit to the right in order to make it smaller than sum */ -#else tmp = div_s( shr( round_fx_o( E, &Overflow ), 1 ), sum ); /* shift E 1 bit to the right in order to make it smaller than sum */ -#endif - tmp_e = sub( add( E_e, 1 ), sub( 15, shift ) ); /* 15Q0 | sum is 15Q0 */ + tmp_e = sub( add( E_e, 1 ), sub( 15, shift ) ); /* 15Q0 | sum is 15Q0 */ /* multiply the result by the hopsize */ L_tmp = L_mult( tmp, hopsize ); @@ -2575,12 +2590,8 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in sum = shl( sum, shift ); /* exponent of sum: sub(15, shift) */ /* divide E by sum */ -#ifdef ISSUE_1866_replace_overflow_libdec - tmp = div_s( shr( round_fx_sat( E ), 1 ), sum ); /* shift E 1 bit to the right in order to make it smaller than sum */ -#else tmp = div_s( shr( round_fx_o( E, &Overflow ), 1 ), sum ); /* shift E 1 bit to the right in order to make it smaller than sum */ -#endif - tmp_e = sub( add( E_e, 1 ), sub( 15, shift ) ); /* 15Q0 | sum is 15Q0 */ + tmp_e = sub( add( E_e, 1 ), sub( 15, shift ) ); /* 15Q0 | sum is 15Q0 */ /* multiply the result by the hopsize */ L_tmp = L_mult( tmp, hopsize ); @@ -2983,11 +2994,9 @@ static void IGF_RefineGrid( H_IGF_GRID hGrid /**< in Word16 sfb; Word16 tmp; Word16 delta; -#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); -#endif #endif set16_fx( a, 0, IGF_MAX_SFB + 1 ); @@ -3002,11 +3011,7 @@ static void IGF_RefineGrid( H_IGF_GRID hGrid /**< in move16(); tmp = add( tmp, 1 ); delta = sub( hGrid->swb_offset[sfb + 1], hGrid->swb_offset[sfb] ); -#ifdef ISSUE_1866_replace_overflow_libdec - delta = mac_r( 0x00195000, 29491 /*0.45f Q16*/, shl_sat( delta, 5 ) ); -#else delta = mac_r( 0x00195000, 29491 /*0.45f Q16*/, shl_o( delta, 5, &Overflow ) ); -#endif a[tmp] = add( hGrid->swb_offset[sfb], shr( delta, 6 ) ); move16(); IF( s_and( a[tmp], 1 ) != 0 ) @@ -3037,11 +3042,9 @@ static void IGF_RefineGrid_ivas_fx( H_IGF_GRID hGrid /**< in/out: | IGF grid han Word16 sfb; Word16 tmp; Word16 delta; -#ifndef ISSUE_1866_replace_overflow_libdec #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move16(); -#endif #endif set16_fx( a, 0, IGF_MAX_SFB + 1 ); @@ -3056,11 +3059,7 @@ static void IGF_RefineGrid_ivas_fx( H_IGF_GRID hGrid /**< in/out: | IGF grid han move16(); tmp = add( tmp, 1 ); delta = sub( hGrid->swb_offset[sfb + 1], hGrid->swb_offset[sfb] ); -#ifdef ISSUE_1796_replace_shl_o - delta = mac_r( 0x00195000, 29491 /*0.45f Q16*/, shl_sat( delta, 5 ) ); -#else delta = mac_r( 0x00195000, 29491 /*0.45f Q16*/, shl_o( delta, 5, &Overflow ) ); -#endif a[tmp] = add( hGrid->swb_offset[sfb], shr( delta, 6 ) ); move16(); // Rounding off delta values >=t+0.5 to t+1 diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index c57f5ffb0..48d64ead1 100644 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -355,10 +355,16 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou Word16 i; Word16 igfBgn; Word16 igfEnd; +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Word32 highPassEner; /* Q31 */ +#else + Word64 highPassEner; +#endif Word32 lastLine; Word32 nextLine; +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Word32 L_c; +#endif Word32 highPassEner_Ovfl; Word16 s; Word16 tmploop; @@ -374,7 +380,9 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Flag Carry = 0; +#endif move32(); move32(); #endif @@ -409,19 +417,30 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou IF( igfBgn > 0 ) { +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW L_c = 0; +#endif move32(); FOR( i = 0; i < igfBgn; i++ ) { +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Carry = 0; move32(); highPassEner = L_add_co( highPassEner, Mpy_32_16_1( pPowerSpectrum[i], shl( i, 4 ) /*Q4*/ ) /*Q20, pPowerSpectrum_exp*/, &Carry, &Overflow ); Overflow = 0; move32(); L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); +#else + move32(); + highPassEner = W_add( highPassEner, Mpy_32_16_1( pPowerSpectrum[i], shl( i, 4 ) /*Q4*/ ) /*Q20, pPowerSpectrum_exp*/ ); +#endif } +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW highPassEner = norm_llQ31( L_c, highPassEner, highPassEner_exp ); /*Q20, highPassEner_exp*/ +#else + highPassEner = w_norm_llQ31( highPassEner, highPassEner_exp ); /*Q20, highPassEner_exp*/ +#endif *highPassEner_exp = add( *highPassEner_exp, pPowerSpectrum_exp ); move16(); test(); @@ -875,21 +894,31 @@ Word16 IGF_getSFM( /**< out: Q15| SFM value { Word16 n, i, s; Word32 num; +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Word32 denom; +#else + Word64 denom; +#endif Word16 denom_exp; Word16 invDenom_exp, numf_exp; Word16 numf; Word32 SFM32; +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Word32 L_c; +#endif Word16 invDenom, SFM; #ifdef BASOP_NOGLOB_DECLARE_LOCAL +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Flag Overflow = 0; Flag Carry = 0; +#endif move32(); move32(); #endif +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW L_c = 0; +#endif move32(); num = 0; move32(); @@ -919,15 +948,23 @@ Word16 IGF_getSFM( /**< out: Q15| SFM value n = s_max( 0, n ); num = L_add( num, L_deposit_l( n ) ); /*Q0*/ +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Carry = 0; move32(); denom = L_add_co( energy[i], denom, &Carry, &Overflow ); Overflow = 0; move32(); L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); +#else + denom = W_add( energy[i], denom ); +#endif } +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW denom = norm_llQ31( L_c, denom, &denom_exp ); /*Q31*/ +#else + denom = w_norm_llQ31(denom, &denom_exp ); /*Q31*/ +#endif denom_exp = add( denom_exp, *energy_exp ); /* calculate SFM only if signal is present */ -- GitLab From ee2926340579d7245b3ad26457017e08ba389b81 Mon Sep 17 00:00:00 2001 From: gerstack Date: Tue, 26 Aug 2025 13:14:42 +0200 Subject: [PATCH 05/33] issue _1965_ fix clang-format --- lib_dec/igf_dec_fx.c | 2 +- lib_enc/igf_enc_fx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index c6a6f1bf3..fa2ae6301 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -1592,7 +1592,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in fprintf(stderr, "%s:%d: 0x%08X, %d, 0x%08X, %d\n", __FILE__,__LINE__, L_tmp,shift, L_tmp2,shift2); } #else - L_tmp = sum_array_norm(energyTmp, 24, &shift); + L_tmp = sum_array_norm( energyTmp, 24, &shift ); #endif } #endif diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index 48d64ead1..82dece835 100644 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -963,7 +963,7 @@ Word16 IGF_getSFM( /**< out: Q15| SFM value #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW denom = norm_llQ31( L_c, denom, &denom_exp ); /*Q31*/ #else - denom = w_norm_llQ31(denom, &denom_exp ); /*Q31*/ + denom = w_norm_llQ31( denom, &denom_exp ); /*Q31*/ #endif denom_exp = add( denom_exp, *energy_exp ); -- GitLab From 5c0879099cbe65fd92c4252a55507623a0fbd733 Mon Sep 17 00:00:00 2001 From: gerstack Date: Tue, 26 Aug 2025 13:35:46 +0200 Subject: [PATCH 06/33] issue _1965_ fix --- lib_com/options.h | 2 +- lib_dec/arith_coder_dec_fx.c | 8 +++++++- lib_enc/arith_coder_enc_fx.c | 6 ++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index f32576da1..ecf5cbcf4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -81,7 +81,7 @@ #define FIX_1917_DIRAC_RENDER_PTR_INCR /* FhG: fix wrong pointer increment in ivas_dirac_dec_render_sf_fx() for object rendering */ #define FIX_CDLFB_BUFFER_SCALING /* FhG: fix wrong buffer scaling in ivas_dirac_dec_render_sf_fx() for object rendering */ #define FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 1931 */ -#define FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 1931 */ +#define FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 2166 */ #define NONBE_SVD_OPTIMIZATION /* FhG: reduce WMOPS of HouseHolderReduction() in ivas_svd_dec.c() by removing redundant mathematics and using 64 bit additions */ #define FIX_1766_TCX2ACELP_BWE_ISSUE /* VA : Fix rare BWE issue when switching from TCX to ACELP */ #define FIX_1781_SPECTRAL_GAPS /* FhG: Change internal calculation of tcx_noise_factor_ivas_fx() to 32-bit*/ diff --git a/lib_dec/arith_coder_dec_fx.c b/lib_dec/arith_coder_dec_fx.c index 60a59c4da..8419f8641 100644 --- a/lib_dec/arith_coder_dec_fx.c +++ b/lib_dec/arith_coder_dec_fx.c @@ -29,9 +29,11 @@ static Word16 tcx_arith_decode_fx( Word16 tmp; Word32 L_tmp, Q; #ifdef BASOP_NOGLOB_DECLARE_LOCAL +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOWxxx Flag Overflow = 0; move32(); - Flag Carry = 0; + Flag Carry = 0; //not done +#endif move32(); #endif @@ -63,7 +65,11 @@ static Word16 tcx_arith_decode_fx( { bp = ari_decode_14bits_sign_fx( prm, bp, target_bits, &s, &as ); +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOWxxx L_tmp = L_macNs_co( L_tmp, q, k, &Carry, &Overflow ); +#else + L_tmp = L_macNs_sat( L_tmp, q, k ); +#endif Q = L_mult( q, negate( shl( 1, sub( 30, SPEC_EXP_DEC ) ) ) ); IF( EQ_16( s, 0 ) ) diff --git a/lib_enc/arith_coder_enc_fx.c b/lib_enc/arith_coder_enc_fx.c index 2e88b1f00..76d384570 100644 --- a/lib_enc/arith_coder_enc_fx.c +++ b/lib_enc/arith_coder_enc_fx.c @@ -702,10 +702,12 @@ void tcx_arith_encode_envelope_fx( Word16 tmp; TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; #ifdef BASOP_NOGLOB_DECLARE_LOCAL +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Flag Overflow = 0; Flag Carry = 0; move32(); move32(); +#endif #endif assert( L_spec <= N_MAX_ARI ); @@ -793,7 +795,11 @@ void tcx_arith_encode_envelope_fx( L_tmp2 = L_deposit_l( 0 ); FOR( k = 0; k <= kMax; k++ ) { +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW L_tmp2 = L_macNs_co( L_tmp2, q_spectrum[k], k, &Carry, &Overflow ); +#else + L_tmp2 = L_macNs_sat( L_tmp2, q_spectrum[k], k ); +#endif if ( signs[k] != 0 ) L_tmp = L_mult( q_spectrum[k], -( 1 << ( 30 - SPEC_EXP_DEC ) ) ); -- GitLab From 3ad96d7bd4c41535420c9f751fc89a6cda01d42c Mon Sep 17 00:00:00 2001 From: gerstack Date: Tue, 26 Aug 2025 13:49:28 +0200 Subject: [PATCH 07/33] issue _1965_ fix clang-format --- lib_dec/arith_coder_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/arith_coder_dec_fx.c b/lib_dec/arith_coder_dec_fx.c index 8419f8641..eaa1f7c40 100644 --- a/lib_dec/arith_coder_dec_fx.c +++ b/lib_dec/arith_coder_dec_fx.c @@ -32,7 +32,7 @@ static Word16 tcx_arith_decode_fx( #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOWxxx Flag Overflow = 0; move32(); - Flag Carry = 0; //not done + Flag Carry = 0; // not done #endif move32(); #endif -- GitLab From b7e5f8327efa3bb8590260bde28ea21a8025e3b9 Mon Sep 17 00:00:00 2001 From: gerstack Date: Tue, 26 Aug 2025 14:21:50 +0200 Subject: [PATCH 08/33] issue _1965_ fix --- lib_com/igf_base_fx.c | 26 +++++++++++++++++++++++++- lib_dec/arith_coder_dec_fx.c | 4 ++-- lib_enc/cod_tcx_fx.c | 12 ++++++++++++ lib_enc/enc_acelp_fx.c | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+), 3 deletions(-) diff --git a/lib_com/igf_base_fx.c b/lib_com/igf_base_fx.c index 44cf27c5f..f9562d971 100644 --- a/lib_com/igf_base_fx.c +++ b/lib_com/igf_base_fx.c @@ -1115,21 +1115,27 @@ void IGFCommonFuncsCalcSfbEnergyPowerSpec( const Word16 startSfb, /**< in ) { Word16 /*Q0*/ sfb; +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Word16 /*Q0*/ line; Word32 L_c; +#endif #ifdef BASOP_NOGLOB_DECLARE_LOCAL +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Flag Overflow = 0; - Flag Carry = 0; + Flag Carry = 0; //done +#endif move16(); move16(); #endif +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW FOR( sfb = startSfb; sfb < stopSfb; sfb++ ) { sfbEnergy[sfb] = L_deposit_l( 0 ); move32(); } +#endif IF( NULL == pPowerSpectrum ) { return; @@ -1137,6 +1143,7 @@ void IGFCommonFuncsCalcSfbEnergyPowerSpec( const Word16 startSfb, /**< in FOR( sfb = startSfb; sfb < stopSfb; sfb++ ) { +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW L_c = L_deposit_l( 0 ); FOR( line = swb_offset[sfb]; line < swb_offset[sfb + 1]; line++ ) { @@ -1150,6 +1157,23 @@ void IGFCommonFuncsCalcSfbEnergyPowerSpec( const Word16 startSfb, /**< in } sfbEnergy[sfb] = norm_llQ31( L_c, sfbEnergy[sfb], &( sfbEnergy_exp[sfb] ) ); move32(); +#else +#if 0 + Word16 sfbEnergy2_exp = 0; + Word32 sfbEnergy2 = sum_array_norm(pPowerSpectrum + swb_offset[sfb], + swb_offset[sfb + 1] - swb_offset[sfb], + &( sfbEnergy2_exp )); + if ( sfbEnergy[sfb] != sfbEnergy2 || sfbEnergy_exp[sfb] != sfbEnergy2_exp ) { + fprintf(stderr, "ERROR %s:%d: 0x%08X 0x%08X %d %d\n", __FILE__,__LINE__, + sfbEnergy[sfb], sfbEnergy2, sfbEnergy_exp[sfb], sfbEnergy2_exp ); + + } +#else + sfbEnergy[sfb] = sum_array_norm(pPowerSpectrum + swb_offset[sfb], + swb_offset[sfb + 1] - swb_offset[sfb], + &( sfbEnergy_exp[sfb] )); +#endif +#endif sfbEnergy_exp[sfb] = add( sfbEnergy_exp[sfb], *pPowerSpectrum_exp ); move16(); } diff --git a/lib_dec/arith_coder_dec_fx.c b/lib_dec/arith_coder_dec_fx.c index eaa1f7c40..206cbfde0 100644 --- a/lib_dec/arith_coder_dec_fx.c +++ b/lib_dec/arith_coder_dec_fx.c @@ -29,7 +29,7 @@ static Word16 tcx_arith_decode_fx( Word16 tmp; Word32 L_tmp, Q; #ifdef BASOP_NOGLOB_DECLARE_LOCAL -#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOWxxx +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Flag Overflow = 0; move32(); Flag Carry = 0; // not done @@ -65,7 +65,7 @@ static Word16 tcx_arith_decode_fx( { bp = ari_decode_14bits_sign_fx( prm, bp, target_bits, &s, &as ); -#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOWxxx +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW L_tmp = L_macNs_co( L_tmp, q, k, &Carry, &Overflow ); #else L_tmp = L_macNs_sat( L_tmp, q, k ); diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index c598af538..7c83af996 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -1274,8 +1274,10 @@ void QuantizeSpectrum_fx( CONTEXT_HM_CONFIG *phm_cfg; TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; #ifdef BASOP_NOGLOB_DECLARE_LOCAL +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Flag Overflow = 0; Flag Carry = 0; +#endif #endif /* Stack memory is split between encoder and internal decoder to reduce max @@ -1852,7 +1854,11 @@ void QuantizeSpectrum_fx( spectrum[i] = L_mult( sqQ[i], 1 << ( 30 - SPEC_EXP_DEC ) ); move32(); /* noise filling seed */ +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW tmp32 = L_macNs_co( tmp32, abs_s( sqQ[i] ), i, &Carry, &Overflow ); +#else + tmp32 = L_macNs_sat( tmp32, abs_s( sqQ[i] ), i ); +#endif } *spectrum_e = SPEC_EXP_DEC; move16(); @@ -2912,10 +2918,12 @@ void QuantizeTCXSpectrum_fx( Word16 att_fx = 0; move16(); #ifdef BASOP_NOGLOB_DECLARE_LOCAL +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Flag Overflow = 0; move16(); Flag Carry = 0; move16(); +#endif #endif /*-----------------------------------------------------------* * Init * @@ -3543,7 +3551,11 @@ void QuantizeTCXSpectrum_fx( spectrum_fx[i] = L_mult( sqQ[i], 1 << ( 30 - SPEC_EXP_DEC ) ); move32(); /* noise filling seed */ +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW tmp32 = L_macNs_co( tmp32, abs_s( sqQ[i] ), i, &Carry, &Overflow ); +#else + tmp32 = L_macNs_sat( tmp32, abs_s( sqQ[i] ), i ); +#endif } *spectrum_e = SPEC_EXP_DEC; move16(); diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index e9feb81d3..567614e11 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -2358,10 +2358,16 @@ static void E_ACELP_codearithp_fx( const Word16 v[] /*Q9*/, UWord32 *n /*Q0*/, U { Word16 k, nb_pulse, i, t, pos[NPMAXPT], posno; Word16 sign, m; +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW UWord32 s; +#else + UWord64 s; +#endif #ifdef BASOP_NOGLOB_DECLARE_LOCAL +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Flag Overflow = 0; Flag Carry = 0; +#endif move32(); move32(); #endif @@ -2387,7 +2393,11 @@ static void E_ACELP_codearithp_fx( const Word16 v[] /*Q9*/, UWord32 *n /*Q0*/, U } /* Iterate over the different pulse positions */ +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW s = L_deposit_l( 0 ); +#else + s= 0; +#endif t = 0; move16(); nb_pulse = 0; @@ -2400,9 +2410,15 @@ static void E_ACELP_codearithp_fx( const Word16 v[] /*Q9*/, UWord32 *n /*Q0*/, U /* Code m-1 pulses */ FOR( i = 1; i < m; ++i ) { +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Carry = 0; +#endif move32(); +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW s = L_add_co( s, pulsestostates[pos[k]][t], &Carry, &Overflow ); +#else + s = W_add( s, pulsestostates[pos[k]][t] ); +#endif t = add( t, 1 ); if ( sub( t, NPMAXPT ) > 0 ) { @@ -2413,18 +2429,34 @@ static void E_ACELP_codearithp_fx( const Word16 v[] /*Q9*/, UWord32 *n /*Q0*/, U /* Code sign */ /* We use L_add_c since we want to work with unsigned UWord32 */ /* Therefore, we have to clear carry */ +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Carry = 0; +#endif move32(); +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW s = L_lshl( s, 1 ); +#else + s = W_lshl( s, 1 ); +#endif if ( sign < 0 ) { +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW s = L_add_co( s, 1, &Carry, &Overflow ); +#else + s = W_add( s, 1 ); +#endif } /* Code last pulse */ +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Carry = 0; +#endif move32(); +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW s = L_add_co( s, pulsestostates[pos[k]][t], &Carry, &Overflow ); +#else + s = W_add( s, pulsestostates[pos[k]][t] ); +#endif t = add( t, 1 ); } -- GitLab From 741f302cf8f047b2cbe8be14a58e24dd25221fc4 Mon Sep 17 00:00:00 2001 From: gerstack Date: Tue, 26 Aug 2025 14:28:46 +0200 Subject: [PATCH 09/33] issue _1965_ fix clang-format --- lib_com/igf_base_fx.c | 8 ++++---- lib_enc/enc_acelp_fx.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_com/igf_base_fx.c b/lib_com/igf_base_fx.c index f9562d971..64081cfce 100644 --- a/lib_com/igf_base_fx.c +++ b/lib_com/igf_base_fx.c @@ -1123,7 +1123,7 @@ void IGFCommonFuncsCalcSfbEnergyPowerSpec( const Word16 startSfb, /**< in #ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Flag Overflow = 0; - Flag Carry = 0; //done + Flag Carry = 0; // done #endif move16(); move16(); @@ -1169,9 +1169,9 @@ void IGFCommonFuncsCalcSfbEnergyPowerSpec( const Word16 startSfb, /**< in } #else - sfbEnergy[sfb] = sum_array_norm(pPowerSpectrum + swb_offset[sfb], - swb_offset[sfb + 1] - swb_offset[sfb], - &( sfbEnergy_exp[sfb] )); + sfbEnergy[sfb] = sum_array_norm( pPowerSpectrum + swb_offset[sfb], + swb_offset[sfb + 1] - swb_offset[sfb], + &( sfbEnergy_exp[sfb] ) ); #endif #endif sfbEnergy_exp[sfb] = add( sfbEnergy_exp[sfb], *pPowerSpectrum_exp ); diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index 567614e11..634e74750 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -2396,7 +2396,7 @@ static void E_ACELP_codearithp_fx( const Word16 v[] /*Q9*/, UWord32 *n /*Q0*/, U #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW s = L_deposit_l( 0 ); #else - s= 0; + s = 0; #endif t = 0; move16(); -- GitLab From c58b336626358ed80277049c5b77f012cbe60441 Mon Sep 17 00:00:00 2001 From: gerstack Date: Wed, 27 Aug 2025 14:50:59 +0200 Subject: [PATCH 10/33] issue _1965_ fix --- lib_com/igf_base_fx.c | 12 ------------ lib_dec/arith_coder_dec_fx.c | 15 +++++++++++++-- lib_dec/igf_dec_fx.c | 9 --------- lib_enc/arith_coder_enc_fx.c | 15 ++++++++++++++- 4 files changed, 27 insertions(+), 24 deletions(-) diff --git a/lib_com/igf_base_fx.c b/lib_com/igf_base_fx.c index 64081cfce..b94abb06d 100644 --- a/lib_com/igf_base_fx.c +++ b/lib_com/igf_base_fx.c @@ -1157,22 +1157,10 @@ void IGFCommonFuncsCalcSfbEnergyPowerSpec( const Word16 startSfb, /**< in } sfbEnergy[sfb] = norm_llQ31( L_c, sfbEnergy[sfb], &( sfbEnergy_exp[sfb] ) ); move32(); -#else -#if 0 - Word16 sfbEnergy2_exp = 0; - Word32 sfbEnergy2 = sum_array_norm(pPowerSpectrum + swb_offset[sfb], - swb_offset[sfb + 1] - swb_offset[sfb], - &( sfbEnergy2_exp )); - if ( sfbEnergy[sfb] != sfbEnergy2 || sfbEnergy_exp[sfb] != sfbEnergy2_exp ) { - fprintf(stderr, "ERROR %s:%d: 0x%08X 0x%08X %d %d\n", __FILE__,__LINE__, - sfbEnergy[sfb], sfbEnergy2, sfbEnergy_exp[sfb], sfbEnergy2_exp ); - - } #else sfbEnergy[sfb] = sum_array_norm( pPowerSpectrum + swb_offset[sfb], swb_offset[sfb + 1] - swb_offset[sfb], &( sfbEnergy_exp[sfb] ) ); -#endif #endif sfbEnergy_exp[sfb] = add( sfbEnergy_exp[sfb], *pPowerSpectrum_exp ); move16(); diff --git a/lib_dec/arith_coder_dec_fx.c b/lib_dec/arith_coder_dec_fx.c index 206cbfde0..785b8beb7 100644 --- a/lib_dec/arith_coder_dec_fx.c +++ b/lib_dec/arith_coder_dec_fx.c @@ -27,12 +27,15 @@ static Word16 tcx_arith_decode_fx( Tastat as; Word16 exp_k; Word16 tmp; - Word32 L_tmp, Q; #ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW + Word32 L_tmp, Q; Flag Overflow = 0; move32(); Flag Carry = 0; // not done +#else + Word32 Q; + Word64 W_tmp; #endif move32(); #endif @@ -41,7 +44,11 @@ static Word16 tcx_arith_decode_fx( bp = ari_start_decoding_14bits_prm_fx( prm, 0, &as ); tmp = sub( envelope_e, 1 + 15 ); +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW L_tmp = L_deposit_l( 0 ); +#else + W_tmp = 0; +#endif FOR( k = 0; k < L_frame; k++ ) { IF( envelope[k] == 0 ) /* safety check in case of bit errors */ @@ -68,7 +75,7 @@ static Word16 tcx_arith_decode_fx( #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW L_tmp = L_macNs_co( L_tmp, q, k, &Carry, &Overflow ); #else - L_tmp = L_macNs_sat( L_tmp, q, k ); + W_tmp = W_mac_16_16( W_tmp, q, k ); #endif Q = L_mult( q, negate( shl( 1, sub( 30, SPEC_EXP_DEC ) ) ) ); @@ -94,7 +101,11 @@ static Word16 tcx_arith_decode_fx( set32_fx( q_spectrum + k, 0, sub( L_frame, k ) ); /* noise filling seed */ +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW *nf_seed = extract_l( L_tmp ); +#else + *nf_seed = extract_l( (Word32)W_tmp ); +#endif move16(); return bp; diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index edd0546f9..58442c635 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -1584,16 +1584,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in L_tmp = norm_llQ31( L_c, L_tmp, &shift ); // Q31 #else { -#if 0 - Word16 shift2=shift; - - Word32 L_tmp2 = sum_array_norm(energyTmp, 24, &shift2); - if (L_tmp != L_tmp2 || shift != shift2) { - fprintf(stderr, "%s:%d: 0x%08X, %d, 0x%08X, %d\n", __FILE__,__LINE__, L_tmp,shift, L_tmp2,shift2); - } -#else L_tmp = sum_array_norm( energyTmp, 24, &shift ); -#endif } #endif /* float: dE = (float)sqrt(dE / 24.f); basop: */ diff --git a/lib_enc/arith_coder_enc_fx.c b/lib_enc/arith_coder_enc_fx.c index cffe0be2c..9d5a3b974 100644 --- a/lib_enc/arith_coder_enc_fx.c +++ b/lib_enc/arith_coder_enc_fx.c @@ -676,7 +676,12 @@ void tcx_arith_encode_envelope_fx( const Word8 *deadzone_flags; Word16 gamma_w, gamma_uw; Word16 hm_bits; +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Word32 L_tmp, L_tmp2; +#else + Word32 L_tmp; + Word64 W_tmp2; +#endif Word16 tmp; TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; #ifdef BASOP_NOGLOB_DECLARE_LOCAL @@ -770,13 +775,17 @@ void tcx_arith_encode_envelope_fx( move16(); /* Multiply back the signs */ +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW L_tmp2 = L_deposit_l( 0 ); +#else + W_tmp2 = 0; +#endif FOR( k = 0; k <= kMax; k++ ) { #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW L_tmp2 = L_macNs_co( L_tmp2, q_spectrum[k], k, &Carry, &Overflow ); #else - L_tmp2 = L_macNs_sat( L_tmp2, q_spectrum[k], k ); + W_tmp2 = W_mac_16_16( W_tmp2, q_spectrum[k], k ); #endif if ( signs[k] != 0 ) @@ -791,7 +800,11 @@ void tcx_arith_encode_envelope_fx( set32_fx( spectrum + k, 0, sub( s_max( L_frame, L_spec ), k ) ); /* noise filling seed */ +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW *nf_seed = extract_l( L_tmp2 ); +#else + *nf_seed = extract_l( (Word32)W_tmp2 ); +#endif move16(); } -- GitLab From 3591cbb07973e1badc2f6afb4d3405b53b07dba9 Mon Sep 17 00:00:00 2001 From: gerstack Date: Wed, 27 Aug 2025 15:22:50 +0200 Subject: [PATCH 11/33] issue _1965_ fix clang-format --- lib_dec/arith_coder_dec_fx.c | 2 +- lib_enc/arith_coder_enc_fx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/arith_coder_dec_fx.c b/lib_dec/arith_coder_dec_fx.c index 785b8beb7..b1e379f26 100644 --- a/lib_dec/arith_coder_dec_fx.c +++ b/lib_dec/arith_coder_dec_fx.c @@ -104,7 +104,7 @@ static Word16 tcx_arith_decode_fx( #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW *nf_seed = extract_l( L_tmp ); #else - *nf_seed = extract_l( (Word32)W_tmp ); + *nf_seed = extract_l( (Word32) W_tmp ); #endif move16(); diff --git a/lib_enc/arith_coder_enc_fx.c b/lib_enc/arith_coder_enc_fx.c index 9d5a3b974..8c4cdabe8 100644 --- a/lib_enc/arith_coder_enc_fx.c +++ b/lib_enc/arith_coder_enc_fx.c @@ -803,7 +803,7 @@ void tcx_arith_encode_envelope_fx( #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW *nf_seed = extract_l( L_tmp2 ); #else - *nf_seed = extract_l( (Word32)W_tmp2 ); + *nf_seed = extract_l( (Word32) W_tmp2 ); #endif move16(); } -- GitLab From 29f3f339eb1637b6bcc4c3afab47c1452e6bf4bf Mon Sep 17 00:00:00 2001 From: gerstack Date: Wed, 27 Aug 2025 15:40:03 +0200 Subject: [PATCH 12/33] issue _1965_ fix --- lib_dec/igf_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index 58442c635..af998244f 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -1487,8 +1487,8 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in #endif Word16 Hr; #ifdef BASOP_NOGLOB_DECLARE_LOCAL - Flag Overflow = 0; #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW + Flag Overflow = 0; Flag Carry = 0; #endif move16(); -- GitLab From 68b30036704448064441d10f7edf3b692ed85d59 Mon Sep 17 00:00:00 2001 From: gerstack Date: Wed, 27 Aug 2025 15:54:28 +0200 Subject: [PATCH 13/33] issue _1965_ fix --- lib_dec/er_dec_tcx_fx.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib_dec/er_dec_tcx_fx.c b/lib_dec/er_dec_tcx_fx.c index 55a3770ff..091b5ee5d 100644 --- a/lib_dec/er_dec_tcx_fx.c +++ b/lib_dec/er_dec_tcx_fx.c @@ -57,7 +57,6 @@ static void calcGainc_fx( Word16 *exc, Word16 Q_exc, Word32 old_fpitch /*Q16*/, /*st->lp_gainc += ( exc[i-2*L_subfr] - st->Mode2_lp_gainp * exc[i-2*L_subfr-(int)(st->old_fpitch+0.5f)] ) * ( exc[i-2*L_subfr] - st->Mode2_lp_gainp * exc[i-2*L_subfr-(int)(st->old_fpitch+0.5f)] );*/ tmp16_3 = sub_sat( exc[( i - ( L_subfr * 2 ) )] /*Q1*/, mult_r( tmp16_2 /*Q15*/, exc[( ( i - ( L_subfr * 2 ) ) - tmp16 )] /*Q1*/ ) /*Q1*/ ); -#endif #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW L_acc = L_macNs_co( L_acc, tmp16_3, tmp16_3, &Carry, &Overflow ); /*Q3*/ Overflow = 0; -- GitLab From 99f0ed6911ea39fbe3d0b2eedf9e3e1516d28251 Mon Sep 17 00:00:00 2001 From: gerstack Date: Thu, 28 Aug 2025 10:20:06 +0200 Subject: [PATCH 14/33] issue _1965_ fix --- lib_com/basop_util.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index ec6c89896..089d53119 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -2079,22 +2079,33 @@ Word32 norm_llQ31( /* o : normalized result Q31 */ ) { Word16 i; +#ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW + Word64 W_tmp; +#else Word32 L_tmp; +#endif #ifdef BASOP_NOGLOB_DECLARE_LOCAL -#ifndef ISSUE_1836_replace_overflow_libcom +#if !defined( ISSUE_1836_replace_overflow_libcom ) && !defined( FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW ) Flag Overflow = 0; #endif +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Flag Carry = 0; +#endif #endif /* BASOP_NOGLOB */ /* Move MSBit of L_sum into L_c */ +#ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW + W_tmp = W_add( L_sum, L_sum ); /* W_tmp = L_sum << 1 */ + L_c = L_add( L_add( L_c, L_c ), W_extract_h(W_tmp) ); +#else + #ifdef ISSUE_1836_replace_overflow_libcom Carry = 0; -#ifdef ISSUE_1836_replace_overflow_libcom L_tmp = L_add_c( L_sum, L_sum, &Carry ); /* L_tmp = L_sum << 1 */ L_c = L_add_c( L_c, L_c, &Carry ); -#else + #else L_tmp = L_add_co( L_sum, L_sum, &Carry, &Overflow ); /* L_tmp = L_sum << 1 */ L_c = L_add_co( L_c, L_c, &Carry, &Overflow ); + #endif #endif L_add( 0, 0 ); test(); @@ -2103,9 +2114,14 @@ Word32 norm_llQ31( /* o : normalized result Q31 */ i = norm_l( L_c ); L_c = L_shl( L_c, i ); i = sub( 31, i ); /* positive exponent */ +#ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW + L_sum = W_lshr( W_tmp, 1 ); /* L_sum with MSBit=0 */ + L_sum = L_lshr( L_sum, i ); +#else L_sum = L_lshr( L_tmp, 1 ); /* L_sum with MSBit=0 */ L_sum = L_lshr( L_sum, i ); L_sum = L_add( L_c, L_sum ); +#endif } ELSE { -- GitLab From 918483f9b26b417ad42190742c6c7fe1044418fa Mon Sep 17 00:00:00 2001 From: gerstack Date: Thu, 28 Aug 2025 10:37:51 +0200 Subject: [PATCH 15/33] issue _1965_ fix clang-format --- lib_com/basop_util.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index 089d53119..8f9b71e8a 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -2096,16 +2096,16 @@ Word32 norm_llQ31( /* o : normalized result Q31 */ /* Move MSBit of L_sum into L_c */ #ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW W_tmp = W_add( L_sum, L_sum ); /* W_tmp = L_sum << 1 */ - L_c = L_add( L_add( L_c, L_c ), W_extract_h(W_tmp) ); + L_c = L_add( L_add( L_c, L_c ), W_extract_h( W_tmp ) ); #else - #ifdef ISSUE_1836_replace_overflow_libcom +#ifdef ISSUE_1836_replace_overflow_libcom Carry = 0; L_tmp = L_add_c( L_sum, L_sum, &Carry ); /* L_tmp = L_sum << 1 */ L_c = L_add_c( L_c, L_c, &Carry ); - #else +#else L_tmp = L_add_co( L_sum, L_sum, &Carry, &Overflow ); /* L_tmp = L_sum << 1 */ L_c = L_add_co( L_c, L_c, &Carry, &Overflow ); - #endif +#endif #endif L_add( 0, 0 ); test(); @@ -2113,7 +2113,7 @@ Word32 norm_llQ31( /* o : normalized result Q31 */ { i = norm_l( L_c ); L_c = L_shl( L_c, i ); - i = sub( 31, i ); /* positive exponent */ + i = sub( 31, i ); /* positive exponent */ #ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW L_sum = W_lshr( W_tmp, 1 ); /* L_sum with MSBit=0 */ L_sum = L_lshr( L_sum, i ); -- GitLab From 788eaa26ee6a5cb30a470c5d2b53440ffd63e8aa Mon Sep 17 00:00:00 2001 From: gerstack Date: Thu, 28 Aug 2025 11:16:53 +0200 Subject: [PATCH 16/33] issue _1965_ fix --- lib_com/basop_util.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index 8f9b71e8a..9a791deec 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -2078,6 +2078,10 @@ Word32 norm_llQ31( /* o : normalized result Q31 */ Word16 *exp /* o : exponent of result in [-32,31] Q0 */ ) { +#ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW + L_sum =w_norm_llQ31( (Word64)L_c<<32 | L_sum, exp); + return L_sum; +#else Word16 i; #ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Word64 W_tmp; @@ -2137,6 +2141,7 @@ Word32 norm_llQ31( /* o : normalized result Q31 */ *exp = i; move16(); return L_sum; +#endif } -- GitLab From 0b54e7c8b7966315a2030b4e0ae2c353eea164cd Mon Sep 17 00:00:00 2001 From: gerstack Date: Thu, 28 Aug 2025 11:58:55 +0200 Subject: [PATCH 17/33] issue _1965_ fix --- lib_com/basop_util.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index 9a791deec..856a99707 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -2079,26 +2079,29 @@ Word32 norm_llQ31( /* o : normalized result Q31 */ ) { #ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW - L_sum =w_norm_llQ31( (Word64)L_c<<32 | L_sum, exp); - return L_sum; +// Word16 exp2=*exp; +// Word32 L_sumOld= L_sum; +// Word32 L_cOld= L_c; +// Word32 L_sum2 =w_norm_llQ31( ((Word64)L_c<<32) | (UWord32)L_sum, &exp2); + L_sum =w_norm_llQ31( ((Word64)L_c<<32) | (UWord32)L_sum, exp); #else Word16 i; -#ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW +#ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOWxxx Word64 W_tmp; #else Word32 L_tmp; #endif #ifdef BASOP_NOGLOB_DECLARE_LOCAL -#if !defined( ISSUE_1836_replace_overflow_libcom ) && !defined( FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW ) +#if !defined( ISSUE_1836_replace_overflow_libcom ) && !defined( FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOWxxx ) Flag Overflow = 0; #endif -#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOWxxx Flag Carry = 0; #endif #endif /* BASOP_NOGLOB */ /* Move MSBit of L_sum into L_c */ -#ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW +#ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOWxxx W_tmp = W_add( L_sum, L_sum ); /* W_tmp = L_sum << 1 */ L_c = L_add( L_add( L_c, L_c ), W_extract_h( W_tmp ) ); #else @@ -2118,7 +2121,7 @@ Word32 norm_llQ31( /* o : normalized result Q31 */ i = norm_l( L_c ); L_c = L_shl( L_c, i ); i = sub( 31, i ); /* positive exponent */ -#ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW +#ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOWxxx L_sum = W_lshr( W_tmp, 1 ); /* L_sum with MSBit=0 */ L_sum = L_lshr( L_sum, i ); #else @@ -2140,8 +2143,15 @@ Word32 norm_llQ31( /* o : normalized result Q31 */ } *exp = i; move16(); - return L_sum; +#if 0 + char isnotok = *exp != exp2 || L_sum!=L_sum2; + if (isnotok) fprintf(stderr, "%s: %s:%d: (0x%08x, 0x%08x) 0x%08x 0x%08x %d %d\n", isnotok?"ERROR ":"IS_OK ", + __FILE__,__LINE__, + L_cOld,L_sumOld, + L_sum, L_sum2, *exp, exp2); +#endif #endif + return L_sum; } -- GitLab From 42b2d5e905d23ac96f008065ea1a803d2d6b44cc Mon Sep 17 00:00:00 2001 From: gerstack Date: Thu, 28 Aug 2025 12:06:37 +0200 Subject: [PATCH 18/33] issue _1965_ fix clang-format --- lib_com/basop_util.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index 856a99707..7f9963bc1 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -2079,11 +2079,11 @@ Word32 norm_llQ31( /* o : normalized result Q31 */ ) { #ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW -// Word16 exp2=*exp; -// Word32 L_sumOld= L_sum; -// Word32 L_cOld= L_c; -// Word32 L_sum2 =w_norm_llQ31( ((Word64)L_c<<32) | (UWord32)L_sum, &exp2); - L_sum =w_norm_llQ31( ((Word64)L_c<<32) | (UWord32)L_sum, exp); + // Word16 exp2=*exp; + // Word32 L_sumOld= L_sum; + // Word32 L_cOld= L_c; + // Word32 L_sum2 =w_norm_llQ31( ((Word64)L_c<<32) | (UWord32)L_sum, &exp2); + L_sum = w_norm_llQ31( ( (Word64) L_c << 32 ) | (UWord32) L_sum, exp ); #else Word16 i; #ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOWxxx @@ -2120,7 +2120,7 @@ Word32 norm_llQ31( /* o : normalized result Q31 */ { i = norm_l( L_c ); L_c = L_shl( L_c, i ); - i = sub( 31, i ); /* positive exponent */ + i = sub( 31, i ); /* positive exponent */ #ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOWxxx L_sum = W_lshr( W_tmp, 1 ); /* L_sum with MSBit=0 */ L_sum = L_lshr( L_sum, i ); -- GitLab From 4754810bd374545917fded2e2836c63504593b86 Mon Sep 17 00:00:00 2001 From: gerstack Date: Thu, 28 Aug 2025 17:30:32 +0200 Subject: [PATCH 19/33] issue _1965_ fix --- lib_com/basop_util.c | 37 +++++++----------------------------- lib_com/igf_base_fx.c | 12 ++++++++++-- lib_dec/arith_coder_dec_fx.c | 4 ++-- lib_dec/igf_dec_fx.c | 10 +++++++--- lib_enc/arith_coder_enc_fx.c | 2 +- lib_enc/cod_tcx_fx.c | 4 ++-- 6 files changed, 29 insertions(+), 40 deletions(-) diff --git a/lib_com/basop_util.c b/lib_com/basop_util.c index 7f9963bc1..fe2b7e871 100644 --- a/lib_com/basop_util.c +++ b/lib_com/basop_util.c @@ -2072,6 +2072,7 @@ Word16 idiv1616_1( Word16 x, Word16 y ) } } +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Word32 norm_llQ31( /* o : normalized result Q31 */ Word32 L_c, /* i : upper bits of accu Q-1 */ Word32 L_sum, /* i : lower bits of accu, unsigned Q31 */ @@ -2079,32 +2080,20 @@ Word32 norm_llQ31( /* o : normalized result Q31 */ ) { #ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW - // Word16 exp2=*exp; - // Word32 L_sumOld= L_sum; - // Word32 L_cOld= L_c; - // Word32 L_sum2 =w_norm_llQ31( ((Word64)L_c<<32) | (UWord32)L_sum, &exp2); - L_sum = w_norm_llQ31( ( (Word64) L_c << 32 ) | (UWord32) L_sum, exp ); + move32(); /* compensate missing instrumentation */ + move32(); /* compensate missing instrumentation */ + return w_norm_llQ31( ( (Word64) L_c << 32 ) | (UWord32) L_sum, exp ); #else Word16 i; -#ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOWxxx - Word64 W_tmp; -#else Word32 L_tmp; -#endif #ifdef BASOP_NOGLOB_DECLARE_LOCAL -#if !defined( ISSUE_1836_replace_overflow_libcom ) && !defined( FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOWxxx ) +#ifndef ISSUE_1836_replace_overflow_libcom Flag Overflow = 0; #endif -#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOWxxx Flag Carry = 0; -#endif #endif /* BASOP_NOGLOB */ /* Move MSBit of L_sum into L_c */ -#ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOWxxx - W_tmp = W_add( L_sum, L_sum ); /* W_tmp = L_sum << 1 */ - L_c = L_add( L_add( L_c, L_c ), W_extract_h( W_tmp ) ); -#else #ifdef ISSUE_1836_replace_overflow_libcom Carry = 0; L_tmp = L_add_c( L_sum, L_sum, &Carry ); /* L_tmp = L_sum << 1 */ @@ -2112,7 +2101,6 @@ Word32 norm_llQ31( /* o : normalized result Q31 */ #else L_tmp = L_add_co( L_sum, L_sum, &Carry, &Overflow ); /* L_tmp = L_sum << 1 */ L_c = L_add_co( L_c, L_c, &Carry, &Overflow ); -#endif #endif L_add( 0, 0 ); test(); @@ -2121,14 +2109,9 @@ Word32 norm_llQ31( /* o : normalized result Q31 */ i = norm_l( L_c ); L_c = L_shl( L_c, i ); i = sub( 31, i ); /* positive exponent */ -#ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOWxxx - L_sum = W_lshr( W_tmp, 1 ); /* L_sum with MSBit=0 */ - L_sum = L_lshr( L_sum, i ); -#else L_sum = L_lshr( L_tmp, 1 ); /* L_sum with MSBit=0 */ L_sum = L_lshr( L_sum, i ); L_sum = L_add( L_c, L_sum ); -#endif } ELSE { @@ -2143,16 +2126,10 @@ Word32 norm_llQ31( /* o : normalized result Q31 */ } *exp = i; move16(); -#if 0 - char isnotok = *exp != exp2 || L_sum!=L_sum2; - if (isnotok) fprintf(stderr, "%s: %s:%d: (0x%08x, 0x%08x) 0x%08x 0x%08x %d %d\n", isnotok?"ERROR ":"IS_OK ", - __FILE__,__LINE__, - L_cOld,L_sumOld, - L_sum, L_sum2, *exp, exp2); -#endif -#endif return L_sum; +#endif /* #ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW */ } +#endif /* #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW */ Word32 Dot_product16HQ( /* o : normalized result Q31 */ diff --git a/lib_com/igf_base_fx.c b/lib_com/igf_base_fx.c index b94abb06d..e9aea5274 100644 --- a/lib_com/igf_base_fx.c +++ b/lib_com/igf_base_fx.c @@ -1123,11 +1123,11 @@ void IGFCommonFuncsCalcSfbEnergyPowerSpec( const Word16 startSfb, /**< in #ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Flag Overflow = 0; - Flag Carry = 0; // done -#endif + Flag Carry = 0; move16(); move16(); #endif +#endif #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW FOR( sfb = startSfb; sfb < stopSfb; sfb++ ) @@ -1138,6 +1138,13 @@ void IGFCommonFuncsCalcSfbEnergyPowerSpec( const Word16 startSfb, /**< in #endif IF( NULL == pPowerSpectrum ) { +#ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW + FOR( sfb = startSfb; sfb < stopSfb; sfb++ ) + { + sfbEnergy[sfb] = L_deposit_l( 0 ); + move32(); + } +#endif return; } @@ -1161,6 +1168,7 @@ void IGFCommonFuncsCalcSfbEnergyPowerSpec( const Word16 startSfb, /**< in sfbEnergy[sfb] = sum_array_norm( pPowerSpectrum + swb_offset[sfb], swb_offset[sfb + 1] - swb_offset[sfb], &( sfbEnergy_exp[sfb] ) ); + move32(); #endif sfbEnergy_exp[sfb] = add( sfbEnergy_exp[sfb], *pPowerSpectrum_exp ); move16(); diff --git a/lib_dec/arith_coder_dec_fx.c b/lib_dec/arith_coder_dec_fx.c index b1e379f26..77ae166b4 100644 --- a/lib_dec/arith_coder_dec_fx.c +++ b/lib_dec/arith_coder_dec_fx.c @@ -32,7 +32,7 @@ static Word16 tcx_arith_decode_fx( Word32 L_tmp, Q; Flag Overflow = 0; move32(); - Flag Carry = 0; // not done + Flag Carry = 0; #else Word32 Q; Word64 W_tmp; @@ -104,7 +104,7 @@ static Word16 tcx_arith_decode_fx( #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW *nf_seed = extract_l( L_tmp ); #else - *nf_seed = extract_l( (Word32) W_tmp ); + *nf_seed = extract_l( W_extract_l( W_tmp ) ); #endif move16(); diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index af998244f..46fc4f168 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -1583,9 +1583,7 @@ static void IGF_appl( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in } L_tmp = norm_llQ31( L_c, L_tmp, &shift ); // Q31 #else - { - L_tmp = sum_array_norm( energyTmp, 24, &shift ); - } + L_tmp = sum_array_norm( energyTmp, 24, &shift ); #endif /* float: dE = (float)sqrt(dE / 24.f); basop: */ shift = add( sub( shift, 4 ), dE_e ); /* x/24 = (x >> 4) * 1/1.5 */ @@ -2182,11 +2180,13 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in Word16 spec_e_arr[N_MAX]; Word16 vspec_e_arr[N_MAX_TCX - IGF_START_MN]; #ifdef BASOP_NOGLOB_DECLARE_LOCAL +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Flag Overflow = 0; move16(); Flag Carry = 0; move16(); #endif +#endif /* initialize variables */ @@ -2266,6 +2266,7 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in L_c = 0; move32(); +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW FOR( tb = 0; tb < 24; tb++ ) { Carry = 0; @@ -2275,6 +2276,9 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); } L_tmp = norm_llQ31( L_c, L_tmp, &shift ); // Q31 +#else + L_tmp = sum_array_norm( energyTmp, 24, &shift ); +#endif /* float: dE = (float)sqrt(dE / 24.f); basop: */ shift = add( sub( shift, 4 ), dE_e ); /* x/24 = (x >> 4) * 1/1.5 */ dE = Sqrt16norm( extract_h( L_tmp ), &shift ); diff --git a/lib_enc/arith_coder_enc_fx.c b/lib_enc/arith_coder_enc_fx.c index 8c4cdabe8..e7654beba 100644 --- a/lib_enc/arith_coder_enc_fx.c +++ b/lib_enc/arith_coder_enc_fx.c @@ -803,7 +803,7 @@ void tcx_arith_encode_envelope_fx( #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW *nf_seed = extract_l( L_tmp2 ); #else - *nf_seed = extract_l( (Word32) W_tmp2 ); + *nf_seed = extract_l( W_extract_l( W_tmp2 ) ); #endif move16(); } diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 7c8615013..806949a60 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -1849,7 +1849,7 @@ void QuantizeSpectrum_fx( #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW tmp32 = L_macNs_co( tmp32, abs_s( sqQ[i] ), i, &Carry, &Overflow ); #else - tmp32 = L_macNs_sat( tmp32, abs_s( sqQ[i] ), i ); + tmp32 = L_macNs( tmp32, abs_s( sqQ[i] ), i ); #endif } *spectrum_e = SPEC_EXP_DEC; @@ -3538,7 +3538,7 @@ void QuantizeTCXSpectrum_fx( #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW tmp32 = L_macNs_co( tmp32, abs_s( sqQ[i] ), i, &Carry, &Overflow ); #else - tmp32 = L_macNs_sat( tmp32, abs_s( sqQ[i] ), i ); + tmp32 = L_macNs( tmp32, abs_s( sqQ[i] ), i ); #endif } *spectrum_e = SPEC_EXP_DEC; -- GitLab From 51ebf72b6df41948e95ba244677e9c4956564d4b Mon Sep 17 00:00:00 2001 From: gerstack Date: Thu, 28 Aug 2025 17:34:12 +0200 Subject: [PATCH 20/33] issue _1965_ fix --- lib_enc/enc_acelp_fx.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index 2556c61e2..11527533c 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -1946,7 +1946,7 @@ static void E_ACELP_codearithp_fx( const Word16 v[] /*Q9*/, UWord32 *n /*Q0*/, U #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW UWord32 s; #else - UWord64 s; + UWord64 W_s; #endif #ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW @@ -1981,7 +1981,7 @@ static void E_ACELP_codearithp_fx( const Word16 v[] /*Q9*/, UWord32 *n /*Q0*/, U #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW s = L_deposit_l( 0 ); #else - s = 0; + W_s = 0; #endif t = 0; move16(); @@ -2002,7 +2002,7 @@ static void E_ACELP_codearithp_fx( const Word16 v[] /*Q9*/, UWord32 *n /*Q0*/, U #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW s = L_add_co( s, pulsestostates[pos[k]][t], &Carry, &Overflow ); #else - s = W_add( s, pulsestostates[pos[k]][t] ); + W_s = W_add( W_s, pulsestostates[pos[k]][t] ); #endif t = add( t, 1 ); if ( sub( t, NPMAXPT ) > 0 ) @@ -2021,14 +2021,14 @@ static void E_ACELP_codearithp_fx( const Word16 v[] /*Q9*/, UWord32 *n /*Q0*/, U #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW s = L_lshl( s, 1 ); #else - s = W_lshl( s, 1 ); + W_s = W_lshl( W_s, 1 ); #endif if ( sign < 0 ) { #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW s = L_add_co( s, 1, &Carry, &Overflow ); #else - s = W_add( s, 1 ); + W_s = W_add( W_s, 1 ); #endif } @@ -2040,12 +2040,16 @@ static void E_ACELP_codearithp_fx( const Word16 v[] /*Q9*/, UWord32 *n /*Q0*/, U #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW s = L_add_co( s, pulsestostates[pos[k]][t], &Carry, &Overflow ); #else - s = W_add( s, pulsestostates[pos[k]][t] ); + W_s = W_add( W_s, pulsestostates[pos[k]][t] ); #endif t = add( t, 1 ); } +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW *ps = s; /*Q0*/ +#else + *ps = (UWord32)W_s; /*Q0*/ +#endif move32(); *n = L_deposit_l( 0 ); if ( nb_pulse ) -- GitLab From cb43a6ee08d68432246b77b26f3f5b637ce541dd Mon Sep 17 00:00:00 2001 From: gerstack Date: Thu, 28 Aug 2025 17:39:12 +0200 Subject: [PATCH 21/33] issue _1965_ fix clang-format --- lib_enc/enc_acelp_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/enc_acelp_fx.c b/lib_enc/enc_acelp_fx.c index 11527533c..995edc4cc 100644 --- a/lib_enc/enc_acelp_fx.c +++ b/lib_enc/enc_acelp_fx.c @@ -2048,7 +2048,7 @@ static void E_ACELP_codearithp_fx( const Word16 v[] /*Q9*/, UWord32 *n /*Q0*/, U #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW *ps = s; /*Q0*/ #else - *ps = (UWord32)W_s; /*Q0*/ + *ps = (UWord32) W_s; /*Q0*/ #endif move32(); *n = L_deposit_l( 0 ); -- GitLab From d76fad509496b502bb44b26bf4e292176788aaf7 Mon Sep 17 00:00:00 2001 From: gerstack Date: Thu, 28 Aug 2025 19:12:38 +0200 Subject: [PATCH 22/33] issue _1965_ fix --- lib_enc/cod_tcx_fx.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 806949a60..2d6b9fcb0 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -1841,6 +1841,11 @@ void QuantizeSpectrum_fx( /* Save quantized Values */ tmp32 = L_deposit_l( 0 ); + move16(); +#ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW + Word64 seed = 0; + move64(); +#endif FOR( i = 0; i < L_spec; i++ ) { spectrum[i] = L_mult( sqQ[i], 1 << ( 30 - SPEC_EXP_DEC ) ); @@ -1849,13 +1854,17 @@ void QuantizeSpectrum_fx( #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW tmp32 = L_macNs_co( tmp32, abs_s( sqQ[i] ), i, &Carry, &Overflow ); #else - tmp32 = L_macNs( tmp32, abs_s( sqQ[i] ), i ); + seed = W_mac_16_16( seed, abs_s( sqQ[i] ), i ); #endif } *spectrum_e = SPEC_EXP_DEC; move16(); +#ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW + nf_seed = extract_l( W_extract_l( seed ) ); // Q0 +#else nf_seed = extract_l( tmp32 ); +#endif } ELSE /* low rates: new arithmetic coder */ { -- GitLab From 97bdfd501709d54d92a1ea4e476d96c67ace7b86 Mon Sep 17 00:00:00 2001 From: gerstack Date: Fri, 29 Aug 2025 10:59:00 +0200 Subject: [PATCH 23/33] issue _1965_ fix --- lib_dec/igf_dec_fx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index 46fc4f168..206627d92 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -2176,7 +2176,9 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in Word16 dS[IGF_MAX_SFB]; Word16 dS_e[IGF_MAX_SFB]; Word32 energyTmp[24]; +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Word32 L_c; +#endif Word16 spec_e_arr[N_MAX]; Word16 vspec_e_arr[N_MAX_TCX - IGF_START_MN]; #ifdef BASOP_NOGLOB_DECLARE_LOCAL @@ -2264,9 +2266,9 @@ static void IGF_appl_ivas( IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData, /**< in &dE_e, negate( tmp ) ); +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW L_c = 0; move32(); -#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW FOR( tb = 0; tb < 24; tb++ ) { Carry = 0; -- GitLab From f0083e01c5e92d4ca489453bbd8c668a4bbf26a5 Mon Sep 17 00:00:00 2001 From: gerstack Date: Mon, 1 Sep 2025 08:53:07 +0200 Subject: [PATCH 24/33] issue _1965_ fix --- lib_com/basop_util.h | 6 +++++- lib_enc/cod_tcx_fx.c | 11 ++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib_com/basop_util.h b/lib_com/basop_util.h index 9e5882f22..50cb51cf8 100644 --- a/lib_com/basop_util.h +++ b/lib_com/basop_util.h @@ -647,7 +647,11 @@ Word32 norm_llQ31( /* o : normalized result Q31 */ * \brief Compute normalized Q31 Values out of overflowed Q31 value * using 64-bit operators *------------------------------------------------------------------*/ -static inline Word32 w_norm_llQ31( Word64 L64_var1, Word16 *S_var2 ) /*Q31 - L_tmp_exp*/ +static inline +Word32 w_norm_llQ31( /* o : normalized result Q31 - *S_var2 */ + Word64 L64_var1, /* i : 64-bit accu Q63 */ + Word16 *S_var2 /* o : exponent of result in [-32,31] Q0 */ +) { Word32 L_result; Word16 sh = W_norm( L64_var1 ); diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 2d6b9fcb0..e1059cfe8 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -1274,7 +1274,7 @@ void QuantizeSpectrum_fx( CONTEXT_HM_CONFIG *phm_cfg; TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; #ifdef BASOP_NOGLOB_DECLARE_LOCAL -#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOWxxx Flag Overflow = 0; Flag Carry = 0; #endif @@ -1851,9 +1851,9 @@ void QuantizeSpectrum_fx( spectrum[i] = L_mult( sqQ[i], 1 << ( 30 - SPEC_EXP_DEC ) ); move32(); /* noise filling seed */ -#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOWxxx tmp32 = L_macNs_co( tmp32, abs_s( sqQ[i] ), i, &Carry, &Overflow ); -#else +//#else seed = W_mac_16_16( seed, abs_s( sqQ[i] ), i ); #endif } @@ -1861,9 +1861,10 @@ void QuantizeSpectrum_fx( move16(); #ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW - nf_seed = extract_l( W_extract_l( seed ) ); // Q0 -#else + Word16 nf_seed2 = extract_l( W_extract_l( seed ) ); // Q0 +///#else nf_seed = extract_l( tmp32 ); + if (nf_seed != nf_seed2) fprintf(stderr, "nfseed=0x%04x, nf_seed2= 0x%04x\n", nf_seed&0xffff, nf_seed2&0xffff); #endif } ELSE /* low rates: new arithmetic coder */ -- GitLab From fe66b0d823dd542835e410351fa0efcbcdca0209 Mon Sep 17 00:00:00 2001 From: gerstack Date: Mon, 1 Sep 2025 09:11:25 +0200 Subject: [PATCH 25/33] issue _1965_ fix --- lib_com/basop_util.h | 7 +++---- lib_enc/cod_tcx_fx.c | 7 ++++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_com/basop_util.h b/lib_com/basop_util.h index 50cb51cf8..e6db321da 100644 --- a/lib_com/basop_util.h +++ b/lib_com/basop_util.h @@ -647,10 +647,9 @@ Word32 norm_llQ31( /* o : normalized result Q31 */ * \brief Compute normalized Q31 Values out of overflowed Q31 value * using 64-bit operators *------------------------------------------------------------------*/ -static inline -Word32 w_norm_llQ31( /* o : normalized result Q31 - *S_var2 */ - Word64 L64_var1, /* i : 64-bit accu Q63 */ - Word16 *S_var2 /* o : exponent of result in [-32,31] Q0 */ +static inline Word32 w_norm_llQ31( /* o : normalized result Q31 - *S_var2 */ + Word64 L64_var1, /* i : 64-bit accu Q63 */ + Word16 *S_var2 /* o : exponent of result in [-32,31] Q0 */ ) { Word32 L_result; diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index e1059cfe8..83a499a8b 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -1853,7 +1853,7 @@ void QuantizeSpectrum_fx( /* noise filling seed */ #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOWxxx tmp32 = L_macNs_co( tmp32, abs_s( sqQ[i] ), i, &Carry, &Overflow ); -//#else + //#else seed = W_mac_16_16( seed, abs_s( sqQ[i] ), i ); #endif } @@ -1862,9 +1862,10 @@ void QuantizeSpectrum_fx( #ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Word16 nf_seed2 = extract_l( W_extract_l( seed ) ); // Q0 -///#else + ///#else nf_seed = extract_l( tmp32 ); - if (nf_seed != nf_seed2) fprintf(stderr, "nfseed=0x%04x, nf_seed2= 0x%04x\n", nf_seed&0xffff, nf_seed2&0xffff); + if ( nf_seed != nf_seed2 ) + fprintf( stderr, "nfseed=0x%04x, nf_seed2= 0x%04x\n", nf_seed & 0xffff, nf_seed2 & 0xffff ); #endif } ELSE /* low rates: new arithmetic coder */ -- GitLab From d89a08755a2897f06d6ffaec11127c6fed432003 Mon Sep 17 00:00:00 2001 From: gerstack Date: Mon, 1 Sep 2025 10:49:54 +0200 Subject: [PATCH 26/33] issue _1965_ fix --- lib_enc/cod_tcx_fx.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib_enc/cod_tcx_fx.c b/lib_enc/cod_tcx_fx.c index 83a499a8b..2d6b9fcb0 100644 --- a/lib_enc/cod_tcx_fx.c +++ b/lib_enc/cod_tcx_fx.c @@ -1274,7 +1274,7 @@ void QuantizeSpectrum_fx( CONTEXT_HM_CONFIG *phm_cfg; TCX_ENC_HANDLE hTcxEnc = st->hTcxEnc; #ifdef BASOP_NOGLOB_DECLARE_LOCAL -#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOWxxx +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Flag Overflow = 0; Flag Carry = 0; #endif @@ -1851,9 +1851,9 @@ void QuantizeSpectrum_fx( spectrum[i] = L_mult( sqQ[i], 1 << ( 30 - SPEC_EXP_DEC ) ); move32(); /* noise filling seed */ -#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOWxxx +#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW tmp32 = L_macNs_co( tmp32, abs_s( sqQ[i] ), i, &Carry, &Overflow ); - //#else +#else seed = W_mac_16_16( seed, abs_s( sqQ[i] ), i ); #endif } @@ -1861,11 +1861,9 @@ void QuantizeSpectrum_fx( move16(); #ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW - Word16 nf_seed2 = extract_l( W_extract_l( seed ) ); // Q0 - ///#else + nf_seed = extract_l( W_extract_l( seed ) ); // Q0 +#else nf_seed = extract_l( tmp32 ); - if ( nf_seed != nf_seed2 ) - fprintf( stderr, "nfseed=0x%04x, nf_seed2= 0x%04x\n", nf_seed & 0xffff, nf_seed2 & 0xffff ); #endif } ELSE /* low rates: new arithmetic coder */ -- GitLab From 9f374220c8b7e2f94cbb137e8141ac3c87d82066 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 3 Sep 2025 11:14:28 +0200 Subject: [PATCH 27/33] resolve previously wrong resolved merge conflict --- lib_com/options.h | 39 +++------------------------------------ 1 file changed, 3 insertions(+), 36 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 9b79a8b23..06f661b8b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -73,43 +73,10 @@ /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ -#define ISSUE_1836_replace_overflow_libcom /* FhG: replace overflow operators by non-overflow-alternatives in lib_com - BE */ -#define ISSUE_1836_replace_overflow_libcom__remnant /* FhG: replace remaining overflow operators by non-overflow-alternatives in lib_com - BE */ -#define ISSUE_1866_replace_overflow_libdec /* FhG: BE - Replace BASOPoverflow operators all over the lib_dec module if Overflow result is not used */ - -#define FIX_1917_DIRAC_RENDER_PTR_INCR /* FhG: fix wrong pointer increment in ivas_dirac_dec_render_sf_fx() for object rendering */ -#define FIX_CDLFB_BUFFER_SCALING /* FhG: fix wrong buffer scaling in ivas_dirac_dec_render_sf_fx() for object rendering */ -#define FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 1931 */ #define FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 2166 */ -#define NONBE_SVD_OPTIMIZATION /* FhG: reduce WMOPS of HouseHolderReduction() in ivas_svd_dec.c() by removing redundant mathematics and using 64 bit additions */ -#define FIX_1766_TCX2ACELP_BWE_ISSUE /* VA : Fix rare BWE issue when switching from TCX to ACELP */ -#define FIX_1781_SPECTRAL_GAPS /* FhG: Change internal calculation of tcx_noise_factor_ivas_fx() to 32-bit*/ -#define FIX_ISSUE_1811_EXCEEDING_W_SHIFTS /* FhG: limit exceeding 64bit shifts */ -#define FIX_1843_IO_QFACTOR_INIT /* FhG: initialize CRend's io_qfactor also in IVAS_rend */ - - -#define FIX_1931_BIN_COHR_CROSS_MIX /* FhG: correct binauralCoherenceCrossmixGains_fx calculation */ -#define FIX_1939_REVERB_DMX_OUT_Q /*Dlb: output correct q factor for the reverb dmx function*/ - -#define EVS_BE_REUSAGE -#ifdef EVS_BE_REUSAGE -#define REUSE_EVS_BE_ACELP_LP_FILT -#define REUSE_EVS_BE_ACELP_4T64 -#define REUSE_EVS_BE_ACELP_2t32 -#define REUSE_EVS_BE_ACELP_1t64 -#define REUSE_EVS_BE_ACELP_AVQ -#define REUSE_EVS_BE_GAUSS -#define REUSE_EVS_BE_GAINQ -#define REUSE_EVS_BE_ACELP_PITCH -#define REUSE_EVS_BE_ACELP_PITCH_PIT_Q -#define REUSE_EVS_BE_GAINQ_LBR // BE by adding one condition, but could be harmonized in a non-BE way. There is a small difference in how Etot is computed - -#endif - -#define FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 1931 */ -#define FIX_1844_MISSING_FREE /* FhG: add missing free in ivas_binRenderer_convModuleClose_fx() */ -#define FIX_1942_ASSERTION_LOWSHELF /* FhG: Modified the target_gains_db_fx calculation in compute_t60_coeffs_fx() */ -#define FIX_1944_CRASH_FOR_STEREO /* FhG: improve TonalMDCTConceal_InsertNoise calculation precision */ +#define ISSUE_1836_replace_overflow_libcom /* FhG: replace overflow operators by non-overflow-alternatives in lib_com - BE */ +#define FIX_1942_ASSERTION_LOWSHELF /* FhG: Modified the target_gains_db_fx calculation in compute_t60_coeffs_fx() */ +#define FIX_1944_CRASH_FOR_STEREO /* FhG: improve TonalMDCTConceal_InsertNoise calculation precision */ #define FIX_1970_SBA_CRASH /* Dlb: Fix for issue 1970, SBA crash */ #define FIX_1978_SAT_MISSING_IN_GAIN_ENC /* VA: Fix add saturation missing that lead to a crash in P800-10 */ -- GitLab From a4c767ea2a68e68c92fd533d707967e4c86d2fdf Mon Sep 17 00:00:00 2001 From: gerstack Date: Wed, 3 Sep 2025 11:19:09 +0200 Subject: [PATCH 28/33] merge conflict issue _1965_ --- lib_com/options.h | 37 ++----------------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 9b79a8b23..2085a7736 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -74,42 +74,9 @@ /* Note: each compile switch (FIX_1101_...) is independent from the other ones */ #define ISSUE_1836_replace_overflow_libcom /* FhG: replace overflow operators by non-overflow-alternatives in lib_com - BE */ -#define ISSUE_1836_replace_overflow_libcom__remnant /* FhG: replace remaining overflow operators by non-overflow-alternatives in lib_com - BE */ -#define ISSUE_1866_replace_overflow_libdec /* FhG: BE - Replace BASOPoverflow operators all over the lib_dec module if Overflow result is not used */ - -#define FIX_1917_DIRAC_RENDER_PTR_INCR /* FhG: fix wrong pointer increment in ivas_dirac_dec_render_sf_fx() for object rendering */ -#define FIX_CDLFB_BUFFER_SCALING /* FhG: fix wrong buffer scaling in ivas_dirac_dec_render_sf_fx() for object rendering */ -#define FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 1931 */ #define FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 2166 */ -#define NONBE_SVD_OPTIMIZATION /* FhG: reduce WMOPS of HouseHolderReduction() in ivas_svd_dec.c() by removing redundant mathematics and using 64 bit additions */ -#define FIX_1766_TCX2ACELP_BWE_ISSUE /* VA : Fix rare BWE issue when switching from TCX to ACELP */ -#define FIX_1781_SPECTRAL_GAPS /* FhG: Change internal calculation of tcx_noise_factor_ivas_fx() to 32-bit*/ -#define FIX_ISSUE_1811_EXCEEDING_W_SHIFTS /* FhG: limit exceeding 64bit shifts */ -#define FIX_1843_IO_QFACTOR_INIT /* FhG: initialize CRend's io_qfactor also in IVAS_rend */ - - -#define FIX_1931_BIN_COHR_CROSS_MIX /* FhG: correct binauralCoherenceCrossmixGains_fx calculation */ -#define FIX_1939_REVERB_DMX_OUT_Q /*Dlb: output correct q factor for the reverb dmx function*/ - -#define EVS_BE_REUSAGE -#ifdef EVS_BE_REUSAGE -#define REUSE_EVS_BE_ACELP_LP_FILT -#define REUSE_EVS_BE_ACELP_4T64 -#define REUSE_EVS_BE_ACELP_2t32 -#define REUSE_EVS_BE_ACELP_1t64 -#define REUSE_EVS_BE_ACELP_AVQ -#define REUSE_EVS_BE_GAUSS -#define REUSE_EVS_BE_GAINQ -#define REUSE_EVS_BE_ACELP_PITCH -#define REUSE_EVS_BE_ACELP_PITCH_PIT_Q -#define REUSE_EVS_BE_GAINQ_LBR // BE by adding one condition, but could be harmonized in a non-BE way. There is a small difference in how Etot is computed - -#endif - -#define FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 1931 */ -#define FIX_1844_MISSING_FREE /* FhG: add missing free in ivas_binRenderer_convModuleClose_fx() */ -#define FIX_1942_ASSERTION_LOWSHELF /* FhG: Modified the target_gains_db_fx calculation in compute_t60_coeffs_fx() */ -#define FIX_1944_CRASH_FOR_STEREO /* FhG: improve TonalMDCTConceal_InsertNoise calculation precision */ +#define FIX_1942_ASSERTION_LOWSHELF /* FhG: Modified the target_gains_db_fx calculation in compute_t60_coeffs_fx() */ +#define FIX_1944_CRASH_FOR_STEREO /* FhG: improve TonalMDCTConceal_InsertNoise calculation precision */ #define FIX_1970_SBA_CRASH /* Dlb: Fix for issue 1970, SBA crash */ #define FIX_1978_SAT_MISSING_IN_GAIN_ENC /* VA: Fix add saturation missing that lead to a crash in P800-10 */ -- GitLab From bbb4069efec3571990956fd63781958e64ea2425 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 4 Sep 2025 09:08:25 +0200 Subject: [PATCH 29/33] fix compilation warning --- lib_enc/igf_enc_fx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index 236ef8a1a..7199713f3 100644 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -389,6 +389,7 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou Word16 tmp; Word32 L_tmp; +#if !defined(FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW) && !defined(ISSUE_1867_replace_overflow_libenc) #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW @@ -396,6 +397,7 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou #endif move32(); move32(); +#endif #endif hPrivateData = &hInstance->igfData; -- GitLab From c38ace99137f734859178f169448c873227237a0 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 4 Sep 2025 09:15:48 +0200 Subject: [PATCH 30/33] fix formatting --- lib_enc/igf_enc_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index 7199713f3..4b3933d6c 100644 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -389,7 +389,7 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou Word16 tmp; Word32 L_tmp; -#if !defined(FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW) && !defined(ISSUE_1867_replace_overflow_libenc) +#if !defined( FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW ) && !defined( ISSUE_1867_replace_overflow_libenc ) #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW -- GitLab From e9edc1c07dad4b1efa87502b111cb68dcb212352 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 4 Sep 2025 11:40:46 +0200 Subject: [PATCH 31/33] fix compilation warnings --- lib_enc/igf_enc_fx.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) mode change 100644 => 100755 lib_enc/igf_enc_fx.c diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c old mode 100644 new mode 100755 index 4b3933d6c..52c126ef7 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -366,11 +366,7 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou Word16 i; Word16 igfBgn; Word16 igfEnd; -#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Word32 highPassEner; /* Q31 */ -#else - Word64 highPassEner; -#endif Word32 lastLine; Word32 nextLine; #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW @@ -432,6 +428,8 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou { #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW L_c = 0; +#else + Word64 W_accum = 0; #endif move32(); FOR( i = 0; i < igfBgn; i++ ) @@ -445,14 +443,14 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); #else move32(); - highPassEner = W_add( highPassEner, Mpy_32_16_1( pPowerSpectrum[i], shl( i, 4 ) /*Q4*/ ) /*Q20, pPowerSpectrum_exp*/ ); + W_accum = W_add( W_accum, Mpy_32_16_1( pPowerSpectrum[i], shl( i, 4 ) /*Q4*/ ) /*Q20, pPowerSpectrum_exp*/ ); #endif } #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW highPassEner = norm_llQ31( L_c, highPassEner, highPassEner_exp ); /*Q20, highPassEner_exp*/ #else - highPassEner = w_norm_llQ31( highPassEner, highPassEner_exp ); /*Q20, highPassEner_exp*/ + highPassEner = w_norm_llQ31( W_accum, highPassEner_exp ); /*Q20, highPassEner_exp*/ #endif *highPassEner_exp = add( *highPassEner_exp, pPowerSpectrum_exp ); move16(); -- GitLab From 815290130ba78f5dd4a02bd02afb20dcec4e7306 Mon Sep 17 00:00:00 2001 From: gerstack Date: Thu, 4 Sep 2025 12:09:00 +0200 Subject: [PATCH 32/33] issue _1965_ fix --- lib_enc/igf_enc_fx.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index 52c126ef7..ac54c42cd 100755 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -910,11 +910,7 @@ Word16 IGF_getSFM( /**< out: Q15| SFM value { Word16 n, i, s; Word32 num; -#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW Word32 denom; -#else - Word64 denom; -#endif Word16 denom_exp; Word16 invDenom_exp, numf_exp; Word16 numf; @@ -945,6 +941,7 @@ Word16 IGF_getSFM( /**< out: Q15| SFM value SFM = 32767 /*1.0f Q15*/; move16(); + Word64 W_denom = W_deposit32_l( denom ); FOR( i = start; i < stop; i++ ) { /*ln(x * 2^-Qx * 2^xExp) = ln(x) - Qx + xExp*/ @@ -972,14 +969,14 @@ Word16 IGF_getSFM( /**< out: Q15| SFM value move32(); L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); #else - denom = W_add( energy[i], denom ); + W_denom = W_add( energy[i], W_denom ); #endif } #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW denom = norm_llQ31( L_c, denom, &denom_exp ); /*Q31*/ #else - denom = w_norm_llQ31( denom, &denom_exp ); /*Q31*/ + denom = w_norm_llQ31( W_denom, &denom_exp ); /*Q31*/ #endif denom_exp = add( denom_exp, *energy_exp ); -- GitLab From a987bf13b951838b949fb2321ab0f540a365f35f Mon Sep 17 00:00:00 2001 From: gerstack Date: Thu, 4 Sep 2025 14:04:39 +0200 Subject: [PATCH 33/33] issue _1965_ fix --- lib_enc/igf_enc_fx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib_enc/igf_enc_fx.c b/lib_enc/igf_enc_fx.c index ac54c42cd..b6a1c66c2 100755 --- a/lib_enc/igf_enc_fx.c +++ b/lib_enc/igf_enc_fx.c @@ -428,10 +428,11 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou { #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW L_c = 0; + move32(); #else - Word64 W_accum = 0; + Word64 W_highPassEner = 0; + move64(); #endif - move32(); FOR( i = 0; i < igfBgn; i++ ) { #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW @@ -442,15 +443,14 @@ void IGF_ErodeSpectrum( Word16 *highPassEner_exp, /**< ou move32(); L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); #else - move32(); - W_accum = W_add( W_accum, Mpy_32_16_1( pPowerSpectrum[i], shl( i, 4 ) /*Q4*/ ) /*Q20, pPowerSpectrum_exp*/ ); + W_highPassEner = W_add( W_highPassEner, W_deposit32_l( Mpy_32_16_1( pPowerSpectrum[i], shl( i, 4 ) /*Q4*/ ) ) /*Q20, pPowerSpectrum_exp*/ ); #endif } #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW highPassEner = norm_llQ31( L_c, highPassEner, highPassEner_exp ); /*Q20, highPassEner_exp*/ #else - highPassEner = w_norm_llQ31( W_accum, highPassEner_exp ); /*Q20, highPassEner_exp*/ + highPassEner = w_norm_llQ31( W_highPassEner, highPassEner_exp ); /*Q20, highPassEner_exp*/ #endif *highPassEner_exp = add( *highPassEner_exp, pPowerSpectrum_exp ); move16(); @@ -969,7 +969,7 @@ Word16 IGF_getSFM( /**< out: Q15| SFM value move32(); L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); #else - W_denom = W_add( energy[i], W_denom ); + W_denom = W_add( W_deposit32_l( energy[i] ), W_denom ); #endif } -- GitLab