From 8a609b985dff27ddc74a901f8c0575259db7c782 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 16 Jun 2025 16:34:06 +0530 Subject: [PATCH 1/2] Fix for 3GPP issue 1724: Renderer MASA output metadata difference - 2 Link #1724 --- lib_rend/ivas_masa_merge_fx.c | 107 ++++++++++++---------------------- lib_rend/ivas_prot_rend_fx.h | 4 +- lib_rend/ivas_stat_rend.h | 12 ++-- lib_rend/lib_rend_fx.c | 47 ++++++--------- 4 files changed, 60 insertions(+), 110 deletions(-) diff --git a/lib_rend/ivas_masa_merge_fx.c b/lib_rend/ivas_masa_merge_fx.c index 65829e1c8..d90076847 100644 --- a/lib_rend/ivas_masa_merge_fx.c +++ b/lib_rend/ivas_masa_merge_fx.c @@ -46,9 +46,25 @@ static void copy_masa_meta_tile_fx( MASA_DECODER_EXT_OUT_META_HANDLE outMeta, MASA_DECODER_EXT_OUT_META_HANDLE inMeta, const UWord8 sf, const UWord8 band ); -static void full_stream_merge_fx( MASA_DECODER_EXT_OUT_META_HANDLE outMeta, MASA_DECODER_EXT_OUT_META_HANDLE inMeta1, Word32 inEne1[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word16 *inEne1_e, MASA_DECODER_EXT_OUT_META_HANDLE inMeta2, Word32 inEne2[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word16 *inEne2_e ); +static void full_stream_merge_fx( + MASA_DECODER_EXT_OUT_META_HANDLE outMeta, /* o : Merged metadata output */ + MASA_DECODER_EXT_OUT_META_HANDLE inMeta1, /* i : Input metadata 1 */ + Word32 inEne1_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1. after merge, contains the energy of the merged signal */ + Word16 inEne1_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1 Exponent */ + MASA_DECODER_EXT_OUT_META_HANDLE inMeta2, /* i : Input metadata 2 */ + Word32 inEne2_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 2 */ + Word16 inEne2_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : TF-energy of input 2 Exponent */ +); -static void diffuse_meta_merge_1x1_fx( MASA_DECODER_EXT_OUT_META_HANDLE outMeta, MASA_DECODER_EXT_OUT_META_HANDLE inMeta, Word32 inEne_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word16 *inEne_e, MASA_DECODER_EXT_OUT_META_HANDLE inMetaISM, Word32 inEneISM_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], Word16 *inEneISM_e ); +static void diffuse_meta_merge_1x1_fx( + MASA_DECODER_EXT_OUT_META_HANDLE outMeta, /* o : Merged metadata output */ + MASA_DECODER_EXT_OUT_META_HANDLE inMeta, /* i : Input metadata 1 */ + Word32 inEne_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 1 */ + Word16 inEne_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 1 Exponent */ + MASA_DECODER_EXT_OUT_META_HANDLE inMetaISM, /* i : Input metadata 2 */ + Word32 inEneISM_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 2 */ + Word16 inEneISM_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : TF-energy of input 2 Exponent */ +); /*---------------------------------------------------------------------* @@ -144,14 +160,13 @@ void diffuse_meta_merge_1x1_fx( MASA_DECODER_EXT_OUT_META_HANDLE outMeta, /* o : Merged metadata output */ MASA_DECODER_EXT_OUT_META_HANDLE inMeta, /* i : Input metadata 1 */ Word32 inEne_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 1 */ - Word16 *inEne_e, /* i : TF-energy of input 1 Exponent */ + Word16 inEne_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 1 Exponent */ MASA_DECODER_EXT_OUT_META_HANDLE inMetaISM, /* i : Input metadata 2 */ Word32 inEneISM_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 2 */ - Word16 *inEneISM_e /* i : TF-energy of input 2 Exponent */ + Word16 inEneISM_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : TF-energy of input 2 Exponent */ ) { Word8 sf, band; - Word16 max_e, in1_e[MASA_FREQUENCY_BANDS], i; FOR( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ ) { FOR( band = 0; band < MASA_FREQUENCY_BANDS; band++ ) @@ -164,22 +179,13 @@ void diffuse_meta_merge_1x1_fx( tmp = BASOP_Util_Divide1616_Scale( inMeta->directToTotalRatio[0][sf][band], UINT8_MAX, &scale ); energyTimesRatio_fx = Mpy_32_16_r( inEne_fx[sf][band], tmp ); /* Q( 31 - ( nEne_e[sf] + scale ) ) */ - energyTimesRatio_e = add( inEne_e[sf], scale ); + energyTimesRatio_e = add( inEne_e[sf][band], scale ); + total_nrg_fx = BASOP_Util_Add_Mant32Exp( inEne_fx[sf][band], inEne_e[sf][band], inEneISM_fx[sf][band], inEneISM_e[sf][band], &total_nrg_e ); - IF( GT_16( inEne_e[sf], inEneISM_e[sf] ) ) - { - total_nrg_fx = L_add( L_shr( inEne_fx[sf][band], 1 ), L_shr( inEneISM_fx[sf][band], add( sub( inEne_e[sf], inEneISM_e[sf] ), 1 ) ) ); /* Q(30 - inEne_e[sf]) */ - total_nrg_e = add( inEne_e[sf], 1 ); - } - ELSE - { - total_nrg_fx = L_add( L_shr( inEneISM_fx[sf][band], 1 ), L_shr( inEne_fx[sf][band], add( sub( inEneISM_e[sf], inEne_e[sf] ), 1 ) ) ); /* Q(30 - inEneISM_e[sf]) */ - total_nrg_e = add( inEneISM_e[sf], 1 ); - } /* target is original MASA diffuseness */ tmp = BASOP_Util_Divide1616_Scale( inMeta->diffuseToTotalRatio[sf][band], UINT8_MAX, &scale ); total_diff_nrg_fx = Mpy_32_16_r( inEne_fx[sf][band], tmp ); /* Q( 31 - ( nEne_e[sf] + scale ) ) */ - total_diff_nrg_e = add( inEne_e[sf], scale ); + total_diff_nrg_e = add( inEne_e[sf][band], scale ); /* criterion is mean of ISM ratio and new ratio */ dir_ratio_ism_fx = L_deposit_h( BASOP_Util_Divide1616_Scale( inMetaISM->directToTotalRatio[0][sf][band], UINT8_MAX, &dir_ratio_ism_e ) ); @@ -191,7 +197,7 @@ void diffuse_meta_merge_1x1_fx( L_tmp1 = BASOP_Util_Add_Mant32Exp( dir_ratio_ism_fx, dir_ratio_ism_e, L_tmp2, scale, &tmp ); L_tmp1 = L_shr( L_tmp1, 1 ); energyTimesRatioISM_fx = Mpy_32_32( L_tmp1, inEneISM_fx[sf][band] ); /* Q( 31 - ( tmp + inEneISM_e[sf] ) ) */ - energyTimesRatioISM_e = add( tmp, inEneISM_e[sf] ); + energyTimesRatioISM_e = add( tmp, inEneISM_e[sf][band] ); IF( ( BASOP_Util_Cmp_Mant32Exp( energyTimesRatioISM_fx, energyTimesRatioISM_e, energyTimesRatio_fx, energyTimesRatio_e ) > 0 ) ) { @@ -264,29 +270,9 @@ void diffuse_meta_merge_1x1_fx( outMeta->spreadCoherence[1][sf][band] = 0u; move16(); - inEne_fx[sf][band] = BASOP_Util_Add_Mant32Exp( inEne_fx[sf][band], inEne_e[sf], inEneISM_fx[sf][band], inEneISM_e[sf], &in1_e[band] ); /* Update energy for subsequent mergings */ - move16(); - } - - max_e = in1_e[0]; - move16(); - FOR( i = 1; i < MASA_FREQUENCY_BANDS; i++ ) - { - if ( LT_16( max_e, in1_e[i] ) ) - { - max_e = in1_e[i]; - move16(); - } - } - - FOR( i = 0; i < MASA_FREQUENCY_BANDS; i++ ) - { - inEne_fx[sf][i] = L_shr( inEne_fx[sf][i], sub( max_e, in1_e[i] ) ); /* Q(31 - max_e) */ + inEne_fx[sf][band] = BASOP_Util_Add_Mant32Exp( inEne_fx[sf][band], inEne_e[sf][band], inEneISM_fx[sf][band], inEneISM_e[sf][band], &inEne_e[sf][band] ); /* Update energy for subsequent mergings */ move32(); } - - inEne_e[sf] = max_e; - move16(); } /* Set descriptive meta for mixed format */ @@ -318,16 +304,15 @@ void full_stream_merge_fx( MASA_DECODER_EXT_OUT_META_HANDLE outMeta, /* o : Merged metadata output */ MASA_DECODER_EXT_OUT_META_HANDLE inMeta1, /* i : Input metadata 1 */ Word32 inEne1_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1. after merge, contains the energy of the merged signal */ - Word16 *inEne1_e, /* i/o: TF-energy of input 1 Exponent */ + Word16 inEne1_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1 Exponent */ MASA_DECODER_EXT_OUT_META_HANDLE inMeta2, /* i : Input metadata 2 */ Word32 inEne2_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 2 */ - Word16 *inEne2_e /* i : TF-energy of input 2 Exponent */ + Word16 inEne2_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : TF-energy of input 2 Exponent */ ) { UWord8 n_dirs_1, n_dirs_2; UWord8 sf, band; - Word16 scale, tmp, dir_nrg_1_e, dir_nrg_2_e, max_e, i; - Word16 in1_e[MASA_FREQUENCY_BANDS]; + Word16 scale, tmp, dir_nrg_1_e, dir_nrg_2_e; Word32 dir_nrg_1_fx, dir_nrg_2_fx, L_tmp; /* full stream select based on total direct energy */ @@ -340,17 +325,17 @@ void full_stream_merge_fx( { tmp = BASOP_Util_Divide1616_Scale( inMeta1->directToTotalRatio[0][sf][band], UINT8_MAX, &scale ); dir_nrg_1_fx = Mpy_32_32( L_deposit_h( tmp ), inEne1_fx[sf][band] ); /* Q( 31 - ( scale + inEne1_e[sf] ) ) */ - dir_nrg_1_e = add( scale, inEne1_e[sf] ); + dir_nrg_1_e = add( scale, inEne1_e[sf][band] ); - tmp = BASOP_Util_Divide1616_Scale( inMeta1->directToTotalRatio[0][sf][band], UINT8_MAX, &scale ); + tmp = BASOP_Util_Divide1616_Scale( inMeta2->directToTotalRatio[0][sf][band], UINT8_MAX, &scale ); dir_nrg_2_fx = Mpy_32_32( L_deposit_h( tmp ), inEne2_fx[sf][band] ); /* Q( 31 - ( scale + inEne2_e[sf] ) ) */ - dir_nrg_2_e = add( scale, inEne2_e[sf] ); + dir_nrg_2_e = add( scale, inEne2_e[sf][band] ); IF( EQ_16( n_dirs_1, 2 ) ) { tmp = BASOP_Util_Divide1616_Scale( inMeta1->directToTotalRatio[1][sf][band], UINT8_MAX, &scale ); L_tmp = Mpy_32_32( L_deposit_h( tmp ), inEne1_fx[sf][band] ); /* Q( 31 - ( scale + inEne1_e[sf] ) ) */ - scale = add( scale, inEne1_e[sf] ); + scale = add( scale, inEne1_e[sf][band] ); dir_nrg_1_fx = BASOP_Util_Add_Mant32Exp( L_tmp, scale, dir_nrg_1_fx, dir_nrg_1_e, &dir_nrg_1_e ); } @@ -358,7 +343,7 @@ void full_stream_merge_fx( { tmp = BASOP_Util_Divide1616_Scale( inMeta2->directToTotalRatio[1][sf][band], UINT8_MAX, &scale ); L_tmp = Mpy_32_32( L_deposit_h( tmp ), inEne2_fx[sf][band] ); /* Q( 31 - ( scale + inEne2_e[sf] ) ) */ - scale = add( scale, inEne2_e[sf] ); + scale = add( scale, inEne2_e[sf][band] ); dir_nrg_2_fx = BASOP_Util_Add_Mant32Exp( L_tmp, scale, dir_nrg_2_fx, dir_nrg_2_e, &dir_nrg_2_e ); } @@ -371,29 +356,9 @@ void full_stream_merge_fx( copy_masa_meta_tile_fx( outMeta, inMeta2, sf, band ); } - inEne1_fx[sf][band] = BASOP_Util_Add_Mant32Exp( inEne1_fx[sf][band], inEne1_e[sf], inEne2_fx[sf][band], inEne2_e[sf], &in1_e[band] ); + inEne1_fx[sf][band] = BASOP_Util_Add_Mant32Exp( inEne1_fx[sf][band], inEne1_e[sf][band], inEne2_fx[sf][band], inEne2_e[sf][band], &inEne1_e[sf][band] ); move32(); } - - max_e = in1_e[0]; - move16(); - FOR( i = 1; i < MASA_FREQUENCY_BANDS; i++ ) - { - if ( LT_16( max_e, in1_e[i] ) ) - { - max_e = in1_e[i]; - move16(); - } - } - - FOR( i = 0; i < MASA_FREQUENCY_BANDS; i++ ) - { - inEne1_fx[sf][i] = L_shr( inEne1_fx[sf][i], sub( max_e, in1_e[i] ) ); /* Q( 31 - max_e ) */ - move32(); - } - - inEne1_e[sf] = max_e; - move16(); } /* Set descriptive meta for mixed format */ @@ -436,11 +401,11 @@ void ivas_prerend_merge_masa_metadata_fx( MASA_DECODER_EXT_OUT_META_HANDLE inMeta1, /* i : Input metadata 1 */ IVAS_REND_AudioConfigType inType1, /* i : Type of input 1 */ Word32 inEne1_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1. after merge, contains the energy of the merged signal */ - Word16 *inEne1_e, /* i/o: TF-energy of input 1 Exponent */ + Word16 inEne1_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1 Exponent */ MASA_DECODER_EXT_OUT_META_HANDLE inMeta2, /* i : Input metadata 2 */ IVAS_REND_AudioConfigType inType2, /* i : Type of input 2 */ Word32 inEne2_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 2 */ - Word16 *inEne2_e /* i : TF-energy of input 2 Exponent */ + Word16 inEne2_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : TF-energy of input 2 Exponent */ ) { /* mixing ISMs with non-ISM use different merge */ diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 7cd547cb8..8772b542e 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -1478,11 +1478,11 @@ void ivas_prerend_merge_masa_metadata_fx( MASA_DECODER_EXT_OUT_META_HANDLE inMeta1, /* i : Input metadata 1 */ IVAS_REND_AudioConfigType inType1, /* i : Type of input 1 */ Word32 inEne1_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1. after merge, contains the energy of the merged signal */ - Word16 *inEne1_e, /* i/o: TF-energy of input 1 Exponent */ + Word16 inEne1_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i/o: TF-energy of input 1 Exponent */ MASA_DECODER_EXT_OUT_META_HANDLE inMeta2, /* i : Input metadata 2 */ IVAS_REND_AudioConfigType inType2, /* i : Type of input 2 */ Word32 inEne2_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* i : TF-energy of input 2 */ - Word16 *inEne2_e /* i : TF-energy of input 2 Exponent */ + Word16 inEne2_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS] /* i : TF-energy of input 2 Exponent */ ); ivas_error masaPrerendOpen_fx( diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index ddf2b5942..bf13d40f8 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1565,9 +1565,8 @@ typedef struct ivas_mcmasa_ana_data_structure MASA_DECODER_EXT_OUT_META_HANDLE hMasaOut; SPHERICAL_GRID_DATA *sph_grid16; - Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /*Exp :energy_e[][]*/ Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word16 energy_exp[MAX_PARAM_SPATIAL_SUBFRAMES]; } MCMASA_ANA_DATA, *MCMASA_ANA_HANDLE; @@ -1601,10 +1600,8 @@ typedef struct ivas_omasa_ana_data_structure Word32 ism_azimuth_fx[MAX_NUM_OBJECTS]; Word32 ism_elevation_fx[MAX_NUM_OBJECTS]; - Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word16 energy_q; + Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];/*Exp :energy_e[][]*/ Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word16 energy_exp[MAX_PARAM_SPATIAL_SUBFRAMES]; Word16 interpolator_fx[L_FRAME48k]; Word32 prev_object_dm_gains_fx[MAX_NUM_OBJECTS][MASA_MAX_TRANSPORT_CHANNELS]; @@ -1645,7 +1642,6 @@ typedef struct ivas_dirac_ana_data_structure Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word16 energy_exp[MAX_PARAM_SPATIAL_SUBFRAMES]; } DIRAC_ANA_DATA, *DIRAC_ANA_HANDLE; /*----------------------------------------------------------------------------------* @@ -1661,8 +1657,8 @@ typedef struct ivas_masa_prerend_data_structure MASA_DECODER_EXT_OUT_META_HANDLE hMasaOut; SPHERICAL_GRID_DATA *sph_grid16; - Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES]; + Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];/*Exp :energy_e[][]*/ + Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; } MASA_PREREND_DATA, *MASA_PREREND_HANDLE; diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index b46d13610..3b800ed07 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -6669,7 +6669,6 @@ static void renderMasaToMasa( Word16 mrange[2]; Word16 brange[2]; Word16 numAnalysisChannels; - Word16 tmp_energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; copyBufferTo2dArray_fx( masaInput->base.inputBuffer, tmpBuffer_fx ); Word16 q_cldfb = *outAudio.pq_fact; Word16 q_cldfb_out = *outAudio.pq_fact; @@ -6692,6 +6691,7 @@ static void renderMasaToMasa( move16(); set_zero_fx( masaInput->hMasaPrerend->energy_fx[block_m_idx], MASA_FREQUENCY_BANDS ); + set16_fx( masaInput->hMasaPrerend->energy_e[block_m_idx], 0, MASA_FREQUENCY_BANDS ); FOR( ts = mrange[0]; ts < mrange[1]; ts++ ) { @@ -6746,30 +6746,14 @@ static void renderMasaToMasa( FOR( i = 0; i < numAnalysisChannels; i++ ) { Word32 temp = L_add( Mpy_32_32( Chan_RealBuffer_fx[0][j], Chan_RealBuffer_fx[0][j] ), Mpy_32_32( Chan_ImagBuffer_fx[0][j], Chan_ImagBuffer_fx[0][j] ) ); /* 2 * Q(q_cldfb_out + scale_factor) - 31 */ - masaInput->hMasaPrerend->energy_fx[block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( masaInput->hMasaPrerend->energy_fx[block_m_idx][band_m_idx], tmp_energy_e[block_m_idx][band_m_idx], temp, shl( q_add, 1 ), &tmp_energy_e[block_m_idx][band_m_idx] ); + masaInput->hMasaPrerend->energy_fx[block_m_idx][band_m_idx] = BASOP_Util_Add_Mant32Exp( masaInput->hMasaPrerend->energy_fx[block_m_idx][band_m_idx], masaInput->hMasaPrerend->energy_e[block_m_idx][band_m_idx], temp, shl( q_add, 1 ), &masaInput->hMasaPrerend->energy_e[block_m_idx][band_m_idx] ); move32(); } } } } } - FOR( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ ) - { - Word16 max_e = MIN_16; - move16(); - FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - max_e = s_max( max_e, tmp_energy_e[i][j] ); - } - masaInput->hMasaPrerend->energy_e[i] = max_e; - move16(); - FOR( j = 0; j < MASA_FREQUENCY_BANDS; j++ ) - { - masaInput->hMasaPrerend->energy_fx[i][j] = L_shr( masaInput->hMasaPrerend->energy_fx[i][j], sub( max_e, tmp_energy_e[i][j] ) ); /* Q(31 - max_e) */ - move32(); - } - } /* Copy audio channels if mismatch in number of transports */ test(); test(); @@ -7067,8 +7051,8 @@ ivas_error IVAS_REND_MergeMasaMetadata( MASA_DECODER_EXT_OUT_META_HANDLE inMeta2; Word32( *inEne1_fx )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; Word32( *inEne2_fx )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; - Word16 *inEne1_e; - Word16 *inEne2_e; + Word16( *inEne1_e )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; + Word16( *inEne2_e )[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; IF( hIvasRend == NULL ) { @@ -7078,27 +7062,31 @@ ivas_error IVAS_REND_MergeMasaMetadata( /* Input1 metadata and energy */ IF( EQ_32( inputType1, IVAS_REND_AUDIO_CONFIG_TYPE_OBJECT_BASED ) ) { + *hMasaExtOutMeta = hIvasRend->inputsIsm->hOMasa->hMasaOut; inEne1_fx = &( hIvasRend->inputsIsm->hOMasa->energy_fx ); - inEne1_e = ( hIvasRend->inputsIsm->hOMasa->energy_exp ); + inEne1_e = &( hIvasRend->inputsIsm->hOMasa->energy_e ); } ELSE IF( EQ_32( inputType1, IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) ) { + *hMasaExtOutMeta = hIvasRend->inputsMc->hMcMasa->hMasaOut; inEne1_fx = &( hIvasRend->inputsMc->hMcMasa->energy_fx ); - inEne1_e = ( hIvasRend->inputsMc->hMcMasa->energy_exp ); + inEne1_e = &( hIvasRend->inputsMc->hMcMasa->energy_e ); } ELSE IF( EQ_32( inputType1, IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) ) { + *hMasaExtOutMeta = hIvasRend->inputsSba->hDirAC->hMasaOut; inEne1_fx = &( hIvasRend->inputsSba->hDirAC->energy_fx ); - inEne1_e = ( hIvasRend->inputsSba->hDirAC->energy_exp ); + inEne1_e = &( hIvasRend->inputsSba->hDirAC->energy_e ); } ELSE IF( EQ_32( inputType1, IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) ) { + *hMasaExtOutMeta = hIvasRend->inputsMasa->hMasaPrerend->hMasaOut; inEne1_fx = &( hIvasRend->inputsMasa->hMasaPrerend->energy_fx ); - inEne1_e = ( hIvasRend->inputsMasa->hMasaPrerend->energy_e ); + inEne1_e = &( hIvasRend->inputsMasa->hMasaPrerend->energy_e ); } ELSE { @@ -7110,25 +7098,26 @@ ivas_error IVAS_REND_MergeMasaMetadata( { inMeta2 = hIvasRend->inputsIsm->hOMasa->hMasaOut; inEne2_fx = &( hIvasRend->inputsIsm->hOMasa->energy_fx ); - inEne2_e = ( hIvasRend->inputsIsm->hOMasa->energy_exp ); + inEne2_e = &( hIvasRend->inputsIsm->hOMasa->energy_e ); } ELSE IF( EQ_32( inputType2, IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) ) { inMeta2 = hIvasRend->inputsMc->hMcMasa->hMasaOut; inEne2_fx = &( hIvasRend->inputsMc->hMcMasa->energy_fx ); - inEne2_e = ( hIvasRend->inputsMc->hMcMasa->energy_exp ); + inEne2_e = &( hIvasRend->inputsMc->hMcMasa->energy_e ); } ELSE IF( EQ_32( inputType2, IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) ) { inMeta2 = hIvasRend->inputsSba->hDirAC->hMasaOut; inEne2_fx = &( hIvasRend->inputsSba->hDirAC->energy_fx ); - inEne2_e = ( hIvasRend->inputsSba->hDirAC->energy_exp ); + inEne2_e = &( hIvasRend->inputsSba->hDirAC->energy_e ); } ELSE IF( EQ_32( inputType2, IVAS_REND_AUDIO_CONFIG_TYPE_MASA ) ) { + inMeta2 = hIvasRend->inputsMasa->hMasaPrerend->hMasaOut; inEne2_fx = &( hIvasRend->inputsMasa->hMasaPrerend->energy_fx ); - inEne2_e = ( hIvasRend->inputsMasa->hMasaPrerend->energy_e ); + inEne2_e = &( hIvasRend->inputsMasa->hMasaPrerend->energy_e ); } ELSE { @@ -7136,7 +7125,7 @@ ivas_error IVAS_REND_MergeMasaMetadata( } /* Merge metadata */ - ivas_prerend_merge_masa_metadata_fx( *hMasaExtOutMeta, *hMasaExtOutMeta, inputType1, *inEne1_fx, inEne1_e, inMeta2, inputType2, *inEne2_fx, inEne2_e ); + ivas_prerend_merge_masa_metadata_fx( *hMasaExtOutMeta, *hMasaExtOutMeta, inputType1, *inEne1_fx, *inEne1_e, inMeta2, inputType2, *inEne2_fx, *inEne2_e ); IF( EQ_32( hIvasRend->outputConfig, IVAS_AUDIO_CONFIG_MASA1 ) ) -- GitLab From a139264d27bfc6c877b0220d615059abfdc44304 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 16 Jun 2025 16:50:28 +0530 Subject: [PATCH 2/2] Clang formatting --- lib_rend/ivas_stat_rend.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index bf13d40f8..f8dad9a66 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -1600,7 +1600,7 @@ typedef struct ivas_omasa_ana_data_structure Word32 ism_azimuth_fx[MAX_NUM_OBJECTS]; Word32 ism_elevation_fx[MAX_NUM_OBJECTS]; - Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];/*Exp :energy_e[][]*/ + Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /*Exp :energy_e[][]*/ Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; Word16 interpolator_fx[L_FRAME48k]; Word32 prev_object_dm_gains_fx[MAX_NUM_OBJECTS][MASA_MAX_TRANSPORT_CHANNELS]; @@ -1657,7 +1657,7 @@ typedef struct ivas_masa_prerend_data_structure MASA_DECODER_EXT_OUT_META_HANDLE hMasaOut; SPHERICAL_GRID_DATA *sph_grid16; - Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS];/*Exp :energy_e[][]*/ + Word32 energy_fx[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; /*Exp :energy_e[][]*/ Word16 energy_e[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS]; } MASA_PREREND_DATA, *MASA_PREREND_HANDLE; -- GitLab