From fd1f8b5feeb372f8f9882f3d08302a9ade09e052 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 14 Aug 2024 09:28:18 -0400 Subject: [PATCH 1/3] proposed fix to 843 --- lib_com/options.h | 1 + lib_dec/acelp_core_dec_ivas_fx.c | 10 ++++++++++ lib_dec/ivas_td_low_rate_dec.c | 4 ++++ lib_dec/swb_bwe_dec_fx.c | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 5cb264d35..475df11b7 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -163,6 +163,7 @@ #define FIX_844_Q_SYN_INIT /* VA : proposed fix to 844, initializing q_old_synth when switching to MDCT*/ #define FIX_839_FB_CONTENT_SOMETIME_MISSING /* VA : Fix scaling error for FB TB BWE */ #define FIX_846_TILT_BWE /* VA : Proposed fix to 846, to solve saturation */ +#define FIX_843_LOW_RATE_BWE /* VA : Proposed fix to 843 to solve mid band noise */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index db5a51769..8eb83ce1a 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -1187,7 +1187,11 @@ ivas_error acelp_core_dec_ivas_fx( /* Core synthesis at 12.8kHz or 16kHz */ i = 1; move16(); +#ifdef FIX_843_LOW_RATE_BWE + if ( st->coder_type == INACTIVE && st->element_mode == EVS_MONO ) +#else if ( st->coder_type == INACTIVE ) +#endif { i = 0; move16(); @@ -2121,9 +2125,15 @@ ivas_error acelp_core_dec_ivas_fx( Copy_Scale_sig_32_16( synth_fx, synth_fx16, L_FRAME48k, 0 ); #endif #ifdef FIX_774_ENERGY_BURST +#ifdef FIX_843_LOW_RATE_BWE + hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc2_fx, + psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2, st->hBWE_zero->delay_syn_hf_fx, &st->hBWE_zero->memExp1, + st->hBWE_zero->mem_hp_interp_fx, st->extl, st->CNG_mode ); +#else hf_synth_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2, st->hBWE_zero->delay_syn_hf_fx, &st->hBWE_zero->memExp1, st->hBWE_zero->mem_hp_interp_fx, st->extl, st->CNG_mode ); +#endif #else hf_synth_ivas_fx( st->hBWE_zero, st->core_brate, output_frame, Aq_fx, exc_fx, psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2, st->hBWE_zero->delay_syn_hf_fx, &tmp_exp, diff --git a/lib_dec/ivas_td_low_rate_dec.c b/lib_dec/ivas_td_low_rate_dec.c index 0d1e8b9d7..bf3b6da34 100644 --- a/lib_dec/ivas_td_low_rate_dec.c +++ b/lib_dec/ivas_td_low_rate_dec.c @@ -315,6 +315,10 @@ void tdm_low_rate_dec_fx( edct_16fx( exc_wo_nf_fx, exc_wo_nf_fx, L_FRAME, find_guarded_bits_fx( L_FRAME ), IVAS_CPE_TD ); +#ifdef FIX_843_LOW_RATE_BWE + Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, &exc[0], &bwe_exc[0], st->hGSCDec->last_exc_dct_in_fx, + L_FRAME, L_FRAME * HIBND_ACB_L_FAC, L_shl( st->lp_gainc_fx, 13 /* Q3 -> Q16*/ ), &( st->Q_exc ), st->Q_subfr, NULL, 0, st->coder_type ); +#endif /*----------------------------------------------------------------------* * Remove potential pre-echo in case an onset has been detected *----------------------------------------------------------------------*/ diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c index f72e89398..1d6e0d395 100644 --- a/lib_dec/swb_bwe_dec_fx.c +++ b/lib_dec/swb_bwe_dec_fx.c @@ -398,7 +398,7 @@ Word16 ivas_wb_bwe_dec_fx( *Qpost = sub( new_input_fx_exp, 15 ); move16(); /* DCT of the ACELP core synthesis */ -#ifdef MSAN_FIX +#if defined MSAN_FIX && !defined FIX_843_LOW_RATE_BWE direct_transform_fx( L_wtda_synth_fx, ysynth_32, 0, L_FRAME16k, &new_input_fx_exp, st_fx->element_mode ); #else direct_transform_fx( L_wtda_synth_fx, ysynth_32, 0, output_frame, &new_input_fx_exp, st_fx->element_mode ); -- GitLab From 531c14f20ee43aabd0cec474fc26ca589367c3a1 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 14 Aug 2024 10:00:45 -0400 Subject: [PATCH 2/3] Complete fix for 843 --- lib_dec/swb_bwe_dec_fx.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c index 1d6e0d395..0ef71df4b 100644 --- a/lib_dec/swb_bwe_dec_fx.c +++ b/lib_dec/swb_bwe_dec_fx.c @@ -368,7 +368,9 @@ Word16 ivas_wb_bwe_dec_fx( Word16 scl, new_input_fx_exp; Word16 i; FD_BWE_DEC_HANDLE hBWE_FD; - +#ifdef FIX_843_LOW_RATE_BWE + Word16 ysynth_frame_size; +#endif Word16 coder_type = st_fx->coder_type; move16(); @@ -389,6 +391,9 @@ Word16 ivas_wb_bwe_dec_fx( *Qpost = sub( new_input_fx_exp, 15 ); move16(); direct_transform_fx( L_wtda_synth_fx, ysynth_32, 0, /*st->L_frame*/ L_FRAME16k, &new_input_fx_exp, st_fx->element_mode ); +#ifdef FIX_843_LOW_RATE_BWE + ysynth_frame_size = L_FRAME16k; +#endif } ELSE { @@ -398,11 +403,17 @@ Word16 ivas_wb_bwe_dec_fx( *Qpost = sub( new_input_fx_exp, 15 ); move16(); /* DCT of the ACELP core synthesis */ -#if defined MSAN_FIX && !defined FIX_843_LOW_RATE_BWE +#ifdef FIX_843_LOW_RATE_BWE + direct_transform_fx( L_wtda_synth_fx, ysynth_32, 0, output_frame, &new_input_fx_exp, st_fx->element_mode ); + ysynth_frame_size = output_frame; +#else +#ifdef MSAN_FIX direct_transform_fx( L_wtda_synth_fx, ysynth_32, 0, L_FRAME16k, &new_input_fx_exp, st_fx->element_mode ); #else direct_transform_fx( L_wtda_synth_fx, ysynth_32, 0, output_frame, &new_input_fx_exp, st_fx->element_mode ); #endif +#endif + } /* Convert to 16 Bits (Calc Shift Required to Stay within MAX_Q_NEW_INPUT) */ scl = sub( 16 + MAX_Q_NEW_INPUT, new_input_fx_exp ); @@ -411,18 +422,26 @@ Word16 ivas_wb_bwe_dec_fx( { /* Yes */ /* Calc Room to Upscale */ +#ifdef FIX_843_LOW_RATE_BWE + Q_syn = Find_Max_Norm32( ysynth_32, ysynth_frame_size ); +#else #ifdef MSAN_FIX Q_syn = Find_Max_Norm32( ysynth_32, L_FRAME16k ); #else Q_syn = Find_Max_Norm32( ysynth_32, output_frame ); +#endif #endif /* Stay within MAX_Q_NEW_INPUT */ scl = s_min( Q_syn, scl ); } +#ifdef FIX_843_LOW_RATE_BWE + Copy_Scale_sig32_16( ysynth_32, ysynth_fx, ysynth_frame_size, scl ); +#else #ifdef MSAN_FIX Copy_Scale_sig32_16( ysynth_32, ysynth_fx, L_FRAME16k, scl ); #else Copy_Scale_sig32_16( ysynth_32, ysynth_fx, output_frame, scl ); +#endif #endif Q_syn = add( sub( new_input_fx_exp, 16 ), scl ); IF( !st_fx->bfi ) -- GitLab From 7b78b91633215353e4f68a55b9ee462c892b38d7 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 14 Aug 2024 10:24:12 -0400 Subject: [PATCH 3/3] fix clang-format --- lib_dec/swb_bwe_dec_fx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_dec/swb_bwe_dec_fx.c b/lib_dec/swb_bwe_dec_fx.c index 0ef71df4b..765458a90 100644 --- a/lib_dec/swb_bwe_dec_fx.c +++ b/lib_dec/swb_bwe_dec_fx.c @@ -407,13 +407,12 @@ Word16 ivas_wb_bwe_dec_fx( direct_transform_fx( L_wtda_synth_fx, ysynth_32, 0, output_frame, &new_input_fx_exp, st_fx->element_mode ); ysynth_frame_size = output_frame; #else -#ifdef MSAN_FIX +#ifdef MSAN_FIX direct_transform_fx( L_wtda_synth_fx, ysynth_32, 0, L_FRAME16k, &new_input_fx_exp, st_fx->element_mode ); #else direct_transform_fx( L_wtda_synth_fx, ysynth_32, 0, output_frame, &new_input_fx_exp, st_fx->element_mode ); #endif #endif - } /* Convert to 16 Bits (Calc Shift Required to Stay within MAX_Q_NEW_INPUT) */ scl = sub( 16 + MAX_Q_NEW_INPUT, new_input_fx_exp ); -- GitLab