Commit 5c90c527 authored by Dominik Weckbecker's avatar Dominik Weckbecker 💬
Browse files

Merge branch '736-foa-bitrate-switching-decoding-crashes-in-in-ivas_spar_to_dirac' into 'main'

[non-BE] Resolve "FOA bitrate switching decoding crashes in in ivas_spar_to_dirac"

See merge request !1015
parents 939c36c8 9ce21a9d
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -165,9 +165,9 @@
/* any switch which is non-be wrt selection floating point code */
/* all switches in this category should start with "NONBE_" */

#define NONBE_FIX_736_FOA_BR_SWITCH                           /* FhG/Dlb : Issue 736: FOA bitrate switching decoding crashes in in ivas_spar_to_dirac */
#define NONBE_FIX_746_NONDIEGETIC_MD                          /* Eri: Issue 746: The non-diegetic panning flag affects the encoder bitstream even if extended metadata is not enabled. Crashes the decoder.*/


/* ##################### End NON-BE switches ############################# */

/* ################## End DEVELOPMENT switches ######################### */
+50 −5
Original line number Diff line number Diff line
@@ -183,7 +183,11 @@ ivas_error ivas_sba_dec_reconfigure(

    if ( hSpar != NULL )
    {
#ifdef NONBE_FIX_736_FOA_BR_SWITCH
        if ( ( hSpar->hPCA != NULL ) && ( ( hDecoderConfig->ivas_total_brate != PCA_BRATE ) || ( st_ivas->sba_order != 1 ) ) )
#else
        if ( ( hSpar->hPCA != NULL ) && ( ( hDecoderConfig->ivas_total_brate != PCA_BRATE ) || ( sba_order_internal != 1 ) ) )
#endif
        {
            free( st_ivas->hSpar->hPCA );
            hSpar->hPCA = NULL;
@@ -214,6 +218,18 @@ ivas_error ivas_sba_dec_reconfigure(
                return error;
            }
        }
#ifdef NONBE_FIX_736_FOA_BR_SWITCH
        if ( ( hSpar->hPCA == NULL ) &&
             ( st_ivas->hDecoderConfig->ivas_total_brate == PCA_BRATE && st_ivas->sba_order == 1 ) && ( st_ivas->ivas_format == SBA_FORMAT ) )
        {
            if ( ( hSpar->hPCA = (PCA_DEC_STATE *) malloc( sizeof( PCA_DEC_STATE ) ) ) == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for PCA decoder" );
            }

            ivas_pca_dec_init( hSpar->hPCA );
        }
#endif
        ivas_spar_config( ivas_total_brate, sba_order_internal, &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &hSpar->core_nominal_brate, st_ivas->sid_format );
    }
    else
@@ -273,8 +289,17 @@ ivas_error ivas_sba_dec_reconfigure(
    {
        ivas_binRenderer_close( &st_ivas->hBinRenderer );
    }

#ifdef NONBE_FIX_736_FOA_BR_SWITCH
    if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) ) != IVAS_ERR_OK )
    {
        return error;
    }
#endif
#ifndef NONBE_FIX_736_FOA_BR_SWITCH
    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 ) ) || ( last_ivas_total_brate > IVAS_256k && ivas_total_brate <= IVAS_256k ) || ( last_ivas_total_brate <= IVAS_256k && ivas_total_brate > IVAS_256k ) )
#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;

@@ -299,12 +324,32 @@ ivas_error ivas_sba_dec_reconfigure(
            mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
        }
    }

#ifdef NONBE_FIX_736_FOA_BR_SWITCH
    else
    {
#endif
#ifndef NONBE_FIX_736_FOA_BR_SWITCH
        if ( ( error = ivas_dirac_sba_config( st_ivas->hQMetaData, &st_ivas->element_mode_init, ivas_total_brate, st_ivas->sba_analysis_order, ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) ? IVAS_MAX_NUM_BANDS : ( IVAS_MAX_NUM_BANDS - SPAR_DIRAC_SPLIT_START_BAND ) ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#endif
#ifdef NONBE_FIX_736_FOA_BR_SWITCH
        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 );
        if ( ivas_get_hodirac_flag( ivas_total_brate, st_ivas->sba_analysis_order ) )
        {
            st_ivas->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 );
    }
#endif
    if ( st_ivas->renderer_type == RENDERER_DISABLE )
    {
        ivas_dirac_rend_close( &( st_ivas->hDirACRend ) );