From 16c32dd76915cca79dd2b1197406b0c55f2830da Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 16 Jan 2025 12:46:57 +0530 Subject: [PATCH] Fix for 3GPP issue 1164: Assertion in reduce_metadata_further_fx for OMASA LTV input Link #1164 --- lib_enc/ivas_masa_enc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index 543897b85..625bc837b 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -2500,6 +2500,8 @@ static void reduce_metadata_further_fx( Word32 x, y, z; Word32 veclen, L_tmp; + W_tmp = 0; + move64(); FOR( band = 0; band < numCodingBands; band++ ) { xSum = 0; @@ -2528,9 +2530,14 @@ static void reduce_metadata_further_fx( ySum = L_add( ySum, y ); zSum = L_add( zSum, z ); - bandSumEnergy = L_add( bandSumEnergy, energy[sf][band] ); + W_tmp = W_add( W_tmp, energy[sf][band] ); } + tmp2 = W_norm( W_tmp ); + tmp2 = s_min( 32, tmp2 ); + bandSumEnergy = W_extract_h( W_shl( W_tmp, tmp2 ) ); + tmp2 = sub( add( hMasa->data.q_energy, tmp2 ), 32 ); + aziRad = BASOP_util_atan2( ySum, xSum, 0 ); // Q13 W_xSum_sq = W_mult0_32_32( xSum, xSum ); // 2 * hMasa->data.q_energy - Q6 W_ySum_sq = W_mult0_32_32( ySum, ySum ); // 2 * hMasa->data.q_energy - Q6 @@ -2558,6 +2565,7 @@ static void reduce_metadata_further_fx( } // hqmetadata->q_direction[0].coherence_band_data[band].spread_coherence[0] = (uint8_t) roundf( spreadCohSum / ( bandSumEnergy + EPSILON ) * 255.0f ); tmp = BASOP_Util_Divide3232_Scale( spreadCohSum, bandSumEnergy, &exp ); + exp = add( exp, sub( tmp2, hMasa->data.q_energy ) ); tmp = mult_r( tmp, 32640 /* 255 in Q7 */ ); // 15 - exp + 7 - 15 => 7 - exp hqmetadata->q_direction[0].coherence_band_data[band].spread_coherence[0] = (UWord8) shr( tmp, sub( 7, exp ) ); // Q0 move16(); -- GitLab