From 68de2b57ccddece15d4fe1f25d53d2ccf958b62a Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 8 Apr 2026 13:50:47 +0200 Subject: [PATCH] Avoid reading of unitialized st->hTcxCfg->psychParamsCurrent by harmonizing open_decoder_LPD*_fx() --- lib_com/options.h | 1 + lib_com/prot_fx.h | 6 ++++++ lib_dec/core_dec_init_fx.c | 11 +++++++++++ lib_dec/core_dec_switch_fx.c | 18 ++++++++++++++++++ lib_dec/init_dec_fx.c | 6 ++++++ 5 files changed, 42 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index e628cf13d..8d4c9acae 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,6 +103,7 @@ #define HARMONIZE_DCT /* VA: removal of duplicated DCT functions */ #define FIX_2489_HARMONIZE_FdCng_encodeSID /* FhG: harmonize FdCng_encodeSID_fx() and FdCng_encodeSID_ivas_fx() */ #define FIX_1527_CMR_BITRATE_IDX /* Fix for incorrect bitrate idx packed in rtp CMR E-byte */ +#define FIX_2509_HARMONIZE_OPEN_DECODER_LPD /* FhG: BASOP issue 2509: Avoid reading of unitialized st->hTcxCfg->psychParamsCurrent by harmonizing open_decoder_LPD*_fx() */ /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 1df946613..08447ca59 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7287,13 +7287,19 @@ ivas_error ppp_quarter_decoder_fx( DTFS_STRUCTURE PREV_CW_D_FX, /* i : Previous DTFS */ Decoder_State *st_fx ); +#ifndef FIX_2509_HARMONIZE_OPEN_DECODER_LPD void open_decoder_LPD_fx( Decoder_State *st, const Word32 total_brate, /* Q0 */ const Word16 bwidth /* Q0 */ ); +#endif +#ifdef FIX_2509_HARMONIZE_OPEN_DECODER_LPD +void open_decoder_LPD_fx( +#else void open_decoder_LPD_ivas_fx( +#endif Decoder_State *st, /* i/o: decoder state structure */ const Word32 total_brate, /* i : total bitrate Q0*/ const Word32 last_total_brate, /* i : last total bitrate Q0*/ diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index dd3115fb7..080c2c844 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -12,6 +12,7 @@ #include "rom_com.h" #include "cnst.h" /* for MIN_CNG_LEV */ +#ifndef FIX_2509_HARMONIZE_OPEN_DECODER_LPD /*-----------------------------------------------------------------------* * open_decoder_LPD_fx() * @@ -1005,6 +1006,7 @@ void open_decoder_LPD_fx( } return; } +#endif void tcxltp_dec_init_fx( TCX_LTP_DEC_HANDLE hTcxLtpDec, /* Q0 */ @@ -1114,7 +1116,16 @@ void acelp_plc_mdct_transition_fx( return; } +#ifdef FIX_2509_HARMONIZE_OPEN_DECODER_LPD +/*-----------------------------------------------------------------------* + * open_decoder_LPD_fx() + * + * Initialization of state variables + *-----------------------------------------------------------------------*/ +void open_decoder_LPD_fx( +#else void open_decoder_LPD_ivas_fx( +#endif Decoder_State *st, /* i/o: decoder state structure */ const Word32 total_brate, /* i : total bitrate Q0*/ const Word32 last_total_brate, /* i : last total bitrate Q0*/ diff --git a/lib_dec/core_dec_switch_fx.c b/lib_dec/core_dec_switch_fx.c index 142609fff..671dfc433 100644 --- a/lib_dec/core_dec_switch_fx.c +++ b/lib_dec/core_dec_switch_fx.c @@ -89,7 +89,21 @@ void mode_switch_decoder_LPD_fx( test(); IF( NE_16( fscale, st->fscale ) || ( switchWB != 0 ) || ( bSwitchFromAmrwbIO != 0 ) || EQ_16( st->last_codec_mode, MODE1 ) || st->force_lpd_reset ) { +#ifdef FIX_2509_HARMONIZE_OPEN_DECODER_LPD + Word16 Q_syn_Overl_TDAC = 0, Q_fer_samples = 0, Q_syn_Overl = 0, Q_syn_Overl_TDACFB = 0, Q_syn_OverlFB = 0, Q_old_out = 0, Q_old_outLB = 0, Q_old_Aq_12_8 = 0; + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + move16(); + + open_decoder_LPD_fx( st, total_brate, st->last_total_brate, bwidth, 0, EVS_MONO, 0, &Q_syn_Overl_TDAC, &Q_fer_samples, &Q_syn_Overl, &Q_syn_Overl_TDACFB, &Q_syn_OverlFB, &Q_old_out, &Q_old_outLB, &Q_old_Aq_12_8 ); +#else open_decoder_LPD_fx( st, total_brate, bwidth ); +#endif } ELSE { @@ -323,7 +337,11 @@ void mode_switch_decoder_LPD_ivas_fx( assert( (Word16) ( st->sr_core / FRAMES_PER_SEC ) == extract_l( Mult_32_16( st->sr_core, INV_FRAME_PER_SEC_Q15 ) ) ); IF( NE_16( fscale, st->fscale ) || switchWB || bSwitchFromAmrwbIO || EQ_16( st->last_codec_mode, MODE1 ) || st->force_lpd_reset ) { +#ifdef FIX_2509_HARMONIZE_OPEN_DECODER_LPD + open_decoder_LPD_fx( st, total_brate, last_total_brate, bwidth, MCT_flag, last_element_mode, 0, Q_syn_Overl_TDAC, Q_fer_samples, Q_syn_Overl, Q_syn_Overl_TDACFB, Q_syn_OverlFB, Q_old_out, Q_old_outLB, Q_old_Aq_12_8 ); +#else open_decoder_LPD_ivas_fx( st, total_brate, last_total_brate, bwidth, MCT_flag, last_element_mode, 0, Q_syn_Overl_TDAC, Q_fer_samples, Q_syn_Overl, Q_syn_Overl_TDACFB, Q_syn_OverlFB, Q_old_out, Q_old_outLB, Q_old_Aq_12_8 ); +#endif } ELSE { diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index bae2638e1..999b763f6 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -878,12 +878,14 @@ ivas_error init_decoder_fx( st_fx->hTECDec = NULL; } +#ifndef FIX_2509_HARMONIZE_OPEN_DECODER_LPD /* Init Decoder */ IF( st_fx->element_mode == EVS_MONO ) { open_decoder_LPD_fx( st_fx, st_fx->total_brate, st_fx->bwidth ); } ELSE +#endif { Word16 Q_syn_Overl_TDAC = 0, Q_fer_samples = 0, Q_syn_Overl = 0, Q_syn_Overl_TDACFB = 0, Q_syn_OverlFB = 0, Q_old_out = 0, Q_old_outLB = 0, Q_old_Aq_12_8 = 0; move16(); @@ -894,7 +896,11 @@ ivas_error init_decoder_fx( move16(); move16(); move16(); +#ifdef FIX_2509_HARMONIZE_OPEN_DECODER_LPD + open_decoder_LPD_fx( st_fx, st_fx->total_brate, st_fx->last_total_brate, st_fx->bwidth, 0, st_fx->element_mode, 1, &Q_syn_Overl_TDAC, &Q_fer_samples, &Q_syn_Overl, &Q_syn_Overl_TDACFB, &Q_syn_OverlFB, &Q_old_out, &Q_old_outLB, &Q_old_Aq_12_8 ); +#else open_decoder_LPD_ivas_fx( st_fx, st_fx->total_brate, st_fx->last_total_brate, st_fx->bwidth, 0, st_fx->element_mode, 1, &Q_syn_Overl_TDAC, &Q_fer_samples, &Q_syn_Overl, &Q_syn_Overl_TDACFB, &Q_syn_OverlFB, &Q_old_out, &Q_old_outLB, &Q_old_Aq_12_8 ); +#endif } /* PLC mode initialization */ -- GitLab