Commit 1d74178e authored by JÜRGEN Gerstacker's avatar JÜRGEN Gerstacker
Browse files

Merge branch '1965-replace-carry-overflow-using-32-bit-operators-by-64-bit-version-ii' into 'main'

Resolve "Replace carry/overflow-using 32-bit operators by 64-bit version (II.)"

Closes #1965

See merge request !2166
parents 059e7b30 0e20154f
Loading
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -2072,12 +2072,18 @@ Word16 idiv1616_1( Word16 x, Word16 y )
    }
}

#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW
Word32 norm_llQ31(               /* o : normalized result              Q31 */
                   Word32 L_c,   /* i : upper bits of accu             Q-1 */
                   Word32 L_sum, /* i : lower bits of accu, unsigned   Q31 */
                   Word16 *exp   /* o : exponent of result in [-32,31]  Q0 */
)
{
#ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW
    move32(); /* compensate missing instrumentation */
    move32(); /* compensate missing instrumentation */
    return w_norm_llQ31( ( (Word64) L_c << 32 ) | (UWord32) L_sum, exp );
#else
    Word16 i;
    Word32 L_tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
@@ -2088,8 +2094,8 @@ Word32 norm_llQ31( /* o : normalized result Q31 */
#endif /* BASOP_NOGLOB */

    /* Move MSBit of L_sum into L_c */
    Carry = 0;
#ifdef ISSUE_1836_replace_overflow_libcom
    Carry = 0;
    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
@@ -2121,7 +2127,9 @@ Word32 norm_llQ31( /* o : normalized result Q31 */
    *exp = i;
    move16();
    return L_sum;
#endif /* #ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW */
}
#endif /* #ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW */


Word32 Dot_product16HQ(                     /* o : normalized result              Q31 */
+4 −1
Original line number Diff line number Diff line
@@ -647,7 +647,10 @@ Word32 norm_llQ31( /* o : normalized result Q31 */
 * \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*/
static inline Word32 w_norm_llQ31(                  /* o : normalized result               Q31 - *S_var2 */
                                   Word64 L64_var1, /* i : 64-bit accu                     Q63           */
                                   Word16 *S_var2   /* o : exponent of result in [-32,31]  Q0            */
)
{
    Word32 L_result;
    Word16 sh = W_norm( L64_var1 );
+20 −0
Original line number Diff line number Diff line
@@ -1115,28 +1115,42 @@ void IGFCommonFuncsCalcSfbEnergyPowerSpec( const Word16 startSfb, /**< in
)
{
    Word16 /*Q0*/ sfb;
#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW
    Word16 /*Q0*/ line;
    Word32 L_c;
#endif

#ifdef BASOP_NOGLOB_DECLARE_LOCAL
#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW
    Flag Overflow = 0;
    Flag Carry = 0;
    move16();
    move16();
#endif
#endif

#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW
    FOR( sfb = startSfb; sfb < stopSfb; sfb++ )
    {
        sfbEnergy[sfb] = L_deposit_l( 0 );
        move32();
    }
#endif
    IF( NULL == pPowerSpectrum )
    {
#ifdef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW
        FOR( sfb = startSfb; sfb < stopSfb; sfb++ )
        {
            sfbEnergy[sfb] = L_deposit_l( 0 );
            move32();
        }
#endif
        return;
    }

    FOR( sfb = startSfb; sfb < stopSfb; sfb++ )
    {
#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW
        L_c = L_deposit_l( 0 );
        FOR( line = swb_offset[sfb]; line < swb_offset[sfb + 1]; line++ )
        {
@@ -1150,6 +1164,12 @@ void IGFCommonFuncsCalcSfbEnergyPowerSpec( const Word16 startSfb, /**< in
        }
        sfbEnergy[sfb] = norm_llQ31( L_c, sfbEnergy[sfb], &( sfbEnergy_exp[sfb] ) );
        move32();
#else
        sfbEnergy[sfb] = sum_array_norm( pPowerSpectrum + swb_offset[sfb],
                                         swb_offset[sfb + 1] - swb_offset[sfb],
                                         &( sfbEnergy_exp[sfb] ) );
        move32();
#endif
        sfbEnergy_exp[sfb] = add( sfbEnergy_exp[sfb], *pPowerSpectrum_exp );
        move16();
    }
+1 −0
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@

/* Note: each compile switch (FIX_1101_...) is independent from the other ones */

#define FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW                /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 2166 */
#define ISSUE_1836_replace_overflow_libcom                   /* FhG: BE - replace overflow operators by non-overflow-alternatives in lib_com */
#define ISSUE_1867_replace_overflow_libenc                   /* FhG: BE - replace overflow operators by non-overflow-alternatives all over the lib_enc module */
#define FIX_1942_ASSERTION_LOWSHELF                          /* FhG: Modified the target_gains_db_fx calculation in compute_t60_coeffs_fx() */
+18 −1
Original line number Diff line number Diff line
@@ -27,11 +27,16 @@ static Word16 tcx_arith_decode_fx(
    Tastat as;
    Word16 exp_k;
    Word16 tmp;
    Word32 L_tmp, Q;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW
    Word32 L_tmp, Q;
    Flag Overflow = 0;
    move32();
    Flag Carry = 0;
#else
    Word32 Q;
    Word64 W_tmp;
#endif
    move32();
#endif

@@ -39,7 +44,11 @@ static Word16 tcx_arith_decode_fx(
    bp = ari_start_decoding_14bits_prm_fx( prm, 0, &as );

    tmp = sub( envelope_e, 1 + 15 );
#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW
    L_tmp = L_deposit_l( 0 );
#else
    W_tmp = 0;
#endif
    FOR( k = 0; k < L_frame; k++ )
    {
        IF( envelope[k] == 0 ) /* safety check in case of bit errors */
@@ -63,7 +72,11 @@ static Word16 tcx_arith_decode_fx(
        {
            bp = ari_decode_14bits_sign_fx( prm, bp, target_bits, &s, &as );

#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW
            L_tmp = L_macNs_co( L_tmp, q, k, &Carry, &Overflow );
#else
            W_tmp = W_mac_16_16( W_tmp, q, k );
#endif

            Q = L_mult( q, negate( shl( 1, sub( 30, SPEC_EXP_DEC ) ) ) );
            IF( EQ_16( s, 0 ) )
@@ -88,7 +101,11 @@ static Word16 tcx_arith_decode_fx(
    set32_fx( q_spectrum + k, 0, sub( L_frame, k ) );

    /* noise filling seed */
#ifndef FIX_ISSUE_1965_REPLACE_CARRY_OVERFLOW
    *nf_seed = extract_l( L_tmp );
#else
    *nf_seed = extract_l( W_extract_l( W_tmp ) );
#endif
    move16();

    return bp;
Loading