Loading apps/renderer.c +1 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ #include "split_rend_bfi_file_reader.h" #include "vector3_pair_file_reader.h" #include "wmc_auto.h" #include "basop32.h" #define WMC_TOOL_SKIP Loading lib_com/arith_coder_fx.c +4 −0 Original line number Diff line number Diff line Loading @@ -271,7 +271,11 @@ void tcx_arith_scale_envelope( tmp2 = BASOP_Util_Add_MantExp( negate( b ), b_e, tmp, tmp2, &scale ); /* exp(scale) */ scale = BASOP_Util_Divide1616_Scale( scale, round_fx( a ), &tmp ); #ifdef ISSUE_1796_replace_shl_o scale = shl_sat( scale, sub( sub( add( tmp, tmp2 ), a_e ), 1 ) ); /* Q15 */ #else scale = shl_o( scale, sub( sub( add( tmp, tmp2 ), a_e ), 1 ), &Overflow ); /* Q15 */ #endif /* iscale = 1.0f / scale; */ iscale_e = 0; Loading lib_com/basop32.c +1 −1 Original line number Diff line number Diff line Loading @@ -1268,7 +1268,7 @@ Word16 round_fx( Word32 L_var1 ) Word32 L_rounded; BASOP_SATURATE_WARNING_OFF L_rounded = L_add( L_var1, (Word32) 0x00008000L ); L_rounded = L_add_sat( L_var1, (Word32) 0x00008000L ); BASOP_SATURATE_WARNING_ON var_out = extract_h( L_rounded ); Loading lib_com/basop_util.c +21 −0 Original line number Diff line number Diff line Loading @@ -2085,6 +2085,8 @@ Word32 norm_llQ31( /* o : normalized result Q31 */ return L_sum; } #ifndef FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW /* note: now available in basop_util.h */ Word32 w_norm_llQ31( Word64 L_sum, Word16 *exp ); Word32 w_norm_llQ31( /* o : normalized result Q31 */ Word64 L_sum, /* i : upper and lower bits of accu, unsigned Q31 */ Loading @@ -2111,6 +2113,7 @@ Word32 w_norm_llQ31( /* o : normalized result Q31 */ L_tmp = W_extract_h( L64_inp64 ); return L_tmp; } #endif Word32 Dot_product16HQ( /* o : normalized result Q31 */ const Word32 L_off, /* i : initial sum value Qn */ Loading @@ -2135,6 +2138,24 @@ Word32 Dot_product16HQ( /* o : normalized result return L_sum; } Word32 sum_array_norm( /* o : normalized result Q31 */ const Word32 x[], /* i : x vector Qn */ const Word16 lg, /* i : vector length, range [0..7FFF] Q0 */ Word16 *exp /* o : exponent of result in [-32,31] Q0 */ ) { Word16 i; Word64 W_tmp = 0; Word32 L_tmp; FOR( i = 0; i < lg; i++ ) { W_tmp = W_add( W_tmp, x[i] ); /*Q31*/ } L_tmp = w_norm_llQ31( W_tmp, exp ); /*Q31 - *exp*/ return L_tmp; } Word32 Norm32Norm( const Word32 *x, const Word16 headroom, const Word16 length, Word16 *result_e ) { Word32 L_tmp, L_tmp2; Loading lib_com/basop_util.h +31 −0 Original line number Diff line number Diff line Loading @@ -612,6 +612,20 @@ Word32 Dot_product16HQ( /*<! o : normalized result Word16 *exp /*<! o : exponent of result in [-32,31] Q0 */ ); /*------------------------------------------------------------------* * sum_array_norm: * * \brief Compute array summation of x[] using 64-bit accumulator. * * Performs normalization of the result, returns the exponent * Note: no headroom is required for data in x[] *------------------------------------------------------------------*/ Word32 sum_array_norm( /* o : normalized result Q31 */ const Word32 x[], /* i : x vector Qn */ const Word16 lg, /* i : vector length, range [0..7FFF] Q0 */ Word16 *exp /* o : exponent of result in [-32,31] Q0 */ ); /*------------------------------------------------------------------* * norm_llQ31: * Loading @@ -627,6 +641,23 @@ Word32 norm_llQ31( /* o : normalized result Q31 */ Word16 *exp /* o : exponent of result in [-32,31] Q0 */ ); #ifdef FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW /*------------------------------------------------------------------* * w_norm_llQ31: * * \brief Compute normalized Q31 Values out of overflowed Q31 value * using 64-bit operators *------------------------------------------------------------------*/ static inline Word32 w_norm_llQ31( Word64 L64_var1, Word16 *S_var2 ) /*Q31 - L_tmp_exp*/ { Word32 L_result; Word16 sh = W_norm( L64_var1 ); L_result = W_extract_h( W_shl( L64_var1, sh ) ); *S_var2 = ( L_result == 0 ) ? -32 : 32 - sh; return L_result; } #endif /** * \brief Compute dot product of 1 32 bit vectors with itself * \param x input vector 1 Loading Loading
apps/renderer.c +1 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ #include "split_rend_bfi_file_reader.h" #include "vector3_pair_file_reader.h" #include "wmc_auto.h" #include "basop32.h" #define WMC_TOOL_SKIP Loading
lib_com/arith_coder_fx.c +4 −0 Original line number Diff line number Diff line Loading @@ -271,7 +271,11 @@ void tcx_arith_scale_envelope( tmp2 = BASOP_Util_Add_MantExp( negate( b ), b_e, tmp, tmp2, &scale ); /* exp(scale) */ scale = BASOP_Util_Divide1616_Scale( scale, round_fx( a ), &tmp ); #ifdef ISSUE_1796_replace_shl_o scale = shl_sat( scale, sub( sub( add( tmp, tmp2 ), a_e ), 1 ) ); /* Q15 */ #else scale = shl_o( scale, sub( sub( add( tmp, tmp2 ), a_e ), 1 ), &Overflow ); /* Q15 */ #endif /* iscale = 1.0f / scale; */ iscale_e = 0; Loading
lib_com/basop32.c +1 −1 Original line number Diff line number Diff line Loading @@ -1268,7 +1268,7 @@ Word16 round_fx( Word32 L_var1 ) Word32 L_rounded; BASOP_SATURATE_WARNING_OFF L_rounded = L_add( L_var1, (Word32) 0x00008000L ); L_rounded = L_add_sat( L_var1, (Word32) 0x00008000L ); BASOP_SATURATE_WARNING_ON var_out = extract_h( L_rounded ); Loading
lib_com/basop_util.c +21 −0 Original line number Diff line number Diff line Loading @@ -2085,6 +2085,8 @@ Word32 norm_llQ31( /* o : normalized result Q31 */ return L_sum; } #ifndef FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW /* note: now available in basop_util.h */ Word32 w_norm_llQ31( Word64 L_sum, Word16 *exp ); Word32 w_norm_llQ31( /* o : normalized result Q31 */ Word64 L_sum, /* i : upper and lower bits of accu, unsigned Q31 */ Loading @@ -2111,6 +2113,7 @@ Word32 w_norm_llQ31( /* o : normalized result Q31 */ L_tmp = W_extract_h( L64_inp64 ); return L_tmp; } #endif Word32 Dot_product16HQ( /* o : normalized result Q31 */ const Word32 L_off, /* i : initial sum value Qn */ Loading @@ -2135,6 +2138,24 @@ Word32 Dot_product16HQ( /* o : normalized result return L_sum; } Word32 sum_array_norm( /* o : normalized result Q31 */ const Word32 x[], /* i : x vector Qn */ const Word16 lg, /* i : vector length, range [0..7FFF] Q0 */ Word16 *exp /* o : exponent of result in [-32,31] Q0 */ ) { Word16 i; Word64 W_tmp = 0; Word32 L_tmp; FOR( i = 0; i < lg; i++ ) { W_tmp = W_add( W_tmp, x[i] ); /*Q31*/ } L_tmp = w_norm_llQ31( W_tmp, exp ); /*Q31 - *exp*/ return L_tmp; } Word32 Norm32Norm( const Word32 *x, const Word16 headroom, const Word16 length, Word16 *result_e ) { Word32 L_tmp, L_tmp2; Loading
lib_com/basop_util.h +31 −0 Original line number Diff line number Diff line Loading @@ -612,6 +612,20 @@ Word32 Dot_product16HQ( /*<! o : normalized result Word16 *exp /*<! o : exponent of result in [-32,31] Q0 */ ); /*------------------------------------------------------------------* * sum_array_norm: * * \brief Compute array summation of x[] using 64-bit accumulator. * * Performs normalization of the result, returns the exponent * Note: no headroom is required for data in x[] *------------------------------------------------------------------*/ Word32 sum_array_norm( /* o : normalized result Q31 */ const Word32 x[], /* i : x vector Qn */ const Word16 lg, /* i : vector length, range [0..7FFF] Q0 */ Word16 *exp /* o : exponent of result in [-32,31] Q0 */ ); /*------------------------------------------------------------------* * norm_llQ31: * Loading @@ -627,6 +641,23 @@ Word32 norm_llQ31( /* o : normalized result Q31 */ Word16 *exp /* o : exponent of result in [-32,31] Q0 */ ); #ifdef FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW /*------------------------------------------------------------------* * w_norm_llQ31: * * \brief Compute normalized Q31 Values out of overflowed Q31 value * using 64-bit operators *------------------------------------------------------------------*/ static inline Word32 w_norm_llQ31( Word64 L64_var1, Word16 *S_var2 ) /*Q31 - L_tmp_exp*/ { Word32 L_result; Word16 sh = W_norm( L64_var1 ); L_result = W_extract_h( W_shl( L64_var1, sh ) ); *S_var2 = ( L_result == 0 ) ? -32 : 32 - sh; return L_result; } #endif /** * \brief Compute dot product of 1 32 bit vectors with itself * \param x input vector 1 Loading