Loading lib_com/basop_util.c +38 −0 Original line number Diff line number Diff line Loading @@ -267,9 +267,11 @@ void BASOP_Util_Divide_MantExp( Word16 a_m, /*!< Mantissa of dividend a Word16 preShift, postShift; Word16 m; Word32 m32; #ifndef ISSUE_1836_replace_overflow_libcom #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; #endif #endif assert( b_m != 0 ); Loading Loading @@ -303,7 +305,11 @@ void BASOP_Util_Divide_MantExp( Word16 a_m, /*!< Mantissa of dividend a /* normalize result */ postShift = norm_l( m32 ); #ifdef ISSUE_1836_replace_overflow_libcom m = round_fx_sat( L_shl( m32, postShift ) ); #else m = round_fx_o( L_shl( m32, postShift ), &Overflow ); #endif /* exponent */ *ptrResult_e = sub( add( add( a_e, sub( 1, b_e ) ), preShift ), postShift ); Loading @@ -319,7 +325,9 @@ static Word16 Sqrt16_common( Word16 m, Word16 e ) { Word16 index, frac; #ifndef ISSUE_1836_replace_overflow_libcom Flag Overflow; #endif assert( ( m >= 0x4000 ) || ( m == 0 ) ); Loading @@ -334,9 +342,13 @@ static Word16 Sqrt16_common( Word16 m, /* interpolate */ if ( m != 0 ) { #ifdef ISSUE_1836_replace_overflow_libcom m = mac_r_sat( SqrtTable[index], SqrtDiffTable[index], frac ); #else BASOP_SATURATE_WARNING_OFF_EVS; m = mac_ro( SqrtTable[index], SqrtDiffTable[index], frac, &Overflow ); BASOP_SATURATE_WARNING_ON_EVS; #endif } /* handle odd exponents */ Loading @@ -352,13 +364,19 @@ static Word32 Sqrt32_common( Word32 m, Word16 e ) { Word16 m16, index, frac; #ifndef ISSUE_1836_replace_overflow_libcom #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; #endif #endif assert( ( m >= 0x40000000 ) || ( m == 0 ) ); #ifdef ISSUE_1836_replace_overflow_libcom m16 = round_fx_sat( m ); #else m16 = round_fx_o( m, &Overflow ); #endif /* get table index (upper 6 bits minus 32) */ /* index = (m16 >> 9) - 32; */ Loading Loading @@ -414,16 +432,23 @@ static Word32 ISqrt32_common( Word32 m, Word16 e ) { Word16 m16, index, frac; #ifndef ISSUE_1836_replace_overflow_libcom #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; #endif #endif assert( m >= 0x40000000 ); #ifdef ISSUE_1836_replace_overflow_libcom m16 = round_fx_sat( m ); #else #ifdef BASOP_NOGLOB_DECLARE_LOCAL m16 = round_fx_o( m, &Overflow ); #else m16 = round_fx( m ); #endif #endif /* get table index (upper 6 bits minus 32) */ /* index = (m16 >> 25) - 32; */ Loading Loading @@ -890,9 +915,11 @@ Word16 divide3232( Word32 L_num, Word32 L_denom ) { Word16 z; Word32 sign; #ifndef ISSUE_1836_replace_overflow_libcom #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; #endif #endif sign = L_and( L_xor( L_num, L_denom ), (Word32) 0x80000000 ); Loading @@ -906,7 +933,11 @@ Word16 divide3232( Word32 L_num, Word32 L_denom ) L_denom = L_shl( L_denom, z ); /* round_fx instead of extract_h improves spectral distortion in E_UTIL_lev_dur (schur version). */ #ifdef ISSUE_1836_replace_overflow_libcom z = div_l( L_num, round_fx_sat( L_denom ) ); #else z = div_l( L_num, round_fx_o( L_denom, &Overflow ) ); #endif if ( 0 != sign ) { z = negate( z ); Loading Loading @@ -2054,14 +2085,21 @@ Word32 norm_llQ31( /* o : normalized result Q31 */ Word16 i; Word32 L_tmp; #ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifndef ISSUE_1836_replace_overflow_libcom Flag Overflow = 0; #endif Flag Carry = 0; #endif /* BASOP_NOGLOB */ /* Move MSBit of L_sum into L_c */ Carry = 0; #ifdef ISSUE_1836_replace_overflow_libcom L_tmp = L_add_c( L_sum, L_sum, &Carry ); /* L_tmp = L_sum << 1 */ L_c = L_add_c( L_c, L_c, &Carry ); #else L_tmp = L_add_co( L_sum, L_sum, &Carry, &Overflow ); /* L_tmp = L_sum << 1 */ L_c = L_add_co( L_c, L_c, &Carry, &Overflow ); #endif L_add( 0, 0 ); test(); IF( ( L_c != (Word32) 0L ) && ( L_c != (Word32) 0xFFFFFFFFL ) ) Loading Loading
lib_com/basop_util.c +38 −0 Original line number Diff line number Diff line Loading @@ -267,9 +267,11 @@ void BASOP_Util_Divide_MantExp( Word16 a_m, /*!< Mantissa of dividend a Word16 preShift, postShift; Word16 m; Word32 m32; #ifndef ISSUE_1836_replace_overflow_libcom #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; #endif #endif assert( b_m != 0 ); Loading Loading @@ -303,7 +305,11 @@ void BASOP_Util_Divide_MantExp( Word16 a_m, /*!< Mantissa of dividend a /* normalize result */ postShift = norm_l( m32 ); #ifdef ISSUE_1836_replace_overflow_libcom m = round_fx_sat( L_shl( m32, postShift ) ); #else m = round_fx_o( L_shl( m32, postShift ), &Overflow ); #endif /* exponent */ *ptrResult_e = sub( add( add( a_e, sub( 1, b_e ) ), preShift ), postShift ); Loading @@ -319,7 +325,9 @@ static Word16 Sqrt16_common( Word16 m, Word16 e ) { Word16 index, frac; #ifndef ISSUE_1836_replace_overflow_libcom Flag Overflow; #endif assert( ( m >= 0x4000 ) || ( m == 0 ) ); Loading @@ -334,9 +342,13 @@ static Word16 Sqrt16_common( Word16 m, /* interpolate */ if ( m != 0 ) { #ifdef ISSUE_1836_replace_overflow_libcom m = mac_r_sat( SqrtTable[index], SqrtDiffTable[index], frac ); #else BASOP_SATURATE_WARNING_OFF_EVS; m = mac_ro( SqrtTable[index], SqrtDiffTable[index], frac, &Overflow ); BASOP_SATURATE_WARNING_ON_EVS; #endif } /* handle odd exponents */ Loading @@ -352,13 +364,19 @@ static Word32 Sqrt32_common( Word32 m, Word16 e ) { Word16 m16, index, frac; #ifndef ISSUE_1836_replace_overflow_libcom #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; #endif #endif assert( ( m >= 0x40000000 ) || ( m == 0 ) ); #ifdef ISSUE_1836_replace_overflow_libcom m16 = round_fx_sat( m ); #else m16 = round_fx_o( m, &Overflow ); #endif /* get table index (upper 6 bits minus 32) */ /* index = (m16 >> 9) - 32; */ Loading Loading @@ -414,16 +432,23 @@ static Word32 ISqrt32_common( Word32 m, Word16 e ) { Word16 m16, index, frac; #ifndef ISSUE_1836_replace_overflow_libcom #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; #endif #endif assert( m >= 0x40000000 ); #ifdef ISSUE_1836_replace_overflow_libcom m16 = round_fx_sat( m ); #else #ifdef BASOP_NOGLOB_DECLARE_LOCAL m16 = round_fx_o( m, &Overflow ); #else m16 = round_fx( m ); #endif #endif /* get table index (upper 6 bits minus 32) */ /* index = (m16 >> 25) - 32; */ Loading Loading @@ -890,9 +915,11 @@ Word16 divide3232( Word32 L_num, Word32 L_denom ) { Word16 z; Word32 sign; #ifndef ISSUE_1836_replace_overflow_libcom #ifdef BASOP_NOGLOB_DECLARE_LOCAL Flag Overflow = 0; #endif #endif sign = L_and( L_xor( L_num, L_denom ), (Word32) 0x80000000 ); Loading @@ -906,7 +933,11 @@ Word16 divide3232( Word32 L_num, Word32 L_denom ) L_denom = L_shl( L_denom, z ); /* round_fx instead of extract_h improves spectral distortion in E_UTIL_lev_dur (schur version). */ #ifdef ISSUE_1836_replace_overflow_libcom z = div_l( L_num, round_fx_sat( L_denom ) ); #else z = div_l( L_num, round_fx_o( L_denom, &Overflow ) ); #endif if ( 0 != sign ) { z = negate( z ); Loading Loading @@ -2054,14 +2085,21 @@ Word32 norm_llQ31( /* o : normalized result Q31 */ Word16 i; Word32 L_tmp; #ifdef BASOP_NOGLOB_DECLARE_LOCAL #ifndef ISSUE_1836_replace_overflow_libcom Flag Overflow = 0; #endif Flag Carry = 0; #endif /* BASOP_NOGLOB */ /* Move MSBit of L_sum into L_c */ Carry = 0; #ifdef ISSUE_1836_replace_overflow_libcom L_tmp = L_add_c( L_sum, L_sum, &Carry ); /* L_tmp = L_sum << 1 */ L_c = L_add_c( L_c, L_c, &Carry ); #else L_tmp = L_add_co( L_sum, L_sum, &Carry, &Overflow ); /* L_tmp = L_sum << 1 */ L_c = L_add_co( L_c, L_c, &Carry, &Overflow ); #endif L_add( 0, 0 ); test(); IF( ( L_c != (Word32) 0L ) && ( L_c != (Word32) 0xFFFFFFFFL ) ) Loading