From 9ec61ece8e4a33f28d0a01b10979bcaafd805c27 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 12 May 2026 09:31:36 +0200 Subject: [PATCH] port FIX_2585_BIT_ALLOCATION_DIFF --- lib_com/gs_bitallocation.c | 16 ++++++++++++---- lib_com/options.h | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib_com/gs_bitallocation.c b/lib_com/gs_bitallocation.c index 9ec211d1f..ef2e4835c 100644 --- a/lib_com/gs_bitallocation.c +++ b/lib_com/gs_bitallocation.c @@ -81,7 +81,7 @@ static void reajust_bits( float *bits_per_bands, const int16_t st_band, const in static Word16 Find_norm_inv( const Word32 ToDivide, Word16 *e_div ); -static Word16 Find_bit_alloc_IVAS_int( const Word32 core_brate, const Word16 GSC_IVAS_mode, const Word16 Diff_len, const Word16 nb_tot_bands, const Word16 L_frame, Word16 *bit, Word16 *max_ener_band, float *ener_vec, float *bits_per_bands ); +static Word16 Find_bit_alloc_IVAS( const Word32 core_brate, const Word16 GSC_IVAS_mode, const Word16 Diff_len, const Word16 nb_tot_bands, const Word16 L_frame, Word16 *bit, Word16 *max_ener_band, float *ener_vec, float *bits_per_bands ); static Word16 maximum_fx( const Word16 *vec_fx, const Word16 lvec_fx, Word16 *max_fx ); @@ -223,7 +223,7 @@ void bands_and_bit_alloc( { if ( GSC_IVAS_mode > 0 ) { - nb_tot_bands = (int16_t) Find_bit_alloc_IVAS_int( (Word32) core_brate, (Word16) GSC_IVAS_mode, (Word16) Diff_len, (Word16) nb_tot_bands, (Word16) L_frame, (Word16 *) bit, (Word16 *) max_ener_band, ener_vec, bits_per_bands ); + nb_tot_bands = (int16_t) Find_bit_alloc_IVAS( (Word32) core_brate, (Word16) GSC_IVAS_mode, (Word16) Diff_len, (Word16) nb_tot_bands, (Word16) L_frame, (Word16 *) bit, (Word16 *) max_ener_band, ener_vec, bits_per_bands ); nb_bands = nb_tot_bands; } else if ( GSC_noisy_speech ) @@ -789,13 +789,13 @@ static float Find_bit_frac( /*-------------------------------------------------------------------* - * Find_bit_alloc_IVAS_int() + * Find_bit_alloc_IVAS() * * *-------------------------------------------------------------------*/ /*! r: Number of bands to encode */ -static Word16 Find_bit_alloc_IVAS_int( +static Word16 Find_bit_alloc_IVAS( const Word32 core_brate, /* i : core bit rate */ const Word16 GSC_IVAS_mode, /* i : GSC IVAS mode */ const Word16 Diff_len, /* i : Length of the difference signal (before pure spectral)*/ @@ -1022,13 +1022,21 @@ static Word16 Find_bit_alloc_IVAS_int( sum_bit = L_add( sum_bit, L_sub( bits_per_bands[i], Q18_112 ) ); /* bits_per_bands[i] = 112; */ bits_per_bands[i] = Q18_112; +#ifndef FIX_2585_BIT_ALLOCATION_DIFF j = add( j, add( i, 1 ) ); +#else + j = add( i, 1 ); +#endif } /* safety check for overage bit reallocation */ /* else if (bits_per_bands[i] + sum_bit / 3 > 112) */ else if ( L_add( bits_per_bands[i], Mpy_32_16_1( sum_bit, Q15_0_33 ) ) > Q18_112 ) { +#ifndef FIX_2585_BIT_ALLOCATION_DIFF j = add( j, add( i, 1 ) ); +#else + j = add( i, 1 ); +#endif } } diff --git a/lib_com/options.h b/lib_com/options.h index a24b82b9a..f9703206b 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -182,6 +182,7 @@ #define FIX_FMSW_DEC_2 /* float issue 1575: fix crash for format switching when bitsream starts with EVS */ #define FIX_1548_HARMONIZE_NON_DIEGETIC_PANNING_LAW /* Orange: float issue 1548: Harmonize non diegetic panning law in ISM and renderers */ #define FIX_FLOAT_1578_OMASA_REND_SPIKES /* Nokia: Float issue 1578: Fix spikes and collapsed perception in OMASA/MASA rendering to FOA/HOA */ +#define FIX_2585_BIT_ALLOCATION_DIFF /* VA : issue 2585, bit allocation different behaviors between float and fixed-point for corner cases */ /* ##################### End NON-BE switches ########################### */ -- GitLab