Commit 2c9d5e6f authored by Nishant S Kulgod's avatar Nishant S Kulgod
Browse files

commit 1

parent 29b454bb
Loading
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -209,6 +209,15 @@ enum{
#define L_FRAME8k                       160             /* Frame size in samples at 8kHz */
#define L_FRAME4k                       80              /* Frame size in samples at 4kHz */

#define ONE_BY_L_FRAME48k_Q31           2236962
#define ONE_BY_L_FRAME32k_Q31           3355443
#define ONE_BY_L_FRAME25_6k_Q31         4194304
#define ONE_BY_L_FRAME16k_Q31           6710886
#define ONE_BY_L_FRAME_Q31              8388608
#define ONE_BY_240_Q31                  8947849
#define ONE_BY_L_FRAME8k_Q31            13421772
#define ONE_BY_L_FRAME4k_Q31            26843546

#define L_SPEC48k                       800             /* HQ spectrum length at 48kHz */
#define L_SPEC32k                       640             /* HQ spectrum length at 32kHz */
#define L_SPEC16k                       320             /* HQ spectrum length at 16kHz */
@@ -737,6 +746,7 @@ enum
#define PIT_L_INTERPOL6_2                   17
#define PIT_FIR_SIZE6_2                     ( PIT_UP_SAMP6 * PIT_L_INTERPOL6_2 + 1 )
#define E_MIN                               0.0035f                /* minimum allowable energy */
#define E_MIN_Q11_FX                            7                      /* minimum allowable energy in Q11*/
#define STEP_DELTA                          0.0625f                /* quantization step for tilt compensation of gaussian cb. excitation */
#define GAMMA_EV                            0.92f                  /* weighting factor for core synthesis error weighting */
#define FORMANT_SHARPENING_NOISE_THRESHOLD  21.0f                  /* lp_noise level above which formant sharpening is deactivated */
@@ -2752,6 +2762,7 @@ enum
#define Fs_2_16k                              20480     /* lsf max value (Use in reorder_fx.c) */

#define LG10                                  24660       /*  10*log10(2)  in Q13                 */
#define TEN_MULT_LOG10_2_IN_Q29               1616142464             /* (10 * log10(2)) =  3.0103 (in Q29) */
#define LG10_s3_0                             16440       /* 10*log10(2)/1.55 = 1.00343331 in Q14              */
#define LOG2_10                               27213      /* log base 2 of 10 in Q12 */
#define LOG2_10_Q29                           1783446566      /* log base 2 of 10 in Q12 */
+38 −3
Original line number Diff line number Diff line
@@ -703,6 +703,7 @@ void stereo_tcx_init_enc(
    Encoder_State *st                                           /* i/o: encoder state structure                 */
);

#ifndef IVAS_FLOAT_FIXED
void stereo_tcx_core_enc(
    Encoder_State *st,                                          /* i/o: encoder state structure                 */
    const float new_samples_12k8[],                             /* i  : buffer of input signal @12.8 kHz        */
@@ -715,7 +716,6 @@ void stereo_tcx_core_enc(
    const int16_t vad_hover_flag                                /* i  : VAD hangover flag                       */
);

#ifndef IVAS_FLOAT_FIXED
void stereo_tcx_core_dec(
    Decoder_State *st,                                          /* i/o: decoder state structure                 */
    const FRAME_MODE frameMode,                                 /* i  : Decoder frame mode                      */
@@ -1805,10 +1805,12 @@ void stereo_dft_enc_res(
    const int16_t max_bits 
);

#ifndef IVAS_FLOAT_FIXED
void stereo_dft_enc_write_BS(
    CPE_ENC_HANDLE hCPE,                                        /* i/o: CPE encoder structure               */
    int16_t *nb_bits                                            /* o  : number of bits written              */
);
#endif

void stereo_dtf_cng( 
    CPE_DEC_HANDLE hCPE,                                        /* i/o: CPE decoder structure               */
@@ -1857,6 +1859,7 @@ void stereo_dft_dequantize_itd(
    const int32_t output_Fs 
);

#ifndef IVAS_FLOAT_FIXED
void stereo_dft_enc_sid_calc_coh(
    STEREO_DFT_ENC_DATA_HANDLE hStereoDft,                      /* i/o: DFT stereo handle                   */
    float prev_cohBand[2*(STEREO_DFT_BAND_MAX/2)],              /* i/o: Previous coherence                  */
@@ -1864,7 +1867,9 @@ void stereo_dft_enc_sid_calc_coh(
    int16_t *first_SID,                                         /* i/o: First SID indicator                 */
    float *cohBand                                              /* i/o: Coherence per band                  */
);
#endif

#ifndef IVAS_FLOAT_FIXED
void stereo_dft_enc_sid_coh(
    BSTR_ENC_HANDLE hBstr,                                      /* i/o: bitstream handle                    */
    float *mem_cohBand,                                         /* i/o: Coherence memory                    */
@@ -1872,6 +1877,7 @@ void stereo_dft_enc_sid_coh(
    int16_t *nb_bits,                                           /* i/o: number of bits written              */
    float *cohBand                                              /* i/o: Coherence per band                  */
);
#endif
#ifdef IVAS_FLOAT_FIXED
void stereo_dft_dec_sid_coh_fx(
    Decoder_State *st,                                          /* i/o: decoder state structure             */
@@ -3102,7 +3108,17 @@ void TNSAnalysisStereo(
    int16_t param_core[][NB_DIV * NPRM_DIV],                    /* o  : quantized noise filling level           */
    const int16_t mct_on                                        /* i  : flag mct block (1) or stereo (0)        */
);

#ifdef IVAS_FLOAT_FIXED
void TNSAnalysisStereo_fx(
    Encoder_State **sts,                        /* i  : encoder state handle                    */
    Word32 *mdst_spectrum_fx[CPE_CHANNELS][NB_DIV], /* o  : MDST spectrum                       Qx*/
    const Word16 bWhitenedDomain,               /* i  : whitened domain flag                    Q0*/
    Word16 tnsSize[CPE_CHANNELS][NB_DIV],       /* i  : number of tns parameters put into prm   Q0*/
    Word16 tnsBits[CPE_CHANNELS][NB_DIV],       /* i  : number of tns bits in the frame         Q0*/
    Word16 param_core[][NB_DIV * NPRM_DIV],     /* o  : TNS parameters                          Q0*/
    const Word16 mct_on                         /* i  : flag mct block (1) or stereo (0)        Q0*/
);
#endif
void InternalTCXDecoder(
    Encoder_State *st,                                          /* i/o: state handle                            */
    const int16_t frame_cnt,                                    /* i  : frame counter in the super_frame        */
@@ -3681,7 +3697,26 @@ ivas_error front_vad(
    float *PS_out,                                              /* o  : energy spectrum                         */
    float *Bin_E_out                                            /* o  : log-energy spectrum of the current frame*/
);

#ifdef IVAS_FLOAT_FIXED
ivas_error front_vad_fx(
    CPE_ENC_HANDLE hCPE,                                        /* i/o: CPE encoder structure, nullable         */
    Encoder_State *st,                                          /* i/o: encoder state structure                 */
    const ENCODER_CONFIG_HANDLE hEncoderConfig,                 /* i  : configuration structure                 */
    FRONT_VAD_ENC_HANDLE *hFrontVads,                           /* i/o: front-VAD handles                       */
    const int16_t MCT_flag,                                     /* i  : hMCT handle allocated (1) or not (0)    */
    const int16_t input_frame,                                  /* i  : frame length                            */
    int16_t vad_flag_dtx[],                                     /* o  : HE-SAD flag with additional DTX HO      */
    float fr_bands[][2 * NB_BANDS],                             /* i  : energy in frequency bands               */
    float Etot_LR[],                                            /* o  : total energy Left & Right channel       */
    float lf_E[][2 * VOIC_BINS],                                /* i  : per bin spectrum energy in lf, LR channels  */
    int16_t localVAD_HE_SAD[],                                  /* o  : HE-SAD flag without hangover, LR channels   */
    int16_t vad_hover_flag[],                                   /* o  : VAD hangover flag                           */
    float band_energies_LR[2 * NB_BANDS],                       /* o  : energy in critical bands without minimum noise floor E_MIN */
    float *PS_out,                                              /* o  : energy spectrum                         */
    float *Bin_E_out,                                            /* o  : log-energy spectrum of the current frame*/
    Word16 Qinp
);
#endif
ivas_error front_vad_spar(
    SPAR_ENC_HANDLE hSpar,                                      /* i/o: SPAR encoder structure                  */
    const float *omni_in,                                       /* i  : omnidirectional input signal            */
+71 −5
Original line number Diff line number Diff line
@@ -296,10 +296,10 @@ Word16 res_bpf_adapt_fx(

// ivas_sns_com_fx.c
void sns_compute_scf_fx(
    Word32 spectrum[],
    Word32 spectrum[], /* i  : Spectrum (Q_in) */
    const PsychoacousticParameters *pPsychParams,
    const Word16 L_frame,
    Word32 *scf,
    Word32 *scf, /* o  : Scalefactors (Q16)*/
    Word16 q );

void sns_interpolate_scalefactors_fx(
@@ -1402,10 +1402,18 @@ void dtx_read_padding_bits_fx(
    DEC_CORE_HANDLE st,
    const Word16 num_bits );

void FdCngEncodeMDCTStereoSID_fx(
    CPE_ENC_HANDLE hCPE /* i/o: CPE encoder state structure     */
);

void FdCngDecodeMDCTStereoSID_fx(
    CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure     */
);

void FdCngEncodeDiracMDCTStereoSID_fx(
    CPE_ENC_HANDLE hCPE /* i/o: CPE encoder state structure             */
);

void FdCngDecodeDiracMDCTStereoSID_fx(
    CPE_DEC_HANDLE hCPE /* i/o: CPE decoder state structure     */
);
@@ -2700,7 +2708,6 @@ void rc_uni_enc_encode_bits(
    const Word16 bits            /* i  : Number of bits                      */
);

#ifdef IVAS_FLOAT_FIXED
void stereo_dft_enc_process_fx(
    CPE_ENC_HANDLE hCPE,           /* i/o: CPE encoder structure       */
    const Word16 vad_flag_dtx[],   /* i  : VAD dtx flags               */
@@ -2708,6 +2715,54 @@ void stereo_dft_enc_process_fx(
    const Word16 input_frame       /* i  : input frame length          */
);

void stereo_dft_cng_side_gain_fx(
    STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: DFT stereo handle            */
    STEREO_CNG_ENC_HANDLE hStereoCng,      /* i/o: Stereo CNG data structure    */
    const Word32 core_brate,               /* i  : core bitrate                 */
    const Word32 last_core_brate,          /* i  : last core bitrate            */
    const Word16 bwidth                    /* i  : audio band-width             */
);

Word16 quantize_sns_fx(
    Word32 sns_in_fx[CPE_CHANNELS][NB_DIV][M],   /* sns_e */
    Word32 snsQ_out_fx[CPE_CHANNELS][NB_DIV][M], /* sns_e */
    Word16 *sns_e,
    Encoder_State **sts,
    Word16 *indices,           /* Q0 */
    Word16 *zero_side_flag,    /* Q0 */
    Word16 *sns_stereo_mode ); /* Q0 */

void stereo_cng_upd_counters_fx(
    STEREO_CNG_ENC_HANDLE hStereoCng, /* i/o: Stereo CNG data structure     */
    const Word32 element_mode,        /* i  : element mode                  */
    const Word16 nbands,              /* i  : Number of bands in active     */
    const Word32 sidSideGain[],       /* i  : SID side gains                */
    const Word16 burst_ho_count,      /* i  : Hang-over count               */
    Word16 *coh_fade_counter          /* i  : Coherence fade counter        */
);


void stereo_dft_enc_sid_calc_coh_fx(
    STEREO_DFT_ENC_DATA_HANDLE hStereoDft,               /* i/o: DFT stereo handle           */
    Word32 prev_cohBand[2 * (STEREO_DFT_BAND_MAX / 2)], /* i/o: Previous coherence  Q31 */
    Word16 *td_active,                                  /* i/o: TD stereo mode indicator    */
    Word16 *first_SID,                                  /* i/o: First SID indicator         */
    Word32 *cohBand                                       /* i/o: Coherence per band Q31         */
);

void stereo_dft_enc_sid_coh_fx(
    BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle             */
    Word32 *mem_cohBand,    /* i/o: Coherence memory             */
    const Word16 nbands,  /* i  : number of DFT stereo bands   */
    Word16 *nb_bits,      /* i/o: number of bits written       */
    Word32 *cohBand         /* i/o: Coherence per band           */
);

void stereo_dft_enc_write_BS_fx(
    CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure   */
    Word16 *nb_bits     /* o  : number of bits written  */
);

void spectral_balancer_fx16(
    Word16 *signal,        /* i/o  : signal  Qx                 */
    Word16 *mem,           /* i/o  : mem  Qx                    */
@@ -2763,8 +2818,6 @@ void acelp_fast_fx(
    const Word16 L_subfr                                     /* i  : subframe length                               */
);

#endif

void ivas_mdct_quant_coder_fx(
    CPE_ENC_HANDLE hCPE,                  /* i/o: Encoder CPE handle                   */
    Word16 tnsBits[CPE_CHANNELS][NB_DIV], /* i  : bits needed for TNS parameters       */
@@ -2819,4 +2872,17 @@ void InternalTCXDecoder_fx(
    Word16 synth[],                  /* o  : time domain signal                      */
    Word16 *gain_tcx_q               /* o  : quantized global gain (at low bitrates) */
);

void stereo_tcx_core_enc(
    Encoder_State *st,                /* i/o: encoder state structure                    */
    const float new_samples_12k8[],   /* i  : buffer of input signal @12.8 kHz           */
    const float new_samples_16k[],    /* i  : buffer of input signal @16 kHz             */
    const Word16 Aw_fx[],             /* i  : weighted A(z) unquant. for subframes, Q12  */
    float lsp_new[],                  /* i  : LSPs at the end of the frame, Q15          */
    float lsp_mid[],                  /* i  : LSPs in the middle of the frame, Q15       */
    Word16 pitch_buf_fx[NB_SUBFR16k], /* o  : pitch for each subframe, Q6                */
    const Word16 last_element_mode,   /* i  : last element mode, Q0                      */
    const Word16 vad_hover_flag       /* i  : VAD hangover flag, Q0                      */
);

#endif
+8 −0
Original line number Diff line number Diff line
@@ -962,6 +962,14 @@ const float nf_tw_smoothing_coeffs[N_LTP_GAIN_MEMS] =
 * Stereo DTX tables
 *----------------------------------------------------------------------------------*/
const Word32 dft_cng_coh_pred_Q29[STEREO_DFT_N_COH_PRED][STEREO_DFT_COH_PRED_COEFFS] =
{
    { 322840352, -54249732, 681323520, 45657648, 149804160, 359663232, 43794172, 101391832, -92841088, 172591648, 5010079, -45280228, 194478800, -229067248, 407153760 },
    { 459212000, 225880928, 221880688, -5028333, -214586768, 743996800, 6672231, -8234526, 84004728, 277797408, 86032488, -163012256, 256499744, -301048768, 742268608 },
    { 108739448, 26209502, 141415552, 12636868, 49403400, 212415664, 7013681, -5973762, 19040664, 524015552, 5351529, 87486872, 205720880, -196222560, 1360794368 },
    { 748217664, -70545376, 531195648, 396387904, 367147232, 900332, -121036472, -6527276, 582294464, -61989264, 12010339, -24459838, -180512112, 226957888, 267986096 }
};
const float dft_cng_coh_pred[STEREO_DFT_N_COH_PRED][STEREO_DFT_COH_PRED_COEFFS] =
{
    { 0.601337f, -0.101048f,  1.269064f,  0.085044f,  0.279032f,  0.669925f,  0.081573f,  0.188857f, -0.172930f,  0.321477f,  0.009332f, -0.084341f,  0.362245f, -0.426671f,  0.758383f},
+2 −0
Original line number Diff line number Diff line
@@ -159,9 +159,11 @@ extern const float nf_tw_smoothing_coeffs[N_LTP_GAIN_MEMS];
 * Stereo DTX ROM tables
 *----------------------------------------------------------------------------------*/

extern const Word16 dft_cng_coh_pred_fx[][STEREO_DFT_COH_PRED_COEFFS];
extern const float dft_cng_coh_pred[][STEREO_DFT_COH_PRED_COEFFS];
extern const int16_t dft_cng_coh_u2i[9];
extern const int16_t dft_cng_coh_i2u[9];
extern const Word16 dft_cng_alpha_bits_fx[STEREO_DFT_N_COH_ALPHA_STEPS][STEREO_DFT_N_COH_ALPHA_LEVELS];
extern const float dft_cng_alpha_bits[STEREO_DFT_N_COH_ALPHA_STEPS][STEREO_DFT_N_COH_ALPHA_LEVELS];
extern const int16_t dft_cng_coh_alpha_start[STEREO_DFT_N_COH_ALPHA_STEPS - 1];

Loading