From 3fb7ab5fd613ec908b3e623d055095723e59ef07 Mon Sep 17 00:00:00 2001 From: naghibza Date: Tue, 3 Mar 2026 17:02:57 +0100 Subject: [PATCH 1/4] Fix loop bounds when scaling p_output_fx before ivas_spar_dec_agc_pca_fx() --- lib_com/options.h | 1 + lib_dec/ivas_dec_fx.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 7fa610801..eeb654fd3 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,6 +103,7 @@ #define FIX_2458_USAN_NULLPTR_WITH_ZERO_OFFSET /* FhG: basop issue 2458: avoid indexing into null pointer */ #define HARM_2456_APPLY_SCALE /* FhG basop issue 2456: Harmonize apply_scale_ind(), apply_scale_ivas_fx() */ #define HARM_2454_TCX_RES_Q_SPEC /* FhG: harmonization of tcx_res_Q_spec_fx() and tcx_res_Q_spec_ivas_fx() */ +#define FIX_2440_AGC_PRESCALING /* FhG: basop issue 2440: Fix loop bounds when scaling p_output_fx before ivas_spar_dec_agc_pca_fx() */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_dec_fx.c b/lib_dec/ivas_dec_fx.c index d95c010c8..e0f88f7fe 100644 --- a/lib_dec/ivas_dec_fx.c +++ b/lib_dec/ivas_dec_fx.c @@ -631,7 +631,11 @@ ivas_error ivas_dec_fx( ELSE IF( NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) && st_ivas->sba_dirac_stereo_flag == 0 ) { Word16 size = add( st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, sba_ch_idx ); +#ifdef FIX_2440_AGC_PRESCALING + if ( EQ_16( st_ivas->nchan_transport, 3 ) ) +#else if ( EQ_16( size, 3 ) ) +#endif { size = add( size, 1 ); } -- GitLab From adb04d3e1b3d7f1b51b83ef0a3ff860646ffd5e3 Mon Sep 17 00:00:00 2001 From: naghibza Date: Wed, 4 Mar 2026 09:24:34 +0100 Subject: [PATCH 2/4] Add explanatory comment. --- lib_dec/ivas_dec_fx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_dec/ivas_dec_fx.c b/lib_dec/ivas_dec_fx.c index e0f88f7fe..aaa77eb30 100644 --- a/lib_dec/ivas_dec_fx.c +++ b/lib_dec/ivas_dec_fx.c @@ -632,6 +632,8 @@ ivas_error ivas_dec_fx( { Word16 size = add( st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, sba_ch_idx ); #ifdef FIX_2440_AGC_PRESCALING + // For nchan_transport = 3, the fourth input audio channel in ivas_spar_dec_agc_pca_fx() is also used, + // so one additional channel must be aligned to Q14. if ( EQ_16( st_ivas->nchan_transport, 3 ) ) #else if ( EQ_16( size, 3 ) ) -- GitLab From a053fa16578d62dc75d588cfe39088d89452156d Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 5 Mar 2026 09:53:47 +0100 Subject: [PATCH 3/4] Replace st_ivas->nchan_transport with st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport and add Q-format explanatory comment --- lib_com/ivas_prot_fx.h | 6 +++--- lib_dec/ivas_dec_fx.c | 2 +- lib_dec/ivas_spar_decoder_fx.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index b8feba23d..74a0bfdfd 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -5170,9 +5170,9 @@ Word16 ivas_is_res_channel( ); void ivas_spar_dec_agc_pca_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - Word32 *output[], /* i/o: input/output audio channels */ - const Word16 output_frame /* i : output frame length */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + Word32 *output[], /* i/o: input/output audio channels, Qin=Q14 -> Qout=Q11*/ + const Word16 output_frame /* i : output frame length */ ); void ivas_spar_dec_set_render_map_fx( diff --git a/lib_dec/ivas_dec_fx.c b/lib_dec/ivas_dec_fx.c index 1b567286d..525caf8e2 100644 --- a/lib_dec/ivas_dec_fx.c +++ b/lib_dec/ivas_dec_fx.c @@ -632,7 +632,7 @@ ivas_error ivas_dec_fx( #ifdef FIX_2440_AGC_PRESCALING // For nchan_transport = 3, the fourth input audio channel in ivas_spar_dec_agc_pca_fx() is also used, // so one additional channel must be aligned to Q14. - if ( EQ_16( st_ivas->nchan_transport, 3 ) ) + if ( EQ_16( st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, 3 ) ) #else if ( EQ_16( size, 3 ) ) #endif diff --git a/lib_dec/ivas_spar_decoder_fx.c b/lib_dec/ivas_spar_decoder_fx.c index bc819763b..f36cdc0cb 100644 --- a/lib_dec/ivas_spar_decoder_fx.c +++ b/lib_dec/ivas_spar_decoder_fx.c @@ -1442,9 +1442,9 @@ static void ivas_spar_calc_smooth_facs_fx( *-------------------------------------------------------------------*/ void ivas_spar_dec_agc_pca_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - Word32 *output[], /* i/o: input/output audio channels Q14*/ - const Word16 output_frame /* i : output frame length Q0*/ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + Word32 *output[], /* i/o: input/output audio channels, Qin=Q14 -> Qout=Q11*/ + const Word16 output_frame /* i : output frame length Q0*/ ) { Word16 nchan_transport; -- GitLab From 58db2184212eeb5e590370b2d53f66693a0b7abf Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 5 Mar 2026 14:52:10 +0100 Subject: [PATCH 4/4] define to correct location --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 2dcb876c5..23a5aa26c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -91,7 +91,6 @@ #define HARM_2456_APPLY_SCALE /* FhG basop issue 2456: Harmonize apply_scale_ind(), apply_scale_ivas_fx() */ #define HARM_2454_TCX_RES_Q_SPEC /* FhG: harmonization of tcx_res_Q_spec_fx() and tcx_res_Q_spec_ivas_fx() */ #define FIX_FLOAT_1535_ARI_RES_Q_CLEANUP /* FhG: remove dead code from tcx_ari_res_Q_spec() */ -#define FIX_2440_AGC_PRESCALING /* FhG: basop issue 2440: Fix loop bounds when scaling p_output_fx before ivas_spar_dec_agc_pca_fx() */ /* #################### End BE switches ################################## */ @@ -101,6 +100,7 @@ #define FIX_2448_RENDERER_MSAN_ERROR /* FhG: basop issue 2448: fix MSAN error with MSA rendering */ #define FIX_2283_ISM_MD_DELAY /* Dolby: Fix ISM metadata delay round-off */ #define FIX_BASOP_2262_OLAP_BUFFER_SYNTH_SWITCHING /* FhG: basop issue 2262: correct buffer update for FD-CNG buffer in case of BR switching */ +#define FIX_2440_AGC_PRESCALING /* FhG: basop issue 2440: Fix loop bounds when scaling p_output_fx before ivas_spar_dec_agc_pca_fx() */ /* ##################### End NON-BE switches ########################### */ -- GitLab