From d31a26aa1b2b9421c683885d7adcf9b840e38e1f Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 25 Feb 2026 13:24:16 +0100 Subject: [PATCH 1/3] correct blending in blend_subfr2() --- lib_com/options.h | 1 + lib_com/prot_fx.h | 5 ++++- lib_dec/acelp_core_dec_fx.c | 4 ++++ lib_dec/acelp_core_switch_dec_fx.c | 4 ++++ lib_dec/dec_post_fx.c | 27 +++++++++++++++++++++++++-- lib_dec/post_dec_fx.c | 15 +++++++++++++++ 6 files changed, 53 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 10396a5c3..9cc74f220 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -108,6 +108,7 @@ #define FIX_2283_ISM_MD_DELAY /* Dolby: Fix ISM metadata delay round-off */ #define FIX_2283_Q_CLDFB /* FhG: Fix Q format issue in CLDFB */ #define FIX_2283_ACCU_CLDFB /* FhG: Fix to consider Q-format differences in accumulateCLDFBArrayToBuffer_fx() */ +#define FIX_FLOAT_1533_BLEND_SUBFR2 /* FhG: float issue 1533: correct blending in blend_subfr2() */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index a4a32366e..0ba1a3200 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -6171,7 +6171,10 @@ void scale_st_fx( void blend_subfr2_fx( Word16 *sigIn1, /* i : i signal for fade-out */ Word16 *sigIn2, /* i : i signal for fade-in */ - Word16 *sigOut /* o : output signal */ +#ifdef FIX_FLOAT_1533_BLEND_SUBFR2 + Word16 L_subfr, /* i : subframe length */ +#endif + Word16 *sigOut /* o : output signal */ ); void init_tcx_window_cfg_fx( diff --git a/lib_dec/acelp_core_dec_fx.c b/lib_dec/acelp_core_dec_fx.c index 7b06d4b0d..eefc304e3 100644 --- a/lib_dec/acelp_core_dec_fx.c +++ b/lib_dec/acelp_core_dec_fx.c @@ -1529,7 +1529,11 @@ ivas_error acelp_core_dec_fx( E_UTIL_synthesis( 1, Aq_fx, temp_buf_fx + M + L_SUBFR, temp_buf_fx, L_SUBFR, st->hPFstat->mem_stp + L_SYN_MEM - M, 0, M ); scale_st_fx( psyn_fx, temp_buf_fx, &st->hPFstat->gain_prec, L_SUBFR ); Copy( temp_buf_fx, psyn_fx, ( L_SUBFR >> 1 ) ); +#ifdef FIX_FLOAT_1533_BLEND_SUBFR2 + blend_subfr2_fx( temp_buf_fx + L_SUBFR / 2, psyn_fx + L_SUBFR / 2, L_SUBFR, psyn_fx + L_SUBFR / 2 ); +#else blend_subfr2_fx( temp_buf_fx + L_SUBFR / 2, psyn_fx + L_SUBFR / 2, psyn_fx + L_SUBFR / 2 ); +#endif } st->hPFstat->on = 0; move16(); diff --git a/lib_dec/acelp_core_switch_dec_fx.c b/lib_dec/acelp_core_switch_dec_fx.c index dd477874f..d4ccf00f9 100644 --- a/lib_dec/acelp_core_switch_dec_fx.c +++ b/lib_dec/acelp_core_switch_dec_fx.c @@ -177,7 +177,11 @@ ivas_error acelp_core_switch_dec_fx( E_UTIL_synthesis( 1, Aq, exc, bpf_error_signal, L_SUBFR, st_fx->hPFstat->mem_stp + L_SYN_MEM - M, 0, M ); scale_st_fx( synth_intFreq, bpf_error_signal, &st_fx->hPFstat->gain_prec, L_SUBFR ); Copy( bpf_error_signal, synth_intFreq, L_SUBFR / 2 ); +#ifdef FIX_FLOAT_1533_BLEND_SUBFR2 + blend_subfr2_fx( bpf_error_signal + L_SUBFR / 2, synth_intFreq + L_SUBFR / 2, L_SUBFR, synth_intFreq + L_SUBFR / 2 ); +#else blend_subfr2_fx( bpf_error_signal + L_SUBFR / 2, synth_intFreq + L_SUBFR / 2, synth_intFreq + L_SUBFR / 2 ); +#endif } st_fx->hPFstat->on = 0; move16(); diff --git a/lib_dec/dec_post_fx.c b/lib_dec/dec_post_fx.c index 1a568cbf9..442e0caf0 100644 --- a/lib_dec/dec_post_fx.c +++ b/lib_dec/dec_post_fx.c @@ -1513,18 +1513,41 @@ void scale_st_fx( void blend_subfr2_fx( Word16 *sigIn1, // Qx Word16 *sigIn2, // Qx - Word16 *sigOut // Qx +#ifdef FIX_FLOAT_1533_BLEND_SUBFR2 + Word16 L_subfr, // Q0 +#endif + Word16 *sigOut // Qx ) { Word16 fac1 = 32768 - 512; // 1.Q15 - ( 1.Q15 / L_SUBFR ); Word16 fac2 = 0 + 512; // 0.Q15 + ( 1.Q15 / L_SUBFR ); Word16 step = 1024; // 1.Q15 / ( L_SUBFR / 2 ); - Word16 i; + Word16 i, L_subfr_half; move16(); move16(); move16(); +#ifdef FIX_FLOAT_1533_BLEND_SUBFR2 + assert( ( L_subfr == L_SUBFR ) || ( L_subfr == 2 * L_SUBFR ) ); + + IF( EQ_16( L_subfr, 2 * L_SUBFR ) ) + { + fac1 = 32768 - 256; // 1.Q15 - ( 1.Q15 / L_SUBFR ); + fac2 = 0 + 256; // 0.Q15 + ( 1.Q15 / L_SUBFR ); + step = 512; // 1.Q15 / ( L_SUBFR / 2 ); + move16(); + move16(); + move16(); + } +#endif + +#ifdef FIX_FLOAT_1533_BLEND_SUBFR2 + L_subfr_half = shr( L_subfr, 1 ); + + FOR( i = 0; i < L_subfr_half; i++ ) +#else FOR( i = 0; i < L_SUBFR / 2; i++ ) +#endif { sigOut[i] = mac_r_sat( L_mult_sat( fac1, sigIn1[i] ), fac2, sigIn2[i] ); // Qx fac1 = sub_sat( fac1, step ); diff --git a/lib_dec/post_dec_fx.c b/lib_dec/post_dec_fx.c index 8bf9380b3..6f00fd720 100644 --- a/lib_dec/post_dec_fx.c +++ b/lib_dec/post_dec_fx.c @@ -75,7 +75,11 @@ void post_decoder( Residu3_fx( st->old_Aq_12_8_fx, synth, synth_buf, L_SUBFR, 1 ); E_UTIL_synthesis( 1, st->old_Aq_12_8_fx, synth_buf, synth2, L_SUBFR, st->hPFstat->mem_stp + L_SYN_MEM - M, 0, M ); scale_st_fx( synth, synth2, &st->hPFstat->gain_prec, L_SUBFR ); +#ifdef FIX_FLOAT_1533_BLEND_SUBFR2 + blend_subfr2_fx( synth2 + L_SUBFR / 2, synth + L_SUBFR / 2, L_SUBFR, synth2 + L_SUBFR / 2 ); +#else blend_subfr2_fx( synth2 + L_SUBFR / 2, synth + L_SUBFR / 2, synth2 + L_SUBFR / 2 ); +#endif } } ELSE @@ -238,7 +242,18 @@ void post_decoder_ivas_fx( Residu3_fx( st->old_Aq_12_8_fx, synth, synth_buf, L_subfr, 1 ); E_UTIL_synthesis( 1, st->old_Aq_12_8_fx, synth_buf, synth2, L_subfr, st->hPFstat->mem_stp + L_SYN_MEM - M, 0, M ); scale_st_fx( synth, synth2, &st->hPFstat->gain_prec, L_subfr ); +#ifdef FIX_FLOAT_1533_BLEND_SUBFR2 + IF( EQ_16( st->element_mode, EVS_MONO ) ) + { + blend_subfr2_fx( synth2 + shr( L_subfr, 1 ), synth + shr( L_subfr, 1 ), L_SUBFR, synth2 + shr( L_subfr, 1 ) ); + } + ELSE + { + blend_subfr2_fx( synth2 + shr( L_subfr, 1 ), synth + shr( L_subfr, 1 ), L_subfr, synth2 + shr( L_subfr, 1 ) ); + } +#else blend_subfr2_fx( synth2 + shr( L_subfr, 1 ), synth + shr( L_subfr, 1 ), synth2 + shr( L_subfr, 1 ) ); +#endif } } ELSE -- GitLab From 02c13fb82b65c87628ee7a2f85926e529800b83e Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 25 Feb 2026 21:04:30 +0100 Subject: [PATCH 2/3] empty commit -- GitLab From 77442c3295e633a1424b8264a71b1005ae947dae Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 26 Feb 2026 16:29:22 +0100 Subject: [PATCH 3/3] take proposals for optimization into account --- lib_dec/post_dec_fx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib_dec/post_dec_fx.c b/lib_dec/post_dec_fx.c index 3894f429f..89f4ea724 100644 --- a/lib_dec/post_dec_fx.c +++ b/lib_dec/post_dec_fx.c @@ -257,11 +257,14 @@ void post_decoder_fx( ELSE { Word16 L_subfr = idiv1616( st->L_frame, st->nb_subfr ); +#ifdef FIX_FLOAT_1533_BLEND_SUBFR2 + Word16 L_subfr_half = shr( L_subfr, 1 ); +#endif Residu3_fx( st->old_Aq_12_8_fx, synth, synth_buf, L_subfr, 1 ); E_UTIL_synthesis( 1, st->old_Aq_12_8_fx, synth_buf, synth2, L_subfr, st->hPFstat->mem_stp + L_SYN_MEM - M, 0, M ); scale_st_fx( synth, synth2, &st->hPFstat->gain_prec, L_subfr ); #ifdef FIX_FLOAT_1533_BLEND_SUBFR2 - blend_subfr2_fx( synth2 + shr( L_subfr, 1 ), synth + shr( L_subfr, 1 ), L_subfr, synth2 + shr( L_subfr, 1 ) ); + blend_subfr2_fx( synth2 + L_subfr_half, synth + L_subfr_half, L_subfr, synth2 + L_subfr_half ); #else blend_subfr2_fx( synth2 + shr( L_subfr, 1 ), synth + shr( L_subfr, 1 ), synth2 + shr( L_subfr, 1 ) ); #endif -- GitLab