Commit 044c43e0 authored by vaillancour's avatar vaillancour
Browse files

Change of strategy and and reuse Ittiam approache for the first computation of...

Change of strategy and and reuse Ittiam approache for the first computation of gains and Q_exc adjutement (for the second run, it not necessary as both excitation vectors have the same dynamic
parent 64396215
Loading
Loading
Loading
Loading
Loading
+44 −17
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ void Comp_and_apply_gain_fx(
    Word16 Mbands_gn,        /* i  : number of bands                       */
    const Word16 ReUseGain,  /* i  : Reuse the gain in Ener_per_bd_yQ      */
#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX
    const Word16 max_target_ener, /* i  : max_target_ener of Ener_per_bd_iQ   */
    const Word16 Flag_adj_q_exc, /* i  : Flag allowing Q_exc adjustment   */
#endif
    Word16 Qexc_diff,
    Word16 Q_exc )
@@ -92,6 +92,8 @@ void Comp_and_apply_gain_fx(
    Word16 L16, frac, exp1, tmp_exp;
#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX
    Word16 Q_adapt;
    Word16 Q_exc_diffQ[L_FRAME16k];
    Word32 exc_diffQ32[L_FRAME16k];
#endif
    Word32 L32;

@@ -102,16 +104,7 @@ void Comp_and_apply_gain_fx(
    move16();

    tmp_exp = add( 14, sub( Q_exc, Qexc_diff ) ); /* In case of reuse, it can be computed outside the loop*/
#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX
    Q_adapt = 0;
    move16();
    test();
    test();
    IF( GT_16( Q_exc, 3 ) && EQ_16( ReUseGain, 0 ) && GT_16( max_target_ener, 12 ) ) /* When target energy is high, Q_exc shouldn't be high too, addresses cases when switching from CNG or from almos*/
    {
        Q_adapt = sub( 3 - 1, Q_exc ); /* add extra 1 bit headroom */
    }
#endif

    FOR( i_band = 0; i_band < Mbands_gn; i_band++ )
    {
        StartBin = add( StartBin, NB_Qbins );
@@ -147,8 +140,23 @@ void Comp_and_apply_gain_fx(
            move16(); /*Q1     */
            tmp_exp = add( add( exp1, 1 ), sub( Q_exc, Qexc_diff ) );
#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX
            tmp_exp = add( tmp_exp, Q_adapt );
            IF( Flag_adj_q_exc != 0)
            {
                FOR( i = StartBin; i < NB_Qbins + StartBin; i++ )
                {
                    exc_diffQ32[i] = L_mult( exc_diffQ[i], y_gain ); /*Qexc_diff+15 */
                    move32();
                    Q_exc_diffQ[i] = Q_exc;
                    if ( exc_diffQ[i] )
                    {
                        Q_exc_diffQ[i] = sub( Q_exc_diffQ[i], tmp_exp );
                        move16();
                    }
                }
            }
            ELSE
#endif
            {
                FOR( i = StartBin; i < NB_Qbins + StartBin; i++ )
                {
                    L32 = L_mult( exc_diffQ[i], y_gain );                     /*Qexc_diff+15 */
@@ -156,9 +164,28 @@ void Comp_and_apply_gain_fx(
                    move16();
                }
            }
            
        }
    }
#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX
    return add( Q_exc, Q_adapt );
    Q_adapt = Q_exc;
    move16();
    test();
    IF( EQ_16( ReUseGain, 0 ) && Flag_adj_q_exc != 0 )
    {
        Word16 total_bins = add( StartBin, NB_Qbins );
        move16();
        FOR(i = 0; i < total_bins; i++)
        {
            Q_adapt = s_min( Q_adapt, add( Q_exc_diffQ[i], norm_l( exc_diffQ32[i] ) ) );
            move16();
        }
        FOR(i = 0; i < total_bins; i++)
        {
            exc_diffQ[i] = round_fx( L_shl( exc_diffQ32[i], sub( Q_adapt, Q_exc_diffQ[i] ) ) ); /*Q_exc*/
        }
    }
    return Q_adapt;
#else
    return;
#endif
+7 −10
Original line number Diff line number Diff line
@@ -1082,7 +1082,7 @@ void highband_exc_dct_in_ivas_fx(
    Word16 tmp2;
    Word16 *end, Q_hb_exc;
#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX
    Word16 max_target_ener, old_Q_exc;
    Word16 Flag_adj_q_exc, old_Q_exc;
#endif

    FOR( j = 10; j < MBANDS_GN; j++ )
@@ -1408,24 +1408,21 @@ void highband_exc_dct_in_ivas_fx(
        }
    }
#elif defined FIX_2380_HARM_GSC_GAIN_COMP_FX
    max_target_ener = 0;
    Flag_adj_q_exc = 0;
    move16();
    IF( NE_16( element_mode, EVS_MONO ) && lt_ener_per_band_fx != NULL ) /* to keep EVS BE */
    IF( NE_16( element_mode, EVS_MONO ) && lt_ener_per_band_fx != NULL ) /* to keep all EVS BE */
    {
        FOR( i = 0; i < MBANDS_GN / 2; i++ )
        {
            max_target_ener = s_max( max_target_ener, Ener_per_bd_iQ[i] );
        }
        max_target_ener = sub( 15, norm_s( max_target_ener ) );
        Flag_adj_q_exc = 1;
        move16();
    }
    old_Q_exc = *Q_exc;
    move16();
    *Q_exc = Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, max_target_ener, Qexc_diffQ, *Q_exc );
    *Q_exc = Comp_and_apply_gain_fx( exc_diffQ, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 0, Flag_adj_q_exc, Qexc_diffQ, *Q_exc );
    Scale_sig( exc_dct_in, L_frame, sub( *Q_exc, old_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, max_target_ener, Qexc_diffQ, *Q_exc );
        Comp_and_apply_gain_fx( exc_wo_nf, Ener_per_bd_iQ, Ener_per_bd_yQ, last_bin, 1, Flag_adj_q_exc, Qexc_diffQ, *Q_exc );
        Vr_add( exc_dct_in, exc_wo_nf, exc_wo_nf, L_frame );
    }
#else /* #if defined FIX_2338_HARM_GSC_GAIN_COMP */
+1 −1
Original line number Diff line number Diff line
@@ -1714,7 +1714,7 @@ void Comp_and_apply_gain_fx(
    Word16 Mbands_gn,        /* i  : number of bands                       */
    const Word16 ReUseGain,  /* i  : Reuse the gain in Ener_per_bd_yQ      */
#ifdef FIX_2380_HARM_GSC_GAIN_COMP_FX
    const Word16 max_target_ener, /* i  : Ener_per_bd_iQ of lt_ener_per_band_fx   */
    const Word16 Flag_adj_q_exc, /* i  : Ener_per_bd_iQ of lt_ener_per_band_fx   */
#endif
    Word16 Qexc_diff,
    Word16 Q_exc );