Commit 6ed87933 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

ivas_td_low_rate_dec converted to fixed point.

[x]Implemented td_low_rate_dec_fx and re-implemented
some EVS functions with IVAS specific processing
(disabled under ADD_LRTD macro).
[x]Examples:
- bands_and_bit_alloc_ivas_fx required conversion of
additional bit allocation processing
- GSC_gain_adj_ivas_fx required an additional gain
factor from IVAS code
- highband_exc_dct_in_ivas_fx required addition of
scaling code
- gsc_dec_ivas_fx required change in one of the if
conditions which was causing bit reading issues and
also required addition of scaling code.
parent 428b0771
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -195,6 +195,7 @@
    <ClCompile Include="..\lib_com\get_gain.c" />
    <ClCompile Include="..\lib_com\gs_bitallocation.c" />
    <ClCompile Include="..\lib_com\gs_bitallocation_fx.c" />
    <ClCompile Include="..\lib_com\gs_bitallocation_ivas_fx.c" />
    <ClCompile Include="..\lib_com\gs_gains.c" />
    <ClCompile Include="..\lib_com\gs_gains_fx.c" />
    <ClCompile Include="..\lib_com\gs_inact_switching.c" />
+1 −0
Original line number Diff line number Diff line
@@ -520,6 +520,7 @@
    <ClCompile Include="..\lib_com\window.c" />
    <ClCompile Include="..\lib_com\window_ola.c" />
    <ClCompile Include="..\lib_com\wtda.c" />
    <ClCompile Include="..\lib_com\gs_bitallocation_ivas_fx.c" />
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="..\lib_com\basop_proto_func.h">
+1 −0
Original line number Diff line number Diff line
@@ -1929,6 +1929,7 @@ typedef enum _DCTTYPE
#define MBANDS_GN_BITALLOC16k               20                      /* Number of band for gain coding in GSC */
#define BAND1k2                             3
#define DSR_NB_PULSE                        ( 4.5f )
#define DSR_NB_PULSE_Q18                    ( 1179648 )
#define MAX_EQ_LF                           1.0f
#define MBANDS_LOC                          ( MBANDS_GN - 1 )
#define BIN_SIZE                            25.0f
+1005 −0

File added.

Preview size limit exceeded, changes collapsed.

+240 −0
Original line number Diff line number Diff line
@@ -303,6 +303,86 @@ static void GSC_gain_adj(

    return;
}

#ifdef IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------*
 * GSC_gain_adj_ivas_fx()
 *
 * Quantization of the energy per band
 *-------------------------------------------------------------------*/
static void GSC_gain_adj_ivas_fx(
    const Word16 coder_type,      /* i  : Coder type        */
    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 */
    const Word16 *y_gain_tmp,     /* i  : Dequantized gains */
    Word16 *y_gainQ         /* i/o: Output gains Q12  */
)
{
    /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */
    Word16 Gain_off, i;

    IF(NE_16(coder_type, INACTIVE) && NE_16(coder_type, UNVOICED))
    {
        FOR(i = 0; i < MBANDS_GN; i++)
        {
            old_y_gain[i] = y_gain_tmp[i];
            move16();
            y_gainQ[i] = add(y_gain_tmp[i], mean_g);
            move16();
        }
    }
    ELSE
    {
        Gain_off = 0;
        move16();
        IF( LE_32( core_brate, ACELP_5k00 ) && EQ_16( coder_type, UNVOICED ) )
        {
            Gain_off = 18432;
            move16();   /* 9 -> Q11 */
        }
        IF(LE_32(core_brate,ACELP_7k20))
        {
            Gain_off = 16384;
            move16();   /* 8 -> Q11 */
        }
        ELSE IF(LE_32(core_brate,ACELP_8k00))
        {
            Gain_off = 13517;
            move16();   /* 6.6f -> Q11 */
        }
        ELSE IF(LE_32(core_brate,ACELP_9k60))
        {
            Gain_off = 9830;
            move16();   /*4.8f-> Q11 */
        }
        ELSE IF(LE_32(core_brate,ACELP_11k60))
        {
            Gain_off = 7168;
            move16();   /* 3.5f -> Q11 */
        }
        ELSE IF(LE_32(core_brate,ACELP_13k20))
        {
            Gain_off = 6144;
            move16(); /* 3.0f -> Q11 dB */
        }

        /*mimic ACELP decay of energy for low rates*/
        FOR(i = 0; i < MBANDS_GN; i++)
        {
            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));*/
            //y_gainQ[i] = add(y_gain_tmp[i], sub(mean_g, i_mult2(i, mult_r(Gain_off, 102))));
            y_gainQ[i] = add(y_gain_tmp[i], sub(mean_g, i_mult2(i, mult_r(Gain_off, 205))));
            move16();
        }
    }

    return;
}
#endif

/*==========================================================================*/
/* FUNCTION : Word16 gsc_gaindec_fx	()							            */
/*--------------------------------------------------------------------------*/
@@ -462,6 +542,166 @@ Word16 gsc_gaindec_fx( /* o : average frequency gain */

}

#ifdef IVAS_FLOAT_FIXED
/*==========================================================================*/
/* FUNCTION : Word16 gsc_gaindec_ivas_fx	()							            */
/*--------------------------------------------------------------------------*/
/* PURPOSE  :  Generic signal frequency band decoding and application       */
/*--------------------------------------------------------------------------*/
/*    INPUT ARGUMENTS :												        */
/* _ (Word16) pvq_bits_fx 	   : core used					Q0			    */
/* _ (Word16) coder_type_fx    : coding type				Q0			    */
/* _ (Word16) core_fx          : core used                  Q0              */
/* _ (Word16) bwidth_fx        : input signal bandwidth     Q0              */
/*--------------------------------------------------------------------------*/
/* OUTPUT ARGUMENTS :													    */
/* _ (Word16[]) y_gainQ_fx	   : quantized gain per band                    */
/*--------------------------------------------------------------------------*/
/* INPUT/OUTPUT ARGUMENTS :  											    */
/* _ (Word16[]) old_y_gain_fx  : AR gain quantizer for low rate          	*/
/*--------------------------------------------------------------------------*/
/* RETURN ARGUMENTS :													    */
/* _ (Word16) :					average frequency gain 					    */
/*==========================================================================*/
Word16 gsc_gaindec_ivas_fx(                  /* o  : average frequency gain    */
    Decoder_State *st_fx,           /* i/o: decoder state structure   */
    Word16 y_gainQ_fx[],        /* o  : quantized gain per band   */
    const Word32 core_brate_fx,       /* i  : core used                 */
    Word16 old_y_gain_fx[],     /* i/o: AR gain quantizer for low rate */
    const Word16 coder_type_fx,       /* i  : coding type               */
    const Word16 bwidth_fx            /* i  : input signal bandwidth    */
)
{
    Word16 idx_g_fx, i;
    Word16 mean_4g_fx;
    Word16 y_gain_tmp3_fx[MBANDS_GN];

    test();
    test();
    IF((EQ_16(coder_type_fx, AUDIO) || EQ_16(coder_type_fx, INACTIVE)) && EQ_16(bwidth_fx, NB))
    {
        idx_g_fx = (Word16)get_next_indice(st_fx, 6);
        VDQ_vec_fx(&mean_4g_fx, Gain_meanNB_fx, Gain_mean_dicNB_fx, idx_g_fx, 1);

        idx_g_fx = (Word16)get_next_indice(st_fx, 6);
        move16();
        VDQ_vec_fx(y_gainQ_fx, Mean_dic_NB_fx, Gain_dic1_NB_fx, idx_g_fx, 3);

        IF(LT_32(core_brate_fx, ACELP_9k60))
        {
            idx_g_fx = (Word16)get_next_indice(st_fx, 5);
            VDQ_vec_fx(y_gainQ_fx + 3, Mean_dic_NB_fx + 3, Gain_dic2_NB_fx, idx_g_fx, 3);

            idx_g_fx = (Word16)get_next_indice(st_fx, 4);
            VDQ_vec_fx(y_gainQ_fx + 6, Mean_dic_NB_fx + 6, Gain_dic3_NB_fx, idx_g_fx, 4);
        }
        ELSE
        {
            idx_g_fx = (Word16)get_next_indice(st_fx, 6);
            VDQ_vec_fx(y_gainQ_fx + 3, Mean_dic_NB_fx + 3, Gain_dic2_NBHR_fx, idx_g_fx, 3);

            idx_g_fx = (Word16)get_next_indice(st_fx, 7);
            VDQ_vec_fx(y_gainQ_fx + 6, Mean_dic_NB_fx + 6, Gain_dic3_NBHR_fx, idx_g_fx, 4);
        }
        test();
        IF(LE_32(core_brate_fx, ACELP_9k60) && EQ_16(coder_type_fx, INACTIVE))
        {
            /* Some energy is needed in high band for stat_noise_uv_enc
              to be functional in inactive speech */
            y_gainQ_fx[10] = mean_fx(y_gainQ_fx + 6, 3);
            move16();
            y_gainQ_fx[11] = mean_fx(y_gainQ_fx + 7, 3);
            move16();
            y_gainQ_fx[12] = mean_fx(y_gainQ_fx + 8, 3);
            move16();
            y_gainQ_fx[13] = mean_fx(y_gainQ_fx + 9, 3);
            move16();
            y_gainQ_fx[14] = mean_fx(y_gainQ_fx + 10, 3);
            move16();
            y_gainQ_fx[15] = mean_fx(y_gainQ_fx + 11, 3);
            move16();
        }
        ELSE
        {
            set16_fx(y_gainQ_fx + 10, 0, MBANDS_GN - 10);
        }
    }
    ELSE
    {
        idx_g_fx = (Word16)get_next_indice(st_fx, 6);

        VDQ_vec_fx(&mean_4g_fx, mean_m_fx, mean_gain_dic_fx, idx_g_fx, 1);

        IF(LT_32(core_brate_fx,ACELP_9k60))
        {
            /*--------------------------------------------------------------------------------------*
             * UQ of the first 8 bands and half of the last 8 bands
             *--------------------------------------------------------------------------------------*/
            idx_g_fx = (Word16)get_next_indice(st_fx, 5);
            VDQ_vec_fx(y_gainQ_fx, YGain_mean_LR_fx, YGain_dic1_LR_fx, idx_g_fx, 3);

            idx_g_fx = (Word16)get_next_indice(st_fx, 5);
            VDQ_vec_fx(y_gainQ_fx + 3, YGain_mean_LR_fx + 3, YGain_dic2_LR_fx, idx_g_fx, 4);

            /*----------------------------------------------------------------------*
             * Interpolation of the last 4 Q bands to create bands 8-16
             * And scaling
             *----------------------------------------------------------------------*/

            idx_g_fx = (Word16)get_next_indice(st_fx, 5);

            VDQ_vec_fx(y_gainQ_fx + 7, YGain_mean_LR_fx + 7, YGain_dic3_LR_fx, idx_g_fx, 5);

            Copy(y_gainQ_fx + 8, y_gain_tmp3_fx, 4);
            set16_fx(y_gainQ_fx + 12, 0, 4);

            fft_rel_fx(y_gainQ_fx + 8, 4, 2);

            y_gainQ_fx[15] = y_gainQ_fx[11];
            move16();
            y_gainQ_fx[11] = 0;
            move16();
            ifft_rel_fx(y_gainQ_fx + 8, 8, 3);
            FOR(i = 8; i < 16; i++)
            {
                /*y_gainQ_fx[i] *=  1.41f;*/
                y_gainQ_fx[i] = round_fx(L_shl(L_mult(y_gainQ_fx[i] , 23101),1));/*Q12 */
            }
            /*----------------------------------------------------------------------*
             * Copy the true Q values in the specific bands
             *----------------------------------------------------------------------*/
            y_gainQ_fx[8] = y_gain_tmp3_fx[0];
            move16();
            y_gainQ_fx[10] = y_gain_tmp3_fx[1];
            move16();
            y_gainQ_fx[12] = y_gain_tmp3_fx[2];
            move16();
            y_gainQ_fx[14] = y_gain_tmp3_fx[3];
            move16();
        }
        ELSE
        {
            idx_g_fx = (Word16)get_next_indice(st_fx, 6);
            VDQ_vec_fx(y_gainQ_fx, YG_mean16_fx, YG_dicMR_1_fx, idx_g_fx, 4);

            idx_g_fx = (Word16)get_next_indice(st_fx, 5);
            VDQ_vec_fx(y_gainQ_fx + 4, YG_mean16_fx + 4, YG_dicMR_2_fx, idx_g_fx, 4);

            idx_g_fx = (Word16)get_next_indice(st_fx, 5);
            VDQ_vec_fx(y_gainQ_fx + 8, YG_mean16_fx + 8, YG_dicMR_3_fx, idx_g_fx, 4);

            idx_g_fx = (Word16)get_next_indice(st_fx, 4);
            VDQ_vec_fx(y_gainQ_fx + 12, YG_mean16_fx + 12, YG_dicMR_4_fx, idx_g_fx, 4);
        }
    }

        /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */
    GSC_gain_adj_ivas_fx(coder_type_fx, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx);

    return mean_4g_fx;

}
#endif

/*-------------------------------------------------------------------*
 * gsc_gainQ()
Loading