From 8a2f604e7760c9df9a2bede0ecc1a3a486a99760 Mon Sep 17 00:00:00 2001 From: knj Date: Tue, 11 Apr 2023 17:01:19 +0200 Subject: [PATCH 1/2] fix clicks in ism dtx for cng to TCX transitions --- lib_com/options.h | 2 ++ lib_com/prot.h | 3 +++ lib_dec/core_switching_dec.c | 17 ++++++++++++----- lib_dec/evs_dec.c | 4 ++++ lib_dec/ivas_core_dec.c | 4 ++++ lib_dec/ivas_mct_dec.c | 4 ++++ 6 files changed, 29 insertions(+), 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index f7073d3d6c..98fbab5f9c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -161,6 +161,8 @@ #define FIX_390_EXT_REND_MASA_META_COPY /* Nokia: Issue 390: Fixes MASA metadata copying to renderer. */ #define FIX_392_LATE_REVERB /* DLB : Issue 392: keep late reverb by default off when output config is not BINAURAL_ROOM*/ +#define FIX_ISM_DTX_CLICKS /* FhG: fix for clicks in ISM DTX for inactive to active TCX transitions */ + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ #endif diff --git a/lib_com/prot.h b/lib_com/prot.h index e89037076e..babd1ff9f7 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -5860,6 +5860,9 @@ ivas_error core_switching_post_dec( float *synth, /* i/o: output synthesis */ float *output, /* i/o: LB synth/upsampled LB synth */ float output_mem[], /* i : OLA memory from last TCX/HQ frame */ +#ifdef FIX_ISM_DTX_CLICKS + const IVAS_FORMAT ivas_format, /* i : IVAS format */ +#endif const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ const int16_t output_frame, /* i : frame length */ const int16_t core_switching_flag, /* i : ACELP->HQ switching frame flag */ diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c index c2a3955afb..a83e97c53c 100644 --- a/lib_dec/core_switching_dec.c +++ b/lib_dec/core_switching_dec.c @@ -51,7 +51,7 @@ *---------------------------------------------------------------------*/ static void core_switch_lb_upsamp( Decoder_State *st, float *output ); -static void smoothTransitionMdctStereoDtx( float synth[], const int16_t output_frame, const int16_t delay_comp ); +static void smoothTransitionDtxToTcx( float synth[], const int16_t output_frame, const int16_t delay_comp ); /*---------------------------------------------------------------------* * core_switching_pre_dec() @@ -556,6 +556,9 @@ ivas_error core_switching_post_dec( float *synth, /* i/o: output synthesis */ float *output, /* i/o: LB synth/upsampled LB synth */ float output_mem[], /* i : OLA memory from last TCX/HQ frame */ +#ifdef FIX_ISM_DTX_CLICKS + const IVAS_FORMAT ivas_format, /* i : IVAS format */ +#endif const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ const int16_t output_frame, /* i : frame length */ const int16_t core_switching_flag, /* i : ACELP->HQ switching flag */ @@ -677,10 +680,14 @@ ivas_error core_switching_post_dec( synth[i + delay_comp] = ( synth[i + delay_comp] * i + ( tmpDelta - i ) * st->previoussynth[i + delay_comp] ) / tmpDelta; } +#ifdef FIX_ISM_DTX_CLICKS + if ( ( st->element_mode == IVAS_CPE_MDCT || ( ivas_format == ISM_FORMAT && st->core == TCX_20_CORE /* <- means TCX in general, TCX10 is forbidden after ACELP */ ) ) && st->last_core_brate <= SID_2k40 && st->core_brate > SID_2k40 ) +#else if ( st->element_mode == IVAS_CPE_MDCT && st->last_core_brate <= SID_2k40 && st->core_brate > SID_2k40 ) +#endif { /* smooth transitions to avoid pops in car noise items */ - smoothTransitionMdctStereoDtx( synth, output_frame, delay_comp ); + smoothTransitionDtxToTcx( synth, output_frame, delay_comp ); } /* Reset memories of CLDFBs */ @@ -1245,16 +1252,16 @@ static void core_switch_lb_upsamp( } /*---------------------------------------------------------------------* - * smoothTransitionMdctStereoDtx() + * smoothTransitionDtxToTcx() * - * apply smoothing to the transition part for MDCT-Stereo DTX + * apply smoothing to the transition part for inactive to active transitions in DTX *---------------------------------------------------------------------*/ #define TRANSITION_SMOOTHING_LEN_16k 15 #define TRANSITION_SMOOTHING_LEN_32k 31 #define TRANSITION_SMOOTHING_LEN_48k 47 -static void smoothTransitionMdctStereoDtx( +static void smoothTransitionDtxToTcx( float synth[], /* i/o: synthesis */ const int16_t output_frame, /* i : output frame length */ const int16_t delay_comp /* i : delay compensation in samples */ diff --git a/lib_dec/evs_dec.c b/lib_dec/evs_dec.c index 2391430237..0dbc0feafc 100644 --- a/lib_dec/evs_dec.c +++ b/lib_dec/evs_dec.c @@ -276,7 +276,11 @@ ivas_error evs_dec( * Postprocessing for ACELP/MDCT core switching *---------------------------------------------------------------------*/ +#ifdef FIX_ISM_DTX_CLICKS + if ( ( error = core_switching_post_dec( st, synth, NULL, NULL, 0, MONO_FORMAT, output_frame, core_switching_flag, 0, -1, EVS_MONO ) ) != IVAS_ERR_OK ) +#else if ( ( error = core_switching_post_dec( st, synth, NULL, NULL, 0, output_frame, core_switching_flag, 0, -1, EVS_MONO ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 0811f9957a..bf13dee06f 100755 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -451,7 +451,11 @@ ivas_error ivas_core_dec( mvr2r( synth[n], hSCE->save_synth, output_frame ); } +#ifdef FIX_ISM_DTX_CLICKS + if ( ( error = core_switching_post_dec( st, synth[n], output[n], p_output_mem, ( st_ivas != NULL ) ? st_ivas->ivas_format : UNDEFINED_FORMAT, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, ( hCPE != NULL ) ? hCPE->last_element_mode : IVAS_SCE ) ) != IVAS_ERR_OK ) +#else if ( ( error = core_switching_post_dec( st, synth[n], output[n], p_output_mem, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, ( hCPE != NULL ) ? hCPE->last_element_mode : IVAS_SCE ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index f39951e087..eeecd4d8fa 100755 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -243,7 +243,11 @@ ivas_error ivas_mct_dec( } /* Postprocessing for ACELP/MDCT core switching and synchronization */ +#ifdef FIX_ISM_DTX_CLICKS + if ( ( error = core_switching_post_dec( sts[n], synth[n], output[cpe_id * CPE_CHANNELS + n], hCPE->output_mem[1], st_ivas->ivas_format, 0, output_frame, 0 /*core_switching_flag*/, st_ivas->sba_dirac_stereo_flag, -1, hCPE->last_element_mode ) ) != IVAS_ERR_OK ) +#else if ( ( error = core_switching_post_dec( sts[n], synth[n], output[cpe_id * CPE_CHANNELS + n], hCPE->output_mem[1], 0, output_frame, 0 /*core_switching_flag*/, st_ivas->sba_dirac_stereo_flag, -1, hCPE->last_element_mode ) ) != IVAS_ERR_OK ) +#endif { return error; } -- GitLab From f03a62cfc3d54ffa62f2379e10761bc8c370c88b Mon Sep 17 00:00:00 2001 From: knj Date: Wed, 12 Apr 2023 08:50:08 +0200 Subject: [PATCH 2/2] apply clang-format patch from pipeline --- lib_com/prot.h | 10 +++++----- lib_dec/core_switching_dec.c | 10 +++++----- lib_dec/ivas_core_dec.c | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) mode change 100755 => 100644 lib_dec/ivas_core_dec.c diff --git a/lib_com/prot.h b/lib_com/prot.h index babd1ff9f7..51d1cb1e20 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -5856,12 +5856,12 @@ void core_switching_post_enc( ); ivas_error core_switching_post_dec( - Decoder_State *st, /* i/o: decoder state structure */ - float *synth, /* i/o: output synthesis */ - float *output, /* i/o: LB synth/upsampled LB synth */ - float output_mem[], /* i : OLA memory from last TCX/HQ frame */ + Decoder_State *st, /* i/o: decoder state structure */ + float *synth, /* i/o: output synthesis */ + float *output, /* i/o: LB synth/upsampled LB synth */ + float output_mem[], /* i : OLA memory from last TCX/HQ frame */ #ifdef FIX_ISM_DTX_CLICKS - const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ #endif const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ const int16_t output_frame, /* i : frame length */ diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c index a83e97c53c..fc331a2e9f 100644 --- a/lib_dec/core_switching_dec.c +++ b/lib_dec/core_switching_dec.c @@ -552,12 +552,12 @@ ivas_error core_switching_pre_dec( *---------------------------------------------------------------------*/ ivas_error core_switching_post_dec( - Decoder_State *st, /* i/o: decoder state structure */ - float *synth, /* i/o: output synthesis */ - float *output, /* i/o: LB synth/upsampled LB synth */ - float output_mem[], /* i : OLA memory from last TCX/HQ frame */ + Decoder_State *st, /* i/o: decoder state structure */ + float *synth, /* i/o: output synthesis */ + float *output, /* i/o: LB synth/upsampled LB synth */ + float output_mem[], /* i : OLA memory from last TCX/HQ frame */ #ifdef FIX_ISM_DTX_CLICKS - const IVAS_FORMAT ivas_format, /* i : IVAS format */ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ #endif const int16_t use_cldfb_for_dft, /* i : flag to use of CLDFB for DFT Stereo */ const int16_t output_frame, /* i : frame length */ diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c old mode 100755 new mode 100644 index bf13dee06f..05c1f41727 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -452,7 +452,7 @@ ivas_error ivas_core_dec( } #ifdef FIX_ISM_DTX_CLICKS - if ( ( error = core_switching_post_dec( st, synth[n], output[n], p_output_mem, ( st_ivas != NULL ) ? st_ivas->ivas_format : UNDEFINED_FORMAT, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, ( hCPE != NULL ) ? hCPE->last_element_mode : IVAS_SCE ) ) != IVAS_ERR_OK ) + if ( ( error = core_switching_post_dec( st, synth[n], output[n], p_output_mem, ( st_ivas != NULL ) ? st_ivas->ivas_format : UNDEFINED_FORMAT, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, ( hCPE != NULL ) ? hCPE->last_element_mode : IVAS_SCE ) ) != IVAS_ERR_OK ) #else if ( ( error = core_switching_post_dec( st, synth[n], output[n], p_output_mem, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, ( hCPE != NULL ) ? hCPE->last_element_mode : IVAS_SCE ) ) != IVAS_ERR_OK ) #endif -- GitLab