From 3d7f0a896db1552271379d40e002b19b57859022 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Fri, 17 Apr 2026 12:02:41 +0300 Subject: [PATCH] Fix BASOP issue 2545 by avoiding wrapping of MASA coherence parameters. --- lib_com/options.h | 1 + lib_enc/ivas_masa_enc_fx.c | 4 ++++ lib_util/masa_file_reader.c | 10 ++++++++++ 3 files changed, 15 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 499a45afc..3077f91f2 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -126,6 +126,7 @@ #define FIX_BASOP_2529_MASA_RATIO_SCALINGS /* Nokia: BASOP issue 2529: Fix MASA ratio scalings and verifications */ #define FIX_BASOP_2531_MCT_CP_BITRATE /* FhG: BASOP issue 2531: Fix MCT cp_bitrate calculation; affects bitrate switching only */ #define FIX_BASOP_2541_OMASA_ENC_FIXES /* Nokia: BASOP issue 2541: Fix function ivas_encode_masaism_metadata_fx */ +#define FIX_BASOP_2545_FIX_LTV_REGRESSION_2529 /* Nokia: BASOP issue 2545: Fix LTV regression caused by issue 2529 fix */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index 31eb3a3f6..4c5f7ba28 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -3160,7 +3160,11 @@ static void average_masa_metadata_fx( hMeta->directional_meta[i].spread_coherence_fx[j][k] = BASOP_Util_Divide3232_Scale( spread_coh_sum_fx, L_add( energy_sum_fx, EPSILON_FX ), &temp2_e ); move16(); temp2_e = add( temp2_e, sub( spread_coh_sum_e, energy_sum_e ) ); +#ifdef FIX_BASOP_2545_FIX_LTV_REGRESSION_2529 + hMeta->directional_meta[i].spread_coherence_fx[j][k] = shl_sat( hMeta->directional_meta[i].spread_coherence_fx[j][k], temp2_e ); /*changing q from 15-temp2_e to q15*/ +#else hMeta->directional_meta[i].spread_coherence_fx[j][k] = shl( hMeta->directional_meta[i].spread_coherence_fx[j][k], temp2_e ); /*changing q from 15-temp2_e to q15*/ +#endif move16(); IF( i == 0 ) { diff --git a/lib_util/masa_file_reader.c b/lib_util/masa_file_reader.c index 04ffdbfaa..b96e7fc98 100644 --- a/lib_util/masa_file_reader.c +++ b/lib_util/masa_file_reader.c @@ -210,7 +210,12 @@ ivas_error MasaFileReader_readNextFrame( for ( b = 0; b < MASA_FREQUENCY_BANDS; b++ ) { #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS +#ifdef FIX_BASOP_2545_FIX_LTV_REGRESSION_2529 + int32_t tmp_coh = ( (int32_t) readOther[b] * ONE_IN_Q15 + 254 ) / 255; + hMeta->directional_meta[i].spread_coherence_fx[j][b] = (Word16) ( tmp_coh > MAX_16 ? MAX_16 : tmp_coh ); // Q15, need to clamp +#else hMeta->directional_meta[i].spread_coherence_fx[j][b] = (Word16) ( ( (int32_t) readOther[b] * ONE_IN_Q15 + 254 ) / 255 ); // Q15 +#endif #else hMeta->directional_meta[i].spread_coherence_fx[j][b] = (Word16) ( readOther[b] * ONE_IN_Q7 ); // Q15 #endif @@ -242,7 +247,12 @@ ivas_error MasaFileReader_readNextFrame( for ( b = 0; b < MASA_FREQUENCY_BANDS; b++ ) { #ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS +#ifdef FIX_BASOP_2545_FIX_LTV_REGRESSION_2529 + int32_t tmp_coh = ( (int32_t) readOther[b] * ONE_IN_Q15 + 254 ) / 255; + hMeta->common_meta.surround_coherence_fx[j][b] = (Word16) ( tmp_coh > MAX_16 ? MAX_16 : tmp_coh ); // Q15, need to clamp +#else hMeta->common_meta.surround_coherence_fx[j][b] = (Word16) ( ( (int32_t) readOther[b] * ONE_IN_Q15 + 254 ) / 255 ); // Q15 +#endif #else hMeta->common_meta.surround_coherence_fx[j][b] = shl( (Word16) readOther[b], 7 ); // Q8->Q15 move16(); -- GitLab