Commit a42390a7 authored by vaclav's avatar vaclav
Browse files

simplify dereferencing + comments

parent f7433f79
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3526,7 +3526,7 @@ int16_t ivas_sba_spar_sid_bitlen(
void ivas_sba_get_spar_hoa_ch_ind(
    const int16_t num_md_chs,                                   /* i  : number of MD channels                   */
    const int32_t ivas_total_brate,                             /* i  : IVAS total bitrate                      */
    int16_t HOA_md_ind[IVAS_SPAR_MAX_CH]
    int16_t HOA_md_ind[IVAS_SPAR_MAX_CH]                        /* o  : channel indexes                         */
);

/*! r: flag indicating to code SPAR HOA MD for all bands */
+4 −4
Original line number Diff line number Diff line
@@ -226,11 +226,11 @@ int16_t ivas_sba_get_nchan_metadata(
 *
 *-------------------------------------------------------------------*/

/*! r: flag indicating to code SPAR HOA MD for all bands  */
void ivas_sba_get_spar_hoa_ch_ind(
    const int16_t num_md_chs,            /* i  : number of MD channels      */
    const int32_t ivas_total_brate,      /* i  : IVAS total bitrate         */
    int16_t HOA_md_ind[IVAS_SPAR_MAX_CH] )
    int16_t HOA_md_ind[IVAS_SPAR_MAX_CH] /* o  : channel indexes            */
)
{
    int16_t ch;
    const int16_t *hoa_ind;
+111 −98

File changed.

Preview size limit exceeded, changes collapsed.

+43 −44
Original line number Diff line number Diff line
@@ -117,6 +117,7 @@ ivas_error ivas_sba_dec_reconfigure(
{
    int16_t nchan_transport_old, nSCE_old, nCPE_old, nchan_hp20_old;
    AUDIO_CONFIG intern_config_old;
    int16_t sba_order_internal;
    int16_t numCldfbAnalyses_old, numCldfbSyntheses_old;
    int16_t sba_dirac_stereo_flag_old;
    int32_t ivas_total_brate;
@@ -128,10 +129,14 @@ ivas_error ivas_sba_dec_reconfigure(
    ivas_error error;
    ISM_MODE ism_mode_old;
    int16_t granularity_new;
    DECODER_TC_BUFFER_HANDLE hTcBuffer;
    SPAR_DEC_HANDLE hSpar;
#ifdef NONBE_FIX_ISM_XOVER_BR
    int16_t nchan_transport;
#endif

    hTcBuffer = st_ivas->hTcBuffer;
    hSpar = st_ivas->hSpar;
    ism_mode_old = st_ivas->ism_mode;
    hDecoderConfig = st_ivas->hDecoderConfig;
    ivas_total_brate = hDecoderConfig->ivas_total_brate;
@@ -176,13 +181,12 @@ ivas_error ivas_sba_dec_reconfigure(
    st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order );

    *nSamplesFlushed = 0;
    granularity_new = st_ivas->hTcBuffer->n_samples_granularity;
    granularity_new = hTcBuffer->n_samples_granularity;

    /* we may need to flush only for binaural and OSBA and TSM */
    if ( st_ivas->ivas_format == SBA_ISM_FORMAT && ( st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
    {
        RENDERER_TYPE renderer_type_new;
        int16_t sba_order_internal;

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

@@ -229,7 +233,7 @@ ivas_error ivas_sba_dec_reconfigure(
        }

        /* flush renderer on granularity change form 5ms to 1.25ms, again only possible for binaural rendering */
        if ( granularity_new < st_ivas->hTcBuffer->n_samples_granularity )
        if ( granularity_new < hTcBuffer->n_samples_granularity )
        {
            /* write back info for correct rendering of the flushable samples */
            st_ivas->sba_analysis_order = sba_analysis_order_old_flush;
@@ -248,7 +252,7 @@ ivas_error ivas_sba_dec_reconfigure(
            st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order );
            st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate;
        }
        else if ( granularity_new > st_ivas->hTcBuffer->n_samples_granularity )
        else if ( granularity_new > hTcBuffer->n_samples_granularity )
        {
            if ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK )
            {
@@ -258,30 +262,30 @@ ivas_error ivas_sba_dec_reconfigure(
            /* make sure the changed number of slots in the last subframe is not lost in the following steps */
            if ( st_ivas->hSpatParamRendCom != NULL )
            {
                st_ivas->hSpatParamRendCom->subframe_nbslots[st_ivas->hSpatParamRendCom->nb_subframes - 1] = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1];
                st_ivas->hSpatParamRendCom->subframe_nbslots[st_ivas->hSpatParamRendCom->nb_subframes - 1] = hTcBuffer->subframe_nbslots[hTcBuffer->nb_subframes - 1];
            }
            st_ivas->hSpar->subframe_nbslots[st_ivas->hSpar->nb_subframes - 1] = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1];
            hSpar->subframe_nbslots[hSpar->nb_subframes - 1] = hTcBuffer->subframe_nbslots[hTcBuffer->nb_subframes - 1];
        }
    }

    /* save old */
    if ( ism_mode_old != ISM_SBA_MODE_DISC && st_ivas->hTcBuffer->tc_buffer_mode != TC_BUFFER_MODE_BUFFER )
    if ( ism_mode_old != ISM_SBA_MODE_DISC && hTcBuffer->tc_buffer_mode != TC_BUFFER_MODE_BUFFER )
    {
        if ( st_ivas->hDirAC == NULL && st_ivas->hSpar != NULL )
        if ( st_ivas->hDirAC == NULL && hSpar != NULL )
        {
            st_ivas->hTcBuffer->num_slots = st_ivas->hSpar->num_slots;
            st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpar->nb_subframes;
            st_ivas->hTcBuffer->slots_rendered = st_ivas->hSpar->slots_rendered;
            st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpar->subframes_rendered;
            mvs2s( st_ivas->hSpar->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
            hTcBuffer->num_slots = hSpar->num_slots;
            hTcBuffer->nb_subframes = hSpar->nb_subframes;
            hTcBuffer->slots_rendered = hSpar->slots_rendered;
            hTcBuffer->subframes_rendered = hSpar->subframes_rendered;
            mvs2s( hSpar->subframe_nbslots, hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
        }
        else if ( st_ivas->hSpatParamRendCom != NULL )
        {
            st_ivas->hTcBuffer->num_slots = st_ivas->hSpatParamRendCom->num_slots;
            st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpatParamRendCom->nb_subframes;
            st_ivas->hTcBuffer->slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered;
            st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered;
            mvs2s( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
            hTcBuffer->num_slots = st_ivas->hSpatParamRendCom->num_slots;
            hTcBuffer->nb_subframes = st_ivas->hSpatParamRendCom->nb_subframes;
            hTcBuffer->slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered;
            hTcBuffer->subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered;
            mvs2s( st_ivas->hSpatParamRendCom->subframe_nbslots, hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
        }
    }

@@ -289,23 +293,19 @@ ivas_error ivas_sba_dec_reconfigure(
     * Allocate, initialize, and configure SBA handles
     *-----------------------------------------------------------------*/

    int16_t sba_order_internal;
    SPAR_DEC_HANDLE hSpar;
    hSpar = st_ivas->hSpar;

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

    if ( hSpar != NULL )
    {
        if ( ( hSpar->hPCA != NULL ) && ( ( hDecoderConfig->ivas_total_brate != PCA_BRATE ) || ( st_ivas->sba_order != 1 ) ) )
        {
            free( st_ivas->hSpar->hPCA );
            free( hSpar->hPCA );
            hSpar->hPCA = NULL;
        }

        if ( nchan_transport_old != ivas_get_sba_num_TCs( ivas_total_brate, sba_order_internal ) || ( last_ivas_total_brate >= IVAS_512k && ivas_total_brate < IVAS_512k ) || ( last_ivas_total_brate < IVAS_512k && ivas_total_brate >= IVAS_512k ) )
        {
            ivas_spar_dec_close( &( st_ivas->hSpar ), hDecoderConfig->output_Fs, 1 );
            ivas_spar_dec_close( &hSpar, hDecoderConfig->output_Fs, 1 );

            if ( ( error = ivas_spar_dec_open( st_ivas, 1 ) ) != IVAS_ERR_OK )
            {
@@ -314,11 +314,11 @@ ivas_error ivas_sba_dec_reconfigure(
        }
        else if ( last_ivas_total_brate < IVAS_24k4 && ivas_total_brate >= IVAS_24k4 )
        {
            num_channels = st_ivas->hSpar->hMdDec->spar_md_cfg.num_umx_chs;
            ivas_spar_md_dec_matrix_close( st_ivas->hSpar->hMdDec, num_channels );
            num_channels = hSpar->hMdDec->spar_md_cfg.num_umx_chs;
            ivas_spar_md_dec_matrix_close( hSpar->hMdDec, num_channels );

            num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( sba_order_internal, ivas_total_brate, st_ivas->last_active_ivas_total_brate );
            if ( ( error = ivas_spar_md_dec_matrix_open( st_ivas->hSpar->hMdDec, num_channels, num_md_sub_frames ) ) != IVAS_ERR_OK )
            if ( ( error = ivas_spar_md_dec_matrix_open( hSpar->hMdDec, num_channels, num_md_sub_frames ) ) != IVAS_ERR_OK )
            {
                return error;
            }
@@ -344,7 +344,6 @@ ivas_error ivas_sba_dec_reconfigure(
        }
    }

    hSpar = st_ivas->hSpar;
    st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas );

    if ( st_ivas->nchan_transport == 1 )
@@ -424,21 +423,21 @@ ivas_error ivas_sba_dec_reconfigure(
    {
        int16_t band_grouping[IVAS_MAX_NUM_BANDS + 1];

        st_ivas->hSpar->enc_param_start_band = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND );
        hSpar->enc_param_start_band = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND );
        if ( ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) )
        {
            st_ivas->hSpar->enc_param_start_band = 0;
            hSpar->enc_param_start_band = 0;

            set_c( (int8_t *) st_ivas->hQMetaData->twoDirBands, (int8_t) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands );
            st_ivas->hQMetaData->numTwoDirBands = (uint8_t) st_ivas->hQMetaData->q_direction[0].cfg.nbands;
        }

        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, 1 );
                                 hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0, 1 );

        if ( st_ivas->hDirAC )
        {
            st_ivas->hDirAC->hConfig->enc_param_start_band = st_ivas->hSpar->enc_param_start_band;
            st_ivas->hDirAC->hConfig->enc_param_start_band = hSpar->enc_param_start_band;
        }
    }

@@ -452,7 +451,7 @@ ivas_error ivas_sba_dec_reconfigure(

    if ( st_ivas->hDirAC != NULL )
    {
        st_ivas->hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band;
        hSpar->enc_param_start_band = st_ivas->hDirAC->hConfig->enc_param_start_band;
    }

    /*-----------------------------------------------------------------*
@@ -666,7 +665,7 @@ ivas_error ivas_sba_dec_reconfigure(
            }
        }

        if ( tc_nchan_tc != st_ivas->hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != st_ivas->hTcBuffer->nchan_transport_internal || tc_buffer_mode != st_ivas->hTcBuffer->tc_buffer_mode || granularity_new != st_ivas->hTcBuffer->n_samples_granularity )
        if ( tc_nchan_tc != hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != hTcBuffer->nchan_transport_internal || tc_buffer_mode != hTcBuffer->tc_buffer_mode || granularity_new != hTcBuffer->n_samples_granularity )
        {
            if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, tc_buffer_mode, tc_nchan_tc, tc_nchan_to_allocate, tc_nchan_to_allocate, granularity_new ) ) != IVAS_ERR_OK )
            {
@@ -676,24 +675,24 @@ ivas_error ivas_sba_dec_reconfigure(
    }

    /* resync SPAR and DirAC JBM info from TC Buffer */
    if ( st_ivas->hSpatParamRendCom != NULL && st_ivas->hSpatParamRendCom->slot_size == st_ivas->hTcBuffer->n_samples_granularity )
    if ( st_ivas->hSpatParamRendCom != NULL && st_ivas->hSpatParamRendCom->slot_size == hTcBuffer->n_samples_granularity )
    {
        mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
        st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes;
        st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered;
        mvs2s( hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
        st_ivas->hSpatParamRendCom->nb_subframes = hTcBuffer->nb_subframes;
        st_ivas->hSpatParamRendCom->subframes_rendered = hTcBuffer->subframes_rendered;
    }
    mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpar->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
    st_ivas->hSpar->nb_subframes = st_ivas->hTcBuffer->nb_subframes;
    st_ivas->hSpar->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered;
    mvs2s( hTcBuffer->subframe_nbslots, hSpar->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
    hSpar->nb_subframes = hTcBuffer->nb_subframes;
    hSpar->subframes_rendered = hTcBuffer->subframes_rendered;

    if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV && st_ivas->ism_mode == ISM_SBA_MODE_DISC )
    {
        int16_t granularityMultiplier = st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size;
        int16_t granularityMultiplier = hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size;
        int16_t n;
        for ( n = 0; n < MAX_JBM_SUBFRAMES_5MS; n++ )
        {
            st_ivas->hSpatParamRendCom->subframe_nbslots[n] = st_ivas->hTcBuffer->subframe_nbslots[n] * granularityMultiplier;
            st_ivas->hSpar->subframe_nbslots[n] = st_ivas->hSpatParamRendCom->subframe_nbslots[n];
            st_ivas->hSpatParamRendCom->subframe_nbslots[n] = hTcBuffer->subframe_nbslots[n] * granularityMultiplier;
            hSpar->subframe_nbslots[n] = st_ivas->hSpatParamRendCom->subframe_nbslots[n];
        }
    }

+1 −1

File changed.

Contains only whitespace changes.