From c7605ca33c7e9f963db3a568133a37f44afa192d Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 23 Jan 2026 13:47:20 +0100 Subject: [PATCH 1/3] correctly initialize exponents in getChannelEnergies_fx() --- lib_com/options.h | 1 + lib_enc/ivas_mct_enc_mct_fx.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index c7cd38dd8..9fcf994e4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -119,6 +119,7 @@ #define FIX_1500_ISM_MD_DTX /* VA: float issue 1500: fix ISM elevation metadata smoothing in DTX */ #define FIX_2348_REPLACE_FEC_ENC /* VA: basop issue 2348: replace FEC_encode_ivas_fx with FEC_encode_fx */ #define FIX_2338_HARM_GSC_GAIN_COMP /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */ +#define FIX_2356_GET_CHAN_ENERGIES /* FhG: basop issue 2356: correctly initialize exponents in getChannelEnergies_fx() */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_enc/ivas_mct_enc_mct_fx.c b/lib_enc/ivas_mct_enc_mct_fx.c index 5b2642030..5329e3c2f 100644 --- a/lib_enc/ivas_mct_enc_mct_fx.c +++ b/lib_enc/ivas_mct_enc_mct_fx.c @@ -92,15 +92,36 @@ void getChannelEnergies_fx( move16(); nrg[ch] = 0; move32(); + +#ifdef FIX_2356_GET_CHAN_ENERGIES + /* move first loop iteration outside of loop - we need a proper initialization of nrg_e[ch] based on sum2_e, which is calculated in first loop iteration */ + sum2 = sum2_32_exp_fx( st->hTcxEnc->spectrum_fx[0], L_subframe, &sum2_e, gb ); // 31 - sum2_e + + nrg_e[ch] = sum2_e; /* only needed in first iteration */ + move16(); + + nrg[ch] = BASOP_Util_Add_Mant32Exp( nrg[ch], nrg_e[ch], sum2, sum2_e, &nrg_e[ch] ); + move32(); + FOR( n = 0; n < nSubframes; n++ ) +#else + FOR( n = 1; n < nSubframes; n++ ) +#endif { +#ifdef FIX_2356_GET_CHAN_ENERGIES + sum2_e = st->hTcxEnc->spectrum_e[n]; + move16(); +#endif + sum2 = sum2_32_exp_fx( st->hTcxEnc->spectrum_fx[n], L_subframe, &sum2_e, gb ); // 31 - sum2_e nrg[ch] = BASOP_Util_Add_Mant32Exp( nrg[ch], nrg_e[ch], sum2, sum2_e, &nrg_e[ch] ); move32(); +#ifndef FIX_2356_GET_CHAN_ENERGIES sum2_e = st->hTcxEnc->spectrum_e[0]; move16(); +#endif } nrg[ch] = Sqrt32( nrg[ch], &nrg_e[ch] ); // nrg_e -- GitLab From e672c51d6f075ec360238fba5685bc01434bea2b Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 23 Jan 2026 15:22:30 +0100 Subject: [PATCH 2/3] fix loop initialization --- lib_enc/ivas_mct_enc_mct_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/ivas_mct_enc_mct_fx.c b/lib_enc/ivas_mct_enc_mct_fx.c index 5329e3c2f..40882b1eb 100644 --- a/lib_enc/ivas_mct_enc_mct_fx.c +++ b/lib_enc/ivas_mct_enc_mct_fx.c @@ -103,9 +103,9 @@ void getChannelEnergies_fx( nrg[ch] = BASOP_Util_Add_Mant32Exp( nrg[ch], nrg_e[ch], sum2, sum2_e, &nrg_e[ch] ); move32(); - FOR( n = 0; n < nSubframes; n++ ) -#else FOR( n = 1; n < nSubframes; n++ ) +#else + FOR( n = 0; n < nSubframes; n++ ) #endif { #ifdef FIX_2356_GET_CHAN_ENERGIES -- GitLab From f21565c8cb0a93d023872d837b4763de7489cb72 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 23 Jan 2026 15:37:55 +0100 Subject: [PATCH 3/3] simplify patch --- lib_enc/ivas_mct_enc_mct_fx.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/lib_enc/ivas_mct_enc_mct_fx.c b/lib_enc/ivas_mct_enc_mct_fx.c index 40882b1eb..84bc74dd9 100644 --- a/lib_enc/ivas_mct_enc_mct_fx.c +++ b/lib_enc/ivas_mct_enc_mct_fx.c @@ -88,31 +88,24 @@ void getChannelEnergies_fx( gb = find_guarded_bits_fx( (Word32) L_subframe ); +#ifndef FIX_2356_GET_CHAN_ENERGIES sum2_e = st->hTcxEnc->spectrum_e[0]; move16(); +#endif nrg[ch] = 0; move32(); - #ifdef FIX_2356_GET_CHAN_ENERGIES - /* move first loop iteration outside of loop - we need a proper initialization of nrg_e[ch] based on sum2_e, which is calculated in first loop iteration */ - sum2 = sum2_32_exp_fx( st->hTcxEnc->spectrum_fx[0], L_subframe, &sum2_e, gb ); // 31 - sum2_e - - nrg_e[ch] = sum2_e; /* only needed in first iteration */ + nrg_e[ch] = 0; /* if the mantissa is 0, the exponent gets set to sum2_e inside BASOP_Util_Add_Mant32Exp() */ move16(); +#endif - nrg[ch] = BASOP_Util_Add_Mant32Exp( nrg[ch], nrg_e[ch], sum2, sum2_e, &nrg_e[ch] ); - move32(); - - FOR( n = 1; n < nSubframes; n++ ) -#else FOR( n = 0; n < nSubframes; n++ ) -#endif { #ifdef FIX_2356_GET_CHAN_ENERGIES sum2_e = st->hTcxEnc->spectrum_e[n]; move16(); -#endif +#endif sum2 = sum2_32_exp_fx( st->hTcxEnc->spectrum_fx[n], L_subframe, &sum2_e, gb ); // 31 - sum2_e nrg[ch] = BASOP_Util_Add_Mant32Exp( nrg[ch], nrg_e[ch], sum2, sum2_e, &nrg_e[ch] ); -- GitLab