From e746ec9e0f842a7a38afb5946aaa398ef073810a Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Thu, 22 Jun 2023 16:09:51 +0200 Subject: [PATCH 1/2] fix for issue 575 for transitions to TCX5 after a lost frame --- lib_com/options.h | 2 ++ lib_dec/dec_tcx.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index b7c95bede7..fd71dedb42 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -154,6 +154,8 @@ #define FIX_559_EXTL_IGF_MISMATCH /* VA: issue 559: fix mismatch between st->extl and st->igf observed as crash in PlanarSBA bitrate switching */ #define FIX_QMETA_SID_5k2 /* Nokia: Issue 137: enable using full 5.2k bitrate in MASA SID */ +#define FIX_575_LOW_OVERLAP_PLC_RECOVERY /* FhG: Issue 575 fix for PLC and transistion to TCX5*/ + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index 35bdc6041f..45f8b87ced 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -377,7 +377,11 @@ void IMDCT( TCX_MDCT_Inverse( x + w * L_spec_TCX5, win, L_ola, L_win - L_ola, L_ola, st->element_mode ); } +#ifndef FIX_575_LOW_OVERLAP_PLC_RECOVERY tcx_windowing_synthesis_current_frame( win, tcx_aldo_window_2, tcx_mdct_window_half, tcx_mdct_window_minimum, L_ola, tcx_mdct_window_half_length, tcx_mdct_window_min_length, ( w > 0 ) ? 0 : left_rect, ( w > 0 ) || ( w == 0 && index == 2 ) ? MIN_OVERLAP : hTcxCfg->tcx_last_overlap_mode, acelp_zir, hTcxDec->old_syn_Overl, syn_Overl_TDAC, st->old_Aq_12_8, tcx_mdct_window_trans, L_win, tcx_offset < 0 ? -tcx_offset : 0, ( w > 0 ) || ( frame_cnt > 0 ) ? 1 : st->last_core_bfi, ( w > 0 ) || ( frame_cnt > 0 ) ? 0 : st->last_is_cng, fullbandScale ); +#else + tcx_windowing_synthesis_current_frame( win, tcx_aldo_window_2, tcx_mdct_window_half, tcx_mdct_window_minimum, L_ola, tcx_mdct_window_half_length, tcx_mdct_window_min_length, ( w > 0 ) ? 0 : left_rect, ( w > 0 ) || ( w == 0 && index == 2 ) ? MIN_OVERLAP : hTcxCfg->tcx_last_overlap_mode, acelp_zir, hTcxDec->old_syn_Overl, syn_Overl_TDAC, st->old_Aq_12_8, tcx_mdct_window_trans, L_win, tcx_offset < 0 ? -tcx_offset : 0, ( w > 0 ) || ( frame_cnt > 0 ) ? 1 : st->last_core, ( w > 0 ) || ( frame_cnt > 0 ) ? 0 : st->last_is_cng, fullbandScale ); +#endif if ( w > 0 ) { @@ -393,6 +397,14 @@ void IMDCT( /* To assure that no garbage values are passed to overlap */ set_zero( xn_buf + L_frame + tcx_offset + ( L_ola >> 1 ), overlap - tcx_offset - ( L_ola >> 1 ) ); + +#ifdef FIX_575_LOW_OVERLAP_PLC_RECOVERY + if ( st->prev_bfi && frame_cnt == 0 && st->last_core != st->last_core_bfi && st->last_core_bfi == ACELP_CORE ) + { + tcx_windowing_synthesis_past_frame( old_syn_overl, tcx_aldo_window_1_trunc, tcx_mdct_window_half, tcx_mdct_window_minimum, overlap, tcx_mdct_window_half_length, tcx_mdct_window_min_length, hTcxCfg->tcx_last_overlap_mode ); + v_add( xn_buf, old_syn_overl, xn_buf, overlap ); + } +#endif } else if ( !bfi && ( frame_cnt == 0 ) && ( hTcxCfg->tcx_curr_overlap_mode == FULL_OVERLAP ) ) -- GitLab From 0a9dd0e3e173bbbf1f0efe9ec8177c7b71032e55 Mon Sep 17 00:00:00 2001 From: Eleni Fotopoulou Date: Fri, 23 Jun 2023 13:06:50 +0200 Subject: [PATCH 2/2] fix additional issue on TCX 5 transition --- lib_dec/dec_tcx.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index 1e62a6d422..dd10cef293 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -1252,27 +1252,80 @@ void decoder_tcx_noisefilling( if ( ( frame_cnt == 0 ) && ( L_frameTCX == hTcxDec->L_frameTCX >> 1 ) && ( st->tcxonly ) && ( !st->tonal_mdct_plc_active ) && ( st->nbLostCmpt == 1 ) && ( hTcxCfg->tcx_last_overlap_mode != FULL_OVERLAP ) && ( hTcxCfg->tcx_curr_overlap_mode != FULL_OVERLAP ) ) { E_2ndlast = E_last = EPSILON; +#ifdef FIX_575_LOW_OVERLAP_PLC_RECOVERY + if ( st->element_mode > EVS_MONO ) + { + for ( i = 0; i < L_frameTCX; i = i + 2 ) + { + E_2ndlast += st->hTonalMDCTConc->lastBlockData.spectralData[i] * st->hTonalMDCTConc->lastBlockData.spectralData[i]; + E_last += st->hTonalMDCTConc->lastBlockData.spectralData[i + 1] * st->hTonalMDCTConc->lastBlockData.spectralData[i + 1]; + } + } + else + { + for ( i = 0; i < infoIGFStartLine; i = i + 2 ) + { + E_2ndlast += st->hTonalMDCTConc->lastBlockData.spectralData[i] * st->hTonalMDCTConc->lastBlockData.spectralData[i]; + E_last += st->hTonalMDCTConc->lastBlockData.spectralData[i + 1] * st->hTonalMDCTConc->lastBlockData.spectralData[i + 1]; + } + } +#else for ( i = 0; i < infoIGFStartLine; i = i + 2 ) { E_2ndlast += st->hTonalMDCTConc->lastBlockData.spectralData[i] * st->hTonalMDCTConc->lastBlockData.spectralData[i]; E_last += st->hTonalMDCTConc->lastBlockData.spectralData[i + 1] * st->hTonalMDCTConc->lastBlockData.spectralData[i + 1]; } +#endif tmp2 = E_2ndlast / E_last; /* replace higher energy TCX5 frame by lower one to avoid energy fluctuation */ if ( tmp2 > 2 ) { +#ifdef FIX_575_LOW_OVERLAP_PLC_RECOVERY + if ( st->element_mode > EVS_MONO ) + { + for ( i = 0; i < L_frameTCX; i = i + 2 ) + { + st->hTonalMDCTConc->lastBlockData.spectralData[i] = st->hTonalMDCTConc->lastBlockData.spectralData[i + 1]; + } + } + else + { + for ( i = 0; i < infoIGFStartLine; i = i + 2 ) + { + st->hTonalMDCTConc->lastBlockData.spectralData[i] = st->hTonalMDCTConc->lastBlockData.spectralData[i + 1]; + } + } +#else for ( i = 0; i < infoIGFStartLine; i = i + 2 ) { st->hTonalMDCTConc->lastBlockData.spectralData[i] = st->hTonalMDCTConc->lastBlockData.spectralData[i + 1]; } +#endif } else if ( tmp2 < 0.5 ) { +#ifdef FIX_575_LOW_OVERLAP_PLC_RECOVERY + if ( st->element_mode > EVS_MONO ) + { + for ( i = 0; i < L_frameTCX; i = i + 2 ) + { + st->hTonalMDCTConc->lastBlockData.spectralData[i + 1] = st->hTonalMDCTConc->lastBlockData.spectralData[i]; + } + } + else + { + for ( i = 0; i < infoIGFStartLine; i = i + 2 ) + { + st->hTonalMDCTConc->lastBlockData.spectralData[i + 1] = st->hTonalMDCTConc->lastBlockData.spectralData[i]; + } + } +#else for ( i = 0; i < infoIGFStartLine; i = i + 2 ) { st->hTonalMDCTConc->lastBlockData.spectralData[i + 1] = st->hTonalMDCTConc->lastBlockData.spectralData[i]; } +#endif } } -- GitLab