diff --git a/lib_com/cnst.h b/lib_com/cnst.h index cf1a7820f868b97acce348b592673e7f564030e8..97dd19f18105dfc973816c5a85c67b62a91c46b3 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -2787,12 +2787,15 @@ enum #define Fs_2_16k 20480 /* lsf max value (Use in reorder_fx.c) */ #define LG10 24660 /* 10*log10(2) in Q13 */ -#define TEN_MULT_LOG10_2_IN_Q29 1616142464 /* (10 * log10(2)) = 3.0103 (in Q29) */ +#define TEN_MULT_LOG10_2_IN_Q29 1616142464 /* (10 * log10(2)) = 3.0103 (in Q29) */ #define LG10_s3_0 16440 /* 10*log10(2)/1.55 = 1.00343331 in Q14 */ -#define LOG2_10 27213 /* log base 2 of 10 in Q12 */ -#define LOG2_10_Q29 1783446566 /* log base 2 of 10 in Q12 */ -#define LOG10_2_Q31 646456993 /* inverse log base 10 of 2 in Q31 */ -#define MU_MA_FX 10923 /* original prediction factor for the AMR WB tables (Q15) */ +#define LOG2_10 27213 /* log base 2 of 10 in Q12 */ +#define LOG2_10_Q29 1783446566 /* log base 2 of 10 in Q12 */ +#define LOG10_2_Q31 646456993 /* inverse log base 10 of 2 in Q31 */ +#ifdef FIX_2210_ASSERT_IN_BW_DETEC_FX_FOR_OMASA +#define INV_LOG2_10 9864 /* 1/log2(10), Q15*/ +#endif +#define MU_MA_FX 10923 /* original prediction factor for the AMR WB tables (Q15) */ #define E_MIN_FXQ15 115 /* Q15*/ #define E_MIN_FXQ31 7516193 /* 0.0035d in Q31*/ diff --git a/lib_com/options.h b/lib_com/options.h index 9fb081849f8786f35b1a92177f38697fbeaed885..da5b38dfb899b8a6872bae9ac30558bbd1f0736d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -73,6 +73,7 @@ #endif /* ################### Start FIXES switches ########################### */ +/*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ #define REMOVE_BASOP_Util_Divide3232_Scale_cadence /* remove this division variant */ #define FIX_1990_SANITIZER_IN_REVERB_LOAD /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure - keep until #2059 is addressed */ #define FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK /* Eri: Issue 1999: Range check on float values of distance attenuation, while the float values are not propagated to this function. The test is not correct, but configurable distance attenuation is not used in Characterization.*/ @@ -103,7 +104,7 @@ #define FIX_2184_EVS_STEREO_DMX_CHANNEL_DISAPPEARING /* Orange: Fix for issue 2184 - to prevent one channel from becoming inaudible in the mono downmix output */ #define FIX_2148_OBJ_EDIT_ISSUE_WITH_OSBA /* Nokia: Add missing code to solve issue */ #define FIX_2200_ISAR_PLC_CRASH /* Dolby: Fix for ISAR PLC crash observed with newly added BASOP tests */ - +#define FIX_2210_ASSERT_IN_BW_DETEC_FX_FOR_OMASA /* FhG: Resolve overflow by swapping the order of addition and multiplication */ /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_enc/bw_detect_fx.c b/lib_enc/bw_detect_fx.c index 49391f60f7d0fc3485c737453dc621b215c9d0c3..08ad0714996d0f70d30669d720a8cf2c2c946f8e 100644 --- a/lib_enc/bw_detect_fx.c +++ b/lib_enc/bw_detect_fx.c @@ -55,7 +55,11 @@ void bw_detect_fx( Word16 spect[L_FRAME48k], spect_bin[BWD_N_BINS_MAX]; Word32 spect32[L_FRAME48k], in_win32[BWD_TOTAL_WIDTH]; Word16 e_tmp, f_tmp; +#ifdef FIX_2210_ASSERT_IN_BW_DETEC_FX_FOR_OMASA + Word32 L_tmp, sum32, L_tmp_q_shift; +#else Word32 L_tmp, sum32; +#endif Word32 L_tmp1, L_tmp2, L_tmp3; Word16 scale; @@ -131,12 +135,17 @@ void bw_detect_fx( } #endif L_tmp = BASOP_Util_Log2( cldfb_bin[0] ); /*(log2(660423549*2^(-31))/64)*2^31*/ -#ifdef FIX_2141_ASSERT_IN_OMASA_BITRATE_SWITSCHING - L_tmp = L_add_sat( L_tmp, L_shl_sat( L_deposit_l( cldfb_bin_Exp[0] ), 31 - LD_DATA_SCALE ) ); /* Q25 */ +#ifdef FIX_2210_ASSERT_IN_BW_DETEC_FX_FOR_OMASA + L_tmp = Mpy_32_16_1( L_tmp, INV_LOG2_10 ); // instead of adding it to L_tmp_q_shift and then multiplying by INV_LOG2_10 ( to avoid saturation ). + + L_tmp_q_shift = L_shl_sat( L_deposit_l( cldfb_bin_Exp[0] ), 31 - LD_DATA_SCALE ); // This term should be added to L_temp to align it to Q25 + L_tmp_q_shift = Mpy_32_16_1( L_tmp_q_shift, INV_LOG2_10 ); // instead of adding it to L_tmp and then multiplying by INV_LOG2_10 ( to avoid saturation ). + + cldfb_bin[0] = L_add( L_tmp, L_tmp_q_shift ); /* Q25 */ #else - L_tmp = L_add_sat( L_tmp, L_shl( L_deposit_l( cldfb_bin_Exp[0] ), 31 - LD_DATA_SCALE ) ); /* Q25 */ -#endif + L_tmp = L_add_sat( L_tmp, L_shl( L_deposit_l( cldfb_bin_Exp[0] ), 31 - LD_DATA_SCALE ) ); /* Q25 */ cldfb_bin[0] = Mpy_32_16_1( L_tmp, 9864 /*1.0f/3.3219280948873623478703194294894f Q15*/ ); +#endif move32(); /* 1/log2(10) */ /* Q25 */ /* WB: 4.4 - 7.2 kHz, 8 cldfb-bands, mid band(14) counted twice */ @@ -165,12 +174,17 @@ void bw_detect_fx( move32(); } L_tmp = BASOP_Util_Log2( cldfb_bin[i] ); /*(log2(660423549*2^(-31))/64)*2^31*/ -#ifdef FIX_2141_ASSERT_IN_OMASA_BITRATE_SWITSCHING - L_tmp = L_add( L_tmp, L_shl_sat( L_deposit_l( cldfb_bin_Exp[i] ), 31 - LD_DATA_SCALE ) ); /* Q25 */ +#ifdef FIX_2210_ASSERT_IN_BW_DETEC_FX_FOR_OMASA + L_tmp = Mpy_32_16_1( L_tmp, INV_LOG2_10 ); // instead of adding it to L_tmp_q_shift and then multiplying by INV_LOG2_10 ( to avoid saturation ). + + L_tmp_q_shift = L_shl_sat( L_deposit_l( cldfb_bin_Exp[i] ), 31 - LD_DATA_SCALE ); // This term should be added to L_temp to align it to Q25 + L_tmp_q_shift = Mpy_32_16_1( L_tmp_q_shift, INV_LOG2_10 ); // instead of adding it to L_tmp and then multiplying by INV_LOG2_10 ( to avoid saturation ). + + cldfb_bin[i] = L_add( L_tmp, L_tmp_q_shift ); /* Q25 */ #else L_tmp = L_add( L_tmp, L_shl( L_deposit_l( cldfb_bin_Exp[i] ), 31 - LD_DATA_SCALE ) ); /* Q25 */ -#endif cldfb_bin[i] = Mpy_32_16_1( L_tmp, 9864 /*1.0f/3.3219280948873623478703194294894f Q15*/ ); +#endif move32(); /* 1/log2(10) */ /* Q25 */ } } @@ -208,12 +222,17 @@ void bw_detect_fx( move32(); } L_tmp = BASOP_Util_Log2( cldfb_bin[i] ); /*(log2(660423549*2^(-31))/64)*2^31*/ -#ifdef FIX_2141_ASSERT_IN_OMASA_BITRATE_SWITSCHING - L_tmp = L_add( L_tmp, L_shl_sat( L_deposit_l( cldfb_bin_Exp[i] ), 31 - LD_DATA_SCALE ) ); /* Q25 */ +#ifdef FIX_2210_ASSERT_IN_BW_DETEC_FX_FOR_OMASA + L_tmp = Mpy_32_16_1( L_tmp, INV_LOG2_10 ); // instead of adding it to L_tmp_q_shift and then multiplying by INV_LOG2_10 ( to avoid saturation ). + + L_tmp_q_shift = L_shl_sat( L_deposit_l( cldfb_bin_Exp[i] ), 31 - LD_DATA_SCALE ); // This term should be added to L_temp to align it to Q25 + L_tmp_q_shift = Mpy_32_16_1( L_tmp_q_shift, INV_LOG2_10 ); // instead of adding it to L_tmp and then multiplying by INV_LOG2_10 ( to avoid saturation ). + + cldfb_bin[i] = L_add( L_tmp, L_tmp_q_shift ); /* Q25 */ #else L_tmp = L_add( L_tmp, L_shl( L_deposit_l( cldfb_bin_Exp[i] ), 31 - LD_DATA_SCALE ) ); /* Q25 */ -#endif cldfb_bin[i] = Mpy_32_16_1( L_tmp, 9864 /*1.0f/3.3219280948873623478703194294894f Q15*/ ); +#endif move32(); /* 1/log2(10) */ /* Q25 */ } } @@ -245,12 +264,17 @@ void bw_detect_fx( move32(); } L_tmp = BASOP_Util_Log2( cldfb_bin[i] ); /*(log2(660423549*2^(-31))/64)*2^31*/ -#ifdef FIX_2141_ASSERT_IN_OMASA_BITRATE_SWITSCHING - L_tmp = L_add( L_tmp, L_shl_sat( L_deposit_l( cldfb_bin_Exp[i] ), 31 - LD_DATA_SCALE ) ); /* Q25 */ +#ifdef FIX_2210_ASSERT_IN_BW_DETEC_FX_FOR_OMASA + L_tmp = Mpy_32_16_1( L_tmp, INV_LOG2_10 ); // instead of adding it to L_tmp_q_shift and then multiplying by INV_LOG2_10 ( to avoid saturation ). + + L_tmp_q_shift = L_shl_sat( L_deposit_l( cldfb_bin_Exp[i] ), 31 - LD_DATA_SCALE ); // This term should be added to L_temp to align it to Q25 + L_tmp_q_shift = Mpy_32_16_1( L_tmp_q_shift, INV_LOG2_10 ); // instead of adding it to L_tmp and then multiplying by INV_LOG2_10 ( to avoid saturation ). + + cldfb_bin[i] = L_add( L_tmp, L_tmp_q_shift ); /* Q25 */ #else L_tmp = L_add( L_tmp, L_shl( L_deposit_l( cldfb_bin_Exp[i] ), 31 - LD_DATA_SCALE ) ); /* Q25 */ -#endif cldfb_bin[i] = Mpy_32_16_1( L_tmp, 9864 /*1.0f/3.3219280948873623478703194294894f Q15*/ ); +#endif move32(); /* 1/log2(10) */ /* Q25 */ } }