Commit 3f87f40f authored by vaillancour's avatar vaillancour
Browse files

Firs part of nonBE 2311 harmonisation

parent 4703bb6d
Loading
Loading
Loading
Loading
Loading
+44 −8
Original line number Diff line number Diff line
@@ -388,6 +388,9 @@ void Ener_per_band_comp_ivas_fx(

static void GSC_gain_adj(
    const Word16 coder_type,  /* i  : Coder type        */
#ifdef OPT_NBE_2311_HARM_GSC_GAIN
    const Word16 Mbands_gn,   /* i  : Number of band    */
#endif
    const Word32 core_brate,  /* i  : Bit rate          */
    const Word16 mean_g,      /* i  : Average gain Q12  */
    Word16 *old_y_gain,       /* i/o: Previous frame dequantized vector */
@@ -397,10 +400,23 @@ static void GSC_gain_adj(
{
    /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */
    Word16 Gain_off, i;

#ifdef OPT_NBE_2311_HARM_GSC_GAIN
    Word16 Fac_div;
    Fac_div = 102;
    move16();
#endif
#ifdef OPT_NBE_2311_HARM_GSC_GAIN
    test();
    IF( coder_type != INACTIVE && NE_16( coder_type, UNVOICED ) )
#else
    IF( coder_type != INACTIVE )
#endif    
    {
#ifdef OPT_NBE_2311_HARM_GSC_GAIN
        FOR( i = 0; i < Mbands_gn; i++ )
#else
        FOR( i = 0; i < MBANDS_GN; i++ )
#endif     
        {
            old_y_gain[i] = y_gain_tmp[i];
            move16();
@@ -412,7 +428,19 @@ static void GSC_gain_adj(
    {
        Gain_off = 0;
        move16();
#ifdef OPT_NBE_2311_HARM_GSC_GAIN
        test();
        IF( LE_32( core_brate, ACELP_5k00 ) && EQ_16( coder_type, UNVOICED ) )     /* IVAS LR mode only */
        {
            Gain_off = 18432;
            move16(); /* 9 -> Q11 */
            Fac_div = 205; /* Q15 -> Q16 to compensate for Gain_off being Q11 instead of Q12 */
            move16();
        }
        ELSE IF( LE_32( core_brate, ACELP_7k20 ) )
#else
        IF( LE_32( core_brate, ACELP_7k20 ) )
#endif
        {
            Gain_off = 32767;
            move16(); /* 8 -> Q12 */
@@ -444,7 +472,11 @@ static void GSC_gain_adj(
            old_y_gain[i] = y_gain_tmp[i];
            move16();
            /*y_gainQ[i] = y_gain_tmp[i]+mean_4g[0]-(i*(Gain_off/20.f)/((float) Mbands_gn));*/
#ifdef OPT_NBE_2311_HARM_GSC_GAIN
            y_gainQ[i] = add( y_gain_tmp[i], sub( mean_g, i_mult2( i, mult_r( Gain_off, Fac_div /* 20/MBANDS_GN in Q15 */ ) ) ) );
#else
            y_gainQ[i] = add( y_gain_tmp[i], sub( mean_g, i_mult2( i, mult_r( Gain_off, 102 /* 20/MBANDS_GN in Q15 */ ) ) ) );
#endif
            move16();
        }
    }
@@ -452,7 +484,7 @@ static void GSC_gain_adj(
    return;
}


#ifndef OPT_NBE_2311_HARM_GSC_GAIN
/*-------------------------------------------------------------------*
 * GSC_gain_adj_ivas_fx()
 *
@@ -532,7 +564,7 @@ static void GSC_gain_adj_ivas_fx(

    return;
}

#endif

/*-------------------------------------------------------------------*
 * GSC_gain_DQ()
@@ -930,7 +962,7 @@ Word16 gsc_gainQ_ivas_fx(
    return mean_4g_fx[0];
}


#ifndef OPT_BE_2311_HARM_GSC_GAIN
/*==========================================================================*/
/* FUNCTION : Word16 gsc_gaindec_fx()                                       */
/*--------------------------------------------------------------------------*/
@@ -951,7 +983,6 @@ Word16 gsc_gainQ_ivas_fx(
/* RETURN ARGUMENTS :                                                       */
/* _ (Word16)                  : average frequency gain                     */
/*==========================================================================*/
#ifndef OPT_BE_2311_HARM_GSC_GAIN
Word16 gsc_gaindec_fx(                             /* o  : average frequency gain    */
                       Decoder_State *st_fx,       /* i/o: decoder state structure   */
                       Word16 y_gainQ_fx[],        /* o  : quantized gain per band   */
@@ -1271,7 +1302,7 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */
            }
        }
    }

#ifndef OPT_NBE_2311_HARM_GSC_GAIN
#ifdef OPT_BE_2311_HARM_GSC_GAIN
    IF( st_fx->element_mode == EVS_MONO )
    {
@@ -1283,7 +1314,9 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */
        /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */
        GSC_gain_adj_ivas_fx( coder_type, Mbands_gn, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx );
    }

#else
    GSC_gain_adj( coder_type, Mbands_gn, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx );
#endif
    return mean_4g_fx;
}

@@ -1515,8 +1548,11 @@ Word16 gsc_gainQ_fx( /*Q12*/
    }

    /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */
#ifdef OPT_NBE_2311_HARM_GSC_GAIN
    GSC_gain_adj( coder_type, Mbands_gn, core_brate, mean_4g[0], y_gain_tmp2 /* dummy buffer */, y_gain_tmp, y_gainQ );
#else
    GSC_gain_adj( coder_type, core_brate, mean_4g[0], y_gain_tmp2 /* dummy buffer */, y_gain_tmp, y_gainQ );

#endif
    return mean_4g[0]; /*Q12*/
}

+2 −1
Original line number Diff line number Diff line
@@ -148,7 +148,8 @@
#define NONBE_OPT_2239_IVAS_FILTER_PROCESS  /* Dolby: Issue 2239, optimize ivas_filter_process_fx. */
#define NONBE_OPT_2193_EIG2X2               /* Dolby: Issue 2193, optimize eig2x2_fx. */
#define BE_FIX_2240_COMPUTE_COV_MTC_FX_FAST /* FhG: Speeds up covariance calculation e.g. 60 WMOPS for encoding -mc 7_1_4 24400 48 */
#define OPT_BE_2311_HARM_GSC_GAIN           /* VA:    BE part of the GSC gain harmonisation */
#define OPT_BE_2311_HARM_GSC_GAIN           /* VA:    BE part of the GSC gain harmonization */
#define OPT_NBE_2311_HARM_GSC_GAIN          /* VA:    NBE part of the GSC gain harmonization */
/* #################### End BASOP optimization switches ############################ */