From 338a77ad54bca6a1ea866f0a8ca5d9668d6ede18 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 3 Jul 2025 13:36:30 +0200 Subject: [PATCH 01/22] added macro ISSUE_1799_replace_L_shr_o and replaced one single critical L_shr_o for testing --- lib_com/options.h | 1 + lib_enc/swb_bwe_enc_lr_fx.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index bfa02eacf..7376e28ab 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -112,6 +112,7 @@ #define ISSUE_1751_replace_shl_ro /*FhG: replace shl_ro by overflow-free alternatives*/ #define ISSUE_1770_replace_shr_ro /* FhG: replace by non-overflow-alternative - BE */ #define ISSUE_1772_replace_shr_o /* FhG: replace by non-overflow-alternative - BE */ +#define ISSUE_1799_replace_L_shr_o /* FhG: replace by non-overflow-alternative - BE */ #define FIX_1735_W_SHL_SAT_L /* FhG: Usage of W_shl_sat_l() */ diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index 938cdd971..b26cc2d43 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -173,7 +173,16 @@ static Word16 GetSubbandCorrIndex2_har_fx( /* o : corr_sq_hi_fx = extract_h( L_corr_sq ); L_corr_sq = L_mult_o( corr_sq_hi_fx, corr_sq_hi_fx, &Overflow ); /* (((Qhi:Qsh+exp_norm_hi-16)+Qss+1)+exp_norm-16)*2+1 */ +#ifdef ISSUE_1799_replace_L_shr_o + L_corr_sq = L_shr_sat( L_corr_sq, s_min( shl( exp_norm, 1 ), 31 ) ); /* (QCorr-16)*2+1 */ + /* Catching an Overflow: solve MAX_32 = x / 2^y for integers x < 2^31 and y : + x has to be MAX_32 and y has to be 0 + So, a saturated overflow has occured if the result is MAX_32 and y is != 0 + THe case MIN_32 with negative x is not valid since x is calculated by square */ + Overflow = ( ( L_corr_sq == MAX_32 ) && ( exp_norm != 0 ) ) ? 1 : 0; +#else L_corr_sq = L_shr_o( L_corr_sq, s_min( shl( exp_norm, 1 ), 31 ), &Overflow ); /* (QCorr-16)*2+1 */ +#endif IF( Overflow != 0 ) { L_corr_sq = 0x0L; -- GitLab From 2847af4a6cb00b7029bae8f43a65e89dc16930d0 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 3 Jul 2025 13:53:41 +0200 Subject: [PATCH 02/22] clang format patch --- lib_enc/swb_bwe_enc_lr_fx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index b26cc2d43..bddd33d50 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -172,14 +172,14 @@ static Word16 GetSubbandCorrIndex2_har_fx( /* o : L_corr_sq = L_shl( L_corr, exp_norm ); corr_sq_hi_fx = extract_h( L_corr_sq ); - L_corr_sq = L_mult_o( corr_sq_hi_fx, corr_sq_hi_fx, &Overflow ); /* (((Qhi:Qsh+exp_norm_hi-16)+Qss+1)+exp_norm-16)*2+1 */ + L_corr_sq = L_mult_o( corr_sq_hi_fx, corr_sq_hi_fx, &Overflow ); /* (((Qhi:Qsh+exp_norm_hi-16)+Qss+1)+exp_norm-16)*2+1 */ #ifdef ISSUE_1799_replace_L_shr_o L_corr_sq = L_shr_sat( L_corr_sq, s_min( shl( exp_norm, 1 ), 31 ) ); /* (QCorr-16)*2+1 */ /* Catching an Overflow: solve MAX_32 = x / 2^y for integers x < 2^31 and y : - x has to be MAX_32 and y has to be 0 - So, a saturated overflow has occured if the result is MAX_32 and y is != 0 + x has to be MAX_32 and y has to be 0 + So, a saturated overflow has occured if the result is MAX_32 and y is != 0 THe case MIN_32 with negative x is not valid since x is calculated by square */ - Overflow = ( ( L_corr_sq == MAX_32 ) && ( exp_norm != 0 ) ) ? 1 : 0; + Overflow = ( ( L_corr_sq == MAX_32 ) && ( exp_norm != 0 ) ) ? 1 : 0; #else L_corr_sq = L_shr_o( L_corr_sq, s_min( shl( exp_norm, 1 ), 31 ), &Overflow ); /* (QCorr-16)*2+1 */ #endif -- GitLab From 841eb83c187f6df5b57c5ddb0eff0096e638a2e2 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 3 Jul 2025 14:40:26 +0200 Subject: [PATCH 03/22] fix bug --- lib_enc/swb_bwe_enc_lr_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index bddd33d50..5635667de 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -179,7 +179,7 @@ static Word16 GetSubbandCorrIndex2_har_fx( /* o : x has to be MAX_32 and y has to be 0 So, a saturated overflow has occured if the result is MAX_32 and y is != 0 THe case MIN_32 with negative x is not valid since x is calculated by square */ - Overflow = ( ( L_corr_sq == MAX_32 ) && ( exp_norm != 0 ) ) ? 1 : 0; + Overflow = ( ( L_corr_sq == MAX_32 ) && ( exp_norm < 0 ) ) ? 1 : 0; #else L_corr_sq = L_shr_o( L_corr_sq, s_min( shl( exp_norm, 1 ), 31 ), &Overflow ); /* (QCorr-16)*2+1 */ #endif -- GitLab From 1dfac65e38534c043362cbc7579b3926825dd5c6 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 3 Jul 2025 15:11:31 +0200 Subject: [PATCH 04/22] deactivate macro --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 7376e28ab..27735895f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -112,7 +112,7 @@ #define ISSUE_1751_replace_shl_ro /*FhG: replace shl_ro by overflow-free alternatives*/ #define ISSUE_1770_replace_shr_ro /* FhG: replace by non-overflow-alternative - BE */ #define ISSUE_1772_replace_shr_o /* FhG: replace by non-overflow-alternative - BE */ -#define ISSUE_1799_replace_L_shr_o /* FhG: replace by non-overflow-alternative - BE */ +//#define ISSUE_1799_replace_L_shr_o /* FhG: replace by non-overflow-alternative - BE */ #define FIX_1735_W_SHL_SAT_L /* FhG: Usage of W_shl_sat_l() */ -- GitLab From 00cb07822413e977de2c3e5e5bcbfbce03663cb0 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 3 Jul 2025 15:38:38 +0200 Subject: [PATCH 05/22] changed all remaining L_shr_o and activated macro --- lib_com/cldfb_evs_fx.c | 8 ++++++++ lib_com/cldfb_fx.c | 8 ++++++++ lib_com/cng_exc_fx.c | 28 +++++++++++++++++++++++++++ lib_com/edct_fx.c | 8 ++++++++ lib_com/frame_ener_fx.c | 4 ++++ lib_com/hp50_fx.c | 32 +++++++++++++++++++++++++++++++ lib_com/hq2_noise_inject_fx.c | 4 ++++ lib_com/lsf_tools_fx.c | 12 ++++++++++++ lib_com/lsp_conv_poly_fx.c | 4 ++++ lib_com/options.h | 2 +- lib_com/swb_bwe_com_fx.c | 9 +++++++++ lib_com/syn_filt_fx.c | 4 ++++ lib_com/tools_fx.c | 10 +++++++++- lib_dec/LD_music_post_filter_fx.c | 4 ++++ lib_dec/pvq_decode_fx.c | 4 ++++ lib_enc/bw_detect_fx.c | 4 ++++ lib_enc/energy_fx.c | 6 ++++++ lib_enc/find_tilt_fx.c | 12 ++++++++++++ lib_enc/find_uv_fx.c | 8 ++++++++ lib_enc/hvq_enc_fx.c | 16 ++++++++++++++++ lib_enc/nois_est_fx.c | 20 +++++++++++++++++++ lib_enc/pitch_ol2_fx.c | 16 ++++++++++++++++ lib_enc/pitch_ol_fx.c | 8 ++++++++ lib_enc/pvq_encode_fx.c | 8 ++++++++ lib_enc/speech_music_classif_fx.c | 16 ++++++++++++++++ lib_enc/swb_bwe_enc_hr_fx.c | 4 ++++ lib_enc/swb_tbe_enc_fx.c | 4 ++++ lib_enc/vad_fx.c | 12 ++++++++++++ 28 files changed, 273 insertions(+), 2 deletions(-) diff --git a/lib_com/cldfb_evs_fx.c b/lib_com/cldfb_evs_fx.c index 51c9ee6f9..ed5b95be2 100644 --- a/lib_com/cldfb_evs_fx.c +++ b/lib_com/cldfb_evs_fx.c @@ -1329,7 +1329,11 @@ void GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead) { FOR( j = 20; j < numberBandsM; j++ ) { +#ifdef ISSUE_1799_replace_L_shr_o + nrg = L_add_o( nrg, L_shr_sat( energyValues[k][j], s ), &Overflow ); +#else nrg = L_add_o( nrg, L_shr_o( energyValues[k][j], s, &Overflow ), &Overflow ); +#endif } } @@ -1352,7 +1356,11 @@ void GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead) { FOR( j = 20; j < numberBandsM; j++ ) { +#ifdef ISSUE_1799_replace_L_shr_o + nrg = L_add_o( nrg, L_shr_sat( energyValues[k][j], s ), &Overflow ); +#else nrg = L_add_o( nrg, L_shr_o( energyValues[k][j], s, &Overflow ), &Overflow ); +#endif } } diff --git a/lib_com/cldfb_fx.c b/lib_com/cldfb_fx.c index 30b8d57d0..efeb2ac28 100644 --- a/lib_com/cldfb_fx.c +++ b/lib_com/cldfb_fx.c @@ -1905,7 +1905,11 @@ static void GetEnergyCldfb_ivas_fx( Word32 *energyLookahead, /*!< o: Q(*sf_e { FOR( j = 20; j < numberBandsM; j++ ) { +#ifdef ISSUE_1799_replace_L_shr_o + nrg = L_add_o( nrg, L_shr_sat( energyValues[k][j], s ), &Overflow ); +#else nrg = L_add_o( nrg, L_shr_o( energyValues[k][j], s, &Overflow ), &Overflow ); +#endif } } @@ -1928,7 +1932,11 @@ static void GetEnergyCldfb_ivas_fx( Word32 *energyLookahead, /*!< o: Q(*sf_e { FOR( j = 20; j < numberBandsM; j++ ) { +#ifdef ISSUE_1799_replace_L_shr_o + nrg = L_add_o( nrg, L_shr_sat( energyValues[k][j], s ), &Overflow ); +#else nrg = L_add_o( nrg, L_shr_o( energyValues[k][j], s, &Overflow ), &Overflow ); +#endif } } diff --git a/lib_com/cng_exc_fx.c b/lib_com/cng_exc_fx.c index e335e9435..4e5fb1ad1 100644 --- a/lib_com/cng_exc_fx.c +++ b/lib_com/cng_exc_fx.c @@ -904,7 +904,11 @@ void cng_params_upd_fx( tmpv = shl( *pt_exc2, scale ); L_tmp = L_mac0_o( L_tmp, tmpv, tmpv, &Overflow ); pt_exc2++; +#ifdef ISSUE_1799_replace_L_shr_o + L_ener = L_add_o( L_ener, L_shr_sat( L_tmp, 7 ), &Overflow ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */ +#else L_ener = L_add_o( L_ener, L_shr_o( L_tmp, 7, &Overflow ), &Overflow ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */ +#endif } } ELSE /* L_FRAME16k */ @@ -917,10 +921,18 @@ void cng_params_upd_fx( tmpv = shl( *pt_exc2, scale ); L_tmp = L_mac0_o( L_tmp, tmpv, tmpv, &Overflow ); pt_exc2++; +#ifdef ISSUE_1799_replace_L_shr_o + L_ener = L_add_o( L_ener, L_shr_sat( Mult_32_16( L_tmp, 26214 /* 256/320, Q15 */ ), 7 ), &Overflow ); /* Q(2*(Q_exc+scale)+15+1-16+1) ,division by L_frame done here */ +#else L_ener = L_add_o( L_ener, L_shr_o( Mult_32_16( L_tmp, 26214 /* 256/320, Q15 */ ), 7, &Overflow ), &Overflow ); /* Q(2*(Q_exc+scale)+15+1-16+1) ,division by L_frame done here */ +#endif } } +#ifdef ISSUE_1799_replace_L_shr_o + L_ener = L_shr_sat( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ) ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */ +#else L_ener = L_shr_o( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ), &Overflow ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */ +#endif /* update the circular buffer of old energies */ ho_ener_circ[*ho_circ_ptr] = L_ener; @@ -1082,7 +1094,11 @@ void cng_params_upd_ivas_fx( tmpv = shl( *pt_exc2, scale ); L_tmp = L_mac0_o( L_tmp, tmpv, tmpv, &Overflow ); pt_exc2++; +#ifdef ISSUE_1799_replace_L_shr_o + L_ener = L_add_o( L_ener, L_shr_sat( L_tmp, 7 ), &Overflow ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */ +#else L_ener = L_add_o( L_ener, L_shr_o( L_tmp, 7, &Overflow ), &Overflow ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */ +#endif } } ELSE /* L_FRAME16k */ @@ -1095,10 +1111,18 @@ void cng_params_upd_ivas_fx( tmpv = shl( *pt_exc2, scale ); L_tmp = L_mac0_o( L_tmp, tmpv, tmpv, &Overflow ); pt_exc2++; +#ifdef ISSUE_1799_replace_L_shr_o + L_ener = L_add_o( L_ener, L_shr_sat( Mult_32_16( L_tmp, 26214 /* 256/320, Q15 */ ), 7 ), &Overflow ); /* Q(2*(Q_exc+scale)+15+1-16+1) ,division by L_frame done here */ +#else L_ener = L_add_o( L_ener, L_shr_o( Mult_32_16( L_tmp, 26214 /* 256/320, Q15 */ ), 7, &Overflow ), &Overflow ); /* Q(2*(Q_exc+scale)+15+1-16+1) ,division by L_frame done here */ +#endif } } +#ifdef ISSUE_1799_replace_L_shr_o + L_ener = L_shr_sat( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ) ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */ +#else L_ener = L_shr_o( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ), &Overflow ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */ +#endif /* update the circular buffer of old energies */ ho_ener_circ[*ho_circ_ptr] = L_ener; @@ -1137,7 +1161,11 @@ void cng_params_upd_ivas_fx( L_tmp = L_add_o( L_tmp, L_tmp, &Overflow ); /* 2*Q_exc+1 */ L_tmp = Mult_32_16( L_tmp, 128 ); /* 2*Q_exc+1 */ tmp = add( add( Q_exc, Q_exc ), 1 ); +#ifdef ISSUE_1799_replace_L_shr_o + sp[i] = L_shr_sat( L_tmp, sub( tmp, 6 ) ); +#else sp[i] = L_shr_o( L_tmp, sub( tmp, 6 ), &Overflow ); +#endif move32(); /* Q6 */ ptR++; ptI--; diff --git a/lib_com/edct_fx.c b/lib_com/edct_fx.c index 1b303d285..eae0dfb73 100644 --- a/lib_com/edct_fx.c +++ b/lib_com/edct_fx.c @@ -504,12 +504,20 @@ void edct_16fx( L_tmp = L_mult( re[i], edct_table[i] ); /*Q(Qx+Q_edct+16) */ Lacc = L_mac_o( L_tmp, im[i], *pt, &Overflow ); /*Q(Qx+Q_edct+16) */ +#ifdef ISSUE_1799_replace_L_shr_o + y[i2] = round_fx_o( L_shr_sat( Lacc, Q_edct ), &Overflow ); /* Q(Qx) */ +#else y[i2] = round_fx_o( L_shr_o( Lacc, Q_edct, &Overflow ), &Overflow ); /* Q(Qx) */ +#endif move16(); L_tmp = L_mult( re[i], edct_table[sub( shr( length, 1 ), add( 1, i ) )] ); /*Q(Qx+Q_edct+16) */ Lacc = L_msu( L_tmp, im[i], edct_table[i] ); /*Q(Qx+Q_edct+16) */ +#ifdef ISSUE_1799_replace_L_shr_o + *py = round_fx_o( L_shr_sat( Lacc, Q_edct ), &Overflow ); /* Q(Qx) */ +#else *py = round_fx_o( L_shr_o( Lacc, Q_edct, &Overflow ), &Overflow ); /* Q(Qx) */ +#endif move16(); py -= 2; diff --git a/lib_com/frame_ener_fx.c b/lib_com/frame_ener_fx.c index 68fdf33c3..57d6e83e7 100644 --- a/lib_com/frame_ener_fx.c +++ b/lib_com/frame_ener_fx.c @@ -277,7 +277,11 @@ Word16 frame_energy_fx( /* o : Frame energy in Q8 /*add ld(2^exp1)=exp1 but check format, first*/ tmp16 = sub( sub( 15, norm_s( exp1 ) ), 5 ); /*factor to shift Ltmp and exp1 with (shr) to avoid overflows when adding*/ +#ifdef ISSUE_1799_replace_L_shr_o + Ltmp = L_shr_sat( Ltmp, tmp16 ); /*Q25, tmp16*/ +#else Ltmp = L_shr_o( Ltmp, tmp16, &Overflow ); /*Q25, tmp16*/ +#endif exp2 = shr( exp1, tmp16 ); /*Q0 , tmp16*/ Ltmp = L_add_o( Ltmp, L_shl( L_deposit_l( exp2 ), 25 ), &Overflow ); /*Q25, tmp16, normalized*/ diff --git a/lib_com/hp50_fx.c b/lib_com/hp50_fx.c index 4a055e073..0e412f70d 100644 --- a/lib_com/hp50_fx.c +++ b/lib_com/hp50_fx.c @@ -212,13 +212,29 @@ void hp20( Word16 signal[], /* i/o: signal to filter any * IF( prescale != prescaleOld ) { diff = sub( prescale, prescaleOld ); +#ifdef ISSUE_1799_replace_L_shr_o + mem[0] = L_shr_sat( mem[0], diff ); +#else mem[0] = L_shr_o( mem[0], diff, &Overflow ); +#endif move32(); +#ifdef ISSUE_1799_replace_L_shr_o + mem[1] = L_shr_sat( mem[1], diff ); +#else mem[1] = L_shr_o( mem[1], diff, &Overflow ); +#endif move32(); +#ifdef ISSUE_1799_replace_L_shr_o + mem[2] = L_shr_sat( mem[2], diff ); +#else mem[2] = L_shr_o( mem[2], diff, &Overflow ); +#endif move32(); +#ifdef ISSUE_1799_replace_L_shr_o + mem[3] = L_shr_sat( mem[3], diff ); +#else mem[3] = L_shr_o( mem[3], diff, &Overflow ); +#endif move32(); mem[4] = L_deposit_l( prescale ); } @@ -325,13 +341,29 @@ void hp20_fx_32( prescale = s_min( 3, sub( 1 + HP20_COEFF_SCALE, prescale ) ); diff = sub( prescale, prescaleOld ); +#ifdef ISSUE_1799_replace_L_shr_o + mem_fx[0] = L_shr_sat( mem_fx[0], diff ); +#else mem_fx[0] = L_shr_o( mem_fx[0], diff, &Overflow ); +#endif move32(); +#ifdef ISSUE_1799_replace_L_shr_o + mem_fx[1] = L_shr_sat( mem_fx[1], diff ); +#else mem_fx[1] = L_shr_o( mem_fx[1], diff, &Overflow ); +#endif move32(); +#ifdef ISSUE_1799_replace_L_shr_o + mem_fx[2] = L_shr_sat( mem_fx[2], diff ); +#else mem_fx[2] = L_shr_o( mem_fx[2], diff, &Overflow ); +#endif move32(); +#ifdef ISSUE_1799_replace_L_shr_o + mem_fx[3] = L_shr_sat( mem_fx[3], diff ); +#else mem_fx[3] = L_shr_o( mem_fx[3], diff, &Overflow ); +#endif move32(); mem_fx[4] = L_deposit_l( prescale_current_frame ); move32(); diff --git a/lib_com/hq2_noise_inject_fx.c b/lib_com/hq2_noise_inject_fx.c index bc96fe0f8..d8d89d26c 100644 --- a/lib_com/hq2_noise_inject_fx.c +++ b/lib_com/hq2_noise_inject_fx.c @@ -467,7 +467,11 @@ void hq2_noise_inject_fx( } L_tmp = Mult_32_16( Ep_fx[k], fac_fx ); /*Q(Q_Ep_fx[k]+12-15 = Q_Ep_fx[k]-3) */ +#ifdef ISSUE_1799_replace_L_shr_o + ni_gain_fx[k] = L_shr_sat( L_tmp, sub( Q_Ep_fx[k], 20 ) ); +#else ni_gain_fx[k] = L_shr_o( L_tmp, sub( Q_Ep_fx[k], 20 ), &Overflow ); +#endif move32(); /*Q17 */ } ELSE diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c index a41e10713..3df965e20 100644 --- a/lib_com/lsf_tools_fx.c +++ b/lib_com/lsf_tools_fx.c @@ -1800,8 +1800,16 @@ void a2rc_fx( const Word16 *a, /* i: can be any Q */ L_tmp1 = L_mac_o( L_tmp1, tmp, f_fx[n], &Overflow ); /* denom*f[j]+km*denom*f[n] in Q28 (floating with exp) */ L_tmp2 = L_mult( denom_mant, f_fx[n] ); /* denom*f[n]. Q15*Q12 = Q28 (floating with exp) */ L_tmp2 = L_mac_o( L_tmp2, tmp, f_fx[j], &Overflow ); /* denom*f[n]+km*denom*f[j] in Q28 (floating with exp) */ +#ifdef ISSUE_1799_replace_L_shr_o + L_tmp1 = L_shr_sat( L_tmp1, exp ); /* bringing to true Q28 */ +#else L_tmp1 = L_shr_o( L_tmp1, exp, &Overflow ); /* bringing to true Q28 */ +#endif +#ifdef ISSUE_1799_replace_L_shr_o + L_tmp2 = L_shr_sat( L_tmp2, exp ); /* bringing to true Q28 */ +#else L_tmp2 = L_shr_o( L_tmp2, exp, &Overflow ); /* bringing to true Q28 */ +#endif f_fx[j] = round_fx_o( L_tmp1, &Overflow ); /* extracting in q_a */ f_fx[n] = round_fx_o( L_tmp2, &Overflow ); /* extracting in q_a */ } @@ -1810,7 +1818,11 @@ void a2rc_fx( const Word16 *a, /* i: can be any Q */ { L_tmp1 = L_mult( denom_mant, f_fx[j] ); /* denom*f[j]. Q15*Q12 = Q28 (floating with exp) */ L_tmp1 = L_mac_o( L_tmp1, tmp, f_fx[j], &Overflow ); /* denom*f[j]+km*denom*f[j] in Q28 (floating with exp) */ +#ifdef ISSUE_1799_replace_L_shr_o + L_tmp1 = L_shr_sat( L_tmp1, exp ); /* bringing to true Q28 */ +#else L_tmp1 = L_shr_o( L_tmp1, exp, &Overflow ); /* bringing to true Q28 */ +#endif f_fx[j] = round_fx_o( L_tmp1, &Overflow ); /* extracting in q_a */ move16(); } diff --git a/lib_com/lsp_conv_poly_fx.c b/lib_com/lsp_conv_poly_fx.c index 4f493cacd..6c71168c0 100644 --- a/lib_com/lsp_conv_poly_fx.c +++ b/lib_com/lsp_conv_poly_fx.c @@ -423,7 +423,11 @@ static Word32 inv_pow( } tmp = div_s( (Word16) ( ( 1 << 14 ) - 1 ), tmp ); exp1 = add( exp1, exp2 ); +#ifdef ISSUE_1799_replace_L_shr_o + L_tmp = L_shr_sat( tmp, sub( 31, exp1 ) ); /* result in Q15 */ +#else L_tmp = L_shr_o( tmp, sub( 31, exp1 ), &Overflow ); /* result in Q15 */ +#endif return ( L_tmp ); } diff --git a/lib_com/options.h b/lib_com/options.h index 27735895f..7376e28ab 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -112,7 +112,7 @@ #define ISSUE_1751_replace_shl_ro /*FhG: replace shl_ro by overflow-free alternatives*/ #define ISSUE_1770_replace_shr_ro /* FhG: replace by non-overflow-alternative - BE */ #define ISSUE_1772_replace_shr_o /* FhG: replace by non-overflow-alternative - BE */ -//#define ISSUE_1799_replace_L_shr_o /* FhG: replace by non-overflow-alternative - BE */ +#define ISSUE_1799_replace_L_shr_o /* FhG: replace by non-overflow-alternative - BE */ #define FIX_1735_W_SHL_SAT_L /* FhG: Usage of W_shl_sat_l() */ diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index 11da78c46..55a312326 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -593,7 +593,16 @@ Word32 calc_tilt_bwe_fx( /* o : Tilt in Q24 tmp1 = mult_ro( *ptr++, 8192 /*0.25 in Q15 */, &Overflow ); /* Divide by 4 */ L_ener = L_mac0_o( L_ener, tmp1, tmp1, &Overflow ); } +#ifdef ISSUE_1799_replace_L_shr_o + /*Overflow will never happen because exp2 is always positive*/ + L_ener = L_shr( L_ener, exp2 ); +#else +#ifdef ISSUE_1799_replace_L_shr_o + L_ener = L_shr_sat( L_ener, exp2 ); +#else L_ener = L_shr_o( L_ener, exp2, &Overflow ); +#endif +#endif L_temp = L_add_o( L_ener_tot, L_ener, &Overflow ); IF( Overflow != 0 ) { diff --git a/lib_com/syn_filt_fx.c b/lib_com/syn_filt_fx.c index 1216c4533..ebebc266b 100644 --- a/lib_com/syn_filt_fx.c +++ b/lib_com/syn_filt_fx.c @@ -492,7 +492,11 @@ void E_UTIL_synthesis_fx( const Word16 shift, const Word32 a[], const Word32 x[] *-----------------------------------------------------------------------*/ mem += m; /*move32();*/ +#ifdef ISSUE_1799_replace_L_shr_o + a0 = L_shr_sat( a[0], shift ); /* input / 2^shift */ +#else a0 = L_shr_o( a[0], shift, &Overflow ); /* input / 2^shift */ +#endif /*-----------------------------------------------------------------------* * Do the filtering diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index b2974696a..6bc09a10e 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -3300,8 +3300,16 @@ Word32 Calc_Energy_Autoscaled( /* o: Result (Energy) temp = mult_ro( *signal++, 16384, &Overflow ); L_temp = L_mac0_o( L_temp, temp, temp, &Overflow ); } - +#ifdef ISSUE_1799_replace_L_shr_o + /*Overfloe will never happen because temp2 is always positive*/ + L_temp = L_shr( L_temp, temp2 ); +#else +#ifdef ISSUE_1799_replace_L_shr_o + L_temp = L_shr_sat( L_temp, temp2 ); +#else L_temp = L_shr_o( L_temp, temp2, &Overflow ); +#endif +#endif /* Here we try the addition just to check if we can sum the energy of the small (8 Iterations) loop with the total energy calculated so far without an overflow. diff --git a/lib_dec/LD_music_post_filter_fx.c b/lib_dec/LD_music_post_filter_fx.c index 12a13a4ec..da77d6ace 100644 --- a/lib_dec/LD_music_post_filter_fx.c +++ b/lib_dec/LD_music_post_filter_fx.c @@ -599,7 +599,11 @@ static void spectrum_mod_dct_fx( Ltmp = L_mult( tmpN, m_binE ); /*2*Qdct+e_binE+9*/ e_binE = sub( add( e_tmp, e_binE ), 15 ); +#ifdef ISSUE_1799_replace_L_shr_o + Ltmp = L_shr_sat( Ltmp, e_binE ); /*2*Qdct+9*/ +#else Ltmp = L_shr_o( Ltmp, e_binE, &Overflow ); /*2*Qdct+9*/ +#endif Lgain = L_add_o( Ltmp, Lshift, &Overflow ); /*Saturation can occure here result in Q30*/ } diff --git a/lib_dec/pvq_decode_fx.c b/lib_dec/pvq_decode_fx.c index 649840f55..c9ed050a2 100644 --- a/lib_dec/pvq_decode_fx.c +++ b/lib_dec/pvq_decode_fx.c @@ -103,7 +103,11 @@ void pvq_decode_fx( Mpy_32_16_ss( L_isqrt, shl( y[i], shift_num ), &L_tmp, &u16_tmp ); /* Q31*Q(0+x) *2*/ Mpy_32_16_ss( L_tmp, neg_gain_norm, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) *Q15 *2*/ +#ifdef ISSUE_1799_replace_L_shr_o + L_tmp = L_shr_sat( L_tmp, shift_tot ); +#else L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); +#endif xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15 , array move */ move16(); } diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c index 94ed49129..f7a40dbbb 100644 --- a/lib_enc/bw_detect_fx.c +++ b/lib_enc/bw_detect_fx.c @@ -297,7 +297,11 @@ void bw_detect_fx( FOR( i = 0; i < BWD_TOTAL_WIDTH; i++ ) { +#ifdef ISSUE_1799_replace_L_shr_o + spect[i] = round_fx_o( L_shr_sat( spect32[i], Q_dct ), &Overflow ); +#else spect[i] = round_fx_o( L_shr_o( spect32[i], Q_dct, &Overflow ), &Overflow ); +#endif move16(); } Q_dct = -2; diff --git a/lib_enc/energy_fx.c b/lib_enc/energy_fx.c index 0168e52b1..cc0001d4a 100644 --- a/lib_enc/energy_fx.c +++ b/lib_enc/energy_fx.c @@ -42,8 +42,10 @@ void est_energy_fx( const Word16 *Nregion_index; Word32 *sb_power = enerBuffer; Word32 Ltmp32 = 0; +#ifndef ISSUE_1799_replace_L_shr_o #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; +#endif #endif move32(); SNR_sb_num = SNR_SUB_BAND_NUM[bandwidth - CLDFBVAD_NB_ID]; @@ -125,7 +127,11 @@ void est_energy_fx( tmpspec_amp = L_shl( sb_power[j], s16MaxCoefNorm ); /* sb_power_Q + s16MaxCoefNorm */ s32CopyPower = L_add( s32CopyPower, tmpspec_amp ); } +#ifdef ISSUE_1799_replace_L_shr_o + frame_sb_energy[i] = L_shr_sat( s32CopyPower, s16MaxCoefNorm ); /* sb_power_Q */ +#else frame_sb_energy[i] = L_shr_o( s32CopyPower, s16MaxCoefNorm, &Overflow ); /* sb_power_Q */ +#endif move32(); } diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c index a49955e6c..551792d15 100644 --- a/lib_enc/find_tilt_fx.c +++ b/lib_enc/find_tilt_fx.c @@ -175,7 +175,11 @@ void find_tilt_fx( m_tmp = div_s( m_tmp, m_cnt ); /* exp(e_tmp + e_cnt) */ e_tmp = sub( e_tmp, e_cnt ); +#ifdef ISSUE_1799_replace_L_shr_o + lp_E = L_sub_o( L_shr_sat( m_tmp, sub( e_tmp, 1 ) ), lp_bckr, &Overflow ); /* Q_new + QSCALE */ +#else lp_E = L_sub_o( L_shr_o( m_tmp, sub( e_tmp, 1 ), &Overflow ), lp_bckr, &Overflow ); /* Q_new + QSCALE */ +#endif pt_E = tmp_E + VOIC_BINS; /* Update for next half-frame */ } @@ -203,7 +207,11 @@ void find_tilt_fx( m_tmp = div_s( m_tmp, m_hpE ); /* exp(e_tmp + e_hpE) */ e_tmp = sub( e_tmp, e_hpE ); +#ifdef ISSUE_1799_replace_L_shr_o + ee[i] = L_shr_sat( m_tmp, add( e_tmp, 15 - 6 ) ); /* ee in Q6 */ +#else ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ +#endif } ELSE IF( lp_E == 0 ) { @@ -466,7 +474,11 @@ void find_tilt_ivas_fx( m_hpE = extract_h( L_shl( hp_E[i], e_hpE ) ); // e_hpE+q_bckr-16 m_tmp = div_s( m_tmp, m_hpE ); // Q15+(e_tmp+q_lp_E)-(e_hpE+q_bckr) e_tmp = sub( add( e_tmp, q_lp_E ), add( e_hpE, q_bckr ) ); +#ifdef ISSUE_1799_replace_L_shr_o + ee[i] = L_shr_sat( m_tmp, add( e_tmp, 15 - 6 ) ); /* ee in Q6 */ +#else ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ +#endif move32(); } diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 9dcd8386b..272bca9ef 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -188,7 +188,11 @@ Word16 find_uv_fx( /* o : coding type */ exp1 = sub( norm_l( *pt_enr_ssf1 ), 1 ); wtmp1 = extract_h( L_shl( *pt_enr_ssf1, exp1 ) ); fac = div_s( wtmp1, wtmp0 ); +#ifdef ISSUE_1799_replace_L_shr_o + fac_32 = L_shr_sat( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ) ); /* fac32 in Q13*/ +#else fac_32 = L_shr_o( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ), &Overflow ); /* fac32 in Q13*/ +#endif if ( GT_32( fac_32, dE1 ) ) { @@ -680,7 +684,11 @@ Word16 find_uv_ivas_fx( /* o : coding typ exp1 = sub( norm_l( *pt_enr_ssf1 ), 1 ); wtmp1 = extract_h( L_shl( *pt_enr_ssf1, exp1 ) ); fac = div_s( wtmp1, wtmp0 ); +#ifdef ISSUE_1799_replace_L_shr_o + fac_32 = L_shr_sat( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ) ); /* fac32 in Q13*/ +#else fac_32 = L_shr_o( L_deposit_l( fac ), add( sub( exp1, exp0 ), 15 - 13 ), &Overflow ); /* fac32 in Q13*/ +#endif if ( GT_32( fac_32, dE1 ) ) { diff --git a/lib_enc/hvq_enc_fx.c b/lib_enc/hvq_enc_fx.c index a0acd0bfd..f5b129799 100644 --- a/lib_enc/hvq_enc_fx.c +++ b/lib_enc/hvq_enc_fx.c @@ -146,7 +146,11 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits expNfpe3 = extract_l( L_mult0( expNfpe, 3 ) ); /* Cube operation */ /* Number of bits required to adjust to Q15 */ adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ +#ifdef ISSUE_1799_replace_L_shr_o + noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ +#else noise_level[i] = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ +#endif move16(); q_noise_level_idx[i] = quant_lc_fx( noise_level[i], &q_noise_level[i] ); move16(); @@ -177,7 +181,11 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits expo3 = extract_l( L_mult0( expo, 3 ) ); /* Cube operation. */ /* Number of bits required to adjust to Q15 */ adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ +#ifdef ISSUE_1799_replace_L_shr_o + lb_nfpe = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ +#else lb_nfpe = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ +#endif IF( GT_16( lb_nfpe, 16384 ) ) /* in Q15 */ { lb_nfpe = 16384; @@ -323,7 +331,11 @@ Word16 hvq_enc_fx( /*o : Consumed bits expNfpe3 = extract_l( L_mult0( expNfpe, 3 ) ); /* Cube operation */ /* Number of bits required to adjust to Q15 */ adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ +#ifdef ISSUE_1799_replace_L_shr_o + noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ +#else noise_level[i] = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ +#endif move16(); q_noise_level_idx[i] = quant_lc_fx( noise_level[i], &q_noise_level[i] ); move16(); @@ -354,7 +366,11 @@ Word16 hvq_enc_fx( /*o : Consumed bits expo3 = extract_l( L_mult0( expo, 3 ) ); /* Cube operation. */ /* Number of bits required to adjust to Q15 */ adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ +#ifdef ISSUE_1799_replace_L_shr_o + lb_nfpe = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ +#else lb_nfpe = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ +#endif IF( lb_nfpe > 16384 ) /* in Q15 */ { lb_nfpe = 16384; diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 676696fd6..f83030da3 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -1228,7 +1228,11 @@ void noise_est_fx( ExpDen = norm_l( Ltmp ); den = extract_h( L_shl( Ltmp, ExpDen ) ); num = div_s( num, den ); +#ifdef ISSUE_1799_replace_L_shr_o + noise_chartmp = extract_h( L_shr_sat( num, add( sub( ExpNum, ExpDen ), 4 - 16 ) ) ); /* Q11 */ +#else noise_chartmp = extract_h( L_shr_o( num, add( sub( ExpNum, ExpDen ), 4 - 16 ), &Overflow ) ); /* Q11 */ +#endif } noise_chartmp = s_min( noise_chartmp, (Word16) 10 << 11 ); /* Q11 */ @@ -1327,7 +1331,11 @@ void noise_est_fx( den = extract_h( L_shl( Lden, ExpDen ) ); num = div_s( num, den ); Ltmp = Mult_32_16( non_sta, num ); +#ifdef ISSUE_1799_replace_L_shr_o + non_sta = L_shr_sat( Ltmp, sub( ExpNum, ExpDen ) ); /* Q10 */ +#else non_sta = L_shr_o( Ltmp, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ +#endif } /* st->ave_enr[i] = alpha * st->ave_enr[i] + (1-alpha) * enr[i];*/ /* update long-term average */ @@ -1362,7 +1370,11 @@ void noise_est_fx( den = extract_h( L_shl( Lden, ExpDen ) ); num = div_s( num, den ); Ltmp1 = Mult_32_16( Lnon_sta2, num ); +#ifdef ISSUE_1799_replace_L_shr_o + Lnon_sta2 = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ +#else Lnon_sta2 = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ +#endif } /* st_ave_enr2[i] = (float)alpha2 * st_ave_enr2[i] @@ -2678,7 +2690,11 @@ void noise_est_ivas_fx( num = div_s( num, den ); // 15+ExpNum-ExpDen Ltmp1 = Mult_32_16( non_sta, num ); // 15+ExpNum-ExpDen+10-15 +#ifdef ISSUE_1799_replace_L_shr_o + non_sta = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ +#else non_sta = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ +#endif } /* st->ave_enr[i] = alpha * st->ave_enr[i] + (1-alpha) * enr[i];*/ /* update long-term average */ @@ -2717,7 +2733,11 @@ void noise_est_ivas_fx( num = div_s( num, den ); // 15+ExpNum-ExpDen Ltmp1 = Mult_32_16( Lnon_sta2, num ); // 15+ExpNum-ExpDen+10-15 +#ifdef ISSUE_1799_replace_L_shr_o + Lnon_sta2 = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ +#else Lnon_sta2 = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ +#endif } /* st_ave_enr2[i] = (float)alpha2 * st_ave_enr2[i] + (1.0f - alpha2) * (enr[i]) */ diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c index cbeea8f1d..bbf5e18e9 100644 --- a/lib_enc/pitch_ol2_fx.c +++ b/lib_enc/pitch_ol2_fx.c @@ -294,7 +294,11 @@ void StableHighPitchDetect_fx( tmp = abs_s( tmp ); tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ BASOP_SATURATE_WARNING_OFF_EVS +#ifdef ISSUE_1799_replace_L_shr_o + diff = L_negate( L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); +#else diff = L_negate( L_shr_o( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ), &Overflow ) ); +#endif BASOP_SATURATE_WARNING_ON_EVS diff16 = round_fx_o( diff, &Overflow ); } @@ -302,7 +306,11 @@ void StableHighPitchDetect_fx( { tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ BASOP_SATURATE_WARNING_OFF_EVS +#ifdef ISSUE_1799_replace_L_shr_o + diff = L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); +#else diff = L_shr_o( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ), &Overflow ); +#endif BASOP_SATURATE_WARNING_ON_EVS diff16 = round_fx_o( diff, &Overflow ); } @@ -509,7 +517,11 @@ void StableHighPitchDetect_ivas_fx( tmp = abs_s( tmp ); tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ BASOP_SATURATE_WARNING_OFF_EVS +#ifdef ISSUE_1799_replace_L_shr_o + diff = L_negate( L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); +#else diff = L_negate( L_shr_o( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ), &Overflow ) ); +#endif BASOP_SATURATE_WARNING_ON_EVS diff16 = round_fx_o( diff, &Overflow ); } @@ -517,7 +529,11 @@ void StableHighPitchDetect_ivas_fx( { tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ BASOP_SATURATE_WARNING_OFF_EVS +#ifdef ISSUE_1799_replace_L_shr_o + diff = L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); +#else diff = L_shr_o( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ), &Overflow ); +#endif BASOP_SATURATE_WARNING_ON_EVS diff16 = round_fx_o( diff, &Overflow ); } diff --git a/lib_enc/pitch_ol_fx.c b/lib_enc/pitch_ol_fx.c index 79c55821e..d4e3284da 100644 --- a/lib_enc/pitch_ol_fx.c +++ b/lib_enc/pitch_ol_fx.c @@ -751,7 +751,11 @@ void pitch_ol_fx( Ltmp = L_mult0( cor_buf[ind], enr1 ); qCorX = add( sub( 15, enr1_exp ), sub( 14, pt_exp1[ind] ) ); +#ifdef ISSUE_1799_replace_L_shr_o + corX[i][j] = extract_h( L_shr_sat( Ltmp, sub( qCorX, 31 ) ) ); +#else corX[i][j] = extract_h( L_shr_o( Ltmp, sub( qCorX, 31 ), &Overflow ) ); +#endif qCorX = 31; move16(); @@ -788,7 +792,11 @@ void pitch_ol_fx( Ltmp = L_mult0( cor_buf[ind1 + len_x], enr1 ); qCorX = add( sub( 15, enr1_exp ), sub( 14, pt_exp3[ind1] ) ); +#ifdef ISSUE_1799_replace_L_shr_o + corX[i][j + NSECT] = extract_h( L_shr_sat( Ltmp, qCorX - 31 ) ); +#else corX[i][j + NSECT] = extract_h( L_shr_o( Ltmp, qCorX - 31, &Overflow ) ); +#endif qCorX = 31; move16(); diff --git a/lib_enc/pvq_encode_fx.c b/lib_enc/pvq_encode_fx.c index 749a39ed9..275eba5cb 100644 --- a/lib_enc/pvq_encode_fx.c +++ b/lib_enc/pvq_encode_fx.c @@ -359,7 +359,11 @@ void pvq_encode_ivas_fx( } Mpy_32_16_ss( L_isqrt, tmp, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) +1 */ Mpy_32_16_ss( L_tmp, neg_gain_norm, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) *Q15 +1 */ +#ifdef ISSUE_1799_replace_L_shr_o + L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ +#else L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ +#endif xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ move16(); L_xq[i] = L_tmp; /* Q31 currently unused */ @@ -567,7 +571,11 @@ void pvq_encode_fx( } Mpy_32_16_ss( L_isqrt, tmp, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) +1 */ Mpy_32_16_ss( L_tmp, neg_gain_norm, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) *Q15 +1 */ +#ifdef ISSUE_1799_replace_L_shr_o + L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ +#else L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ +#endif xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ move16(); L_xq[i] = L_tmp; /* Q31 currently unused */ diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 59f3b35f6..4729844fd 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -1500,11 +1500,19 @@ static Word16 attack_det_fx( /* o : attack flag exp1 = norm_s( att_3lsub_pos ); tmp = div_s( shl( 1, sub( 14, exp1 ) ), att_3lsub_pos ); /*Q(29-exp1) */ +#ifdef ISSUE_1799_replace_L_shr_o + L_tmp = L_shr_sat( finc[0], Qx ); /*Qx */ +#else L_tmp = L_shr_o( finc[0], Qx, &Overflow ); /*Qx */ +#endif FOR( i = 1; i < att_3lsub_pos; i++ ) { +#ifdef ISSUE_1799_replace_L_shr_o + L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i], Qx ), &Overflow ); /*Qx */ +#else L_tmp = L_add_o( L_tmp, L_shr_o( finc[i], Qx, &Overflow ), &Overflow ); /*Qx */ +#endif } L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(14-exp1+Qx) */ etmp = L_shl( L_tmp, sub( exp1, 14 ) ); /*Qx */ @@ -1513,10 +1521,18 @@ static Word16 attack_det_fx( /* o : attack flag exp1 = norm_s( tmp1 ); tmp = div_s( shl( 1, sub( 14, exp1 ) ), tmp1 ); /*Q(29-exp1) */ +#ifdef ISSUE_1799_replace_L_shr_o + L_tmp = L_shr_sat( finc[attack], Qx ); /*Qx */ +#else L_tmp = L_shr_o( finc[attack], Qx, &Overflow ); /*Qx */ +#endif FOR( i = 1; i < tmp1; i++ ) { +#ifdef ISSUE_1799_replace_L_shr_o + L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i + attack], Qx ), &Overflow ); /*Qx */ +#else L_tmp = L_add_o( L_tmp, L_shr_o( finc[i + attack], Qx, &Overflow ), &Overflow ); /*Qx */ +#endif } L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(14-exp1+Qx) */ etmp2 = L_shl( L_tmp, sub( exp1, 14 ) ); /*Qx */ diff --git a/lib_enc/swb_bwe_enc_hr_fx.c b/lib_enc/swb_bwe_enc_hr_fx.c index 8b5a17353..f510a1cb6 100644 --- a/lib_enc/swb_bwe_enc_hr_fx.c +++ b/lib_enc/swb_bwe_enc_hr_fx.c @@ -767,7 +767,11 @@ void swb_bwe_enc_hr_fx( FOR( i = 0; i < Nsv2 * WIDTH_BAND; i++ ) { L_tmp = L_mult( temp, t_audio_fx[i] ); +#ifdef ISSUE_1799_replace_L_shr_o + L_tmp = L_shr_sat( L_tmp, temp2 ); +#else L_tmp = L_shr_o( L_tmp, temp2, &Overflow ); +#endif t_audio_fx[i] = round_fx_o( L_tmp, &Overflow ); move16(); } diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index 6b65f9afa..e1327e7e0 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -7386,7 +7386,11 @@ void fb_tbe_enc_fx( tmp = div_s( tmp2, tmp ); L_tmp = L_deposit_h( tmp ); L_tmp = Isqrt_lc( L_tmp, &exp ); /*Q(31-exp)*/ +#ifdef ISSUE_1799_replace_L_shr_o + L_tmp = L_max( L_shr_sat( L_tmp, sub( 31, exp ) ), 0x1 ); /* Q0 */ +#else L_tmp = L_max( L_shr_o( L_tmp, sub( 31, exp ), &Overflow ), 0x1 ); /* Q0 */ +#endif } ELSE { diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 1cf7a5de8..fe495c2a9 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -1014,7 +1014,11 @@ Word16 wb_vad_fx( m_num = shr( m_num, 1 ); shift_snr = add( sub( e_num, e_noise ), 15 - 4 ); snr_tmp = div_s( m_num, m_noise_local ); +#ifdef ISSUE_1799_replace_L_shr_o + L_snr = L_shr_sat( snr_tmp, shift_snr ); /* L_snr in Q4 */ +#else L_snr = L_shr_o( snr_tmp, shift_snr, &Overflow ); /* L_snr in Q4 */ +#endif } ELSE { @@ -1047,7 +1051,11 @@ Word16 wb_vad_fx( shift_snr = add( sub( e_num, e_noise ), 15 - 4 ); snr_tmp = div_s( m_num, m_noise_local ); +#ifdef ISSUE_1799_replace_L_shr_o + L_snr = L_shr_sat( snr_tmp, shift_snr ); /* L_snr in Q4 */ +#else L_snr = L_shr_o( snr_tmp, shift_snr, &Overflow ); /* L_snr in Q4 */ +#endif } ELSE { @@ -1148,7 +1156,11 @@ Word16 wb_vad_fx( shift_snr = add( sub( e_num, e_noise ), 15 - 4 ); snr_tmp = div_s( m_num, m_noise_local ); +#ifdef ISSUE_1799_replace_L_shr_o + L_snr = L_shr_sat( snr_tmp, shift_snr ); /* L_snr in Q4 */ +#else L_snr = L_shr_o( snr_tmp, shift_snr, &Overflow ); /* L_snr in Q4 */ +#endif } ELSE { -- GitLab From 283e31088b9701cc7b71b09b3aa2c89e79e040ad Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 3 Jul 2025 15:47:06 +0200 Subject: [PATCH 06/22] clang patch --- lib_com/cldfb_evs_fx.c | 8 ++++---- lib_com/cldfb_fx.c | 10 +++++----- lib_com/cng_exc_fx.c | 8 ++++---- lib_com/edct_fx.c | 8 ++++---- lib_com/frame_ener_fx.c | 6 +++--- lib_com/lsf_tools_fx.c | 18 +++++++++--------- lib_com/syn_filt_fx.c | 4 ++-- lib_com/tools_fx.c | 4 ++-- lib_dec/LD_music_post_filter_fx.c | 4 ++-- lib_enc/bw_detect_fx.c | 4 ++-- lib_enc/find_tilt_fx.c | 6 +++--- lib_enc/find_uv_fx.c | 2 +- lib_enc/hvq_enc_fx.c | 16 ++++++++-------- lib_enc/nois_est_fx.c | 16 ++++++++-------- lib_enc/pitch_ol2_fx.c | 8 ++++---- lib_enc/pvq_encode_fx.c | 12 ++++++------ lib_enc/speech_music_classif_fx.c | 14 +++++++------- lib_enc/swb_tbe_enc_fx.c | 2 +- lib_enc/vad_fx.c | 2 +- 19 files changed, 76 insertions(+), 76 deletions(-) diff --git a/lib_com/cldfb_evs_fx.c b/lib_com/cldfb_evs_fx.c index ed5b95be2..710ecf121 100644 --- a/lib_com/cldfb_evs_fx.c +++ b/lib_com/cldfb_evs_fx.c @@ -1329,8 +1329,8 @@ void GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead) { FOR( j = 20; j < numberBandsM; j++ ) { -#ifdef ISSUE_1799_replace_L_shr_o - nrg = L_add_o( nrg, L_shr_sat( energyValues[k][j], s ), &Overflow ); +#ifdef ISSUE_1799_replace_L_shr_o + nrg = L_add_o( nrg, L_shr_sat( energyValues[k][j], s ), &Overflow ); #else nrg = L_add_o( nrg, L_shr_o( energyValues[k][j], s, &Overflow ), &Overflow ); #endif @@ -1356,8 +1356,8 @@ void GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead) { FOR( j = 20; j < numberBandsM; j++ ) { -#ifdef ISSUE_1799_replace_L_shr_o - nrg = L_add_o( nrg, L_shr_sat( energyValues[k][j], s ), &Overflow ); +#ifdef ISSUE_1799_replace_L_shr_o + nrg = L_add_o( nrg, L_shr_sat( energyValues[k][j], s ), &Overflow ); #else nrg = L_add_o( nrg, L_shr_o( energyValues[k][j], s, &Overflow ), &Overflow ); #endif diff --git a/lib_com/cldfb_fx.c b/lib_com/cldfb_fx.c index efeb2ac28..244967c20 100644 --- a/lib_com/cldfb_fx.c +++ b/lib_com/cldfb_fx.c @@ -1905,8 +1905,8 @@ static void GetEnergyCldfb_ivas_fx( Word32 *energyLookahead, /*!< o: Q(*sf_e { FOR( j = 20; j < numberBandsM; j++ ) { -#ifdef ISSUE_1799_replace_L_shr_o - nrg = L_add_o( nrg, L_shr_sat( energyValues[k][j], s ), &Overflow ); +#ifdef ISSUE_1799_replace_L_shr_o + nrg = L_add_o( nrg, L_shr_sat( energyValues[k][j], s ), &Overflow ); #else nrg = L_add_o( nrg, L_shr_o( energyValues[k][j], s, &Overflow ), &Overflow ); #endif @@ -1932,8 +1932,8 @@ static void GetEnergyCldfb_ivas_fx( Word32 *energyLookahead, /*!< o: Q(*sf_e { FOR( j = 20; j < numberBandsM; j++ ) { -#ifdef ISSUE_1799_replace_L_shr_o - nrg = L_add_o( nrg, L_shr_sat( energyValues[k][j], s ), &Overflow ); +#ifdef ISSUE_1799_replace_L_shr_o + nrg = L_add_o( nrg, L_shr_sat( energyValues[k][j], s ), &Overflow ); #else nrg = L_add_o( nrg, L_shr_o( energyValues[k][j], s, &Overflow ), &Overflow ); #endif @@ -2085,7 +2085,7 @@ static void cldfb_init_proto_and_twiddles( #ifdef OPT_IVAS_FILTER_ROM hs->p_filter_32 = CLDFB80_10_fx; #else /* OPT_IVAS_FILTER_ROM */ - hs->p_filter_sf = (Word16) 17036; // Q14 + hs->p_filter_sf = (Word16) 17036; // Q14 hs->p_filter = CLDFB80_10_fx; #endif /* OPT_IVAS_FILTER_ROM */ hs->scale = CLDFB80_10_SCALE_FX_Q8; diff --git a/lib_com/cng_exc_fx.c b/lib_com/cng_exc_fx.c index 4e5fb1ad1..00ce93218 100644 --- a/lib_com/cng_exc_fx.c +++ b/lib_com/cng_exc_fx.c @@ -907,7 +907,7 @@ void cng_params_upd_fx( #ifdef ISSUE_1799_replace_L_shr_o L_ener = L_add_o( L_ener, L_shr_sat( L_tmp, 7 ), &Overflow ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */ #else - L_ener = L_add_o( L_ener, L_shr_o( L_tmp, 7, &Overflow ), &Overflow ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */ + L_ener = L_add_o( L_ener, L_shr_o( L_tmp, 7, &Overflow ), &Overflow ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */ #endif } } @@ -931,7 +931,7 @@ void cng_params_upd_fx( #ifdef ISSUE_1799_replace_L_shr_o L_ener = L_shr_sat( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ) ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */ #else - L_ener = L_shr_o( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ), &Overflow ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */ + L_ener = L_shr_o( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ), &Overflow ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */ #endif /* update the circular buffer of old energies */ @@ -1097,7 +1097,7 @@ void cng_params_upd_ivas_fx( #ifdef ISSUE_1799_replace_L_shr_o L_ener = L_add_o( L_ener, L_shr_sat( L_tmp, 7 ), &Overflow ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */ #else - L_ener = L_add_o( L_ener, L_shr_o( L_tmp, 7, &Overflow ), &Overflow ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */ + L_ener = L_add_o( L_ener, L_shr_o( L_tmp, 7, &Overflow ), &Overflow ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */ #endif } } @@ -1121,7 +1121,7 @@ void cng_params_upd_ivas_fx( #ifdef ISSUE_1799_replace_L_shr_o L_ener = L_shr_sat( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ) ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */ #else - L_ener = L_shr_o( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ), &Overflow ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */ + L_ener = L_shr_o( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ), &Overflow ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */ #endif /* update the circular buffer of old energies */ diff --git a/lib_com/edct_fx.c b/lib_com/edct_fx.c index eae0dfb73..c30ed4a57 100644 --- a/lib_com/edct_fx.c +++ b/lib_com/edct_fx.c @@ -502,8 +502,8 @@ void edct_16fx( { i2 = shl( i, 1 ); - L_tmp = L_mult( re[i], edct_table[i] ); /*Q(Qx+Q_edct+16) */ - Lacc = L_mac_o( L_tmp, im[i], *pt, &Overflow ); /*Q(Qx+Q_edct+16) */ + L_tmp = L_mult( re[i], edct_table[i] ); /*Q(Qx+Q_edct+16) */ + Lacc = L_mac_o( L_tmp, im[i], *pt, &Overflow ); /*Q(Qx+Q_edct+16) */ #ifdef ISSUE_1799_replace_L_shr_o y[i2] = round_fx_o( L_shr_sat( Lacc, Q_edct ), &Overflow ); /* Q(Qx) */ #else @@ -514,9 +514,9 @@ void edct_16fx( L_tmp = L_mult( re[i], edct_table[sub( shr( length, 1 ), add( 1, i ) )] ); /*Q(Qx+Q_edct+16) */ Lacc = L_msu( L_tmp, im[i], edct_table[i] ); /*Q(Qx+Q_edct+16) */ #ifdef ISSUE_1799_replace_L_shr_o - *py = round_fx_o( L_shr_sat( Lacc, Q_edct ), &Overflow ); /* Q(Qx) */ + *py = round_fx_o( L_shr_sat( Lacc, Q_edct ), &Overflow ); /* Q(Qx) */ #else - *py = round_fx_o( L_shr_o( Lacc, Q_edct, &Overflow ), &Overflow ); /* Q(Qx) */ + *py = round_fx_o( L_shr_o( Lacc, Q_edct, &Overflow ), &Overflow ); /* Q(Qx) */ #endif move16(); diff --git a/lib_com/frame_ener_fx.c b/lib_com/frame_ener_fx.c index 57d6e83e7..f3dbe52bd 100644 --- a/lib_com/frame_ener_fx.c +++ b/lib_com/frame_ener_fx.c @@ -276,11 +276,11 @@ Word16 frame_energy_fx( /* o : Frame energy in Q8 exp1 = sub( 15 + exp1, tmp2 ); /*add ld(2^exp1)=exp1 but check format, first*/ - tmp16 = sub( sub( 15, norm_s( exp1 ) ), 5 ); /*factor to shift Ltmp and exp1 with (shr) to avoid overflows when adding*/ + tmp16 = sub( sub( 15, norm_s( exp1 ) ), 5 ); /*factor to shift Ltmp and exp1 with (shr) to avoid overflows when adding*/ #ifdef ISSUE_1799_replace_L_shr_o - Ltmp = L_shr_sat( Ltmp, tmp16 ); /*Q25, tmp16*/ + Ltmp = L_shr_sat( Ltmp, tmp16 ); /*Q25, tmp16*/ #else - Ltmp = L_shr_o( Ltmp, tmp16, &Overflow ); /*Q25, tmp16*/ + Ltmp = L_shr_o( Ltmp, tmp16, &Overflow ); /*Q25, tmp16*/ #endif exp2 = shr( exp1, tmp16 ); /*Q0 , tmp16*/ Ltmp = L_add_o( Ltmp, L_shl( L_deposit_l( exp2 ), 25 ), &Overflow ); /*Q25, tmp16, normalized*/ diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c index 3df965e20..7bea09cfd 100644 --- a/lib_com/lsf_tools_fx.c +++ b/lib_com/lsf_tools_fx.c @@ -1801,17 +1801,17 @@ void a2rc_fx( const Word16 *a, /* i: can be any Q */ L_tmp2 = L_mult( denom_mant, f_fx[n] ); /* denom*f[n]. Q15*Q12 = Q28 (floating with exp) */ L_tmp2 = L_mac_o( L_tmp2, tmp, f_fx[j], &Overflow ); /* denom*f[n]+km*denom*f[j] in Q28 (floating with exp) */ #ifdef ISSUE_1799_replace_L_shr_o - L_tmp1 = L_shr_sat( L_tmp1, exp ); /* bringing to true Q28 */ + L_tmp1 = L_shr_sat( L_tmp1, exp ); /* bringing to true Q28 */ #else - L_tmp1 = L_shr_o( L_tmp1, exp, &Overflow ); /* bringing to true Q28 */ + L_tmp1 = L_shr_o( L_tmp1, exp, &Overflow ); /* bringing to true Q28 */ #endif #ifdef ISSUE_1799_replace_L_shr_o - L_tmp2 = L_shr_sat( L_tmp2, exp ); /* bringing to true Q28 */ + L_tmp2 = L_shr_sat( L_tmp2, exp ); /* bringing to true Q28 */ #else - L_tmp2 = L_shr_o( L_tmp2, exp, &Overflow ); /* bringing to true Q28 */ + L_tmp2 = L_shr_o( L_tmp2, exp, &Overflow ); /* bringing to true Q28 */ #endif - f_fx[j] = round_fx_o( L_tmp1, &Overflow ); /* extracting in q_a */ - f_fx[n] = round_fx_o( L_tmp2, &Overflow ); /* extracting in q_a */ + f_fx[j] = round_fx_o( L_tmp1, &Overflow ); /* extracting in q_a */ + f_fx[n] = round_fx_o( L_tmp2, &Overflow ); /* extracting in q_a */ } IF( m & 1 ) @@ -1819,11 +1819,11 @@ void a2rc_fx( const Word16 *a, /* i: can be any Q */ L_tmp1 = L_mult( denom_mant, f_fx[j] ); /* denom*f[j]. Q15*Q12 = Q28 (floating with exp) */ L_tmp1 = L_mac_o( L_tmp1, tmp, f_fx[j], &Overflow ); /* denom*f[j]+km*denom*f[j] in Q28 (floating with exp) */ #ifdef ISSUE_1799_replace_L_shr_o - L_tmp1 = L_shr_sat( L_tmp1, exp ); /* bringing to true Q28 */ + L_tmp1 = L_shr_sat( L_tmp1, exp ); /* bringing to true Q28 */ #else - L_tmp1 = L_shr_o( L_tmp1, exp, &Overflow ); /* bringing to true Q28 */ + L_tmp1 = L_shr_o( L_tmp1, exp, &Overflow ); /* bringing to true Q28 */ #endif - f_fx[j] = round_fx_o( L_tmp1, &Overflow ); /* extracting in q_a */ + f_fx[j] = round_fx_o( L_tmp1, &Overflow ); /* extracting in q_a */ move16(); } } diff --git a/lib_com/syn_filt_fx.c b/lib_com/syn_filt_fx.c index ebebc266b..ed2c91493 100644 --- a/lib_com/syn_filt_fx.c +++ b/lib_com/syn_filt_fx.c @@ -200,7 +200,7 @@ void syn_filt_fx( #ifdef ISSUE_1772_replace_shr_o a0 = shr_sat( a[0], shift ); /* input / 2^shift */ #else - a0 = shr_o( a[0], shift, &Overflow ); /* input / 2^shift */ + a0 = shr_o( a[0], shift, &Overflow ); /* input / 2^shift */ #endif /*------------------------------------------------------------------* @@ -382,7 +382,7 @@ void E_UTIL_synthesis( const Word16 shift, const Word16 a[], const Word16 x[], W #ifdef ISSUE_1772_replace_shr_o a0 = shr_sat( a[0], shift ); /* input / 2^shift */ #else - a0 = shr_o( a[0], shift, &Overflow ); /* input / 2^shift */ + a0 = shr_o( a[0], shift, &Overflow ); /* input / 2^shift */ #endif /*-----------------------------------------------------------------------* * Do the filtering diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index 6bc09a10e..ebc0211a3 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -3301,8 +3301,8 @@ Word32 Calc_Energy_Autoscaled( /* o: Result (Energy) L_temp = L_mac0_o( L_temp, temp, temp, &Overflow ); } #ifdef ISSUE_1799_replace_L_shr_o - /*Overfloe will never happen because temp2 is always positive*/ - L_temp = L_shr( L_temp, temp2 ); + /*Overfloe will never happen because temp2 is always positive*/ + L_temp = L_shr( L_temp, temp2 ); #else #ifdef ISSUE_1799_replace_L_shr_o L_temp = L_shr_sat( L_temp, temp2 ); diff --git a/lib_dec/LD_music_post_filter_fx.c b/lib_dec/LD_music_post_filter_fx.c index da77d6ace..a45072dec 100644 --- a/lib_dec/LD_music_post_filter_fx.c +++ b/lib_dec/LD_music_post_filter_fx.c @@ -600,9 +600,9 @@ static void spectrum_mod_dct_fx( Ltmp = L_mult( tmpN, m_binE ); /*2*Qdct+e_binE+9*/ e_binE = sub( add( e_tmp, e_binE ), 15 ); #ifdef ISSUE_1799_replace_L_shr_o - Ltmp = L_shr_sat( Ltmp, e_binE ); /*2*Qdct+9*/ + Ltmp = L_shr_sat( Ltmp, e_binE ); /*2*Qdct+9*/ #else - Ltmp = L_shr_o( Ltmp, e_binE, &Overflow ); /*2*Qdct+9*/ + Ltmp = L_shr_o( Ltmp, e_binE, &Overflow ); /*2*Qdct+9*/ #endif Lgain = L_add_o( Ltmp, Lshift, &Overflow ); /*Saturation can occure here result in Q30*/ } diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c index f7a40dbbb..3a389be22 100644 --- a/lib_enc/bw_detect_fx.c +++ b/lib_enc/bw_detect_fx.c @@ -297,8 +297,8 @@ void bw_detect_fx( FOR( i = 0; i < BWD_TOTAL_WIDTH; i++ ) { -#ifdef ISSUE_1799_replace_L_shr_o - spect[i] = round_fx_o( L_shr_sat( spect32[i], Q_dct ), &Overflow ); +#ifdef ISSUE_1799_replace_L_shr_o + spect[i] = round_fx_o( L_shr_sat( spect32[i], Q_dct ), &Overflow ); #else spect[i] = round_fx_o( L_shr_o( spect32[i], Q_dct, &Overflow ), &Overflow ); #endif diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c index 551792d15..0a862f3f9 100644 --- a/lib_enc/find_tilt_fx.c +++ b/lib_enc/find_tilt_fx.c @@ -178,7 +178,7 @@ void find_tilt_fx( #ifdef ISSUE_1799_replace_L_shr_o lp_E = L_sub_o( L_shr_sat( m_tmp, sub( e_tmp, 1 ) ), lp_bckr, &Overflow ); /* Q_new + QSCALE */ #else - lp_E = L_sub_o( L_shr_o( m_tmp, sub( e_tmp, 1 ), &Overflow ), lp_bckr, &Overflow ); /* Q_new + QSCALE */ + lp_E = L_sub_o( L_shr_o( m_tmp, sub( e_tmp, 1 ), &Overflow ), lp_bckr, &Overflow ); /* Q_new + QSCALE */ #endif pt_E = tmp_E + VOIC_BINS; /* Update for next half-frame */ @@ -210,7 +210,7 @@ void find_tilt_fx( #ifdef ISSUE_1799_replace_L_shr_o ee[i] = L_shr_sat( m_tmp, add( e_tmp, 15 - 6 ) ); /* ee in Q6 */ #else - ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ + ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ #endif } ELSE IF( lp_E == 0 ) @@ -477,7 +477,7 @@ void find_tilt_ivas_fx( #ifdef ISSUE_1799_replace_L_shr_o ee[i] = L_shr_sat( m_tmp, add( e_tmp, 15 - 6 ) ); /* ee in Q6 */ #else - ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ + ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ #endif move32(); } diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 272bca9ef..718836515 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -81,7 +81,7 @@ static Word16 find_ener_decrease_fx( /* o : maximum #ifdef ISSUE_1770_replace_shr_ro dE2 = shr_r_sat( wtmp1, add( sub( exp1, exp0 ), 15 - 10 ) ); /*Q10*/ #else - dE2 = shr_ro( wtmp1, add( sub( exp1, exp0 ), 15 - 10 ), &Overflow ); /*Q10*/ + dE2 = shr_ro( wtmp1, add( sub( exp1, exp0 ), 15 - 10 ), &Overflow ); /*Q10*/ #endif return dE2; diff --git a/lib_enc/hvq_enc_fx.c b/lib_enc/hvq_enc_fx.c index f5b129799..222aed4c2 100644 --- a/lib_enc/hvq_enc_fx.c +++ b/lib_enc/hvq_enc_fx.c @@ -145,7 +145,7 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits acc = L_mult( tmp16, HVQ_NFPE_FACTOR_CUBE_FX ); /* in Q(12+6+1) = Q19 */ expNfpe3 = extract_l( L_mult0( expNfpe, 3 ) ); /* Cube operation */ /* Number of bits required to adjust to Q15 */ - adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ + adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ #ifdef ISSUE_1799_replace_L_shr_o noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ #else @@ -180,13 +180,13 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits 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. */ /* Number of bits required to adjust to Q15 */ - adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ + adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ #ifdef ISSUE_1799_replace_L_shr_o lb_nfpe = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ #else - lb_nfpe = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ + lb_nfpe = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ #endif - IF( GT_16( lb_nfpe, 16384 ) ) /* in Q15 */ + IF( GT_16( lb_nfpe, 16384 ) ) /* in Q15 */ { lb_nfpe = 16384; move16(); @@ -330,7 +330,7 @@ Word16 hvq_enc_fx( /*o : Consumed bits acc = L_mult( tmp16, HVQ_NFPE_FACTOR_CUBE_FX ); /* in Q(12+6+1) = Q19 */ expNfpe3 = extract_l( L_mult0( expNfpe, 3 ) ); /* Cube operation */ /* Number of bits required to adjust to Q15 */ - adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ + adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ #ifdef ISSUE_1799_replace_L_shr_o noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ #else @@ -365,13 +365,13 @@ Word16 hvq_enc_fx( /*o : Consumed bits 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. */ /* Number of bits required to adjust to Q15 */ - adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ + adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ #ifdef ISSUE_1799_replace_L_shr_o lb_nfpe = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ #else - lb_nfpe = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ + lb_nfpe = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ #endif - IF( lb_nfpe > 16384 ) /* in Q15 */ + IF( lb_nfpe > 16384 ) /* in Q15 */ { lb_nfpe = 16384; move16(); diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index f83030da3..9c0ae90a3 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -1334,7 +1334,7 @@ void noise_est_fx( #ifdef ISSUE_1799_replace_L_shr_o non_sta = L_shr_sat( Ltmp, sub( ExpNum, ExpDen ) ); /* Q10 */ #else - non_sta = L_shr_o( Ltmp, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ + non_sta = L_shr_o( Ltmp, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ #endif } @@ -1373,7 +1373,7 @@ void noise_est_fx( #ifdef ISSUE_1799_replace_L_shr_o Lnon_sta2 = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ #else - Lnon_sta2 = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ + Lnon_sta2 = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ #endif } @@ -2688,12 +2688,12 @@ void noise_est_ivas_fx( ExpDen = norm_l( Lden ); den = extract_h( L_shl( Lden, ExpDen ) ); // q_enr+ExpDen-16 - num = div_s( num, den ); // 15+ExpNum-ExpDen - Ltmp1 = Mult_32_16( non_sta, num ); // 15+ExpNum-ExpDen+10-15 + num = div_s( num, den ); // 15+ExpNum-ExpDen + Ltmp1 = Mult_32_16( non_sta, num ); // 15+ExpNum-ExpDen+10-15 #ifdef ISSUE_1799_replace_L_shr_o non_sta = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ #else - non_sta = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ + non_sta = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ #endif } @@ -2731,12 +2731,12 @@ void noise_est_ivas_fx( ExpDen = norm_l( Lden ); den = extract_h( L_shl( Lden, ExpDen ) ); // q_enr+ExpDen-16 - num = div_s( num, den ); // 15+ExpNum-ExpDen - Ltmp1 = Mult_32_16( Lnon_sta2, num ); // 15+ExpNum-ExpDen+10-15 + num = div_s( num, den ); // 15+ExpNum-ExpDen + Ltmp1 = Mult_32_16( Lnon_sta2, num ); // 15+ExpNum-ExpDen+10-15 #ifdef ISSUE_1799_replace_L_shr_o Lnon_sta2 = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ #else - Lnon_sta2 = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ + Lnon_sta2 = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ #endif } diff --git a/lib_enc/pitch_ol2_fx.c b/lib_enc/pitch_ol2_fx.c index bbf5e18e9..de47d85af 100644 --- a/lib_enc/pitch_ol2_fx.c +++ b/lib_enc/pitch_ol2_fx.c @@ -295,7 +295,7 @@ void StableHighPitchDetect_fx( tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ BASOP_SATURATE_WARNING_OFF_EVS #ifdef ISSUE_1799_replace_L_shr_o - diff = L_negate( L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); + diff = L_negate( L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); #else diff = L_negate( L_shr_o( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ), &Overflow ) ); #endif @@ -307,7 +307,7 @@ void StableHighPitchDetect_fx( tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ BASOP_SATURATE_WARNING_OFF_EVS #ifdef ISSUE_1799_replace_L_shr_o - diff = L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); + diff = L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); #else diff = L_shr_o( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ), &Overflow ); #endif @@ -518,7 +518,7 @@ void StableHighPitchDetect_ivas_fx( tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ BASOP_SATURATE_WARNING_OFF_EVS #ifdef ISSUE_1799_replace_L_shr_o - diff = L_negate( L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); + diff = L_negate( L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ) ); #else diff = L_negate( L_shr_o( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ), &Overflow ) ); #endif @@ -530,7 +530,7 @@ void StableHighPitchDetect_ivas_fx( tmp = div_s( 16384, tmp ); /*Q(15+exp)*/ BASOP_SATURATE_WARNING_OFF_EVS #ifdef ISSUE_1799_replace_L_shr_o - diff = L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); + diff = L_shr_sat( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ) ); #else diff = L_shr_o( Mult_32_16( diff, tmp ), sub( exp + 7, 31 ), &Overflow ); #endif diff --git a/lib_enc/pvq_encode_fx.c b/lib_enc/pvq_encode_fx.c index 275eba5cb..d08b8a902 100644 --- a/lib_enc/pvq_encode_fx.c +++ b/lib_enc/pvq_encode_fx.c @@ -360,11 +360,11 @@ void pvq_encode_ivas_fx( Mpy_32_16_ss( L_isqrt, tmp, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) +1 */ Mpy_32_16_ss( L_tmp, neg_gain_norm, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) *Q15 +1 */ #ifdef ISSUE_1799_replace_L_shr_o - L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ + L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ #else - L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ + L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ #endif - xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ + xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ move16(); L_xq[i] = L_tmp; /* Q31 currently unused */ move32(); @@ -572,11 +572,11 @@ void pvq_encode_fx( Mpy_32_16_ss( L_isqrt, tmp, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) +1 */ Mpy_32_16_ss( L_tmp, neg_gain_norm, &L_tmp, &u16_tmp ); /* Q31*Q(0+x) *Q15 +1 */ #ifdef ISSUE_1799_replace_L_shr_o - L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ + L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ #else - L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ + L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ #endif - xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ + xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ move16(); L_xq[i] = L_tmp; /* Q31 currently unused */ move32(); diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 4729844fd..3bf4a53bf 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -1503,15 +1503,15 @@ static Word16 attack_det_fx( /* o : attack flag #ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_shr_sat( finc[0], Qx ); /*Qx */ #else - L_tmp = L_shr_o( finc[0], Qx, &Overflow ); /*Qx */ + L_tmp = L_shr_o( finc[0], Qx, &Overflow ); /*Qx */ #endif FOR( i = 1; i < att_3lsub_pos; i++ ) { -#ifdef ISSUE_1799_replace_L_shr_o - L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i], Qx ), &Overflow ); /*Qx */ +#ifdef ISSUE_1799_replace_L_shr_o + L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i], Qx ), &Overflow ); /*Qx */ #else - L_tmp = L_add_o( L_tmp, L_shr_o( finc[i], Qx, &Overflow ), &Overflow ); /*Qx */ + L_tmp = L_add_o( L_tmp, L_shr_o( finc[i], Qx, &Overflow ), &Overflow ); /*Qx */ #endif } L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(14-exp1+Qx) */ @@ -1524,12 +1524,12 @@ static Word16 attack_det_fx( /* o : attack flag #ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_shr_sat( finc[attack], Qx ); /*Qx */ #else - L_tmp = L_shr_o( finc[attack], Qx, &Overflow ); /*Qx */ + L_tmp = L_shr_o( finc[attack], Qx, &Overflow ); /*Qx */ #endif FOR( i = 1; i < tmp1; i++ ) { -#ifdef ISSUE_1799_replace_L_shr_o - L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i + attack], Qx ), &Overflow ); /*Qx */ +#ifdef ISSUE_1799_replace_L_shr_o + L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i + attack], Qx ), &Overflow ); /*Qx */ #else L_tmp = L_add_o( L_tmp, L_shr_o( finc[i + attack], Qx, &Overflow ), &Overflow ); /*Qx */ #endif diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index e1327e7e0..4a28f4263 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -7385,7 +7385,7 @@ void fb_tbe_enc_fx( { tmp = div_s( tmp2, tmp ); L_tmp = L_deposit_h( tmp ); - L_tmp = Isqrt_lc( L_tmp, &exp ); /*Q(31-exp)*/ + L_tmp = Isqrt_lc( L_tmp, &exp ); /*Q(31-exp)*/ #ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_max( L_shr_sat( L_tmp, sub( 31, exp ) ), 0x1 ); /* Q0 */ #else diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index fe495c2a9..11602c976 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -1159,7 +1159,7 @@ Word16 wb_vad_fx( #ifdef ISSUE_1799_replace_L_shr_o L_snr = L_shr_sat( snr_tmp, shift_snr ); /* L_snr in Q4 */ #else - L_snr = L_shr_o( snr_tmp, shift_snr, &Overflow ); /* L_snr in Q4 */ + L_snr = L_shr_o( snr_tmp, shift_snr, &Overflow ); /* L_snr in Q4 */ #endif } ELSE -- GitLab From 60d02a4b08621717dc71377ab9184d61cd5a67e2 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 3 Jul 2025 15:48:33 +0200 Subject: [PATCH 07/22] deactivate all --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 7376e28ab..27735895f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -112,7 +112,7 @@ #define ISSUE_1751_replace_shl_ro /*FhG: replace shl_ro by overflow-free alternatives*/ #define ISSUE_1770_replace_shr_ro /* FhG: replace by non-overflow-alternative - BE */ #define ISSUE_1772_replace_shr_o /* FhG: replace by non-overflow-alternative - BE */ -#define ISSUE_1799_replace_L_shr_o /* FhG: replace by non-overflow-alternative - BE */ +//#define ISSUE_1799_replace_L_shr_o /* FhG: replace by non-overflow-alternative - BE */ #define FIX_1735_W_SHL_SAT_L /* FhG: Usage of W_shl_sat_l() */ -- GitLab From eb73c092013ef85cb2e7895ee236d5417729884b Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 17 Jul 2025 08:52:19 +0200 Subject: [PATCH 08/22] fixed instrumentation --- lib_enc/swb_bwe_enc_lr_fx.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index 5635667de..ba4871633 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -179,7 +179,13 @@ static Word16 GetSubbandCorrIndex2_har_fx( /* o : x has to be MAX_32 and y has to be 0 So, a saturated overflow has occured if the result is MAX_32 and y is != 0 THe case MIN_32 with negative x is not valid since x is calculated by square */ - Overflow = ( ( L_corr_sq == MAX_32 ) && ( exp_norm < 0 ) ) ? 1 : 0; + Overflow = 0; + move32(); + test(); + IF(L_corr_sq == MAX_32 && (exp_norm < 0)) + { + Overflow = 1; + } #else L_corr_sq = L_shr_o( L_corr_sq, s_min( shl( exp_norm, 1 ), 31 ), &Overflow ); /* (QCorr-16)*2+1 */ #endif -- GitLab From 7cdd9045a0dc27fd4d25ea5d472aa3b77d36dbe9 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 17 Jul 2025 08:56:34 +0200 Subject: [PATCH 09/22] clang format patch --- lib_enc/swb_bwe_enc_lr_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index ba4871633..48802af68 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -182,7 +182,7 @@ static Word16 GetSubbandCorrIndex2_har_fx( /* o : Overflow = 0; move32(); test(); - IF(L_corr_sq == MAX_32 && (exp_norm < 0)) + IF( L_corr_sq == MAX_32 && ( exp_norm < 0 ) ) { Overflow = 1; } -- GitLab From 97ac56693051b371630e7da427302c20dfff487c Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 17 Jul 2025 11:15:50 +0200 Subject: [PATCH 10/22] fix instrumentation --- lib_enc/swb_bwe_enc_lr_fx.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index 48802af68..f7ecdf147 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -179,8 +179,6 @@ static Word16 GetSubbandCorrIndex2_har_fx( /* o : x has to be MAX_32 and y has to be 0 So, a saturated overflow has occured if the result is MAX_32 and y is != 0 THe case MIN_32 with negative x is not valid since x is calculated by square */ - Overflow = 0; - move32(); test(); IF( L_corr_sq == MAX_32 && ( exp_norm < 0 ) ) { -- GitLab From 8d327bfe565365085e2ef55c47acf99f769c7ad0 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 17 Jul 2025 11:16:04 +0200 Subject: [PATCH 11/22] activate macro --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index a364877b6..a7e7a79d8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -123,7 +123,7 @@ #define ISSUE_1751_replace_shl_ro /*FhG: replace shl_ro by overflow-free alternatives*/ #define ISSUE_1770_replace_shr_ro /* FhG: replace by non-overflow-alternative - BE */ #define ISSUE_1772_replace_shr_o /* FhG: replace by non-overflow-alternative - BE */ -//#define ISSUE_1799_replace_L_shr_o /* FhG: replace by non-overflow-alternative - BE */ +#define ISSUE_1799_replace_L_shr_o /* FhG: replace by non-overflow-alternative - BE */ #define FIX_1735_W_SHL_SAT_L /* FhG: Usage of W_shl_sat_l() */ #define FIX_ISSUE_1792 /* FhG: fix noise bursts in binaural rendering */ -- GitLab From 4307169b55a80464663c996b23dfd533b0a44b36 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 17 Jul 2025 14:05:07 +0200 Subject: [PATCH 12/22] disable critical parts, outer wraps --- lib_com/swb_bwe_com_fx.c | 2 +- lib_com/tools_fx.c | 2 +- lib_enc/swb_bwe_enc_lr_fx.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index 36691ae0c..68d152f1e 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -605,7 +605,7 @@ Word32 calc_tilt_bwe_fx( /* o : Tilt in Q24 tmp1 = mult_ro( *ptr++, 8192 /*0.25 in Q15 */, &Overflow ); /* Divide by 4 */ L_ener = L_mac0_o( L_ener, tmp1, tmp1, &Overflow ); } -#ifdef ISSUE_1799_replace_L_shr_o +#ifdef ISSUE_1799_replace_L_shr_o__ /*Overflow will never happen because exp2 is always positive*/ L_ener = L_shr( L_ener, exp2 ); #else diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index ebc0211a3..00b3b559a 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -3300,7 +3300,7 @@ Word32 Calc_Energy_Autoscaled( /* o: Result (Energy) temp = mult_ro( *signal++, 16384, &Overflow ); L_temp = L_mac0_o( L_temp, temp, temp, &Overflow ); } -#ifdef ISSUE_1799_replace_L_shr_o +#ifdef ISSUE_1799_replace_L_shr_o__ /*Overfloe will never happen because temp2 is always positive*/ L_temp = L_shr( L_temp, temp2 ); #else diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index f7ecdf147..b66e6967f 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -173,7 +173,7 @@ static Word16 GetSubbandCorrIndex2_har_fx( /* o : corr_sq_hi_fx = extract_h( L_corr_sq ); L_corr_sq = L_mult_o( corr_sq_hi_fx, corr_sq_hi_fx, &Overflow ); /* (((Qhi:Qsh+exp_norm_hi-16)+Qss+1)+exp_norm-16)*2+1 */ -#ifdef ISSUE_1799_replace_L_shr_o +#ifdef ISSUE_1799_replace_L_shr_o__ L_corr_sq = L_shr_sat( L_corr_sq, s_min( shl( exp_norm, 1 ), 31 ) ); /* (QCorr-16)*2+1 */ /* Catching an Overflow: solve MAX_32 = x / 2^y for integers x < 2^31 and y : x has to be MAX_32 and y has to be 0 -- GitLab From 1ef260bd150a3299e427f7cd7be81849e2d1fee0 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 17 Jul 2025 15:05:58 +0200 Subject: [PATCH 13/22] activate critical code in swb_bwe_com_fx --- lib_com/swb_bwe_com_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index 68d152f1e..36691ae0c 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -605,7 +605,7 @@ Word32 calc_tilt_bwe_fx( /* o : Tilt in Q24 tmp1 = mult_ro( *ptr++, 8192 /*0.25 in Q15 */, &Overflow ); /* Divide by 4 */ L_ener = L_mac0_o( L_ener, tmp1, tmp1, &Overflow ); } -#ifdef ISSUE_1799_replace_L_shr_o__ +#ifdef ISSUE_1799_replace_L_shr_o /*Overflow will never happen because exp2 is always positive*/ L_ener = L_shr( L_ener, exp2 ); #else -- GitLab From e605de18d7c55cc8ee6928d41ba8b5766cb4173c Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 17 Jul 2025 15:47:47 +0200 Subject: [PATCH 14/22] activated critival code in tools_fx.c for testing --- lib_com/tools_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index 00b3b559a..ebc0211a3 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -3300,7 +3300,7 @@ Word32 Calc_Energy_Autoscaled( /* o: Result (Energy) temp = mult_ro( *signal++, 16384, &Overflow ); L_temp = L_mac0_o( L_temp, temp, temp, &Overflow ); } -#ifdef ISSUE_1799_replace_L_shr_o__ +#ifdef ISSUE_1799_replace_L_shr_o /*Overfloe will never happen because temp2 is always positive*/ L_temp = L_shr( L_temp, temp2 ); #else -- GitLab From d9d181a8a389128b54ba6b23470c04ee826d5a90 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 23 Jul 2025 08:42:31 +0200 Subject: [PATCH 15/22] swb_bwe_enc_lr_fx.c: activate macro and test again --- lib_enc/swb_bwe_enc_lr_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index b66e6967f..f7ecdf147 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -173,7 +173,7 @@ static Word16 GetSubbandCorrIndex2_har_fx( /* o : corr_sq_hi_fx = extract_h( L_corr_sq ); L_corr_sq = L_mult_o( corr_sq_hi_fx, corr_sq_hi_fx, &Overflow ); /* (((Qhi:Qsh+exp_norm_hi-16)+Qss+1)+exp_norm-16)*2+1 */ -#ifdef ISSUE_1799_replace_L_shr_o__ +#ifdef ISSUE_1799_replace_L_shr_o L_corr_sq = L_shr_sat( L_corr_sq, s_min( shl( exp_norm, 1 ), 31 ) ); /* (QCorr-16)*2+1 */ /* Catching an Overflow: solve MAX_32 = x / 2^y for integers x < 2^31 and y : x has to be MAX_32 and y has to be 0 -- GitLab From f8d76af69776b424b84771b27dc5d38fea667e27 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 23 Jul 2025 08:50:20 +0200 Subject: [PATCH 16/22] minor: comments --- lib_enc/swb_bwe_enc_lr_fx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index f7ecdf147..cb9cd7f67 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -175,10 +175,9 @@ static Word16 GetSubbandCorrIndex2_har_fx( /* o : L_corr_sq = L_mult_o( corr_sq_hi_fx, corr_sq_hi_fx, &Overflow ); /* (((Qhi:Qsh+exp_norm_hi-16)+Qss+1)+exp_norm-16)*2+1 */ #ifdef ISSUE_1799_replace_L_shr_o L_corr_sq = L_shr_sat( L_corr_sq, s_min( shl( exp_norm, 1 ), 31 ) ); /* (QCorr-16)*2+1 */ - /* Catching an Overflow: solve MAX_32 = x / 2^y for integers x < 2^31 and y : + /* Catching a false-positive Overflow: solve MAX_32 = x * 2^y for integers x < 2^31 and y : x has to be MAX_32 and y has to be 0 - So, a saturated overflow has occured if the result is MAX_32 and y is != 0 - THe case MIN_32 with negative x is not valid since x is calculated by square */ + So, a saturated overflow has occured if the result is MAX_32 and y is != 0*/ test(); IF( L_corr_sq == MAX_32 && ( exp_norm < 0 ) ) { -- GitLab From a40db9485f55604cc83b6739c7b952a1bbef3e98 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 23 Jul 2025 09:35:59 +0200 Subject: [PATCH 17/22] minor: comments --- lib_enc/swb_bwe_enc_lr_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index cb9cd7f67..68bd400c4 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -175,9 +175,9 @@ static Word16 GetSubbandCorrIndex2_har_fx( /* o : L_corr_sq = L_mult_o( corr_sq_hi_fx, corr_sq_hi_fx, &Overflow ); /* (((Qhi:Qsh+exp_norm_hi-16)+Qss+1)+exp_norm-16)*2+1 */ #ifdef ISSUE_1799_replace_L_shr_o L_corr_sq = L_shr_sat( L_corr_sq, s_min( shl( exp_norm, 1 ), 31 ) ); /* (QCorr-16)*2+1 */ - /* Catching a false-positive Overflow: solve MAX_32 = x * 2^y for integers x < 2^31 and y : - x has to be MAX_32 and y has to be 0 - So, a saturated overflow has occured if the result is MAX_32 and y is != 0*/ + /* Catching an Overflow: solve MAX_32 = x * 2^y for integers x < 2^31 and y : + x = MAX_32 && y == 0 + So, a saturated overflow has occured if the result is MAX_32 and y != 0 OR x != MAX_32*/ test(); IF( L_corr_sq == MAX_32 && ( exp_norm < 0 ) ) { -- GitLab From 290f6e5602f181259c025e1e97f42b29e1e3df4d Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 23 Jul 2025 11:38:29 +0000 Subject: [PATCH 18/22] Reduce changes --- lib_com/cldfb_fx.c | 2 +- lib_com/cng_exc_fx.c | 8 ++++---- lib_com/edct_fx.c | 6 +++--- lib_com/frame_ener_fx.c | 4 ++-- lib_com/lsf_tools_fx.c | 15 ++++++--------- lib_com/swb_bwe_com_fx.c | 4 ---- lib_com/syn_filt_fx.c | 4 ++-- lib_com/tools_fx.c | 4 ---- lib_dec/LD_music_post_filter_fx.c | 2 +- lib_enc/find_tilt_fx.c | 6 +++--- lib_enc/find_uv_fx.c | 2 +- lib_enc/hvq_enc_fx.c | 14 +++++++------- lib_enc/nois_est_fx.c | 16 ++++++++-------- lib_enc/pvq_encode_fx.c | 8 ++++---- lib_enc/speech_music_classif_fx.c | 6 +++--- lib_enc/vad_fx.c | 2 +- 16 files changed, 46 insertions(+), 57 deletions(-) diff --git a/lib_com/cldfb_fx.c b/lib_com/cldfb_fx.c index 244967c20..b772b9099 100644 --- a/lib_com/cldfb_fx.c +++ b/lib_com/cldfb_fx.c @@ -2085,7 +2085,7 @@ static void cldfb_init_proto_and_twiddles( #ifdef OPT_IVAS_FILTER_ROM hs->p_filter_32 = CLDFB80_10_fx; #else /* OPT_IVAS_FILTER_ROM */ - hs->p_filter_sf = (Word16) 17036; // Q14 + hs->p_filter_sf = (Word16) 17036; // Q14 hs->p_filter = CLDFB80_10_fx; #endif /* OPT_IVAS_FILTER_ROM */ hs->scale = CLDFB80_10_SCALE_FX_Q8; diff --git a/lib_com/cng_exc_fx.c b/lib_com/cng_exc_fx.c index 00ce93218..4e5fb1ad1 100644 --- a/lib_com/cng_exc_fx.c +++ b/lib_com/cng_exc_fx.c @@ -907,7 +907,7 @@ void cng_params_upd_fx( #ifdef ISSUE_1799_replace_L_shr_o L_ener = L_add_o( L_ener, L_shr_sat( L_tmp, 7 ), &Overflow ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */ #else - L_ener = L_add_o( L_ener, L_shr_o( L_tmp, 7, &Overflow ), &Overflow ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */ + L_ener = L_add_o( L_ener, L_shr_o( L_tmp, 7, &Overflow ), &Overflow ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */ #endif } } @@ -931,7 +931,7 @@ void cng_params_upd_fx( #ifdef ISSUE_1799_replace_L_shr_o L_ener = L_shr_sat( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ) ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */ #else - L_ener = L_shr_o( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ), &Overflow ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */ + L_ener = L_shr_o( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ), &Overflow ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */ #endif /* update the circular buffer of old energies */ @@ -1097,7 +1097,7 @@ void cng_params_upd_ivas_fx( #ifdef ISSUE_1799_replace_L_shr_o L_ener = L_add_o( L_ener, L_shr_sat( L_tmp, 7 ), &Overflow ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */ #else - L_ener = L_add_o( L_ener, L_shr_o( L_tmp, 7, &Overflow ), &Overflow ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */ + L_ener = L_add_o( L_ener, L_shr_o( L_tmp, 7, &Overflow ), &Overflow ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */ #endif } } @@ -1121,7 +1121,7 @@ void cng_params_upd_ivas_fx( #ifdef ISSUE_1799_replace_L_shr_o L_ener = L_shr_sat( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ) ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */ #else - L_ener = L_shr_o( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ), &Overflow ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */ + L_ener = L_shr_o( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ), &Overflow ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */ #endif /* update the circular buffer of old energies */ diff --git a/lib_com/edct_fx.c b/lib_com/edct_fx.c index c30ed4a57..332455026 100644 --- a/lib_com/edct_fx.c +++ b/lib_com/edct_fx.c @@ -502,8 +502,8 @@ void edct_16fx( { i2 = shl( i, 1 ); - L_tmp = L_mult( re[i], edct_table[i] ); /*Q(Qx+Q_edct+16) */ - Lacc = L_mac_o( L_tmp, im[i], *pt, &Overflow ); /*Q(Qx+Q_edct+16) */ + L_tmp = L_mult( re[i], edct_table[i] ); /*Q(Qx+Q_edct+16) */ + Lacc = L_mac_o( L_tmp, im[i], *pt, &Overflow ); /*Q(Qx+Q_edct+16) */ #ifdef ISSUE_1799_replace_L_shr_o y[i2] = round_fx_o( L_shr_sat( Lacc, Q_edct ), &Overflow ); /* Q(Qx) */ #else @@ -516,7 +516,7 @@ void edct_16fx( #ifdef ISSUE_1799_replace_L_shr_o *py = round_fx_o( L_shr_sat( Lacc, Q_edct ), &Overflow ); /* Q(Qx) */ #else - *py = round_fx_o( L_shr_o( Lacc, Q_edct, &Overflow ), &Overflow ); /* Q(Qx) */ + *py = round_fx_o( L_shr_o( Lacc, Q_edct, &Overflow ), &Overflow ); /* Q(Qx) */ #endif move16(); diff --git a/lib_com/frame_ener_fx.c b/lib_com/frame_ener_fx.c index f3dbe52bd..8f40567d4 100644 --- a/lib_com/frame_ener_fx.c +++ b/lib_com/frame_ener_fx.c @@ -276,11 +276,11 @@ Word16 frame_energy_fx( /* o : Frame energy in Q8 exp1 = sub( 15 + exp1, tmp2 ); /*add ld(2^exp1)=exp1 but check format, first*/ - tmp16 = sub( sub( 15, norm_s( exp1 ) ), 5 ); /*factor to shift Ltmp and exp1 with (shr) to avoid overflows when adding*/ + tmp16 = sub( sub( 15, norm_s( exp1 ) ), 5 ); /*factor to shift Ltmp and exp1 with (shr) to avoid overflows when adding*/ #ifdef ISSUE_1799_replace_L_shr_o Ltmp = L_shr_sat( Ltmp, tmp16 ); /*Q25, tmp16*/ #else - Ltmp = L_shr_o( Ltmp, tmp16, &Overflow ); /*Q25, tmp16*/ + Ltmp = L_shr_o( Ltmp, tmp16, &Overflow ); /*Q25, tmp16*/ #endif exp2 = shr( exp1, tmp16 ); /*Q0 , tmp16*/ Ltmp = L_add_o( Ltmp, L_shl( L_deposit_l( exp2 ), 25 ), &Overflow ); /*Q25, tmp16, normalized*/ diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c index 7bea09cfd..0fb313418 100644 --- a/lib_com/lsf_tools_fx.c +++ b/lib_com/lsf_tools_fx.c @@ -1802,16 +1802,13 @@ void a2rc_fx( const Word16 *a, /* i: can be any Q */ L_tmp2 = L_mac_o( L_tmp2, tmp, f_fx[j], &Overflow ); /* denom*f[n]+km*denom*f[j] in Q28 (floating with exp) */ #ifdef ISSUE_1799_replace_L_shr_o L_tmp1 = L_shr_sat( L_tmp1, exp ); /* bringing to true Q28 */ -#else - L_tmp1 = L_shr_o( L_tmp1, exp, &Overflow ); /* bringing to true Q28 */ -#endif -#ifdef ISSUE_1799_replace_L_shr_o L_tmp2 = L_shr_sat( L_tmp2, exp ); /* bringing to true Q28 */ #else - L_tmp2 = L_shr_o( L_tmp2, exp, &Overflow ); /* bringing to true Q28 */ + L_tmp1 = L_shr_o( L_tmp1, exp, &Overflow ); /* bringing to true Q28 */ + L_tmp2 = L_shr_o( L_tmp2, exp, &Overflow ); /* bringing to true Q28 */ #endif - f_fx[j] = round_fx_o( L_tmp1, &Overflow ); /* extracting in q_a */ - f_fx[n] = round_fx_o( L_tmp2, &Overflow ); /* extracting in q_a */ + f_fx[j] = round_fx_o( L_tmp1, &Overflow ); /* extracting in q_a */ + f_fx[n] = round_fx_o( L_tmp2, &Overflow ); /* extracting in q_a */ } IF( m & 1 ) @@ -1821,9 +1818,9 @@ void a2rc_fx( const Word16 *a, /* i: can be any Q */ #ifdef ISSUE_1799_replace_L_shr_o L_tmp1 = L_shr_sat( L_tmp1, exp ); /* bringing to true Q28 */ #else - L_tmp1 = L_shr_o( L_tmp1, exp, &Overflow ); /* bringing to true Q28 */ + L_tmp1 = L_shr_o( L_tmp1, exp, &Overflow ); /* bringing to true Q28 */ #endif - f_fx[j] = round_fx_o( L_tmp1, &Overflow ); /* extracting in q_a */ + f_fx[j] = round_fx_o( L_tmp1, &Overflow ); /* extracting in q_a */ move16(); } } diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index 36691ae0c..fd4c6df66 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -608,12 +608,8 @@ Word32 calc_tilt_bwe_fx( /* o : Tilt in Q24 #ifdef ISSUE_1799_replace_L_shr_o /*Overflow will never happen because exp2 is always positive*/ L_ener = L_shr( L_ener, exp2 ); -#else -#ifdef ISSUE_1799_replace_L_shr_o - L_ener = L_shr_sat( L_ener, exp2 ); #else L_ener = L_shr_o( L_ener, exp2, &Overflow ); -#endif #endif L_temp = L_add_o( L_ener_tot, L_ener, &Overflow ); IF( Overflow != 0 ) diff --git a/lib_com/syn_filt_fx.c b/lib_com/syn_filt_fx.c index ed2c91493..ebebc266b 100644 --- a/lib_com/syn_filt_fx.c +++ b/lib_com/syn_filt_fx.c @@ -200,7 +200,7 @@ void syn_filt_fx( #ifdef ISSUE_1772_replace_shr_o a0 = shr_sat( a[0], shift ); /* input / 2^shift */ #else - a0 = shr_o( a[0], shift, &Overflow ); /* input / 2^shift */ + a0 = shr_o( a[0], shift, &Overflow ); /* input / 2^shift */ #endif /*------------------------------------------------------------------* @@ -382,7 +382,7 @@ void E_UTIL_synthesis( const Word16 shift, const Word16 a[], const Word16 x[], W #ifdef ISSUE_1772_replace_shr_o a0 = shr_sat( a[0], shift ); /* input / 2^shift */ #else - a0 = shr_o( a[0], shift, &Overflow ); /* input / 2^shift */ + a0 = shr_o( a[0], shift, &Overflow ); /* input / 2^shift */ #endif /*-----------------------------------------------------------------------* * Do the filtering diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index ebc0211a3..aebee91f8 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -3303,12 +3303,8 @@ Word32 Calc_Energy_Autoscaled( /* o: Result (Energy) #ifdef ISSUE_1799_replace_L_shr_o /*Overfloe will never happen because temp2 is always positive*/ L_temp = L_shr( L_temp, temp2 ); -#else -#ifdef ISSUE_1799_replace_L_shr_o - L_temp = L_shr_sat( L_temp, temp2 ); #else L_temp = L_shr_o( L_temp, temp2, &Overflow ); -#endif #endif /* Here we try the addition just to check if we can sum the energy of the small (8 Iterations) loop with the diff --git a/lib_dec/LD_music_post_filter_fx.c b/lib_dec/LD_music_post_filter_fx.c index a45072dec..af80c2378 100644 --- a/lib_dec/LD_music_post_filter_fx.c +++ b/lib_dec/LD_music_post_filter_fx.c @@ -602,7 +602,7 @@ static void spectrum_mod_dct_fx( #ifdef ISSUE_1799_replace_L_shr_o Ltmp = L_shr_sat( Ltmp, e_binE ); /*2*Qdct+9*/ #else - Ltmp = L_shr_o( Ltmp, e_binE, &Overflow ); /*2*Qdct+9*/ + Ltmp = L_shr_o( Ltmp, e_binE, &Overflow ); /*2*Qdct+9*/ #endif Lgain = L_add_o( Ltmp, Lshift, &Overflow ); /*Saturation can occure here result in Q30*/ } diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c index 0a862f3f9..551792d15 100644 --- a/lib_enc/find_tilt_fx.c +++ b/lib_enc/find_tilt_fx.c @@ -178,7 +178,7 @@ void find_tilt_fx( #ifdef ISSUE_1799_replace_L_shr_o lp_E = L_sub_o( L_shr_sat( m_tmp, sub( e_tmp, 1 ) ), lp_bckr, &Overflow ); /* Q_new + QSCALE */ #else - lp_E = L_sub_o( L_shr_o( m_tmp, sub( e_tmp, 1 ), &Overflow ), lp_bckr, &Overflow ); /* Q_new + QSCALE */ + lp_E = L_sub_o( L_shr_o( m_tmp, sub( e_tmp, 1 ), &Overflow ), lp_bckr, &Overflow ); /* Q_new + QSCALE */ #endif pt_E = tmp_E + VOIC_BINS; /* Update for next half-frame */ @@ -210,7 +210,7 @@ void find_tilt_fx( #ifdef ISSUE_1799_replace_L_shr_o ee[i] = L_shr_sat( m_tmp, add( e_tmp, 15 - 6 ) ); /* ee in Q6 */ #else - ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ + ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ #endif } ELSE IF( lp_E == 0 ) @@ -477,7 +477,7 @@ void find_tilt_ivas_fx( #ifdef ISSUE_1799_replace_L_shr_o ee[i] = L_shr_sat( m_tmp, add( e_tmp, 15 - 6 ) ); /* ee in Q6 */ #else - ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ + ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ #endif move32(); } diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 718836515..272bca9ef 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -81,7 +81,7 @@ static Word16 find_ener_decrease_fx( /* o : maximum #ifdef ISSUE_1770_replace_shr_ro dE2 = shr_r_sat( wtmp1, add( sub( exp1, exp0 ), 15 - 10 ) ); /*Q10*/ #else - dE2 = shr_ro( wtmp1, add( sub( exp1, exp0 ), 15 - 10 ), &Overflow ); /*Q10*/ + dE2 = shr_ro( wtmp1, add( sub( exp1, exp0 ), 15 - 10 ), &Overflow ); /*Q10*/ #endif return dE2; diff --git a/lib_enc/hvq_enc_fx.c b/lib_enc/hvq_enc_fx.c index 222aed4c2..69deba923 100644 --- a/lib_enc/hvq_enc_fx.c +++ b/lib_enc/hvq_enc_fx.c @@ -180,13 +180,13 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits 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. */ /* Number of bits required to adjust to Q15 */ - adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ + adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ #ifdef ISSUE_1799_replace_L_shr_o lb_nfpe = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ #else - lb_nfpe = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ + lb_nfpe = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ #endif - IF( GT_16( lb_nfpe, 16384 ) ) /* in Q15 */ + IF( GT_16( lb_nfpe, 16384 ) ) /* in Q15 */ { lb_nfpe = 16384; move16(); @@ -330,7 +330,7 @@ Word16 hvq_enc_fx( /*o : Consumed bits acc = L_mult( tmp16, HVQ_NFPE_FACTOR_CUBE_FX ); /* in Q(12+6+1) = Q19 */ expNfpe3 = extract_l( L_mult0( expNfpe, 3 ) ); /* Cube operation */ /* Number of bits required to adjust to Q15 */ - adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ + adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ #ifdef ISSUE_1799_replace_L_shr_o noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ #else @@ -365,13 +365,13 @@ Word16 hvq_enc_fx( /*o : Consumed bits 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. */ /* Number of bits required to adjust to Q15 */ - adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ + adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ #ifdef ISSUE_1799_replace_L_shr_o lb_nfpe = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ #else - lb_nfpe = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ + lb_nfpe = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ #endif - IF( lb_nfpe > 16384 ) /* in Q15 */ + IF( lb_nfpe > 16384 ) /* in Q15 */ { lb_nfpe = 16384; move16(); diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 31b53204e..3f680f668 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -1334,7 +1334,7 @@ void noise_est_fx( #ifdef ISSUE_1799_replace_L_shr_o non_sta = L_shr_sat( Ltmp, sub( ExpNum, ExpDen ) ); /* Q10 */ #else - non_sta = L_shr_o( Ltmp, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ + non_sta = L_shr_o( Ltmp, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ #endif } @@ -1373,7 +1373,7 @@ void noise_est_fx( #ifdef ISSUE_1799_replace_L_shr_o Lnon_sta2 = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ #else - Lnon_sta2 = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ + Lnon_sta2 = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ #endif } @@ -2689,12 +2689,12 @@ void noise_est_ivas_fx( ExpDen = norm_l( Lden ); den = extract_h( L_shl( Lden, ExpDen ) ); // q_enr+ExpDen-16 - num = div_s( num, den ); // 15+ExpNum-ExpDen - Ltmp1 = Mult_32_16( non_sta, num ); // 15+ExpNum-ExpDen+10-15 + num = div_s( num, den ); // 15+ExpNum-ExpDen + Ltmp1 = Mult_32_16( non_sta, num ); // 15+ExpNum-ExpDen+10-15 #ifdef ISSUE_1799_replace_L_shr_o non_sta = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ #else - non_sta = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ + non_sta = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ #endif } @@ -2732,12 +2732,12 @@ void noise_est_ivas_fx( ExpDen = norm_l( Lden ); den = extract_h( L_shl( Lden, ExpDen ) ); // q_enr+ExpDen-16 - num = div_s( num, den ); // 15+ExpNum-ExpDen - Ltmp1 = Mult_32_16( Lnon_sta2, num ); // 15+ExpNum-ExpDen+10-15 + num = div_s( num, den ); // 15+ExpNum-ExpDen + Ltmp1 = Mult_32_16( Lnon_sta2, num ); // 15+ExpNum-ExpDen+10-15 #ifdef ISSUE_1799_replace_L_shr_o Lnon_sta2 = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ #else - Lnon_sta2 = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ + Lnon_sta2 = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ #endif } diff --git a/lib_enc/pvq_encode_fx.c b/lib_enc/pvq_encode_fx.c index d08b8a902..04aba3d80 100644 --- a/lib_enc/pvq_encode_fx.c +++ b/lib_enc/pvq_encode_fx.c @@ -362,9 +362,9 @@ void pvq_encode_ivas_fx( #ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ #else - L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ + L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ #endif - xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ + xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ move16(); L_xq[i] = L_tmp; /* Q31 currently unused */ move32(); @@ -574,9 +574,9 @@ void pvq_encode_fx( #ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ #else - L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ + L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ #endif - xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ + xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ move16(); L_xq[i] = L_tmp; /* Q31 currently unused */ move32(); diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 3bf4a53bf..b67baf4b4 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -1503,7 +1503,7 @@ static Word16 attack_det_fx( /* o : attack flag #ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_shr_sat( finc[0], Qx ); /*Qx */ #else - L_tmp = L_shr_o( finc[0], Qx, &Overflow ); /*Qx */ + L_tmp = L_shr_o( finc[0], Qx, &Overflow ); /*Qx */ #endif FOR( i = 1; i < att_3lsub_pos; i++ ) @@ -1511,7 +1511,7 @@ static Word16 attack_det_fx( /* o : attack flag #ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i], Qx ), &Overflow ); /*Qx */ #else - L_tmp = L_add_o( L_tmp, L_shr_o( finc[i], Qx, &Overflow ), &Overflow ); /*Qx */ + L_tmp = L_add_o( L_tmp, L_shr_o( finc[i], Qx, &Overflow ), &Overflow ); /*Qx */ #endif } L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(14-exp1+Qx) */ @@ -1524,7 +1524,7 @@ static Word16 attack_det_fx( /* o : attack flag #ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_shr_sat( finc[attack], Qx ); /*Qx */ #else - L_tmp = L_shr_o( finc[attack], Qx, &Overflow ); /*Qx */ + L_tmp = L_shr_o( finc[attack], Qx, &Overflow ); /*Qx */ #endif FOR( i = 1; i < tmp1; i++ ) { diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index b98693733..88413850b 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -1159,7 +1159,7 @@ Word16 wb_vad_fx( #ifdef ISSUE_1799_replace_L_shr_o L_snr = L_shr_sat( snr_tmp, shift_snr ); /* L_snr in Q4 */ #else - L_snr = L_shr_o( snr_tmp, shift_snr, &Overflow ); /* L_snr in Q4 */ + L_snr = L_shr_o( snr_tmp, shift_snr, &Overflow ); /* L_snr in Q4 */ #endif } ELSE -- GitLab From fa6526fcc3ef0a9819e5479f9ab6bcdfec357912 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 23 Jul 2025 13:48:42 +0200 Subject: [PATCH 19/22] clang patch --- lib_com/cldfb_fx.c | 2 +- lib_com/cng_exc_fx.c | 8 ++++---- lib_com/edct_fx.c | 6 +++--- lib_com/frame_ener_fx.c | 4 ++-- lib_com/lsf_tools_fx.c | 12 ++++++------ lib_com/syn_filt_fx.c | 4 ++-- lib_dec/LD_music_post_filter_fx.c | 2 +- lib_enc/find_tilt_fx.c | 6 +++--- lib_enc/find_uv_fx.c | 2 +- lib_enc/hvq_enc_fx.c | 14 +++++++------- lib_enc/nois_est_fx.c | 16 ++++++++-------- lib_enc/pvq_encode_fx.c | 8 ++++---- lib_enc/speech_music_classif_fx.c | 6 +++--- lib_enc/vad_fx.c | 2 +- 14 files changed, 46 insertions(+), 46 deletions(-) diff --git a/lib_com/cldfb_fx.c b/lib_com/cldfb_fx.c index b772b9099..244967c20 100644 --- a/lib_com/cldfb_fx.c +++ b/lib_com/cldfb_fx.c @@ -2085,7 +2085,7 @@ static void cldfb_init_proto_and_twiddles( #ifdef OPT_IVAS_FILTER_ROM hs->p_filter_32 = CLDFB80_10_fx; #else /* OPT_IVAS_FILTER_ROM */ - hs->p_filter_sf = (Word16) 17036; // Q14 + hs->p_filter_sf = (Word16) 17036; // Q14 hs->p_filter = CLDFB80_10_fx; #endif /* OPT_IVAS_FILTER_ROM */ hs->scale = CLDFB80_10_SCALE_FX_Q8; diff --git a/lib_com/cng_exc_fx.c b/lib_com/cng_exc_fx.c index 4e5fb1ad1..00ce93218 100644 --- a/lib_com/cng_exc_fx.c +++ b/lib_com/cng_exc_fx.c @@ -907,7 +907,7 @@ void cng_params_upd_fx( #ifdef ISSUE_1799_replace_L_shr_o L_ener = L_add_o( L_ener, L_shr_sat( L_tmp, 7 ), &Overflow ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */ #else - L_ener = L_add_o( L_ener, L_shr_o( L_tmp, 7, &Overflow ), &Overflow ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */ + L_ener = L_add_o( L_ener, L_shr_o( L_tmp, 7, &Overflow ), &Overflow ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */ #endif } } @@ -931,7 +931,7 @@ void cng_params_upd_fx( #ifdef ISSUE_1799_replace_L_shr_o L_ener = L_shr_sat( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ) ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */ #else - L_ener = L_shr_o( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ), &Overflow ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */ + L_ener = L_shr_o( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ), &Overflow ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */ #endif /* update the circular buffer of old energies */ @@ -1097,7 +1097,7 @@ void cng_params_upd_ivas_fx( #ifdef ISSUE_1799_replace_L_shr_o L_ener = L_add_o( L_ener, L_shr_sat( L_tmp, 7 ), &Overflow ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */ #else - L_ener = L_add_o( L_ener, L_shr_o( L_tmp, 7, &Overflow ), &Overflow ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */ + L_ener = L_add_o( L_ener, L_shr_o( L_tmp, 7, &Overflow ), &Overflow ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */ #endif } } @@ -1121,7 +1121,7 @@ void cng_params_upd_ivas_fx( #ifdef ISSUE_1799_replace_L_shr_o L_ener = L_shr_sat( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ) ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */ #else - L_ener = L_shr_o( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ), &Overflow ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */ + L_ener = L_shr_o( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ), &Overflow ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */ #endif /* update the circular buffer of old energies */ diff --git a/lib_com/edct_fx.c b/lib_com/edct_fx.c index 332455026..c30ed4a57 100644 --- a/lib_com/edct_fx.c +++ b/lib_com/edct_fx.c @@ -502,8 +502,8 @@ void edct_16fx( { i2 = shl( i, 1 ); - L_tmp = L_mult( re[i], edct_table[i] ); /*Q(Qx+Q_edct+16) */ - Lacc = L_mac_o( L_tmp, im[i], *pt, &Overflow ); /*Q(Qx+Q_edct+16) */ + L_tmp = L_mult( re[i], edct_table[i] ); /*Q(Qx+Q_edct+16) */ + Lacc = L_mac_o( L_tmp, im[i], *pt, &Overflow ); /*Q(Qx+Q_edct+16) */ #ifdef ISSUE_1799_replace_L_shr_o y[i2] = round_fx_o( L_shr_sat( Lacc, Q_edct ), &Overflow ); /* Q(Qx) */ #else @@ -516,7 +516,7 @@ void edct_16fx( #ifdef ISSUE_1799_replace_L_shr_o *py = round_fx_o( L_shr_sat( Lacc, Q_edct ), &Overflow ); /* Q(Qx) */ #else - *py = round_fx_o( L_shr_o( Lacc, Q_edct, &Overflow ), &Overflow ); /* Q(Qx) */ + *py = round_fx_o( L_shr_o( Lacc, Q_edct, &Overflow ), &Overflow ); /* Q(Qx) */ #endif move16(); diff --git a/lib_com/frame_ener_fx.c b/lib_com/frame_ener_fx.c index 8f40567d4..f3dbe52bd 100644 --- a/lib_com/frame_ener_fx.c +++ b/lib_com/frame_ener_fx.c @@ -276,11 +276,11 @@ Word16 frame_energy_fx( /* o : Frame energy in Q8 exp1 = sub( 15 + exp1, tmp2 ); /*add ld(2^exp1)=exp1 but check format, first*/ - tmp16 = sub( sub( 15, norm_s( exp1 ) ), 5 ); /*factor to shift Ltmp and exp1 with (shr) to avoid overflows when adding*/ + tmp16 = sub( sub( 15, norm_s( exp1 ) ), 5 ); /*factor to shift Ltmp and exp1 with (shr) to avoid overflows when adding*/ #ifdef ISSUE_1799_replace_L_shr_o Ltmp = L_shr_sat( Ltmp, tmp16 ); /*Q25, tmp16*/ #else - Ltmp = L_shr_o( Ltmp, tmp16, &Overflow ); /*Q25, tmp16*/ + Ltmp = L_shr_o( Ltmp, tmp16, &Overflow ); /*Q25, tmp16*/ #endif exp2 = shr( exp1, tmp16 ); /*Q0 , tmp16*/ Ltmp = L_add_o( Ltmp, L_shl( L_deposit_l( exp2 ), 25 ), &Overflow ); /*Q25, tmp16, normalized*/ diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c index 0fb313418..fcd425155 100644 --- a/lib_com/lsf_tools_fx.c +++ b/lib_com/lsf_tools_fx.c @@ -1804,11 +1804,11 @@ void a2rc_fx( const Word16 *a, /* i: can be any Q */ L_tmp1 = L_shr_sat( L_tmp1, exp ); /* bringing to true Q28 */ L_tmp2 = L_shr_sat( L_tmp2, exp ); /* bringing to true Q28 */ #else - L_tmp1 = L_shr_o( L_tmp1, exp, &Overflow ); /* bringing to true Q28 */ - L_tmp2 = L_shr_o( L_tmp2, exp, &Overflow ); /* bringing to true Q28 */ + L_tmp1 = L_shr_o( L_tmp1, exp, &Overflow ); /* bringing to true Q28 */ + L_tmp2 = L_shr_o( L_tmp2, exp, &Overflow ); /* bringing to true Q28 */ #endif - f_fx[j] = round_fx_o( L_tmp1, &Overflow ); /* extracting in q_a */ - f_fx[n] = round_fx_o( L_tmp2, &Overflow ); /* extracting in q_a */ + f_fx[j] = round_fx_o( L_tmp1, &Overflow ); /* extracting in q_a */ + f_fx[n] = round_fx_o( L_tmp2, &Overflow ); /* extracting in q_a */ } IF( m & 1 ) @@ -1818,9 +1818,9 @@ void a2rc_fx( const Word16 *a, /* i: can be any Q */ #ifdef ISSUE_1799_replace_L_shr_o L_tmp1 = L_shr_sat( L_tmp1, exp ); /* bringing to true Q28 */ #else - L_tmp1 = L_shr_o( L_tmp1, exp, &Overflow ); /* bringing to true Q28 */ + L_tmp1 = L_shr_o( L_tmp1, exp, &Overflow ); /* bringing to true Q28 */ #endif - f_fx[j] = round_fx_o( L_tmp1, &Overflow ); /* extracting in q_a */ + f_fx[j] = round_fx_o( L_tmp1, &Overflow ); /* extracting in q_a */ move16(); } } diff --git a/lib_com/syn_filt_fx.c b/lib_com/syn_filt_fx.c index ebebc266b..ed2c91493 100644 --- a/lib_com/syn_filt_fx.c +++ b/lib_com/syn_filt_fx.c @@ -200,7 +200,7 @@ void syn_filt_fx( #ifdef ISSUE_1772_replace_shr_o a0 = shr_sat( a[0], shift ); /* input / 2^shift */ #else - a0 = shr_o( a[0], shift, &Overflow ); /* input / 2^shift */ + a0 = shr_o( a[0], shift, &Overflow ); /* input / 2^shift */ #endif /*------------------------------------------------------------------* @@ -382,7 +382,7 @@ void E_UTIL_synthesis( const Word16 shift, const Word16 a[], const Word16 x[], W #ifdef ISSUE_1772_replace_shr_o a0 = shr_sat( a[0], shift ); /* input / 2^shift */ #else - a0 = shr_o( a[0], shift, &Overflow ); /* input / 2^shift */ + a0 = shr_o( a[0], shift, &Overflow ); /* input / 2^shift */ #endif /*-----------------------------------------------------------------------* * Do the filtering diff --git a/lib_dec/LD_music_post_filter_fx.c b/lib_dec/LD_music_post_filter_fx.c index af80c2378..a45072dec 100644 --- a/lib_dec/LD_music_post_filter_fx.c +++ b/lib_dec/LD_music_post_filter_fx.c @@ -602,7 +602,7 @@ static void spectrum_mod_dct_fx( #ifdef ISSUE_1799_replace_L_shr_o Ltmp = L_shr_sat( Ltmp, e_binE ); /*2*Qdct+9*/ #else - Ltmp = L_shr_o( Ltmp, e_binE, &Overflow ); /*2*Qdct+9*/ + Ltmp = L_shr_o( Ltmp, e_binE, &Overflow ); /*2*Qdct+9*/ #endif Lgain = L_add_o( Ltmp, Lshift, &Overflow ); /*Saturation can occure here result in Q30*/ } diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c index 551792d15..0a862f3f9 100644 --- a/lib_enc/find_tilt_fx.c +++ b/lib_enc/find_tilt_fx.c @@ -178,7 +178,7 @@ void find_tilt_fx( #ifdef ISSUE_1799_replace_L_shr_o lp_E = L_sub_o( L_shr_sat( m_tmp, sub( e_tmp, 1 ) ), lp_bckr, &Overflow ); /* Q_new + QSCALE */ #else - lp_E = L_sub_o( L_shr_o( m_tmp, sub( e_tmp, 1 ), &Overflow ), lp_bckr, &Overflow ); /* Q_new + QSCALE */ + lp_E = L_sub_o( L_shr_o( m_tmp, sub( e_tmp, 1 ), &Overflow ), lp_bckr, &Overflow ); /* Q_new + QSCALE */ #endif pt_E = tmp_E + VOIC_BINS; /* Update for next half-frame */ @@ -210,7 +210,7 @@ void find_tilt_fx( #ifdef ISSUE_1799_replace_L_shr_o ee[i] = L_shr_sat( m_tmp, add( e_tmp, 15 - 6 ) ); /* ee in Q6 */ #else - ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ + ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ #endif } ELSE IF( lp_E == 0 ) @@ -477,7 +477,7 @@ void find_tilt_ivas_fx( #ifdef ISSUE_1799_replace_L_shr_o ee[i] = L_shr_sat( m_tmp, add( e_tmp, 15 - 6 ) ); /* ee in Q6 */ #else - ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ + ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ #endif move32(); } diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 272bca9ef..718836515 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -81,7 +81,7 @@ static Word16 find_ener_decrease_fx( /* o : maximum #ifdef ISSUE_1770_replace_shr_ro dE2 = shr_r_sat( wtmp1, add( sub( exp1, exp0 ), 15 - 10 ) ); /*Q10*/ #else - dE2 = shr_ro( wtmp1, add( sub( exp1, exp0 ), 15 - 10 ), &Overflow ); /*Q10*/ + dE2 = shr_ro( wtmp1, add( sub( exp1, exp0 ), 15 - 10 ), &Overflow ); /*Q10*/ #endif return dE2; diff --git a/lib_enc/hvq_enc_fx.c b/lib_enc/hvq_enc_fx.c index 69deba923..222aed4c2 100644 --- a/lib_enc/hvq_enc_fx.c +++ b/lib_enc/hvq_enc_fx.c @@ -180,13 +180,13 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits 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. */ /* Number of bits required to adjust to Q15 */ - adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ + adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ #ifdef ISSUE_1799_replace_L_shr_o lb_nfpe = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ #else - lb_nfpe = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ + lb_nfpe = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ #endif - IF( GT_16( lb_nfpe, 16384 ) ) /* in Q15 */ + IF( GT_16( lb_nfpe, 16384 ) ) /* in Q15 */ { lb_nfpe = 16384; move16(); @@ -330,7 +330,7 @@ Word16 hvq_enc_fx( /*o : Consumed bits acc = L_mult( tmp16, HVQ_NFPE_FACTOR_CUBE_FX ); /* in Q(12+6+1) = Q19 */ expNfpe3 = extract_l( L_mult0( expNfpe, 3 ) ); /* Cube operation */ /* Number of bits required to adjust to Q15 */ - adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ + adjust = add( 19 - ( 15 + 16 ), expNfpe3 ); /* +16 is due to the following extract_h(). */ #ifdef ISSUE_1799_replace_L_shr_o noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ #else @@ -365,13 +365,13 @@ Word16 hvq_enc_fx( /*o : Consumed bits 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. */ /* Number of bits required to adjust to Q15 */ - adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ + adjust = add( 22 - ( 15 + 16 ), expo3 ); /* +16 is due to the following extract_h(). */ #ifdef ISSUE_1799_replace_L_shr_o lb_nfpe = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ #else - lb_nfpe = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ + lb_nfpe = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ #endif - IF( lb_nfpe > 16384 ) /* in Q15 */ + IF( lb_nfpe > 16384 ) /* in Q15 */ { lb_nfpe = 16384; move16(); diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index 3f680f668..31b53204e 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -1334,7 +1334,7 @@ void noise_est_fx( #ifdef ISSUE_1799_replace_L_shr_o non_sta = L_shr_sat( Ltmp, sub( ExpNum, ExpDen ) ); /* Q10 */ #else - non_sta = L_shr_o( Ltmp, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ + non_sta = L_shr_o( Ltmp, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ #endif } @@ -1373,7 +1373,7 @@ void noise_est_fx( #ifdef ISSUE_1799_replace_L_shr_o Lnon_sta2 = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ #else - Lnon_sta2 = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ + Lnon_sta2 = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ #endif } @@ -2689,12 +2689,12 @@ void noise_est_ivas_fx( ExpDen = norm_l( Lden ); den = extract_h( L_shl( Lden, ExpDen ) ); // q_enr+ExpDen-16 - num = div_s( num, den ); // 15+ExpNum-ExpDen - Ltmp1 = Mult_32_16( non_sta, num ); // 15+ExpNum-ExpDen+10-15 + num = div_s( num, den ); // 15+ExpNum-ExpDen + Ltmp1 = Mult_32_16( non_sta, num ); // 15+ExpNum-ExpDen+10-15 #ifdef ISSUE_1799_replace_L_shr_o non_sta = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ #else - non_sta = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ + non_sta = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ #endif } @@ -2732,12 +2732,12 @@ void noise_est_ivas_fx( ExpDen = norm_l( Lden ); den = extract_h( L_shl( Lden, ExpDen ) ); // q_enr+ExpDen-16 - num = div_s( num, den ); // 15+ExpNum-ExpDen - Ltmp1 = Mult_32_16( Lnon_sta2, num ); // 15+ExpNum-ExpDen+10-15 + num = div_s( num, den ); // 15+ExpNum-ExpDen + Ltmp1 = Mult_32_16( Lnon_sta2, num ); // 15+ExpNum-ExpDen+10-15 #ifdef ISSUE_1799_replace_L_shr_o Lnon_sta2 = L_shr_sat( Ltmp1, sub( ExpNum, ExpDen ) ); /* Q10 */ #else - Lnon_sta2 = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ + Lnon_sta2 = L_shr_o( Ltmp1, sub( ExpNum, ExpDen ), &Overflow ); /* Q10 */ #endif } diff --git a/lib_enc/pvq_encode_fx.c b/lib_enc/pvq_encode_fx.c index 04aba3d80..d08b8a902 100644 --- a/lib_enc/pvq_encode_fx.c +++ b/lib_enc/pvq_encode_fx.c @@ -362,9 +362,9 @@ void pvq_encode_ivas_fx( #ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ #else - L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ + L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ #endif - xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ + xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ move16(); L_xq[i] = L_tmp; /* Q31 currently unused */ move32(); @@ -574,9 +574,9 @@ void pvq_encode_fx( #ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_shr_sat( L_tmp, shift_tot ); /* Q31+x */ #else - L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ + L_tmp = L_shr_o( L_tmp, shift_tot, &Overflow ); /* Q31+x */ #endif - xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ + xq[i] = round_fx_o( L_tmp, &Overflow ); /* Q15, array move */ move16(); L_xq[i] = L_tmp; /* Q31 currently unused */ move32(); diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index b67baf4b4..3bf4a53bf 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -1503,7 +1503,7 @@ static Word16 attack_det_fx( /* o : attack flag #ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_shr_sat( finc[0], Qx ); /*Qx */ #else - L_tmp = L_shr_o( finc[0], Qx, &Overflow ); /*Qx */ + L_tmp = L_shr_o( finc[0], Qx, &Overflow ); /*Qx */ #endif FOR( i = 1; i < att_3lsub_pos; i++ ) @@ -1511,7 +1511,7 @@ static Word16 attack_det_fx( /* o : attack flag #ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_add_o( L_tmp, L_shr_sat( finc[i], Qx ), &Overflow ); /*Qx */ #else - L_tmp = L_add_o( L_tmp, L_shr_o( finc[i], Qx, &Overflow ), &Overflow ); /*Qx */ + L_tmp = L_add_o( L_tmp, L_shr_o( finc[i], Qx, &Overflow ), &Overflow ); /*Qx */ #endif } L_tmp = Mult_32_16( L_tmp, tmp ); /*Q(14-exp1+Qx) */ @@ -1524,7 +1524,7 @@ static Word16 attack_det_fx( /* o : attack flag #ifdef ISSUE_1799_replace_L_shr_o L_tmp = L_shr_sat( finc[attack], Qx ); /*Qx */ #else - L_tmp = L_shr_o( finc[attack], Qx, &Overflow ); /*Qx */ + L_tmp = L_shr_o( finc[attack], Qx, &Overflow ); /*Qx */ #endif FOR( i = 1; i < tmp1; i++ ) { diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index 88413850b..b98693733 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -1159,7 +1159,7 @@ Word16 wb_vad_fx( #ifdef ISSUE_1799_replace_L_shr_o L_snr = L_shr_sat( snr_tmp, shift_snr ); /* L_snr in Q4 */ #else - L_snr = L_shr_o( snr_tmp, shift_snr, &Overflow ); /* L_snr in Q4 */ + L_snr = L_shr_o( snr_tmp, shift_snr, &Overflow ); /* L_snr in Q4 */ #endif } ELSE -- GitLab From 3c9aa7c2154c6396e9d0e8e96ebfa6a7e393b6d0 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 29 Jul 2025 13:49:47 +0200 Subject: [PATCH 20/22] lib_enc/swb_bwe_enc_lr_fx.c : GetSubbandCorrIndex2_har_fx(() : keep L_shr_o, fix instrumentation --- lib_enc/swb_bwe_enc_lr_fx.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index 68bd400c4..5369f02e0 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -173,27 +173,16 @@ static Word16 GetSubbandCorrIndex2_har_fx( /* o : corr_sq_hi_fx = extract_h( L_corr_sq ); L_corr_sq = L_mult_o( corr_sq_hi_fx, corr_sq_hi_fx, &Overflow ); /* (((Qhi:Qsh+exp_norm_hi-16)+Qss+1)+exp_norm-16)*2+1 */ -#ifdef ISSUE_1799_replace_L_shr_o - L_corr_sq = L_shr_sat( L_corr_sq, s_min( shl( exp_norm, 1 ), 31 ) ); /* (QCorr-16)*2+1 */ - /* Catching an Overflow: solve MAX_32 = x * 2^y for integers x < 2^31 and y : - x = MAX_32 && y == 0 - So, a saturated overflow has occured if the result is MAX_32 and y != 0 OR x != MAX_32*/ - test(); - IF( L_corr_sq == MAX_32 && ( exp_norm < 0 ) ) - { - Overflow = 1; - } -#else L_corr_sq = L_shr_o( L_corr_sq, s_min( shl( exp_norm, 1 ), 31 ), &Overflow ); /* (QCorr-16)*2+1 */ -#endif - IF( Overflow != 0 ) + if( Overflow != 0 ) { L_corr_sq = 0x0L; - move16(); - Overflow = 0; - move16(); + move32(); } + Overflow = 0; + move16(); + /* normalize for L_lagCorr_sq and L_corr_sq */ L_buf = L_or( L_lagCorr_sq, L_corr_sq ); exp_corr = norm_l( L_buf ); -- GitLab From 30a8800c27f608461dca8eeca601d6da81eeb9dd Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 29 Jul 2025 14:44:35 +0200 Subject: [PATCH 21/22] clang patch --- lib_enc/swb_bwe_enc_lr_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/swb_bwe_enc_lr_fx.c b/lib_enc/swb_bwe_enc_lr_fx.c index 5369f02e0..3c92c7f89 100644 --- a/lib_enc/swb_bwe_enc_lr_fx.c +++ b/lib_enc/swb_bwe_enc_lr_fx.c @@ -172,9 +172,9 @@ static Word16 GetSubbandCorrIndex2_har_fx( /* o : L_corr_sq = L_shl( L_corr, exp_norm ); corr_sq_hi_fx = extract_h( L_corr_sq ); - L_corr_sq = L_mult_o( corr_sq_hi_fx, corr_sq_hi_fx, &Overflow ); /* (((Qhi:Qsh+exp_norm_hi-16)+Qss+1)+exp_norm-16)*2+1 */ + L_corr_sq = L_mult_o( corr_sq_hi_fx, corr_sq_hi_fx, &Overflow ); /* (((Qhi:Qsh+exp_norm_hi-16)+Qss+1)+exp_norm-16)*2+1 */ L_corr_sq = L_shr_o( L_corr_sq, s_min( shl( exp_norm, 1 ), 31 ), &Overflow ); /* (QCorr-16)*2+1 */ - if( Overflow != 0 ) + if ( Overflow != 0 ) { L_corr_sq = 0x0L; move32(); -- GitLab From 1476d274ef1e0f44c8c5f9dade97e23d4b51841e Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 6 Aug 2025 22:38:01 +0200 Subject: [PATCH 22/22] formatting --- lib_com/lsf_tools_fx.c | 2 +- lib_dec/LD_music_post_filter_fx.c | 2 +- lib_enc/find_tilt_fx.c | 6 +++--- lib_enc/hvq_enc_fx.c | 8 ++++---- lib_enc/nois_est_fx.c | 2 +- lib_enc/vad_fx.c | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c index 7463e51c2..ea5e51cef 100644 --- a/lib_com/lsf_tools_fx.c +++ b/lib_com/lsf_tools_fx.c @@ -2326,7 +2326,7 @@ Word16 lsf_stab_fx( /* o : LP filter stability Q15*/ #ifdef ISSUE_1796_replace_shl_o tmp = shl_sat( tmp, 1 ); /* Q14 -> Q15 with saturation */ #else - tmp = shl_o( tmp, 1, &Overflow ); /* Q14 -> Q15 with saturation */ + tmp = shl_o( tmp, 1, &Overflow ); /* Q14 -> Q15 with saturation */ #endif tmp = s_max( tmp, 0 ); diff --git a/lib_dec/LD_music_post_filter_fx.c b/lib_dec/LD_music_post_filter_fx.c index c9d03fd54..4c3fa3728 100644 --- a/lib_dec/LD_music_post_filter_fx.c +++ b/lib_dec/LD_music_post_filter_fx.c @@ -932,7 +932,7 @@ static Word16 norm_lfe( #ifdef ISSUE_1796_replace_shl_o tmp16 = shl_sat( tmp16, exp3 ); /* Result in Q12 */ #else - tmp16 = shl_o( tmp16, exp3, &Overflow ); /* Result in Q12 */ + tmp16 = shl_o( tmp16, exp3, &Overflow ); /* Result in Q12 */ #endif return tmp16; diff --git a/lib_enc/find_tilt_fx.c b/lib_enc/find_tilt_fx.c index 7274cd82c..d2e946098 100644 --- a/lib_enc/find_tilt_fx.c +++ b/lib_enc/find_tilt_fx.c @@ -178,7 +178,7 @@ void find_tilt_fx( #ifdef ISSUE_1799_replace_L_shr_o lp_E = L_sub_o( L_shr_sat( m_tmp, sub( e_tmp, 1 ) ), lp_bckr, &Overflow ); /* Q_new + QSCALE */ #else - lp_E = L_sub_o( L_shr_o( m_tmp, sub( e_tmp, 1 ), &Overflow ), lp_bckr, &Overflow ); /* Q_new + QSCALE */ + lp_E = L_sub_o( L_shr_o( m_tmp, sub( e_tmp, 1 ), &Overflow ), lp_bckr, &Overflow ); /* Q_new + QSCALE */ #endif pt_E = tmp_E + VOIC_BINS; /* Update for next half-frame */ @@ -210,7 +210,7 @@ void find_tilt_fx( #ifdef ISSUE_1799_replace_L_shr_o ee[i] = L_shr_sat( m_tmp, add( e_tmp, 15 - 6 ) ); /* ee in Q6 */ #else - ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ + ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ #endif } ELSE IF( lp_E == 0 ) @@ -477,7 +477,7 @@ void find_tilt_ivas_fx( #ifdef ISSUE_1799_replace_L_shr_o ee[i] = L_shr_sat( m_tmp, add( e_tmp, 15 - 6 ) ); /* ee in Q6 */ #else - ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ + ee[i] = L_shr_o( m_tmp, add( e_tmp, 15 - 6 ), &Overflow ); /* ee in Q6 */ #endif move32(); } diff --git a/lib_enc/hvq_enc_fx.c b/lib_enc/hvq_enc_fx.c index 519114e40..f6c45dab2 100644 --- a/lib_enc/hvq_enc_fx.c +++ b/lib_enc/hvq_enc_fx.c @@ -149,7 +149,7 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits #ifdef ISSUE_1799_replace_L_shr_o noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ #else - noise_level[i] = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ + noise_level[i] = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ #endif move16(); q_noise_level_idx[i] = quant_lc_fx( noise_level[i], &q_noise_level[i] ); @@ -184,7 +184,7 @@ Word16 hvq_enc_ivas_fx( /*o : Consumed bits #ifdef ISSUE_1799_replace_L_shr_o lb_nfpe = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ #else - lb_nfpe = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ + lb_nfpe = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ #endif IF( GT_16( lb_nfpe, 16384 ) ) /* in Q15 */ { @@ -338,7 +338,7 @@ Word16 hvq_enc_fx( /*o : Consumed bits #ifdef ISSUE_1799_replace_L_shr_o noise_level[i] = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ #else - noise_level[i] = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ + noise_level[i] = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ #endif move16(); q_noise_level_idx[i] = quant_lc_fx( noise_level[i], &q_noise_level[i] ); @@ -373,7 +373,7 @@ Word16 hvq_enc_fx( /*o : Consumed bits #ifdef ISSUE_1799_replace_L_shr_o lb_nfpe = extract_h( L_shr_sat( acc, adjust ) ); /* noise_level[] in Q15 */ #else - lb_nfpe = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ + lb_nfpe = extract_h( L_shr_o( acc, adjust, &Overflow ) ); /* noise_level[] in Q15 */ #endif IF( lb_nfpe > 16384 ) /* in Q15 */ { diff --git a/lib_enc/nois_est_fx.c b/lib_enc/nois_est_fx.c index ae7d07a67..224e4dddb 100644 --- a/lib_enc/nois_est_fx.c +++ b/lib_enc/nois_est_fx.c @@ -2568,7 +2568,7 @@ void noise_est_ivas_fx( #ifdef ISSUE_1796_replace_shl_o noise_chartmp = shl_sat( num, sub( sub( exp, exp2 ), 4 ) ); // 15+exp2-exp1 -> Q11 #else - noise_chartmp = shl_o( num, sub( sub( exp, exp2 ), 4 ), &Overflow ); // 15+exp2-exp1 -> Q11 + noise_chartmp = shl_o( num, sub( sub( exp, exp2 ), 4 ), &Overflow ); // 15+exp2-exp1 -> Q11 #endif } diff --git a/lib_enc/vad_fx.c b/lib_enc/vad_fx.c index e22f8cdcd..955c7c74d 100644 --- a/lib_enc/vad_fx.c +++ b/lib_enc/vad_fx.c @@ -1090,7 +1090,7 @@ Word16 wb_vad_fx( #ifdef ISSUE_1796_replace_shl_o tmp = shl_sat( snr, 5 ); /* Q8 -> Q13 */ #else - tmp = shl_o( snr, 5, &Overflow ); /* Q8 -> Q13 */ + tmp = shl_o( snr, 5, &Overflow ); /* Q8 -> Q13 */ #endif IF( LT_16( i, 2 ) ) { -- GitLab