From 6d8d514d1a97d710d71b49d1b9edeabe08d77696 Mon Sep 17 00:00:00 2001 From: knj Date: Tue, 17 Oct 2023 10:57:56 +0200 Subject: [PATCH 1/5] fix for clicks in MDCT-Stereo DTX to mono --- lib_com/options.h | 1 + lib_dec/ivas_stereo_switching_dec.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index d51e80754d..a5a2f86b9b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -174,6 +174,7 @@ #define NONBE_FIX_849_OMASA_BFI_CRASH /* VA: issue 849: fix OMASA 2TC and FEC crashes */ #define NONBE_UNIFIED_DECODING_PATHS /* FhG: unify decoding paths */ +#define NONBE_FIX_MDCT_STEREO_DTX_MONO_OUT /* FhG: fix clicks in DTX -> active transition frames in MDCT-Stereo with mono output */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index d91fdf4b56..91ac1894e9 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -1302,6 +1302,13 @@ void synchro_synthesis( } } +#ifdef NONBE_FIX_MDCT_STEREO_DTX_MONO_OUT + if ( hCPE->element_mode == IVAS_CPE_MDCT && hCPE->nchan_out == 1 && !is_DTXrate( hCPE->element_brate ) && is_DTXrate( hCPE->last_element_brate ) ) + { + mvr2r( sts[0]->prev_synth_buffer, sts[1]->prev_synth_buffer, delay_comp_DFT + delay_diff ); + } +#endif + nChannels = ( hCPE->element_mode == IVAS_CPE_MDCT ) ? 2 : hCPE->nchan_out; for ( n = 0; n < nChannels; n++ ) { -- GitLab From d7e6f5743d6a8ca3d2c6674fbe708c98976f9193 Mon Sep 17 00:00:00 2001 From: knj Date: Thu, 19 Oct 2023 10:31:59 +0200 Subject: [PATCH 2/5] move buffer update to same place as other updates --- lib_dec/ivas_stereo_mdct_stereo_dec.c | 18 ++++++++++++++++++ lib_dec/ivas_stereo_switching_dec.c | 7 ------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec.c b/lib_dec/ivas_stereo_mdct_stereo_dec.c index 0610447a6f..5963dbf6c4 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec.c @@ -565,12 +565,30 @@ void updateBuffersForDmxMdctStereo( sts[0] = hCPE->hCoreCoder[0]; sts[1] = hCPE->hCoreCoder[1]; +#ifdef NONBE_FIX_MDCT_STEREO_DTX_MONO_OUT + if ( is_DTXrate( hCPE->last_element_brate ) ) + { + /* synch output buffers for inactive frames, but not for transition frames */ + mvr2r( output[0], output[1], output_frame ); + mvr2r( synth[0], synth[1], output_frame ); + + /* synchronize previous synthesis buffer in first active frame to avoid discontinuities in TCX LTP filtering (performed in synchro_synthesis()) */ + if ( !is_DTXrate( hCPE->element_brate ) ) + { + int16_t delay_comp_TD; + + delay_comp_TD = NS2SA( sts[0]->output_Fs, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ); + mvr2r( sts[0]->prev_synth_buffer, sts[1]->prev_synth_buffer, delay_comp_TD ); + } + } +#else /* synch buffers for inactive frames, but not for transition frames */ if ( hCPE->last_element_brate <= IVAS_SID_5k2 ) { mvr2r( output[0], output[1], output_frame ); mvr2r( synth[0], synth[1], output_frame ); } +#endif if ( hCPE->element_brate == IVAS_SID_5k2 && hCPE->last_element_brate > IVAS_SID_5k2 ) { diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 91ac1894e9..d91fdf4b56 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -1302,13 +1302,6 @@ void synchro_synthesis( } } -#ifdef NONBE_FIX_MDCT_STEREO_DTX_MONO_OUT - if ( hCPE->element_mode == IVAS_CPE_MDCT && hCPE->nchan_out == 1 && !is_DTXrate( hCPE->element_brate ) && is_DTXrate( hCPE->last_element_brate ) ) - { - mvr2r( sts[0]->prev_synth_buffer, sts[1]->prev_synth_buffer, delay_comp_DFT + delay_diff ); - } -#endif - nChannels = ( hCPE->element_mode == IVAS_CPE_MDCT ) ? 2 : hCPE->nchan_out; for ( n = 0; n < nChannels; n++ ) { -- GitLab From 1d45ed1b7999951fab9b79cc1bfcb407025403d5 Mon Sep 17 00:00:00 2001 From: knj Date: Thu, 19 Oct 2023 10:36:30 +0200 Subject: [PATCH 3/5] run clang-format --- lib_dec/ivas_stereo_mdct_stereo_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec.c b/lib_dec/ivas_stereo_mdct_stereo_dec.c index 5963dbf6c4..28d5436fa4 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec.c @@ -571,7 +571,7 @@ void updateBuffersForDmxMdctStereo( /* synch output buffers for inactive frames, but not for transition frames */ mvr2r( output[0], output[1], output_frame ); mvr2r( synth[0], synth[1], output_frame ); - + /* synchronize previous synthesis buffer in first active frame to avoid discontinuities in TCX LTP filtering (performed in synchro_synthesis()) */ if ( !is_DTXrate( hCPE->element_brate ) ) { -- GitLab From 8cdd4064caa91cd47dab63bed6ce2837b9fed625 Mon Sep 17 00:00:00 2001 From: knj Date: Thu, 19 Oct 2023 11:03:19 +0200 Subject: [PATCH 4/5] Revert "move buffer update to same place as other updates" This reverts commit d7e6f5743d6a8ca3d2c6674fbe708c98976f9193. --- lib_dec/ivas_stereo_mdct_stereo_dec.c | 18 ------------------ lib_dec/ivas_stereo_switching_dec.c | 7 +++++++ 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec.c b/lib_dec/ivas_stereo_mdct_stereo_dec.c index 28d5436fa4..0610447a6f 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec.c @@ -565,30 +565,12 @@ void updateBuffersForDmxMdctStereo( sts[0] = hCPE->hCoreCoder[0]; sts[1] = hCPE->hCoreCoder[1]; -#ifdef NONBE_FIX_MDCT_STEREO_DTX_MONO_OUT - if ( is_DTXrate( hCPE->last_element_brate ) ) - { - /* synch output buffers for inactive frames, but not for transition frames */ - mvr2r( output[0], output[1], output_frame ); - mvr2r( synth[0], synth[1], output_frame ); - - /* synchronize previous synthesis buffer in first active frame to avoid discontinuities in TCX LTP filtering (performed in synchro_synthesis()) */ - if ( !is_DTXrate( hCPE->element_brate ) ) - { - int16_t delay_comp_TD; - - delay_comp_TD = NS2SA( sts[0]->output_Fs, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS ); - mvr2r( sts[0]->prev_synth_buffer, sts[1]->prev_synth_buffer, delay_comp_TD ); - } - } -#else /* synch buffers for inactive frames, but not for transition frames */ if ( hCPE->last_element_brate <= IVAS_SID_5k2 ) { mvr2r( output[0], output[1], output_frame ); mvr2r( synth[0], synth[1], output_frame ); } -#endif if ( hCPE->element_brate == IVAS_SID_5k2 && hCPE->last_element_brate > IVAS_SID_5k2 ) { diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index d91fdf4b56..91ac1894e9 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -1302,6 +1302,13 @@ void synchro_synthesis( } } +#ifdef NONBE_FIX_MDCT_STEREO_DTX_MONO_OUT + if ( hCPE->element_mode == IVAS_CPE_MDCT && hCPE->nchan_out == 1 && !is_DTXrate( hCPE->element_brate ) && is_DTXrate( hCPE->last_element_brate ) ) + { + mvr2r( sts[0]->prev_synth_buffer, sts[1]->prev_synth_buffer, delay_comp_DFT + delay_diff ); + } +#endif + nChannels = ( hCPE->element_mode == IVAS_CPE_MDCT ) ? 2 : hCPE->nchan_out; for ( n = 0; n < nChannels; n++ ) { -- GitLab From 232e15ada46d66a22cefa5793683336f424197e9 Mon Sep 17 00:00:00 2001 From: knj Date: Thu, 19 Oct 2023 11:03:39 +0200 Subject: [PATCH 5/5] use correct variable for delay value --- lib_dec/ivas_stereo_switching_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index 91ac1894e9..e98adfd60b 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -1305,7 +1305,7 @@ void synchro_synthesis( #ifdef NONBE_FIX_MDCT_STEREO_DTX_MONO_OUT if ( hCPE->element_mode == IVAS_CPE_MDCT && hCPE->nchan_out == 1 && !is_DTXrate( hCPE->element_brate ) && is_DTXrate( hCPE->last_element_brate ) ) { - mvr2r( sts[0]->prev_synth_buffer, sts[1]->prev_synth_buffer, delay_comp_DFT + delay_diff ); + mvr2r( sts[0]->prev_synth_buffer, sts[1]->prev_synth_buffer, delay_comp_TD ); } #endif -- GitLab