From ba2f8a054cd62d8f6123fe0bea2502581153e181 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Sat, 15 Nov 2025 17:25:49 +0100 Subject: [PATCH 1/4] Fix div_l with zero exit(-1) problem. Still need to check if the the problem needs to avoided in a second place (else branch of the if where it happens). --- lib_com/options.h | 2 ++ lib_dec/tonalMDCTconcealment_fx.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index b1d98931d..2e14c9035 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -115,6 +115,8 @@ #define NONBE_FIX_BASOP_2233_RTPDUMP_DIFFERING_BITSTREAMS /* Nokia: fix basop issue 2233: Fix differing rtpdump streams */ +#define NONBE_FIX_2237_ZERO_CURR_NOISE_PROBLEM /* FhG: Modify sum of hTonalMDCTConc->curr_noise_nrg to avoid inaccurate zero */ + /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index d098eaa15..dcb3bd940 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -3098,7 +3098,19 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( move32(); IF( concealment_noise[i] != 0 ) { +#ifdef NONBE_FIX_2237_ZERO_CURR_NOISE_PROBLEM + Word32 cnp; + Word16 cnp_e; + + cnp_e = norm_l( concealment_noise[i] ); + cnp = L_shl( concealment_noise[i], cnp_e ); + cnp = Mpy_32_32( cnp, cnp ); + cnp_e = shl( add( cnp_e, *concealment_noise_exp ), 1 ); + + hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, cnp, cnp_e, &temp_e ); // Q31-temp_e +#else hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, Mpy_32_32( concealment_noise[i], concealment_noise[i] ), shl( *concealment_noise_exp, 1 ), &temp_e ); // Q31-temp_e +#endif } hTonalMDCTConc->curr_noise_nrg_exp = temp_e; move16(); -- GitLab From 7df2a6925107690c67174a516d344e8563cfdafa Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Sun, 16 Nov 2025 19:51:57 +0100 Subject: [PATCH 2/4] Use same change also for mixed TCX10/TCX20 frames to avoid zero hTonalMDCTConc->curr_noise_nrg. --- lib_dec/tonalMDCTconcealment_fx.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index dcb3bd940..bb415e1dd 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -3130,7 +3130,19 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( move32(); IF( concealment_noise[i] != 0 ) { +#ifdef NONBE_FIX_2237_ZERO_CURR_NOISE_PROBLEM + Word32 cnp; + Word16 cnp_e; + + cnp_e = norm_l( concealment_noise[i] ); + cnp = L_shl( concealment_noise[i], cnp_e ); + cnp = Mpy_32_32( cnp, cnp ); + cnp_e = shl( add( cnp_e, *concealment_noise_exp ), 1 ); + + hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, cnp, cnp_e, &temp_e ); // Q31-temp_e +#else hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, Mpy_32_32( concealment_noise[i], concealment_noise[i] ), shl( *concealment_noise_exp, 1 ), &temp_e ); // Q31-temp_e +#endif } hTonalMDCTConc->curr_noise_nrg_exp = temp_e; move16(); -- GitLab From ea79e5a6bb5c0959ef29a4af56fd3b7e61673094 Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Mon, 17 Nov 2025 08:48:44 +0100 Subject: [PATCH 3/4] Correct exponent calculation acccording to comment from @tyagiri. --- lib_dec/tonalMDCTconcealment_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index bb415e1dd..b9e432baf 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -3105,7 +3105,7 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( cnp_e = norm_l( concealment_noise[i] ); cnp = L_shl( concealment_noise[i], cnp_e ); cnp = Mpy_32_32( cnp, cnp ); - cnp_e = shl( add( cnp_e, *concealment_noise_exp ), 1 ); + cnp_e = shl( sub( cnp_e, *concealment_noise_exp ), 1 ); hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, cnp, cnp_e, &temp_e ); // Q31-temp_e #else @@ -3137,7 +3137,7 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( cnp_e = norm_l( concealment_noise[i] ); cnp = L_shl( concealment_noise[i], cnp_e ); cnp = Mpy_32_32( cnp, cnp ); - cnp_e = shl( add( cnp_e, *concealment_noise_exp ), 1 ); + cnp_e = shl( sub( cnp_e, *concealment_noise_exp ), 1 ); hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, cnp, cnp_e, &temp_e ); // Q31-temp_e #else -- GitLab From 415ac0bec5b9e06f792508740b527d0e931b5e0e Mon Sep 17 00:00:00 2001 From: Manuel Jander Date: Mon, 17 Nov 2025 08:50:02 +0100 Subject: [PATCH 4/4] Correct exponent calculation acccording to comment from @tyagiri. second attempt. --- lib_dec/tonalMDCTconcealment_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index b9e432baf..9e880b9f1 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -3105,7 +3105,7 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( cnp_e = norm_l( concealment_noise[i] ); cnp = L_shl( concealment_noise[i], cnp_e ); cnp = Mpy_32_32( cnp, cnp ); - cnp_e = shl( sub( cnp_e, *concealment_noise_exp ), 1 ); + cnp_e = shl( sub( *concealment_noise_exp, cnp_e ), 1 ); hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, cnp, cnp_e, &temp_e ); // Q31-temp_e #else @@ -3137,7 +3137,7 @@ void TonalMdctConceal_create_concealment_noise_ivas_fx( cnp_e = norm_l( concealment_noise[i] ); cnp = L_shl( concealment_noise[i], cnp_e ); cnp = Mpy_32_32( cnp, cnp ); - cnp_e = shl( sub( cnp_e, *concealment_noise_exp ), 1 ); + cnp_e = shl( sub( *concealment_noise_exp, cnp_e ), 1 ); hTonalMDCTConc->curr_noise_nrg = BASOP_Util_Add_Mant32Exp( hTonalMDCTConc->curr_noise_nrg, hTonalMDCTConc->curr_noise_nrg_exp, cnp, cnp_e, &temp_e ); // Q31-temp_e #else -- GitLab