diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index 543897b8542fc9365bc5a48b127ea9427ef03c4d..625bc837b0dca2f42ac4fc5b39d0ccef9e756bd6 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();