Commit 0c981e1d authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'enc_flt_struct_cleanup_libcom_Q_info_LTV_enc_fixes' into 'main'

Encoder code float stucture elements cleanup, LTV crash fixes, Q-info updates for lib_com files

See merge request !775
parents 34e96575 d185b931
Loading
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -2843,6 +2843,8 @@ static void cldfb_init_proto_and_twiddles_enc_fx(
            {
                hs->ds = 10;
                hs->da = 10;
                move16();
                move16();
                hs->rot_vec_ana_delay_re_fx = NULL;
                hs->rot_vec_ana_delay_im_fx = NULL;
                hs->rot_vec_syn_delay_re_fx = NULL;
@@ -2857,6 +2859,8 @@ static void cldfb_init_proto_and_twiddles_enc_fx(
            {
                hs->ds = 40;
                hs->da = -20;
                move16();
                move16();
                hs->rot_vec_ana_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
                hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
                hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
@@ -2884,6 +2888,8 @@ static void cldfb_init_proto_and_twiddles_enc_fx(
            {
                hs->ds = 20;
                hs->da = 20;
                move16();
                move16();
                hs->rot_vec_ana_delay_re_fx = NULL;
                hs->rot_vec_ana_delay_im_fx = NULL;
                hs->rot_vec_syn_delay_re_fx = NULL;
@@ -2898,6 +2904,8 @@ static void cldfb_init_proto_and_twiddles_enc_fx(
            {
                hs->ds = 80;
                hs->da = -40;
                move16();
                move16();
                hs->rot_vec_ana_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
                hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
                hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
@@ -2932,6 +2940,8 @@ static void cldfb_init_proto_and_twiddles_enc_fx(
            {
                hs->ds = 20;
                hs->da = 20;
                move16();
                move16();
                hs->rot_vec_ana_delay_re_fx = NULL;
                hs->rot_vec_ana_delay_im_fx = NULL;
                hs->rot_vec_syn_delay_re_fx = NULL;
@@ -2946,6 +2956,8 @@ static void cldfb_init_proto_and_twiddles_enc_fx(
            {
                hs->ds = 80;
                hs->da = -40;
                move16();
                move16();
                hs->rot_vec_ana_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
                hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
                hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
@@ -2979,6 +2991,8 @@ static void cldfb_init_proto_and_twiddles_enc_fx(
            {
                hs->ds = 30;
                hs->da = 30;
                move16();
                move16();
                hs->rot_vec_ana_delay_re_fx = NULL;
                hs->rot_vec_ana_delay_im_fx = NULL;
                hs->rot_vec_syn_delay_re_fx = NULL;
@@ -2991,6 +3005,8 @@ static void cldfb_init_proto_and_twiddles_enc_fx(
            {
                hs->ds = 120;
                hs->da = -60;
                move16();
                move16();
                hs->rot_vec_ana_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
                hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
                hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
@@ -3018,6 +3034,8 @@ static void cldfb_init_proto_and_twiddles_enc_fx(
            {
                hs->ds = 32;
                hs->da = 32;
                move16();
                move16();
                hs->rot_vec_ana_delay_re_fx = NULL;
                hs->rot_vec_ana_delay_im_fx = NULL;
                hs->rot_vec_syn_delay_re_fx = NULL;
@@ -3032,6 +3050,8 @@ static void cldfb_init_proto_and_twiddles_enc_fx(
            {
                hs->ds = 160;
                hs->da = -80;
                move16();
                move16();
                hs->rot_vec_ana_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
                hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
                hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
@@ -3065,6 +3085,8 @@ static void cldfb_init_proto_and_twiddles_enc_fx(
            {
                hs->ds = 40;
                hs->da = 40;
                move16();
                move16();
                hs->rot_vec_ana_delay_re_fx = NULL;
                hs->rot_vec_ana_delay_im_fx = NULL;
                hs->rot_vec_syn_delay_re_fx = NULL;
@@ -3079,6 +3101,8 @@ static void cldfb_init_proto_and_twiddles_enc_fx(
            {
                hs->ds = 160;
                hs->da = -80;
                move16();
                move16();
                hs->rot_vec_ana_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
                hs->rot_vec_ana_delay_im_fx = rot_vec_delay_im_LDQMF_fx;
                hs->rot_vec_syn_delay_re_fx = rot_vec_delay_re_LDQMF_fx;
+10 −25
Original line number Diff line number Diff line
@@ -50,9 +50,9 @@
/*-------------------------------------------------------------------
 * Local function prototypes
 *-------------------------------------------------------------------*/

#ifndef IVAS_FLOAT_FIXED
static void mhvals_flt( const int16_t d, float *m );

#endif
static void getmidbands( int16_t *part, const int16_t npart, int16_t *midband, float *psize_flt, float *psize_inv_flt );


@@ -85,11 +85,12 @@ ivas_error createFdCngCom_flt(
 *
 *
 *-------------------------------------------------------------------*/

#ifndef IVAS_FLOAT_FIXED
void initFdCngCom_flt(
    HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
    const float scale )
{

    /* Calculate FFT scaling factor */
    hFdCngCom->scalingFactor_flt = 1 / ( scale * scale * 8.f );

@@ -100,28 +101,20 @@ void initFdCngCom_flt(

    /* Initialize the comfort noise generation */
    set_f( hFdCngCom->fftBuffer_flt, 0.0f, FFTLEN );
    set_f( hFdCngCom->cngNoiseLevel_flt, 0.0f, FFTCLDFBLEN );
    set_f( hFdCngCom->olapBufferSynth2_flt, 0.0f, FFTLEN );
    set_f( hFdCngCom->cngNoiseLevel_flt, 0.0f, FFTCLDFBLEN );

    /* Initialize quantizer */
    set_f( hFdCngCom->sidNoiseEst_flt, 0.0f, NPART );
    set_f( hFdCngCom->A_cng_flt, 0.0f, M + 1 );
    hFdCngCom->A_cng_flt[0] = 1.f;
#ifdef IVAS_FLOAT_FIXED
    set16_fx( hFdCngCom->A_cng, 0, M + 1 );
    hFdCngCom->A_cng[0] = MAX_16;
#endif

    /* Set some counters and flags */
    hFdCngCom->inactive_frame_counter = 0; /* Either SID or zero frames */
    hFdCngCom->active_frame_counter = 0;
    hFdCngCom->frame_type_previous = ACTIVE_FRAME;
    hFdCngCom->flag_noisy_speech = 0;
#ifndef IVAS_FLOAT_FIXED
    hFdCngCom->likelihood_noisy_speech_flt = 0.f;
#else
    hFdCngCom->likelihood_noisy_speech = 0;
#endif
    hFdCngCom->numCoreBands = 0;
    hFdCngCom->stopBand = 0;
    hFdCngCom->startBand = 0;
@@ -136,33 +129,24 @@ void initFdCngCom_flt(
    set_f( hFdCngCom->periodog_flt, 0.0f, PERIODOGLEN );
    mhvals_flt( MSNUMSUBFR * MSSUBFRLEN, &( hFdCngCom->msM_win_flt ) );
    mhvals_flt( MSSUBFRLEN, &( hFdCngCom->msM_subwin_flt ) );
    set_f( hFdCngCom->msPeriodogSum_flt, 0.0f, 2 );
    set_f( hFdCngCom->msPsdSum_flt, 0.0f, 2 );
#ifndef IVAS_FLOAT_FIXED
    set_f( hFdCngCom->msPeriodogSum_flt, 0.0f, 2 );
    set_f( hFdCngCom->msSlope_flt, 0.0f, 2 );
    set_f( hFdCngCom->msQeqInvAv_flt, 0.0f, 2 );
#else
    set16_fx( hFdCngCom->msSlope, 0, 2 );
    set32_fx( hFdCngCom->msQeqInvAv, 0, 2 );
#endif
    hFdCngCom->init_old_flt = 0;

    hFdCngCom->msFrCnt_init_counter = 0;
    hFdCngCom->msFrCnt_init_thresh = 1;
    hFdCngCom->offsetflag = 0;
    hFdCngCom->msFrCnt = MSSUBFRLEN;
    hFdCngCom->msMinBufferPtr = 0;
#ifndef IVAS_FLOAT_FIXED
    set_f( hFdCngCom->msAlphaCor_flt, 0.3f, 2 );

    hFdCngCom->coherence_flt = 0.5f;
#else
    set32_fx( hFdCngCom->msAlphaCor, 644245120l /*0.3f Q31*/, 2 );

    hFdCngCom->coherence_fx = 16384; /* 0.5 in Q15 */
#endif

    return;
}
#endif


/*-------------------------------------------------------------------
@@ -1238,7 +1222,7 @@ void SynthesisSTFT_dirac_fx(
 *
 * Compute some values used in the bias correction of the minimum statistics algorithm
 *-------------------------------------------------------------------*/

#ifndef IVAS_FLOAT_FIXED
static void mhvals_flt(
    const int16_t d,
    float *m )
@@ -1278,6 +1262,7 @@ static void mhvals_flt(

    return;
}
#endif

/*-------------------------------------------------------------------
 * rand_gauss_flt()
+434 −426

File changed.

Preview size limit exceeded, changes collapsed.

+2 −27
Original line number Diff line number Diff line
@@ -280,6 +280,7 @@ ivas_error pre_proc_ivas(
    const int32_t last_element_brate,                           /* i  : last element bitrate                    */
    const int16_t input_frame,                                  /* i  : frame length                            */
    float old_inp_12k8[],                                       /* i/o: buffer of old input signal              */
    Word16 old_inp_12k8_fx[],                                       /* i/o: buffer of old input signal              */
    float old_inp_16k[],                                        /* i/o: buffer of old input signal @ 16kHz      */
    float **inp,                                                /* o  : ptr. to inp. signal in the current frame*/
    float *ener,                                                /* o  : residual energy from Levinson-Durbin    */
@@ -290,7 +291,7 @@ ivas_error pre_proc_ivas(
    float lsp_mid[M],                                           /* i/o: LSPs in the middle of the frame         */
    float *new_inp_resamp16k,                                   /* o  : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */
    int16_t *Voicing_flag,                                      /* o  : voicing flag for HQ FEC                 */
    const float old_wsp[],                                      /* i  : weighted input signal buffer            */
    float old_wsp[],                                      /* i  : weighted input signal buffer            */
    const int16_t loc_harm,                                     /* i  : harmonicity flag                        */
#ifndef IVAS_FLOAT_FIXED
    const float cor_map_sum,                                    /* i  : speech/music clasif. parameter          */
@@ -313,32 +314,6 @@ ivas_error pre_proc_ivas(
#endif
);

ivas_error ivas_compute_core_buffers(
    Encoder_State *st,               /* i/o: encoder state structure                  */
    float **inp16k_out,              /* o  : ptr. to inp. signal in the current frame */
    float *old_inp_16k,              /* i/o: buffer of old input signal @ 16kHz       */
    float new_inp_resamp16k_out[],   /* o  : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */
    const int16_t input_frame,       /* i  : frame length                             */
    const int16_t last_element_mode, /* i  : last element mode                        */
    const int32_t sr_core,           /* i  : core-coder sampling rate                 */
    float *ener,                     /* o  : residual energy from Levinson-Durbin     */
#ifndef IVAS_FLOAT_FIXED
    float A[NB_SUBFR16k * (M + 1)],  /* i/o: A(z) unquantized for the 4 subframes     */
    float Aw[NB_SUBFR16k * (M + 1)], /* i/o: weighted A(z) unquantized for subframes  */
#else
    Word16 A_fx[NB_SUBFR16k * (M + 1)],     /* i/o: A(z) unquantized for the 4 subframes     */
    Word16 Aw_Fx[NB_SUBFR16k * (M + 1)],    /* i/o: weighted A(z) unquantized for subframes  */
#endif
    float epsP[M + 1], /* i/o: LP prediction errors                     */
#ifndef IVAS_FLOAT_FIXED
    float lsp_new[M], /* i/o: LSPs at the end of the frame             */
    float lsp_mid[M]  /* i/o: LSPs in the middle of the frame          */
#else
    Word16 lsp_new_fx[M],                     /* i/o: LSPs at the end of the frame             */
    Word16 lsp_mid_fx[M]                      /* i/o: LSPs in the middle of the frame          */
#endif
);

/*! r: number of clipped samples */
uint32_t ivas_syn_output(
	float *synth[],                                             /* i/o: float synthesis signal                  */
+17 −0
Original line number Diff line number Diff line
@@ -5820,6 +5820,23 @@ ivas_error ivas_mct_enc_fx(
    const Word16 nb_bits_metadata      /* i  : number of metadata bits           */
);

ivas_error ivas_compute_core_buffers_fx(
    Encoder_State *st,                     /* i/o: encoder state structure                  */
    Word16 **inp16k_out_fx,                /* o  : ptr. to inp. signal in the current frame */
    Word16 *old_inp_16k_fx,                /* i/o: buffer of old input signal @ 16kHz       */
    Word16 new_inp_resamp16k_out_fx[],     /* o  : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */
    const Word16 input_frame,              /* i  : frame length                             */
    const Word16 last_element_mode,        /* i  : last element mode                        */
    const Word32 sr_core,                  /* i  : core-coder sampling rate                 */
    Word32 *ener,                          /* o  : residual energy from Levinson-Durbin     */
    Word16 A_fx[NB_SUBFR16k * ( M + 1 )],  /* i/o: A(z) unquantized for the 4 subframes     */
    Word16 Aw_fx[NB_SUBFR16k * ( M + 1 )], /* i/o: weighted A(z) unquantized for subframes  */
    Word32 epsP[M + 1],                    /* i/o: LP prediction errors                     */
    Word16 lsp_new_fx[M],                  /* i/o: LSPs at the end of the frame             */
    Word16 lsp_mid_fx[M],                  /* i/o: LSPs in the middle of the frame          */
    Word16 Q_old_inp_16k,
    Word16 Q_r[2] );

ivas_error ivas_enc_fx(
    Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure      */
    const Word16 *data,      /* i  : input signal             Q0 */
Loading