diff --git a/lib_com/options.h b/lib_com/options.h index 02697835f1e0bd4a87c3a1d3e70cce051b431652..5488015ca76d6fc8993b29273484f0782d36f808 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -192,6 +192,7 @@ #define NONBE_FIX_1075 /* FhG: fix segfault for bitrate switching + BINAURAL_ROOM_REVERB output in MC */ #define NON_BE_FIX_1041_USE_OLD_CNG_LSPS_IF_NONSTAB /* FhG: fix bug in TD MDCT-Stereo concealment */ #define FIX_1044_ISM_REND_MEMORY /* VA: issue 1044: Lower the memory of the ISM renderer handle. */ +#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_984_OMASA_EXT_OUTPUT /* Nok: issue 1497 - porting OMASA EXT MR */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_enc/ivas_stereo_dft_enc_itd.c b/lib_enc/ivas_stereo_dft_enc_itd.c index 1c29ea716d4c2f398abb3cf5ba4e04150a368be1..980a465541ed46a8f843d606f6d6303dfd362f86 100644 --- a/lib_enc/ivas_stereo_dft_enc_itd.c +++ b/lib_enc/ivas_stereo_dft_enc_itd.c @@ -642,9 +642,10 @@ 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; @@ -729,10 +730,12 @@ 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 */ prod_LL = prod_L; prod_RR = prod_R; - +#endif if ( j == SFM_PROD_GRP || i == NFFT_mid - 1 ) { prod_L = max( FLT_MIN, prod_L ); @@ -786,7 +789,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;