Commit 974539c9 authored by multrus's avatar multrus
Browse files

[cleanup] accept FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW

parent 9ea054cd
Loading
Loading
Loading
Loading
+0 −29
Original line number Diff line number Diff line
@@ -2123,35 +2123,6 @@ 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 */
                     Word16 *exp   /* o : exponent of result in [-32,31]  Q0 */
)
{
    Word32 L_tmp;
    Word16 exp_val;
    Word64 L64_inp64 = L_sum;
    move64();

    L64_inp64 = W_shl( L64_inp64, 1 );
    exp_val = W_norm( L64_inp64 );
    L64_inp64 = W_shl( L64_inp64, exp_val );
    exp_val = sub( 31, exp_val );
    if ( EQ_64( L_sum, 0 ) )
    {
        exp_val = -32;
        move16();
    }
    *exp = exp_val;
    move16();

    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 */
+0 −2
Original line number Diff line number Diff line
@@ -641,7 +641,6 @@ 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:
 *
@@ -656,7 +655,6 @@ static inline Word32 w_norm_llQ31( Word64 L64_var1, Word16 *S_var2 ) /*Q31 - L_t
    *S_var2 = ( L_result == 0 ) ? -32 : 32 - sh;
    return L_result;
}
#endif

/**
 * \brief Compute dot product of 1 32 bit vectors with itself
+0 −2
Original line number Diff line number Diff line
@@ -75,7 +75,6 @@

#define ISSUE_1836_replace_overflow_libcom                   /* FhG: replace overflow operators by non-overflow-alternatives in lib_com - BE */

#define FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW                /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 1931 */
#define	NONBE_SVD_OPTIMIZATION                               /* FhG: reduce WMOPS of HouseHolderReduction() in ivas_svd_dec.c() by removing redundant mathematics and using 64 bit additions */
#define FIX_1766_TCX2ACELP_BWE_ISSUE                         /* VA : Fix rare BWE issue when switching from TCX to ACELP */
#define FIX_1781_SPECTRAL_GAPS                               /* FhG: Change internal calculation of tcx_noise_factor_ivas_fx() to 32-bit*/
@@ -101,7 +100,6 @@

#endif

#define FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW   /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 1931 */
#define FIX_1844_MISSING_FREE                   /* FhG: add missing free in ivas_binRenderer_convModuleClose_fx() */
#define FIX_1942_ASSERTION_LOWSHELF             /* FhG: Modified the target_gains_db_fx calculation in compute_t60_coeffs_fx() */
#define FIX_1944_CRASH_FOR_STEREO                      /* FhG: improve TonalMDCTConceal_InsertNoise calculation precision */
+0 −39
Original line number Diff line number Diff line
@@ -1852,44 +1852,6 @@ static Word32 CalculateAbsEnergy_fx( /* o : normalized resul
                                     const Word16 lg,    /* i : vector length, range [0..7FFF]  Q0 */
                                     Word16 *exp         /* o : exponent of result in [-32,31]  Q0 */
)
#ifndef FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW
{
    Word16 i;
    Word32 L_sum, L_c;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    Flag Carry;
    move32();
#endif
    /* Clear carry flag and init sum */
    Carry = 0;
    move32();
    L_c = 0;
    move32();
    L_sum = L_macNs_co( L_off, 0, 0, &Carry, &Overflow );
    IF( L_sum > 0 )
    {
        L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow );
    }
    IF( L_sum < 0 )
    {
        L_c = L_msuNs_co( L_c, 0, 0, &Carry, &Overflow );
    }
    FOR( i = 0; i < lg; i += 2 )
    {
        Carry = 0;
        move32();
        BASOP_SATURATE_WARNING_OFF_EVS /*multiplication of -32768 * -32768 throws an overflow, but is not critical*/
            L_sum = L_macNs_co( L_sum, x[i], x[i], &Carry, &Overflow );
        BASOP_SATURATE_WARNING_ON_EVS
        Overflow = 0; /* to avoid useless warning in L_macNs calling L_mult */
        move32();
        L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow );
    }
    L_sum = norm_llQ31( L_c, L_sum, exp );
    return L_sum;
}
#else
{
    Word16 i;
    Word32 L_sum;
@@ -1904,7 +1866,6 @@ static Word32 CalculateAbsEnergy_fx( /* o : normalized resul
    L_sum = w_norm_llQ31( L_sum64, exp ); /*Q31 - *exp */
    return L_sum;
}
#endif /* FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW */

void IMDCT_fx( Word32 *x, Word16 x_e, Word16 *old_syn_overl, Word16 *syn_Overl_TDAC, Word16 *xn_buf, const Word16 *tcx_aldo_window_1, const PWord16 *tcx_aldo_window_1_trunc, const PWord16 *tcx_aldo_window_2, const PWord16 *tcx_mdct_window_half, const PWord16 *tcx_mdct_window_minimum, const PWord16 *tcx_mdct_window_trans, Word16 tcx_mdct_window_half_length, Word16 tcx_mdct_window_min_length, Word16 index, Word16 left_rect, Word16 tcx_offset, Word16 overlap, Word16 L_frame, Word16 L_frameTCX, Word16 L_spec_TCX5, Word16 L_frame_glob, Word16 frame_cnt, Word16 bfi, Word16 *old_out, Word16 *Q_old_wtda, Decoder_State *st, Word16 fullbandScale, Word16 *acelp_zir )
{
+0 −142
Original line number Diff line number Diff line
@@ -576,16 +576,10 @@ Word16 ApplyFdCng_fx(
    Word16 facTab[NPART];
    Word16 facTabExp[NPART];
    Word16 tmp_loop;
#ifndef FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW
    Word32 L_c;
#endif
    Word16 lsp_cng[M];
    HANDLE_FD_CNG_DEC hFdCngDec;
    HANDLE_FD_CNG_COM hFdCngCom;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
#ifndef FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW
    Flag Carry = 0;
#endif
    move16();
    move16();
#endif
@@ -797,40 +791,6 @@ Word16 ApplyFdCng_fx(
                {

                    tmp_loop = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand );
#ifndef FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW
                    L_tmp = L_deposit_h( 0 );
                    L_c = L_deposit_h( 0 );
                    FOR( j = 0; j < tmp_loop; j++ )
                    {

                        Carry = 0;
                        move16();
                        L_tmp = L_add_co( L_tmp, *( cngNoiseLevel + j ), &Carry, &Overflow ); /*Q31*/
                        Overflow = 0;
                        move16();

                        IF( *( cngNoiseLevel + j ) < 0 )
                        {
                            L_c = L_msuNs( L_c, 0, 0 ); /*Q-1*/
                        }
                        IF( *( cngNoiseLevel + j ) >= 0 )
                        {
                            L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); /*Q-1*/
                        }
                    }
                    L_tmp = norm_llQ31( L_c, L_tmp, &L_tmp_exp ); /*Q31 - L_tmp_exp*/
                    L_tmp_exp = sub( add( L_tmp_exp, *cngNoiseLevel_exp ), 1 );

                    L_tmp = Mpy_32_16_1( L_tmp, 1 ); /*Q16 - L_tmp_exp*/

                    L_tmp = Mpy_32_16_1( L_tmp, shr( T_DIV_L_Frame[L_shl( L_mac( -28000, NORM_MDCT_FACTOR, 95 ), 1 - 15 )], 1 ) ); /*Q16,exp -7*/
                    L_tmp_exp = add( L_tmp_exp, -7 );                                                                              /*->Q16, L_tmp_exp */
                    L_tmp_exp = add( L_tmp_exp, 31 - 16 );                                                                         /*->Q31, L_tmp_exp*/

                    st->hTcxDec->conCngLevelBackgroundTrace = round_fx_sat( Sqrt32( L_tmp, &L_tmp_exp ) ); /*Q15 - L_tmp_exp*/
                    move16();
                    L_tmp_exp = add( L_tmp_exp, 1 );
#else
                    L_tmp = sum_array_norm( cngNoiseLevel, tmp_loop, &L_tmp_exp ); /*Q31 - L_tmp_exp*/
                    L_tmp_exp = sub( add( L_tmp_exp, *cngNoiseLevel_exp ), 1 );

@@ -842,7 +802,6 @@ Word16 ApplyFdCng_fx(
                    st->hTcxDec->conCngLevelBackgroundTrace = round_fx_sat( Sqrt32( L_tmp, &L_tmp_exp ) ); /*Q15 - L_tmp_exp*/
                    move16();
                    L_tmp_exp = add( L_tmp_exp, 1 );
#endif
                    st->hTcxDec->conCngLevelBackgroundTrace_e = L_tmp_exp;
                    move16();
                }
@@ -850,38 +809,6 @@ Word16 ApplyFdCng_fx(
                {

                    tmp_loop = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand );
#ifndef FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW
                    L_tmp = L_deposit_h( 0 );
                    L_c = L_deposit_h( 0 );
                    FOR( j = 0; j < tmp_loop; j++ )
                    {

                        Carry = 0;
                        move16();
                        L_tmp = L_add_co( L_tmp, *( cngNoiseLevel + j ), &Carry, &Overflow ); /*Q31 - L_tmp_exp*/
                        Overflow = 0;
                        move16();

                        IF( *( cngNoiseLevel + j ) < 0 )
                        {
                            L_c = L_msuNs( L_c, 0, 0 ); /*Q-1*/
                        }
                        IF( *( cngNoiseLevel + j ) >= 0 )
                        {
                            L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); /*Q-1*/
                        }
                    }
                    L_tmp = norm_llQ31( L_c, L_tmp, &L_tmp_exp ); /*Q31 - L_tmp_exp*/
                    L_tmp_exp = sub( add( L_tmp_exp, *cngNoiseLevel_exp ), 1 );

                    L_tmp = Mpy_32_16_1( L_tmp, hFdCngCom->fftlen ); /*Q16 - L_tmp_exp*/

                    L_tmp = Mpy_32_16_1( L_tmp, T_DIV_L_Frame[L_shl( L_mac( -28000, st->L_frame, 95 ), 1 - 15 )] ); /*Q16,exp -7*/
                    L_tmp_exp = add( L_tmp_exp, -7 );                                                               /*->Q16, L_tmp_exp */
                    L_tmp_exp = add( L_tmp_exp, 31 - 16 );                                                          /*->Q31, L_tmp_exp*/

                    st->hTcxDec->conCngLevelBackgroundTrace = round_fx_sat( Sqrt32( L_tmp, &L_tmp_exp ) ); /*Q15 - L_tmp_exp*/
#else
                    L_tmp = sum_array_norm( cngNoiseLevel, tmp_loop, &L_tmp_exp );
                    L_tmp_exp = sub( add( L_tmp_exp, *cngNoiseLevel_exp ), 1 );

@@ -892,46 +819,12 @@ Word16 ApplyFdCng_fx(


                    st->hTcxDec->conCngLevelBackgroundTrace = round_fx_sat( Sqrt32( L_tmp, &L_tmp_exp ) ); /*Q15 - L_tmp_exp*/
#endif
                    move16();
                    st->hTcxDec->conCngLevelBackgroundTrace_e = L_tmp_exp;
                    move16();
                }

                tmp_loop = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand );
#ifndef FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW
                L_tmp = L_deposit_h( 0 );
                L_c = L_deposit_h( 0 );
                FOR( j = 0; j < tmp_loop; j++ )
                {

                    Carry = 0;
                    move16();
                    L_tmp = L_add_co( L_tmp, *( cngNoiseLevel + j ), &Carry, &Overflow ); /*Q31 - L_tmp_exp*/
                    Overflow = 0;
                    move16();

                    IF( *( cngNoiseLevel + j ) < 0 )
                    {
                        L_c = L_msuNs( L_c, 0, 0 ); /*Q-1*/
                    }
                    IF( *( cngNoiseLevel + j ) >= 0 )
                    {
                        L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); /*Q-1*/
                    }
                }
                L_tmp = norm_llQ31( L_c, L_tmp, &L_tmp_exp ); /*Q31 - L_tmp_exp*/
                L_tmp_exp = sub( add( L_tmp_exp, *cngNoiseLevel_exp ), 1 );

                L_tmp = Mpy_32_16_1( L_tmp, hFdCngCom->fftlen ); /*Q16 - L_tmp_exp*/

                L_tmp = Mpy_32_16_1( L_tmp, T_DIV_L_Frame[L_shl( L_mac( -28000, st->L_frame, 95 ), 1 - 15 )] ); /*Q16,exp -7*/
                L_tmp_exp = add( L_tmp_exp, -7 );                                                               /*->Q16, L_tmp_exp */
                L_tmp_exp = add( L_tmp_exp, 31 - 16 );                                                          /*->Q31, L_tmp_exp*/

                st->cngTDLevel = round_fx_sat( Sqrt32( L_tmp, &L_tmp_exp ) ); /*Q15 - L_tmp_exp*/
                move16();
#else
                L_tmp = sum_array_norm( cngNoiseLevel, tmp_loop, &L_tmp_exp );                             /*Q31 - L_tmp_exp*/
                L_tmp_exp = sub( add( L_tmp_exp, *cngNoiseLevel_exp ), 1 );

@@ -943,7 +836,6 @@ Word16 ApplyFdCng_fx(
                st->cngTDLevel = round_fx_sat( Sqrt32( L_tmp, &L_tmp_exp ) ); /*Q15 - L_tmp_exp*/
                move16();

#endif
                st->cngTDLevel_e = L_tmp_exp;
                move16();
            }
@@ -1062,39 +954,6 @@ Word16 ApplyFdCng_fx(

                /*st->cngTDLevel = (float)sqrt( (sumFLOAT(cngNoiseLevel, hFdCngCom->stopFFTbin - hFdCngCom->startBand) / 2 * hFdCngCom->fftlen) / st->Mode2_L_frame);*/
                tmp_loop = sub( hFdCngCom->stopFFTbin, hFdCngCom->startBand );
#ifndef FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW
                L_tmp = L_deposit_h( 0 );
                L_c = L_deposit_h( 0 );
                FOR( j = 0; j < tmp_loop; j++ )
                {

                    Carry = 0;
                    move16();
                    L_tmp = L_add_co( L_tmp, *( cngNoiseLevel + j ), &Carry, &Overflow ); /*Q31 - L_tmp_exp*/
                    Overflow = 0;
                    move16();

                    IF( *( cngNoiseLevel + j ) < 0 )
                    {
                        L_c = L_msuNs_co( L_c, 0, 0, &Carry, &Overflow ); /*Q-1*/
                    }
                    IF( *( cngNoiseLevel + j ) >= 0 )
                    {
                        L_c = L_macNs_co( L_c, 0, 0, &Carry, &Overflow ); /*Q-1*/
                    }
                }
                L_tmp = norm_llQ31( L_c, L_tmp, &L_tmp_exp ); /*Q31 - L_tmp_exp*/
                L_tmp_exp = sub( add( L_tmp_exp, *cngNoiseLevel_exp ), 1 );

                L_tmp = Mpy_32_16_1( L_tmp, hFdCngCom->fftlen ); /*Q16 - L_tmp_exp*/

                L_tmp = Mpy_32_16_1( L_tmp, T_DIV_L_Frame[L_shl( L_mac( -28000, st->L_frame, 95 ), 1 - 15 )] ); /*Q16,exp -7*/
                L_tmp_exp = add( L_tmp_exp, -7 );                                                               /*->Q16, L_tmp_exp */
                L_tmp_exp = add( L_tmp_exp, 31 - 16 );                                                          /*->Q31, L_tmp_exp*/

                st->cngTDLevel = round_fx_sat( Sqrt32( L_tmp, &L_tmp_exp ) ); /*Q15 - L_tmp_exp*/
                move16();
#else
                L_tmp = sum_array_norm( cngNoiseLevel, tmp_loop, &L_tmp_exp ); /*Q31 - L_tmp_exp*/
                L_tmp_exp = sub( add( L_tmp_exp, *cngNoiseLevel_exp ), 1 );

@@ -1105,7 +964,6 @@ Word16 ApplyFdCng_fx(

                st->cngTDLevel = round_fx( Sqrt32( L_tmp, &L_tmp_exp ) ); /*Q15 - L_tmp_exp*/
                move16();
#endif
                st->cngTDLevel_e = L_tmp_exp;
                move16();
                BREAK;