Commit 0f077019 authored by Fabian Bauer's avatar Fabian Bauer
Browse files

lib_com/hp50_fx.c

lib_com/hq2_bit_alloc_fx.c
lib_com/hq2_core_com_fx.c : completed overflow op replacement
parent 0f1cb3b2
Loading
Loading
Loading
Loading
+60 −28
Original line number Diff line number Diff line
@@ -86,9 +86,11 @@ static void filter_2nd_order(
    Word16 i;
    Word16 x2, x1;
    Word32 L_sum, L_y1, L_y2;
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
#endif
#endif


    /*
@@ -107,12 +109,19 @@ static void filter_2nd_order(
    L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( mem[0], a2 ) );   /* y2*a2 */
    L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( mem[1], a1 ) );   /* y1*a1 */

#ifdef ISSUE_1836_replace_overflow_libcom
    L_y2 = L_shl_sat( L_sum, HP20_COEFF_SCALE );                              //??sat
    BASOP_SATURATE_ERROR_OFF_EVS
    BASOP_SATURATE_WARNING_OFF_EVS
    signal[0] = round_fx_sat( L_shl_sat( L_y2, prescale ) );                  //??sat //??sat
#else
    L_y2 = L_shl_o( L_sum, HP20_COEFF_SCALE, &Overflow );
    BASOP_SATURATE_ERROR_OFF_EVS
    BASOP_SATURATE_WARNING_OFF_EVS
    signal[0] = round_fx_o( L_shl_o( L_y2, prescale, &Overflow ), &Overflow );
    BASOP_SATURATE_WARNING_ON_EVS
#endif

    BASOP_SATURATE_WARNING_ON_EVS
    BASOP_SATURATE_ERROR_ON_EVS
    L_sum = HP50_Mpy_32_32_fix( b2, mem[3] );                   /* b2*x2 */
    L_sum = L_add( L_sum, HP50_Mode2_Mpy_32_16_fix( b1, x2 ) ); /* b1*x1 */
@@ -121,10 +130,17 @@ static void filter_2nd_order(
    L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( mem[1], a2 ) );   /* y2*a2 */
    L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y2, a1 ) );     /* y1*a1 */

#ifdef ISSUE_1836_replace_overflow_libcom
    L_y1 = L_shl_sat( L_sum, HP20_COEFF_SCALE );                                //??sat
    BASOP_SATURATE_ERROR_OFF_EVS
    BASOP_SATURATE_WARNING_OFF_EVS
    signal[stride] = round_fx_sat( L_shl_sat( L_y1, prescale ) );               //??sat
#else
    L_y1 = L_shl_o( L_sum, HP20_COEFF_SCALE, &Overflow );
    BASOP_SATURATE_ERROR_OFF_EVS
    BASOP_SATURATE_WARNING_OFF_EVS
    signal[stride] = round_fx_o( L_shl_o( L_y1, prescale, &Overflow ), &Overflow );
#endif
    BASOP_SATURATE_WARNING_ON_EVS
    move16();

@@ -140,10 +156,17 @@ static void filter_2nd_order(
        L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y2, a2 ) );
        L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y1, a1 ) );

#ifdef ISSUE_1836_replace_overflow_libcom
        L_y2 = L_shl_sat( L_sum, HP20_COEFF_SCALE );                                //??sat
        BASOP_SATURATE_ERROR_OFF_EVS
        BASOP_SATURATE_WARNING_OFF_EVS
        signal[i_mult( i, stride )] = round_fx_sat( L_shl_sat( L_y2, prescale ) );  //??sat
#else
        L_y2 = L_shl_o( L_sum, HP20_COEFF_SCALE, &Overflow );
        BASOP_SATURATE_ERROR_OFF_EVS
        BASOP_SATURATE_WARNING_OFF_EVS
        signal[i_mult( i, stride )] = round_fx_o( L_shl_o( L_y2, prescale, &Overflow ), &Overflow );
#endif
        BASOP_SATURATE_WARNING_ON_EVS
        /* y[i+1] = b2*x[i-1] + b1*x[i-0] + b2*x[i+1] + a2*y[i-1] + a1*y[i+0];  */
        BASOP_SATURATE_ERROR_ON_EVS
@@ -154,10 +177,17 @@ static void filter_2nd_order(
        L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y1, a2 ) );
        L_sum = L_add( L_sum, HP50_Mpy_32_32_fix( L_y2, a1 ) );

#ifdef ISSUE_1836_replace_overflow_libcom
        L_y1 = L_shl_sat( L_sum, HP20_COEFF_SCALE );                                          //??sat
        BASOP_SATURATE_ERROR_OFF_EVS
        BASOP_SATURATE_WARNING_OFF_EVS
        signal[i_mult( add( i, 1 ), stride )] = round_fx_sat( L_shl_sat( L_y1, prescale ) );  //??sat
#else
        L_y1 = L_shl_o( L_sum, HP20_COEFF_SCALE, &Overflow );
        BASOP_SATURATE_ERROR_OFF_EVS
        BASOP_SATURATE_WARNING_OFF_EVS
        signal[i_mult( add( i, 1 ), stride )] = round_fx_o( L_shl_o( L_y1, prescale, &Overflow ), &Overflow );
#endif
        BASOP_SATURATE_WARNING_ON_EVS
        move16();
    }
@@ -190,9 +220,11 @@ void hp20( Word16 signal[], /* i/o: signal to filter any *
{
    Word32 a1, b1, a2, b2;
    Word16 prescale, prescaleOld, diff;
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
#endif
#endif


    prescale = getScaleFactor16( signal, lg );
@@ -202,7 +234,11 @@ void hp20( Word16 signal[], /* i/o: signal to filter any *
    {
        prescale = s_min( prescale, diff );
    }
#ifdef ISSUE_1836_replace_overflow_libcom
    diff = norm_l( L_shl_sat( mem[3], prescaleOld ) );              //??sat
#else
    diff = norm_l( L_shl_o( mem[3], prescaleOld, &Overflow ) );
#endif
    if ( mem[3] != 0 )
    {
        prescale = s_min( prescale, diff );
@@ -212,27 +248,21 @@ void hp20( Word16 signal[], /* i/o: signal to filter any *
    IF( prescale != prescaleOld )
    {
        diff = sub( prescale, prescaleOld );
#ifdef ISSUE_1799_replace_L_shr_o
        mem[0] = L_shr_sat( mem[0], diff );
#ifdef ISSUE_1836_replace_overflow_libcom
        mem[0] = L_shr_sat( mem[0], diff );   //??sat
        move32();
        mem[1] = L_shr_sat( mem[1], diff );   //??sat
        move32();
        mem[2] = L_shr_sat( mem[2], diff );   //??sat
        move32();
        mem[3] = L_shr_sat( mem[3], diff );   //?sat
#else
        mem[0] = L_shr_o( mem[0], diff, &Overflow );
#endif
        move32();
#ifdef ISSUE_1799_replace_L_shr_o
        mem[1] = L_shr_sat( mem[1], diff );
#else
        mem[1] = L_shr_o( mem[1], diff, &Overflow );
#endif
        move32();
#ifdef ISSUE_1799_replace_L_shr_o
        mem[2] = L_shr_sat( mem[2], diff );
#else
        mem[2] = L_shr_o( mem[2], diff, &Overflow );
#endif
        move32();
#ifdef ISSUE_1799_replace_L_shr_o
        mem[3] = L_shr_sat( mem[3], diff );
#else
        mem[3] = L_shr_o( mem[3], diff, &Overflow );
#endif
        move32();
@@ -319,7 +349,9 @@ void hp20_fx_32(
    Word32 i;
    Word32 a1_fx, a2_fx, b1_fx, b2_fx;
    Word32 diff_pos, diff_neg;
#ifndef ISSUE_1836_replace_overflow_libcom
    Flag Overflow = 0;
#endif
    Word16 prescale, prescaleOld, prescale_current_frame, diff;

    prescale = getScaleFactor32( signal_fx, lg );
@@ -328,8 +360,14 @@ void hp20_fx_32(

    prescaleOld = extract_l( mem_fx[4] );

#ifdef ISSUE_1836_replace_overflow_libcom
    diff_pos = norm_l( L_shl_sat( L_max( mem_fx[2], mem_fx[3] ), prescaleOld ) );   //??sat
    diff_neg = norm_l( L_shl_sat( L_min( mem_fx[2], mem_fx[3] ), prescaleOld ) );   //??sat
#else
    diff_pos = norm_l( L_shl_o( L_max( mem_fx[2], mem_fx[3] ), prescaleOld, &Overflow ) );
    diff_neg = norm_l( L_shl_o( L_min( mem_fx[2], mem_fx[3] ), prescaleOld, &Overflow ) );
#endif


    diff = L_max( diff_pos, diff_neg );

@@ -341,27 +379,21 @@ void hp20_fx_32(
    prescale = s_min( 3, sub( 1 + HP20_COEFF_SCALE, prescale ) );

    diff = sub( prescale, prescaleOld );
#ifdef ISSUE_1799_replace_L_shr_o
#ifdef ISSUE_1836_replace_overflow_libcom
    mem_fx[0] = L_shr_sat( mem_fx[0], diff );
#else
    mem_fx[0] = L_shr_o( mem_fx[0], diff, &Overflow );
#endif
    move32();
#ifdef ISSUE_1799_replace_L_shr_o
    mem_fx[1] = L_shr_sat( mem_fx[1], diff );
#else
    mem_fx[1] = L_shr_o( mem_fx[1], diff, &Overflow );
#endif
    move32();
#ifdef ISSUE_1799_replace_L_shr_o
    mem_fx[2] = L_shr_sat( mem_fx[2], diff );
#else
    mem_fx[2] = L_shr_o( mem_fx[2], diff, &Overflow );
#endif
    move32();
#ifdef ISSUE_1799_replace_L_shr_o
    mem_fx[3] = L_shr_sat( mem_fx[3], diff );
#else
    mem_fx[0] = L_shr_o( mem_fx[0], diff, &Overflow );
    move32();
    mem_fx[1] = L_shr_o( mem_fx[1], diff, &Overflow );
    move32();
    mem_fx[2] = L_shr_o( mem_fx[2], diff, &Overflow );
    move32();
    mem_fx[3] = L_shr_o( mem_fx[3], diff, &Overflow );
#endif
    move32();
+6 −0
Original line number Diff line number Diff line
@@ -312,9 +312,11 @@ void hq2_bit_alloc_har_fx(

    Word16 exp_shift;

#ifndef ISSUE_1836_replace_overflow_libcom
    Flag Overflow;
    Overflow = 0;
    move32();
#endif

    L_THR1 = L_shl( L_deposit_l( THR1 ), SWB_BWE_LR_QRk );
    L_THR2 = L_shl( L_deposit_l( THR2 ), SWB_BWE_LR_QRk );
@@ -570,9 +572,13 @@ void hq2_bit_alloc_har_fx(

    L_temp = Mult_32_16( L_Ravg_sub[GRP_SB - 1], sub( GRP_SB, 1 ) ); /* Qbe+0+1 */
    L_temp = Mult_32_16( L_temp, Inv_norm_sum_fx );                  /* Qbe+1+QIpb+1 */
#ifdef ISSUE_1836_replace_overflow_libcom
    lf_hf_ge_r_fx = round_fx_sat( L_shl_sat( L_temp, sub( 15 + 16, sub( add( SWB_BWE_LR_Qbe, QIns ), 30 ) ) ) );    //??sat
#else
    lf_hf_ge_r_fx = round_fx_o( L_shl_o( L_temp, sub( 15 + 16, sub( add( SWB_BWE_LR_Qbe, QIns ), 30 ) ), &Overflow ), &Overflow );
    Overflow = 0; /* reset BASOP Overflow */
    move32();
#endif

    exp_normn = norm_s( norm_sum_fx );
    exp_normn = sub( exp_normn, 1 );
+18 −6
Original line number Diff line number Diff line
@@ -88,9 +88,11 @@ void mdct_spectrum_denorm_fx(

    Word16 cond_fx;

#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move16(); /* allow overflow happen. */
#endif
#endif

    exp_safe = 4; /* safe bit for overflow */
@@ -163,12 +165,12 @@ void mdct_spectrum_denorm_fx(
            pd_fx = div_s( shl( npulses[k], exp_normn ), shl( band_width[k], exp_normd ) ); /* 15 + (exp_norm - exp_normd) */
            Qpd = add( sub( exp_normn, exp_normd ), 15 );

#ifdef ISSUE_1796_replace_shl_o
            cond_fx = sub( shl_sat( pd_fx, sub( 15, Qpd ) ), pd_thresh_fx /*Q15*/ ); /* Q15 */
#ifdef ISSUE_1836_replace_overflow_libcom
            cond_fx = sub( shl_sat( pd_fx, sub( 15, Qpd ) ), pd_thresh_fx /*Q15*/ ); /* Q15 */  //??sat
#else
            cond_fx = sub( shl_o( pd_fx, sub( 15, Qpd ), &Overflow ), pd_thresh_fx /*Q15*/ ); /* Q15 */
#endif
            Overflow = 0;
#endif
            move16(); /* allow overflow happen. */
            IF( cond_fx < 0 )
            {
@@ -200,7 +202,11 @@ void mdct_spectrum_denorm_fx(
                /*gamma *= gain_tweak; */
                L_tmp = L_mult( gamma_fx, gain_tweak_fx ); /* Qgamma+Qtweak+1 */
                exp_norm = norm_l( L_tmp );
#ifdef ISSUE_1836_replace_overflow_libcom
                gamma_fx = round_fx_sat( L_shl( L_tmp, exp_norm ) );  //??sat
#else
                gamma_fx = round_fx_o( L_shl_o( L_tmp, exp_norm, &Overflow ), &Overflow );
#endif
                Qgamma = sub( add( add( Qgamma, Qtweak ), exp_norm ), 15 ); /*Qgamma+Qtweak+1+exp_norm-16; */
            }

@@ -264,9 +270,11 @@ void mdct_spectrum_denorm_ivas_fx(

    Word16 cond_fx;

#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move16(); /* allow overflow happen. */
#endif
#endif

    exp_safe = 4; /* safe bit for overflow */
@@ -339,12 +347,12 @@ void mdct_spectrum_denorm_ivas_fx(
            pd_fx = div_s( shl( npulses[k], exp_normn ), shl( band_width[k], exp_normd ) ); /* 15 + (exp_normn + exp_normd) */
            Qpd = add( sub( exp_normn, exp_normd ), 15 );

#ifdef ISSUE_1796_replace_shl_o
            cond_fx = sub( shl_sat( pd_fx, sub( 15, Qpd ) ), pd_thresh_fx /*Q15*/ ); /* Q15 */
#ifdef ISSUE_1836_replace_overflow_libcom
            cond_fx = sub( shl_sat( pd_fx, sub( 15, Qpd ) ), pd_thresh_fx /*Q15*/ ); /* Q15 */  //??sat
#else
            cond_fx = sub( shl_o( pd_fx, sub( 15, Qpd ), &Overflow ), pd_thresh_fx /*Q15*/ ); /* Q15 */
#endif
            Overflow = 0;
#endif
            move16(); /* allow overflow happen. */
            IF( cond_fx < 0 )
            {
@@ -376,7 +384,11 @@ void mdct_spectrum_denorm_ivas_fx(
                /*gamma *= gain_tweak; */
                L_tmp = L_mult( gamma_fx, gain_tweak_fx ); /* Qgamma+Qtweak+1 */
                exp_norm = norm_l( L_tmp );
#ifdef ISSUE_1836_replace_overflow_libcom
                gamma_fx = round_fx_sat( L_shl( L_tmp, exp_norm ) );  //??sat
#else
                gamma_fx = round_fx_o( L_shl_o( L_tmp, exp_norm, &Overflow ), &Overflow );
#endif
                Qgamma = sub( add( add( Qgamma, Qtweak ), exp_norm ), 15 ); /*Qgamma+Qtweak+1+exp_norm-16; */
            }