From 2c60a6201ff5726d6e019e8b6fd6a542152cad59 Mon Sep 17 00:00:00 2001 From: rhb Date: Tue, 23 Aug 2022 16:13:38 +0200 Subject: [PATCH 1/2] fix bug where wrong number of bands is used in ITD estimator function calc_mean_E_ratio() if bandwidth is limited on commandline --- lib_com/options.h | 4 +++- lib_enc/ivas_stereo_dft_enc_itd.c | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) mode change 100644 => 100755 lib_com/options.h mode change 100644 => 100755 lib_enc/ivas_stereo_dft_enc_itd.c diff --git a/lib_com/options.h b/lib_com/options.h old mode 100644 new mode 100755 index 98d71f99c3..196b139bfb --- a/lib_com/options.h +++ b/lib_com/options.h @@ -147,7 +147,9 @@ /*#define FIX_I1_113*/ /* under review : MCT bit distribution optimization for SBA high bitrates*/ -#define LBR_SBA_CORE_CODING_TUNING /* Contribution "3 Core Coder Tuning for low bitrate SBA with 2 TCs" */ +#define LBR_SBA_CORE_CODING_TUNING /* Contribution "3 Core Coder Tuning for low bitrate SBA with 2 TCs" */ + +#define FIX_WRONG_NBANDS_IN_ITD_ESTIMATION /* Issue 85: fix incorrect setting of nbands in calc_mean_E_ratio() if bwidth is limited on commandline*/ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_enc/ivas_stereo_dft_enc_itd.c b/lib_enc/ivas_stereo_dft_enc_itd.c old mode 100644 new mode 100755 index 5b47e9dc52..68c117a8fd --- a/lib_enc/ivas_stereo_dft_enc_itd.c +++ b/lib_enc/ivas_stereo_dft_enc_itd.c @@ -467,7 +467,11 @@ static float calc_mean_E_ratio( grand_sum_xcorr_img = 0.0f; /*take bands up to 32kHz bandwidth as ITD is always calculated at 32kHz sampling rate*/ +#ifdef FIX_WRONG_NBANDS_IN_ITD_ESTIMATION + nbands -= ( band_limits[nbands] > STEREO_DFT_N_32k_ENC / 2 ); +#else nbands -= ( NFFT > STEREO_DFT_N_32k_ENC ); +#endif sum_Er = 0; for ( b = 0; b < nbands; b++ ) -- GitLab From 41a60d1ac50c40d55b7d976516ffde40bd0c1745 Mon Sep 17 00:00:00 2001 From: rhb Date: Thu, 25 Aug 2022 13:21:30 +0200 Subject: [PATCH 2/2] Fix compiler warning --- lib_enc/ivas_stereo_dft_enc_itd.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib_enc/ivas_stereo_dft_enc_itd.c b/lib_enc/ivas_stereo_dft_enc_itd.c index 68c117a8fd..fd39db32d3 100755 --- a/lib_enc/ivas_stereo_dft_enc_itd.c +++ b/lib_enc/ivas_stereo_dft_enc_itd.c @@ -446,7 +446,9 @@ static float calc_mean_E_ratio( ITD_DATA_HANDLE hItd, int16_t nbands, int16_t band_limits[], +#ifndef FIX_WRONG_NBANDS_IN_ITD_ESTIMATION const int16_t NFFT, +#endif const float sfm, const float nrg_L[STEREO_DFT_N_32k_ENC / 2], const float nrg_R[STEREO_DFT_N_32k_ENC / 2], @@ -1242,7 +1244,11 @@ void stereo_dft_enc_compute_itd( /*calculate mean E ratio of main to background signal for cohSNR*/ if ( hCPE->element_mode == IVAS_CPE_DFT ) { +#ifdef FIX_WRONG_NBANDS_IN_ITD_ESTIMATION + mEr = calc_mean_E_ratio( hItd, hStereoDft->nbands, hStereoDft->band_limits, sfm_L, pNrgL, pNrgR, &total_mEr ); +#else mEr = calc_mean_E_ratio( hItd, hStereoDft->nbands, hStereoDft->band_limits, hStereoDft->NFFT, sfm_L, pNrgL, pNrgR, &total_mEr ); +#endif } else { @@ -1251,7 +1257,11 @@ void stereo_dft_enc_compute_itd( set_s( band_limits, 0, STEREO_DFT_BAND_MAX + 1 ); set_band_limits( &nbands, band_limits, hCPE->hStereoMdct->hDft_ana->NFFT ); +#ifdef FIX_WRONG_NBANDS_IN_ITD_ESTIMATION + mEr = calc_mean_E_ratio( hItd, nbands, band_limits, sfm_L, pNrgL, pNrgR, &total_mEr ); +#else mEr = calc_mean_E_ratio( hItd, nbands, band_limits, hCPE->hStereoMdct->hDft_ana->NFFT, sfm_L, pNrgL, pNrgR, &total_mEr ); +#endif } /*calculate total cohSNR for frame in dB*/ -- GitLab