From 3e8141c95178bdbf4cf4e66fcdd7571e833e6191 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Thu, 16 Apr 2026 11:16:58 +0300 Subject: [PATCH] Fix BASOP issue 2541 by adding the proper energy accumulation. Also skip unnecessary computation. --- lib_com/options.h | 2 +- lib_enc/ivas_masa_enc_fx.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 5f27f69da..7f60337d3 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -120,7 +120,7 @@ #define FIX_BASOP_2522_MAP_PARAMS_DIRAC_STEREO /* FhG: BASOP issue 2522: Fix copy and paste error for side_gain calculation in map_params_dirac_to_stereo() */ #define FIX_2505_IVAS_DEC_SEGFAULT /* FhG: BASOP #2505: Add headroom to input of ivas_rend_crendProcessSubframe_fx() for ivas_mdft_fx() calculation */ #define HARMONIZE_DoRTFTn /* VA: harmonize functions DoRTFTn_fx() and DoRTFTn_fx_ivas() */ - +#define FIX_BASOP_2541_OMASA_ENC_FIXES /* Nokia: BASOP issue 2541: Fix function ivas_encode_masaism_metadata_fx */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index 4125e6d30..fabafe9ed 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -4818,8 +4818,13 @@ static void ivas_encode_masaism_metadata_fx( eneBand32 = W_extract_h( W_shl( eneBand, shift ) ); eneBand_exp = sub( 63, add( add( hMasa->data.q_energy, 1 ), shift ) ); +#ifdef FIX_BASOP_2541_OMASA_ENC_FIXES + energy_ism = L_tmp; // Copy existing value + energy_ism_e = L_tmp_e; +#else energy_ism = 0; energy_ism_e = 0; +#endif move32(); move16(); FOR( obj = 0; obj < nchan_ism; obj++ ) @@ -4832,13 +4837,20 @@ static void ivas_encode_masaism_metadata_fx( FOR( band = 0; band < omasa_nbands; band++ ) { +#ifndef FIX_BASOP_2541_OMASA_ENC_FIXES energy_ism = BASOP_Util_Add_Mant32Exp( energy_ism, energy_ism_e, hOmasaEnergy->energy_ism_fx[sf][band], hOmasaEnergy->energy_ism_fx_e[sf][band], &energy_ism_e ); - +#endif FOR( obj = 0; obj < nchan_ism; obj++ ) { +#ifdef FIX_BASOP_2541_OMASA_ENC_FIXES + L_tmp = Mpy_32_32( hOmasaEnergy->energy_ism_fx[sf][band], hOmasaEnergy->energy_ratio_ism_fx[sf][band][obj] ); // Q = (31 - hOmasaEnergy->energy_ism_fx_e[sf][band]) + Q30 - 31 + L_tmp_e = add( 1, hOmasaEnergy->energy_ism_fx_e[sf][band] ); + energy_ism_ind[obj] = BASOP_Util_Add_Mant32Exp( energy_ism_ind[obj], energy_ism_ind_e[obj], L_tmp, L_tmp_e, &energy_ism_ind_e[obj] ); +#else hOmasaData->masa_to_total_energy_ratio_fx[sf][0] = ONE_IN_Q30; // 1.0f in Q30 move32(); +#endif } } -- GitLab