diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 22b7d37d2f50cac336a9595d9d457944aef4e4e9..60f44e22a388f28b815dc993e74018bdf38c5d73 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -2000,6 +2000,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 038c9ece536eefc9ed4699a0f71dcfe78f413c51..a4d5cb3128401791cf36b99fde1daeef0c47fa7c 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -154,6 +154,7 @@ #define FIX_CREND_CHANNELS /* Issue 71: fix number of Crend channels */ #define HARMONIZE_SBA_NCHAN_TRANSPORT /* harmonize setting of number of transport channels in SBA */ #define DRAM_REDUCTION_MCT_IGF /* Issue 121: reduce dynamic RAM consumption in MCT IGF */ +#define FIX_I13_TCX_TNS_ISSUE /* Issue 13: Fix reported artifacts. Bug in TNS with TCX5 */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_com/prot.h b/lib_com/prot.h index 86e9e172e34ccc700e5ca1852b1b6cc4be3276fb..5cc6065e1528e6b349b46d70e9fd1e871eb65697 100755 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -7889,6 +7889,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 a28630886e53ebbfbbe27405a53494f90ed6d3c4..c1a01a1ca4c248d9ddbe2f00c8093d111a8e116e 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 502433517e87c41442cc4afa9590b1f6d85bc953..f7a6db5c3ee9e12a78afd677c5e2064c2e57da06 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]; @@ -108,7 +112,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 ); @@ -1488,7 +1497,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; @@ -1519,11 +1533,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 } } @@ -1541,6 +1556,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 ); @@ -1548,7 +1570,18 @@ 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 + 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 ); + } + 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 d05024c56599ce49f335e8e547776551a9b40811..1d0a90596e2ae8381553ea0af289ce680e364c61 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -1108,13 +1108,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 e46c32ddbbfde5dc0860c95b5e147de28f1b7480..02ae4b6064e629621563cc96ace2fa013b09504f 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 + ); } }