Commit c1eb8dbb authored by multrus's avatar multrus
Browse files

[cleanup] accept SBA_BR_SWITCHING_CLEAN_UP

parent 9e5e915b
Loading
Loading
Loading
Loading
+0 −28
Original line number Diff line number Diff line
@@ -175,10 +175,8 @@ ivas_error ivas_FB_mixer_open(
    IVAS_FB_MIXER_HANDLE *hFbMixer_out, /* i/o: FB mixer handle           */
    const int32_t sampling_rate,        /* i  : sampling rate             */
    IVAS_FB_CFG *fb_cfg                 /* i  : FB config. handle         */
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    ,
    const int16_t spar_reconfig_flag /* i  : SPAR reconfiguration flag */
#endif
)
{
    IVAS_FB_MIXER_HANDLE hFbMixer;
@@ -190,12 +188,10 @@ ivas_error ivas_FB_mixer_open(

    frame_len = (int16_t) ( sampling_rate / FRAMES_PER_SEC );

#ifdef SBA_BR_SWITCHING_CLEAN_UP
    hFbMixer = *hFbMixer_out;

    if ( !spar_reconfig_flag )
    {
#endif
        if ( ( hFbMixer = (IVAS_FB_MIXER_HANDLE) malloc( sizeof( IVAS_FB_MIXER_DATA ) ) ) == NULL )
        {
            return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" );
@@ -212,9 +208,7 @@ ivas_error ivas_FB_mixer_open(
        {
            hFbMixer->pFb = NULL;
        }
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    }
#endif

    if ( fb_cfg->active_w_mixing == -1 )
    {
@@ -289,10 +283,8 @@ ivas_error ivas_FB_mixer_open(
        }
    }

#ifdef SBA_BR_SWITCHING_CLEAN_UP
    if ( !spar_reconfig_flag )
    {
#endif
        if ( fb_cfg->num_out_chans > 0 )
        {
            const int16_t *pActive_bins_per_band, *pActive_bins_per_band_abs, *pStart_offset, *pStart_offset_abs;
@@ -341,25 +333,19 @@ ivas_error ivas_FB_mixer_open(
            /* ignore all the deeper filter bank stuff for now */
            hFbMixer->num_diff_bands = 0;
        }
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    }
#endif

    hFbMixer->fb_cfg = fb_cfg;
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    set_s( hFbMixer->first_frame, 1, hFbMixer->fb_cfg->num_out_chans );
    set_s( hFbMixer->first_frame + hFbMixer->fb_cfg->num_out_chans, 0, IVAS_SPAR_MAX_CH - hFbMixer->fb_cfg->num_out_chans );

    if ( !spar_reconfig_flag )
    {
#endif
        if ( ( error = ivas_filterbank_setup( hFbMixer, sampling_rate ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    }
#endif

    *hFbMixer_out = hFbMixer;

@@ -376,10 +362,8 @@ ivas_error ivas_FB_mixer_open(
void ivas_FB_mixer_close(
    IVAS_FB_MIXER_HANDLE *hFbMixer_in, /* i/o: FB mixer handle              */
    const int32_t sampling_rate        /* i  : sampling rate in Hz          */
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    ,
    const int16_t spar_reconfig_flag /* i  : SPAR reconfiguration flag    */
#endif
)
{
    IVAS_FB_MIXER_HANDLE hFbMixer;
@@ -439,10 +423,8 @@ void ivas_FB_mixer_close(
            hFbMixer->prior_mixer[0][0] = NULL;
        }

#ifdef SBA_BR_SWITCHING_CLEAN_UP
        if ( !spar_reconfig_flag )
        {
#endif
            if ( fb_cfg->num_out_chans > 0 )
            {
                num_bands = hFbMixer->pFb->filterbank_num_bands;
@@ -476,9 +458,7 @@ void ivas_FB_mixer_close(
                free( hFbMixer->pFb );
                hFbMixer->pFb = NULL;
            }
#ifdef SBA_BR_SWITCHING_CLEAN_UP
        }
#endif

        if ( hFbMixer->fb_cfg != NULL )
        {
@@ -486,15 +466,11 @@ void ivas_FB_mixer_close(
            hFbMixer->fb_cfg = NULL;
        }

#ifdef SBA_BR_SWITCHING_CLEAN_UP
        if ( !spar_reconfig_flag )
        {
#endif
            free( hFbMixer );
            hFbMixer = NULL;
#ifdef SBA_BR_SWITCHING_CLEAN_UP
        }
#endif
    }

    return;
@@ -1074,10 +1050,6 @@ static ivas_error ivas_filterbank_setup(
    IVAS_FB_CFG *pCfg = hFbMixer->fb_cfg;

    error = IVAS_ERR_OK;
#ifndef SBA_BR_SWITCHING_CLEAN_UP
    set_s( hFbMixer->first_frame, 1, pCfg->num_out_chans );
    set_s( hFbMixer->first_frame + pCfg->num_out_chans, 0, IVAS_SPAR_MAX_CH - pCfg->num_out_chans );
#endif

    if ( pCfg->num_out_chans > 0 )
    {
+0 −12
Original line number Diff line number Diff line
@@ -3751,18 +3751,14 @@ void FdCngDecodeDiracMDCTStereoSID(

ivas_error ivas_spar_enc_open(
    Encoder_Struct *st_ivas                                     /* i/o: IVAS encoder handle                     */
#ifdef SBA_BR_SWITCHING_CLEAN_UP
   ,const int16_t spar_reconfig_flag                            /* i  : SPAR reconfiguration flag               */
#endif
);

void ivas_spar_enc_close(
    SPAR_ENC_HANDLE hSpar,                                      /* i/o: SPAR encoder handle                     */
    const int32_t input_Fs,                                     /* i  : input sampling rate                     */
    const int16_t nchan_inp                                     /* i  : number of input channels                */
#ifdef SBA_BR_SWITCHING_CLEAN_UP
   ,const int16_t spar_reconfig_flag                            /* i  : SPAR reconfiguration flag               */
#endif
);

ivas_error ivas_spar_enc(
@@ -3775,19 +3771,15 @@ ivas_error ivas_spar_enc(

ivas_error ivas_spar_dec_open(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder handle                     */
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    ,
    const int16_t spar_reconfig_flag                            /* i  : SPAR reconfiguration flag               */
#endif
);

void ivas_spar_dec_close(
    SPAR_DEC_HANDLE hSpar,                                      /* i/o: SPAR decoder handle                     */
    const int32_t output_Fs                                     /* i  : output sampling rate                    */
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    ,
    const int16_t spar_reconfig_flag                            /* i  : SPAR reconfiguration flag               */
#endif
);

ivas_error ivas_spar_dec(
@@ -4972,19 +4964,15 @@ ivas_error ivas_FB_mixer_open(
    IVAS_FB_MIXER_HANDLE *hFbMixer,                             /* i/o: FB mixer handle                             */
    const int32_t sampling_rate,                                /* i  : sampling rate                               */
    IVAS_FB_CFG *fb_cfg                                         /* i  : FB config. handle                           */
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    ,
    const int16_t spar_reconfig_flag                            /* i  : SPAR reconfiguration flag                   */
#endif
);

void ivas_FB_mixer_close( 
    IVAS_FB_MIXER_HANDLE *hFbMixer,                             /* i/o: FB mixer handle                             */
    const int32_t sampling_rate                                 /* i  : sampling rate in Hz                         */
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    ,
    const int16_t spar_reconfig_flag                            /* i  : SPAR reconfiguration flag                   */
#endif
);

void ivas_fb_mixer_pcm_ingest( 
+0 −1
Original line number Diff line number Diff line
@@ -141,7 +141,6 @@
#define DISABLE_ADAP_RES_COD_TMP                        /* temporary fix for IVAS-403, disables adaptive residual coding */
/*#define ITD_WINNER_GAIN_MODIFY */                     /* ITD optimization - WORK IN PROGRESS */
/*#define FIX_I4_OL_PITCH*/                             /* fix open-loop pitch used for EVS core switching */
#define SBA_BR_SWITCHING_CLEAN_UP                       /*Issue 114: Clean up changes for the SBA reconfiguation functions*/
#define LOW_RATE_TRANS_CORE_CODER                       /* Eri: Activate low-rate-encoding-of-transients contribution for core coder, affects MC, MASA and SBA */
#define FIX_197_CREND_INTERFACE
#define FIX_329_ENABLE_TD_RENDERER_REVERB_MC            /* Eri: Enable reverb for TD renderer for 5.1 and 7.1 with headtracking enabled for IVAS_dec */
+0 −8
Original line number Diff line number Diff line
@@ -863,11 +863,7 @@ ivas_error ivas_init_decoder(
        {
            if ( st_ivas->sba_mode == SBA_MODE_SPAR )
            {
#ifdef SBA_BR_SWITCHING_CLEAN_UP
                if ( ( error = ivas_spar_dec_open( st_ivas, 0 ) ) != IVAS_ERR_OK )
#else
                if ( ( error = ivas_spar_dec_open( st_ivas ) ) != IVAS_ERR_OK )
#endif
                {
                    return error;
                }
@@ -1727,11 +1723,7 @@ void ivas_destroy_dec(
    /* Spar handle */
    if ( st_ivas->hSpar != NULL )
    {
#ifdef SBA_BR_SWITCHING_CLEAN_UP
        ivas_spar_dec_close( st_ivas->hSpar, st_ivas->hDecoderConfig->output_Fs, 0 );
#else
        ivas_spar_dec_close( st_ivas->hSpar, st_ivas->hDecoderConfig->output_Fs );
#endif
        st_ivas->hSpar = NULL;
    }

+0 −150
Original line number Diff line number Diff line
@@ -65,9 +65,7 @@ ivas_error ivas_sba_dec_reconfigure(
    RENDERER_TYPE old_renderer_type;
    DECODER_CONFIG_HANDLE hDecoderConfig;
    ivas_error error;
#ifdef SBA_BR_SWITCHING_CLEAN_UP
    int16_t band_grouping[IVAS_MAX_NUM_BANDS + 1];
#endif

    error = IVAS_ERR_OK;

@@ -112,11 +110,7 @@ ivas_error ivas_sba_dec_reconfigure(

    if ( st_ivas->sba_mode != SBA_MODE_SPAR )
    {
#ifndef SBA_BR_SWITCHING_CLEAN_UP
        ivas_spar_dec_close( st_ivas->hSpar, hDecoderConfig->output_Fs );
#else
        ivas_spar_dec_close( st_ivas->hSpar, hDecoderConfig->output_Fs, 0 );
#endif
        st_ivas->hSpar = NULL;

        if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, st_ivas->sba_mode, -1 ) ) != IVAS_ERR_OK )
@@ -128,78 +122,11 @@ ivas_error ivas_sba_dec_reconfigure(
    }
    else
    {
#ifdef SBA_BR_SWITCHING_CLEAN_UP
        int16_t sba_order_internal;
#else
        int16_t i, sba_order_internal, nchan_internal;
        DIRAC_DEC_HANDLE hDirAC = st_ivas->hDirAC;
#endif
        SPAR_DEC_HANDLE hSpar = st_ivas->hSpar;

        sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER );

#ifndef SBA_BR_SWITCHING_CLEAN_UP
        nchan_internal = ivas_sba_get_nchan_metadata( sba_order_internal );
        if ( hSpar != NULL && nchan_transport_old != ivas_get_sba_num_TCs( ivas_total_brate, sba_order_internal ) )
        {
            // VE: dirty patch -> reconfiguration of SPAR modules should be used instead !!
            IVAS_FB_CFG *fb_cfg;
            int16_t active_w_mixing;

            /* MD handle */
            ivas_spar_md_dec_close( &hSpar->hMdDec );

            if ( ( error = ivas_spar_md_dec_open( &hSpar->hMdDec, st_ivas->hDecoderConfig, nchan_internal, sba_order_internal, st_ivas->sid_format ) ) != IVAS_ERR_OK )
            {
                return error;
            }
            hSpar->hMdDec->td_decorr_flag = 1;
            hSpar->hMdDec->table_idx = -1;

            /* TD decorr. */
            ivas_td_decorr_dec_close( &hSpar->hTdDecorr );

            if ( ( error = ivas_td_decorr_dec_open( &hSpar->hTdDecorr, hDecoderConfig->output_Fs, nchan_internal, 1 ) ) != IVAS_ERR_OK )
            {
                return error;
            }

            /* FB mixer handle */
            ivas_FB_mixer_close( &hSpar->hFbMixer, hDecoderConfig->output_Fs );

            /* set FB config. */
            active_w_mixing = -1;
            if ( ( error = ivas_fb_set_cfg( &fb_cfg, SBA_FORMAT, SBA_MODE_SPAR, nchan_internal, nchan_internal, active_w_mixing, hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK )
            {
                return error;
            }
            fb_cfg->pcm_offset = NS2SA( hDecoderConfig->output_Fs, DELAY_FB_1_NS + IVAS_ENC_DELAY_NS + IVAS_DEC_DELAY_NS );
            fb_cfg->remix_order = remix_order_set[hSpar->hMdDec->spar_md_cfg.remix_unmix_order];

            /* FB mixer handle */
            if ( ( error = ivas_FB_mixer_open( &hSpar->hFbMixer, hDecoderConfig->output_Fs, fb_cfg ) ) != IVAS_ERR_OK )
            {
                return error;
            }

            /* mixer_mat intitialization */
            for ( i = 0; i < nchan_internal; i++ )
            {
                for ( int16_t j = 0; j < nchan_internal; j++ )
                {
                    for ( int16_t b = 0; b < IVAS_MAX_NUM_BANDS; b++ )
                    {
                        hSpar->hMdDec->mixer_mat[i][j][b] = 0.0f;
                        for ( int16_t i_ts = 0; i_ts < ( MAX_PARAM_SPATIAL_SUBFRAMES + 1 ); i_ts++ )
                        {
                            hSpar->hMdDec->mixer_mat_prev[i_ts][i][j][b] = 0.0f;
                        }
                    }
                }
            }
            hSpar->i_subframe = 0;
        }
#else
        if ( hSpar != NULL )
        {
            if ( ( hSpar->hPCA != NULL ) && ( ( hDecoderConfig->ivas_total_brate != PCA_BRATE ) || ( sba_order_internal != 1 ) ) )
@@ -230,61 +157,6 @@ ivas_error ivas_sba_dec_reconfigure(

        hSpar = st_ivas->hSpar;
        st_ivas->sba_dirac_stereo_flag = 0;
#endif
#ifndef SBA_BR_SWITCHING_CLEAN_UP
        /* PCA handle */
        if ( hSpar != NULL )
        {
            if ( hDecoderConfig->ivas_total_brate == PCA_BRATE && sba_order_internal == 1 )
            {
                if ( ( hSpar->hPCA = (PCA_DEC_STATE *) malloc( sizeof( PCA_DEC_STATE ) ) ) == NULL )
                {
                    return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for PCA decoder" );
                }

                ivas_pca_dec_init( hSpar->hPCA );
            }
            else if ( hSpar->hPCA != NULL )
            {
                free( st_ivas->hSpar->hPCA );
                hSpar->hPCA = NULL;
            }
        }

        if ( hSpar == NULL && st_ivas->sba_mode == SBA_MODE_SPAR )
        {
            if ( ( error = ivas_spar_dec_open( st_ivas ) ) != IVAS_ERR_OK )
            {
                return error;
            }

            hSpar = st_ivas->hSpar;
        }
        st_ivas->sba_dirac_stereo_flag = 0;

        sba_order_internal = min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER );
        ivas_spar_config( ivas_total_brate, sba_order_internal, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, st_ivas->sid_format );

        if ( hDirAC == NULL && st_ivas->sba_mode == SBA_MODE_DIRAC )
        {
            if ( ( error = ivas_dirac_dec_open( st_ivas ) ) != IVAS_ERR_OK )
            {
                return error;
            }

            hDirAC = st_ivas->hDirAC;
        }

        if ( hDirAC != NULL && sba_mode_old == st_ivas->sba_mode )
        {
            ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE_MODE );
        }

        if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, st_ivas->sba_mode, IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#endif
    }

    if ( st_ivas->nchan_transport == 1 )
@@ -351,7 +223,6 @@ ivas_error ivas_sba_dec_reconfigure(
        ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin );
    }

#ifdef SBA_BR_SWITCHING_CLEAN_UP
    if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( sba_mode_old != st_ivas->sba_mode ) || ( ( st_ivas->sba_mode == SBA_MODE_SPAR ) && ( ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_STEREO ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_MONO ) ) ) )
    {
        DIRAC_CONFIG_FLAG flag_config;
@@ -393,27 +264,6 @@ ivas_error ivas_sba_dec_reconfigure(
        ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ),
                                 st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 );
    }
#else
    if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( sba_mode_old != st_ivas->sba_mode ) )
    {
        DIRAC_CONFIG_FLAG flag_config;

        flag_config = DIRAC_OPEN;
        if ( st_ivas->hDirAC != NULL )
        {
            flag_config = DIRAC_RECONFIGURE;
            if ( sba_mode_old != st_ivas->sba_mode && st_ivas->sba_mode != SBA_MODE_SPAR )
            {
                flag_config = DIRAC_RECONFIGURE_MODE;
            }
        }

        if ( ( error = ivas_dirac_dec_config( st_ivas, flag_config ) ) != IVAS_ERR_OK )
        {
            return error;
        }
    }
#endif

    else if ( st_ivas->renderer_type == RENDERER_DISABLE || ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC && st_ivas->sba_mode != SBA_MODE_SPAR ) )
    {
Loading