diff --git a/lib_com/options.h b/lib_com/options.h index d39d42e2570132a701c992396cd559064b895806..3e977819fa2bac943032f1c771eff506f77700dd 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -93,6 +93,7 @@ #define FIX_1372_ISAR_POST_REND #endif #define NONBE_FIX_1058_DECODER_ERROR_WITH_REVERB_ROOM /* FhG: issue 1058: do not initialize EFAP when IntSetup is HOA3 */ +#define FIX_963_USAN_ERROR /* Eri: Issue 963: USAN error in Stereo CNG, division by zero */ #define NONBE_FIX_952_MC_PARAMUPMIX_5MS /* Dlb : issue 952 : Differences between 5ms and 20ms rendering for ParamUpmix*/ #define NONBE_FIX_935_EARLY_REFLECTIONS_WRONG_ORDER /* Qualcomm: issue 953: fix order or ER channels in LC mode*/ #define FIX_955_FASTCONV_REND_IN_ISM /* VA: put FastConv rendering call under DEBUGGING */ diff --git a/lib_enc/ivas_stereo_dft_enc_itd_fx.c b/lib_enc/ivas_stereo_dft_enc_itd_fx.c index b7429e2e796656a838a89b3a0f99a4f7b2a28175..fabc35985b78a623c8bd34b226086e5e8303093b 100644 --- a/lib_enc/ivas_stereo_dft_enc_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_enc_itd_fx.c @@ -1662,11 +1662,24 @@ void stereo_dft_enc_compute_itd_fx( move16(); } // cng_xcorr_filt = max( min( CORR_FILT, 10.0f * CORR_FILT / ( hStereoDft->expectedNumUpdates + hStereoDft->currentNumUpdates ) ), sfm_L ); - +#ifdef FIX_963_USAN_ERROR + IF( add( hStereoDft->expectedNumUpdates, hStereoDft->currentNumUpdates ) == 0 ) + { + cng_xcorr_filt = CORR_FILT_Q31; + move32(); + cng_xcorr_filt = L_max( cng_xcorr_filt, sfm_L ); // Q31 + } + ELSE + { + cng_xcorr_filt = BASOP_Util_Divide3232_Scale_cadence( 8 /*10.0f * CORR_FILT*/, add( hStereoDft->expectedNumUpdates, hStereoDft->currentNumUpdates ), &cng_xcorr_filt_e ); + cng_xcorr_filt = L_shl_sat( cng_xcorr_filt, cng_xcorr_filt_e ); // Q31 + cng_xcorr_filt = L_max( L_min( CORR_FILT_Q31, cng_xcorr_filt ), sfm_L ); // Q31 + } +#else cng_xcorr_filt = BASOP_Util_Divide3232_Scale_cadence( 8 /*10.0f * CORR_FILT*/, add( hStereoDft->expectedNumUpdates, hStereoDft->currentNumUpdates ), &cng_xcorr_filt_e ); cng_xcorr_filt = L_shl_sat( cng_xcorr_filt, cng_xcorr_filt_e ); // Q31 cng_xcorr_filt = L_max( L_min( CORR_FILT_Q31, cng_xcorr_filt ), sfm_L ); // Q31 - +#endif hStereoDft->currentNumUpdates = add( hStereoDft->currentNumUpdates, 1 ); move16(); FOR( i = 1; i < NFFT / 4; i++ ) @@ -1722,6 +1735,20 @@ void stereo_dft_enc_compute_itd_fx( { /* expectedNumUpdates updated after call to dtx() in SID frames */ // cng_xcorr_filt = max( min( CORR_FILT, 10.0f * CORR_FILT / ( hStereoDft->expectedNumUpdates + hStereoDft->currentNumUpdates ) ), sfm_L ); +#ifdef FIX_963_USAN_ERROR + IF( add( hStereoDft->expectedNumUpdates, hStereoDft->currentNumUpdates ) == 0 ) + { + cng_xcorr_filt = CORR_FILT_Q31; + move32(); + cng_xcorr_filt = L_max( cng_xcorr_filt, sfm_L ); // Q31 + } + ELSE + { + cng_xcorr_filt = BASOP_Util_Divide3232_Scale_cadence( 8 /*10.0f * CORR_FILT*/, add( hStereoDft->expectedNumUpdates, hStereoDft->currentNumUpdates ), &cng_xcorr_filt_e ); + cng_xcorr_filt = L_shl_sat( cng_xcorr_filt, cng_xcorr_filt_e ); // Q31 + cng_xcorr_filt = L_max( L_min( CORR_FILT_Q31, cng_xcorr_filt ), sfm_L ); // Q31 + } +#else IF( add( hStereoDft->expectedNumUpdates, hStereoDft->currentNumUpdates ) != 0 ) { cng_xcorr_filt = BASOP_Util_Divide3232_Scale_cadence( 8 /*10.0f * CORR_FILT*/, add( hStereoDft->expectedNumUpdates, hStereoDft->currentNumUpdates ), &cng_xcorr_filt_e ); @@ -1734,6 +1761,7 @@ void stereo_dft_enc_compute_itd_fx( move32(); cng_xcorr_filt = L_max( cng_xcorr_filt, sfm_L ); // Q31 } +#endif hStereoDft->currentNumUpdates = add( hStereoDft->currentNumUpdates, 1 ); move16(); hStereoDft->sfm_fx = cng_xcorr_filt;