From adab390681a56b68f271f51fd3f438719d4dfec6 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 23 Jul 2025 15:51:38 -0400 Subject: [PATCH 1/2] possible fix for #1766, mld goes from 23.75 to 11.72 on the mono output --- lib_com/options.h | 2 ++ lib_enc/enc_gen_voic_fx.c | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 14b1c5eb8..757bf1698 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -148,4 +148,6 @@ #define FIX_1824 #define FIX_1822 +#define FIX_1766_TCX2ACELP_BWE_ISSUE /* VA : Fix rare BWE issue when switching from TCX to ACELP */ + #endif diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index fc1f3e993..b7771bbff 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -9,6 +9,30 @@ #include "rom_com.h" /* Static table prototypes */ #include "prot_fx_enc.h" /* Function prototypes */ + + +#ifdef FIX_1766_TCX2ACELP_BWE_ISSUE +static void rem_offset(const Word16 *in, Word16 *out, Word16 l_subfr ) +{ + Word16 i; + Word16 tmp; + Word32 loffset = 0; + move32(); + + tmp = shl( 2, norm_s( l_subfr ) ); /* l_subfr is expected to be based 2 */ + FOR( i = 0; i < l_subfr; i++ ) + { + loffset = L_mac( loffset, in[i], tmp ); + } + tmp = round_fx_sat( loffset ); + FOR( i = 0; i < l_subfr; i++ ) + { + out[i] = sub( in[i], tmp ); + move16(); + } +} +#endif + /*======================================================================*/ /* FUNCTION : encod_gen_voic_fx() */ /*----------------------------------------------------------------------*/ @@ -565,7 +589,16 @@ void encod_gen_voic_ivas_fx( Scale_sig( h1_fx, L_SUBFR, sub( 14, q_h1 ) ); /* set h1[] in Q14 with scaling for convolution Q14*/ /* scaling of xn[] to limit dynamic at 12 bits */ Scale_sig( xn_fx, L_SUBFR, shift ); - +#ifdef FIX_1766_TCX2ACELP_BWE_ISSUE + test(); + test(); + IF( Es_pred_fx < 0 && LE_16( i_subfr_fx, L_SUBFR ) && NE_16( st_fx->last_core, ACELP_CORE ) ) + { + /* During core transition, when the temporal correlation is non existent */ + rem_offset( xn_fx, xn_fx, L_SUBFR ); + rem_offset( cn_fx, cn_fx, L_SUBFR ); + } +#endif *pt_pitch_fx = pit_encode_ivas_fx( hBstr, st_fx->acelp_cfg.pitch_bits, st_fx->core_brate, 0, L_frame, st_fx->coder_type, &pitch_limit_flag, i_subfr_fx, exc_fx, L_SUBFR, st_fx->pitch, &T0_min_fx, &T0_max_fx, &T0_fx, &T0_frac_fx, h1_fx, xn_fx, tdm_Pitch_reuse_flag, tdm_Pri_pitch_buf, Q_new ); /* Q6 */ move16(); -- GitLab From e773b03d527cc0f0511e9ca8e18aa8adbb0ecc70 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 23 Jul 2025 15:55:57 -0400 Subject: [PATCH 2/2] fix clang --- lib_enc/enc_gen_voic_fx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib_enc/enc_gen_voic_fx.c b/lib_enc/enc_gen_voic_fx.c index b7771bbff..4595dc206 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -10,9 +10,8 @@ #include "prot_fx_enc.h" /* Function prototypes */ - #ifdef FIX_1766_TCX2ACELP_BWE_ISSUE -static void rem_offset(const Word16 *in, Word16 *out, Word16 l_subfr ) +static void rem_offset( const Word16 *in, Word16 *out, Word16 l_subfr ) { Word16 i; Word16 tmp; -- GitLab