Commit f7099de6 authored by Brown, Stefanie's avatar Brown, Stefanie
Browse files

LBR SBA Bitrate switching clean up.

parent 2cbb8a59
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -174,6 +174,7 @@

#define LBR_SBA                                         /* Contribution 47: Master macro for low bitrate SBA (SPAR+DirAC) */
#ifdef LBR_SBA
#define LBR_SBA_BR_SWITCHING                            /* Clean up changes for SBA bitrate switching */
#define LBR_SBA_DM_COV_FIX                              /* Covariance smoothing and resetting fixes proposed at higher bitrates */
#ifdef LBR_SBA_DM_COV_FIX
#define LBR_SBA_EXTRA_COV_SMOOTH						/* Extra covariance smoothing for low bitrate SBA */
+32 −10
Original line number Diff line number Diff line
@@ -110,25 +110,29 @@ ivas_error ivas_sba_dec_reconfigure(
    AUDIO_CONFIG intern_config_old;
    int16_t numCldfbAnalyses_old, numCldfbSyntheses_old;
    int16_t sba_dirac_stereo_flag_old;
#ifndef LBR_SBA_BR_SWITCHING
    SBA_MODE sba_mode_old;
#endif
    int32_t ivas_total_brate, last_ivas_total_brate;
    RENDERER_TYPE old_renderer_type;
    DECODER_CONFIG_HANDLE hDecoderConfig;
    ivas_error error;
#ifndef LBR_SBA_BR_SWITCHING
    int16_t band_grouping[IVAS_MAX_NUM_BANDS + 1];

#endif
    error = IVAS_ERR_OK;

    hDecoderConfig = st_ivas->hDecoderConfig;
    ivas_total_brate = hDecoderConfig->ivas_total_brate;
    last_ivas_total_brate = st_ivas->last_active_ivas_total_brate;
#ifndef LBR_SBA_BR_SWITCHING
#ifndef LBR_SBA
    sba_mode_old = ivas_sba_mode_select( last_ivas_total_brate );
#else
    sba_mode_old = ivas_sba_mode_select( );
#endif
    st_ivas->sba_mode = sba_mode_old;

#endif
    /*-----------------------------------------------------------------*
     * Set SBA high-level parameters
     * Save old SBA high-level parameters
@@ -155,16 +159,17 @@ ivas_error ivas_sba_dec_reconfigure(
    sba_dirac_stereo_flag_old = st_ivas->sba_dirac_stereo_flag;

    st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order );
#ifndef LBR_SBA_BR_SWITCHING
#ifndef LBR_SBA
    st_ivas->sba_mode = ivas_sba_mode_select( ivas_total_brate );
#else
    st_ivas->sba_mode = ivas_sba_mode_select( );
#endif

#endif
    /*-----------------------------------------------------------------*
     * Allocate, initialize, and configure SBA handles
     *-----------------------------------------------------------------*/

#ifndef LBR_SBA_BR_SWITCHING
    if ( st_ivas->sba_mode != SBA_MODE_SPAR )
    {
        ivas_spar_dec_close( &( st_ivas->hSpar ), hDecoderConfig->output_Fs, 0 );
@@ -182,6 +187,7 @@ ivas_error ivas_sba_dec_reconfigure(
    }
    else
    {
#endif
        int16_t sba_order_internal;
        SPAR_DEC_HANDLE hSpar = st_ivas->hSpar;

@@ -222,8 +228,9 @@ ivas_error ivas_sba_dec_reconfigure(
#else
        st_ivas->sba_dirac_stereo_flag = 0;
#endif
#ifndef LBR_SBA_BR_SWITCHING
    }

#endif
    if ( st_ivas->nchan_transport == 1 )
    {
        st_ivas->element_mode_init = IVAS_SCE;
@@ -287,8 +294,11 @@ ivas_error ivas_sba_dec_reconfigure(
    {
        ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin );
    }

#ifndef LBR_SBA_BR_SWITCHING
    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 ) ) ) )
#else
    if ( ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC ) ) || ( ( hDecoderConfig->output_config != AUDIO_CONFIG_FOA ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_STEREO ) && ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_MONO ) ) )
#endif
    {
        DIRAC_CONFIG_FLAG flag_config;

@@ -296,10 +306,12 @@ ivas_error ivas_sba_dec_reconfigure(
        if ( st_ivas->hDirAC != NULL )
        {
            flag_config = DIRAC_RECONFIGURE_MODE;
#ifndef LBR_SBA_BR_SWITCHING
            if ( ( sba_mode_old == st_ivas->sba_mode ) && ( st_ivas->sba_mode != SBA_MODE_SPAR ) )
            {
                flag_config = DIRAC_RECONFIGURE;
            }
#endif
        }

        if ( ( error = ivas_dirac_dec_config( st_ivas, flag_config ) ) != IVAS_ERR_OK )
@@ -307,15 +319,18 @@ ivas_error ivas_sba_dec_reconfigure(
            return error;
        }
    }

#ifndef LBR_SBA_BR_SWITCHING
    if ( st_ivas->sba_mode == SBA_MODE_SPAR )
    {
#endif
        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;
        }
#ifndef LBR_SBA_BR_SWITCHING
    }

#endif
#ifndef LBR_SBA_BR_SWITCHING
    if ( ( ( hDecoderConfig->output_config == AUDIO_CONFIG_FOA ) || ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_STEREO ) || ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_MONO ) ) && ( ( sba_mode_old != st_ivas->sba_mode ) && ( st_ivas->sba_mode == SBA_MODE_SPAR ) ) )
    {
        ivas_dirac_dec_close( &( st_ivas->hDirAC ) );
@@ -325,15 +340,22 @@ 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 );
    }

#endif
#ifndef LBR_SBA_BR_SWITCHING
    else if ( st_ivas->renderer_type == RENDERER_DISABLE || ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC && st_ivas->sba_mode != SBA_MODE_SPAR ) )
#else
    if ( st_ivas->renderer_type == RENDERER_DISABLE )
#endif
    {
        ivas_dirac_dec_close( &( st_ivas->hDirAC ) );

        vbap_free_data( &( st_ivas->hVBAPdata ) );
    }

#ifndef LBR_SBA_BR_SWITCHING
    if ( st_ivas->hDirAC != NULL && st_ivas->sba_mode == SBA_MODE_SPAR )
#else
    if ( st_ivas->hDirAC != NULL )
#endif
    {
        mvs2s( st_ivas->hDirAC->dirac_to_spar_md_bands, st_ivas->hSpar->dirac_to_spar_md_bands, DIRAC_MAX_NBANDS );
        st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band;
+3 −1
Original line number Diff line number Diff line
@@ -339,7 +339,9 @@ ivas_error ivas_init_encoder(
        /* In IVAS, ensure that minimum coded bandwidth is WB */
        hEncoderConfig->max_bwidth = max( hEncoderConfig->max_bwidth, WB );
    }

#ifdef LBR_SBA_BR_SWITCHING
    hEncoderConfig->spar_reconfig_flag = 0;
#endif
    st_ivas->ism_mode = ISM_MODE_NONE;
    st_ivas->mc_mode = MC_MODE_NONE;
    st_ivas->sba_mode = SBA_MODE_NONE;
+27 −9
Original line number Diff line number Diff line
@@ -119,7 +119,9 @@ ivas_error ivas_sba_enc_reconfigure(
    {
        DIRAC_ENC_HANDLE hDirAC = st_ivas->hDirAC;
        SPAR_ENC_HANDLE hSpar;
#ifndef LBR_SBA_BR_SWITCHING
        SBA_MODE sba_mode_old;
#endif
        int16_t analysis_order_old;
        int16_t spar_reconfig_flag;

@@ -127,13 +129,16 @@ ivas_error ivas_sba_enc_reconfigure(
        nchan_transport_old = st_ivas->nchan_transport;
        nCPE_old = st_ivas->nCPE;
        nSCE_old = st_ivas->nSCE;
#ifndef LBR_SBA_BR_SWITCHING
        sba_mode_old = st_ivas->sba_mode;

#endif
        st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, hEncoderConfig->sba_order );
#ifndef LBR_SBA_BR_SWITCHING
#ifndef LBR_SBA
        st_ivas->sba_mode = ivas_sba_mode_select( ivas_total_brate );
#else
        st_ivas->sba_mode = ivas_sba_mode_select();
#endif
#endif
        analysis_order_old = ivas_sba_get_analysis_order( hEncoderConfig->last_ivas_total_brate, hEncoderConfig->sba_order );

@@ -202,7 +207,7 @@ ivas_error ivas_sba_enc_reconfigure(
                old_mem_hp20_in = NULL;
            }
        }

#ifndef LBR_SBA_BR_SWITCHING
        if ( st_ivas->sba_mode == SBA_MODE_SPAR )
        {
            if ( st_ivas->hSpar == NULL )
@@ -212,7 +217,7 @@ ivas_error ivas_sba_enc_reconfigure(
                    return error;
                }
            }

#endif
            ivas_spar_config( ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ),
                              &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, -1 );

@@ -225,12 +230,13 @@ ivas_error ivas_sba_enc_reconfigure(
                }
            }
            hDirAC->num_samples_synchro_delay = 0;
#ifndef LBR_SBA_BR_SWITCHING
        }
        else
        {
            ivas_spar_enc_close( &( st_ivas->hSpar ), hEncoderConfig->input_Fs, hEncoderConfig->nchan_inp, spar_reconfig_flag );
        }

#endif
        hSpar = st_ivas->hSpar;

        if ( st_ivas->nchan_transport == 1 )
@@ -241,20 +247,26 @@ ivas_error ivas_sba_enc_reconfigure(
        {
            hEncoderConfig->element_mode_init = IVAS_CPE_MDCT;
        }

#ifndef LBR_SBA_BR_SWITCHING
        if ( ( sba_mode_old != st_ivas->sba_mode ) || ( nchan_transport_old != st_ivas->nchan_transport ) )
#else
        if ( nchan_transport_old != st_ivas->nchan_transport )
#endif
        {
            /* FB mixer handle */
#ifndef LBR_SBA_BR_SWITCHING
            if ( st_ivas->sba_mode == SBA_MODE_SPAR )
            {
#endif
                if ( hDirAC->hFbMixer != NULL )
                {
                    ivas_FB_mixer_close( &( hDirAC->hFbMixer ), hEncoderConfig->input_Fs, 0 );
                    hDirAC->hFbMixer = NULL;
                }

#ifndef LBR_SBA_BR_SWITCHING
                if ( sba_mode_old == SBA_MODE_SPAR )
                {
#endif
                    spar_reconfig_flag = 1;
                    ivas_spar_enc_close( &( st_ivas->hSpar ), hEncoderConfig->input_Fs, hEncoderConfig->nchan_inp, spar_reconfig_flag );

@@ -262,6 +274,7 @@ ivas_error ivas_sba_enc_reconfigure(
                    {
                        return error;
                    }
#ifndef LBR_SBA_BR_SWITCHING
                }
            }
            else
@@ -300,19 +313,24 @@ ivas_error ivas_sba_enc_reconfigure(
                    }
                }
            }
#endif
        }

#ifdef LBR_SBA_BR_SWITCHING
        hEncoderConfig->spar_reconfig_flag = spar_reconfig_flag;
#endif
        if ( ( error = ivas_dirac_enc_reconfigure( st_ivas ) ) != IVAS_ERR_OK )
        {
            return error;
        }

#ifndef LBR_SBA_BR_SWITCHING
        if ( st_ivas->sba_mode == SBA_MODE_SPAR )
        {
#endif
            mvs2s( hDirAC->dirac_to_spar_md_bands, hSpar->dirac_to_spar_md_bands, DIRAC_MAX_NBANDS );
            hSpar->enc_param_start_band = hDirAC->hConfig->enc_param_start_band;
#ifndef LBR_SBA_BR_SWITCHING
        }

#endif
        /*-----------------------------------------------------------------*
         * Allocate, initialize, and configure SCE/CPE/MCT handles
         *-----------------------------------------------------------------*/
+4 −0
Original line number Diff line number Diff line
@@ -613,7 +613,11 @@ static ivas_error ivas_spar_enc_process(
    if ( hSpar->hMdEnc->table_idx != table_idx )
    {
        hSpar->hMdEnc->table_idx = table_idx;
#ifdef LBR_SBA_BR_SWITCHING
        if ( ( ivas_total_brate != hEncoderConfig->last_ivas_total_brate ) && ( !hEncoderConfig->spar_reconfig_flag ) )
#else
        if ( ivas_total_brate != hEncoderConfig->last_ivas_total_brate )
#endif
        {
            if ( ( error = ivas_spar_md_enc_init( hSpar->hMdEnc, hEncoderConfig, sba_order ) ) != IVAS_ERR_OK )
            {
Loading