Commit cc973b95 authored by vaclav's avatar vaclav
Browse files

- Merge remote-tracking branch 'remotes/origin/main' into 20250827_maintenance

parents d5069ed3 b3940b5e
Loading
Loading
Loading
Loading
Loading
+1 −28
Original line number Diff line number Diff line
@@ -194,13 +194,6 @@ void tcx_arith_scale_envelope(
    Word16 statesi, bits;
    Word32 mean, a, s, L_tmp;
    Word16 mean_e, tmp, tmp2;
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif


    lob_bits = 0;
    move16();
@@ -225,11 +218,7 @@ void tcx_arith_scale_envelope(

        tmp = norm_l( env[k] );
        tmp2 = sub( 15, tmp );
#ifdef ISSUE_1836_replace_overflow_libcom
        tmp = Inv16( round_fx_sat( L_shl( env[k], tmp ) ), &tmp2 ); /* exp(tmp2) */
#else
        tmp = Inv16( round_fx_o( L_shl_o( env[k], tmp, &Overflow ), &Overflow ), &tmp2 ); /* exp(tmp2) */
#endif
        ienv[k] = L_shl( L_deposit_h( tmp ), sub( tmp2, 15 ) );     /* Q16 */
        move32();
        mean = L_add( mean, ienv[k] ); /* Q16 */
@@ -262,11 +251,7 @@ void tcx_arith_scale_envelope(
    b_e = add( b_e, mean_e );

    /* scale = (-b + (float)sqrt(b*b - 4.0f*a*0.035f)) / (2.0f * a); */
#ifdef ISSUE_1836_replace_overflow_libcom
    tmp = round_fx_sat( BASOP_Util_Add_Mant32Exp( L_mult( b, b ), shl( b_e, 1 ), Mpy_32_16_1( a, -4588 /*-4.0f*0.035f Q15*/ ), a_e, &tmp2 ) );
#else
    tmp = round_fx_o( BASOP_Util_Add_Mant32Exp( L_mult( b, b ), shl( b_e, 1 ), Mpy_32_16_1( a, -4588 /*-4.0f*0.035f Q15*/ ), a_e, &tmp2 ), &Overflow );
#endif

    IF( tmp <= 0 )
    {
@@ -281,11 +266,7 @@ 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_1836_replace_overflow_libcom
    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;
@@ -334,11 +315,7 @@ void tcx_arith_scale_envelope(
                L_tmp = L_add( L_tmp, L_shl( Mpy_32_16_1( env[k], mult_r( 1147 /*0.035f Q15*/, iscale ) ), iscale_e ) ); /* Q16 */

                tmp = norm_l( L_tmp );
#ifdef ISSUE_1836_replace_overflow_libcom
                statesi = mult_r( statesi, round_fx_sat( L_shl( L_tmp, tmp ) ) );
#else
                statesi = mult_r( statesi, round_fx_o( L_shl_o( L_tmp, tmp, &Overflow ), &Overflow ) );
#endif
                bits = add( bits, sub( 15, tmp ) );

                tmp = norm_s( statesi );
@@ -425,11 +402,7 @@ void tcx_arith_scale_envelope(
    *s_env_e = sub( add( 15, iscale_e ), tmp );
    move16();
    BASOP_SATURATE_WARNING_OFF_EVS;
#ifdef ISSUE_1836_replace_overflow_libcom
    a = L_shl_sat( 1265000, sub( 15, *s_env_e ) );
#else
    a = L_shl_o( 1265000, sub( 15, *s_env_e ), &Overflow );
#endif
    BASOP_SATURATE_WARNING_ON_EVS;

    FOR( k = 0; k < L_frame; k++ )
+0 −114
Original line number Diff line number Diff line
@@ -267,12 +267,6 @@ 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 );

@@ -305,11 +299,7 @@ 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 );
@@ -325,10 +315,6 @@ 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 ) );

@@ -342,13 +328,7 @@ 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 */
@@ -364,19 +344,10 @@ 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; */
@@ -432,23 +403,9 @@ 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; */
@@ -915,12 +872,6 @@ 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 );

@@ -933,17 +884,12 @@ 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 );
    }


    return z;
}

@@ -2072,66 +2018,6 @@ 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
#ifndef ISSUE_1836_replace_overflow_libcom
    Flag Overflow = 0;
#endif
    Flag Carry = 0;
#endif /* BASOP_NOGLOB */

    /* Move MSBit of L_sum into L_c */
#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
    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 ) )
    {
        i = norm_l( L_c );
        L_c = L_shl( L_c, i );
        i = sub( 31, i );           /* positive exponent  */
        L_sum = L_lshr( L_tmp, 1 ); /* L_sum with MSBit=0 */
        L_sum = L_lshr( L_sum, i );
        L_sum = L_add( L_c, L_sum );
    }
    ELSE
    {
        i = -32;
        move16(); /* default exponent, if total sum=0 */
        IF( L_sum )
        {
            i = norm_l( L_sum );
            L_sum = L_shl( L_sum, i );
            i = negate( i ); /* negative or zero exponent */
        }
    }
    *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 */
                        const Word32 L_off, /* i : initial sum value               Qn */
                        const Word16 x[],   /* i : x vector                        Qn */
+1 −21
Original line number Diff line number Diff line
@@ -23,12 +23,6 @@ void bitalloc_fx(
    Word16 diff, temp;
    Word16 fac;
    Word16 ii;
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif
    Word16 SFM_thr = SFM_G1G2;
    move16();

@@ -56,11 +50,7 @@ void bitalloc_fx(
        move16();
        FOR( m = 1; m < im; m++ )
        {
#ifdef ISSUE_1836_replace_overflow_libcom
            v = sub_sat( temp, y[m] ); /* Q0 */
#else
            v = sub_o( temp, y[m], &Overflow );                /* Q0 */
#endif
            temp = s_max( temp, y[m] );
            if ( v < 0 )
            {
@@ -250,12 +240,6 @@ Word16 BitAllocF_fx(
    Word16 tmp, exp1, exp2;
    Word32 Rsubband_w32_fx[NB_SFM]; /* Q15  */
    Word16 B_w16_fx;
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif

    set32_fx( Rsubband_w32_fx, 0, NB_SFM );

@@ -449,11 +433,7 @@ Word16 BitAllocF_fx(
            exp1 = sub( norm_l( L_tmp2 ), 1 );
            exp2 = norm_s( n );
            tmp = div_s( extract_h( L_shl( L_tmp2, exp1 ) ), shl( n, exp2 ) ); /*15 + 15 + exp1 - 16 - exp2*/
#ifdef ISSUE_1836_replace_overflow_libcom
            m_fx = shl_sat( tmp, sub( exp2, exp1 ) );                          /*Q14*/
#else
            m_fx = shl_o( tmp, sub( exp2, exp1 ), &Overflow ); /*Q14*/
#endif
            if ( L_tmp1 < 0 )
            {
                m_fx = negate( m_fx );
+0 −14
Original line number Diff line number Diff line
@@ -1240,12 +1240,6 @@ void GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead)
    Word32 energyValues[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
    Word16 energyValuesSumE[CLDFB_NO_CHANNELS_MAX];
    // Word16 freqTable[2] = {20, 40};
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif

    FOR( k = 0; k < numberCols; k++ )
    {
@@ -1331,11 +1325,7 @@ void GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead)
        {
            FOR( j = 20; j < numberBandsM; j++ )
            {
#ifdef ISSUE_1836_replace_overflow_libcom
                nrg = L_add_sat( nrg, L_shr_sat( energyValues[k][j], s ) );
#else
                nrg = L_add_o( nrg, L_shr_o( energyValues[k][j], s, &Overflow ), &Overflow );
#endif
            }
        }

@@ -1358,11 +1348,7 @@ void GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead)
        {
            FOR( j = 20; j < numberBandsM; j++ )
            {
#ifdef ISSUE_1836_replace_overflow_libcom
                nrg = L_add_sat( nrg, L_shr_sat( energyValues[k][j], s ) );
#else
                nrg = L_add_o( nrg, L_shr_o( energyValues[k][j], s, &Overflow ), &Overflow );
#endif
            }
        }

+0 −14
Original line number Diff line number Diff line
@@ -1493,12 +1493,6 @@ static void GetEnergyCldfb_ivas_fx( Word32 *energyLookahead, /*!< o: Q(*sf_e
    Word32 energyValues[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
    Word16 energyValuesSumE[CLDFB_NO_CHANNELS_MAX];
    // Word16 freqTable[2] = {20, 40};
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif

    FOR( k = 0; k < numberCols; k++ )
    {
@@ -1584,11 +1578,7 @@ static void GetEnergyCldfb_ivas_fx( Word32 *energyLookahead, /*!< o: Q(*sf_e
        {
            FOR( j = 20; j < numberBandsM; j++ )
            {
#ifdef ISSUE_1836_replace_overflow_libcom
                nrg = L_add_sat( nrg, L_shr_sat( energyValues[k][j], s ) );
#else
                nrg = L_add_o( nrg, L_shr_o( energyValues[k][j], s, &Overflow ), &Overflow );
#endif
            }
        }

@@ -1611,11 +1601,7 @@ static void GetEnergyCldfb_ivas_fx( Word32 *energyLookahead, /*!< o: Q(*sf_e
        {
            FOR( j = 20; j < numberBandsM; j++ )
            {
#ifdef ISSUE_1836_replace_overflow_libcom
                nrg = L_add_sat( nrg, L_shr_sat( energyValues[k][j], s ) );
#else
                nrg = L_add_o( nrg, L_shr_o( energyValues[k][j], s, &Overflow ), &Overflow );
#endif
            }
        }

Loading