Commit 2529d7d4 authored by vaclav's avatar vaclav
Browse files

HARM_COREDECODER_FUNCTIONS

parent bb8bbf03
Loading
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -6180,10 +6180,11 @@ void concealment_init_x(
    const Word16 L_frameTCX,
    T_PLCInfo_HANDLE hPlcInfo );
#ifdef HARM_COREDECODER_FUNCTIONS
void concealment_init_ivas_fx(
    const Word16 L_frameTCX,
    T_PLCInfo_HANDLE hPlcInfo );
#endif
void concealment_update_x(
    const Word16 bfi,
    const Word16 core,
@@ -6563,6 +6564,7 @@ void formant_post_filt_fx(
    const Word16 off_flag  /* i  : off flag                          */
);
#ifndef HARM_COREDECODER_FUNCTIONS
void Filt_mu_fx(
    Word16 *sig_in,  /* i  : signal (beginning at sample -1)     */
    Word16 *sig_out, /* o  : signal with tilt                    */
@@ -6576,7 +6578,7 @@ void Filt_mu_ivas_fx(
    Word16 parcor0,  /* i  : parcor0 (mu = parcor0 * gamma3)     */
    Word16 L_subfr,  /* i  : the length of subframe              */
    const Word16 extl );
#endif
void scale_st_fx(
    const Word16 *sig_in, /* i  : postfilter i signal             */
    Word16 *sig_out,      /* i/o: postfilter o signal             */
@@ -8776,13 +8778,14 @@ Word16 dlpc_avq_fx(
    Word32 sr_core );
Word16 decode_lpc_avq_fx(
#ifndef HARM_COREDECODER_FUNCTIONS
    Decoder_State *st,   /* i/o: decoder state structure     */
    const Word16 numlpc, /* i  : Number of sets of lpc       */
    Word16 *param_lpc    /* o  : lpc parameters              */
);
#ifndef HARM_COREDECODER_FUNCTIONS
Word16 decode_lpc_avq_ivas_fx(
#endif
    Decoder_State *st,           /* i/o: decoder state structure     */
    const Word16 numlpc,         /* i  : Number of sets of lpc       */
    Word16 *param_lpc,           /* o  : lpc parameters              */
@@ -8790,7 +8793,7 @@ Word16 decode_lpc_avq_ivas_fx(
    const Word16 element_mode,   /* i  : element mode                */
    const Word16 sns_low_br_mode /* i  : SNS low-bitrate mode        */
);
#endif
void vlpc_1st_dec(
    Word16 index,   /* i  :  codebook index                    */
    Word16 *lsfq ); /* i/o:    i:prediction   o:quantized lsf  */
+4 −0
Original line number Diff line number Diff line
@@ -1978,7 +1978,11 @@ void open_decoder_LPD_ivas_fx(

        IF( st->hTcxDec != NULL && ( st->ini_frame == 0 || LT_32( last_total_brate, HQ_48k ) || EQ_16( st->last_codec_mode, MODE1 ) || st->force_lpd_reset ) )
        {
#ifdef HARM_COREDECODER_FUNCTIONS
            concealment_init_x( st->hTcxDec->L_frameTCX, st->hPlcInfo );
#else
            concealment_init_ivas_fx( st->hTcxDec->L_frameTCX, st->hPlcInfo );
#endif
        }
    }
    ELSE
+57 −46
Original line number Diff line number Diff line
@@ -34,7 +34,10 @@ static void calc_st_filt_local_fx( Word16 *apond2, Word16 *apond1, Word16 *parco
static void modify_pst_param_fx( const Word16 lp_noise, Word16 *g1, Word16 *g2, const Word16 coder_type, Word16 *gain_factor );

static void Dec_formant_postfilt_fx( PFSTAT_HANDLE hPFstat, Word16 *signal_ptr, Word16 *coeff, Word16 *sig_out, Word16 gamma1, Word16 gamma2 );
#ifndef HARM_COREDECODER_FUNCTIONS

#ifdef HARM_COREDECODER_FUNCTIONS
static void Filt_mu_fx( Word16 *sig_in, Word16 *sig_out, Word16 parcor0, Word16 L_subfr );
#else
static void calc_st_filt_ivas_fx( Word16 *apond2, Word16 *apond1, Word16 *parcor0, Word16 *sig_ltp_ptr, Word16 *mem_zero, const Word16 extl );
#endif

@@ -73,11 +76,13 @@ void Init_post_filter_fx(
    return;
}


/*--------------------------------------------------------------------------
 *  NB_post_filt:
 *
 *  Main routine to perform post filtering on NB synthesis
 *--------------------------------------------------------------------------*/

void nb_post_filt_fx(
    const Word16 L_frame,    /* i  : frame length                            */
    PFSTAT_HANDLE hPFstat,   /* i : core decoder parameters                  */
@@ -133,7 +138,6 @@ void nb_post_filt_fx(
        move16();
    }


    /* run the post filter */
    p_Aq = Aq; // Q12
    move16();
@@ -149,10 +153,10 @@ void nb_post_filt_fx(
        j = add( j, 1 );
    }


    return;
}


/*----------------------------------------------------------------------------
 * Dec_postfilt()
 *
@@ -176,6 +180,7 @@ void nb_post_filt_fx(
 *       1. search around 1st subframe delay (3 integer values)
 *       2. search around best integer with fract. delays (1/8)
 *----------------------------------------------------------------------------*/

static void Dec_postfilt_fx(
    PFSTAT_HANDLE hPFstat,    /* i : core decoder parameters */
    const Word16 t0,          /* i  : pitch delay given by coder Q0                   */
@@ -192,14 +197,11 @@ static void Dec_postfilt_fx(
    Word16 apond2[LONG_H_ST];    // Q12
    Word16 sig_ltp[L_SUBFR + 1]; /* H0 output signal  */
    Word16 res2[SIZ_RES2];       // Q0

    Word16 *sig_ltp_ptr;
    Word16 *res2_ptr;
    Word16 *ptr_mem_stp;

    Word16 parcor0; // Q15


    /* Init pointers and restore memories */
    res2_ptr = res2 + DECMEM_RES2;
    ptr_mem_stp = hPFstat->mem_stp + L_SYN_MEM - 1;
@@ -245,10 +247,10 @@ static void Dec_postfilt_fx(
    /* Update for next subframe */
    Copy( &res2[L_SUBFR], hPFstat->mem_res2, DECMEM_RES2 );


    return;
}


/*--------------------------------------------------------------------------
 *  formant_post_filt_fx:
 *
@@ -468,7 +470,12 @@ static void Dec_formant_postfilt_fx(
    }

    /* Tilt filtering */
#ifdef HARM_COREDECODER_FUNCTIONS
    Filt_mu_fx( resynth, sig_out, parcor0, L_SUBFR );
#else
    Filt_mu_ivas_fx( resynth, sig_out, parcor0, L_SUBFR, -1 );
#endif

    IF( scale_down )
    {
        Scale_sig( sig_out, L_SUBFR, 1 );
@@ -477,10 +484,10 @@ static void Dec_formant_postfilt_fx(
    /* Gain control */
    scale_st_fx( signal_ptr, sig_out, &hPFstat->gain_prec, L_SUBFR );


    return;
}


/*------------------------------------------------------------------------------------
 * modify_pst_param()
 *
@@ -499,7 +506,6 @@ static void modify_pst_param_fx(
    Word16 lp_noiseQ12;
    Word32 L_tmp;


    test();
    IF( NE_16( coder_type, INACTIVE ) && LT_16( lp_noise, LP_NOISE_THR_FX ) )
    {
@@ -539,15 +545,16 @@ static void modify_pst_param_fx(

    *gain_factor = extract_h( L_shl( L_tmp, 7 ) ); /* Q24=>Q31=>Q15 */


    return;
}


/*----------------------------------------------------------------------------
 * pst_ltp_fx
 *
 * Perform harmonic postfilter
 *----------------------------------------------------------------------------*/

static void pst_ltp_fx(
    Word16 t0,            /* i  : pitch delay given by coder Q0       */
    Word16 *ptr_sig_in,   /* i  : postfilter i  filter (residu2) Qx   */
@@ -575,7 +582,6 @@ static void pst_ltp_fx(
    Word16 off_yup;
    Word16 nb_sh_sig;


    /* i  signal justified on 13 bits */
    ptr_sig = ptr_sig_in - DECMEM_RES2; // Qx
    nb_sh_sig = getScaleFactor16( ptr_sig, DECMEM_RES2 + L_SUBFR );
@@ -592,7 +598,6 @@ static void pst_ltp_fx(
    /* Sub optimal delay search */
    search_del_fx( t0, ptr_sig_cadr, &ltpdel, &phase, &num_gltp, &den_gltp, &sh_num, &sh_den, y_up, &off_yup );


    IF( num_gltp == 0 )
    {
        Copy( ptr_sig_in, ptr_sig_pst0, L_SUBFR );
@@ -608,7 +613,6 @@ static void pst_ltp_fx(
            /* Filtering with long filter */
            compute_ltp_l_fx( ptr_sig_cadr, ltpdel, phase, ptr_sig_pst0, &num2_gltp, &den2_gltp, &sh_num2, &sh_den2 );


            IF( EQ_16( select_ltp_fx( num_gltp, den_gltp, sh_num, sh_den, num2_gltp, den2_gltp, sh_num2, sh_den2 ), 1 ) )
            {
                /* select short filter */
@@ -677,13 +681,17 @@ static void pst_ltp_fx(
        /** filtering by H0(z) = harmonic filter **/
        filt_plt_fx( ptr_sig_in, ptr_y_up, ptr_sig_pst0, gain_plt );
    }

    return;
}


/*----------------------------------------------------------------------------
 * search_del_fx:
 *
 * Computes best (shortest) integer LTP delay + fine search
 *---------------------------------------------------------------------------*/

static void search_del_fx(
    Word16 t0,           /* i  : pitch delay given by coder Q0     */
    Word16 *ptr_sig_in,  /* i  : i  signal (with delay line)       */
@@ -720,7 +728,6 @@ static void search_del_fx(
    Word16 i_max, lambda, phi, phi_max, ioff;
    Word16 temp;


    /*-------------------------------------
     * Computes energy of current signal
     *-------------------------------------*/
@@ -752,6 +759,7 @@ static void search_del_fx(
     * Selects best of 3 integer delays
     * Maximum of 3 numerators around t0
     *-------------------------------------*/

    lambda = sub( t0, 1 );
    ptr_sig_past = ptr_sig_in - lambda;
    L_num_int = L_deposit_l( -1 );
@@ -952,7 +960,6 @@ static void search_del_fx(
    ptr_L_den1 = L_den1;
    ptr_y_up = y_up;


    /* if den_max = 0 : will be selected and declared unvoiced */
    /* if num!=0 & den=0 : will be selected and declared unvoiced */
    /* degenerated seldom cases, switch off LT is OK */
@@ -1030,6 +1037,7 @@ static void search_del_fx(
    /*---------------------------------------------------
     * test if normalized crit0[iopt] > THRESHCRIT
     *--------------------------------------------------*/

    test();
    IF( num_max == 0 || LE_16( den_max, 1 ) )
    {
@@ -1098,15 +1106,16 @@ static void search_del_fx(
        move16();
    }


    return;
}


/*----------------------------------------------------------------------------
 *  filt_plt_fx:
 *
 * Perform long term postfilter
 *----------------------------------------------------------------------------*/

static void filt_plt_fx(
    Word16 *s_in,   /* i  : i  signal with past Qx        */
    Word16 *s_ltp,  /* i  : filtered signal with gain 1 Qx*/
@@ -1114,14 +1123,11 @@ static void filt_plt_fx(
    Word16 gain_plt /* i  : filter gain Q15               */
)
{

    /* Local variables */
    Word32 L_acc;

    Word16 n;
    Word16 gain_plt_1;


    gain_plt_1 = sub( 32767, gain_plt ); // Q15
    gain_plt_1 = add( gain_plt_1, 1 );   /* 2**15 (1 - g) */

@@ -1133,7 +1139,6 @@ static void filt_plt_fx(
        move16();                                        /* no overflow */
    }


    return;
}

@@ -1144,6 +1149,7 @@ static void filt_plt_fx(
 * compute delayed signal, num & den of gain for fractional delay
 * with long interpolation filter
 *----------------------------------------------------------------------------*/

static void compute_ltp_l_fx(
    Word16 *s_in,   /* i/o: signal with past            */
    Word16 ltpdel,  /* i  : delay factor                */
@@ -1219,10 +1225,10 @@ static void compute_ltp_l_fx(
    move16();
    move16();


    return;
}


/*----------------------------------------------------------------------------
 *  select_ltp_fx:
 *
@@ -1230,7 +1236,8 @@ static void compute_ltp_l_fx(
 *  with gain1 = num1 * 2** sh_num1 / den1 * 2** sh_den1
 *  and  gain2 = num2 * 2** sh_num2 / den2 * 2** sh_den2
 *----------------------------------------------------------------------------*/
static Word16 select_ltp_fx(                 /* o  : 1 = 1st gain, 2 = 2nd gain  */
/* o  : 1 = 1st gain, 2 = 2nd gain  */
static Word16 select_ltp_fx(
    Word16 num1,    /* i  : numerator of gain1 Q(sh_num1)          */
    Word16 den1,    /* i  : denominator of gain1 Q(sh_den1)       */
    Word16 sh_num1, /* i  : just. factor for num1       */
@@ -1243,10 +1250,8 @@ static Word16 select_ltp_fx( /* o : 1 = 1st gain, 2 = 2nd gain
{
    Word32 L_temp1, L_temp2;
    Word32 L_temp;

    Word16 temp1, temp2;


    IF( den2 == 0 )
    {
        return 1;
@@ -1288,6 +1293,7 @@ static Word16 select_ltp_fx( /* o : 1 = 1st gain, 2 = 2nd gain
    return temp1;
}


/*----------------------------------------------------------------------------
 * calc_st_filt_local_fx
 *
@@ -1336,7 +1342,6 @@ static void calc_st_filt_local_fx(
        }
    }


    return;
}

@@ -1403,7 +1408,12 @@ static void calc_st_filt_ivas_fx(
 * tilt filtering with : (1 + mu z-1) * (1/1-|mu|)
 *      computes y[n] = (1/1-|mu|) (x[n]+mu*x[n-1])
 *---------------------------------------------------------------------------*/

#ifdef HARM_COREDECODER_FUNCTIONS
static void Filt_mu_fx(
#else
void Filt_mu_fx(
#endif
    Word16 *sig_in,  /* i  : signal (beginning at sample -1)     */
    Word16 *sig_out, /* o  : signal with tilt                    */
    Word16 parcor0,  /* i  : parcor0 (mu = parcor0 * gamma3)     */
@@ -1411,14 +1421,11 @@ void Filt_mu_fx(
)
{
    Word32 L_acc, L_temp, L_fact;

    Word16 *ptrs;

    Word16 n;
    Word16 mu, mu2, ga, temp;
    Word16 fact, sh_fact;


    IF( parcor0 > 0 )
    {
        mu = mult_r( parcor0, GAMMA3_PLUS_FX ); // Q15
@@ -1464,10 +1471,10 @@ void Filt_mu_fx(
        BASOP_SATURATE_WARNING_ON_EVS;
    }


    return;
}

#ifndef HARM_COREDECODER_FUNCTIONS
void Filt_mu_ivas_fx(
    Word16 *sig_in,  /* i  : signal (beginning at sample -1)     */
    Word16 *sig_out, /* o  : signal with tilt                    */
@@ -1557,12 +1564,16 @@ void Filt_mu_ivas_fx(

    return;
}

#endif

/*----------------------------------------------------------------------------
 * scale_st_fx()
 *
 * control of the subframe gain
 * gain[n] = AGC_FAC_FX * gain[n-1] + (1 - AGC_FAC_FX) g_in/g_out
 *---------------------------------------------------------------------------*/

void scale_st_fx(
    const Word16 *sig_in, /* i  : postfilter i signal Qx             */
    Word16 *sig_out,      /* i/o: postfilter o signal Qx             */
@@ -1570,12 +1581,11 @@ void scale_st_fx(
    Word16 L_subfr )
{
    Word32 L_acc, L_temp;

    Word16 i;
    Word16 scal_in, scal_out;
    Word16 s_g_in, s_g_out, temp, sh_g0, g0;
    Word16 gain = 0;

    move16();

    /* compute i  gain */
    L_acc = L_deposit_l( 0 );
@@ -1654,10 +1664,10 @@ void scale_st_fx(
    *gain_prec = gain;
    move16();


    return;
}


/*----------------------------------------------------------------------------
 * blend_subfr2_fx()
 *
@@ -1677,6 +1687,7 @@ void blend_subfr2_fx(
    move16();
    move16();
    move16();

    FOR( i = 0; i < L_SUBFR / 2; i++ )
    {
        sigOut[i] = mac_r_sat( L_mult_sat( fac1, sigIn1[i] ), fac2, sigIn2[i] ); // Qx
+4 −0
Original line number Diff line number Diff line
@@ -1007,7 +1007,11 @@ void dec_prm_fx(
        {
            IF( st->lpcQuantization == 0 )
            {
#ifdef HARM_COREDECODER_FUNCTIONS
                decode_lpc_avq_fx( st, st->numlpc, param_lpc, 0, EVS_MONO, 0 );
#else
                decode_lpc_avq_fx( st, st->numlpc, param_lpc );
#endif
                move16();
            }
            ELSE IF( EQ_16( st->lpcQuantization, 1 ) )
+2 −1
Original line number Diff line number Diff line
@@ -839,7 +839,7 @@ void concealment_init_x(
    return;
}


#ifndef HARM_COREDECODER_FUNCTIONS
void concealment_init_ivas_fx(
    const Word16 L_frameTCX,
    T_PLCInfo_HANDLE hPlcInfo )
@@ -898,6 +898,7 @@ void concealment_init_ivas_fx(
    }
    return;
}
#endif

static Word16 own_random_fix(              /* o  : output random value */
                              Word16 *seed /* i/o: random seed   Q0      */