Commit 8e9af9fa authored by vaclav's avatar vaclav
Browse files

more simplifications

parent 0089595d
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -77,6 +77,9 @@ ivas_error ivas_cpe_dec(
    float res_buf[STEREO_DFT_N_8k];
    CPE_DEC_HANDLE hCPE;
    Decoder_State **sts;
#ifdef SIMPLIFY_IVAS_CORE
    STEREO_DFT_CONFIG_DATA_HANDLE hConfigDft;
#endif
    int32_t ivas_total_brate;
    ivas_error error;
    int32_t cpe_brate;
@@ -116,6 +119,14 @@ ivas_error ivas_cpe_dec(
        return error;
    }

#ifdef SIMPLIFY_IVAS_CORE
    hConfigDft = NULL;
    IF( hCPE->hStereoDft != NULL )
    {
        hConfigDft = hCPE->hStereoDft->hConfig;
    }

#endif
    /*------------------------------------------------------------------*
     * Initialization
     *-----------------------------------------------------------------*/
@@ -172,11 +183,19 @@ ivas_error ivas_cpe_dec(
        {
            if ( st_ivas->ivas_format == MASA_ISM_FORMAT )
            {
#ifdef SIMPLIFY_IVAS_CORE
                stereo_dft_config( hConfigDft, (int32_t) ( 0.7f * st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC ), &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
#else
                stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, (int32_t) ( 0.7f * st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC ), &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
#endif
            }
            else
            {
#ifdef SIMPLIFY_IVAS_CORE
                stereo_dft_config( hConfigDft, st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
#else
                stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
#endif
            }
        }
        else
@@ -184,11 +203,19 @@ ivas_error ivas_cpe_dec(
            /* Note: This only works for stereo operation. If DTX would be applied for multiple CPEs a different bitrate signaling is needed */
            if ( ivas_total_brate <= IVAS_SID_5k2 )
            {
#ifdef SIMPLIFY_IVAS_CORE
                stereo_dft_config( hConfigDft, ivas_total_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
#else
                stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, ivas_total_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
#endif
            }
            else
            {
#ifdef SIMPLIFY_IVAS_CORE
                stereo_dft_config( hConfigDft, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
#else
                stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
#endif
            }
        }
    }
@@ -415,7 +442,11 @@ ivas_error ivas_cpe_dec(
     * Core Decoder
     *----------------------------------------------------------------*/

#ifdef SIMPLIFY_IVAS_CORE
    if ( hCPE->element_mode != IVAS_CPE_DFT || ( hCPE->nchan_out == 1 && hConfigDft->res_cod_mode == STEREO_DFT_RES_COD_OFF ) )
#else
    if ( hCPE->element_mode != IVAS_CPE_DFT || ( hCPE->nchan_out == 1 && hCPE->hStereoDft->hConfig->res_cod_mode == STEREO_DFT_RES_COD_OFF ) )
#endif
    {
        if ( ( error = ivas_core_dec( st_ivas, NULL, hCPE, st_ivas->hMCT, n_channels, output, outputHB, NULL, st_ivas->sba_dirac_stereo_flag ) ) != IVAS_ERR_OK )
        {
@@ -434,7 +465,11 @@ ivas_error ivas_cpe_dec(
     * Stereo decoder & upmixing
     *----------------------------------------------------------------*/

#ifdef SIMPLIFY_IVAS_CORE
    if ( hCPE->element_mode == IVAS_CPE_DFT && !( hCPE->nchan_out == 1 && hConfigDft->res_cod_mode == STEREO_DFT_RES_COD_OFF ) )
#else
    if ( hCPE->element_mode == IVAS_CPE_DFT && !( hCPE->nchan_out == 1 && hCPE->hStereoDft->hConfig->res_cod_mode == STEREO_DFT_RES_COD_OFF ) )
#endif
    {
        float DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX];

+7 −0
Original line number Diff line number Diff line
@@ -90,7 +90,11 @@ ivas_error ivas_core_enc(
    float *inp[CPE_CHANNELS];
    float new_inp_resamp16k[CPE_CHANNELS][L_FRAME16k]; /* new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */
    float old_syn_12k8_16k[CPE_CHANNELS][L_FRAME16k];  /* ACELP core synthesis at 12.8kHz or 16kHz to be used by the SWB BWE */
#ifdef SIMPLIFY_IVAS_CORE
    float *shb_speech;
#else
    float shb_speech[L_FRAME16k];
#endif
    float hb_speech[L_FRAME16k / 4];
    float *new_swb_speech;
    float new_swb_speech_buffer[L_FRAME48k + STEREO_DFT_OVL_MAX];
@@ -363,6 +367,9 @@ ivas_error ivas_core_enc(
         *---------------------------------------------------------------------*/

        new_swb_speech = new_swb_speech_buffer + STEREO_DFT_OVL_MAX;
#ifdef SIMPLIFY_IVAS_CORE
        shb_speech = new_inp_resamp16k; /* reuse existing buffer */
#endif

        if ( !st->Opt_SC_VBR && input_Fs >= 32000 && st->hBWE_TD != NULL )
        {
+66 −3
Original line number Diff line number Diff line
@@ -68,6 +68,9 @@ ivas_error ivas_cpe_enc(
)
{
    CPE_ENC_HANDLE hCPE;
#ifdef SIMPLIFY_IVAS_CORE
    STEREO_DFT_CONFIG_DATA_HANDLE hConfigDft;
#endif
    Encoder_State **sts;
    int16_t n, n_CoreChannels;
    float old_inp_12k8[CPE_CHANNELS][L_INP_12k8];                            /* buffer of input signal @ 12k8            */
@@ -206,7 +209,14 @@ ivas_error ivas_cpe_enc(
        return error;
    }

#ifdef SIMPLIFY_IVAS_CORE
    hConfigDft = NULL;
    IF( hCPE->hStereoDft != NULL )
    {
        hConfigDft = hCPE->hStereoDft->hConfig;
    }

#endif
    /*----------------------------------------------------------------*
     * Set TD stereo parameters
     *----------------------------------------------------------------*/
@@ -281,23 +291,39 @@ ivas_error ivas_cpe_enc(


    if ( hCPE->element_mode != IVAS_CPE_MDCT && ( hCPE->element_brate != hCPE->last_element_brate || hCPE->last_element_mode != hCPE->element_mode || sts[0]->ini_frame == 0 ||
#ifdef SIMPLIFY_IVAS_CORE
                                                  ( ivas_total_brate != hEncoderConfig->last_ivas_total_brate ) || sts[0]->last_core_brate <= SID_2k40 ) ) /* If the last frame was SID or NO_DATA, we need to run stereo_dft_config here since VAD decision is not known yet */
#else
                                                  ( ivas_total_brate != st_ivas->hEncoderConfig->last_ivas_total_brate ) || sts[0]->last_core_brate <= SID_2k40 ) ) /* If the last frame was SID or NO_DATA, we need to run stereo_dft_config here since VAD decision is not known yet */
#endif
    {
        if ( st_ivas->hQMetaData != NULL )
        {
            if ( ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode != ISM_MODE_NONE )
            {
#ifdef SIMPLIFY_IVAS_CORE
                stereo_dft_config( hConfigDft, (int32_t) ( 0.70f * st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC ), &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
#else
                stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, (int32_t) ( 0.70f * st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC ), &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
#endif
            }
            else
            {
#ifdef SIMPLIFY_IVAS_CORE
                stereo_dft_config( hConfigDft, st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
#else
                stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, st_ivas->hQMetaData->bits_frame_nominal * FRAMES_PER_SEC, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
#endif
            }
        }
        else
        {
            /* note; "bits_frame_nominal" needed in TD stereo as well */
#ifdef SIMPLIFY_IVAS_CORE
            stereo_dft_config( hConfigDft, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
#else
            stereo_dft_config( hCPE->hStereoDft == NULL ? NULL : hCPE->hStereoDft->hConfig, hCPE->element_brate, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
#endif
        }
    }

@@ -368,13 +394,25 @@ ivas_error ivas_cpe_enc(

    if ( hCPE->element_mode == IVAS_CPE_DFT )
    {
#ifdef SIMPLIFY_IVAS_CORE
        stereo_dft_hybrid_ITD_flag( hConfigDft, input_Fs, hCPE->hStereoDft->hItd->hybrid_itd_max );
#else
        stereo_dft_hybrid_ITD_flag( hCPE->hStereoDft->hConfig, input_Fs, hCPE->hStereoDft->hItd->hybrid_itd_max );
#endif

        /* Time Domain ITD compensation using extrapolation */
#ifdef DEBUG_MODE_DFT
#ifdef SIMPLIFY_IVAS_CORE
        stereo_td_itd( hCPE->hStereoDft->hItd, hCPE->hStereoDft->input_mem_itd, hConfigDft->hybrid_itd_flag, hConfigDft->itd_mode, hCPE->hStereoDft->dft_ovl, sts, input_frame, hCPE->input_mem );
#else
        stereo_td_itd( hCPE->hStereoDft->hItd, hCPE->hStereoDft->input_mem_itd, hCPE->hStereoDft->hConfig->hybrid_itd_flag, hCPE->hStereoDft->hConfig->itd_mode, hCPE->hStereoDft->dft_ovl, sts, input_frame, hCPE->input_mem );
#endif
#else
#ifdef SIMPLIFY_IVAS_CORE
        stereo_td_itd( hCPE->hStereoDft->hItd, hCPE->hStereoDft->input_mem_itd, hConfigDft->hybrid_itd_flag, hCPE->hStereoDft->dft_ovl, sts, input_frame, hCPE->input_mem );
#else
        stereo_td_itd( hCPE->hStereoDft->hItd, hCPE->hStereoDft->input_mem_itd, hCPE->hStereoDft->hConfig->hybrid_itd_flag, hCPE->hStereoDft->dft_ovl, sts, input_frame, hCPE->input_mem );
#endif
#endif

        /* DFT on right and left input channels */
@@ -384,8 +422,13 @@ ivas_error ivas_cpe_enc(
#ifdef DEBUG_MODE_DFT
        hCPE->hStereoDft->res_cod_bits = (int16_t) ( ( hCPE->element_brate ) / FRAMES_PER_SEC - 0.8f * sts[0]->bits_frame_nominal );
#endif

        /* Update DFT Stereo memories */
#ifdef SIMPLIFY_IVAS_CORE
        stereo_dft_enc_update( hCPE->hStereoDft, max_bwidth );
#else
        stereo_dft_enc_update( hCPE->hStereoDft, sts[0]->max_bwidth );
#endif

        /* DFT stereo processing */
        stereo_dft_enc_process( hCPE, vad_flag_dtx, vad_hover_flag, input_frame );
@@ -393,9 +436,7 @@ ivas_error ivas_cpe_enc(
    else if ( hCPE->element_mode == IVAS_CPE_TD )
    {
        /* Determine the energy ratio between the 2 channels */
        tdm_ratio_idx = stereo_tdm_ener_analysis(
            ivas_format,
            hCPE, input_frame, &tdm_SM_or_LRTD_Pri, &tdm_ratio_idx_SM );
        tdm_ratio_idx = stereo_tdm_ener_analysis( ivas_format, hCPE, input_frame, &tdm_SM_or_LRTD_Pri, &tdm_ratio_idx_SM );

        /* Compute the downmix signal based on the ratio index */
        stereo_tdm_downmix( hCPE->hStereoTD, sts[0]->input, sts[1]->input, input_frame, tdm_ratio_idx, ( ( hCPE->hStereoTD->tdm_LRTD_flag == 0 ) ? tdm_SM_or_LRTD_Pri : 0 ), tdm_ratio_idx_SM );
@@ -478,7 +519,11 @@ ivas_error ivas_cpe_enc(
        error = pre_proc_front_ivas( NULL, hCPE, hCPE->element_brate, nb_bits_metadata, input_frame, n, old_inp_12k8[n], old_inp_16k[n],
                                     &ener[n], &relE[n], A[n], Aw[n], epsP[n], lsp_new[n], lsp_mid[n], &vad_hover_flag[n], &attack_flag[n],
                                     realBuffer[n], imagBuffer[n], old_wsp[n], pitch_fr[n], voicing_fr[n], &loc_harm[n], &cor_map_sum[n], &vad_flag_dtx[n], enerBuffer[n],
#ifdef SIMPLIFY_IVAS_CORE
                                     fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, ivas_format, st_ivas->hMCT != NULL, hEncoderConfig->last_ivas_total_brate, ivas_total_brate );
#else
                                     fft_buff[n], A[0], lsp_new[0], currFlatness[n], tdm_ratio_idx, fr_bands, Etot_LR, lf_E, localVAD_HE_SAD, band_energies_LR, 0, st_ivas->hSpar != NULL ? st_ivas->hSpar->front_vad_flag : 0, 0, 0, ivas_format, st_ivas->hMCT != NULL, st_ivas->hEncoderConfig->last_ivas_total_brate, ivas_total_brate );
#endif
        if ( error != IVAS_ERR_OK )
        {
            return error;
@@ -529,7 +574,11 @@ ivas_error ivas_cpe_enc(
        set_bw_stereo( hCPE );

        /* reconfiguration of MDCT stereo */
#ifdef SIMPLIFY_IVAS_CORE
        if ( sts[0]->bwidth != sts[0]->last_bwidth || ( ( hCPE->last_element_brate != hCPE->element_brate || hCPE->last_element_mode != hCPE->element_mode ) && sts[0]->bwidth != max_bwidth ) )
#else
        if ( sts[0]->bwidth != sts[0]->last_bwidth || ( ( hCPE->last_element_brate != hCPE->element_brate || hCPE->last_element_mode != hCPE->element_mode ) && sts[0]->bwidth != sts[0]->max_bwidth ) )
#endif
        {
            initMdctStereoEncData( hCPE->hStereoMdct, ivas_format, hCPE->element_mode, hCPE->element_brate, sts[0]->bwidth, 0, NULL, 0 );
            hCPE->hStereoMdct->isSBAStereoMode = ( ( ivas_format == SBA_FORMAT || ivas_format == SBA_ISM_FORMAT ) && ( st_ivas->nchan_transport == 2 ) );
@@ -552,9 +601,15 @@ ivas_error ivas_cpe_enc(
            int16_t igf;
            int16_t bw;

#ifdef SIMPLIFY_IVAS_CORE
            bw = ( hCPE->element_mode == IVAS_CPE_MDCT ) ? sts[n]->bwidth : max_bwidth;
            igf = getIgfPresent( sts[n]->element_mode, sts[n]->bits_frame_nominal * FRAMES_PER_SEC, bw, sts[n]->rf_mode );
            if ( ( error = IGF_Reconfig( &sts[n]->hIGFEnc, igf, 0, sts[n]->bits_frame_nominal * FRAMES_PER_SEC, max_bwidth, sts[n]->element_mode, sts[n]->rf_mode ) ) != IVAS_ERR_OK )
#else
            bw = ( hCPE->element_mode == IVAS_CPE_MDCT ) ? sts[n]->bwidth : sts[n]->max_bwidth;
            igf = getIgfPresent( sts[n]->element_mode, sts[n]->bits_frame_nominal * FRAMES_PER_SEC, bw, sts[n]->rf_mode );
            if ( ( error = IGF_Reconfig( &sts[n]->hIGFEnc, igf, 0, sts[n]->bits_frame_nominal * FRAMES_PER_SEC, sts[n]->max_bwidth, sts[n]->element_mode, sts[n]->rf_mode ) ) != IVAS_ERR_OK )
#endif
            {
                return error;
            }
@@ -621,11 +676,19 @@ ivas_error ivas_cpe_enc(
                /* Reconfigure DFT Stereo for inactive frames */
                if ( sts[0]->core_brate == SID_2k40 )
                {
#ifdef SIMPLIFY_IVAS_CORE
                    stereo_dft_config( hConfigDft, IVAS_SID_5k2, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
#else
                    stereo_dft_config( hCPE->hStereoDft->hConfig, IVAS_SID_5k2, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
#endif
                }
                else
                {
#ifdef SIMPLIFY_IVAS_CORE
                    stereo_dft_config( hConfigDft, FRAME_NO_DATA, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
#else
                    stereo_dft_config( hCPE->hStereoDft->hConfig, FRAME_NO_DATA, &sts[0]->bits_frame_nominal, &sts[1]->bits_frame_nominal );
#endif
                }

                stereo_dft_cng_side_gain( hCPE->hStereoDft, hCPE->hStereoCng, sts[0]->core_brate, sts[0]->last_core_brate, sts[0]->bwidth );
+4 −0
Original line number Diff line number Diff line
@@ -166,7 +166,11 @@ ivas_error ivas_sce_enc(

    /* set flag for sampling rate of OL S/M classifier */
    flag_16k_smc = 0;
#ifdef SIMPLIFY_IVAS_CORE
    if ( ivas_format == SBA_FORMAT && ( st_ivas->hEncoderConfig->ivas_total_brate == IVAS_24k4 || st_ivas->hEncoderConfig->ivas_total_brate == IVAS_32k ) && hSCE->element_brate == hSCE->last_element_brate )
#else
    if ( st_ivas->hEncoderConfig->ivas_format == SBA_FORMAT && ( st_ivas->hEncoderConfig->ivas_total_brate == IVAS_24k4 || st_ivas->hEncoderConfig->ivas_total_brate == IVAS_32k ) && hSCE->element_brate == hSCE->last_element_brate )
#endif
    {
        flag_16k_smc = 1;
    }