Commit acdbe62e authored by vaclav's avatar vaclav
Browse files

Merge branch '116-Bitrate-Switching-in-MC' into 'main'

Bitrate-Switching-in-MC-rev01

See merge request !346
parents c4824b93 14431b2b
Loading
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -512,13 +512,8 @@ ivas_error ivas_cpe_dec(

        for ( i = 0; i < n; i++ )
        {
#ifdef MC_BITRATE_SWITCHING // !!! VE: Can it be removed?
            dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "element_brate.cpe", 0, cpe_id, DEC ) );
            dbgwrite( &hCPE->element_mode, sizeof( int16_t ), 1, output_frame, fname( debug_dir, "element_mode.cpe", 0, cpe_id, DEC ) );
#else
            dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "element_brate", 0, cpe_id, DEC ) );
            dbgwrite( &hCPE->element_mode, sizeof( int16_t ), 1, output_frame, fname( debug_dir, "element_mode", 0, cpe_id, DEC ) );
#endif

            for ( int16_t j = 0; j < CPE_CHANNELS; j++ )
            {
+38 −10
Original line number Diff line number Diff line
@@ -667,17 +667,18 @@ static ivas_error ivas_mc_dec_reconfig(
#else
    int16_t numCldfbAnalyses_old, numCldfbAnalyses, numCldfbSyntheses, numCldfbSyntheses_old, i;
#endif
    int32_t new_brate_SCE, new_brate_CPE;
    int32_t new_brate_SCE, new_brate_CPE, ivas_total_brate;
    RENDERER_TYPE renderer_type_old;
    ivas_error error;
    MC_MODE mc_mode, last_mc_mode;

    last_mc_mode = ivas_mc_mode_select( ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ), st_ivas->hDecoderConfig->last_ivas_total_brate ); /* NB: this assumes that LS config remains the same between frames */

    error = IVAS_ERR_OK;

    ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
    nchan_transport_old = st_ivas->nchan_transport;

    last_mc_mode = ivas_mc_mode_select( ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ), st_ivas->hDecoderConfig->last_ivas_total_brate ); /* NB: this assumes that LS config remains the same between frames */

    /* we have to temporally set the current mc_mode back to the previous one to make sure the following call to
       ivas_init_dec_get_num_cldfb_instances() returns the correct counts */
    mc_mode = st_ivas->mc_mode;
@@ -703,6 +704,7 @@ static ivas_error ivas_mc_dec_reconfig(
    /* renderer might have changed, reselect */
    renderer_type_old = st_ivas->renderer_type;
    ivas_renderer_select( st_ivas );

    /* side effect of the renderer selection can be a changed internal config */
    ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config );

@@ -755,6 +757,7 @@ static ivas_error ivas_mc_dec_reconfig(
            {
                ivas_ls_setup_conversion_close( &st_ivas->hLsSetUpConversion );
            }

            if ( ( error = ivas_param_mc_dec_open( st_ivas ) ) != IVAS_ERR_OK )
            {
                return error;
@@ -796,7 +799,7 @@ static ivas_error ivas_mc_dec_reconfig(
    }
    else if ( st_ivas->mc_mode == MC_MODE_MCMASA )
    {
        ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), st_ivas->hDecoderConfig->ivas_total_brate );
        ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate );

        if ( last_mc_mode != MC_MODE_MCMASA )
        {
@@ -805,6 +808,7 @@ static ivas_error ivas_mc_dec_reconfig(
                return error;
            }
        }

        if ( ( error = ivas_mcmasa_dec_reconfig( st_ivas ) ) != IVAS_ERR_OK )
        {
            return error;
@@ -903,7 +907,7 @@ static ivas_error ivas_mc_dec_reconfig(
            }
        }

        st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( st_ivas->hDecoderConfig->ivas_total_brate, st->igf, st->element_mode, st->mct_chan_mode );
        st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( ivas_total_brate, st->igf, st->element_mode, st->mct_chan_mode );
    }
    else if ( last_mc_mode == MC_MODE_PARAMMC && st_ivas->mc_mode == MC_MODE_MCT && nchan_transport_old > 2 )
    {
@@ -919,19 +923,20 @@ static ivas_error ivas_mc_dec_reconfig(
    {
        uint8_t separateChannelEnabled;
        int16_t separateChannelIndex;
        ivas_mcmasa_set_separate_channel_mode( &separateChannelEnabled, &separateChannelIndex, st_ivas->hDecoderConfig->ivas_total_brate );
        ivas_mcmasa_split_brate( separateChannelEnabled, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &new_brate_SCE, &new_brate_CPE );
        ivas_mcmasa_set_separate_channel_mode( &separateChannelEnabled, &separateChannelIndex, ivas_total_brate );
        ivas_mcmasa_split_brate( separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &new_brate_SCE, &new_brate_CPE );
    }
    else if ( st_ivas->mc_mode == MC_MODE_MCT )
    {
        new_brate_SCE = 0;
        new_brate_CPE = ( st_ivas->hDecoderConfig->ivas_total_brate / ( st_ivas->nchan_transport - 1 ) ) * CPE_CHANNELS;
        new_brate_CPE = ( ivas_total_brate / ( st_ivas->nchan_transport - 1 ) ) * CPE_CHANNELS;
    }
    else
    {
        new_brate_SCE = 0; /*st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport;*/
        new_brate_CPE = ( st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS;
        new_brate_SCE = 0; /* ivas_total_brate / st_ivas->nchan_transport;*/
        new_brate_CPE = ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS;
    }

    if ( ( error = ivas_corecoder_dec_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old, new_brate_SCE, new_brate_CPE ) ) != IVAS_ERR_OK )
    {
        return error;
@@ -1030,7 +1035,29 @@ static ivas_error ivas_mc_dec_reconfig(

    if ( st_ivas->mc_mode == MC_MODE_MCT && st_ivas->hLFE == NULL )
    {
#ifdef FIX_I59_LFE_TD_DELAY
        int32_t binauralization_delay_ns = st_ivas->binaural_latency_ns;

        if ( st_ivas->hBinRenderer != NULL )
        {
#ifdef FIX_I59_LFE_CLDFB
            if ( st_ivas->hBinRenderer->render_lfe )
            {
                /* Account for filterbank delay */
                binauralization_delay_ns += IVAS_FB_DEC_DELAY_NS;
            }
            else
            {
                binauralization_delay_ns = 0;
            }
#else
            binauralization_delay_ns = 0;
#endif
        }
        if ( ( error = ivas_create_lfe_dec( &st_ivas->hLFE, st_ivas->hDecoderConfig->output_Fs, binauralization_delay_ns ) ) != IVAS_ERR_OK )
#else
        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 )
#endif
        {
            return error;
        }
@@ -1110,6 +1137,7 @@ static ivas_error ivas_mc_dec_reconfig(
                {
                    /* useTdDecorr may change => close and re-open */
                    ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin );

                    if ( ( error = ivas_dirac_dec_init_binaural_data( st_ivas ) ) != IVAS_ERR_OK )
                    {
                        return error;
+0 −5
Original line number Diff line number Diff line
@@ -273,13 +273,8 @@ ivas_error ivas_sce_dec(

        for ( i = 0; i < n; i++ )
        {
#ifdef MC_BITRATE_SWITCHING // !!! VE: Can it be removed?
            dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "element_brate.sce", 0, sce_id, DEC ) );
            dbgwrite( &st->element_mode, sizeof( int16_t ), 1, output_frame, fname( debug_dir, "element_mode.sce", 0, sce_id, DEC ) );
#else
            dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "element_brate", 0, sce_id, DEC ) );
            dbgwrite( &st->element_mode, sizeof( int16_t ), 1, output_frame, fname( debug_dir, "element_mode", 0, sce_id, DEC ) );
#endif

            dbgwrite( output, sizeof( float ), output_frame, 1, fname( debug_dir, "output.sce", 0, sce_id, DEC ) );
            tmpF = 0;
+2 −1
Original line number Diff line number Diff line
@@ -354,8 +354,9 @@ ivas_error ivas_corecoder_enc_reconfig(
#ifdef MC_BITRATE_SWITCHING
                if ( st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->hMcMasa->separateChannelEnabled )
                {
                    st_ivas->hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; // !!! VE: can it be set in McMASA config module rather than here?
                    st_ivas->hEncoderConfig->element_mode_init = IVAS_CPE_MDCT;
                }

                if ( ( error = create_cpe_enc( st_ivas, cpe_id, brate_CPE ) ) != IVAS_ERR_OK )
#else
                if ( ( error = create_cpe_enc( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK )
+0 −4
Original line number Diff line number Diff line
@@ -426,11 +426,7 @@ ivas_error ivas_cpe_enc(
    {
        dbgwrite( sts[0]->input - NS2SA( sts[0]->input_Fs, ACELP_LOOK_NS ), sizeof( float ), input_frame, 1, fname( debug_dir, "input_DMX", n, sts[n]->id_element, ENC ) );
    }
#ifdef MC_BITRATE_SWITCHING // !!! VE: Can it be removed?
    dbgwrite( &hCPE->element_mode, sizeof( int16_t ), 1, input_frame, fname( debug_dir, "element_mode.cpe", 0, sts[0]->id_element, ENC ) );
#else
    dbgwrite( &hCPE->element_mode, sizeof( int16_t ), 1, input_frame, fname( debug_dir, "element_mode", 0, sts[0]->id_element, ENC ) );
#endif
#endif

    /*----------------------------------------------------------------*
Loading