Commit f7cc2fc7 authored by vaillancour's avatar vaillancour
Browse files

Merge branch '1904-removing-encoder-acelp-bit-exact-code-duplication' into...

Merge branch '1904-removing-encoder-acelp-bit-exact-code-duplication' into 1905-integrate-acelp-evs-function-that-introduces-with-minor-rounding-differences
parents 320799e1 2cd086ee
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -3679,14 +3679,20 @@ static void parseCombinedFormatInput(
        inConfig->numAmbisonicsBuses = 1;
        inConfig->ambisonicsBuses[0].audioConfig = audioConfig;
        inConfig->ambisonicsBuses[0].inputChannelIndex = inConfig->numAudioObjects;
#ifdef NONBE_1352_HARMONIZE_OSBA_LOUDNESS
        inConfig->ambisonicsBuses[0].gain_dB = 0.f;
#else
        inConfig->ambisonicsBuses[0].gain_dB = -6.f;
#endif
        *configString += 4;

        /* Modify input gain for objects too */
#ifndef NONBE_1352_HARMONIZE_OSBA_LOUDNESS
        for ( int16_t i = 0; i < inConfig->numAudioObjects; ++i )
        {
            inConfig->audioObjects[i].gain_dB = -6.f;
        }
#endif
    }
    else if ( audioConfig == IVAS_AUDIO_CONFIG_MASA1 || audioConfig == IVAS_AUDIO_CONFIG_MASA2 )
    {
+20 −2
Original line number Diff line number Diff line
@@ -194,10 +194,12 @@ 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;
@@ -223,7 +225,11 @@ 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 */
@@ -256,7 +262,11 @@ 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 )
    {
@@ -271,7 +281,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_1796_replace_shl_o
#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 */
@@ -324,7 +334,11 @@ 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 );
@@ -411,7 +425,11 @@ 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++ )
+38 −0
Original line number Diff line number Diff line
@@ -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 );
@@ -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 );
@@ -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 ) );
@@ -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 */
@@ -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; */
@@ -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; */
@@ -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 );
@@ -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 );
@@ -2050,14 +2081,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 ) )
+9 −3
Original line number Diff line number Diff line
@@ -23,9 +23,11 @@ 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();
@@ -54,7 +56,11 @@ 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 )
            {
@@ -245,7 +251,7 @@ Word16 BitAllocF_fx(
    Word16 tmp, exp1, exp2;
    Word32 Rsubband_w32_fx[NB_SFM]; /* Q15  */
    Word16 B_w16_fx;
#ifndef ISSUE_1796_replace_shl_o
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
@@ -444,7 +450,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_1796_replace_shl_o
#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*/
+6 −4
Original line number Diff line number Diff line
@@ -1240,9 +1240,11 @@ 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++ )
@@ -1329,8 +1331,8 @@ void GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead)
        {
            FOR( j = 20; j < numberBandsM; j++ )
            {
#ifdef ISSUE_1799_replace_L_shr_o
                nrg = L_add_o( nrg, L_shr_sat( energyValues[k][j], s ), &Overflow );
#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
@@ -1356,8 +1358,8 @@ void GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead)
        {
            FOR( j = 20; j < numberBandsM; j++ )
            {
#ifdef ISSUE_1799_replace_L_shr_o
                nrg = L_add_o( nrg, L_shr_sat( energyValues[k][j], s ), &Overflow );
#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