From 2b64e7a6a9362d7b2f65461181ac1356ff7a5d72 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 25 Jun 2025 15:50:12 +0200 Subject: [PATCH 1/2] replace ahr_ro ba shr_r_sat --- lib_com/options.h | 1 + lib_com/tools_fx.c | 8 ++++++++ lib_enc/find_uv_fx.c | 6 ++++++ 3 files changed, 15 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 4badd652f..4fcc4a03e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -100,5 +100,6 @@ #define FIX_1762_COMPILER_ISSUE /* FhG: fix compiler issues with W_mac_32_32() + ONE_IN_Q30 */ #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 */ #endif diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index a83dfb56b..3d5b13938 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -3144,7 +3144,11 @@ void add_vec_fx( { FOR( i = 0; i < N; i++ ) { +#ifdef ISSUE_1770_replace_shr_ro + y[i] = add_o( x1[i], shr_r_sat( x2[i], Qyx2 ), &Overflow ); +#else y[i] = add_o( x1[i], shr_ro( x2[i], Qyx2, &Overflow ), &Overflow ); +#endif move16(); } } @@ -3152,7 +3156,11 @@ void add_vec_fx( { FOR( i = 0; i < N; i++ ) { +#ifdef ISSUE_1770_replace_shr_ro + y[i] = add_o( shr_r_sat( x1[i], Qyx1 ), shr_ro( x2[i], Qyx2, &Overflow ), &Overflow ); +#else y[i] = add_o( shr_ro( x1[i], Qyx1, &Overflow ), shr_ro( x2[i], Qyx2, &Overflow ), &Overflow ); +#endif move16(); } } diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 61de9ca7d..462b7580d 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -32,9 +32,11 @@ static Word16 find_ener_decrease_fx( /* o : maximum Word16 wtmp0, wtmp1; Word32 maxEnr, minEnr; Word16 dE2, exp0, exp1; +#ifndef ISSUE_1770_replace_shr_ro #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; move32(); +#endif #endif dE2 = 0; @@ -76,7 +78,11 @@ static Word16 find_ener_decrease_fx( /* o : maximum exp1 = sub( norm_l( maxEnr ), 1 ); wtmp1 = extract_h( L_shl( maxEnr, exp1 ) ); wtmp1 = div_s( wtmp1, wtmp0 ); +#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*/ +#endif return dE2; } -- GitLab From 54a3b922b83f90b4a37c29f8a4b6e6d0c13603c5 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 25 Jun 2025 15:54:22 +0200 Subject: [PATCH 2/2] replace shr_ro ba shr_r_sat oe more + buildfix --- lib_com/tools_fx.c | 2 +- lib_enc/find_uv_fx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/tools_fx.c b/lib_com/tools_fx.c index 3d5b13938..b2974696a 100644 --- a/lib_com/tools_fx.c +++ b/lib_com/tools_fx.c @@ -3157,7 +3157,7 @@ void add_vec_fx( FOR( i = 0; i < N; i++ ) { #ifdef ISSUE_1770_replace_shr_ro - y[i] = add_o( shr_r_sat( x1[i], Qyx1 ), shr_ro( x2[i], Qyx2, &Overflow ), &Overflow ); + y[i] = add_o( shr_r_sat( x1[i], Qyx1 ), shr_r_sat( x2[i], Qyx2 ), &Overflow ); #else y[i] = add_o( shr_ro( x1[i], Qyx1, &Overflow ), shr_ro( x2[i], Qyx2, &Overflow ), &Overflow ); #endif diff --git a/lib_enc/find_uv_fx.c b/lib_enc/find_uv_fx.c index 462b7580d..9dcd8386b 100644 --- a/lib_enc/find_uv_fx.c +++ b/lib_enc/find_uv_fx.c @@ -79,7 +79,7 @@ static Word16 find_ener_decrease_fx( /* o : maximum wtmp1 = extract_h( L_shl( maxEnr, exp1 ) ); wtmp1 = div_s( wtmp1, wtmp0 ); #ifdef ISSUE_1770_replace_shr_ro - dE2 = shr_r_Sat( wtmp1, add( sub( exp1, exp0 ), 15 - 10 ) ); /*Q10*/ + 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*/ #endif -- GitLab