Commit b027ec60 authored by vaclav's avatar vaclav
Browse files

fix Issue 98: do the setting of all handles to NULL in one place; under FIX_I98_HANDLES_TO_NULL

parent ccf6ae2f
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -352,10 +352,11 @@ void ivas_destroy_dec(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                  */
);

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

#endif
ivas_error ivas_core_enc(
    SCE_ENC_HANDLE hSCE,                                                     /* i/o: SCE encoder structure                   */
    CPE_ENC_HANDLE hCPE,                                                     /* i/o: CPE encoder structure                   */
+1 −1
Original line number Diff line number Diff line
@@ -149,7 +149,7 @@
#define FIX_ADAP_STEFI_SHIFT                            /* Issue 89: fix bug in parameter shift of adaptive stereo filling */
#define SPAR_SCALING_HARMONIZATION                      /* Issue 80: Changes to harmonize scaling in spar */
#define FIX_I2_BWD                                      /* Issue 2: BWD fix to more quickly react to WB -> SWB/FB change */ 

#define FIX_I98_HANDLES_TO_NULL                         /* Issue 98: do the setting of all handles to NULL in one place */

/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */
+86 −8
Original line number Diff line number Diff line
@@ -508,9 +508,79 @@ ivas_error ivas_init_decoder_front(
)
{
    ivas_error error;
#ifdef FIX_I98_HANDLES_TO_NULL
    int16_t i;
#endif

    error = IVAS_ERR_OK;

#ifdef FIX_I98_HANDLES_TO_NULL
    /*-----------------------------------------------------------------*
     * Dummy pointers to decoder handles
     *-----------------------------------------------------------------*/

    /* SCE handles */
    for ( i = 0; i < MAX_SCE; i++ )
    {
        st_ivas->hSCE[i] = NULL;
    }

    /* CPE handles */
    for ( i = 0; i < MAX_CPE; i++ )
    {
        st_ivas->hCPE[i] = NULL;
    }

    st_ivas->mem_hp20_out = NULL;
    st_ivas->hLimiter = NULL;

    /* CLDFB handles */
    for ( i = 0; i < MAX_INTERN_CHANNELS; i++ )
    {
        st_ivas->cldfbAnaDec[i] = NULL;
    }

    for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ )
    {
        st_ivas->cldfbSynDec[i] = NULL;
    }

    /* ISM metadata handles */
    for ( i = 0; i < MAX_NUM_OBJECTS; i++ )
    {
        st_ivas->hIsmMetaData[i] = NULL;
    }

    /* spatial coding handles */    
    st_ivas->hDirAC = NULL;
    st_ivas->hSpar = NULL;
    st_ivas->hMasa = NULL;
    st_ivas->hQMetaData = NULL;
    st_ivas->hMCT = NULL;
    st_ivas->hParamMC = NULL;
    st_ivas->hLFE = NULL;

    /* rendering handles */
    st_ivas->hBinRenderer = NULL;
    st_ivas->hDiracDecBin = NULL;
    st_ivas->hLsSetUpConversion = NULL;
    st_ivas->hEFAPdata = NULL;
    st_ivas->hVBAPdata = NULL;
    st_ivas->hIsmRendererData = NULL;
    st_ivas->hBinRendererTd = NULL;
    st_ivas->hMonoDmxRenderer = NULL;
    st_ivas->hIsmRendererData = NULL;
    st_ivas->hCrend = NULL;
    st_ivas->hHrtf = NULL;
    st_ivas->hoa_dec_mtx = NULL;

    /* external data handles */
    st_ivas->hHeadTrackData = NULL;
    st_ivas->hHrtfTD = NULL;
    st_ivas->hLsSetupCustom = NULL;
    st_ivas->hRenderConfig = NULL;
#endif

    /*-----------------------------------------------------------------*
     * Resets
     *-----------------------------------------------------------------*/
@@ -679,6 +749,7 @@ ivas_error ivas_init_decoder(
        }
    }

#ifndef FIX_I98_HANDLES_TO_NULL
#if 0
    /*-----------------------------------------------------------------*
     * Dummy pointers to decoder handles
@@ -732,7 +803,7 @@ ivas_error ivas_init_decoder(
    st_ivas->hHrtf = NULL;              /* Crend hrtf data */
    st_ivas->hCrend = NULL;             /* Crend renderer */
#endif

#endif
    /*-----------------------------------------------------------------*
     * Allocate and initalize SCE/CPE and other handles
     *-----------------------------------------------------------------*/
@@ -1469,7 +1540,7 @@ void destroy_core_dec(
    return;
}


#ifndef FIX_I98_HANDLES_TO_NULL
/*-------------------------------------------------------------------------
 * ivas_initialize_handles_dec()
 *
@@ -1545,7 +1616,7 @@ void ivas_initialize_handles_dec(

    return;
}

#endif

/*-------------------------------------------------------------------------
 * ivas_destroy_dec()
@@ -2015,11 +2086,18 @@ static ivas_error doSanityChecks_IVAS(
#endif

#ifdef DEBUGGING
#ifdef FIX_I98_HANDLES_TO_NULL
    if ( ( st_ivas->hDecoderConfig->Opt_HRTF_binary || st_ivas->hDecoderConfig->force_rend == FORCE_TD_RENDERER ) && ( ( st_ivas->ivas_format != MC_FORMAT && st_ivas->ivas_format != ISM_FORMAT ) || output_config != AUDIO_CONFIG_BINAURAL || ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM ) || ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode != MC_MODE_MCT ) ) )
#else
    if ( ( st_ivas->hHrtfTD != NULL || st_ivas->hDecoderConfig->force_rend == FORCE_TD_RENDERER ) && ( ( st_ivas->ivas_format != MC_FORMAT && st_ivas->ivas_format != ISM_FORMAT ) || output_config != AUDIO_CONFIG_BINAURAL || ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM ) || ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode != MC_MODE_MCT ) ) )
#endif
#else
#ifdef FIX_I98_HANDLES_TO_NULL
    if ( st_ivas->hDecoderConfig->Opt_HRTF_binary && ( ( st_ivas->ivas_format != MC_FORMAT && st_ivas->ivas_format != ISM_FORMAT ) || output_config != AUDIO_CONFIG_BINAURAL || ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM ) ) )
#else
    if ( st_ivas->hHrtfTD != NULL && ( ( st_ivas->ivas_format != MC_FORMAT && st_ivas->ivas_format != ISM_FORMAT ) || output_config != AUDIO_CONFIG_BINAURAL || ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM ) ) )
#endif

#endif
    {
        return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Incorrect output configuration: Time Domain object renderer not supported in this configuration" );
    }
+4 −1
Original line number Diff line number Diff line
@@ -146,8 +146,10 @@ ivas_error IVAS_DEC_Open(
    hIvasDec->prev_ft_speech = 1; /* RXDTX handeler previous frametype flag for G.192 format AMRWB SID_FIRST detection */
    hIvasDec->CNG = 0;            /* RXDTX handler CNG = 1, no CNG = 0*/

#ifndef FIX_I98_HANDLES_TO_NULL
    /* initialize pointers to handles */
    ivas_initialize_handles_dec( hIvasDec->st_ivas );
#endif

    /* high-level set parameters */
    if ( mode == IVAS_DEC_MODE_EVS )
@@ -252,6 +254,7 @@ void IVAS_DEC_Close(
            ( *phIvasDec )->st_ivas->hDecoderConfig = NULL;
        }

#ifndef FIX_I98_HANDLES_TO_NULL
        if ( ( *phIvasDec )->st_ivas->hHeadTrackData != NULL )
        {
            count_free( ( *phIvasDec )->st_ivas->hHeadTrackData );
@@ -261,7 +264,7 @@ void IVAS_DEC_Close(
        ivas_render_config_close( &( ( *phIvasDec )->st_ivas->hRenderConfig ) );

        ivas_HRTF_binary_close( &( *phIvasDec )->st_ivas->hHrtfTD );

#endif
        count_free( ( *phIvasDec )->st_ivas );
    }