From defe9447f182f044386b7bfea9ef068298b4ae4c Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sat, 4 Oct 2025 19:37:45 +0200 Subject: [PATCH 1/3] port float MR 1861 --- lib_com/options.h | 1 + lib_enc/ivas_stereo_dft_td_itd_fx.c | 17 +++++++++++++++++ lib_enc/ivas_stereo_switching_enc_fx.c | 5 ++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index fdf73590a..c55b14089 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -137,6 +137,7 @@ #define FIX_1053_REVERB_RECONFIGURATION #define TMP_FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add error check for unsupported config: split rendering with VoIP mode */ #define FIX_1113_EXTREND_ISAR /* FhG: issue 1113: fix external renderer asserts for FOA/HOA2 and CLDFB config */ +#define NONBE_1203_MDCT2DFT_SWITCHING /* VA: issue 1203: fix severe artifacts during MDCT to DFT stereo switching when MDCT ITD is not used */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_enc/ivas_stereo_dft_td_itd_fx.c b/lib_enc/ivas_stereo_dft_td_itd_fx.c index a0d49176f..2ac886d08 100644 --- a/lib_enc/ivas_stereo_dft_td_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_td_itd_fx.c @@ -573,6 +573,9 @@ void stereo_td_itd_mdct_stereo_fx( Word16 DFT_e[CPE_CHANNELS]; Word16 DFT_tmp_e[CPE_CHANNELS][STEREO_DFT_N_MAX_ENC]; STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct; +#ifdef NONBE_1203_MDCT2DFT_SWITCHING + Word16 dft_ovl; +#endif test(); IF( hCPE->hStereoMdct != NULL && hCPE->hStereoMdct->hItd != NULL ) @@ -611,6 +614,20 @@ void stereo_td_itd_mdct_stereo_fx( /* Time Domain ITD compensation using extrapolation */ stereo_td_itd_fx( hStereoMdct->hItd, NULL, NULL, 1, hStereoMdct->hDft_ana->dft_ovl, hCPE->hCoreCoder, input_frame, hCPE->input_mem_fx, hCPE->q_input_mem ); } +#ifdef NONBE_1203_MDCT2DFT_SWITCHING + ELSE IF( hCPE->input_mem_fx[0] != NULL ) + { + dft_ovl = extract_l( Mpy_32_32( imult3216( input_frame, STEREO_DFT_OVL_MAX ), 2236963 ) ); // 1/L_FRAME48k = 2236963 (Q31) + + FOR( i = 0; i < CPE_CHANNELS; i++ ) + { + Copy_Scale_sig32_16( hCPE->hCoreCoder[i]->input32_fx + input_frame - dft_ovl, hCPE->input_mem_fx[i], dft_ovl, 0 ); /* sts[n]->q_inp32 - 16 */ + hCPE->q_input_mem[i] = sub( hCPE->hCoreCoder[i]->q_inp32, 16 ); + move16(); + } + } +#endif + return; } diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 3bee88482..8890622a9 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -649,13 +649,16 @@ void stereo_switching_enc_fx( dft_ovl = extract_l( Mpy_32_32( imult3216( input_frame, STEREO_DFT_OVL_MAX ), 2236963 ) ); // 1/L_FRAME48k = 2236963 (Q31) /* update DFT analysis overlap memory */ +#ifdef NONBE_1203_MDCT2DFT_SWITCHING + /* note: in MDCT stereo, the update is done in stereo_td_itd_mdct_stereo() */ +#endif test(); test(); IF( GT_16( hCPE->element_mode, IVAS_CPE_DFT ) && hCPE->input_mem_fx[0] != NULL && NE_16( hCPE->element_mode, IVAS_CPE_MDCT ) ) { FOR( n = 0; n < CPE_CHANNELS; n++ ) { - Copy_Scale_sig32_16( sts[n]->input32_fx + input_frame - dft_ovl, hCPE->input_mem_fx[n], dft_ovl, 0 ); /* sts[n]->q_inp32 - 16*/ + Copy_Scale_sig32_16( sts[n]->input32_fx + input_frame - dft_ovl, hCPE->input_mem_fx[n], dft_ovl, 0 ); /* sts[n]->q_inp32 - 16 */ hCPE->q_input_mem[n] = sub( sts[n]->q_inp32, 16 ); move16(); } -- GitLab From 98bec86e1cb9360801948981d748376c0d64aedd Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sat, 4 Oct 2025 20:15:48 +0200 Subject: [PATCH 2/3] update from 16 bit buffer instead --- lib_enc/ivas_stereo_dft_td_itd_fx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib_enc/ivas_stereo_dft_td_itd_fx.c b/lib_enc/ivas_stereo_dft_td_itd_fx.c index 2ac886d08..fdd58eeab 100644 --- a/lib_enc/ivas_stereo_dft_td_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_td_itd_fx.c @@ -621,8 +621,9 @@ void stereo_td_itd_mdct_stereo_fx( FOR( i = 0; i < CPE_CHANNELS; i++ ) { - Copy_Scale_sig32_16( hCPE->hCoreCoder[i]->input32_fx + input_frame - dft_ovl, hCPE->input_mem_fx[i], dft_ovl, 0 ); /* sts[n]->q_inp32 - 16 */ - hCPE->q_input_mem[i] = sub( hCPE->hCoreCoder[i]->q_inp32, 16 ); + /* without renormalization, hCPE->hCoreCoder[i]->input_fx has a better resolution than hCPE->hCoreCoder[i]->input32_fx */ + Copy( hCPE->hCoreCoder[i]->input_fx + input_frame - dft_ovl, hCPE->input_mem_fx[i], dft_ovl ); + hCPE->q_input_mem[i] = hCPE->hCoreCoder[i]->q_inp; move16(); } } -- GitLab From b7f02c3b7621d6a10c438891639c595516e96f45 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sun, 5 Oct 2025 16:54:52 +0200 Subject: [PATCH 3/3] use scaled version of 32 bit buffer, also in stereo_switching_enc_fx() --- lib_enc/ivas_stereo_dft_td_itd_fx.c | 7 ++++--- lib_enc/ivas_stereo_switching_enc_fx.c | 7 +++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib_enc/ivas_stereo_dft_td_itd_fx.c b/lib_enc/ivas_stereo_dft_td_itd_fx.c index fdd58eeab..0e404a0de 100644 --- a/lib_enc/ivas_stereo_dft_td_itd_fx.c +++ b/lib_enc/ivas_stereo_dft_td_itd_fx.c @@ -575,6 +575,7 @@ void stereo_td_itd_mdct_stereo_fx( STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct; #ifdef NONBE_1203_MDCT2DFT_SWITCHING Word16 dft_ovl; + Word16 sf; #endif test(); @@ -621,9 +622,9 @@ void stereo_td_itd_mdct_stereo_fx( FOR( i = 0; i < CPE_CHANNELS; i++ ) { - /* without renormalization, hCPE->hCoreCoder[i]->input_fx has a better resolution than hCPE->hCoreCoder[i]->input32_fx */ - Copy( hCPE->hCoreCoder[i]->input_fx + input_frame - dft_ovl, hCPE->input_mem_fx[i], dft_ovl ); - hCPE->q_input_mem[i] = hCPE->hCoreCoder[i]->q_inp; + sf = L_norm_arr( hCPE->hCoreCoder[i]->input32_fx + input_frame - dft_ovl, dft_ovl ); + Copy_Scale_sig32_16( hCPE->hCoreCoder[i]->input32_fx + input_frame - dft_ovl, hCPE->input_mem_fx[i], dft_ovl, sf ); + hCPE->q_input_mem[i] = sub( add( hCPE->hCoreCoder[i]->q_inp32, sf ), 16 ); move16(); } } diff --git a/lib_enc/ivas_stereo_switching_enc_fx.c b/lib_enc/ivas_stereo_switching_enc_fx.c index 8890622a9..24ff57217 100644 --- a/lib_enc/ivas_stereo_switching_enc_fx.c +++ b/lib_enc/ivas_stereo_switching_enc_fx.c @@ -658,9 +658,16 @@ void stereo_switching_enc_fx( { FOR( n = 0; n < CPE_CHANNELS; n++ ) { +#ifdef NONBE_1203_MDCT2DFT_SWITCHING + Word16 sf = L_norm_arr( sts[n]->input32_fx + input_frame - dft_ovl, dft_ovl ); + Copy_Scale_sig32_16( sts[n]->input32_fx + input_frame - dft_ovl, hCPE->input_mem_fx[n], dft_ovl, sf ); /* sts[n]->q_inp32 - 16 */ + hCPE->q_input_mem[n] = sub( add( sts[n]->q_inp32, sf ), 16 ); + move16(); +#else Copy_Scale_sig32_16( sts[n]->input32_fx + input_frame - dft_ovl, hCPE->input_mem_fx[n], dft_ovl, 0 ); /* sts[n]->q_inp32 - 16 */ hCPE->q_input_mem[n] = sub( sts[n]->q_inp32, 16 ); move16(); +#endif } } -- GitLab