Commit 02e4cf99 authored by Fabian Bauer's avatar Fabian Bauer
Browse files

some more overflow op replacements

parent a93d57a6
Loading
Loading
Loading
Loading
Loading
+135 −2
Original line number Diff line number Diff line
@@ -58,9 +58,11 @@ void E_ACELP_h_vec_corr1_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac
    Word16 *dn2;
    Word16 *p0, *p1, *p2;
    Word32 L_sum;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif

    dn2 = &dn2_pos[( track * 8 )]; /*Q0*/
@@ -75,20 +77,36 @@ void E_ACELP_h_vec_corr1_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac
        p2 = &vec[dn]; /*Qx*/
        FOR( j = dn; j < L_SUBFR - 1; j++ )
        {
#ifdef ISSUE_1867_replace_overflow_libenc
            L_sum = L_mac_sat( L_sum, *p1++, *p2++ ); /*2*Qx+1*/  //??sat
#else
            L_sum = L_mac_o( L_sum, *p1++, *p2++, &Overflow ); /*2*Qx+1*/
#endif
        }

#ifdef ISSUE_1867_replace_overflow_libenc
        corr = mac_r_sat( L_sum, *p1++, *p2++ ); /*Q9*/  //??sat
#else
        corr = mac_ro( L_sum, *p1++, *p2++, &Overflow ); /*Q9*/
#endif

        /*cor[dn >> 2] = sign[dn] * s + p0[dn >> 2];*/
        j = shr( dn, 2 );
        if ( sign[dn] > 0 )
        {
#ifdef ISSUE_1867_replace_overflow_libenc
            corr = add_sat( p0[j], corr ); /*Q9*/   //??sat
#else
            corr = add_o( p0[j], corr, &Overflow ); /*Q9*/
#endif
        }
        if ( sign[dn] < 0 )
        {
#ifdef ISSUE_1867_replace_overflow_libenc
            corr = sub_sat( p0[j], corr ); /*Q9*/   //??sat
#else
            corr = sub_o( p0[j], corr, &Overflow ); /*Q9*/
#endif
        }

        cor[j] = corr; /*Q9*/
@@ -102,9 +120,11 @@ void E_ACELP_h_vec_corr2_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac
    Word16 i, j, pos, corr;
    Word16 *p0, *p1, *p2;
    Word32 L_sum;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif

    p0 = rrixix[track]; /*Q9*/
@@ -118,12 +138,30 @@ void E_ACELP_h_vec_corr2_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac
        p2 = &vec[pos]; /*Qx*/
        FOR( j = pos; j < L_SUBFR - 1; j++ )
        {
#ifdef ISSUE_1867_replace_overflow_libenc
            L_sum = L_mac_sat( L_sum, *p1++, *p2++ ); /* 2*Qx+1 */  //??sat
#else
            L_sum = L_mac_o( L_sum, *p1++, *p2++, &Overflow ); /* 2*Qx+1 */
#endif
        }
#ifdef ISSUE_1867_replace_overflow_libenc
        corr = mac_r_sat( L_sum, *p1++, *p2++ ); /*Q9*/  //??sat
#else
        corr = mac_ro( L_sum, *p1++, *p2++, &Overflow ); /*Q9*/
#endif

        /*cor[i] = s * sign[track] + p0[i];*/

#ifdef ISSUE_1867_replace_overflow_libenc
        if ( sign[pos] > 0 )
        {
            corr = add_sat( *p0++, corr ); /*Q9*/   //??sat
        }
        if ( sign[pos] < 0 )
        {
            corr = sub_sat( *p0++, corr ); /*Q9*/   //??sat
        }
#else
        if ( sign[pos] > 0 )
        {
            corr = add_o( *p0++, corr, &Overflow ); /*Q9*/
@@ -132,6 +170,7 @@ void E_ACELP_h_vec_corr2_fx( Word16 h[] /*Qx*/, Word16 vec[] /*Qx*/, UWord8 trac
        {
            corr = sub_o( *p0++, corr, &Overflow ); /*Q9*/
        }
#endif
        cor[i] = corr; /*Q9*/
        move16();

@@ -174,10 +213,12 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix /*Q0*/, UWord8 track_x /*Q0*
    Word32 xy_save;
    Word16 check = 0; /* debug code not instrumented */

#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif


    /* eight dn2 max positions per track */
@@ -195,7 +236,11 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix /*Q0*/, UWord8 track_x /*Q0*
    sqk[0] = -1;
    move16();
    x2 = shr( pos_x[0], 2 ); /*Qdn*/
#ifdef ISSUE_1867_replace_overflow_libenc
    if ( mac_r_sat( L_mac_sat( L_mac_sat( alp0, cor_x[x2], _1_ ), cor_y[0], _1_ ), rrixiy[track_x][( x2 * 16 )], _1_ ) < 0 )   //??sat  //??sat  //??sat
#else
    if ( mac_ro( L_mac_o( L_mac_o( alp0, cor_x[x2], _1_, &Overflow ), cor_y[0], _1_, &Overflow ), rrixiy[track_x][( x2 * 16 )], _1_, &Overflow ) < 0 )
#endif
    {
        sqk[0] = 1;
        move16();
@@ -215,7 +260,11 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix /*Q0*/, UWord8 track_x /*Q0*
        ps1 = add( ps0, dn[x] ); /*Qdn*/

        /*alp1 = alp0 + cor_x[x2];*/
#ifdef ISSUE_1867_replace_overflow_libenc
        alp1 = L_mac_sat( alp0, cor_x[x2], _1_ ); /*Q22*/   //??sat
#else
        alp1 = L_mac_o( alp0, cor_x[x2], _1_, &Overflow ); /*Q22*/
#endif

        p1 = cor_y;                         /*Qx*/
        p2 = &rrixiy[track_x][( x2 * 16 )]; /*Q9*/
@@ -227,8 +276,13 @@ static void E_ACELP_2pulse_search( Word16 nb_pos_ix /*Q0*/, UWord8 track_x /*Q0*
            move16();

            /*alp2 = alp1 + (*p1++) + (*p2++);*/
#ifdef ISSUE_1867_replace_overflow_libenc
            alp2 = L_mac_sat( alp1, *p1++, _1_ );   /*Qx+12+1*/   //??sat
            alp2_16 = mac_r_sat( alp2, *p2++, _1_ ); /*Q6*/  //??sat
#else
            alp2 = L_mac_o( alp1, *p1++, _1_, &Overflow );   /*Qx+12+1*/
            alp2_16 = mac_ro( alp2, *p2++, _1_, &Overflow ); /*Q6*/
#endif
            alpk[1 - ik] = alp2_16;                          /*Q6*/
            move16();

@@ -523,19 +577,29 @@ Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn
    Word16 i, Q_xn;
    Word16 xy, yy, exp_xy, exp_yy, gain;
    Word32 L_off;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif

    L_off = L_shr( 10737418l /*0.01f/2.0f Q31*/, s_min( add( exp_xn, exp_xn ), 31 ) );
    L_off = L_max( 1, L_off ); /* ensure at least a '1' */

    /* Compute scalar product t1: <y1[] * y1[]> */
#ifdef ISSUE_1867_replace_overflow_libenc
    yy = round_fx_sat( Dot_product15_offs( y1, y1, L_subfr, &exp_yy, L_off ) ); /*Q15 - exp_yy*/  //??sat
#else
    yy = round_fx_o( Dot_product15_offs( y1, y1, L_subfr, &exp_yy, L_off ), &Overflow ); /*Q15 - exp_yy*/
#endif

    /* Compute scalar product t0: <xn[] * y1[]> */
#ifdef ISSUE_1867_replace_overflow_libenc
    xy = round_fx_sat( Dot_product12_offs( xn, y1, L_subfr, &exp_xy, L_off ) ); /*Q15 - exp_xy*/  //??sat
#else
    xy = round_fx_o( Dot_product12_offs( xn, y1, L_subfr, &exp_xy, L_off ), &Overflow ); /*Q15 - exp_xy*/
#endif
    /* Compute doubled format out of the exponent */
    Q_xn = shl( sub( 15, exp_xn ), 1 );
    g_corr->y1y1 = yy;
@@ -563,8 +627,8 @@ Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn
    i = add( exp_xy, 1 - 1 ); /* -1 -> gain in Q14 */
    i = sub( i, exp_yy );
    BASOP_SATURATE_WARNING_OFF_EVS
#ifdef ISSUE_1796_replace_shl_o
    gain = shl_sat( gain, i ); /* saturation can occur here */
#ifdef ISSUE_1867_replace_overflow_libenc
    gain = shl_sat( gain, i ); /* saturation can occur here */  //??sat
#else
    gain = shl_o( gain, i, &Overflow ); /* saturation can occur here */
#endif
@@ -581,7 +645,11 @@ Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn
        Word16 tmp, exp_tmp, exp_div;

        /* Compute scalar product <xn[],xn[]> */
#ifdef ISSUE_1867_replace_overflow_libenc
        tmp = round_fx_sat( Dot_product12_offs( xn, xn, L_subfr, &exp_tmp, 1 ) ); /*Q15 - exp_tmp*/   //??sat
#else
        tmp = round_fx_o( Dot_product12_offs( xn, xn, L_subfr, &exp_tmp, 1 ), &Overflow ); /*Q15 - exp_tmp*/
#endif
        /* gain_p_snr = sqrt(<xn,xn>/<y1,y1>) */
        tmp = BASOP_Util_Divide1616_Scale( tmp, yy, &exp_div );
        exp_tmp = add( sub( exp_tmp, exp_yy ), exp_div );
@@ -591,7 +659,11 @@ Word16 E_ACELP_xy1_corr_fx( Word16 xn[] /*Q15-exp_xn*/, Word16 y1[] /*Q15-exp_xn
        /* Note: shl works as shl or shr. */
        exp_tmp = sub( exp_tmp, 1 );
        BASOP_SATURATE_WARNING_OFF_EVS
#ifdef ISSUE_1867_replace_overflow_libenc
        tmp = round_fx_sat( L_shl_sat( Mpy_32_16_1( 1717986944l /*ACELP_GAINS_CONST Q31*/, tmp ), exp_tmp ) ); /*Q14*/   //??sat  //??sat
#else
        tmp = round_fx_o( L_shl_o( Mpy_32_16_1( 1717986944l /*ACELP_GAINS_CONST Q31*/, tmp ), exp_tmp, &Overflow ), &Overflow ); /*Q14*/
#endif
        BASOP_SATURATE_WARNING_ON_EVS

        gain = s_min( gain, tmp ); /*Q14*/
@@ -688,9 +760,11 @@ void E_ACELP_codebook_target_update_fx( Word16 *x /*Q_xn*/, Word16 *x2 /*Q_xn*/,
{
    Word16 i, Q15_flag;
    Word32 L_tmp;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif
    assert( gain >= 0 );

@@ -708,9 +782,17 @@ void E_ACELP_codebook_target_update_fx( Word16 *x /*Q_xn*/, Word16 *x2 /*Q_xn*/,
        L_tmp = L_deposit_h( x[i] ); /*Q_xn+16*/
        if ( Q15_flag == 0 )
        {
#ifdef ISSUE_1867_replace_overflow_libenc
            L_tmp = L_msu_sat( L_tmp, y[i], gain ); /*Q_xn+15*/   //??sat
#else
            L_tmp = L_msu_o( L_tmp, y[i], gain, &Overflow ); /*Q_xn+15*/
#endif
        }
#ifdef ISSUE_1867_replace_overflow_libenc
        x2[i] = msu_r_sat( L_tmp, y[i], gain ); /*Q_xn*/   //??sat
#else
        x2[i] = msu_ro( L_tmp, y[i], gain, &Overflow ); /*Q_xn*/
#endif
        move16();
    }
}
@@ -744,10 +826,12 @@ void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16
    Word16 signs[3];
    Word16 *ptr16;
    Word16 val, index;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif


    /* calculate energy for normalization of cn[] and dn[] */
@@ -756,7 +840,11 @@ void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16

    FOR( i = 1; i < L_subfr; i++ )
    {
#ifdef ISSUE_1867_replace_overflow_libenc
        Lval = L_mac0_sat( Lval, cn[i], cn[i] ); /*2*Q_xn*/   //??sat
#else
        Lval = L_mac0_o( Lval, cn[i], cn[i], &Overflow ); /*2*Q_xn*/
#endif
        Lcor = L_mac0( Lcor, dn[i], dn[i] );              /*2*Qdn*/
    }

@@ -773,8 +861,13 @@ void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16
    if ( i > 0 )
        Lcor = L_shr( Lcor, i );

#ifdef ISSUE_1867_replace_overflow_libenc
    k_dn = round_fx_sat( Lval ); /*Q15 - e_dn*/   //??sat
    k_cn = round_fx_sat( Lcor ); /*Q15 - e_cn*/   //??sat
#else
    k_dn = round_fx_o( Lval, &Overflow ); /*Q15 - e_dn*/
    k_cn = round_fx_o( Lcor, &Overflow ); /*Q15 - e_cn*/
#endif

    k_cn = mult_r( 0x2000, k_cn ); /* 1 in Q13 */
    k_dn = mult_r( alp, k_dn );    /* alp in Q13 */
@@ -794,7 +887,11 @@ void E_ACELP_pulsesign( const Word16 cn[] /*Q_xn*/, Word16 dn[] /*Qdn*/, Word16
        /*cor = (s * cn[i]) + (alp * dn[i]);                        MULT(1);MAC(1);*/
        Lcor = L_mult( cn[i], k_cn );                                 /*Q_xn + Q15 - e_cn + 1*/
        Lcor = L_mac( Lcor, dn[i], k_dn );                            /*Qdn + Q15 - e_dn + 1*/
#ifdef ISSUE_1867_replace_overflow_libenc
        val = round_fx_sat( L_shl_sat( Lcor, 4 ) ); /*shifting by 4 may overflow but improves accuracy Qdn + 4 - e_dn*/  //??sat  //??sat
#else
        val = round_fx_o( L_shl_o( Lcor, 4, &Overflow ), &Overflow ); /*shifting by 4 may overflow but improves accuracy Qdn + 4 - e_dn*/
#endif

        index = shr( val, 15 );
        sign[i] = ptr16[index];    /*Q15*/
@@ -1090,10 +1187,12 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const
    Word32 s, L_tmp;
    Word16 nb_pulse, nb_pulse_m2;
    Word16 check = 0; /* debug code not instrumented */
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif


    alp = config->alp; /* Q13 */ /* initial value for energy of all fixed pulses */
@@ -1132,7 +1231,11 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const
    BASOP_SATURATE_WARNING_OFF_EVS
    FOR( i = 0; i < L_SUBFR; i++ )
    {
#ifdef ISSUE_1867_replace_overflow_libenc
        L_tmp = L_mac_sat( L_tmp, H[i], H[i] ); /*Q25*/   //??sat
#else
        L_tmp = L_mac_o( L_tmp, H[i], H[i], &Overflow ); /*Q25*/
#endif
    }
    val = extract_h( L_tmp ); /*Q9*/
    BASOP_SATURATE_WARNING_ON_EVS
@@ -1277,7 +1380,11 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const

            L_tmp = L_mult( vec[0], vec[0] ); /*Q25+2*scale*/
            FOR( i = 1; i < L_SUBFR; i++ )
#ifdef ISSUE_1867_replace_overflow_libenc
            L_tmp = L_mac_sat( L_tmp, vec[i], vec[i] ); /*Q25+2*scale*/   //??sat
#else
            L_tmp = L_mac_o( L_tmp, vec[i], vec[i], &Overflow ); /*Q25+2*scale*/
#endif

            alp = round_fx( L_shr( L_tmp, 3 ) ); /*Q6+2*scale*/

@@ -1334,7 +1441,11 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const
                FOR( i = 0; i < L_SUBFR; i++ )
                {
                    tmp = add( *p0++, *p1++ );
#ifdef ISSUE_1867_replace_overflow_libenc
                    vec[i] = add_sat( vec[i], tmp ); /* can saturate here. */
#else
                    vec[i] = add_o( vec[i], tmp, &Overflow ); /* can saturate here. */
#endif
                    move16();
                }
            }
@@ -1384,7 +1495,11 @@ void E_ACELP_4tsearch_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/, const
        }
        FOR( i = 0; i < L_SUBFR; i++ )
        {
#ifdef ISSUE_1867_replace_overflow_libenc
            y[i] = add_sat( y[i], *p0++ ); /*Q12+scale*/  //??sat
#else
            y[i] = add_o( y[i], *p0++, &Overflow ); /*Q12+scale*/
#endif
            move16();
        }
    }
@@ -1410,10 +1525,12 @@ void E_ACELP_4tsearch_ivas_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/,
    Word32 s, L_tmp;
    Word16 nb_pulse, nb_pulse_m2;
    Word16 check = 0; /* debug code not instrumented */
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif


    alp = config->alp; /* Q13 */ /* initial value for energy of all fixed pulses */
@@ -1452,7 +1569,11 @@ void E_ACELP_4tsearch_ivas_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/,
    BASOP_SATURATE_WARNING_OFF_EVS
    FOR( i = 0; i < L_SUBFR; i++ )
    {
#ifdef ISSUE_1867_replace_overflow_libenc
        L_tmp = L_mac_sat( L_tmp, H[i], H[i] ); /*Q25*/   //??sat
#else
        L_tmp = L_mac_o( L_tmp, H[i], H[i], &Overflow ); /*Q25*/
#endif
    }
    val = extract_h( L_tmp ); /*Q9*/
    BASOP_SATURATE_WARNING_ON_EVS
@@ -1602,7 +1723,11 @@ void E_ACELP_4tsearch_ivas_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/,

            L_tmp = L_mult( vec[0], vec[0] ); /*Q25+2*scale*/
            FOR( i = 1; i < L_SUBFR; i++ )
#ifdef ISSUE_1867_replace_overflow_libenc
            L_tmp = L_mac_sat( L_tmp, vec[i], vec[i] ); /*Q25+2*scale*/   //??sat
#else
            L_tmp = L_mac_o( L_tmp, vec[i], vec[i], &Overflow ); /*Q25+2*scale*/
#endif

            alp = round_fx( L_shr( L_tmp, 3 ) ); /*Q6+2*scale*/

@@ -1659,7 +1784,11 @@ void E_ACELP_4tsearch_ivas_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/,
                FOR( i = 0; i < L_SUBFR; i++ )
                {
                    tmp = add( *p0++, *p1++ );
#ifdef ISSUE_1867_replace_overflow_libenc
                    vec[i] = add_sat( vec[i], tmp ); /* can saturate here. */   //??sat
#else
                    vec[i] = add_o( vec[i], tmp, &Overflow ); /* can saturate here. */
#endif
                    move16();
                }
            }
@@ -1709,7 +1838,11 @@ void E_ACELP_4tsearch_ivas_fx( Word16 dn[] /*Qdn*/, const Word16 cn[] /*Q_xn*/,
        }
        FOR( i = 0; i < L_SUBFR; i++ )
        {
#ifdef ISSUE_1867_replace_overflow_libenc
            y[i] = add_sat( y[i], *p0++ ); /*Q12+scale*/  //??sat
#else
            y[i] = add_o( y[i], *p0++, &Overflow ); /*Q12+scale*/
#endif
            move16();
        }
    }
+16 −0
Original line number Diff line number Diff line
@@ -64,9 +64,11 @@ void encod_amr_wb_fx(
    AMRWB_IO_ENC_HANDLE hAmrwb_IO = st->hAmrwb_IO;
    BSTR_ENC_HANDLE hBstr = st->hBstr;
    LPD_state_HANDLE hLPDmem = st->hLPDmem;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif

    /*------------------------------------------------------------------*
@@ -187,14 +189,23 @@ void encod_amr_wb_fx(
                            &gain_inov, &norm_gain_code, g_corr, clip_gain, hAmrwb_IO->past_qua_en_fx );

        gp_clip_test_gain_pit_fx( st->element_mode, st->core_brate, gain_pit, st->clip_var_fx );
#ifdef ISSUE_1867_replace_overflow_libenc
        Lgcode = L_shl_sat( gain_code, Q_new ); /* scaled gain_code with Qnew -> Q16*/  //??sat
        gcode16 = round_fx_sat( Lgcode );       /*Q0*/  //??sat
#else
        Lgcode = L_shl_o( gain_code, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/
        gcode16 = round_fx_o( Lgcode, &Overflow );       /*Q0*/
#endif

        hLPDmem->tilt_code = Est_tilt2( exc + i_subfr, gain_pit, code, Lgcode, &voice_fac, shift ); /*Q15*/

        FOR( i = 0; i < L_SUBFR; i++ )
        {
#ifdef ISSUE_1867_replace_overflow_libenc
            exc2[i + i_subfr] = round_fx_sat( L_shl_sat( L_mult( gain_pit, exc[i + i_subfr] ), 1 ) ); /*Q_new*/  //??sat  //??sat
#else
            exc2[i + i_subfr] = round_fx_o( L_shl_o( L_mult( gain_pit, exc[i + i_subfr] ), 1, &Overflow ), &Overflow ); /*Q_new*/
#endif
            move16();
        }

@@ -219,8 +230,13 @@ void encod_amr_wb_fx(
            L_tmp = L_mult( gcode16, code[i] );                     /*Q10*/
            L_tmp = L_shl_sat( L_tmp, 5 );                          /*Q15*/
            L_tmp = L_mac_sat( L_tmp, exc[i + i_subfr], gain_pit ); /* Q_new+15 */
#ifdef ISSUE_1867_replace_overflow_libenc
            L_tmp = L_shl_sat( L_tmp, 1 );                 /* saturation can occur here Q_new+15*/  //??sat
            exc[i + i_subfr] = round_fx_sat( L_tmp );      /*Q_new*/  //??sat
#else
            L_tmp = L_shl_o( L_tmp, 1, &Overflow );                 /* saturation can occur here Q_new+15*/
            exc[i + i_subfr] = round_fx_o( L_tmp, &Overflow );      /*Q_new*/
#endif
            move16();
        }

+62 −0
Original line number Diff line number Diff line
@@ -134,9 +134,11 @@ void encod_gen_voic_fx(
    Word16 shift_wsp;
    Word16 harm_flag_acelp;
    Word16 lp_select, lp_flag, L_frame;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif
    SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
    BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
@@ -266,7 +268,11 @@ void encod_gen_voic_fx(
        }

        /*st_fx->lowrate_pitchGain = 0.9f * st_fx->lowrate_pitchGain + 0.1f * gain_pit_fx;*/
#ifdef ISSUE_1867_replace_overflow_libenc
        hSpMusClas->lowrate_pitchGain = round_fx_sat( L_mac_sat( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx ) ); /*Q14*Q16(0.1) + Q15 -> Q15*/  //??sat  //??sat
#else
        hSpMusClas->lowrate_pitchGain = round_fx_o( L_mac_o( L_mult( 29491, hSpMusClas->lowrate_pitchGain ), 6554, gain_pit_fx, &Overflow ), &Overflow ); /*Q14*Q16(0.1) + Q15 -> Q15*/
#endif

        /*-----------------------------------------------------------------*
         * Transform domain contribution encoding - active frames
@@ -317,8 +323,13 @@ void encod_gen_voic_fx(
        }
        gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit_fx, st_fx->clip_var_fx );

#ifdef ISSUE_1867_replace_overflow_libenc
        Lgcode = L_shl_sat( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/   //??sat
        gcode16 = round_fx_sat( Lgcode );          /*Q0*/   //??sat
#else
        Lgcode = L_shl_o( gain_code_fx, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/
        gcode16 = round_fx_o( Lgcode, &Overflow );          /*Q0*/
#endif

        hLPDmem->tilt_code = Est_tilt2( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, Lgcode, &voice_fac_fx, shift ); /* Q15 */
        move16();
@@ -354,20 +365,35 @@ void encod_gen_voic_fx(
            FOR( i = 0; i < L_SUBFR; i++ )
            {
                /* Contribution from AVQ layer */
#ifdef ISSUE_1867_replace_overflow_libenc
                Ltmp1 = L_mult_sat( gain_preQ_fx, code_preQ_fx[i] ); /* Q2 + Q6 -> Q9*/   //??sat
                Ltmp1 = L_shl_sat( Ltmp1, tmp1_fx );                 /* Q16 + Q_exc */  //??sat
#else
                Ltmp1 = L_mult_o( gain_preQ_fx, code_preQ_fx[i], &Overflow ); /* Q2 + Q6 -> Q9*/
                Ltmp1 = L_shl_o( Ltmp1, tmp1_fx, &Overflow );                 /* Q16 + Q_exc */
#endif

                /* Compute exc2 */
#ifdef ISSUE_1867_replace_overflow_libenc
                Ltmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 );        /* Q16 */  //??sat
                exc2_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); /* Q0 */   //??sat  //??sat
#else
                Ltmp = L_shl_o( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1, &Overflow );        /* Q16 */
                exc2_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); /* Q0 */
#endif
                move16();

                /* code in Q9, gain_pit in Q14 */
                Ltmp = L_mult( gcode16, code_fx[i] );                                                /* Q10 */
                Ltmp = L_shl( Ltmp, 5 );                                                             /* Q15 */
                Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx );                           /* Q15 */
#ifdef ISSUE_1867_replace_overflow_libenc
                Ltmp = L_shl_sat( Ltmp, 1 );                                                /* saturation can occur here Q16*/  //??sat
                exc_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) ); /* Q0 */  //??sat  //??sat
#else
                Ltmp = L_shl_o( Ltmp, 1, &Overflow );                                                /* saturation can occur here Q16*/
                exc_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow ); /* Q0 */
#endif
            }
        }
        ELSE
@@ -380,10 +406,17 @@ void encod_gen_voic_fx(
            {
                /* code in Q9, gain_pit in Q14 */
                Ltmp = L_mult( gcode16, code_fx[i] );                                   /* Q10 */
#ifdef ISSUE_1867_replace_overflow_libenc
                Ltmp = L_shl_sat( Ltmp, 5 );                                   /* Q15 */  //??sat
                Ltmp = L_mac_sat( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /* Q15 */  //??sat
                Ltmp = L_shl_sat( Ltmp, 1 );                                   /* saturation can occur here Q16*/
                exc_fx[i + i_subfr_fx] = round_fx_sat( Ltmp );                 /* Q0 */   //??sat
#else
                Ltmp = L_shl_o( Ltmp, 5, &Overflow );                                   /* Q15 */
                Ltmp = L_mac_o( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx, &Overflow ); /* Q15 */
                Ltmp = L_shl_o( Ltmp, 1, &Overflow );                                   /* saturation can occur here Q16*/
                exc_fx[i + i_subfr_fx] = round_fx_o( Ltmp, &Overflow );                 /* Q0 */
#endif
            }
        }

@@ -492,9 +525,11 @@ void encod_gen_voic_ivas_fx(
    Word16 harm_flag_acelp;
    Word16 lp_select, lp_flag, L_frame;
    Word16 q_h1;
#ifndef ISSUE_1867_replace_overflow_libenc
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif
    SC_VBR_ENC_HANDLE hSC_VBR = st_fx->hSC_VBR;
    BSTR_ENC_HANDLE hBstr = st_fx->hBstr;
@@ -684,8 +719,13 @@ void encod_gen_voic_ivas_fx(
        }
        gp_clip_test_gain_pit_fx( st_fx->element_mode, st_fx->core_brate, gain_pit_fx, st_fx->clip_var_fx );

#ifdef ISSUE_1867_replace_overflow_libenc
        Lgcode = L_shl_sat( gain_code_fx, Q_new ); /* scaled gain_code with Qnew -> Q16*/   //??sat
        gcode16 = round_fx_sat( Lgcode );   //??sat
#else
        Lgcode = L_shl_o( gain_code_fx, Q_new, &Overflow ); /* scaled gain_code with Qnew -> Q16*/
        gcode16 = round_fx_o( Lgcode, &Overflow );
#endif

        hLPDmem->tilt_code = est_tilt_ivas_fx( &exc_fx[i_subfr_fx], gain_pit_fx, code_fx, gain_code_fx, &voice_fac_fx, Q_new, L_SUBFR, 0 ); /* Q15 */
        move16();
@@ -737,20 +777,35 @@ void encod_gen_voic_ivas_fx(
            FOR( i = 0; i < L_SUBFR; i++ )
            {
                /* Contribution from AVQ layer */
#ifdef ISSUE_1867_replace_overflow_libenc
                Ltmp1 = L_mult_sat( gain_preQ_fx, code_preQ_fx[i] );  //??sat
                Ltmp1 = L_shl_sat( Ltmp1, tmp1_fx );  //??sat
#else
                Ltmp1 = L_mult_o( gain_preQ_fx, code_preQ_fx[i], &Overflow );
                Ltmp1 = L_shl_o( Ltmp1, tmp1_fx, &Overflow );
#endif

                /* Compute exc2 */
#ifdef ISSUE_1867_replace_overflow_libenc
                Ltmp = L_shl_sat( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1 );   //??sat
                exc2_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) );  //??sat  //??sat
#else
                Ltmp = L_shl_o( L_mult( gain_pit_fx, exc_fx[i + i_subfr_fx] ), 1, &Overflow );
                exc2_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow );
#endif
                move16();

                /* code in Q9, gain_pit in Q14 */
                Ltmp = L_mult( gcode16, code_fx[i] );                        /*Qnew + 9 + 1 */
                Ltmp = L_shl( Ltmp, 5 );                                     /*Qnew + 9+ 1+5 */
                Ltmp = L_mac( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx );   /*Qnew + 14 + 1*/
#ifdef ISSUE_1867_replace_overflow_libenc
                Ltmp = L_shl_sat( Ltmp, 1 ); /*Qnew + 14 + 1 +1  */ /* saturation can occur here Q16*/  //??sat
                exc_fx[i + i_subfr_fx] = round_fx_sat( L_add_sat( Ltmp, Ltmp1 ) );   //??sat  //??sat
#else
                Ltmp = L_shl_o( Ltmp, 1, &Overflow ); /*Qnew + 14 + 1 +1  */ /* saturation can occur here Q16*/
                exc_fx[i + i_subfr_fx] = round_fx_o( L_add_o( Ltmp, Ltmp1, &Overflow ), &Overflow );
#endif
                move16();
            }
        }
@@ -765,10 +820,17 @@ void encod_gen_voic_ivas_fx(
                /* code in Q9, gain_pit in Q14 */
                /*gcode16 in Qnew*/
                Ltmp = L_mult( gcode16, code_fx[i] );                                   /*Qnew + 9 + 1 */
#ifdef ISSUE_1867_replace_overflow_libenc
                Ltmp = L_shl_sat( Ltmp, 5 );                                   /*Qnew + 9+ 1+5 */   //??sat
                Ltmp = L_mac_sat( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx ); /*Qnew + 14 + 1*/  //??sat
                Ltmp = L_shl_sat( Ltmp, 1 );                                   /*Qnew + 14 + 1 +1  */   //??sat
                exc_fx[i + i_subfr_fx] = round_fx_sat( Ltmp );  //??sat
#else
                Ltmp = L_shl_o( Ltmp, 5, &Overflow );                                   /*Qnew + 9+ 1+5 */
                Ltmp = L_mac_o( Ltmp, exc_fx[i + i_subfr_fx], gain_pit_fx, &Overflow ); /*Qnew + 14 + 1*/
                Ltmp = L_shl_o( Ltmp, 1, &Overflow );                                   /*Qnew + 14 + 1 +1  */
                exc_fx[i + i_subfr_fx] = round_fx_o( Ltmp, &Overflow );
#endif
            }
        }
        /*-----------------------------------------------------------------*
+24 −0

File changed.

Preview size limit exceeded, changes collapsed.

+20 −4

File changed.

Preview size limit exceeded, changes collapsed.

Loading