Commit 68f73a3b authored by Fabian Bauer's avatar Fabian Bauer
Browse files

lib_com/frame_ener_fx.c

lib_com/get_gain_fx.c
lib_com/gs_bitallocation_fx.c
lib_com/gs_bitallocation_ivas_fx.c
lib_com/gs_gains_fx.c
lib_com/gs_noisefill_fx.c : completed overflow op replacement
parent cc77b482
Loading
Loading
Loading
Loading
Loading
+18 −3
Original line number Diff line number Diff line
@@ -239,14 +239,20 @@ Word16 frame_energy_fx( /* o : Frame energy in Q8
    const Word16 *pt1;
    Word16 tmp16, exp1, exp2, tmp1, tmp2;
    Word16 len, enern;
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif


    /* len = (0.5f * (pitch[2]/64.0 + pitch[3]/64.0) + 0.5f) */
#ifdef ISSUE_1836_replace_overflow_libcom
    len = mult_r( add_sat( pitch[2], pitch[3] ), 256 ); //??sat
#else
    len = mult_r( add_o( pitch[2], pitch[3], &Overflow ), 256 );
#endif

    if ( LT_16( len, L_SUBFR ) )
    {
@@ -277,19 +283,28 @@ Word16 frame_energy_fx( /* o : Frame energy in Q8

    /*add ld(2^exp1)=exp1 but check format, first*/
    tmp16 = sub( sub( 15, norm_s( exp1 ) ), 5 ); /*factor to shift Ltmp and exp1 with (shr) to avoid overflows when adding*/
#ifdef ISSUE_1799_replace_L_shr_o
    Ltmp = L_shr_sat( Ltmp, tmp16 ); /*Q25, tmp16*/
#ifdef ISSUE_1836_replace_overflow_libcom
    Ltmp = L_shr_sat( Ltmp, tmp16 ); /*Q25, tmp16*/ //??sat
#else
    Ltmp = L_shr_o( Ltmp, tmp16, &Overflow ); /*Q25, tmp16*/
#endif
    exp2 = shr( exp1, tmp16 );                                           /*Q0 , tmp16*/
#ifdef ISSUE_1836_replace_overflow_libcom
    Ltmp = L_add_sat( Ltmp, L_shl( L_deposit_l( exp2 ), 25 ) );          /*Q25, tmp16, normalized*/ //??sat
#else
    Ltmp = L_add_o( Ltmp, L_shl( L_deposit_l( exp2 ), 25 ), &Overflow ); /*Q25, tmp16, normalized*/
#endif

    /*make 10*log10 out of log2*/
    Ltmp = Mpy_32_16_1( Ltmp, LG10 );                                       /*Q25,tmp16 * Q13 = Q23, tmp16*/
#ifdef ISSUE_1836_replace_overflow_libcom
    *frame_ener = extract_h( L_shl_sat( Ltmp, add( tmp16, 1 ) ) ); /*Q8*/ //??sat
    move16();
    enern = sub_sat( *frame_ener, lp_speech ); /*Q8*/ //??sat
#else
    *frame_ener = extract_h( L_shl_o( Ltmp, add( tmp16, 1 ), &Overflow ) ); /*Q8*/
    move16();
    enern = sub_o( *frame_ener, lp_speech, &Overflow ); /*Q8*/

#endif
    return enern;
}
+13 −0
Original line number Diff line number Diff line
@@ -53,10 +53,12 @@ Word32 get_gain( /* output: codebook gain (adaptive or fixed)
{
    Word32 tcorr, tener, Lgain;
    Word16 exp_c, exp_e, exp, tmp;
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif


    tcorr = L_deposit_l( 0 );
@@ -70,8 +72,13 @@ Word32 get_gain( /* output: codebook gain (adaptive or fixed)
    tcorr = Dot_product16HQ( 0, x, y, n, &exp_c );
    tener = Dot_productSq16HQ( 0, y, n, &exp_e );

#ifdef ISSUE_1836_replace_overflow_libcom
    BASOP_Util_Divide_MantExp( round_fx_sat( tcorr ), exp_c, s_max( round_fx_sat( tener ), 1 ), exp_e, &tmp, &exp ); //??sat
    Lgain = L_shl_sat( L_deposit_l( tmp ) /*Q15*/, add( 1, exp ) ) /*Q16*/; //?sat
#else
    BASOP_Util_Divide_MantExp( round_fx_o( tcorr, &Overflow ), exp_c, s_max( round_fx_o( tener, &Overflow ), 1 ), exp_e, &tmp, &exp );
    Lgain = L_shl_o( L_deposit_l( tmp ) /*Q15*/, add( 1, exp ), &Overflow ) /*Q16*/;
#endif

    return Lgain;
}
@@ -84,9 +91,11 @@ Word32 get_gain2( /* output: codebook gain (adaptive or fixed)
{
    Word32 tcorr, tener, Lgain;
    Word16 m_corr, m_ener, negative, Q_corr, Q_ener;
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif

    negative = 0;
@@ -130,7 +139,11 @@ Word32 get_gain2( /* output: codebook gain (adaptive or fixed)

    Q_corr = sub( Q_corr, Q_ener );

#ifdef ISSUE_1836_replace_overflow_libcom
    Lgain = L_shl_sat( L_deposit_l( m_corr ), add( Q_corr, 1 ) ); /* Lgain in Q16 */ //??sat
#else
    Lgain = L_shl_o( L_deposit_l( m_corr ), add( Q_corr, 1 ), &Overflow ); /* Lgain in Q16 */
#endif

    if ( negative != 0 )
    {
+6 −0
Original line number Diff line number Diff line
@@ -77,8 +77,10 @@ void bands_and_bit_alloc_fx(
    Word16 w_sum_bit;
    (void) GSC_IVAS_mode;
    (void) element_mode;
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
#endif
#endif
    nb_tot_bands = MBANDS_GN;
    move16();
@@ -93,7 +95,11 @@ void bands_and_bit_alloc_fx(
    set16_fx( out_bits_per_bands, 0, MBANDS_GN_BITALLOC16k );

    /* To adapt current energy band to PVQ freq band for sorting*/
#ifdef ISSUE_1836_replace_overflow_libcom
    ener_vec[0] = add_sat( Ener_per_bd_iQ[0], Ener_per_bd_iQ[1] ); /*Q12 */ //??sat
#else
    ener_vec[0] = add_o( Ener_per_bd_iQ[0], Ener_per_bd_iQ[1], &Overflow ); /*Q12 */
#endif
    Copy( Ener_per_bd_iQ_tmp + 1, ener_vec, MBANDS_GN - 1 );                /*Q12 */
    ener_vec[MBANDS_GN - 1] = ener_vec[MBANDS_GN - 2];
    move16();
+6 −0
Original line number Diff line number Diff line
@@ -105,8 +105,10 @@ void bands_and_bit_alloc_ivas_fx(
    Word32 bits_per_bands[MBANDS_GN_BITALLOC16k]; /* Q18 */
    Word16 w_sum_bit;
    Word16 fzero_val;
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
#endif
#endif
    nb_tot_bands = MBANDS_GN;
    move16();
@@ -120,7 +122,11 @@ void bands_and_bit_alloc_ivas_fx(
    set16_fx( out_bits_per_bands, 0, MBANDS_GN_BITALLOC16k );

    /* To adapt current energy band to PVQ freq band for sorting*/
#ifdef ISSUE_1836_replace_overflow_libcom
    ener_vec[0] = add_sat( Ener_per_bd_iQ[0], Ener_per_bd_iQ[1] ); /*Q12 */ //??sat
#else
    ener_vec[0] = add_o( Ener_per_bd_iQ[0], Ener_per_bd_iQ[1], &Overflow ); /*Q12 */
#endif
    move16();
    Copy( Ener_per_bd_iQ + 1, ener_vec, MBANDS_GN - 1 ); /*Q12 */
    ener_vec[MBANDS_GN - 1] = ener_vec[MBANDS_GN - 2];
+25 −3
Original line number Diff line number Diff line
@@ -84,9 +84,11 @@ void Comp_and_apply_gain_fx(
    Word16 y_gain;
    Word16 L16, frac, exp1, tmp_exp;
    Word32 L32;
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif

    /* Recreate excitation for local synthesis and decoder */
@@ -108,9 +110,15 @@ void Comp_and_apply_gain_fx(

            FOR( i = StartBin; i < NB_Qbins + StartBin; i++ )
            {
#ifdef ISSUE_1836_replace_overflow_libcom
                L32 = L_shl_sat( L_mult( exc_diffQ[i], y_gain ), tmp_exp );          /*Q_exc+16 */  //??sat
                exc_diffQ[i] = round_fx_sat( L32 );                                  /*Q_exc */     //??sat
                move16();
#else
                L32 = L_shl_o( L_mult( exc_diffQ[i], y_gain ), tmp_exp, &Overflow ); /*Q_exc+16 */
                exc_diffQ[i] = round_fx_o( L32, &Overflow );                         /*Q_exc */
                move16();
#endif
            }
        }
        ELSE
@@ -126,7 +134,7 @@ void Comp_and_apply_gain_fx(
            y_gain = extract_l( Pow2( 14, frac ) );                      /* Put 14 as exponent so that */
                                                                         /* output of Pow2() will be: */
                                                                         /* 16384 < Pow2() <= 32767 */
#ifdef ISSUE_1796_replace_shl_o
#ifdef ISSUE_1836_replace_overflow_libcom
            Ener_per_bd_yQ[i_band] = shl_sat( y_gain, sub( exp1, 13 ) );
#else
            Ener_per_bd_yQ[i_band] = shl_o( y_gain, sub( exp1, 13 ), &Overflow );
@@ -137,7 +145,11 @@ void Comp_and_apply_gain_fx(
            FOR( i = StartBin; i < NB_Qbins + StartBin; i++ )
            {
                L32 = L_mult( exc_diffQ[i], y_gain );                                       /*Qexc_diff+15 */
#ifdef ISSUE_1836_replace_overflow_libcom
                exc_diffQ[i] = round_fx_sat( L_shl_sat( L32, tmp_exp ) );                   /*Q_exc */ //??sat //??sat
#else
                exc_diffQ[i] = round_fx_o( L_shl_o( L32, tmp_exp, &Overflow ), &Overflow ); /*Q_exc */
#endif
                move16();
            }
        }
@@ -161,9 +173,11 @@ void Comp_and_apply_gain_ivas_fx(
    Word16 L16, frac, exp1, tmp_exp;
    Word32 L32;
    Word16 Q_exc_diffQ[L_FRAME16k];
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif

    /* Recreate excitation for local synthesis and decoder */
@@ -186,7 +200,11 @@ void Comp_and_apply_gain_ivas_fx(
            FOR( i = StartBin; i < NB_Qbins + StartBin; i++ )
            {
                L32 = L_mult( exc_diffQ[i], y_gain );        /*Q_exc+16-tmp_exp */
#ifdef ISSUE_1836_replace_overflow_libcom
                exc_diffQ[i] = round_fx_sat( L32 );          /*Q_exc-tmp_exp */ //??sat
#else
                exc_diffQ[i] = round_fx_o( L32, &Overflow ); /*Q_exc-tmp_exp */
#endif
                move16();
                IF( exc_diffQ[i] )
                {
@@ -212,10 +230,10 @@ void Comp_and_apply_gain_ivas_fx(
            y_gain = extract_l( Pow2( 14, frac ) );                          /* Put 14 as exponent so that */
                                                                             /* output of Pow2() will be: */
                                                                             /* 16384 < Pow2() <= 32767 */
#ifdef ISSUE_1796_replace_shl_o
#ifdef ISSUE_1836_replace_overflow_libcom
            Ener_per_bd_yQ[i_band] = shl_sat( y_gain, sub( exp1, 13 ) ); /*Q13*/
#else
            Ener_per_bd_yQ[i_band] = shl_o( y_gain, sub( exp1, 13 ), &Overflow ); /*Q13*/
            Ener_per_bd_yQ[i_band] = shl_o( y_gain, sub( exp1, 13 ), &Overflow ); /*Q13*/   //??sat
#endif
            move16(); /*Q1     */
            tmp_exp = add( add( exp1, 1 ), sub( *Q_exc, Qexc_diff ) );
@@ -223,7 +241,11 @@ void Comp_and_apply_gain_ivas_fx(
            FOR( i = StartBin; i < NB_Qbins + StartBin; i++ )
            {
                L32 = L_mult( exc_diffQ[i], y_gain );        /*Qexc_diff+15 */
#ifdef ISSUE_1836_replace_overflow_libcom
                exc_diffQ[i] = round_fx_sat( L32 );          /*Q_exc-tmp_exp */ //??sat
#else
                exc_diffQ[i] = round_fx_o( L32, &Overflow ); /*Q_exc-tmp_exp */
#endif
                move16();
                IF( exc_diffQ[i] )
                {
Loading