diff --git a/lib_com/options.h b/lib_com/options.h index a8301f74b79ca9b15e943ab6315c728d03679b66..1178c1878a16ffff4d28d4e952bf403371f57ca5 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -119,4 +119,6 @@ /* #################### End BASOP porting switches ############################ */ +#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 fc1f3e993f0038da6e3e1cf494c325313259461c..4595dc2062b3dd27b39b6b6ad488546957e56f09 100644 --- a/lib_enc/enc_gen_voic_fx.c +++ b/lib_enc/enc_gen_voic_fx.c @@ -9,6 +9,29 @@ #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 +588,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();