From c444ec22173c1c009b252c47a0d5e1f53c6ac177 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 14:49:47 +0100 Subject: [PATCH 1/3] replace erroneous division by if-else-statemment --- lib_com/options.h | 1 + lib_enc/ivas_cpe_enc_fx.c | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index a1ac29acd..0ee88e0ec 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -133,6 +133,7 @@ #define FIX_2261_REMOVE_LP_RESCALING /* VA: Remove of unnecessary lpc coefficient rescaling */ #define FIX_2320_OOB_SCE_SWITCHING /* VA: basop issue 2320: Correct the length of the buffer to be scaled in SCE/CPE switching */ #define FIX_2302_LSF_CDBK_THRESHOLD /* VA: basop issue 2302: fix threshold for LSF Q codebook-type decision */ +#define FIX_2362_TOTAL_BRATE_CALCULATION /* FhG: basop issue 2362: fix calculation of st->total_brate in ivas_cpe_enc_fx() */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index ef7e3f83e..5179b10e8 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -632,7 +632,20 @@ ivas_error ivas_cpe_enc_fx( { sts[n]->bits_frame_nominal = extract_l( Mpy_32_32_r( hCPE->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ); /* Q0 */ sts[n]->bits_frame_channel = idiv1616( extract_l( Mpy_32_32_r( hCPE->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) ), n_CoreChannels ); /* Q0 */ - sts[n]->total_brate = L_shl( div_l( hCPE->element_brate, n_CoreChannels ), 1 ); /* Q0 */ +#ifdef FIX_2362_TOTAL_BRATE_CALCULATION + /* sts[n]->total_brate = hCPE->element_brate / n_CoreChannels; */ + assert( n_CoreChannels == 1 || n_CoreChannels == 2 ); + IF( n_CoreChannels == 1 ) + { + sts[n]->total_brate = hCPE->element_brate; + } + ELSE IF( n_CoreChannels == 2 ) + { + sts[n]->total_brate = L_shr( hCPE->element_brate, 1 ); + } +#else + sts[n]->total_brate = L_shl( div_l( hCPE->element_brate, n_CoreChannels ), 1 ); /* Q0 */ +#endif move32(); move16(); move16(); -- GitLab From f15a0e6814acd5ab707bdcac48c40124dbb1300c Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Wed, 21 Jan 2026 15:18:42 +0100 Subject: [PATCH 2/3] small optimization of patch --- lib_enc/ivas_cpe_enc_fx.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib_enc/ivas_cpe_enc_fx.c b/lib_enc/ivas_cpe_enc_fx.c index 5179b10e8..46e21a087 100644 --- a/lib_enc/ivas_cpe_enc_fx.c +++ b/lib_enc/ivas_cpe_enc_fx.c @@ -635,11 +635,8 @@ ivas_error ivas_cpe_enc_fx( #ifdef FIX_2362_TOTAL_BRATE_CALCULATION /* sts[n]->total_brate = hCPE->element_brate / n_CoreChannels; */ assert( n_CoreChannels == 1 || n_CoreChannels == 2 ); - IF( n_CoreChannels == 1 ) - { - sts[n]->total_brate = hCPE->element_brate; - } - ELSE IF( n_CoreChannels == 2 ) + sts[n]->total_brate = hCPE->element_brate; + if ( n_CoreChannels == 2 ) { sts[n]->total_brate = L_shr( hCPE->element_brate, 1 ); } -- GitLab From f7d7b9fa793ec1306db899ab9a94aea179c76279 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 22 Jan 2026 17:20:01 +0100 Subject: [PATCH 3/3] move swich to correct section --- 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 a663938f9..208ca7b72 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,6 +103,7 @@ #define HARM_COREDECODER_FUNCTIONS /* VA: basop issue 2347: Remove various duplicated code in core-decoder */ #define FIX_BASOP_2351_EXTREND_SCALE /* FhG: basop issue 2351: Only scale initialized samples in renderer, related to 2326 */ #define FIX_2331_CLANG18_MSAN_UNINIT_VARIABLE /* FhG: Fix issue 2331: Uninitialized variable */ +#define FIX_2362_TOTAL_BRATE_CALCULATION /* FhG: basop issue 2362: fix calculation of st->total_brate in ivas_cpe_enc_fx() */ /* #################### End BE switches ################################## */ @@ -112,7 +113,6 @@ #define FIX_2250_LARGE_DIFFERENCES_BETWEEN_BASOP_AND_FLOAT /* Dolby: Issue 2250: random vector generation in GenShapedSHBExcitation() */ #define FIX_2320_OOB_SCE_SWITCHING /* VA: basop issue 2320: Correct the length of the buffer to be scaled in SCE/CPE switching */ #define FIX_2302_LSF_CDBK_THRESHOLD /* VA: basop issue 2302: fix threshold for LSF Q codebook-type decision */ -#define FIX_2362_TOTAL_BRATE_CALCULATION /* FhG: basop issue 2362: fix calculation of st->total_brate in ivas_cpe_enc_fx() */ /* ##################### End NON-BE switches ########################### */ -- GitLab