Commit 1467784c authored by vaclav's avatar vaclav
Browse files

fix, updt

parent 26c61062
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1877,7 +1877,7 @@ void ivas_wb_tbe_dec_fx(
    Word16 *synth,                                              /* o  : WB synthesis/final synthesis            */
    Word16 *Q_synth 
);
#endif

void GenShapedWBExcitation_ivas_fx(
    Word16 *excSHB,                                             /* o : synthesized shaped shb exctiation Q_bwe_exc*/
    const Word16 *lpc_shb,                                      /* i : lpc coefficients Q12                     */
@@ -1896,7 +1896,7 @@ void GenShapedWBExcitation_ivas_fx(
    const Word16 uv_flag,                                       /* i : unvoiced flag                            */
    const Word16 igf_flag 
);

#endif
/* o : Q_syn_hb*/
Word16 ivas_wb_bwe_dec_fx(
    Decoder_State *st_fx,                                       /* i/o: decoder state structure                 */
+68 −46
Original line number Diff line number Diff line
@@ -2856,11 +2856,12 @@ void Calc_rc0_h(
    Word16 *rc0 /* o  : 1st parcor */
);
#ifndef HARMONIZE_TBE
void Calc_rc0_h_ivas_enc_fx(
    Word16 *h,  /* i  : impulse response of composed filter */
    Word16 *rc0 /* o  : 1st parcor */
);
#endif
void PostShortTerm_fx(
    Word16 *sig_in,             /* i  : i   signal (pointer to current subframe */
    Word16 *lpccoeff,           /* i  : LPC coefficients for current subframe */
@@ -2915,12 +2916,33 @@ void GenShapedWBExcitation_fx(
    const Word16 coder_type,          /* i   : coding type                            */
    const Word16 element_mode,        /* i   : element mode                           */
    const Word16 *bwe_exc_extended,   /* i   : bandwidth extended exciatation         */
    const Word16 Q_bwe_exc,
    const Word16 Q_bwe_exc,           /* i   : Q for memories                         */
    Word16 bwe_seed[],                /* i/o : random number generator seed           */
    const Word16 voice_factors[],     /* i   : voicing factor                         */
    const Word16 signal_type,
    const Word16 igf_flag );
#ifdef HARMONIZE_TBE
void GenShapedWBExcitation_ivas_fx(
    Word16 *excSHB,                   /* o  : synthesized shaped shb exctiation   Q_bwe_exc*/
    const Word16 *lpc_shb,            /* i  : lpc coefficients Q12                         */
    Word16 *exc4kWhtnd,               /* o  : whitened synthesized shb excitation Q_bwe_exc*/
    Word32 *mem_csfilt,               /* i/o: memory                           Q_bwe_exc+16*/
    Word16 *mem_genSHBexc_filt_down1, /* i/o: memory                              Q_bwe_exc*/
    Word16 *mem_genSHBexc_filt_down2, /* i/o: memory                              Q_bwe_exc*/
    Word16 *mem_genSHBexc_filt_down3, /* i/o: memory                              Q_bwe_exc*/
    Word16 *state_lpc_syn,            /* i/o: memory                              Q_bwe_exc*/
    const Word16 coder_type,          /* i  : coding type                                  */
    const Word16 element_mode,        /* i  : element mode                                 */
    const Word16 *bwe_exc_extended,   /* i  : bwidth extended exciatation         Q_bwe_exc*/
    const Word16 Q_bwe_exc,           /* i  : Q for memories                               */
    Word16 bwe_seed[],                /* i/o: random number generator seed                 */
    const Word16 voice_factors[],     /* i  : voicing factor                            Q15*/
    const Word16 uv_flag,             /* i  : unvoiced flag                                */
    const Word16 igf_flag             /* i  : IGF flag                                     */
);
#endif
void GenWBSynth_fx(
    const Word16 *input_synspeech, /* i  : i   synthesized speech                  */
    Word16 *shb_syn_speech_16k,    /* o  : output highband compnent                */
@@ -3094,7 +3116,7 @@ void ScaleShapedWB_fx(
    const Word32 frame_gain, /* i  : frame gain                                                  */
    const Word16 *win,       /* i  : window                                                      */
    const Word16 *subwin,    /* i  : subframes window                                            */
    const Word16 Q_bwe_exc,
    const Word16 Q_bwe_exc,  /* i  : Q for memories                                              */
    Word16 L_frame,          /* i  : Frame length - determines whether 12.8 or 16kHz core in-use */
    Word16 dynQ,             /* i  : indicate whether output is dynamic Q, or Q0                 */
    Word16 *Qx,              /* o  : newly computed Q factor for  synSHB                         */
+73 −56
Original line number Diff line number Diff line
@@ -8,30 +8,29 @@
#include "rom_com.h" /* Static table prototypes                */
#include "prot_fx.h"
#include "basop_util.h"
#include "ivas_prot_fx.h"


/*-----------------------------------------------------------------*
 * Local constants
 *-----------------------------------------------------------------*/

#define POW_EXC16k_WHTND                    1.14e11f   /* power of random excitation, length 320 samples, uniform distribution */
#define POW_EXC16k_WHTND_FX_INV_SQRT        6360       // Q31
#define POW_EXC16k_WHTND_FX_INV_SQRT        6360       // 1.14e11f in Q31 power of random excitation, length 320 samples, uniform distribution
#define POW_EXC16k_WHTND_FX_INV_SQRT_IN_Q49 1667313793 // Q49
#define POW_EXC16k_WHTND_FX                 178125000  // Q-6
#define THR_ENV_ERROR_PLOSIVE               200.0f     /* threshold for envelope error used in plosive detection */
#define THR_ENV_ERROR_PLOSIVE_FX            200        /* threshold for envelope error used in plosive detection Q0 */


/*-----------------------------------------------------------------*
 * Local function prototypes
 *-----------------------------------------------------------------*/

static void create_random_vector_fx( Word16 output[], const Word16 length, Word16 seed[], Word16 element_mode );
static void flip_spectrum_fx( const Word16 input[], Word16 output[], const Word16 length );
static void Calc_st_filt_tbe( Word16 *apond2, Word16 *apond1, Word16 *parcor0, Word16 *sig_ltp_ptr, Word16 *mem_zero );
static void Calc_st_filt_tbe_fx( Word16 *apond2, Word16 *apond1, Word16 *parcor0, Word16 *sig_ltp_ptr, Word16 *mem_zero );
static void Hilbert_transform_fx( Word32 tmp_R[], Word32 tmp_I[], Word32 *tmpi_R, Word32 *tmpi_I, const Word16 length, const Word16 HB_stage_id );
static void Hilbert_transform_sp_fx( Word16 tmp_R[], Word16 tmp_I[], Word32 *tmpi_R, Word32 *tmpi_I, const Word16 length, const Word16 HB_stage_id );
void Estimate_mix_factors_fx( const Word16 *shb_res, const Word16 Q_shb, const Word16 *exc16kWhtnd, const Word16 Q_bwe_exc, const Word16 *White_exc16k_frac, const Word16 Q_frac, const Word32 pow1, const Word16 Q_pow1, const Word32 pow22, const Word16 Q_pow22, Word16 *vf_modified, Word16 *vf_ind );
static void Estimate_mix_factors_fx( const Word16 *shb_res, const Word16 Q_shb, const Word16 *exc16kWhtnd, const Word16 Q_bwe_exc, const Word16 *White_exc16k_frac, const Word16 Q_frac, const Word32 pow1, const Word16 Q_pow1, const Word32 pow22, const Word16 Q_pow22, Word16 *vf_modified, Word16 *vf_ind );


/*-------------------------------------------------------------------*
 * swb_tbe_reset()
@@ -720,9 +719,15 @@ void Calc_rc0_h(
        *rc0 = negate( *rc0 );
        move16();
    }

    return;
}

#ifdef HARMONIZE_TBE
static void Calc_rc0_h_ivas_enc_fx(
#else
void Calc_rc0_h_ivas_enc_fx(
#endif
    Word16 *h,  /* i  : impulse response of composed filter */
    Word16 *rc0 /* o  : 1st parcor */
)
@@ -781,7 +786,7 @@ void Calc_rc0_h_ivas_enc_fx(
    }
}

static void Calc_st_filt_tbe(
static void Calc_st_filt_tbe_fx(
    Word16 *apond2,      /* i  : coefficients of numerator             */
    Word16 *apond1,      /* i  : coefficients of denominator           */
    Word16 *parcor0,     /* o  : 1st parcor calcul. on composed filter */
@@ -819,6 +824,8 @@ static void Calc_st_filt_tbe(
            move16();
        }
    }

    return;
}

static void Calc_st_filt_tbe_ivas_enc_fx(
@@ -859,8 +866,11 @@ static void Calc_st_filt_tbe_ivas_enc_fx(
            move16();
        }
    }

    return;
}

#ifndef HARMONIZE_TBE
static void Calc_st_filt_tbe_ivas_dec_fx(
    Word16 *apond2,      /* i  : coefficients of numerator             */
    Word16 *apond1,      /* i  : coefficients of denominator           */
@@ -899,8 +909,10 @@ static void Calc_st_filt_tbe_ivas_dec_fx(
            move16();
        }
    }
}

    return;
}
#endif
static void filt_mu_fx(
    const Word16 *sig_in, /* i  : signal (beginning at sample -1) */
    Word16 *sig_out,      /* o  : output signal                   */
@@ -1103,7 +1115,7 @@ void PostShortTerm_fx(
    move16();

    /* Control short term pst filter gain and compute parcor0   */
    Calc_st_filt_tbe( apond2_fx, apond1_fx, &parcor0_fx, sig_ltp_fx + 1, mem_zero );
    Calc_st_filt_tbe_fx( apond2_fx, apond1_fx, &parcor0_fx, sig_ltp_fx + 1, mem_zero );
    /* o: parcor0 in Q15 */
    /* i/o: sig_ltp_fx in Q_bwe_exc */

@@ -1223,7 +1235,11 @@ void PostShortTerm_ivas_dec_fx(
    move16();

    /* Control short term pst filter gain and compute parcor0   */
#ifdef HARMONIZE_TBE
    Calc_st_filt_tbe_fx( apond2_fx, apond1_fx, &parcor0_fx, sig_ltp_fx + 1, mem_zero );
#else
    Calc_st_filt_tbe_ivas_dec_fx( apond2_fx, apond1_fx, &parcor0_fx, sig_ltp_fx + 1, mem_zero );
#endif
    /* o: parcor0 in Q15 */
    /* i/o: sig_ltp_fx in Q_bwe_exc */

@@ -1240,6 +1256,13 @@ void PostShortTerm_ivas_dec_fx(
    return;
}


/*-------------------------------------------------------------------*
 * flip_spectrum_and_decimby4()
 *
 *
 *-------------------------------------------------------------------*/

void flip_spectrum_and_decimby4_fx(
    const Word16 input[],  /* i : input spectrum Q_inp     */
    Word16 output[],       /* o : output spectrum Q_inp    */
@@ -1330,11 +1353,12 @@ void GenShapedWBExcitation_ivas_fx(
    const Word16 coder_type,          /* i  : coding type                                  */
    const Word16 element_mode,        /* i  : element mode                                 */
    const Word16 *bwe_exc_extended,   /* i  : bwidth extended exciatation         Q_bwe_exc*/
    const Word16 Q_bwe_exc,
    const Word16 Q_bwe_exc,           /* i : Q for memories                                */
    Word16 bwe_seed[],                /* i/o: random number generator seed                 */
    const Word16 voice_factors[],     /* i  : voicing factor                            Q15*/
    const Word16 uv_flag,             /* i  : unvoiced flag                                */
    const Word16 igf_flag )
    const Word16 igf_flag             /* i  : IGF flag                                     */
)
{
    Word16 i, j, k;
    Word16 wht_fil_mem[LPC_WHTN_ORDER_WB];
@@ -4868,7 +4892,6 @@ void ScaleShapedSHB_fx(
        }
    }


    Q_gFr_norm = norm_l( frame_gain );
    if ( frame_gain == 0 )
    {
@@ -5113,7 +5136,7 @@ void ScaleShapedWB_fx(
    const Word32 frame_gain, /* i  : frame gain                         Q18*/
    const Word16 *win,       /* i  : window                             Q15*/
    const Word16 *subwin,    /* i  : subframes window                   Q15*/
    const Word16 Q_bwe_exc,
    const Word16 Q_bwe_exc,  /* i  : Q for memories                        */
    Word16 L_frame,          /* i  : Frame length - determines whether 12.8 or 16kHz core in-use */
    Word16 dynQ,             /* i  : indicate whether output is dynamic Q, or Q0 */
    Word16 *Qx,              /* o  : newly computed Q factor for  synSHB   */
@@ -5128,6 +5151,7 @@ void ScaleShapedWB_fx(
    Word16 sum_gain;
    Word32 L_tmp;
    Word16 max_val, abs_sig, sc1, sc2, shift, max_headroom, min_shift, max_shift, max_shift2;

    /* Init */
    set32_fx( mod_syn, 0, L_FRAME16k + L_SHB_LAHEAD );

@@ -5225,7 +5249,6 @@ void ScaleShapedWB_fx(
        }
    }


    max_val = 0;
    move16();
    FOR( i = 0; i < l_frame + l_shb_lahead; i++ )
@@ -5997,6 +6020,7 @@ void interp_code_5over2_fx(
    Ltemp = L_mult( inp_code_fx[kk], factor_j_fx[1] ); /*Q(16+x) */
    interp_code_fx[i + 1] = round_fx( Ltemp );         /*Qx */
    move16();

    return;
}

@@ -6224,7 +6248,6 @@ void elliptic_bpf_48k_generic_fx(

    } /*IsUpsampled3*/


    memory_fx2[0][0] = input_fx[L_FRAME48k - 4];
    memory_fx2[0][1] = input_fx[L_FRAME48k - 3];
    memory_fx2[0][2] = input_fx[L_FRAME48k - 2];
@@ -6272,7 +6295,6 @@ void elliptic_bpf_48k_generic_fx(
        }
    }


    Q_temp = norm_l( L_tmpMax );
    Q_temp = sub( Q_temp, 4 );
    Scale_sig32( L_tmp2, 960, Q_temp );
@@ -6334,7 +6356,6 @@ void elliptic_bpf_48k_generic_fx(
        }
    }


    memory_fx2[2][0] = L_tmp2[L_FRAME48k - 4];
    memory_fx2[2][1] = L_tmp2[L_FRAME48k - 3];
    memory_fx2[2][2] = L_tmp2[L_FRAME48k - 2];
@@ -6372,6 +6393,8 @@ void elliptic_bpf_48k_generic_fx(

    return;
}


/*-------------------------------------------------------------------*
 * synthesise_fb_high_band()
 *
@@ -6428,20 +6451,12 @@ void synthesise_fb_high_band_fx(
    IF( EQ_16( L_frame, L_FRAME16k ) )
    {
        /* for 16kHz ACELP core */
        elliptic_bpf_48k_generic_fx(
            element_mode,
            1, // IsUpsampled3
            excitation_in_interp3, &exp_tmp, tmp, bpf_memory, bpf_memory_Q, full_band_bpf_3_fx

        );
        elliptic_bpf_48k_generic_fx( element_mode, 1, /* IsUpsampled3 */ excitation_in_interp3, &exp_tmp, tmp, bpf_memory, bpf_memory_Q, full_band_bpf_3_fx );
    }
    ELSE
    {
        /* for 12.8kHz ACELP core */
        elliptic_bpf_48k_generic_fx(
            element_mode,
            1, // IsUpsampled3
            excitation_in_interp3, &exp_tmp, tmp, bpf_memory, bpf_memory_Q, full_band_bpf_1_fx );
        elliptic_bpf_48k_generic_fx( element_mode, 1, /* IsUpsampled3 */ excitation_in_interp3, &exp_tmp, tmp, bpf_memory, bpf_memory_Q, full_band_bpf_1_fx );
    }
    /* temp1 = sum2_f( tmp, L_FRAME48k ) + 0.001f */
    temp1 = sum2_fx_mod( tmp, L_FRAME48k );
@@ -6524,15 +6539,18 @@ void synthesise_fb_high_band_fx(
            move16();
        }
    }

    return;
}


/*-------------------------------------------------------------------*
 * Estimate_mix_factors_fx()                                         *
 *                                                                   *
 * Estimate mix factors for SHB excitation generation                *
 *-------------------------------------------------------------------*/
void Estimate_mix_factors_fx(

static void Estimate_mix_factors_fx(
    const Word16 *shb_res, /* i  : SHB LP residual in Q = Q_shb */
    const Word16 Q_shb,
    const Word16 *exc16kWhtnd, /* i  : SHB transformed low band excitation Q_bwe_exc */
@@ -6596,7 +6614,6 @@ void Estimate_mix_factors_fx(
        /* (Q_bwe_exc) */
    }


    length = L_FRAME16k;
    move16();
    temp_p1_p2 = Dot_product( temp_numer1, temp_numer2, length ); /* 2*(Q_bwe_exc)+1 */
@@ -6672,6 +6689,7 @@ void Estimate_mix_factors_fx(
    return;
}


/*======================================================================================*/
/* FUNCTION : prep_tbe_exc_fx() */
/*--------------------------------------------------------------------------------------*/
@@ -6721,7 +6739,6 @@ void prep_tbe_exc_fx(
    const Word16 idchan,         /* i  : channel ID                             */
    const Word16 flag_TD_BWE,    /* i  : flag indicating whether hTD_BWE exists */
    const Word16 tdm_LRTD_flag   /* i  : LRTD stereo mode flag                  */

)
{
    Word16 i;
+7 −4
Original line number Diff line number Diff line
@@ -7,7 +7,6 @@
#include "rom_com.h"
#include "prot_fx.h"
#include "rom_dec.h"
#include "stl.h"
#include "ivas_prot_fx.h"

/*-----------------------------------------------------------------*
@@ -278,9 +277,6 @@ static void rescale_genSHB_mem_dec(
        }
    }

    if ( EQ_16( st_fx->extl, FB_TBE ) )
    {
    }
    hBWE_TD->mem_csfilt_fx[0] = L_shl( hBWE_TD->mem_csfilt_fx[0], sf );
    move32();

@@ -292,6 +288,7 @@ static void rescale_genSHB_mem_dec(
    return;
}


static void find_max_mem_wb(
    Decoder_State *st_fx,
    Word16 *n_mem )
@@ -482,6 +479,12 @@ static void InitSWBdecBuffer_fx(
}


/*-------------------------------------------------------------------*
 * ResetSHBbuffer_Dec()
 *
 *
 *-------------------------------------------------------------------*/

void ResetSHBbuffer_Dec_fx(
    TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle      */
    const Word16 extl          /* i  : BWE extension layer     */
+2 −2
Original line number Diff line number Diff line
@@ -425,8 +425,8 @@ ivas_error evs_enc_fx(
    IF( EQ_16( st->extl, WB_TBE ) )
    {
        /* WB TBE encoder */
#ifdef HARMONIZE_TBEaa
        wb_tbe_enc_ivas_fx( st, hb_speech, bwe_exc_extended, Q_new, voice_factors, pitch_buf );
#ifdef HARMONIZE_TBE
        wb_tbe_enc_fx( st, hb_speech, bwe_exc_extended, Q_new, voice_factors, pitch_buf );
#else
        wb_tbe_enc_fx( st, st->coder_type, hb_speech, bwe_exc_extended, Q_new, voice_factors, pitch_buf, st->voicing_fx );
#endif
Loading