From bdd95100b5ddc20250c39299fafe5cbf7b59531c Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 9 Oct 2024 10:08:54 -0400 Subject: [PATCH 1/2] possible fix to 918, correcting scaling for the secondary channel after switching mode --- lib_com/options.h | 1 + lib_dec/ivas_stereo_switching_dec.c | 36 ++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 80600f9f9..5add1e88e 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -184,6 +184,7 @@ #define FIX_882_LOW_LEVEL_DISCONTINUITIES /* VA: Fix 882, discontinuities for low level signal by adding a scaling function that uses rounding, this function is more complex than normal one, has to be used only when necessary*/ #define FIX_879_DIFF_CONCEAL_PATH /* FhG: Fix for issue 879 and different concelalment paths that led to crash */ #define FIX_907_MEM_UPDATE_ISSUE /* VA: fix for 907, multiples issues surrounding mem_syn_r and update of mem_syn2 when FS is changing */ +#define FIX_918_WRONG_SCALING_ON_MODE_SWITCHING /* VA: Fix wrong scaling of secondary channel when switching from stereo DFT to TD */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index e5f6cc63c..a024e0435 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -3256,8 +3256,42 @@ void stereo_switching_dec( sts[1]->last_L_frame = sts[0]->last_L_frame; move16(); - +#ifndef FIX_918_WRONG_SCALING_ON_MODE_SWITCHING Copy_Scale_sig( sts[0]->old_exc_fx, sts[1]->old_exc_fx, L_EXC_MEM_DEC, sub( sts[1]->Q_exc, sts[0]->Q_exc ) ); +#else + /* Should not force sts[1]->Q_exc on the data of st[0], instead it better to just reuse the current scaling of st[0]*/ + Copy( sts[0]->old_exc_fx, sts[1]->old_exc_fx, L_EXC_MEM_DEC ); + sts[1]->Q_exc = sts[0]->Q_exc; + move16(); + sts[1]->Q_exc_cng = sts[0]->Q_exc_cng; + move16(); + sts[1]->prev_Q_exc = sts[0]->prev_Q_exc; + move16(); + Copy( sts[0]->Q_subfr, sts[1]->Q_subfr, L_Q_MEM ); + + sts[1]->prev_Q_bwe_syn = sts[0]->prev_Q_bwe_syn; + move16(); + sts[1]->prev_Q_bwe_syn2 = sts[0]->prev_Q_bwe_syn2; + move16(); + + sts[1]->prev_Q_bwe_exc_fb = sts[0]->prev_Q_bwe_exc_fb; + move16(); + sts[1]->prev_Qx = sts[0]->prev_Qx; + move16(); + sts[1]->prev_Q_bwe_exc = sts[0]->prev_Q_bwe_exc; + move16(); + sts[1]->prev_Q_synth = sts[0]->prev_Q_synth; + move16(); + sts[1]->Q_syn = sts[0]->Q_syn; + move16(); + sts[1]->Q_syn2 = sts[0]->Q_syn2; + move16(); + sts[1]->Q_syn_cng = sts[0]->Q_syn_cng; + move16(); + sts[1]->prev_Q_syn = sts[0]->prev_Q_syn; + move16(); + +#endif Copy( sts[0]->lsf_old_fx, sts[1]->lsf_old_fx, M ); Copy( sts[0]->lsp_old_fx, sts[1]->lsp_old_fx, M ); IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) ) -- GitLab From a79d75766fe4dd8afe14c719cd442e81eb105db8 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 9 Oct 2024 11:46:51 -0400 Subject: [PATCH 2/2] fix clang --- 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 a024e0435..3accfa8b6 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -3291,7 +3291,7 @@ void stereo_switching_dec( sts[1]->prev_Q_syn = sts[0]->prev_Q_syn; move16(); -#endif +#endif Copy( sts[0]->lsf_old_fx, sts[1]->lsf_old_fx, M ); Copy( sts[0]->lsp_old_fx, sts[1]->lsp_old_fx, M ); IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) ) -- GitLab