From 4c6ad29675a7270258f0df5634f7523cc3fa143c Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 27 Feb 2026 14:59:27 +0100 Subject: [PATCH 1/7] disable updating of olapBufferSynth_fx[] (32 bit), use olapBufferSynth[] (16 bit) instead; the 32 bit buffer is updated instead of the 16 bit buffer, but then actually never used; should affect br switching only --- lib_com/fd_cng_com_fx.c | 2 ++ lib_com/options.h | 1 + lib_com/stat_com.h | 2 ++ lib_dec/core_switching_dec_fx.c | 4 ++++ 4 files changed, 9 insertions(+) diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c index f7b58ae62..d2e3b0d3c 100644 --- a/lib_com/fd_cng_com_fx.c +++ b/lib_com/fd_cng_com_fx.c @@ -166,7 +166,9 @@ void initFdCngCom( set16_fx( hFdCngCom->coherence_fx, 16384 /* 0.5 in Q15 */, MDCT_ST_DTX_NUM_COHERENCE_BANDS ); +#ifndef FIX_BASOP_2262_OLAP_BUFFER_SYNTH_SWITCHING set32_fx( hFdCngCom->olapBufferSynth_fx, 0, FFTLEN ); +#endif set32_fx( hFdCngCom->olapBufferSynth2_fx, 0, FFTLEN ); set32_fx( hFdCngCom->exc_cng_32fx, 0, L_FRAME16k ); set16_fx( hFdCngCom->exc_cng, 0, L_FRAME16k ); diff --git a/lib_com/options.h b/lib_com/options.h index 20cc81e20..d1fa34417 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -113,6 +113,7 @@ #define FIX_1530_Codec_Level_Harmonization_Non_diegetic_panning /* FhG: Adjust non-diegetic panning law to harmonize codec levels with 3GPP reference software */ #define FIX_FLOAT_1518 /* FhG: fix issue 1518: loudness differences in OSBA decoding to mono or stereo output */ #define FIX_FLOAT_1533_BLEND_SUBFR2 /* FhG: float issue 1533: correct blending in blend_subfr2() */ +#define FIX_BASOP_2262_OLAP_BUFFER_SYNTH_SWITCHING /* FhG: basop issue 2262: correct buffer update for FD-CNG buffer in case of BR switching */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index a85d6c7c0..9cc17a482 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -367,7 +367,9 @@ typedef struct Word16 fftlenFac; // Q0 Word16 timeDomainBuffer[L_FRAME16k]; /*Q15*/ +#ifndef FIX_BASOP_2262_OLAP_BUFFER_SYNTH_SWITCHING Word32 olapBufferSynth_fx[FFTLEN]; /*Q_olapBufferSynth*/ +#endif Word32 olapBufferSynth2_fx[FFTLEN]; /*Q_olapBufferSynth2*/ const Word32 *olapWinAna_fx; /* Q30 */ diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index b8f4cc63f..f1581ba59 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1919,8 +1919,10 @@ ivas_error core_switching_pre_dec_fx( lerp( st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->last_L_frame, st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->L_frame, st->L_frame, st->last_L_frame ); } +#ifndef FIX_BASOP_2262_OLAP_BUFFER_SYNTH_SWITCHING IF( EQ_16( st->element_mode, EVS_MONO ) ) { +#endif lerp( st->hFdCngDec->hFdCngCom->olapBufferSynth2, st->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ) ); test(); IF( LE_32( st->total_brate, SID_2k40 ) && LE_32( st->last_total_brate, SID_2k40 ) ) @@ -1944,6 +1946,7 @@ ivas_error core_switching_pre_dec_fx( } } } +#ifndef FIX_BASOP_2262_OLAP_BUFFER_SYNTH_SWITCHING } ELSE { @@ -1972,6 +1975,7 @@ ivas_error core_switching_pre_dec_fx( } } } +#endif } } -- GitLab From c6a0c9b0903cc5be977e8ef4950cc919fd16c7cb Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sun, 1 Mar 2026 19:41:17 +0100 Subject: [PATCH 2/7] formatting --- lib_com/stat_com.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index 9cc17a482..0ae17b976 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -368,9 +368,9 @@ typedef struct Word16 timeDomainBuffer[L_FRAME16k]; /*Q15*/ #ifndef FIX_BASOP_2262_OLAP_BUFFER_SYNTH_SWITCHING - Word32 olapBufferSynth_fx[FFTLEN]; /*Q_olapBufferSynth*/ + Word32 olapBufferSynth_fx[FFTLEN]; /*Q_olapBufferSynth*/ #endif - Word32 olapBufferSynth2_fx[FFTLEN]; /*Q_olapBufferSynth2*/ + Word32 olapBufferSynth2_fx[FFTLEN]; /*Q_olapBufferSynth2*/ const Word32 *olapWinAna_fx; /* Q30 */ const Word16 *olapWinSyn_fx; /* Q15 */ -- GitLab From 1d036b8c5f1ceefa1b695297628df260a8a88fab Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sun, 1 Mar 2026 20:56:39 +0100 Subject: [PATCH 3/7] replace olapBufferSynth_fx[] by olapBufferSynth[] --- lib_dec/core_switching_dec_fx.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index f1581ba59..52e519b3d 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1919,10 +1919,8 @@ ivas_error core_switching_pre_dec_fx( lerp( st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->last_L_frame, st->hFdCngDec->hFdCngCom->olapBufferAna_fx + st->L_frame, st->L_frame, st->last_L_frame ); } -#ifndef FIX_BASOP_2262_OLAP_BUFFER_SYNTH_SWITCHING IF( EQ_16( st->element_mode, EVS_MONO ) ) { -#endif lerp( st->hFdCngDec->hFdCngCom->olapBufferSynth2, st->hFdCngDec->hFdCngCom->olapBufferSynth2, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ) ); test(); IF( LE_32( st->total_brate, SID_2k40 ) && LE_32( st->last_total_brate, SID_2k40 ) ) @@ -1946,7 +1944,6 @@ ivas_error core_switching_pre_dec_fx( } } } -#ifndef FIX_BASOP_2262_OLAP_BUFFER_SYNTH_SWITCHING } ELSE { @@ -1955,27 +1952,41 @@ ivas_error core_switching_pre_dec_fx( test(); IF( LE_32( st->total_brate, SID_2k40 ) && LE_32( st->last_total_brate, SID_2k40 ) ) { +#ifdef FIX_BASOP_2262_OLAP_BUFFER_SYNTH_SWITCHING + lerp( st->hFdCngDec->hFdCngCom->olapBufferSynth, st->hFdCngDec->hFdCngCom->olapBufferSynth, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ) ); + ( void ) Q_olapBufferSynth; +#else L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth ); +#endif IF( EQ_16( st->L_frame, L_FRAME ) ) { FOR( i = 0; i < shl( st->L_frame, 1 ); i++ ) { +#ifdef FIX_BASOP_2262_OLAP_BUFFER_SYNTH_SWITCHING + st->hFdCngDec->hFdCngCom->olapBufferSynth[i] = mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth[i], 20480 /* Q15*/ ); /* q_olapBuffer */ + move16(); +#else st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], (Word16) 20480 /* 0.6250f in Q15 */ ); move32(); +#endif } } ELSE { FOR( i = 0; i < shl( st->L_frame, 1 ); i++ ) { +#ifdef FIX_BASOP_2262_OLAP_BUFFER_SYNTH_SWITCHING + st->hFdCngDec->hFdCngCom->olapBufferSynth[i] = mult_r( shl( st->hFdCngDec->hFdCngCom->olapBufferSynth[i], 1 ), 26214 /* Q14*/ ); /* q_olapBuffer */ + move16(); +#else st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( L_shl( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], 1 ), (Word16) 26214 /* 1.6f in Q14 */ ); move32(); +#endif } } } } -#endif } } -- GitLab From a2adc11ed51d271f945c851e5fe84553af3433da Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Sun, 1 Mar 2026 20:58:06 +0100 Subject: [PATCH 4/7] formatting --- lib_dec/core_switching_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 52e519b3d..2e89cdc48 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1954,7 +1954,7 @@ ivas_error core_switching_pre_dec_fx( { #ifdef FIX_BASOP_2262_OLAP_BUFFER_SYNTH_SWITCHING lerp( st->hFdCngDec->hFdCngCom->olapBufferSynth, st->hFdCngDec->hFdCngCom->olapBufferSynth, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ) ); - ( void ) Q_olapBufferSynth; + (void) Q_olapBufferSynth; #else L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth ); #endif -- GitLab From 0b195299387ffdbd2075cb3f4423e56c8d88fbd2 Mon Sep 17 00:00:00 2001 From: naghibza Date: Wed, 4 Mar 2026 16:53:51 +0100 Subject: [PATCH 5/7] Modify olapBufferSynth scaling and remove unused Q_olapBufferSynth --- lib_com/prot_fx.h | 2 ++ lib_dec/core_switching_dec_fx.c | 10 +++++++--- lib_dec/ivas_core_dec_fx.c | 7 +++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index b7f81c484..b0f936595 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -7189,7 +7189,9 @@ ivas_error core_switching_pre_dec_fx( const Word16 last_element_mode, /* i : last_element_mode */ const Word32 last_element_brate, /* i : last element bitrate */ const Word16 Q_old_synthFB, +#ifndef FIX_BASOP_2262_OLAP_BUFFER_SYNTH_SWITCHING Word16 *Q_olapBufferSynth, +#endif Word16 *Q_olapBufferSynth2 ); ivas_error core_switching_post_dec_fx( diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 2e89cdc48..2eab8f473 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1158,7 +1158,9 @@ ivas_error core_switching_pre_dec_fx( const Word16 last_element_mode, /* i : last_element_mode */ const Word32 last_element_brate, /* i : last element bitrate */ const Word16 Q_old_synthFB, +#ifndef FIX_BASOP_2262_OLAP_BUFFER_SYNTH_SWITCHING Word16 *Q_olapBufferSynth, +#endif Word16 *Q_olapBufferSynth2 ) { Word32 tmp_fx; /*Q-12*/ @@ -1954,7 +1956,6 @@ ivas_error core_switching_pre_dec_fx( { #ifdef FIX_BASOP_2262_OLAP_BUFFER_SYNTH_SWITCHING lerp( st->hFdCngDec->hFdCngCom->olapBufferSynth, st->hFdCngDec->hFdCngCom->olapBufferSynth, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ) ); - (void) Q_olapBufferSynth; #else L_lerp_fx( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, st->hFdCngDec->hFdCngCom->olapBufferSynth_fx, shl( st->L_frame, 1 ), shl( st->last_L_frame, 1 ), Q_olapBufferSynth ); #endif @@ -1964,7 +1965,7 @@ ivas_error core_switching_pre_dec_fx( FOR( i = 0; i < shl( st->L_frame, 1 ); i++ ) { #ifdef FIX_BASOP_2262_OLAP_BUFFER_SYNTH_SWITCHING - st->hFdCngDec->hFdCngCom->olapBufferSynth[i] = mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth[i], 20480 /* Q15*/ ); /* q_olapBuffer */ + st->hFdCngDec->hFdCngCom->olapBufferSynth[i] = mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth[i], 20480 /* Q15*/ ); /* (Q15 - olapBufferSynth_exp) */ move16(); #else st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], (Word16) 20480 /* 0.6250f in Q15 */ ); @@ -1977,13 +1978,16 @@ ivas_error core_switching_pre_dec_fx( FOR( i = 0; i < shl( st->L_frame, 1 ); i++ ) { #ifdef FIX_BASOP_2262_OLAP_BUFFER_SYNTH_SWITCHING - st->hFdCngDec->hFdCngCom->olapBufferSynth[i] = mult_r( shl( st->hFdCngDec->hFdCngCom->olapBufferSynth[i], 1 ), 26214 /* Q14*/ ); /* q_olapBuffer */ + st->hFdCngDec->hFdCngCom->olapBufferSynth[i] = mult_r( st->hFdCngDec->hFdCngCom->olapBufferSynth[i], 26214 /* Q14*/ ); /* (Q15 - olapBufferSynth_exp) + 1 */ move16(); #else st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( L_shl( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], 1 ), (Word16) 26214 /* 1.6f in Q14 */ ); move32(); #endif } +#ifdef FIX_BASOP_2262_OLAP_BUFFER_SYNTH_SWITCHING + st->hFdCngDec->hFdCngCom->olapBufferSynth_exp = add( st->hFdCngDec->hFdCngCom->olapBufferSynth_exp, 1 ); +#endif } } } diff --git a/lib_dec/ivas_core_dec_fx.c b/lib_dec/ivas_core_dec_fx.c index fbb69eb63..6b8e65671 100644 --- a/lib_dec/ivas_core_dec_fx.c +++ b/lib_dec/ivas_core_dec_fx.c @@ -438,7 +438,13 @@ ivas_error ivas_core_dec_fx( /*---------------------------------------------------------------------* * Preprocessing (preparing) for ACELP/HQ core switching *---------------------------------------------------------------------*/ +#ifdef FIX_BASOP_2262_OLAP_BUFFER_SYNTH_SWITCHING + Word16 Q_olapBufferSynth2; + Q_olapBufferSynth2 = Q15; /*Initializing with max values to avoid warnings*/ + move16(); + IF( NE_32( ( error = core_switching_pre_dec_fx( st, output_frame, sts[0]->last_core_brate, nchan_out, last_element_mode, last_element_brate, st->Q_syn, &Q_olapBufferSynth2 ) ), IVAS_ERR_OK ) ) +#else Word16 Q_olapBufferSynth, Q_olapBufferSynth2; Q_olapBufferSynth = Q15; /*Initializing with max values to avoid warnings*/ @@ -447,6 +453,7 @@ ivas_error ivas_core_dec_fx( move16(); IF( NE_32( ( error = core_switching_pre_dec_fx( st, output_frame, sts[0]->last_core_brate, nchan_out, last_element_mode, last_element_brate, st->Q_syn, &Q_olapBufferSynth, &Q_olapBufferSynth2 ) ), IVAS_ERR_OK ) ) +#endif { return error; } -- GitLab From 12b2cd850fe464a332c3633cbb1d8da98c01ca78 Mon Sep 17 00:00:00 2001 From: naghibza Date: Wed, 4 Mar 2026 17:04:54 +0100 Subject: [PATCH 6/7] Fix core_switching_pre_dec_fx() call args in evs_dec_fx.c --- lib_dec/evs_dec_fx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib_dec/evs_dec_fx.c b/lib_dec/evs_dec_fx.c index 95345a444..dbc450b1f 100644 --- a/lib_dec/evs_dec_fx.c +++ b/lib_dec/evs_dec_fx.c @@ -315,8 +315,11 @@ ivas_error evs_dec_fx( /*---------------------------------------------------------------------* * Preprocessing (preparing) for ACELP/HQ core switching *---------------------------------------------------------------------*/ - +#ifdef FIX_BASOP_2262_OLAP_BUFFER_SYNTH_SWITCHING + IF( ( error = core_switching_pre_dec_fx( st_fx, output_frame, -1, 1, EVS_MONO, EVS_MONO, -1, &tmp16 ) ) != IVAS_ERR_OK ) +#else IF( ( error = core_switching_pre_dec_fx( st_fx, output_frame, -1, 1, EVS_MONO, EVS_MONO, -1, &tmp16, &tmp16 ) ) != IVAS_ERR_OK ) +#endif { return error; } -- GitLab From 8c8581449a700d92811a7df7b45e923a98062cef Mon Sep 17 00:00:00 2001 From: naghibza Date: Wed, 4 Mar 2026 17:50:29 +0100 Subject: [PATCH 7/7] Fix core_switching_pre_dec_fx() call args in amr_wb_dec_fx.c --- lib_dec/amr_wb_dec_fx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_dec/amr_wb_dec_fx.c b/lib_dec/amr_wb_dec_fx.c index 5eef39ba7..b8515e399 100644 --- a/lib_dec/amr_wb_dec_fx.c +++ b/lib_dec/amr_wb_dec_fx.c @@ -173,7 +173,11 @@ ivas_error amr_wb_dec_fx( } /* Updates in case of EVS -> AMR-WB IO switching */ +#ifdef FIX_BASOP_2262_OLAP_BUFFER_SYNTH_SWITCHING + IF( NE_32( ( error = core_switching_pre_dec_fx( st_fx, output_frame, -1, 1, EVS_MONO, EVS_MONO, -1, &tmp16 ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = core_switching_pre_dec_fx( st_fx, output_frame, -1, 1, EVS_MONO, EVS_MONO, -1, &tmp16, &tmp16 ) ), IVAS_ERR_OK ) ) +#endif { return error; } -- GitLab