diff --git a/lib_com/gs_bitallocation_fx.c b/lib_com/gs_bitallocation_fx.c index 67dde91377b1b4cbaf0a159f29e7b211209895c2..4f8db943a87e3ac1fe9bf94671380238c6cb783e 100644 --- a/lib_com/gs_bitallocation_fx.c +++ b/lib_com/gs_bitallocation_fx.c @@ -1135,14 +1135,22 @@ static Word16 Find_bit_alloc_IVAS_fx( /* bits_per_bands[i] = 112; */ bits_per_bands[i] = Q18_112; move32(); +#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( GT_32( 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/ivas_stereo_td_bit_alloc_fx.c b/lib_com/ivas_stereo_td_bit_alloc_fx.c index 45dfb3110223d8c83886c107cec362b670a38c91..8b1b892cf49d4fc2d85db4614973793ebe537010 100644 --- a/lib_com/ivas_stereo_td_bit_alloc_fx.c +++ b/lib_com/ivas_stereo_td_bit_alloc_fx.c @@ -204,13 +204,25 @@ void tdm_bit_alloc( } ELSE { +#ifdef FIX_2585_BIT_ALLOCATION_DIFF + Word16 neg = 0; + move16(); + if ( bit_rate_diff_fx < 0 ) + { + neg = 1; + move16(); + } +#endif IF( LT_16( ener_ratio_idx, LRTD_STEREO_MID_IS_PRIM ) ) { - bit_rate_diff_fx = imult3216( bit_rate_diff_fx, sub( LRTD_STEREO_MID_IS_PRIM, ener_ratio_idx ) ); /*Q0*/ bit_rate_diff_fx = L_shr( bit_rate_diff_fx, 1 ); /*Q0*/ bit_rate_diff_fx = Mpy_32_16_1( L_abs( bit_rate_diff_fx ), 3277 /*0.1f in Q15*/ ); /*Q0*/ +#ifdef FIX_2585_BIT_ALLOCATION_DIFF + if ( neg != 0 ) +#else if ( bit_rate_diff_fx < 0 ) +#endif { bit_rate_diff_fx = L_negate( bit_rate_diff_fx ); } @@ -220,7 +232,11 @@ void tdm_bit_alloc( bit_rate_diff_fx = imult3216( bit_rate_diff_fx, sub( ener_ratio_idx, LRTD_STEREO_MID_IS_PRIM ) ); /*Q0*/ bit_rate_diff_fx = L_shr( bit_rate_diff_fx, 1 ); /*Q0*/ bit_rate_diff_fx = Mpy_32_16_1( L_abs( bit_rate_diff_fx ), 3277 /*0.1f in Q15*/ ); /*Q0*/ +#ifdef FIX_2585_BIT_ALLOCATION_DIFF + if ( neg != 0 ) +#else if ( bit_rate_diff_fx < 0 ) +#endif { bit_rate_diff_fx = L_negate( bit_rate_diff_fx ); } @@ -322,7 +338,11 @@ void tdm_bit_alloc( *tdm_low_rate_mode = 0; move16(); } +#ifndef FIX_2585_BIT_ALLOCATION_DIFF ELSE IF( ( tdm_lp_reuse_flag == 0 && LT_32( *total_brate_sec, TDM_UC_NORMAL_MODE_MINBR_LP_R ) && EQ_16( coder_type, UNVOICED ) ) || ( tdm_lp_reuse_flag == 0 && LE_32( *total_brate_sec, L_deposit_l( add( tdm_bit_allc_tbl[idx][0], MID_LP_BRATE ) ) ) ) ) +#else + ELSE IF( ( tdm_lp_reuse_flag == 0 && LT_32( *total_brate_sec, TDM_UC_NORMAL_MODE_MINBR_LP_R ) && EQ_16( coder_type, UNVOICED ) ) || ( tdm_lp_reuse_flag == 0 && LT_32( *total_brate_sec, L_deposit_l( add( tdm_bit_allc_tbl[idx][0], MID_LP_BRATE ) ) ) ) ) +#endif { *total_brate_sec = L_add( *total_brate_sec, MID_LP_BRATE ); /*Q0*/ move32(); diff --git a/lib_com/options.h b/lib_com/options.h index c357e4d4dd2e9b3c620b3af24d3826d88fc7f4ac..e5042faace88b3868c694fef5a4a9fb41e176329 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -48,7 +48,7 @@ /* ################### Start DEBUGGING switches ######################## */ #ifndef RELEASE -/*#define DEBUGGING*/ /* Activate debugging part of the code */ +/* #define DEBUGGING */ /* Activate debugging part of the code */ #endif /*#define WMOPS*/ /* Activate complexity and memory counters */ /*#define WMOPS_PER_FRAME*/ /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */ @@ -134,6 +134,8 @@ #define FIX_1521_SBA_LOUDNESS_STEREO /* FhG: issue 1521: Fix loudness for SBA to stereo rendering */ #define FIX_1559 /* Eri/FhG: fix for Issue 1559 in FD CNG with bitrate/bw switching */ +#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 ########################### */ /* ################## End MAINTENANCE switches ######################### */