Commit 713f2d39 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch '1772-replace-shr_o-by-overflow-free-alternatives' into 'main'

Resolve "replace shr_o by Overflow-free alternatives"

Closes #1772

See merge request !1829
parents ec3159d1 9e299235
Loading
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -197,7 +197,11 @@ void E_UTIL_deemph2( Word16 shift, Word16 *x, const Word16 mu, const Word16 L, W
    {
        FOR( i = 0; i < L; i++ )
        {
#ifdef ISSUE_1772_replace_shr_o
            L_tmp = L_msu_o( Mpy_32_16_1( L_tmp, mu ), shr_sat( x[i], shift ), -32768 /*1.0f in Q15*/, &Overflow ); /*Qx-shift+16*/
#else
            L_tmp = L_msu_o( Mpy_32_16_1( L_tmp, mu ), shr_o( x[i], shift, &Overflow ), -32768 /*1.0f in Q15*/, &Overflow ); /*Qx-shift+16*/
#endif
            x[i] = round_fx_o( L_tmp, &Overflow ); /*Qx-shift*/
            move16();
        }
+10 −2
Original line number Diff line number Diff line
@@ -97,7 +97,11 @@ void ivas_fine_gain_pred_fx(

                    /*gp *= 1.0f - 0.05f / accuracy; */
                    tmp = div_s( 13107, accuracy ); /* 0.05 in Q18 */
#ifdef ISSUE_1772_replace_shr_o
                    tmp = shr_sat( tmp, sub( 34, exp ) ); /*15+18-exp+16-15=34-exp */
#else
                    tmp = shr_o( tmp, sub( 34, exp ), &Overflow ); /*15+18-exp+16-15=34-exp */
#endif
                    tmp = sub( 32767, tmp );
                    tmp = s_max( 27554, tmp ); /* Limit attenuation to norm quantizer error, 2^-0.25 in Q15 */
                    gp = mult_r( tmp, gp );    /*15+12+1-16=12 */
@@ -205,7 +209,11 @@ void fine_gain_pred_fx(

                    /*gp *= 1.0f - 0.05f / accuracy; */
                    tmp = div_s( 13107, accuracy ); /* 0.05 in Q18 */
#ifdef ISSUE_1772_replace_shr_o
                    tmp = shr_sat( tmp, sub( 34, exp ) ); /*15+18-exp+16-15=34-exp */
#else
                    tmp = shr_o( tmp, sub( 34, exp ), &Overflow ); /*15+18-exp+16-15=34-exp */
#endif
                    tmp = sub( 32767, tmp );
                    tmp = s_max( 27554, tmp ); /* Limit attenuation to norm quantizer error, 2^-0.25 in Q15 */
                    gp = mult_r( tmp, gp );    /*15+12+1-16=12 */
+1 −0
Original line number Diff line number Diff line
@@ -103,6 +103,7 @@
#define FIX_1762_COMPILER_ISSUE                 /* FhG: fix compiler issues with W_mac_32_32() + ONE_IN_Q30 */
#define ISSUE_1751_replace_shl_ro               /*FhG: replace shl_ro by overflow-free alternatives*/
#define ISSUE_1770_replace_shr_ro               /* FhG: replace by non-overflow-alternative - BE */
#define ISSUE_1772_replace_shr_o                /* FhG: replace by non-overflow-alternative - BE */

#define FIX_1735_W_SHL_SAT_L                    /* FhG: Usage of W_shl_sat_l() */

+10 −0
Original line number Diff line number Diff line
@@ -188,14 +188,20 @@ void syn_filt_fx(
    Word16 *yy;
    Word32 s;
    Word16 q;
#ifndef ISSUE_1772_replace_shr_o
    Flag Overflow = 0;
    move16();
#endif
    Word16 a0;

    yy = &buf[0];
    q = add( norm_s( a[0] ), 1 );

#ifdef ISSUE_1772_replace_shr_o
    a0 = shr_sat( a[0], shift ); /* input / 2^shift */
#else
    a0 = shr_o( a[0], shift, &Overflow ); /* input / 2^shift */
#endif

    /*------------------------------------------------------------------*
     * copy initial filter states into synthesis buffer and do synthesis
@@ -373,7 +379,11 @@ void E_UTIL_synthesis( const Word16 shift, const Word16 a[], const Word16 x[], W
     *-----------------------------------------------------------------------*/
    mem += m; /*move16();*/

#ifdef ISSUE_1772_replace_shr_o
    a0 = shr_sat( a[0], shift ); /* input / 2^shift */
#else
    a0 = shr_o( a[0], shift, &Overflow ); /* input / 2^shift */
#endif
    /*-----------------------------------------------------------------------*
     * Do the filtering
     *-----------------------------------------------------------------------*/
+8 −0
Original line number Diff line number Diff line
@@ -638,7 +638,11 @@ void ivas_HQ_FEC_Mem_update_fx(
            exp2 = norm_l( hHQ_nbfec->ynrm_values_fx[i][0] );
            tmp_fx = div_s( extract_h( L_shl( en_high_fx[i], exp1 ) ), extract_h( L_shl( hHQ_nbfec->ynrm_values_fx[i][0], exp2 ) ) );
            exp = add( 15, sub( exp1, exp2 ) );
#ifdef ISSUE_1772_replace_shr_o
            *mean_en_high_fx = add_o( *mean_en_high_fx, shr_sat( tmp_fx, sub( exp, 5 ) ), &Overflow );
#else
            *mean_en_high_fx = add_o( *mean_en_high_fx, shr_o( tmp_fx, sub( exp, 5 ), &Overflow ), &Overflow );
#endif
            move16();
        }
        *mean_en_high_fx = mult( *mean_en_high_fx, inv_tbl_fx[sub( num_Sb, k )] );
@@ -924,7 +928,11 @@ void HQ_FEC_Mem_update_fx(
            exp2 = norm_l( hHQ_nbfec->ynrm_values_fx[i][0] );
            tmp_fx = div_s( extract_h( L_shl( en_high_fx[i], exp1 ) ), extract_h( L_shl( hHQ_nbfec->ynrm_values_fx[i][0], exp2 ) ) );
            exp = add( 15, sub( exp1, exp2 ) );
#ifdef ISSUE_1772_replace_shr_o
            *mean_en_high_fx = add_o( *mean_en_high_fx, shr_sat( tmp_fx, sub( exp, 5 ) ), &Overflow );
#else
            *mean_en_high_fx = add_o( *mean_en_high_fx, shr_o( tmp_fx, sub( exp, 5 ), &Overflow ), &Overflow );
#endif
            move16();
        }
        *mean_en_high_fx = mult( *mean_en_high_fx, inv_tbl_fx[sub( num_Sb, k )] );
Loading