Commit ba2f12a1 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Stereo path functions conversion/ integration, config and initializations

[x] stereo icbwe enc, tdm_lp_comparison conversion/integration
[x] Conversion of core_signal_analysis_high_bitrate and its subfunctions and integration in ivas_mdct_core_whitening_enc stack
[x] Integration of few functions in pre_proc_front_ivas
[x] Intermediate code cleanup changes
[x] ivas_ism_enc_config stack fixed conversion
[x] tdm downmix function conversion and integration
parent 9735cfcc
Loading
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -2170,6 +2170,7 @@ uint16_t get_indice_1(
 * Reset the buffer of encoder indices
 *-------------------------------------------------------------------*/

#ifndef IVAS_FLOAT_FIXED
void reset_indices_enc(
    BSTR_ENC_HANDLE hBstr,       /* i/o: encoder bitstream handle    */
    const Word16 max_num_indices /* i  : max number of indices       */
@@ -2187,6 +2188,28 @@ void reset_indices_enc(

    return;
}
#else
void reset_indices_enc(
    BSTR_ENC_HANDLE hBstr,       /* i/o: encoder bitstream handle    */
    const Word16 max_num_indices /* i  : max number of indices       */
)
{
    Word16 i;

    hBstr->nb_bits_tot = 0;
    move16();
    hBstr->nb_ind_tot = 0;
    move16();

    FOR( i = 0; i < max_num_indices; i++ )
    {
        hBstr->ind_list[i].nb_bits = -1;
        move16();
    }

    return;
}
#endif

/*-------------------------------------------------------------------*
 * reset_indices_dec()
+67 −0
Original line number Diff line number Diff line
@@ -560,6 +560,27 @@ ivas_error ivas_FB_mixer_open_fx(
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" );
            }
        }
#if 1 // TODO: To be removed later
        if ( fb_cfg->num_out_chans == 0 )
        {
            hFbMixer->ppFilterbank_inFR_re[i] = NULL;
            hFbMixer->ppFilterbank_inFR_im[i] = NULL;
        }
        else
        {
            j = fb_cfg->remix_order[i];

            if ( ( hFbMixer->ppFilterbank_inFR_re[j] = (float *) malloc( sizeof( float ) * frame_len ) ) == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" );
            }

            if ( ( hFbMixer->ppFilterbank_inFR_im[j] = (float *) malloc( sizeof( float ) * frame_len ) ) == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" );
            }
        }
#endif
    }

    IF( EQ_16( fb_cfg->active_w_mixing, -1 ) )
@@ -579,6 +600,13 @@ ivas_error ivas_FB_mixer_open_fx(
            return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" );
        }
        set32_fx( hFbMixer->ppFilterbank_prior_input_fx[i], 0, fb_cfg->prior_input_length );
#if 1 // TODO: To be removed later
        if ( ( hFbMixer->ppFilterbank_prior_input[i] = (float *) malloc( sizeof( float ) * fb_cfg->prior_input_length ) ) == NULL )
        {
            return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" );
        }
        set_f( hFbMixer->ppFilterbank_prior_input[i], 0, fb_cfg->prior_input_length );
#endif
    }

    test();
@@ -598,6 +626,22 @@ ivas_error ivas_FB_mixer_open_fx(
                set32_fx( hFbMixer->prior_mixer_fx[i][j], 0, IVAS_MAX_NUM_BANDS );
            }
        }
#if 1 // TODO: To be removed later
        float *pTemp_mem;
        if ( ( pTemp_mem = (float *) malloc( sizeof( float ) * fb_cfg->num_out_chans * max( fb_cfg->num_in_chans, fb_cfg->nchan_fb_in ) * IVAS_MAX_NUM_BANDS ) ) == NULL )
        {
            return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer" );
        }
        for ( i = 0; i < fb_cfg->num_out_chans; i++ )
        {
            for ( j = 0; j < fb_cfg->num_in_chans; j++ )
            {
                hFbMixer->prior_mixer[i][j] = pTemp_mem;
                pTemp_mem += IVAS_MAX_NUM_BANDS;
                set_f( hFbMixer->prior_mixer[i][j], 0, IVAS_MAX_NUM_BANDS );
            }
        }
#endif
    }

    IF( !spar_reconfig_flag )
@@ -618,6 +662,12 @@ ivas_error ivas_FB_mixer_open_fx(
                    {
                        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder fixed" );
                    }
#if 1 // TODO: To be removed later
                    if ( ( hFbMixer->pFb->fb_bin_to_band.pFb_bin_to_band[i] = (float *) malloc( sizeof( float ) * pActive_bins_per_band_abs[i] ) ) == NULL )
                    {
                        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" );
                    }
#endif
                }
            }

@@ -634,6 +684,17 @@ ivas_error ivas_FB_mixer_open_fx(

                FOR( j = start_diff_band_non48k; j < num_bands; j++ )
                {
#if 1 // TODO: To be removed later
                    if ( ( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[0][j] = (float *) malloc( sizeof( float ) * pActive_bins_per_band[j] ) ) == NULL )
                    {
                        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" );
                    }

                    if ( ( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k[1][j] = (float *) malloc( sizeof( float ) * pActive_bins_per_band[j] ) ) == NULL )
                    {
                        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" );
                    }
#endif
                    IF( ( hFbMixer->pFb->fb_consts.ppFilterbank_FRs_non48k_fx[0][j] = (Word32 *) malloc( sizeof( Word32 ) * pActive_bins_per_band[j] ) ) == NULL )
                    {
                        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" );
@@ -666,6 +727,12 @@ ivas_error ivas_FB_mixer_open_fx(
        {
            return error;
        }
#if 1 // TODO: To be removed later
        if ( ( error = ivas_filterbank_setup( hFbMixer, sampling_rate ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#endif
    }

    *hFbMixer_out = hFbMixer;
+4 −0
Original line number Diff line number Diff line
@@ -1140,6 +1140,10 @@ void ivas_param_ism_config_fx(
    hParamIsm->last_dmx_gain_e = 1;
    move16();
    set16_fx( hParamIsm->last_cardioid_left_fx, (Word16) 16384, MAX_NUM_OBJECTS );
#if 1 // TODO: To be removed later
    hParamIsm->last_dmx_gain = 1.0f;
    set_f( hParamIsm->last_cardioid_left, 1.0f, MAX_NUM_OBJECTS );
#endif

    return;
}
+40 −21
Original line number Diff line number Diff line
@@ -342,16 +342,26 @@ 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[],                                  /* o  : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */
    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 */
@@ -1436,12 +1446,7 @@ ivas_error ivas_ism_metadata_dec(
 *----------------------------------------------------------------------------------*/

/*! r: ISM format mode */
#ifdef IVAS_FLOAT_FIXED
ISM_MODE ivas_ism_mode_select(
    const Word16 nchan_inp,                                    /* i  : number of input objects                     */
    const Word32 ivas_total_brate                              /* i  : IVAS total bitrate                          */
);
#else
#ifndef IVAS_FLOAT_FIXED
ISM_MODE ivas_ism_mode_select(
    const int16_t nchan_inp,                                    /* i  : number of input objects                     */
    const int32_t ivas_total_brate                              /* i  : IVAS total bitrate                          */
@@ -2797,7 +2802,21 @@ void stereo_tdm_combine_fx(
  const Word16 flag_HB,      /* i  : flag to distinguish between core (0) and HB (1) synthesis */
  const Word16 tdm_ratio_idx /* i  : TDM ratio index                             */
);

#ifdef IVAS_FLOAT_FIXED
Word16 tdm_lp_comparison_fx(
    STEREO_TD_ENC_DATA_HANDLE hStereoTD,  /* i/o: TD stereo encoder handle        */
    STEREO_CLASSIF_HANDLE hStereoClassif, /* i/o: stereo classifier structure     */
    Encoder_State *st,                    /* i/o: Encoder structure               */
    Word32 *speech_buff,                  /* i  : Current speech frame          Q_speech  */
    const Word16 *A_PCh_fx,               /* i  : primary channel LP coefficients Q12*/
    const Word16 *A_SCh_fx,               /* i  : secondary channel LP coeff.     Q12*/
    const Word16 m,                       /* i  : filter length                   */
    const Word32 *isp_PCh_fx,             /* i  : primary channel LSPs           Q31 */
    const Word32 *isp_SCh_fx,             /* i  : secondary channel LSPs         Q31 */
    const Word16 L_frame,                 /* i  : frame length                    */
    const Word32 element_brate_wo_meta,   /* i  : element bitrate without metadata*/
    Word16 Q_speech );
#else
/*! r: replication decision; 1 = Use old LP */
int16_t tdm_lp_comparison(
    STEREO_TD_ENC_DATA_HANDLE hStereoTD,                        /* i/o: TD stereo encoder handle                */
@@ -2812,7 +2831,7 @@ int16_t tdm_lp_comparison(
    const int16_t L_frame,                                      /* i  : frame length                            */
    const int32_t element_brate_wo_meta                         /* i  : element bitrate without metadata        */
);

#endif
/*! r: replication decision; 1 = Use old LP */
void tdm_ol_pitch_comparison(
    CPE_ENC_HANDLE hCPE,                                        /* i  : CPE encoder structure                   */
+24 −0
Original line number Diff line number Diff line
@@ -1353,6 +1353,15 @@ void stereo_tcx_init_dec_fx(
    const Word16 last_element_mode /* i  : element mode of previous frame      */
);

void stereo_icBWE_enc_ivas_fx(
    CPE_ENC_HANDLE hCPE,              /* i/o: CPE encoder structure                */
    const Word32 shb_speech_ref_fx[], /* i  : SHB speech ref channel               */
    const Word16 shb_speech_ref_e,    /* i  : SHB speech ref channel               */
    Word32 shb_speech_nonref_fx[],    /* i/o: SHB speech non-ref channel           */
    Word16 shb_speech_nonref_e,       /* i/o: SHB speech non-ref channel           */
    const Word32 *voice_factors_fx    /* i  : voicing factors                     Q31 */
);

void initMdctStereoDecData_fx(
    STEREO_MDCT_DEC_DATA *hStereoMdct, /* i/o: mdct stereo parameters structure */
    const Word16 igf,                  /* i  : flag indicating IGF activity     */
@@ -1361,6 +1370,16 @@ void initMdctStereoDecData_fx(
    const Word16 bwidth                /* i  : audio bandwidth                  */
);

void stereo_tdm_downmix_ivas_fx(
    STEREO_TD_ENC_DATA_HANDLE hStereoTD, /* i  : TD stereo IVAS encoder structure        */
    Word16 *Left_in_fx,                  /* Qx */
    Word16 *Right_in_fx,                 /* Qx */
    const Word16 input_frame,            /* i  : Number of samples                       */
    const Word16 tdm_ratio_idx,          /* i  : TDM ratio index                         */
    const Word16 tdm_SM_flag,            /* i  : channel combination scheme flag         */
    const Word16 tdm_ratio_idx_SM        /* i  : TDM ratio index for SM mode             */
);

void stereo_mdct_init_bands_fx(
    const Word16 L_frame,       /* i  : frame length                                       */
    const Word16 tmp_tcx_mode,  /* i  : tcx mode (TCX10, TCX 20), -1 if transition frame   */
@@ -3068,4 +3087,9 @@ void unclr_classifier_td_fx(
    CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure                           */
);
#endif

ISM_MODE ivas_ism_mode_select(
    const Word16 nchan_inp,       /* i  : number of input objects  */
    const Word32 ivas_total_brate /* i  : IVAS total bitrate       */
);
#endif
Loading