From 28afa26d4ee7436d013f14983b6e8713b9608451 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 8 Oct 2025 18:08:44 +0200 Subject: [PATCH] port FIX_1384_MSAN_stereo_tcx_core_enc --- lib_com/options.h | 1 + lib_dec/ivas_tcx_core_dec.c | 35 +++++++++++++++++++++++++++++++---- lib_enc/ivas_tcx_core_enc.c | 6 +++++- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 6eeb9dd94..1bcc053cc 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -204,6 +204,7 @@ #define FIX_1385_INIT_IGF_STOP_FREQ /* FhG: Initialize infoIGFStopFreq in init_igf_dec() */ #define FIX_1387_INIT_PRM_SQQ /* FhG: initialize pointer prm_sqQ, which might be uninitialized in case of bfi == 1 */ #define NONBE_1296_TDREND_ITD_OUT_OF_BOUNDS_ACCESS /* Eri: issue 1296: ITD resampling can occasionally read out of bounds, especially when the requested subframes are short (1.25 ms). Seen for headtracking+JBM. */ +#define FIX_1384_MSAN_stereo_tcx_core_enc /* VA: issue 1384: fix use-of-uninitialized value in stereo_tcx_core_enc() */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index 62eabd32a..ee4e4598e 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -285,7 +285,7 @@ void stereo_tcx_core_dec( } /*--------------------------------------------------------------------------------* - * LPC PARAMETERS + * LPC envelope decoding *--------------------------------------------------------------------------------*/ st->acelp_cfg.midLpc = 0; @@ -296,6 +296,9 @@ void stereo_tcx_core_dec( { int16_t tcx_lpc_cdk; +#ifdef FIX_1384_MSAN_stereo_tcx_core_enc + tcx_lpc_cdk = tcxlpc_get_cdk( st->coder_type ); +#else if ( bfi && st->use_partial_copy && st->rf_frame_type == RF_TCXFD ) { tcx_lpc_cdk = tcxlpc_get_cdk( GENERIC ); @@ -304,6 +307,7 @@ void stereo_tcx_core_dec( { tcx_lpc_cdk = tcxlpc_get_cdk( st->coder_type ); } +#endif mvr2r( st->lsf_old, &lsf[0], M ); mvr2r( st->lsp_old, &lsp[0], M ); @@ -402,11 +406,12 @@ void stereo_tcx_core_dec( lsp2a_stab( st->lsp_old, st->old_Aq_12_8, M ); } +#ifndef FIX_1384_MSAN_stereo_tcx_core_enc if ( st->enablePlcWaveadjust && bfi ) { st->hPlcInfo->nbLostCmpt++; } - +#endif /*--------------------------------------------------------------------------------* * TD-TCX concealment *--------------------------------------------------------------------------------*/ @@ -528,6 +533,7 @@ void stereo_tcx_core_dec( if ( st->core == TCX_10_CORE || st->core == TCX_20_CORE ) { +#ifndef FIX_1384_MSAN_stereo_tcx_core_enc if ( st->enablePlcWaveadjust || /* bfi */ ( st->last_total_brate >= HQ_48k && /* recovery */ st->last_codec_mode == MODE2 ) ) @@ -545,7 +551,7 @@ void stereo_tcx_core_dec( } } } - +#endif if ( !bfi && st->hTonalMDCTConc != NULL ) { TonalMDCTConceal_SaveTimeSignal( st->hTonalMDCTConc, synthFB, hTcxDec->L_frameTCX ); @@ -669,11 +675,12 @@ void stereo_tcx_core_dec( if ( !bfi ) { +#ifndef FIX_1384_MSAN_stereo_tcx_core_enc if ( st->enablePlcWaveadjust ) { st->hPlcInfo->nbLostCmpt = 0; } - +#endif if ( param[1 + NOISE_FILL_RANGES] != 0 ) { set_f( pitch_buf, hTcxLtpDec->tcxltp_pitch_int + (float) hTcxLtpDec->tcxltp_pitch_fr / (float) st->pit_res_max, NB_SUBFR16k ); @@ -830,7 +837,11 @@ static void dec_prm_tcx( getTCXMode( st, st, 0 /* <- MCT_flag */ ); /* last_core for error concealment */ +#ifdef FIX_1384_MSAN_stereo_tcx_core_enc + if ( st->element_mode != IVAS_CPE_MDCT ) +#else if ( !st->use_partial_copy && st->element_mode != IVAS_CPE_MDCT ) +#endif { st->last_core_from_bs = get_next_indice( st, 1 ); /* Store decoder memory of last_core */ if ( st->last_core == ACELP_CORE && st->last_core_from_bs != ACELP_CORE ) @@ -856,8 +867,10 @@ static void dec_prm_tcx( } } +#ifndef FIX_1384_MSAN_stereo_tcx_core_enc if ( !st->use_partial_copy ) { +#endif if ( st->element_mode != IVAS_CPE_MDCT ) { getTCXWindowing( st->core, st->last_core, st->element_mode, st->hTcxCfg, st ); @@ -868,7 +881,9 @@ static void dec_prm_tcx( { st->dec_glr_idx = -1; } +#ifndef FIX_1384_MSAN_stereo_tcx_core_enc } +#endif #ifdef DEBUG_MODE_TCX fprintf( pF, "\t TCX Header: %d bits: %d %d %d %d\n", st->next_bit_pos - start_bit_pos, st->tcxonly, st->core, st->tcxonly ? st->clas_dec : st->hTcxCfg->coder_type, st->hTcxCfg->tcx_curr_overlap_mode ); @@ -891,6 +906,17 @@ static void dec_prm_tcx( * TCX20/10 parameters *--------------------------------------------------------------------------------*/ +#ifdef FIX_1384_MSAN_stereo_tcx_core_enc + getTCXparam( st, st, hm_cfg, param, bits_common, start_bit_pos, NULL, NULL, NULL, -1 ); + + if ( *total_nbbits - bitsRead[0] < ( st->next_bit_pos - start_bit_pos ) ) + { + st->BER_detect = 1; + st->next_bit_pos = start_bit_pos + *total_nbbits - bitsRead[0]; + } + + bitsRead[0] = st->next_bit_pos - start_bit_pos; +#else if ( st->use_partial_copy == 0 ) { getTCXparam( st, st, hm_cfg, param, bits_common, start_bit_pos, NULL, NULL, NULL, -1 ); @@ -906,6 +932,7 @@ static void dec_prm_tcx( bitsRead[0] = st->next_bit_pos - start_bit_pos; } +#endif return; } diff --git a/lib_enc/ivas_tcx_core_enc.c b/lib_enc/ivas_tcx_core_enc.c index 91adac9a0..175dedd08 100644 --- a/lib_enc/ivas_tcx_core_enc.c +++ b/lib_enc/ivas_tcx_core_enc.c @@ -310,7 +310,7 @@ void stereo_tcx_core_enc( } /*--------------------------------------------------------------* - * Envelope Quantization and FDNS + * LPC Envelope Quantization and FDNS *---------------------------------------------------------------*/ if ( !st->enableTcxLpc ) @@ -336,6 +336,10 @@ void stereo_tcx_core_enc( } } + +#ifdef FIX_1384_MSAN_stereo_tcx_core_enc + st->acelp_cfg.midLpc = 0; +#endif last_core_orig = st->last_core; for ( n = 0; n < n_subframes; n++ ) { -- GitLab