From 04c538585401f9d3c317e04d03331c599538e9a1 Mon Sep 17 00:00:00 2001 From: Adriana Vasilache Date: Thu, 11 Apr 2024 21:43:01 +0300 Subject: [PATCH] MASA coherence and deindex_lead fixes to align with BASOP --- lib_com/ivas_cnst.h | 4 ++++ lib_com/mslvq_com.c | 4 ++++ lib_com/options.h | 6 ++++++ lib_dec/ivas_qmetadata_dec.c | 8 +++++++- lib_enc/ivas_qmetadata_enc.c | 9 +++++++-- 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 6a50483e5..048cf6d48 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1178,6 +1178,10 @@ enum #define MASA_RATIO_TOLERANCE 0.1f #define MASA_RATIO_THRESHOLD 0.1f #define MASA_ANGLE_TOLERANCE 0.5f +#ifdef NON_BE_FIX_1048_THRESHOLD_COH_BASOP +#define MASA_SUR_COH_THRESHOLD 1e-7f +#define MASA_SUR_COH_PRECISION 1e7f +#endif #define MASA_LIMIT_NO_BANDS_SUR_COH 8 #define MINIMUM_BIT_BUDGET_NORMAL_META 100 #define DIFF_DFRATIO_2BIT_LIMIT_IDX_HODIRAC 4 diff --git a/lib_com/mslvq_com.c b/lib_com/mslvq_com.c index 48384794a..840866222 100644 --- a/lib_com/mslvq_com.c +++ b/lib_com/mslvq_com.c @@ -828,7 +828,11 @@ void deindex_lvq_SHB( /* find idx_leader */ i = 1; +#ifdef NONBE_FIX_1054_NEGATIVE_LVQ_INDEX + while ( index > table_no_cv[i] ) +#else while ( index >= table_no_cv[i] ) +#endif { i++; } diff --git a/lib_com/options.h b/lib_com/options.h index b70e22adf..75df7af93 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -56,6 +56,12 @@ /* #################### End DEBUGGING switches ############################ */ +/* ################### Start FIXES switches ########################### */ + +#define NON_BE_FIX_1048_THRESHOLD_COH_BASOP /* Nokia: Fix 1048 replace comparison with 0 with comparison to threshold, to align with BASOP*/ +#define NONBE_FIX_1054_NEGATIVE_LVQ_INDEX /* Nokia: issue 1054: Input to decode_comb in deindex_lvq_SHB should be positive */ + +/* #################### End FIXES switches ############################ */ #define BASOP_NOGLOB /* Disable global symbols in BASOPs, Overflow/Carry in BASOPs disabled, additional BASOPs in case of Overflow */ diff --git a/lib_dec/ivas_qmetadata_dec.c b/lib_dec/ivas_qmetadata_dec.c index 011a16d81..afbb98f0d 100644 --- a/lib_dec/ivas_qmetadata_dec.c +++ b/lib_dec/ivas_qmetadata_dec.c @@ -3829,6 +3829,9 @@ static int16_t read_surround_coherence_hr( IVAS_QDIRECTION *q_direction; int16_t min_index; int16_t d, idx; +#ifdef NON_BE_FIX_1048_THRESHOLD_COH_BASOP + int32_t int_error_ratio_surr; +#endif coding_subbands = hQMetaData->q_direction[0].cfg.nbands; q_direction = hQMetaData->q_direction; @@ -3851,7 +3854,10 @@ static int16_t read_surround_coherence_hr( { error_ratio_surr = 1.0f - q_direction[0].band_data[j].energy_ratio[sf]; } - +#ifdef NON_BE_FIX_1048_THRESHOLD_COH_BASOP + int_error_ratio_surr = (int32_t) ( MASA_SUR_COH_PRECISION * error_ratio_surr ); + error_ratio_surr = (float) ( int_error_ratio_surr * MASA_SUR_COH_THRESHOLD ); +#endif if ( error_ratio_surr <= 0 ) { error_ratio_surr = 0; diff --git a/lib_enc/ivas_qmetadata_enc.c b/lib_enc/ivas_qmetadata_enc.c index adf728547..e3316c9ca 100644 --- a/lib_enc/ivas_qmetadata_enc.c +++ b/lib_enc/ivas_qmetadata_enc.c @@ -4508,7 +4508,9 @@ static int16_t encode_surround_coherence_hr( int16_t max_val = 0, nbits_max; int16_t no_cv_shift[MASA_MAXIMUM_CODING_SUBBANDS], min_idx; int16_t idx16; - +#ifdef NON_BE_FIX_1048_THRESHOLD_COH_BASOP + int32_t int_error_ratio_surr; +#endif coding_subbands = hQMetaData->q_direction[0].cfg.nbands; all_coherence_zero = hQMetaData->all_coherence_zero; q_direction = &( hQMetaData->q_direction[0] ); @@ -4537,7 +4539,10 @@ static int16_t encode_surround_coherence_hr( { error_ratio_surr = 1.0f - q_direction[0].band_data[j].energy_ratio[sf]; } - +#ifdef NON_BE_FIX_1048_THRESHOLD_COH_BASOP + int_error_ratio_surr = (int32_t) ( MASA_SUR_COH_PRECISION * error_ratio_surr ); + error_ratio_surr = (float) ( int_error_ratio_surr * MASA_SUR_COH_THRESHOLD ); +#endif if ( error_ratio_surr <= 0 ) { -- GitLab