Commit 09851c98 authored by vaclav's avatar vaclav
Browse files

FIX_FMSW_DEC andf FIX_FMSW_DEC_2

parent 11cd64e9
Loading
Loading
Loading
Loading
Loading
+48 −2
Original line number Diff line number Diff line
@@ -164,10 +164,16 @@ static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS
#else
static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf );
#endif
#ifdef FIX_FMSW_DEC
static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtf, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE *phIvasDec, int16_t *pcmBuf );
#else
static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtf, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_RENDER_CONFIG_DATA *renderConfig, IVAS_DEC_HANDLE *phIvasDec, int16_t *pcmBuf );
#endif
static ivas_error load_hrtf_from_file( IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, IVAS_DEC_HANDLE hIvasDec, const IVAS_AUDIO_CONFIG OutputConfig, const int32_t output_Fs );
static void do_object_editing_fx( IVAS_EDITABLE_PARAMETERS *editableParameters, ObjectEditFileReader *objectEditFileReader );
#ifndef FIX_FMSW_DEC
static ivas_error restartDecoder( IVAS_DEC_HANDLE *phIvasDec, const IVAS_DEC_MODE decMode, DecArguments *arg, IVAS_RENDER_CONFIG_DATA *renderConfig, IVAS_CUSTOM_LS_DATA *hLsCustomData );
#endif


/*------------------------------------------------------------------------------------------*
@@ -668,7 +674,11 @@ int main(

    if ( arg.voipMode )
    {
#ifdef FIX_FMSW_DEC
        error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, &hIvasDec, pcmBuf );
#else
        error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, &renderConfig, &hIvasDec, pcmBuf );
#endif
    }
    else
    {
@@ -2315,6 +2325,13 @@ static ivas_error decodeG192(

                if ( restartNeeded )
                {
#ifdef FIX_FMSW_DEC
                    if ( ( error = IVAS_DEC_Restart( hIvasDec, IVAS_DEC_MODE_IVAS ) ) != IVAS_ERR_OK ) /* note: only switching within IVAS formats is supported in G.192 */
                    {
                        fprintf( stderr, "\nIVAS_DEC_Restart restart failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                        goto cleanup;
                    }
#else
                    IVAS_DEC_BS_FORMAT tempFormat;
                    if ( ( error = IVAS_DEC_GetFormat( hIvasDec, &tempFormat ) ) != IVAS_ERR_OK )
                    {
@@ -2335,6 +2352,7 @@ static ivas_error decodeG192(
                        goto cleanup;
                    }
                    *phIvasDec = hIvasDec; /* Update for main()' s free */
#endif
                }
#endif

@@ -2814,7 +2832,9 @@ static ivas_error decodeVoIP(
    Vector3PairFileReader *referenceVectorReader,
    ObjectEditFileReader *objectEditFileReader,
    ISAR_SPLIT_REND_BITS_DATA *splitRendBits,
#ifndef FIX_FMSW_DEC
    IVAS_RENDER_CONFIG_DATA *renderConfig,
#endif
    IVAS_DEC_HANDLE *phIvasDec,
    int16_t *pcmBuf )
{
@@ -2970,6 +2990,15 @@ static ivas_error decodeVoIP(

        /* EVS RTP payload format has timescale 16000, JBM uses 1000 internally */
        rtpTimeStamp = rtpTimeStamp / 16;

#ifdef FIX_FMSW_DEC_2
        arg.decMode = ( ivasRtp.codecId == IVAS_RTP_EVS ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS;
        if ( ( error = IVAS_DEC_Restart( hIvasDec, arg.decMode ) ) != IVAS_ERR_OK ) /* note: when the RTP bitstream starts with EVS, do the restart */
        {
            fprintf( stderr, "\nIVAS_DEC_Restart restart failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
            goto cleanup;
        }
#endif
    }
    if ( error != IVAS_ERR_OK )
    {
@@ -3003,6 +3032,14 @@ static ivas_error decodeVoIP(
        /* restart decoder in case of format switching */
        if ( ivasRtp.restartNeeded )
        {
#ifdef FIX_FMSW_DEC
            arg.decMode = ( ivasRtp.codecId == IVAS_RTP_EVS ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS;
            if ( ( error = IVAS_DEC_Restart( hIvasDec, arg.decMode ) ) != IVAS_ERR_OK ) /* note: switching between EVS and IVAS is supported in RTP */
            {
                fprintf( stderr, "\nIVAS_DEC_Restart restart failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                goto cleanup;
            }
#else
            IVAS_DEC_MODE newDecModeInPacket = ( ivasRtp.codecId == IVAS_RTP_EVS ) ? IVAS_DEC_MODE_EVS : IVAS_DEC_MODE_IVAS;
            if ( ( error = restartDecoder(
                       &hIvasDec,
@@ -3017,6 +3054,7 @@ static ivas_error decodeVoIP(
            }

            *phIvasDec = hIvasDec; /* Update for main()' s free */
#endif
            ivasRtp.restartNeeded = false;
            bitstreamReadDone = false;
            parametersAvailableForEditing = false;
@@ -3248,6 +3286,13 @@ static ivas_error decodeVoIP(

                if ( restartNeeded )
                {
#ifdef FIX_FMSW_DEC
                    if ( ( error = IVAS_DEC_Restart( hIvasDec, IVAS_DEC_MODE_IVAS ) ) != IVAS_ERR_OK ) /* note: only switching within IVAS formats is supported in non-RTP VoIP */
                    {
                        fprintf( stderr, "\nIVAS_DEC_Restart restart failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                        goto cleanup;
                    }
#else
                    IVAS_DEC_BS_FORMAT tempBsFormat;
                    if ( ( error = IVAS_DEC_GetFormat( hIvasDec, &tempBsFormat ) ) != IVAS_ERR_OK )
                    {
@@ -3269,6 +3314,7 @@ static ivas_error decodeVoIP(
                    }

                    *phIvasDec = hIvasDec; /* Update for main()' s free */
#endif
                    bitstreamReadDone = false;
                    parametersAvailableForEditing = false;
                }
@@ -3961,7 +4007,7 @@ static ivas_error load_hrtf_from_file(
    return IVAS_ERR_OK;
}


#ifndef FIX_FMSW_DEC
/*---------------------------------------------------------------------*
 * restartDecoder()
 *
@@ -4066,5 +4112,5 @@ cleanup:

    return error;
}

#endif
#undef WMC_TOOL_SKIP
+19 −2
Original line number Diff line number Diff line
@@ -254,6 +254,7 @@ int main(
        fprintf( stderr, "Opening IVAS encoder failed: %s\n", IVAS_ENC_GetErrorMessage( error ) );
        goto cleanup;
    }

    /*------------------------------------------------------------------------------------------*
     * Open output bitstream file
     *------------------------------------------------------------------------------------------*/
@@ -364,6 +365,21 @@ int main(
        }
    }

#ifdef FIX_FMSW_DEC
    /*------------------------------------------------------------------------------------------*
     * Open remote requests file for rtp packing (E-bytes)
     *------------------------------------------------------------------------------------------*/
    
    if ( arg.requestsFileName != NULL )
    {
        if ( ( error = RequestsFileReader_open( arg.requestsFileName, &requestsFileReader ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nError: Can't open requests file %s \n\n", arg.requestsFileName );
            goto cleanup;
        }
    }
#endif

    /*------------------------------------------------------------------------------------------*
     * Handle Channel-aware mode
     *------------------------------------------------------------------------------------------*/
@@ -661,6 +677,7 @@ int main(
        }
    }

#ifndef FIX_FMSW_DEC
    /*------------------------------------------------------------------------------------------*
     * Open remote requests file for rtp packing (E-bytes)
     *------------------------------------------------------------------------------------------*/
@@ -672,7 +689,7 @@ int main(
            goto cleanup;
        }
    }

#endif
    /*------------------------------------------------------------------------------------------*
     * Run the encoder
     *------------------------------------------------------------------------------------------*/
@@ -2133,9 +2150,9 @@ static void usage_enc( void )
    fprintf( stdout, "                      bitstream frames into TS26.253 Annex A IVAS RTP Payload Format packets and \n" );
    fprintf( stdout, "                      writes those to the output file. In EVS mono operating mode, TS26.445 Annex A.2.2 \n" );
    fprintf( stdout, "                      EVS RTP Payload Format is used. Optional N represents number of frames per RTP packet\n" );
    fprintf( stdout, "-requests           : Remote requests file, Only used with rtpdump output.\n" );
    fprintf( stdout, "-scene_orientation  : Scene orientation trajectory file. Only used with rtpdump output.\n" );
    fprintf( stdout, "-device_orientation : Device orientation trajectory file. Only used with rtpdump output.\n" );
    fprintf( stdout, "-requests           : Remote requests file, Only used with rtpdump output.\n" );

    fprintf( stdout, "\n" );

+6 −1
Original line number Diff line number Diff line
@@ -2070,7 +2070,11 @@ void destroy_core_dec_fx(
);

void ivas_destroy_dec_fx(
#ifdef FIX_FMSW_DEC
    Decoder_Struct **st_ivas                                    /* i/o: IVAS decoder structure                      */
#else
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                      */
#endif
);

ivas_error ivas_ism_dec_config_fx(
@@ -3725,10 +3729,11 @@ Word16 getNumChanSynthesis(
    Decoder_Struct *st_ivas                                     /* i  : IVAS decoder structure                      */
);

#ifndef FIX_FMSW_DEC
void ivas_destroy_dec_fx(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                      */
);

#endif
ivas_error ivas_core_dec_fx(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                      */
    SCE_DEC_HANDLE hSCE,                                        /* i/o: SCE decoder structure                       */
+2 −0
Original line number Diff line number Diff line
@@ -116,6 +116,8 @@
#define FIX_BASOP_2531_MCT_CP_BITRATE                   /* FhG: BASOP issue 2531: Fix MCT cp_bitrate calculation; affects bitrate switching only */
#define FIX_BASOP_2541_OMASA_ENC_FIXES                  /* Nokia: BASOP issue 2541: Fix function ivas_encode_masaism_metadata_fx */
#define FIX_BASOP_2545_FIX_LTV_REGRESSION_2529          /* Nokia: BASOP issue 2545: Fix LTV regression caused by issue 2529 fix */
#define FIX_FMSW_DEC                                    /* float issue 1542: fix JBM issue in format switching */
#define FIX_FMSW_DEC_2                                  /* float issue 1575: fix crash for format switching when bitsream starts with EVS */

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

+511 −445
Original line number Diff line number Diff line
@@ -144,11 +144,9 @@ ivas_error ivas_dec_get_format_fx(
    test();
    IF( st_ivas->ini_frame > 0 && NE_32( st_ivas->ivas_format, st_ivas->last_ivas_format ) &&
        !( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_ISM_FORMAT ) ) &&
        !( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_FORMAT ) ) )
    {
        !( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_FORMAT ) ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
        IF( Opt_tsm )
        {
        IF( Opt_tsm ){
#endif
            st_ivas->restartNeeded = 1;
    move16();
@@ -199,11 +197,9 @@ ivas_error ivas_dec_get_format_fx(
        }

        test();
            IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) )
            {
        IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
                IF( Opt_tsm )
                {
            IF( Opt_tsm ){
#endif
                st_ivas->restartNeeded = 1;
        move16();
@@ -240,11 +236,9 @@ ivas_error ivas_dec_get_format_fx(
    num_bits_read = add( num_bits_read, SBA_PLANAR_BITS );

    test();
            IF( st_ivas->ini_frame > 0 && NE_16( sba_planar, st_ivas->sba_planar ) )
            {
    IF( st_ivas->ini_frame > 0 && NE_16( sba_planar, st_ivas->sba_planar ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
                IF( Opt_tsm )
                {
        IF( Opt_tsm ){
#endif
            st_ivas->restartNeeded = 1;
    move16();
@@ -268,11 +262,9 @@ ivas_error ivas_dec_get_format_fx(
sba_order = add( sba_order, shl( st_ivas->bit_stream[num_bits_read], 1 ) );

test();
            IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) )
            {
IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
                IF( Opt_tsm )
                {
    IF( Opt_tsm ){
#endif
        st_ivas->restartNeeded = 1;
move16();
@@ -374,11 +366,9 @@ ivas_error ivas_dec_get_format_fx(
    }

    test();
            IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) )
            {
    IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
                IF( Opt_tsm )
                {
        IF( Opt_tsm ){
#endif
            st_ivas->restartNeeded = 1;
    move16();
@@ -410,11 +400,9 @@ ivas_error ivas_dec_get_format_fx(
    st_ivas->ism_mode = ivas_omasa_ism_mode_select_fx( ivas_total_brate, nchan_ism );

    test();
            IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) )
            {
    IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
                IF( Opt_tsm )
                {
        IF( Opt_tsm ){
#endif
            st_ivas->restartNeeded = 1;
    move16();
@@ -442,11 +430,9 @@ ivas_error ivas_dec_get_format_fx(
    nchan_ism = add( add( shl( st_ivas->bit_stream[k - 1], 1 ), st_ivas->bit_stream[k - 2] ), 1 );

    test();
            IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) )
            {
    IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
                IF( Opt_tsm )
                {
        IF( Opt_tsm ){
#endif
            st_ivas->restartNeeded = 1;
    move16();
@@ -487,11 +473,9 @@ ivas_error ivas_dec_get_format_fx(
}

test();
            IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) )
            {
IF( st_ivas->ini_frame > 0 && NE_16( sba_order, st_ivas->sba_order ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
                IF( Opt_tsm )
                {
    IF( Opt_tsm ){
#endif
        st_ivas->restartNeeded = 1;
move16();
@@ -531,11 +515,9 @@ ivas_error ivas_dec_get_format_fx(
    signaled_config = ivas_mc_map_ls_setup_to_output_config_fx( idx );

    test();
            IF( st_ivas->ini_frame > 0 && NE_32( st_ivas->transport_config, signaled_config ) )
            {
    IF( st_ivas->ini_frame > 0 && NE_32( st_ivas->transport_config, signaled_config ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
                IF( Opt_tsm )
                {
        IF( Opt_tsm ){
#endif
            st_ivas->restartNeeded = 1;
    move16();
@@ -647,11 +629,9 @@ ivas_error ivas_dec_get_format_fx(
        k = sub( k, 1 );

        test();
            IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) )
            {
        IF( st_ivas->ini_frame > 0 && NE_16( nchan_ism, st_ivas->nchan_ism ) ){
#ifndef FIX_FLOAT_1539_G192_FORMAT_SWITCH
                IF( Opt_tsm )
                {
            IF( Opt_tsm ){
#endif
                st_ivas->restartNeeded = 1;
        move16();
@@ -1572,7 +1552,12 @@ ivas_error ivas_init_decoder_front(
     * Allocate and initialize Custom loudspeaker layout handle
     *--------------------------------------------------------------------*/

#ifdef FIX_FMSW_DEC
    test();
    IF( st_ivas->hDecoderConfig->Opt_LsCustom && st_ivas->hLsSetupCustom == NULL )
#else
    IF( st_ivas->hDecoderConfig->Opt_LsCustom )
#endif
    {
        IF( EQ_32( ( error = ivas_ls_custom_open_fx( &( st_ivas->hLsSetupCustom ) ) ), IVAS_ERR_OK ) )
        {
@@ -1589,7 +1574,12 @@ ivas_error ivas_init_decoder_front(
     * Allocate and initialize Head-Tracking handle
     *--------------------------------------------------------------------*/

#ifdef FIX_FMSW_DEC
    test();
    IF( st_ivas->hDecoderConfig->Opt_Headrotation && st_ivas->hHeadTrackData == NULL )
#else
    IF( st_ivas->hDecoderConfig->Opt_Headrotation )
#endif
    {
        IF( NE_32( ( error = ivas_headTrack_open_fx( &( st_ivas->hHeadTrackData ) ) ), IVAS_ERR_OK ) )
        {
@@ -1606,7 +1596,12 @@ ivas_error ivas_init_decoder_front(
     * Allocate and initialize external orientation handle
     *--------------------------------------------------------------------*/

#ifdef FIX_FMSW_DEC
    test();
    IF( st_ivas->hDecoderConfig->Opt_ExternalOrientation && st_ivas->hExtOrientationData == NULL )
#else
    IF( st_ivas->hDecoderConfig->Opt_ExternalOrientation )
#endif
    {
        IF( NE_32( ( error = ivas_external_orientation_open_fx( &( st_ivas->hExtOrientationData ), st_ivas->hDecoderConfig->render_num_subframes ) ), IVAS_ERR_OK ) )
        {
@@ -1619,7 +1614,12 @@ ivas_error ivas_init_decoder_front(
     *--------------------------------------------------------------------*/

    test();
#ifdef FIX_FMSW_DEC
    test();
    IF( ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) && st_ivas->hCombinedOrientationData == NULL )
#else
    IF( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation )
#endif
    {
        IF( NE_32( ( error = ivas_combined_orientation_open_fx( &( st_ivas->hCombinedOrientationData ), st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->render_num_subframes ) ), IVAS_ERR_OK ) )
        {
@@ -1637,8 +1637,15 @@ ivas_error ivas_init_decoder_front(
    test();
    test();
    test();
#ifdef FIX_FMSW_DEC
    test();
    IF( ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ||
          ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) && st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) ) &&
        st_ivas->hRenderConfig == NULL )
#else
    IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ||
        ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) && st_ivas->hDecoderConfig->Opt_non_diegetic_pan ) )
#endif
    {
        IF( NE_32( ( error = ivas_render_config_open_fx( &( st_ivas->hRenderConfig ) ) ), IVAS_ERR_OK ) )
        {
@@ -3348,7 +3355,14 @@ void ivas_initialize_handles_dec(
        st_ivas->hCPE[i] = NULL;
    }

#ifdef FIX_FMSW_DEC
    IF( !st_ivas->restartNeeded )
    {
#endif
        st_ivas->bit_stream = NULL;
#ifdef FIX_FMSW_DEC
    }
#endif
    st_ivas->mem_hp20_out_fx = NULL;
    st_ivas->hLimiter = NULL;

@@ -3393,6 +3407,10 @@ void ivas_initialize_handles_dec(
    st_ivas->hMasaIsmData = NULL;
    st_ivas->hSbaIsmData = NULL;

#ifdef FIX_FMSW_DEC
    IF( !st_ivas->restartNeeded )
    {
#endif
        st_ivas->hHeadTrackData = NULL;
        st_ivas->hHrtfTD = NULL;
        st_ivas->hLsSetupCustom = NULL;
@@ -3402,6 +3420,9 @@ void ivas_initialize_handles_dec(
        st_ivas->acousticEnvironmentsCount = 0;
        move16();
        st_ivas->pAcousticEnvironments = NULL;
#ifdef FIX_FMSW_DEC
    }
#endif

    st_ivas->hSplitBinRend = NULL;
    FOR( i = 0; i < MAX_HEAD_ROT_POSES - 1; ++i )
@@ -3429,10 +3450,17 @@ void ivas_initialize_handles_dec(
 *-------------------------------------------------------------------------*/

void ivas_destroy_dec_fx(
#ifdef FIX_FMSW_DEC
    Decoder_Struct **st_ivas_out /* i/o: IVAS decoder handle      */
#else
    Decoder_Struct *st_ivas /* i/o: IVAS decoder handle      */
#endif
)
{
    Word16 i;
#ifdef FIX_FMSW_DEC
    Decoder_Struct *st_ivas = *st_ivas_out;
#endif

    /* CLDFB handles */
    FOR( i = 0; i < MAX_INTERN_CHANNELS; i++ )
@@ -3564,11 +3592,18 @@ void ivas_destroy_dec_fx(
    ivas_ls_setup_conversion_close_fx( &st_ivas->hLsSetUpConversion );

    /* Custom LS configuration handle */
#ifdef FIX_FMSW_DEC
    IF( !st_ivas->restartNeeded )
    {
#endif
        IF( st_ivas->hLsSetupCustom != NULL )
        {
            free( st_ivas->hLsSetupCustom );
            st_ivas->hLsSetupCustom = NULL;
        }
#ifdef FIX_FMSW_DEC
    }
#endif

    /* Mono downmix structure */
    ivas_mono_dmx_renderer_close( &st_ivas->hMonoDmxRenderer );
@@ -3604,6 +3639,13 @@ void ivas_destroy_dec_fx(
    /* HRTF statistics */
    ivas_HRTF_statistics_binary_close_fx( &st_ivas->hHrtfStatistics );

#ifdef FIX_FMSW_DEC
    /* Limiter struct */
    ivas_limiter_close_fx( &( st_ivas->hLimiter ) );

    IF( !st_ivas->restartNeeded )
    {
#endif
        /* Config. Renderer */
        ivas_render_config_close_fx( &( st_ivas->hRenderConfig ) );

@@ -3614,15 +3656,31 @@ void ivas_destroy_dec_fx(
            st_ivas->pAcousticEnvironments = NULL;
        }

#ifndef FIX_FMSW_DEC
        /* Limiter struct */
        ivas_limiter_close_fx( &( st_ivas->hLimiter ) );

#endif
        /* Decoder configuration structure */
        IF( st_ivas->hDecoderConfig != NULL )
        {
            free( st_ivas->hDecoderConfig );
            st_ivas->hDecoderConfig = NULL;
        }
#ifdef FIX_FMSW_DEC
    }
    ELSE
    {
        /* resets in case of format switching */
        st_ivas->nchan_ism = 0;
        st_ivas->ism_mode = ISM_MODE_NONE;
        st_ivas->mc_mode = MC_MODE_NONE;
        st_ivas->sba_dirac_stereo_flag = 0;
        move16();
        move16();
        move16();
        move16();
    }
#endif

    /* TC buffer structure */
    ivas_dec_tc_buffer_close_fx( &st_ivas->hTcBuffer );
@@ -3640,7 +3698,15 @@ void ivas_destroy_dec_fx(
    }

    /* main IVAS handle */
#ifdef FIX_FMSW_DEC
    if ( !st_ivas->restartNeeded )
    {
        free( *st_ivas_out );
        *st_ivas_out = NULL;
    }
#else
    free( st_ivas );
#endif

    return;
}
Loading