From b895f54260de02aeb6b81a58d2ef3097d59b7777 Mon Sep 17 00:00:00 2001 From: rhb Date: Fri, 10 Nov 2023 15:51:23 +0100 Subject: [PATCH 1/3] change double functions to float counterparts in DFT stereo --- lib_com/options.h | 1 + lib_dec/ivas_stereo_dft_dec.c | 8 ++++++++ lib_enc/ivas_stereo_dft_enc.c | 12 ++++++++++++ lib_enc/ivas_stereo_dft_enc_itd.c | 4 ++++ lib_enc/ivas_stereo_dft_td_itd.c | 4 ++++ 5 files changed, 29 insertions(+) mode change 100644 => 100755 lib_com/options.h mode change 100644 => 100755 lib_dec/ivas_stereo_dft_dec.c mode change 100644 => 100755 lib_enc/ivas_stereo_dft_enc.c mode change 100644 => 100755 lib_enc/ivas_stereo_dft_enc_itd.c mode change 100644 => 100755 lib_enc/ivas_stereo_dft_td_itd.c diff --git a/lib_com/options.h b/lib_com/options.h old mode 100644 new mode 100755 index f44ad78c49..c7e7929207 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -151,6 +151,7 @@ /*#define SPLIT_REND_WITH_HEAD_ROT */ /* Dlb,FhG: Split Rendering contributions 21 and 35 */ #define FIX_643_PCA_OPTION /* VA: issue 643: rename PCA bypass command-line option */ +#define FIX_811_DFT_DOUBLE_TO_FLOAT /* FhG: issue 811: change double precision functions to float in DFT Stereo */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c old mode 100644 new mode 100755 index 5c515aeb2a..d5f27cdb66 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -135,10 +135,18 @@ static void stereo_dft_dequantize_res_gains_f( /* compensate for the offset and extract/remove sign of first index */ sign = ind1[i] < 15 ? -1 : 1; +#ifdef FIX_811_DFT_DOUBLE_TO_FLOAT + i1 = (int16_t) floorf( ind1[i] < 15 ? 15 - ind1[i] : ind1[i] - 15 ); +#else i1 = (int16_t) floor( ind1[i] < 15 ? 15 - ind1[i] : ind1[i] - 15 ); +#endif fi = ( ind1[i] < 15 ? 15 - ind1[i] : ind1[i] - 15 ) - i1; +#ifdef FIX_811_DFT_DOUBLE_TO_FLOAT + j1 = (int16_t) floorf( ind2[i] ); +#else j1 = (int16_t) floor( ind2[i] ); +#endif fj = ind2[i] - j1; /* choose base indices for interpolation */ diff --git a/lib_enc/ivas_stereo_dft_enc.c b/lib_enc/ivas_stereo_dft_enc.c old mode 100644 new mode 100755 index 68164363be..35c28d42be --- a/lib_enc/ivas_stereo_dft_enc.c +++ b/lib_enc/ivas_stereo_dft_enc.c @@ -2695,7 +2695,11 @@ static void stereo_dft_enc_compute_prm( { hStereoDft->dot_prod_real_smooth[b2] = 0.5f * hStereoDft->dot_prod_real_smooth[b2] + 0.5f * dot_prod_real2; hStereoDft->dot_prod_img_smooth[b2] = 0.5f * hStereoDft->dot_prod_img_smooth[b2] + 0.5f * dot_prod_img2; +#ifdef FIX_811_DFT_DOUBLE_TO_FLOAT + pIpd[b2] = (float) atan2f( hStereoDft->dot_prod_img_smooth[b2], hStereoDft->dot_prod_real_smooth[b2] ); +#else pIpd[b2] = (float) atan2( hStereoDft->dot_prod_img_smooth[b2], hStereoDft->dot_prod_real_smooth[b2] ); +#endif ipd_smooth[b2] = stereo_dft_calc_mean_bipd( &pIpd[b2], hStereoDft->ipd_buf[b2] ); @@ -2825,7 +2829,11 @@ static void stereo_dft_enc_compute_prm( { conversion_factor = 2.f / 3; } +#ifdef FIX_811_DFT_DOUBLE_TO_FLOAT + dItd32 = (int16_t) floorf( conversion_factor * hStereoDft->hItd->deltaItd[k_offset] + 0.5f ); +#else dItd32 = (int16_t) floor( conversion_factor * hStereoDft->hItd->deltaItd[k_offset] + 0.5f ); +#endif gain_offset = stereo_dft_gain_offset( c, dItd32 ); pPredGain[b] = max( 0, pPredGain[b] - gain_offset ); @@ -2861,7 +2869,11 @@ static void stereo_dft_enc_compute_prm( hStereoDft->sum_dot_prod_real = ( 1.f - hStereoDft->sfm ) * hStereoDft->sum_dot_prod_real + hStereoDft->sfm * sum_dot_prod_real; hStereoDft->sum_dot_prod_img = ( 1.f - hStereoDft->sfm ) * hStereoDft->sum_dot_prod_img + hStereoDft->sfm * sum_dot_prod_img; +#ifdef FIX_811_DFT_DOUBLE_TO_FLOAT + pgIpd[0] = (float) atan2f( hStereoDft->sum_dot_prod_img, hStereoDft->sum_dot_prod_real ); +#else pgIpd[0] = (float) atan2( hStereoDft->sum_dot_prod_img, hStereoDft->sum_dot_prod_real ); +#endif stereo_dft_gipd_stabilization( &pgIpd[0], hStereoDft->prev_gipd, ipd_mean_change ); hStereoDft->prev_gipd = pgIpd[0]; 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 984c128e85..51cf01e829 --- a/lib_enc/ivas_stereo_dft_enc_itd.c +++ b/lib_enc/ivas_stereo_dft_enc_itd.c @@ -1368,7 +1368,11 @@ void stereo_dft_enc_compute_itd( if ( hItd->deltaItd[k_offset - 1] != 0 && itd_max_flip == 0 ) { +#ifdef FIX_811_DFT_DOUBLE_TO_FLOAT + int16_t tmp_itd = (int16_t) floorf( ( ( hItd->prev_itd ) * ( (float) input_frame / 640 ) ) + 0.5f ); +#else int16_t tmp_itd = (int16_t) floor( ( ( hItd->prev_itd ) * ( (float) input_frame / 640 ) ) + 0.5f ); +#endif hItd->deltaItd[k_offset] = -1.0f * tmp_itd - hItd->td_itd[k_offset]; } } diff --git a/lib_enc/ivas_stereo_dft_td_itd.c b/lib_enc/ivas_stereo_dft_td_itd.c old mode 100644 new mode 100755 index 9fbe5e273a..5813e0bdca --- a/lib_enc/ivas_stereo_dft_td_itd.c +++ b/lib_enc/ivas_stereo_dft_td_itd.c @@ -83,7 +83,11 @@ static void stereo_td_get_td_itd( { assert( ( input_Fs % 16000 ) == 0 && "sampling frequency should be divisible by 16000" ); d = (int16_t) ( input_Fs / 16000 ); +#ifdef FIX_811_DFT_DOUBLE_TO_FLOAT + *td_itd_32 = 2 * (int16_t) floorf( itd / d + 0.5f ); +#else *td_itd_32 = 2 * (int16_t) floor( itd / d + 0.5f ); +#endif *td_itd = ( ( *td_itd_32 ) / 2 ) * d; } -- GitLab From 66b08db954dbd37c530fe11431ce188ea3b9dded Mon Sep 17 00:00:00 2001 From: rhb Date: Fri, 10 Nov 2023 15:55:20 +0100 Subject: [PATCH 2/3] clang format --- lib_dec/ivas_stereo_dft_dec.c | 4 ++-- lib_enc/ivas_stereo_dft_enc.c | 6 +++--- lib_enc/ivas_stereo_dft_enc_itd.c | 2 +- lib_enc/ivas_stereo_dft_td_itd.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) mode change 100755 => 100644 lib_dec/ivas_stereo_dft_dec.c mode change 100755 => 100644 lib_enc/ivas_stereo_dft_enc.c mode change 100755 => 100644 lib_enc/ivas_stereo_dft_enc_itd.c mode change 100755 => 100644 lib_enc/ivas_stereo_dft_td_itd.c diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c old mode 100755 new mode 100644 index d5f27cdb66..8531b6dedc --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -135,14 +135,14 @@ static void stereo_dft_dequantize_res_gains_f( /* compensate for the offset and extract/remove sign of first index */ sign = ind1[i] < 15 ? -1 : 1; -#ifdef FIX_811_DFT_DOUBLE_TO_FLOAT +#ifdef FIX_811_DFT_DOUBLE_TO_FLOAT i1 = (int16_t) floorf( ind1[i] < 15 ? 15 - ind1[i] : ind1[i] - 15 ); #else i1 = (int16_t) floor( ind1[i] < 15 ? 15 - ind1[i] : ind1[i] - 15 ); #endif fi = ( ind1[i] < 15 ? 15 - ind1[i] : ind1[i] - 15 ) - i1; -#ifdef FIX_811_DFT_DOUBLE_TO_FLOAT +#ifdef FIX_811_DFT_DOUBLE_TO_FLOAT j1 = (int16_t) floorf( ind2[i] ); #else j1 = (int16_t) floor( ind2[i] ); diff --git a/lib_enc/ivas_stereo_dft_enc.c b/lib_enc/ivas_stereo_dft_enc.c old mode 100755 new mode 100644 index 35c28d42be..cfc209863f --- a/lib_enc/ivas_stereo_dft_enc.c +++ b/lib_enc/ivas_stereo_dft_enc.c @@ -2695,7 +2695,7 @@ static void stereo_dft_enc_compute_prm( { hStereoDft->dot_prod_real_smooth[b2] = 0.5f * hStereoDft->dot_prod_real_smooth[b2] + 0.5f * dot_prod_real2; hStereoDft->dot_prod_img_smooth[b2] = 0.5f * hStereoDft->dot_prod_img_smooth[b2] + 0.5f * dot_prod_img2; -#ifdef FIX_811_DFT_DOUBLE_TO_FLOAT +#ifdef FIX_811_DFT_DOUBLE_TO_FLOAT pIpd[b2] = (float) atan2f( hStereoDft->dot_prod_img_smooth[b2], hStereoDft->dot_prod_real_smooth[b2] ); #else pIpd[b2] = (float) atan2( hStereoDft->dot_prod_img_smooth[b2], hStereoDft->dot_prod_real_smooth[b2] ); @@ -2829,7 +2829,7 @@ static void stereo_dft_enc_compute_prm( { conversion_factor = 2.f / 3; } -#ifdef FIX_811_DFT_DOUBLE_TO_FLOAT +#ifdef FIX_811_DFT_DOUBLE_TO_FLOAT dItd32 = (int16_t) floorf( conversion_factor * hStereoDft->hItd->deltaItd[k_offset] + 0.5f ); #else dItd32 = (int16_t) floor( conversion_factor * hStereoDft->hItd->deltaItd[k_offset] + 0.5f ); @@ -2869,7 +2869,7 @@ static void stereo_dft_enc_compute_prm( hStereoDft->sum_dot_prod_real = ( 1.f - hStereoDft->sfm ) * hStereoDft->sum_dot_prod_real + hStereoDft->sfm * sum_dot_prod_real; hStereoDft->sum_dot_prod_img = ( 1.f - hStereoDft->sfm ) * hStereoDft->sum_dot_prod_img + hStereoDft->sfm * sum_dot_prod_img; -#ifdef FIX_811_DFT_DOUBLE_TO_FLOAT +#ifdef FIX_811_DFT_DOUBLE_TO_FLOAT pgIpd[0] = (float) atan2f( hStereoDft->sum_dot_prod_img, hStereoDft->sum_dot_prod_real ); #else pgIpd[0] = (float) atan2( hStereoDft->sum_dot_prod_img, hStereoDft->sum_dot_prod_real ); diff --git a/lib_enc/ivas_stereo_dft_enc_itd.c b/lib_enc/ivas_stereo_dft_enc_itd.c old mode 100755 new mode 100644 index 51cf01e829..68ee128cd8 --- a/lib_enc/ivas_stereo_dft_enc_itd.c +++ b/lib_enc/ivas_stereo_dft_enc_itd.c @@ -1368,7 +1368,7 @@ void stereo_dft_enc_compute_itd( if ( hItd->deltaItd[k_offset - 1] != 0 && itd_max_flip == 0 ) { -#ifdef FIX_811_DFT_DOUBLE_TO_FLOAT +#ifdef FIX_811_DFT_DOUBLE_TO_FLOAT int16_t tmp_itd = (int16_t) floorf( ( ( hItd->prev_itd ) * ( (float) input_frame / 640 ) ) + 0.5f ); #else int16_t tmp_itd = (int16_t) floor( ( ( hItd->prev_itd ) * ( (float) input_frame / 640 ) ) + 0.5f ); diff --git a/lib_enc/ivas_stereo_dft_td_itd.c b/lib_enc/ivas_stereo_dft_td_itd.c old mode 100755 new mode 100644 index 5813e0bdca..5169c9e897 --- a/lib_enc/ivas_stereo_dft_td_itd.c +++ b/lib_enc/ivas_stereo_dft_td_itd.c @@ -83,7 +83,7 @@ static void stereo_td_get_td_itd( { assert( ( input_Fs % 16000 ) == 0 && "sampling frequency should be divisible by 16000" ); d = (int16_t) ( input_Fs / 16000 ); -#ifdef FIX_811_DFT_DOUBLE_TO_FLOAT +#ifdef FIX_811_DFT_DOUBLE_TO_FLOAT *td_itd_32 = 2 * (int16_t) floorf( itd / d + 0.5f ); #else *td_itd_32 = 2 * (int16_t) floor( itd / d + 0.5f ); -- GitLab From 81d71c1623725e9457773582e71eb0bd233dcfa2 Mon Sep 17 00:00:00 2001 From: rhb Date: Tue, 14 Nov 2023 10:29:09 +0100 Subject: [PATCH 3/3] move and rename switch to account for potential non-BE --- lib_com/options.h | 2 +- lib_dec/ivas_stereo_dft_dec.c | 4 ++-- lib_enc/ivas_stereo_dft_enc.c | 6 +++--- lib_enc/ivas_stereo_dft_enc_itd.c | 2 +- lib_enc/ivas_stereo_dft_td_itd.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) mode change 100644 => 100755 lib_dec/ivas_stereo_dft_dec.c mode change 100644 => 100755 lib_enc/ivas_stereo_dft_enc.c mode change 100644 => 100755 lib_enc/ivas_stereo_dft_enc_itd.c mode change 100644 => 100755 lib_enc/ivas_stereo_dft_td_itd.c diff --git a/lib_com/options.h b/lib_com/options.h index c7e7929207..ad82a84b71 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -151,7 +151,6 @@ /*#define SPLIT_REND_WITH_HEAD_ROT */ /* Dlb,FhG: Split Rendering contributions 21 and 35 */ #define FIX_643_PCA_OPTION /* VA: issue 643: rename PCA bypass command-line option */ -#define FIX_811_DFT_DOUBLE_TO_FLOAT /* FhG: issue 811: change double precision functions to float in DFT Stereo */ /* #################### End BE switches ################################## */ @@ -166,6 +165,7 @@ #define NONBE_FIX_871_ACELP_CRASH_IN_OSBA /* FhG: isse 871: crash in ACELP core encoder with OSBA */ #define NONBE_FIX_225_MASA_EXT_REND /* Nokia: Resolve #225: Complete MASA external renderer implementation */ #define NONBE_FIX_897_USAN_WITH_MASA_RENDERING /* Nokia: issue #897: USAN null pointer in MASA external renderer to Ambisonics */ +#define NONBE_FIX_811_DFT_DOUBLE_TO_FLOAT /* FhG: issue 811: change double precision functions to float in DFT Stereo */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c old mode 100644 new mode 100755 index 8531b6dedc..ad18db7778 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -135,14 +135,14 @@ static void stereo_dft_dequantize_res_gains_f( /* compensate for the offset and extract/remove sign of first index */ sign = ind1[i] < 15 ? -1 : 1; -#ifdef FIX_811_DFT_DOUBLE_TO_FLOAT +#ifdef NONBE_FIX_811_DFT_DOUBLE_TO_FLOAT i1 = (int16_t) floorf( ind1[i] < 15 ? 15 - ind1[i] : ind1[i] - 15 ); #else i1 = (int16_t) floor( ind1[i] < 15 ? 15 - ind1[i] : ind1[i] - 15 ); #endif fi = ( ind1[i] < 15 ? 15 - ind1[i] : ind1[i] - 15 ) - i1; -#ifdef FIX_811_DFT_DOUBLE_TO_FLOAT +#ifdef NONBE_FIX_811_DFT_DOUBLE_TO_FLOAT j1 = (int16_t) floorf( ind2[i] ); #else j1 = (int16_t) floor( ind2[i] ); diff --git a/lib_enc/ivas_stereo_dft_enc.c b/lib_enc/ivas_stereo_dft_enc.c old mode 100644 new mode 100755 index cfc209863f..e2b21bf61c --- a/lib_enc/ivas_stereo_dft_enc.c +++ b/lib_enc/ivas_stereo_dft_enc.c @@ -2695,7 +2695,7 @@ static void stereo_dft_enc_compute_prm( { hStereoDft->dot_prod_real_smooth[b2] = 0.5f * hStereoDft->dot_prod_real_smooth[b2] + 0.5f * dot_prod_real2; hStereoDft->dot_prod_img_smooth[b2] = 0.5f * hStereoDft->dot_prod_img_smooth[b2] + 0.5f * dot_prod_img2; -#ifdef FIX_811_DFT_DOUBLE_TO_FLOAT +#ifdef NONBE_FIX_811_DFT_DOUBLE_TO_FLOAT pIpd[b2] = (float) atan2f( hStereoDft->dot_prod_img_smooth[b2], hStereoDft->dot_prod_real_smooth[b2] ); #else pIpd[b2] = (float) atan2( hStereoDft->dot_prod_img_smooth[b2], hStereoDft->dot_prod_real_smooth[b2] ); @@ -2829,7 +2829,7 @@ static void stereo_dft_enc_compute_prm( { conversion_factor = 2.f / 3; } -#ifdef FIX_811_DFT_DOUBLE_TO_FLOAT +#ifdef NONBE_FIX_811_DFT_DOUBLE_TO_FLOAT dItd32 = (int16_t) floorf( conversion_factor * hStereoDft->hItd->deltaItd[k_offset] + 0.5f ); #else dItd32 = (int16_t) floor( conversion_factor * hStereoDft->hItd->deltaItd[k_offset] + 0.5f ); @@ -2869,7 +2869,7 @@ static void stereo_dft_enc_compute_prm( hStereoDft->sum_dot_prod_real = ( 1.f - hStereoDft->sfm ) * hStereoDft->sum_dot_prod_real + hStereoDft->sfm * sum_dot_prod_real; hStereoDft->sum_dot_prod_img = ( 1.f - hStereoDft->sfm ) * hStereoDft->sum_dot_prod_img + hStereoDft->sfm * sum_dot_prod_img; -#ifdef FIX_811_DFT_DOUBLE_TO_FLOAT +#ifdef NONBE_FIX_811_DFT_DOUBLE_TO_FLOAT pgIpd[0] = (float) atan2f( hStereoDft->sum_dot_prod_img, hStereoDft->sum_dot_prod_real ); #else pgIpd[0] = (float) atan2( hStereoDft->sum_dot_prod_img, hStereoDft->sum_dot_prod_real ); 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 68ee128cd8..8852a8425b --- a/lib_enc/ivas_stereo_dft_enc_itd.c +++ b/lib_enc/ivas_stereo_dft_enc_itd.c @@ -1368,7 +1368,7 @@ void stereo_dft_enc_compute_itd( if ( hItd->deltaItd[k_offset - 1] != 0 && itd_max_flip == 0 ) { -#ifdef FIX_811_DFT_DOUBLE_TO_FLOAT +#ifdef NONBE_FIX_811_DFT_DOUBLE_TO_FLOAT int16_t tmp_itd = (int16_t) floorf( ( ( hItd->prev_itd ) * ( (float) input_frame / 640 ) ) + 0.5f ); #else int16_t tmp_itd = (int16_t) floor( ( ( hItd->prev_itd ) * ( (float) input_frame / 640 ) ) + 0.5f ); diff --git a/lib_enc/ivas_stereo_dft_td_itd.c b/lib_enc/ivas_stereo_dft_td_itd.c old mode 100644 new mode 100755 index 5169c9e897..7f724685dd --- a/lib_enc/ivas_stereo_dft_td_itd.c +++ b/lib_enc/ivas_stereo_dft_td_itd.c @@ -83,7 +83,7 @@ static void stereo_td_get_td_itd( { assert( ( input_Fs % 16000 ) == 0 && "sampling frequency should be divisible by 16000" ); d = (int16_t) ( input_Fs / 16000 ); -#ifdef FIX_811_DFT_DOUBLE_TO_FLOAT +#ifdef NONBE_FIX_811_DFT_DOUBLE_TO_FLOAT *td_itd_32 = 2 * (int16_t) floorf( itd / d + 0.5f ); #else *td_itd_32 = 2 * (int16_t) floor( itd / d + 0.5f ); -- GitLab