Commit 9efdc663 authored by vaclav's avatar vaclav
Browse files

comments, formatting

parent 8835866f
Loading
Loading
Loading
Loading
+20 −11
Original line number Diff line number Diff line
@@ -685,10 +685,9 @@ static ivas_error ivas_mc_dec_reconfig(
    /* renderer might have changed, reselect */
    renderer_type_old = st_ivas->renderer_type;
    ivas_renderer_select( st_ivas );

    if ( st_ivas->mc_mode == MC_MODE_MCT )
    {


        st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels( ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ) );
        st_ivas->nSCE = 0;
        st_ivas->nCPE = st_ivas->nchan_transport / 2;
@@ -766,6 +765,7 @@ static ivas_error ivas_mc_dec_reconfig(
                ivas_mct_dec_close( &st_ivas->hMCT );
                st_ivas->hMCT = NULL;
            }

            /* LFE handle */
            if ( st_ivas->hLFE != NULL )
            {
@@ -810,6 +810,7 @@ static ivas_error ivas_mc_dec_reconfig(
                ivas_mct_dec_close( &st_ivas->hMCT );
                st_ivas->hMCT = NULL;
            }

            /* LFE handle */
            if ( st_ivas->hLFE != NULL )
            {
@@ -828,8 +829,10 @@ static ivas_error ivas_mc_dec_reconfig(
        st_ivas->element_mode_init = IVAS_CPE_MDCT;
    }

    /*-----------------------------------------------------------------*
     * Reconfigure core coder
     *-----------------------------------------------------------------*/

    /* re-configure core coder*/
    /* special case: MCT->ParamMC with more than 2 TC, CPE 1 stays, but has the wrong mct_chan_mode in channel 1
       and might have IGF static memory not allocated and the bit stream index list not set,
       set correct mct_chan_mode and init missing static mem
@@ -837,6 +840,7 @@ static ivas_error ivas_mc_dec_reconfig(
    if ( last_mc_mode == MC_MODE_MCT && st_ivas->mc_mode == MC_MODE_PARAMMC && st_ivas->nchan_transport > CPE_CHANNELS )
    {
        Decoder_State *st = st_ivas->hCPE[1]->hCoreCoder[1];

        if ( st_ivas->nchan_transport == 3 )
        {
            st->mct_chan_mode = MCT_CHAN_MODE_IGNORE;
@@ -862,8 +866,7 @@ static ivas_error ivas_mc_dec_reconfig(
#ifdef DEBUGGING
        assert( st_ivas->hCPE[1] != NULL );
#endif
        Decoder_State *st = st_ivas->hCPE[1]->hCoreCoder[1];
        st->mct_chan_mode = MCT_CHAN_MODE_LFE;
        st_ivas->hCPE[1]->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_LFE;
    }

    if ( ( error = ivas_corecoder_dec_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old ) ) != IVAS_ERR_OK )
@@ -924,10 +927,12 @@ static ivas_error ivas_mc_dec_reconfig(
        }
    }

    /* Allocat the LFE handle that is coded seperately after the allocation of the core coders*/
    /*-----------------------------------------------------------------*
     * Allocate the LFE handle that is coded seperately after the allocation of the core coders
     *-----------------------------------------------------------------*/

    if ( st_ivas->mc_mode == MC_MODE_MCT && st_ivas->hLFE == NULL )
    {

        if ( ( error = ivas_create_lfe_dec( &st_ivas->hLFE, st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtf != NULL ? st_ivas->hHrtf->latency_s : 0 ) ) != IVAS_ERR_OK )
        {
            return error;
@@ -941,9 +946,8 @@ static ivas_error ivas_mc_dec_reconfig(
        set_zero( st_ivas->hLFE->prior_out_buffer, L_FRAME48k );
    }


    /*-----------------------------------------------------------------*
     * Renderers
     * Reconfigure renderers
     *-----------------------------------------------------------------*/

    if ( renderer_type_old != st_ivas->renderer_type )
@@ -951,6 +955,7 @@ static ivas_error ivas_mc_dec_reconfig(
        AUDIO_CONFIG output_config;

        output_config = st_ivas->hDecoderConfig->output_config;

        /* binaural renderers*/
        if ( output_config == AUDIO_CONFIG_BINAURAL || output_config == AUDIO_CONFIG_BINAURAL_ROOM )
        {
@@ -959,18 +964,22 @@ static ivas_error ivas_mc_dec_reconfig(
            {
                ivas_binRenderer_close( &st_ivas->hBinRenderer );
            }

            if ( st_ivas->hCrend != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV && st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV_ROOM && ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD || st_ivas->hRenderConfig->roomAcoustics.late_reverb_on == 0 ) ) )
            {
                ivas_crend_close( st_ivas );
            }

            if ( st_ivas->hBinRendererTd != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) )
            {
                ivas_td_binaural_close( &st_ivas->hBinRendererTd );
            }

            if ( st_ivas->hDiracDecBin != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM ) )
            {
                ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin );
            }

            /* init necessary new renderers */
            if ( st_ivas->hBinRenderer == NULL && ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) )
            {
@@ -1009,7 +1018,7 @@ static ivas_error ivas_mc_dec_reconfig(
                }
            }
        }
        /* stereo */
        /* mono/stereo */
        else if ( output_config == AUDIO_CONFIG_MONO || output_config == AUDIO_CONFIG_STEREO )
        {
            /* nothing should happen here... */
@@ -1025,7 +1034,7 @@ static ivas_error ivas_mc_dec_reconfig(
        else if ( output_config == AUDIO_CONFIG_FOA || output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_HOA3 )
        {
            /* FOA/HOA output */
            /* Nothing to do, is always RENDERER_SBA_LINEAR_ENC */
            /* Nothing to do, renderer is always RENDERER_SBA_LINEAR_ENC */
            assert( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC && renderer_type_old == RENDERER_SBA_LINEAR_ENC );
        }
#endif
+18 −5
Original line number Diff line number Diff line
@@ -620,6 +620,10 @@ static ivas_error ivas_mc_enc_reconfig(
    nSCE_old = st_ivas->nSCE;
    nCPE_old = st_ivas->nCPE;

    /*-----------------------------------------------------------------*
     * Reconfigure MC modules
     *-----------------------------------------------------------------*/

    if ( st_ivas->mc_mode == MC_MODE_MCT )
    {
        st_ivas->nSCE = 0;
@@ -634,6 +638,7 @@ static ivas_error ivas_mc_enc_reconfig(
            {
                return error;
            }

            /*De-allocate handles for other MC modes*/
            if ( st_ivas->hParamMC != NULL )
            {
@@ -647,6 +652,7 @@ static ivas_error ivas_mc_enc_reconfig(
                ivas_mcmasa_enc_close( st_ivas->hMcMasa, st_ivas->hEncoderConfig->input_Fs );
                st_ivas->hMcMasa = NULL;
            }

            if ( st_ivas->hMasa != NULL )
            {
                ivas_masa_enc_close( st_ivas->hMasa, nchan_transport_old, MC_FORMAT );
@@ -698,6 +704,7 @@ static ivas_error ivas_mc_enc_reconfig(
            ivas_mct_enc_close( st_ivas->hMCT );
            st_ivas->hMCT = NULL;
        }

        if ( last_mc_mode == MC_MODE_MCT && st_ivas->hLFE != NULL )
        {
            /* LFE handle */
@@ -732,6 +739,7 @@ static ivas_error ivas_mc_enc_reconfig(
            ivas_param_mc_enc_close( st_ivas->hParamMC, st_ivas->hEncoderConfig->input_Fs );
            st_ivas->hParamMC = NULL;
        }

        if ( last_mc_mode == MC_MODE_MCT )
        {
            /* LFE handle */
@@ -757,7 +765,10 @@ static ivas_error ivas_mc_enc_reconfig(
        st_ivas->hEncoderConfig->element_mode_init = IVAS_CPE_MDCT;
    }

    /* re-configure core coder*/
    /*-----------------------------------------------------------------*
     * Reconfigure core coder
     *-----------------------------------------------------------------*/

    /* special case: MCT->ParamMC with more than 2 TC, CPE 1 stays, but has the wrong mct_chan_mode in channel 1
       and might have IGF and TranDet static memory not allocated and the bit stream index list not set,
       set correct mct_chan_mode and init missing static mem
@@ -765,6 +776,7 @@ static ivas_error ivas_mc_enc_reconfig(
    if ( last_mc_mode == MC_MODE_MCT && st_ivas->mc_mode == MC_MODE_PARAMMC && st_ivas->nchan_transport > CPE_CHANNELS )
    {
        Encoder_State *st = st_ivas->hCPE[1]->hCoreCoder[1];

        if ( st_ivas->nchan_transport == 3 )
        {
            st->mct_chan_mode = MCT_CHAN_MODE_IGNORE;
@@ -773,15 +785,17 @@ static ivas_error ivas_mc_enc_reconfig(
        {
            st->mct_chan_mode = MCT_CHAN_MODE_REGULAR;
        }

        if ( st->hTranDet == NULL )
        {

            if ( ( st->hTranDet = (TRAN_DET_HANDLE) count_malloc( sizeof( TRAN_DET_DATA ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Transient Detection\n" ) );
            }

            InitTransientDetection( (int16_t) ( st->input_Fs / FRAMES_PER_SEC ), NS2SA( st->input_Fs, DELAY_FIR_RESAMPL_NS ), st->hTranDet, 0 );
        }

        if ( st->hIGFEnc == NULL )
        {
            if ( ( st->hIGFEnc = (IGF_ENC_INSTANCE_HANDLE) count_malloc( sizeof( IGF_ENC_INSTANCE ) ) ) == NULL )
@@ -789,6 +803,7 @@ static ivas_error ivas_mc_enc_reconfig(
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hIGFEnc\n" ) );
            }
        }

        st->igf = getIgfPresent( st->element_mode, st->total_brate, st->bwidth, st->rf_mode, st->mct_chan_mode );
    }
    else if ( last_mc_mode == MC_MODE_PARAMMC && st_ivas->mc_mode == MC_MODE_MCT && nchan_transport_old > 2 )
@@ -796,11 +811,9 @@ static ivas_error ivas_mc_enc_reconfig(
#ifdef DEBUGGING
        assert( st_ivas->hCPE[1] != NULL );
#endif
        Encoder_State *st = st_ivas->hCPE[1]->hCoreCoder[1];
        st->mct_chan_mode = MCT_CHAN_MODE_LFE;
        st_ivas->hCPE[1]->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_LFE;
    }


    if ( ( error = ivas_corecoder_enc_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old ) ) != IVAS_ERR_OK )
    {
        return error;