Commit 9369ec04 authored by multrus's avatar multrus
Browse files

[cleanup] accept FIX_2338_HARM_GSC_GAIN_COMP

parent 14e73093
Loading
Loading
Loading
Loading
+0 −102
Original line number Diff line number Diff line
@@ -189,108 +189,6 @@ void Comp_and_apply_gain_fx(
    return;
#endif
}
#ifndef FIX_2338_HARM_GSC_GAIN_COMP


void Comp_and_apply_gain_ivas_fx(
    Word16 exc_diffQ[],      /* i/o: Quantized excitation                   */
    Word16 Ener_per_bd_iQ[], /* i  : Target ener per band               Q13 */
    Word16 Ener_per_bd_yQ[], /* i/o  : Ener per band for norm vector     i->Q13/o->Q13 */
    Word16 Mbands_gn,        /* i  : number of bands                        */
    const Word16 ReUseGain,  /* i  : Reuse the gain in Ener_per_bd_yQ       */
    Word16 Qexc_diff,
    Word16 *Q_exc )
{
    Word16 i, i_band;
    Word16 StartBin, NB_Qbins;
    Word16 y_gain;
    Word16 L16, frac, exp1, tmp_exp;
    Word32 L32;
    Word16 Q_exc_diffQ[L_FRAME16k];

    /* Recreate excitation for local synthesis and decoder */
    StartBin = 0;
    move16();
    NB_Qbins = 0;
    move16();

    tmp_exp = add( 14, sub( *Q_exc, Qexc_diff ) ); /* In case of reuse, it can be computed outside the loop*/
    FOR( i_band = 0; i_band < Mbands_gn; i_band++ )
    {
        StartBin = add( StartBin, NB_Qbins );
        NB_Qbins = mfreq_bindiv_loc[i_band];
        move16();
        IF( EQ_16( ReUseGain, 1 ) )
        {
            y_gain = Ener_per_bd_yQ[i_band]; /*Q13*/
            move16();

            FOR( i = StartBin; i < NB_Qbins + StartBin; i++ )
            {
                L32 = L_mult( exc_diffQ[i], y_gain ); /*Q_exc+16-tmp_exp */
                exc_diffQ[i] = round_fx_sat( L32 );   /*Q_exc-tmp_exp */
                move16();
                IF( exc_diffQ[i] )
                {
                    Q_exc_diffQ[i] = sub( *Q_exc, tmp_exp );
                }
                ELSE
                {
                    Q_exc_diffQ[i] = *Q_exc;
                }
                move16();
            }
        }
        ELSE
        {
            /*-----------------------------------------------------------------*
             * y_gain  = pow(10.0, (Ener_per_bd_iQ[i_band]-Ener_per_bd_yQ[i_band]))
             * = pow(2, 3.321928*(Ener_per_bd_iQ[i_band]-Ener_per_bd_yQ[i_band]))
             *-----------------------------------------------------------------*/

            L16 = sub_sat( Ener_per_bd_iQ[i_band], Ener_per_bd_yQ[i_band] ); /*Q12 */
            L32 = L_mult( L16, 27213 );                                      /* 3.321928 in Q13 -> Q26 */
            L32 = L_shr( L32, 10 );                                          /* From Q26 to Q16 */
            frac = L_Extract_lc( L32, &exp1 );                               /* Extract exponent of gcode0 */
            y_gain = extract_l( Pow2( 14, frac ) );                          /* Put 14 as exponent so that */
                                                                             /* output of Pow2() will be: */
                                                                             /* 16384 < Pow2() <= 32767 */
            Ener_per_bd_yQ[i_band] = shl_sat( y_gain, sub( exp1, 13 ) );     /*Q13*/
            move16();                                                        /*Q1     */
            tmp_exp = add( add( exp1, 1 ), sub( *Q_exc, Qexc_diff ) );

            FOR( i = StartBin; i < NB_Qbins + StartBin; i++ )
            {
                L32 = L_mult( exc_diffQ[i], y_gain ); /*Qexc_diff+15 */
                exc_diffQ[i] = round_fx_sat( L32 );   /*Q_exc-tmp_exp */
                move16();
                IF( exc_diffQ[i] )
                {
                    Q_exc_diffQ[i] = sub( *Q_exc, tmp_exp );
                }
                ELSE
                {
                    Q_exc_diffQ[i] = *Q_exc;
                }
                move16();
            }
        }
    }

    FOR( i = 0; i < StartBin + NB_Qbins; i++ )
    {
        *Q_exc = s_min( *Q_exc, add( Q_exc_diffQ[i], norm_s( exc_diffQ[i] ) ) );
        move16();
    }
    FOR( i = 0; i < StartBin + NB_Qbins; i++ )
    {
        exc_diffQ[i] = shl( exc_diffQ[i], sub( *Q_exc, Q_exc_diffQ[i] ) ); /*Q_exc*/
        move16();
    }

    return;
}
#endif


/*========================================================================*/
+1 −41
Original line number Diff line number Diff line
@@ -949,47 +949,7 @@ void highband_exc_dct_in_fx(
            move16();
        }
    }
#if !defined FIX_2338_HARM_GSC_GAIN_COMP && !defined FIX_2380_HARM_GSC_GAIN_COMP_FX
    IF( EQ_16( element_mode, EVS_MONO ) )
    {
        Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, *Q_exc );

        IF( exc_wo_nf != NULL )
        {
            Comp_and_apply_gain_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Qexc_diffQ, *Q_exc );
            Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame );
        }
    }
    ELSE
    {
        Word16 Q_tmp = *Q_exc;
        move16();
        Word16 Q_old = *Q_exc;
        move16();
        Comp_and_apply_gain_ivas_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Qexc_diffQ, Q_exc );

        IF( exc_wo_nf != NULL )
        {
            Comp_and_apply_gain_ivas_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Qexc_diffQ, &Q_tmp );
            IF( GT_16( Q_tmp, *Q_exc ) )
            {
                Scale_sig( exc_wo_nf, L_frame, sub( *Q_exc, Q_tmp ) );
            }
            ELSE IF( LT_16( Q_tmp, *Q_exc ) )
            {
                Scale_sig( exc_diffQ, L_frame, sub( Q_tmp, *Q_exc ) );
                *Q_exc = Q_tmp;
                move16();
            }
            Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, Q_old ) );
            Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame );
        }
        ELSE
        {
            Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, Q_old ) );
        }
    }
#elif defined FIX_2380_HARM_GSC_GAIN_COMP_FX
#if defined FIX_2380_HARM_GSC_GAIN_COMP_FX
    Flag_adj_q_exc = 0;
    move16();
    IF( NE_16( element_mode, EVS_MONO ) && lt_ener_per_band_fx != NULL ) /* to keep all EVS BE */
+0 −1
Original line number Diff line number Diff line
@@ -98,7 +98,6 @@
/* #################### Start NON-BE switches ############################ */
/* any switch which is non-be wrt. TS 26.251 V3.0 */

#define FIX_2338_HARM_GSC_GAIN_COMP                     /* VA: basop issue 2338: harmonization of band gain computation for both EVS and IVAS */
#define FIX_BASOP_2361_OTR                              /* FhG: Basop issue 2361: Orientation tracking tests for equivalent rotations fail */
#define FIX_2396_CONSTANT_STRIDE_IN_TC_BUFFER           /* FhG/VA: basop issue 2396: keep TC channel pointers in one constant place during decoding and rendering */
#define FIX_2408_FD_BWE_UPDATE                          /* VA: basop issue 2408: bug-fix in the FD BWE memory updates in wb_pre_proc_ivas_fx()  */
+0 −10
Original line number Diff line number Diff line
@@ -1698,16 +1698,6 @@ void Comp_and_apply_gain_fx(
    Word16 Qexc_diff,
    Word16 Q_exc );

#ifndef FIX_2338_HARM_GSC_GAIN_COMP
void Comp_and_apply_gain_ivas_fx(
    Word16 exc_diffQ[],      /* i/o: Quantized excitation                  */
    Word16 Ener_per_bd_iQ[], /* i  : Target ener per band              Q13 */
    Word16 Ener_per_bd_yQ[], /* i/o  : Ener per band for norm vector     i->Q13/o->Q13 */
    Word16 Mbands_gn,        /* i  : number of bands                       */
    const Word16 ReUseGain,  /* i  : Reuse the gain in Ener_per_bd_yQ      */
    Word16 Qexc_diff,
    Word16 *Q_exc );
#endif
void pre_echo_att_fx(
    Word32 *Last_frame_ener_fx,      /* i/o: Energy of the last frame         2*Q_new+1*/
    Word16 *exc_fx,                  /* i/o: Excitation of the current frame  Q_new*/