Commit fb01a525 authored by vaclav's avatar vaclav
Browse files

fix crashes for Ambisonics and MC outputs + add debugging output file "res/element_brate"

parent e4a16a91
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -911,6 +911,9 @@ typedef enum
{
    DIRAC_OPEN,                                 /* initialize to default value              */
    DIRAC_RECONFIGURE                           /* HOA3                                     */
#ifdef SBA_BITRATE_SWITCHING // VE: TBV - just dirty patch for the moment
   ,DIRAC_RECONFIGURE_MODE                      /* HOA3                                     */
#endif
} DIRAC_CONFIG_FLAG;


+2 −2
Original line number Diff line number Diff line
@@ -496,7 +496,7 @@ ivas_error ivas_cpe_dec(

#ifdef DEBUG_MODE_INFO
    {
        float tmpF = ivas_total_brate / 1000.0f;
        float tmpF = hCPE->element_brate / 1000.0f;

        n = 1;
        if ( st_ivas->ini_frame == 0 && frame > 0 )
@@ -508,7 +508,7 @@ ivas_error ivas_cpe_dec(
        for ( i = 0; i < n; i++ )
        {
            dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "element_brate", 0, cpe_id, DEC ) );
            dbgwrite( &hCPE->element_mode, 2, 1, output_frame, fname( debug_dir, "element_mode", 0, cpe_id, DEC ) );
            dbgwrite( &hCPE->element_mode, sizeof( int16_t ), 1, output_frame, fname( debug_dir, "element_mode", 0, cpe_id, DEC ) );

            for ( int16_t j = 0; j < CPE_CHANNELS; j++ )
            {
+15 −1
Original line number Diff line number Diff line
@@ -127,7 +127,9 @@ ivas_error ivas_dirac_dec_open(

ivas_error ivas_dirac_dec_config(
    Decoder_Struct *st_ivas,            /* i/o: IVAS decoder structure  */
    const DIRAC_CONFIG_FLAG flag_config /* i/ : Flag determining if we open or reconfigure the DirAC decoder */
#ifdef SBA_BITRATE_SWITCHING
    const DIRAC_CONFIG_FLAG flag_config_inp /* i/ : Flag determining if we open or reconfigure the DirAC decoder */
#endif
)
{
    DIRAC_DEC_HANDLE hDirAC;
@@ -146,6 +148,11 @@ ivas_error ivas_dirac_dec_config(
    int32_t output_Fs, ivas_total_brate;
    ivas_error error;
    int16_t nchan_transport_orig;
#ifdef SBA_BITRATE_SWITCHING
    DIRAC_CONFIG_FLAG flag_config;

    flag_config = ( flag_config_inp == DIRAC_RECONFIGURE_MODE ) ? DIRAC_RECONFIGURE : flag_config_inp;
#endif

    error = IVAS_ERR_OK;

@@ -270,6 +277,9 @@ ivas_error ivas_dirac_dec_config(
    /* band config needed only for SPAR with FOA output */
    if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_FOA && st_ivas->sba_mode == SBA_MODE_SPAR )
    {
#ifdef SBA_BITRATE_SWITCHING // VE: TBV
        st_ivas->nchan_transport = nchan_transport_orig;
#endif
        return IVAS_ERR_OK;
    }

@@ -653,7 +663,11 @@ ivas_error ivas_dirac_dec_config(
    }
    else if ( flag_config == DIRAC_RECONFIGURE && hDirAC->proto_signal_decorr_on && proto_signal_decorr_on_old )
    {
#ifdef SBA_BITRATE_SWITCHING
        if ( ( nchan_transport != nchan_transport_old ) || ( hDirAC->num_outputs_diff != num_outputs_diff_old ) || flag_config_inp == DIRAC_RECONFIGURE_MODE )
#else
        if ( ( nchan_transport != nchan_transport_old ) || ( hDirAC->num_outputs_diff != num_outputs_diff_old ) )
#endif
        {
            /* close and reopen the decorrelator */
            ivas_dirac_dec_decorr_close( &hDirAC->h_freq_domain_decorr_ap_params, &hDirAC->h_freq_domain_decorr_ap_state );
+8 −0
Original line number Diff line number Diff line
@@ -250,6 +250,14 @@ ivas_error ivas_mct_dec(
#endif
    }

#ifdef DEBUG_MODE_INFO
    for ( cpe_id = 0; cpe_id < nCPE; cpe_id++ )
    {
        float tmpF = st_ivas->hCPE[cpe_id]->element_brate / 1000.0f;
        dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "element_brate", 0, cpe_id, DEC ) );
    }
#endif

    wmops_sub_end();
    return error;
}
+39 −29
Original line number Diff line number Diff line
@@ -457,6 +457,7 @@ ivas_error ivas_sba_dec_reconfigure(
    int16_t nSCE_old, nCPE_old, nchan_transport_old;
    int16_t nchan_hp20_old, nchan_hp20;
    AUDIO_CONFIG intern_config_old;
    SBA_MODE sba_mode_old;
    int16_t numCldfbAnalyses_old, numCldfbAnalyses, numCldfbSyntheses_old, numCldfbSyntheses;
    int16_t sba_dirac_stereo_flag_old;
    float **old_mem_hp20_out;
@@ -476,9 +477,11 @@ ivas_error ivas_sba_dec_reconfigure(
     * Save old SBA high-level parameters
     *-----------------------------------------------------------------*/

    st_ivas->sba_mode = ivas_sba_mode_select( last_ivas_total_brate );
    sba_mode_old = ivas_sba_mode_select( last_ivas_total_brate );

    st_ivas->sba_mode = sba_mode_old;
    ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );

    nchan_hp20_old = getNumChanSynthesis( st_ivas );

    nSCE_old = st_ivas->nSCE;
@@ -557,12 +560,12 @@ ivas_error ivas_sba_dec_reconfigure(
     * hDirAC decoder handle configuration
     *-----------------------------------------------------------------*/

    if ( st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC &&
         ( last_ivas_total_brate > IVAS_SID_4k4 || st_ivas->nchan_transport != nchan_transport_old ) && ( st_ivas->sba_mode != SBA_MODE_SPAR ) )
#ifdef SBA_BITRATE_SWITCHING // VE: TBD - possibly merge with the 'else if' branch below
    if ( sba_mode_old != st_ivas->sba_mode )
    {
        if ( st_ivas->hDirAC != NULL )
        {
            if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK )
            if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE_MODE ) ) != IVAS_ERR_OK )
            {
                return error;
            }
@@ -575,9 +578,10 @@ ivas_error ivas_sba_dec_reconfigure(
            }
        }
    }
#ifdef SBA_BITRATE_SWITCHING // VE: TBD - possibly merge with the above
    else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC && st_ivas->sba_mode == SBA_MODE_SPAR )
    //else if ( ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC || st_ivas->renderer_type == RENDERER_DIRAC ) && st_ivas->sba_mode == SBA_MODE_SPAR )
    else
#endif
    if ( st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_SBA_LINEAR_DEC &&
         ( last_ivas_total_brate > IVAS_SID_4k4 || st_ivas->nchan_transport != nchan_transport_old ) && ( st_ivas->sba_mode != SBA_MODE_SPAR ) )
    {
        if ( st_ivas->hDirAC != NULL )
        {
@@ -592,14 +596,9 @@ ivas_error ivas_sba_dec_reconfigure(
            {
                return error;
            }

            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;
        }
    }
#endif
#ifdef SBA_BITRATE_SWITCHINGaa
    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 || ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC && st_ivas->sba_mode != SBA_MODE_SPAR ) )
    {
        if ( st_ivas->hDirAC != NULL )
        {
@@ -612,19 +611,11 @@ ivas_error ivas_sba_dec_reconfigure(
            vbap_free_data( &( st_ivas->hVBAPdata ) );
        }
    }
#endif
    else if ( st_ivas->renderer_type == RENDERER_DISABLE || ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_DEC && st_ivas->sba_mode != SBA_MODE_SPAR ) )
    {
        if ( st_ivas->hDirAC != NULL )
        {
            ivas_dirac_dec_close( st_ivas->hDirAC );
            st_ivas->hDirAC = NULL;
        }

        if ( st_ivas->hVBAPdata != NULL )
    if ( st_ivas->hDirAC != NULL && st_ivas->sba_mode == SBA_MODE_SPAR )
    {
            vbap_free_data( &( st_ivas->hVBAPdata ) );
        }
        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;
    }


@@ -685,6 +676,7 @@ ivas_error ivas_sba_dec_reconfigure(
        nSCE_existing = min( nSCE_old, st_ivas->nSCE );
        nCPE_existing = min( nCPE_old, st_ivas->nCPE );

        // VE: TBV - try to reuse the CoreCoder
        /* destroy superfluous core coder elements */
        for ( sce_id = st_ivas->nSCE; sce_id < nSCE_old; sce_id++ )
        {
@@ -902,8 +894,17 @@ ivas_error ivas_sba_dec_reconfigure(
    /* Analysis*/
    if ( numCldfbAnalyses_old > numCldfbAnalyses )
    {
        /* delete superfluous CLDFB synthesis instances */
        for ( i = numCldfbAnalyses; i < numCldfbAnalyses_old; i++ )
        /* resample CLDFB analysis instances */
        for ( i = 0; i < numCldfbAnalyses; i++ )
        {
            if ( ( st_ivas->cldfbAnaDec[i]->no_channels * st_ivas->cldfbAnaDec[i]->no_col ) != output_frame )
            {
                resampleCldfb( st_ivas->cldfbAnaDec[i], hDecoderConfig->output_Fs );
            }
        }

        /* delete superfluous CLDFB analysis instances */
        for ( ; i < numCldfbAnalyses_old; i++ )
        {
            deleteCldfb( &( st_ivas->cldfbAnaDec[i] ) );
            st_ivas->cldfbAnaDec[i] = NULL;
@@ -911,8 +912,17 @@ ivas_error ivas_sba_dec_reconfigure(
    }
    else if ( numCldfbAnalyses_old < numCldfbAnalyses )
    {
        /* create additional CLDFB synthesis instances */
        for ( i = numCldfbAnalyses_old; i < numCldfbAnalyses; i++ )
        /* resample CLDFB analysis instances */
        for ( i = 0; i < numCldfbAnalyses_old; i++ )
        {
            if ( ( st_ivas->cldfbAnaDec[i]->no_channels * st_ivas->cldfbAnaDec[i]->no_col ) != output_frame )
            {
                resampleCldfb( st_ivas->cldfbAnaDec[i], hDecoderConfig->output_Fs );
            }
        }

        /* create additional CLDFB analysis instances */
        for ( ; i < numCldfbAnalyses; i++ )
        {
            if ( ( error = openCldfb( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK )
            {
Loading