diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index f6369235a60c48b21f0f0647ed3a707740e5aae2..b5e3964319561de2bb35cfc157c0fe32031b3104 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -885,6 +885,9 @@ enum fea_names #define MDCT_ST_PLC_FADEOUT_MIN_NOISE_NRG 0.001f #define MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME 2 * FRAMES_PER_SEC #define MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN 20 +#ifdef FIX_MDCT_ST_PLC_FADEOUT_DELAY +#define MDCT_ST_PLC_FADEOUT_DELAY_4_LSP_FADE 3 +#endif typedef enum { EQUAL_CORES, diff --git a/lib_com/options.h b/lib_com/options.h index ffde84d5d335b948a22a3196777807c73012bd40..49d8d544d2b6700f0c8fb400ed092ae9aef3ec71 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -213,6 +213,7 @@ #define FIX_DTX_428 /* FhG: fix for issue 428, crash with DTX and bitrate switching */ #define FIX_STEREO_474 /* FhG fix for issue 574, crash with SBA to stereo output at 512 kbps */ +#define FIX_MDCT_ST_PLC_FADEOUT_DELAY #define FIX_DIRAC_LS_SYNTHESIS_CONFIG_479 /* FhG: fix for issue 479, broken LS output with DirAC at high BRs */ diff --git a/lib_dec/er_dec_tcx.c b/lib_dec/er_dec_tcx.c index 1ce3bf2035f97aee410f014857fefa7da3b749d1..fb797f92c9da1216601ceaf646c687e71bd30cd9 100644 --- a/lib_dec/er_dec_tcx.c +++ b/lib_dec/er_dec_tcx.c @@ -551,20 +551,39 @@ void con_tcx( mvr2r( synth - M, buf, M ); mvr2r( buf, mem_syn, M ); - if ( A_cng != NULL ) { +#ifdef FIX_MDCT_ST_PLC_FADEOUT_DELAY + float alpha_delayed; + + alpha_delayed = 1.0f; + if ( st->nbLostCmpt > MDCT_ST_PLC_FADEOUT_DELAY_4_LSP_FADE ) + { + alpha_delayed = Damping_fact( st->core_ext_mode, st->nbLostCmpt - MDCT_ST_PLC_FADEOUT_DELAY_4_LSP_FADE, st->last_good, st->stab_fac, &( st->lp_gainp ), ACELP_CORE ); + } + + if ( st->plcBackgroundNoiseUpdated && alpha_delayed != 1.0f ) +#else if ( st->plcBackgroundNoiseUpdated && alpha != 1.0f ) +#endif { float lsp_local[M], lsp_fade[M], alpha_inv; +#ifdef FIX_MDCT_ST_PLC_FADEOUT_DELAY + alpha_inv = 1.0f - alpha_delayed; +#else alpha_inv = 1.0f - alpha; +#endif a2lsp_stab( A_local, lsp_local, lsp_local ); for ( i = 0; i < M; i++ ) { +#ifdef FIX_MDCT_ST_PLC_FADEOUT_DELAY + lsp_fade[i] = alpha_delayed * lsp_local[i] + alpha_inv * st->lspold_cng[i]; +#else lsp_fade[i] = alpha * lsp_local[i] + alpha_inv * st->lspold_cng[i]; +#endif } lsp2a_stab( lsp_fade, A_local, M );