From 422cc7d991e20fe74cd7d2f615566e492865afba Mon Sep 17 00:00:00 2001 From: malenov Date: Thu, 11 Apr 2024 10:07:41 +0200 Subject: [PATCH 1/2] fix div by zero at angle_rot calculation --- lib_com/options.h | 2 ++ lib_enc/ivas_stereo_dft_enc_itd.c | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 66bf87943c..6f0fa072d5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -173,6 +173,8 @@ #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 */ +#define NONBE_FIX_1063_DIV_BY_ZERO_SUMNRG /* VoiceAge: issue 1063: divsion by zero for angle_rot feature in the UNCLR classifier */ + /* ##################### End NON-BE switches ########################### */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_enc/ivas_stereo_dft_enc_itd.c b/lib_enc/ivas_stereo_dft_enc_itd.c index 988f3a473b..bc4bb6073b 100755 --- a/lib_enc/ivas_stereo_dft_enc_itd.c +++ b/lib_enc/ivas_stereo_dft_enc_itd.c @@ -640,8 +640,11 @@ void stereo_dft_enc_compute_itd( STEREO_CLASSIF_HANDLE hStereoClassif; const float *dft_trigo32k; float trigo_enc[STEREO_DFT_N_32k_ENC / 2 + 1]; - float cng_xcorr_filt; +#ifdef NONBE_FIX_1063_DIV_BY_ZERO_SUMNRG + float sum_nrg_delta; +#endif + int16_t prev_itd_max; int16_t itd_max_flip; @@ -727,7 +730,10 @@ void stereo_dft_enc_compute_itd( grand_dot_prod_real += xcorr[2 * i]; grand_dot_prod_img += xcorr[2 * i + 1]; xcorr_abs[i] = sqrtf( xcorr[2 * i] * xcorr[2 * i] + xcorr[2 * i + 1] * xcorr[2 * i + 1] ); + +#ifndef NONBE_FIX_1063_DIV_BY_ZERO_SUMNRG /* VM: prod_LL tends to overflow, better to replace with sum(log(prod_L)) and retrain the classifier */ +#endif prod_LL = prod_L; prod_RR = prod_R; @@ -784,7 +790,19 @@ void stereo_dft_enc_compute_itd( hStereoClassif->unclr_fv[E_gainIPD] = g_IPD; hStereoClassif->xtalk_fv[E_gainIPD] = g_IPD; +#ifdef NONBE_FIX_1063_DIV_BY_ZERO_SUMNRG + if ( sum_nrg_L >= sum_nrg_R ) + { + sum_nrg_delta = max( sum_nrg_L - sum_nrg_R, 1.0f ); + } + else + { + sum_nrg_delta = min( sum_nrg_L - sum_nrg_R, -1.0f ); + } + angle_rot = fabsf( atanf( 2.0f * ( grand_dot_prod_real ) / sum_nrg_delta ) ); +#else angle_rot = fabsf( atanf( 2.0f * ( grand_dot_prod_real ) / ( sum_nrg_L - sum_nrg_R + 1.0f ) ) ); +#endif hStereoClassif->unclr_fv[E_angle_rot] = angle_rot; hStereoClassif->xtalk_fv[E_angle_rot] = angle_rot; -- GitLab From 66b9e050472c4e5aaa7c2a7c2f8d66fd65a2474b Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 11 Apr 2024 14:45:14 +0200 Subject: [PATCH 2/2] formatting --- lib_com/options.h | 8 ++++---- lib_enc/ivas_stereo_dft_enc_itd.c | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 3a3f5747f5..fb7a4bebac 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -160,7 +160,8 @@ #define FIX_1038_OFFSET_TO_NULL_PTR_IN_EVS_TCX_BFI /* FhG: move setting of pointers for parameter decoding so they are skipped in lost frames when they are not needed */ #define FIX_1043_JBM_MD_BUFFER /* VA: issue 1043: JBM MD handle allocation is avoided in non-JBM EXT operations */ #define FIX_1044_ISM_REND_MEMORY /* VA: issue 1044: Lower the memory of the ISM renderer handle. */ - + + /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ @@ -170,11 +171,10 @@ #define NON_BE_1055_RESET_LP_MEMORIES /* VA: issue 1055: Correctly reset LP filter MA and AR memories in bitrate switching */ #define NONBE_FIX_1058_DECODER_ERROR_WITH_REVERB_ROOM /* FhG: issue 1058: do not initialize EFAP when IntSetup is HOA3 */ #define NONBE_FIX_1056_ISM_RATE_SWITCH /* FhG: Fix #1056: fix TC buffer udpate on a ISM rate switch */ - #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 */ +#define NONBE_FIX_1054_NEGATIVE_LVQ_INDEX /* Nokia: issue 1054: Input to decode_comb in deindex_lvq_SHB should be positive */ +#define NONBE_FIX_1063_DIV_BY_ZERO_SUMNRG /* VoiceAge: issue 1063: division by zero for angle_rot feature in the UNCLR classifier */ -#define NONBE_FIX_1063_DIV_BY_ZERO_SUMNRG /* VoiceAge: issue 1063: divsion by zero for angle_rot feature in the UNCLR classifier */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_enc/ivas_stereo_dft_enc_itd.c b/lib_enc/ivas_stereo_dft_enc_itd.c index bc4bb6073b..166db84c66 100755 --- a/lib_enc/ivas_stereo_dft_enc_itd.c +++ b/lib_enc/ivas_stereo_dft_enc_itd.c @@ -644,8 +644,6 @@ void stereo_dft_enc_compute_itd( #ifdef NONBE_FIX_1063_DIV_BY_ZERO_SUMNRG float sum_nrg_delta; #endif - - int16_t prev_itd_max; int16_t itd_max_flip; -- GitLab