From 2d6706f3a920230e9e28c556668ff1d1ff1be271 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Mon, 19 Sep 2022 20:15:15 +0200 Subject: [PATCH 1/4] [fix] for Issue 13 --- lib_com/options.h | 2 ++ lib_dec/dec_tcx.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 54d2700014..71d797cc7a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -150,6 +150,8 @@ #define SBA_INTERN_CONFIG_FIX_HOA2 /* Issue 99 : Fix for incorrect internal_config when output format is HOA2 or FOA*/ #define FIX_I98_HANDLES_TO_NULL /* Issue 98: do the setting of all handles to NULL in one place */ +#define FIX_I13_TCX_TNS_ISSUE /* Issue 13: Fix reported artifacts. Bug in TNS with TCX5 */ + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index ae5faa4d73..fe29fc068f 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -1546,7 +1546,11 @@ void decoder_tcx_tns( if ( ( L_frame == st->L_frame >> 1 ) && st->tcxonly && isTCX5 ) { +#ifndef FIX_I13_TCX_TNS_ISSUE tcx5TnsUngrouping( L_frameTCX >> 1, hTcxCfg->tnsConfig[0][0].iFilterBorders[0] >> 1, x, DEC ); +#else + tcx5TnsUngrouping( L >> 1, hTcxCfg->tnsConfig[0][0].iFilterBorders[0] >> 1, x, DEC ); +#endif } } -- GitLab From cd40c09376ce20648ef17556608807700becfca9 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Tue, 20 Sep 2022 16:26:00 +0200 Subject: [PATCH 2/4] [fix] for issue 13 under FIX_I13_TCX_TNS_ISSUE --- lib_com/ivas_prot.h | 4 ++++ lib_com/options.h | 1 - lib_com/prot.h | 4 ++++ lib_dec/dec_LPD.c | 14 ++++++++++++-- lib_dec/dec_tcx.c | 27 ++++++++++++++++++++++++--- lib_dec/ivas_mdct_core_dec.c | 14 ++++++++++++-- lib_dec/ivas_tcx_core_dec.c | 14 ++++++++++++-- 7 files changed, 68 insertions(+), 10 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index c4e93a9545..54c67e6987 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -2005,6 +2005,10 @@ void decoder_tcx_tns( const int16_t bfi, /* i : Bad frame indicator */ const int16_t frame_cnt, /* i : frame counter in the super frame */ const int16_t whitenedDomain +#ifdef FIX_I13_TCX_TNS_ISSUE + , + const int16_t isEvsMono /*i: EVS mono flag */ +#endif ); void decoder_tcx_imdct( diff --git a/lib_com/options.h b/lib_com/options.h index 71d797cc7a..1efcb3fa0b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -149,7 +149,6 @@ #define SPAR_SCALING_HARMONIZATION /* Issue 80: Changes to harmonize scaling in spar */ #define SBA_INTERN_CONFIG_FIX_HOA2 /* Issue 99 : Fix for incorrect internal_config when output format is HOA2 or FOA*/ #define FIX_I98_HANDLES_TO_NULL /* Issue 98: do the setting of all handles to NULL in one place */ - #define FIX_I13_TCX_TNS_ISSUE /* Issue 13: Fix reported artifacts. Bug in TNS with TCX5 */ diff --git a/lib_com/prot.h b/lib_com/prot.h index 4c91c8cd52..a6fabef068 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -7885,6 +7885,10 @@ void decoder_tcx( const int16_t bfi, /* i : Bad frame indicator */ const int16_t frame_cnt, /* i : frame counter in the super_frame */ const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ +#ifdef FIX_I13_TCX_TNS_ISSUE + , + const int16_t isEvsMono /*i: EVS mono flag */ +#endif ); void decoder_tcx_post( diff --git a/lib_dec/dec_LPD.c b/lib_dec/dec_LPD.c index 422104ac43..fb7ffdc263 100644 --- a/lib_dec/dec_LPD.c +++ b/lib_dec/dec_LPD.c @@ -595,7 +595,12 @@ void decoder_LPD( } /* TCX decoder */ - decoder_tcx( st, prm, Aq, Aind, &synth[0], &synthFB[0], bfi, 0, 0 ); + decoder_tcx( st, prm, Aq, Aind, &synth[0], &synthFB[0], bfi, 0, 0 +#ifdef FIX_I13_TCX_TNS_ISSUE + , + 1 +#endif + ); } /*--------------------------------------------------------------------------------* @@ -621,7 +626,12 @@ void decoder_LPD( IGFDecRestoreTCX10SubFrameData( st->hIGFDec, k ); /* TCX decoder */ - decoder_tcx( st, prm, Aq, Aind, &synth[k * L_frame / 2], &synthFB[k * L_frameTCX / 2], bfi, k, 0 ); + decoder_tcx( st, prm, Aq, Aind, &synth[k * L_frame / 2], &synthFB[k * L_frameTCX / 2], bfi, k, 0 +#ifdef FIX_I13_TCX_TNS_ISSUE + , + 1 +#endif + ); } } diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index fe29fc068f..004c226f08 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -68,6 +68,10 @@ void decoder_tcx( const int16_t bfi, /* i : Bad frame indicator */ const int16_t frame_cnt, /* i : frame counter in the super frame */ const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ +#ifdef FIX_I13_TCX_TNS_ISSUE + , + const int16_t isEvsMono /*i: EVS mono flag */ +#endif ) { float x[N_MAX]; @@ -112,7 +116,12 @@ void decoder_tcx( decoder_tcx_noiseshaping_igf( st, L_spec, L_frame, L_frameTCX, left_rect, &x[0], &gainlpc2[0], &tmp_concealment_method, bfi ); - decoder_tcx_tns( st, L_frame_glob, L_spec, L_frame, L_frameTCX, &x[0], fUseTns, &tnsData, bfi, frame_cnt, 0 ); + decoder_tcx_tns( st, L_frame_glob, L_spec, L_frame, L_frameTCX, &x[0], fUseTns, &tnsData, bfi, frame_cnt, 0 +#ifdef FIX_I13_TCX_TNS_ISSUE + , + isEvsMono +#endif + ); decoder_tcx_imdct( st, L_frame_glob, L_frameTCX_glob, L_spec, tcx_offset, tcx_offsetFB, L_frame, L_frameTCX, left_rect, &x[0], &xn_buf[0], MDCT_IV, fUseTns, &synth[0], &synthFB[0], bfi, frame_cnt, 0, sba_dirac_stereo_flag ); @@ -1486,7 +1495,12 @@ void decoder_tcx_tns( STnsData *tnsData, const int16_t bfi, /* i : Bad frame indicator */ const int16_t frame_cnt, /* i : frame counter in the super frame */ - const int16_t whitenedDomain ) + const int16_t whitenedDomain +#ifdef FIX_I13_TCX_TNS_ISSUE + , + const int16_t isEvsMono /*i: EVS mono flag */ +#endif +) { int16_t index, isTCX5, L; TCX_CONFIG_HANDLE hTcxCfg = st->hTcxCfg; @@ -1549,7 +1563,14 @@ void decoder_tcx_tns( #ifndef FIX_I13_TCX_TNS_ISSUE tcx5TnsUngrouping( L_frameTCX >> 1, hTcxCfg->tnsConfig[0][0].iFilterBorders[0] >> 1, x, DEC ); #else - tcx5TnsUngrouping( L >> 1, hTcxCfg->tnsConfig[0][0].iFilterBorders[0] >> 1, x, DEC ); + if ( isEvsMono ) /*TODO: this is temporary to maintain EVS BE, this is a bug and should be fixed also for EVS (see issue 13) */ + { + tcx5TnsUngrouping( L_frameTCX >> 1, hTcxCfg->tnsConfig[0][0].iFilterBorders[0] >> 1, x, DEC ); + } + else + { + tcx5TnsUngrouping( L >> 1, hTcxCfg->tnsConfig[0][0].iFilterBorders[0] >> 1, x, DEC ); + } #endif } } diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index ed5114c651..d0c4c8abfc 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -1130,13 +1130,23 @@ void ivas_mdct_core_tns_ns( } decoder_tcx_tns( st, L_frame_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], &x[ch][k][0], - fUseTns[ch][k], &tnsData[ch][k], bfi, k, 1 ); + fUseTns[ch][k], &tnsData[ch][k], bfi, k, 1 +#ifdef FIX_I13_TCX_TNS_ISSUE + , + 0 +#endif + ); sns_shape_spectrum( x[ch][k], st->hTcxCfg->psychParamsCurrent, &sns_int_scf[0], st->hTcxCfg->psychParamsCurrent->nBins ); v_multc( x[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, sns_int_scf[FDNS_NPTS - 1], x[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, L_spec[ch] - st->hTcxCfg->psychParamsCurrent->nBins ); decoder_tcx_tns( st, L_frame_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], &x[ch][k][0], - fUseTns[ch][k], &tnsData[ch][k], bfi, k, 0 ); + fUseTns[ch][k], &tnsData[ch][k], bfi, k, 0 +#ifdef FIX_I13_TCX_TNS_ISSUE + , + 0 +#endif + ); } if ( bfi && st->tonal_mdct_plc_active ) diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index e3462f21bc..6481009011 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -528,7 +528,12 @@ void stereo_tcx_core_dec( } /* TCX decoder */ - decoder_tcx( st, prm, Aq, Aind, &synth[0], &synthFB[0], bfi, 0, sba_dirac_stereo_flag ); + decoder_tcx( st, prm, Aq, Aind, &synth[0], &synthFB[0], bfi, 0, sba_dirac_stereo_flag +#ifdef FIX_I13_TCX_TNS_ISSUE + , + 0 +#endif + ); } /*--------------------------------------------------------------------------------* @@ -556,7 +561,12 @@ void stereo_tcx_core_dec( } /* TCX decoder */ - decoder_tcx( st, prm, Aq, Aind, &synth[k * st->L_frame / 2], &synthFB[k * hTcxDec->L_frameTCX / 2], bfi, k, sba_dirac_stereo_flag ); + decoder_tcx( st, prm, Aq, Aind, &synth[k * st->L_frame / 2], &synthFB[k * hTcxDec->L_frameTCX / 2], bfi, k, sba_dirac_stereo_flag +#ifdef FIX_I13_TCX_TNS_ISSUE + , + 0 +#endif + ); } } -- GitLab From 2f19f341e7977b632313a9933b2240d6e10eb4ad Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Wed, 21 Sep 2022 09:46:39 +0200 Subject: [PATCH 3/4] rephrase comment in fix --- lib_dec/dec_tcx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index 004c226f08..3891ba0212 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -1563,7 +1563,7 @@ void decoder_tcx_tns( #ifndef FIX_I13_TCX_TNS_ISSUE tcx5TnsUngrouping( L_frameTCX >> 1, hTcxCfg->tnsConfig[0][0].iFilterBorders[0] >> 1, x, DEC ); #else - if ( isEvsMono ) /*TODO: this is temporary to maintain EVS BE, this is a bug and should be fixed also for EVS (see issue 13) */ + if ( isEvsMono ) /*tbc: this is temporary to maintain EVS BE, this is a bug and should be fixed also for EVS (see issue 13) */ { tcx5TnsUngrouping( L_frameTCX >> 1, hTcxCfg->tnsConfig[0][0].iFilterBorders[0] >> 1, x, DEC ); } -- GitLab From 51f37f4f04575786f8b966280a162a8a01897593 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Fri, 23 Sep 2022 12:14:46 +0200 Subject: [PATCH 4/4] [fix] move TCX5 grouping under proper conditions. Under FIX_I13_TCX_TNS_ISSUE. Differences with fix before are negligible --- lib_dec/dec_tcx.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index 3891ba0212..760fdf8e5b 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -1531,11 +1531,12 @@ void decoder_tcx_tns( isTCX5 = 1; tcx5SpectrumDeinterleaving( L >> 1, x ); - +#ifndef FIX_I13_TCX_TNS_ISSUE if ( hTcxCfg->fIsTNSAllowed && fUseTns != 0 && bfi != 1 && tnsData->tnsOnWhitenedSpectra == whitenedDomain ) { tcx5TnsGrouping( L >> 1, hTcxCfg->tnsConfig[0][0].iFilterBorders[0] >> 1, x ); } +#endif } } @@ -1553,6 +1554,13 @@ void decoder_tcx_tns( /* Apply TNS to get the reconstructed signal */ SetTnsConfig( hTcxCfg, L_frame_glob == st->L_frame, ( st->last_core == ACELP_CORE ) && ( frame_cnt == 0 ) ); +#ifdef FIX_I13_TCX_TNS_ISSUE + if ( ( L_frame == st->L_frame >> 1 ) && st->tcxonly && isTCX5 ) + { + tcx5TnsGrouping( L >> 1, hTcxCfg->tnsConfig[0][0].iFilterBorders[0] >> 1, x ); + } +#endif + ApplyTnsFilter( hTcxCfg->pCurrentTnsConfig, tnsData, x, 0 ); #ifdef DEBUG_PLOT sendDebout( "tnsSpec2", L_frameTCX, 1, "aftTNS", MTV_FLOAT, x ); -- GitLab