From f6fb2f2c9886e42c8cf23974edeb1b9691444447 Mon Sep 17 00:00:00 2001 From: knj Date: Tue, 16 May 2023 17:05:11 +0200 Subject: [PATCH 1/2] add fix for MDCT-Stereo PLC fadeout with TD concealment --- lib_com/ivas_cnst.h | 3 +++ lib_com/options.h | 1 + lib_dec/er_dec_tcx.c | 21 ++++++++++++++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index f6369235a6..b5e3964319 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 f7ee9e9c7c..23d3060986 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 /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_dec/er_dec_tcx.c b/lib_dec/er_dec_tcx.c index 1ce3bf2035..e29d8e22b9 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 ); -- GitLab From 69c6748c1b28b2a66f791cde1c498b17399490a7 Mon Sep 17 00:00:00 2001 From: knj Date: Tue, 16 May 2023 17:24:45 +0200 Subject: [PATCH 2/2] apply clang format --- lib_dec/er_dec_tcx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/er_dec_tcx.c b/lib_dec/er_dec_tcx.c index e29d8e22b9..fb797f92c9 100644 --- a/lib_dec/er_dec_tcx.c +++ b/lib_dec/er_dec_tcx.c @@ -557,7 +557,7 @@ void con_tcx( float alpha_delayed; alpha_delayed = 1.0f; - if (st->nbLostCmpt > MDCT_ST_PLC_FADEOUT_DELAY_4_LSP_FADE) + 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 ); } -- GitLab