Commit 3e8141c9 authored by Tapani Pihlajakuja's avatar Tapani Pihlajakuja
Browse files

Fix BASOP issue 2541 by adding the proper energy accumulation. Also skip unnecessary computation.

parent 26ae1a66
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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 ########################### */

+13 −1
Original line number Diff line number Diff line
@@ -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
                    }
                }