From 2b3263450636a40998f621f8ed35fa040c2eeae7 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Thu, 15 Jan 2026 14:37:29 +0200 Subject: [PATCH] Fix float issue 1501 by adding a skip if number of two dir bands is zero. This matches the float code. --- lib_com/options.h | 1 + lib_enc/ivas_masa_enc_fx.c | 46 ++++++++++++++++++++++---------------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 4a272cf24..43b070174 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -124,6 +124,7 @@ #define REMOVE_UNUSED_CODE_IVAS_DEC /* VA: remove unused code in ivas_jbm_dec_tc_fx() */ #define FIX_2294_CLANG_18_WARNINGS_ENC /* VA: Fix some encoder clang-18 warnings, desc. in 2294 */ #define REMOVE_CAM_FROM_IVAS /* VA: basop issue 210: remove obsoelte CAM code from IVAS */ +#define FIX_FLOAT_1501_UNIT_VALUE_IN_OMASA /* Nokia: Fix float issue 1501, uninitialized value in ivas_masa_combine_directions for OMASA */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/ivas_masa_enc_fx.c b/lib_enc/ivas_masa_enc_fx.c index cb3b6e563..4d321702f 100644 --- a/lib_enc/ivas_masa_enc_fx.c +++ b/lib_enc/ivas_masa_enc_fx.c @@ -1800,33 +1800,41 @@ void ivas_masa_combine_directions_fx( } } - /* Estimate the importance of having two directions instead of one */ - /* Reduced precision of importance_fx intentionally to Q13 to maintatin 0.0001f resolution */ - FOR( i = 0; i < numCodingBands; i++ ) +#ifdef FIX_FLOAT_1501_UNIT_VALUE_IN_OMASA + IF( GT_16( hMasa->config.numTwoDirBands, 0 ) ) { - importance_fx[i] = 0; - move32(); - FOR( j = 0; j < numSf; j++ ) +#endif + /* Estimate the importance of having two directions instead of one */ + /* Reduced precision of importance_fx intentionally to Q13 to maintatin 0.0001f resolution */ + FOR( i = 0; i < numCodingBands; i++ ) { - tempImportance_fx = L_shr( L_add( hMeta->directional_meta[0].energy_ratio_fx[j][i], hMeta->directional_meta[1].energy_ratio_fx[j][i] ), Q30 - Q13 ); // Q13 - tempImportance_fx = L_sub( tempImportance_fx, L_shr( sumVecLen_fx[j][i], sub( sub( Q31, exp_sumVecLen ), Q13 ) ) ); // Q13 - importance_fx[i] = L_add( importance_fx[i], tempImportance_fx ); // Q13 + importance_fx[i] = 0; move32(); - } + FOR( j = 0; j < numSf; j++ ) + { + tempImportance_fx = L_shr( L_add( hMeta->directional_meta[0].energy_ratio_fx[j][i], hMeta->directional_meta[1].energy_ratio_fx[j][i] ), Q30 - Q13 ); // Q13 + tempImportance_fx = L_sub( tempImportance_fx, L_shr( sumVecLen_fx[j][i], sub( sub( Q31, exp_sumVecLen ), Q13 ) ) ); // Q13 + importance_fx[i] = L_add( importance_fx[i], tempImportance_fx ); // Q13 + move32(); + } - IF( NE_16( numSf, 1 ) ) - { - importance_fx[i] = L_shr( importance_fx[i], 2 ); // Q13 + IF( NE_16( numSf, 1 ) ) + { + importance_fx[i] = L_shr( importance_fx[i], 2 ); // Q13 + move32(); + } + importance_fx[i] = Mpy_32_32( importance_fx[i], hMasa->data.importanceWeight_fx[i] ); //(Q13, Q30) -> Q12 move32(); } - importance_fx[i] = Mpy_32_32( importance_fx[i], hMasa->data.importanceWeight_fx[i] ); //(Q13, Q30) -> Q12 - move32(); + exp_importance = Q31 - Q12; + move16(); + + /* Determine bands where to use two directions */ + find_n_largest_fx( importance_fx, exp_importance, indicesOfLargest, numCodingBands, hMasa->config.numTwoDirBands ); +#ifdef FIX_FLOAT_1501_UNIT_VALUE_IN_OMASA } - exp_importance = Q31 - Q12; - move16(); - /* Determine bands where to use two directions */ - find_n_largest_fx( importance_fx, exp_importance, indicesOfLargest, numCodingBands, hMasa->config.numTwoDirBands ); +#endif FOR( i = 0; i < numCodingBands; i++ ) { -- GitLab