Commit 2e4d48e1 authored by vaclav's avatar vaclav
Browse files

editorial improvements

parent 4fdc7161
Loading
Loading
Loading
Loading
+93 −67
Original line number Diff line number Diff line
@@ -16,18 +16,54 @@

#ifdef HARM_FD_BWE
static Word16 WB_BWE_encoding_fx( Encoder_State *st_fx, const Word32 *yos_fx, Word16 *WB_fenv_fx, Word16 Q_synth, const Word16 Q_synth_lf );

static Word16 SWB_BWE_encoding_fx( Encoder_State *st_fx, Word16 *insig_fx, const Word16 *insig_lp_fx, const Word16 *insig_hp_fx, const Word16 *synth_fx, const Word16 *yos_fx_16, const Word32 *yos_fx, Word16 *SWB_fenv_fx, const Word16 tilt_nb_fx, const Word16 st_offset, const Word16 Q_insig_lp, const Word16 Q_shb, const Word16 Q_synth, const Word16 Q_synth_lf );
#else
static Word16 WB_BWE_encoding_fx( const Word16 coder_type, const Word16 *yos_fx, Word16 *WB_fenv_fx, Encoder_State *st_fx, const Word16 Q_synth, const Word16 Q_synth_lf );
static Word16 WB_BWE_encoding_fx(
    const Word16 coder_type, /* i  : coder type                             */
    const Word16 *yos_fx,    /* i  : MDCT coefficients of weighted original */
    Word16 *WB_fenv_fx,      /* i/o: energy of WB envelope                  */
    Encoder_State *st_fx,    /* i/o: Encoder structure                      */
    const Word16 Q_synth,
    const Word16 Q_synth_lf );

static Word16 WB_BWE_encoding_fx_32( Encoder_State *st_fx, const Word32 *yos_fx, Word16 *WB_fenv_fx, Word16 Q_synth, const Word16 Q_synth_lf );
#endif
static Word16 WB_BWE_encoding_ivas_fx(
    Encoder_State *st_fx, /* i/o: Encoder structure                      */
    const Word32 *yos_fx, /* i  : MDCT coefficients of weighted original */
    Word16 *WB_fenv_fx,   /* i/o: energy of WB envelope                  */
    Word16 Q_synth,
    const Word16 Q_synth_lf );

static Word16 SWB_BWE_encoding_fx( Encoder_State *st_fx, Word16 *insig_fx, const Word16 *insig_lp_fx, const Word16 *insig_hp_fx, const Word16 *synth_fx, const Word16 *yos_fx, Word16 *SWB_fenv_fx, const Word16 tilt_nb_fx, const Word16 st_offset, const Word16 coder_type, const Word16 Q_insig_lp, const Word16 Q_shb, const Word16 Q_synth, const Word16 Q_synth_lf );
static Word16 SWB_BWE_encoding_fx(
    Encoder_State *st_fx,      /* i/o: encoder state structure   */
    Word16 *insig_fx,          /* i/o: delayed original input signal at 32kHz (might be rescaled)*/
    const Word16 *insig_lp_fx, /* i  : delayed original lowband input signal at 32kHz */
    const Word16 *insig_hp_fx, /* i  : delayed original highband input signal at 32kHz */
    const Word16 *synth_fx,    /* i  : delayed ACELP core synthesis at 12.8kHz */
    const Word16 *yos_fx,      /* i  : MDCT coefficients of the windowed original input signal at 32kHz */
    Word16 *SWB_fenv_fx,       /* o  : frequency-domain quantized BWE envelope */
    const Word16 tilt_nb_fx,   /* i  : SWB tilt */
    const Word16 st_offset,    /* i  : start frequency offset for BWE envelope */
    const Word16 coder_type,   /* i  : coding type                              */
    const Word16 Q_insig_lp,
    const Word16 Q_shb,
    const Word16 Q_synth,
    const Word16 Q_synth_lf );

#ifdef HARM_FD_BWE
static Word16 SWB_BWE_encoding_fx_32( Encoder_State *st_fx, Word16 *insig_fx, const Word16 *insig_lp_fx, const Word16 *insig_hp_fx, const Word16 *synth_fx, const Word16 *yos_fx_16, const Word32 *yos_fx, Word16 *SWB_fenv_fx, const Word16 tilt_nb_fx, const Word16 st_offset, const Word16 Q_insig_lp, const Word16 Q_shb, const Word16 Q_synth, const Word16 Q_synth_lf );
#else
static Word16 SWB_BWE_encoding_fx_32( Encoder_State *st_fx, Word16 *insig_fx, const Word16 *insig_lp_fx, const Word16 *insig_hp_fx, const Word16 *synth_fx, const Word32 *yos_fx, Word16 *SWB_fenv_fx, const Word16 tilt_nb_fx, const Word16 st_offset, const Word16 Q_insig_lp, const Word16 Q_shb, const Word16 Q_synth, const Word16 Q_synth_lf );
static Word16 SWB_BWE_encoding_ivas_fx(
    Encoder_State *st_fx,      /* i/o: encoder state structure   */
    Word16 *insig_fx,          /* i/o: delayed original input signal at 32kHz (might be rescaled)*/
    const Word16 *insig_lp_fx, /* i  : delayed original lowband input signal at 32kHz */
    const Word16 *insig_hp_fx, /* i  : delayed original highband input signal at 32kHz */
    const Word16 *synth_fx,    /* i  : delayed ACELP core synthesis at 12.8kHz */
    const Word32 *yos_fx,      /* i  : MDCT coefficients of the windowed original input signal at 32kHz */
    Word16 *SWB_fenv_fx,       /* o  : frequency-domain quantized BWE envelope */
    const Word16 tilt_nb_fx,   /* i  : SWB tilt */
    const Word16 st_offset,    /* i  : start frequency offset for BWE envelope */
    const Word16 Q_insig_lp,
    const Word16 Q_shb,
    const Word16 Q_synth,
    const Word16 Q_synth_lf );
#endif


@@ -250,7 +286,7 @@ void wb_bwe_enc_ivas_fx(
#ifdef HARM_FD_BWE
        mode = WB_BWE_encoding_fx( st_fx, yorig_32, WB_fenv_fx, new_input_fx_exp, new_input_fx_exp );
#else
        mode = WB_BWE_encoding_fx_32( st_fx, yorig_32, WB_fenv_fx, new_input_fx_exp, new_input_fx_exp );
        mode = WB_BWE_encoding_ivas_fx( st_fx, yorig_32, WB_fenv_fx, new_input_fx_exp, new_input_fx_exp );
#endif
        move16();

@@ -322,7 +358,9 @@ void swb_bwe_enc_ivas_fx(
    Word16 fb_band_begin;
    Word16 q_new_input_hp;
    Word16 shb_speech_fx[L_FRAME16k];
#ifndef HARM_FD_BWE
#ifdef HARM_FD_BWE
    Word16 Qenc_synth_hf, Qenc_synth;
#else
    Word16 Q_shb_speech;
#endif

@@ -573,53 +611,31 @@ IF( st_fx->element_mode == EVS_MONO )
{
    Copy_Scale_sig( new_input_hp_fx, new_input_hp_fx, L_FRAME16k, sub( Q_shb, Q_shb_speech ) );

    /* SWB BWE encoding */
    IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
    {
#ifdef HARM_FD_BWE
        SWB_BWE_encoding_fx_32( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_fx, yorig_32,
                                SWB_fenv_fx, tilt_nb_fx, 80, Q_slb_speech, Q_shb, Q_synth_hf, Q_synth );
#else
        SWB_BWE_encoding_fx( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_fx,
                             SWB_fenv_fx, tilt_nb_fx, 80, st_fx->coder_type, Q_slb_speech, Q_shb, Q_synth_hf, Q_synth );
#endif
    }
    ELSE
    {
#ifdef HARM_FD_BWE
        SWB_BWE_encoding_fx_32( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_fx, yorig_32,
                             SWB_fenv_fx, tilt_nb_fx, 6, Q_slb_speech, Q_shb, Q_synth_hf, Q_synth );
#else
        SWB_BWE_encoding_fx( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_fx,
                             SWB_fenv_fx, tilt_nb_fx, 6, st_fx->coder_type, Q_slb_speech, Q_shb, Q_synth_hf, Q_synth );
#endif
    }
    Qenc_synth_hf = Q_synth_hf;
    Qenc_synth = Q_synth;
    move16();
    move16();
}
ELSE
{
    Copy_Scale_sig( new_input_hp_fx, new_input_hp_fx, L_FRAME16k, sub( Q_shb, q_new_input_hp ) );

    Qenc_synth_hf = new_input_fx_q;
    Qenc_synth = new_input_fx_q;
    move16();
    move16();
}

/* SWB BWE encoding */
IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
{
#ifdef HARM_FD_BWE
        SWB_BWE_encoding_fx_32( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_fx, yorig_32,
                                SWB_fenv_fx, tilt_nb_fx, 80, Q_slb_speech, Q_shb, new_input_fx_q, new_input_fx_q );
#else
        SWB_BWE_encoding_fx_32( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_32,
                                SWB_fenv_fx, tilt_nb_fx, 80, Q_slb_speech, Q_shb, new_input_fx_q, new_input_fx_q );
#endif
    SWB_BWE_encoding_fx( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_fx, yorig_32,
                         SWB_fenv_fx, tilt_nb_fx, 80, Q_slb_speech, Q_shb, Qenc_synth_hf, Qenc_synth );
}
ELSE
{
#ifdef HARM_FD_BWE
        SWB_BWE_encoding_fx_32( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_fx, yorig_32,
                                SWB_fenv_fx, tilt_nb_fx, 6, Q_slb_speech, Q_shb, new_input_fx_q, new_input_fx_q );
#else
        SWB_BWE_encoding_fx_32( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_32,
                                SWB_fenv_fx, tilt_nb_fx, 6, Q_slb_speech, Q_shb, new_input_fx_q, new_input_fx_q );
#endif
    }
    SWB_BWE_encoding_fx( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_fx, yorig_32,
                         SWB_fenv_fx, tilt_nb_fx, 6, Q_slb_speech, Q_shb, Qenc_synth_hf, Qenc_synth );
}
#else
            Copy_Scale_sig( new_input_hp_fx, new_input_hp_fx, L_FRAME16k, sub( Q_shb, q_new_input_hp ) );
@@ -675,12 +691,12 @@ IF( EQ_16( st_fx->extl, FB_BWE ) )
/* SWB BWE encoding */
IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
{
    SWB_BWE_encoding_fx_32( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_32,
    SWB_BWE_encoding_ivas_fx( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_32,
                              SWB_fenv_fx, tilt_nb_fx, 80, Q_slb_speech, Q_shb, new_input_fx_q, new_input_fx_q );
}
ELSE
{
    SWB_BWE_encoding_fx_32( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_32,
    SWB_BWE_encoding_ivas_fx( st_fx, old_input_fx, old_input_lp_fx, new_input_hp_fx, old_syn_12k8_16k_fx, yorig_32,
                              SWB_fenv_fx, tilt_nb_fx, 6, Q_slb_speech, Q_shb, new_input_fx_q, new_input_fx_q );
}

@@ -1009,6 +1025,13 @@ static Word16 WB_BWE_fenv_q_fx(
    return ( indx );
}


/*-------------------------------------------------------------------*
 * get_normalize_spec_fx()
 *
 *
 *-------------------------------------------------------------------*/

static void get_normalize_spec_fx(
    const Word16 core,       /* i  : core selected            */
    const Word16 extl,       /* i  : extension layer selected */
@@ -1646,7 +1669,6 @@ static Word16 vqSimple_w_fx(
        }
    }


    /* Reading the selected vector */
    Copy( &cb[index * dim], y, dim );

@@ -1658,11 +1680,11 @@ static Word16 vqSimple_w_fx(
 * MSVQ_Interpol_Tran_fx()
 *
 *-------------------------------------------------------------------*/

static void MSVQ_Interpol_Tran_fx(
    Word16 *SWB_env_energy, /* i/o: (original/quantized) energy   Q8 */
    Word16 *indice          /* o  : quantized index                  */
)

{
    Word16 k, n_band, candInd[N_CAND_TR], ind_tmp[2], tmp;
    Word16 env_temp11[SWB_FENV_TRANS / 2], env_temp12[SWB_FENV_TRANS / 2];
@@ -1744,6 +1766,7 @@ static void MSVQ_Interpol_Tran_fx(
            move16();
        }
    }

    return;
}

@@ -1879,6 +1902,7 @@ static void msvq_interpol_fx(
 * msvq_interpol_2_fx()
 *
 *-------------------------------------------------------------------*/

static void msvq_interpol_2_fx(
    Word16 *hq_generic_fenv, /* i/o: (original/quantized) energy */
    const Word16 *w_env,     /* i  : weighting coffecients       */
@@ -2593,7 +2617,7 @@ static Word16 WB_BWE_encoding_fx(
 *-------------------------------------------------------------------*/

/* o  : classification of wb signal */
static Word16 WB_BWE_encoding_fx_32(
static Word16 WB_BWE_encoding_ivas_fx(
#endif
    Encoder_State *st_fx, /* i/o: Encoder structure                      */
    const Word32 *yos_fx, /* i  : MDCT coefficients of weighted original */
@@ -2684,10 +2708,11 @@ static Word16 WB_BWE_encoding_fx_32(

        scale = s_min( L_norm_arr( yos_fx, L_FRAME16k ), sub( Q27, Q_synth ) /* To accomodate 10 in Q_synth*/ );
        Copy_Scale_sig32_16( yos_fx, yos_fx_16, L_FRAME16k, scale );

#ifdef HARM_FD_BWE
        Q_class = sub( add( Q_synth, scale ), Q16 );
        Q_energy = sub( add( Q_synth_lf, scale ), Q16 );
        Q_fenv = add( q_WB_fenv[i], 4 );
#endif
    }

#ifdef HARM_FD_BWE
@@ -2741,6 +2766,7 @@ static Word16 WB_BWE_encoding_fx_32(
 *-------------------------------------------------------------------*/

static Word16 SWB_BWE_encoding_fx(
#ifndef HARM_FD_BWE
    Encoder_State *st_fx,      /* i/o: encoder state structure   */
    Word16 *insig_fx,          /* i  : delayed original input signal at 32kHz */
    const Word16 *insig_lp_fx, /* i  : delayed original lowband input signal at 32kHz */
@@ -3180,7 +3206,8 @@ static Word16 SWB_BWE_encoding_fx(
 * SWB BWE encoder, 32-bit variant
 *-------------------------------------------------------------------*/

static Word16 SWB_BWE_encoding_fx_32(
static Word16 SWB_BWE_encoding_ivas_fx(
#endif
    Encoder_State *st_fx,      /* i/o: encoder state structure   */
    Word16 *insig_fx,          /* i  : delayed original input signal at 32kHz */
    const Word16 *insig_lp_fx, /* i  : delayed original lowband input signal at 32kHz */
@@ -4123,6 +4150,7 @@ static void energy_control_fx_32(
 * decision_hq_generic_class_fx_32()
 *
 *-------------------------------------------------------------------*/

static Word16 decision_hq_generic_class_fx_32(
    const Word32 *coefs_fx,        /* i: original MDCT spectrum                      : Q12   */
    const Word16 hq_generic_offset /* i: frequency offset of high frequency spectrum : Q0    */
@@ -4130,7 +4158,6 @@ static Word16 decision_hq_generic_class_fx_32(
{
    Word16 i, k;
    Word16 nband;

    Word16 inv_band_fx;
    Word32 L_tmp, L_tmp1, L_tmp2;
    Word16 exp, tmp, tmp2;
@@ -4191,6 +4218,7 @@ static Word16 decision_hq_generic_class_fx_32(
        }
    }
    avgp2a_fx = Mult_32_16( avgp2a_fx, inv_band_fx ); /*16 + 15 - 15 */

    IF( GT_32( avgp2a_fx, 187227 ) )                  /*8.6 / 10log10(2), Q16 */
    {
        return HQ_GENERIC_EXC1;
@@ -4403,7 +4431,6 @@ void hq_generic_encoding_fx(
        move16();
    }


    IF( EQ_16( st_fx->bwidth, FB ) )
    {
        FOR( n_band = 0; n_band < DIM_FB; n_band++ )
@@ -4680,7 +4707,6 @@ void hq_generic_hf_encoding_fx(
        move16();
    }


    IF( EQ_16( length, L_SPEC48k ) )
    {
        FOR( n_band = 0; n_band < DIM_FB; n_band++ )