Commit 6e811bd5 authored by vaclav's avatar vaclav
Browse files

FIX_1585_ASAN_FORMAT_SW_ALT

parent 26573750
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -166,6 +166,8 @@
#define FIX_2095_REMOVE_UNUSED_ISAR_TABLES              /* Dolby: remove unused ISAR */
#define FIX_FLOAT_1582_STEREO_DFT_QUANTIZE_ITD          /* FhG: float issue 1582: Remove unncessary statement from stereo_dft_quantize_itd() */
#define FIX_1585_ASAN_FORMAT_SW                         /* VA: float issue 1585: fix memory leaks with format switching */
#define FIX_1585_ASAN_FORMAT_SW_ALT                     /* VA: float issue 1585: alternative fix memory leaks with format switching */


/* #################### End BE switches ################################## */

+24 −0
Original line number Diff line number Diff line
@@ -381,7 +381,9 @@ ivas_error ivas_hp20_dec_reconfig(
)
{
    int16_t i, nchan_hp20;
#ifndef FIX_1585_ASAN_FORMAT_SW_ALT
    float **old_mem_hp20_out;
#endif
    ivas_error error;

    error = IVAS_ERR_OK;
@@ -394,6 +396,18 @@ ivas_error ivas_hp20_dec_reconfig(

    if ( nchan_hp20 > nchan_hp20_old )
    {
#ifdef FIX_1585_ASAN_FORMAT_SW_ALT
        /* create additional hp20 memories */
        for ( i = nchan_hp20_old; i < nchan_hp20; i++ )
        {
            if ( ( st_ivas->mem_hp20_out[i] = (float *) malloc( L_HP20_MEM * sizeof( float ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) );
            }

            set_f( st_ivas->mem_hp20_out[i], 0.0f, L_HP20_MEM );
        }
#else
        /* save old mem_hp_20 pointer */
        old_mem_hp20_out = st_ivas->mem_hp20_out;
        st_ivas->mem_hp20_out = NULL;
@@ -421,9 +435,18 @@ ivas_error ivas_hp20_dec_reconfig(

        free( old_mem_hp20_out );
        old_mem_hp20_out = NULL;
#endif
    }
    else if ( nchan_hp20 < nchan_hp20_old )
    {
#ifdef FIX_1585_ASAN_FORMAT_SW_ALT
        /* remove superfluous hp20 memories */
        for ( i = nchan_hp20; i < nchan_hp20_old; i++ )
        {
            free( st_ivas->mem_hp20_out[i] );
            st_ivas->mem_hp20_out[i] = NULL;
        }
#else
        /* save old mem_hp_20 pointer */
        old_mem_hp20_out = st_ivas->mem_hp20_out;
        st_ivas->mem_hp20_out = NULL;
@@ -447,6 +470,7 @@ ivas_error ivas_hp20_dec_reconfig(

        free( old_mem_hp20_out );
        old_mem_hp20_out = NULL;
#endif
    }

    return error;
+22 −1
Original line number Diff line number Diff line
@@ -2304,6 +2304,7 @@ ivas_error ivas_init_decoder(
    /* set number of output channels used for synthesis/decoding */
    n = getNumChanSynthesis( st_ivas );

#ifndef FIX_1585_ASAN_FORMAT_SW_ALT
    if ( n > 0 )
    {
        if ( ( st_ivas->mem_hp20_out = (float **) malloc( n * sizeof( float * ) ) ) == NULL )
@@ -2315,7 +2316,7 @@ ivas_error ivas_init_decoder(
    {
        st_ivas->mem_hp20_out = NULL;
    }

#endif
    for ( i = 0; i < n; i++ )
    {
        if ( ( st_ivas->mem_hp20_out[i] = (float *) malloc( L_HP20_MEM * sizeof( float ) ) ) == NULL )
@@ -2326,6 +2327,13 @@ ivas_error ivas_init_decoder(
        set_f( st_ivas->mem_hp20_out[i], 0.0f, L_HP20_MEM );
    }

#ifdef FIX_1585_ASAN_FORMAT_SW_ALT
    for ( ; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ )
    {
        st_ivas->mem_hp20_out[i] = NULL;
    }
#endif

    /*-------------------------------------------------------------------*
     * Allocate and initialize rendering handles
     *--------------------------------------------------------------------*/
@@ -2822,7 +2830,9 @@ void ivas_initialize_handles_dec(
#ifdef FIX_FMSW_DEC
    }
#endif
#ifndef FIX_1585_ASAN_FORMAT_SW_ALT
    st_ivas->mem_hp20_out = NULL;
#endif
    st_ivas->hLimiter = NULL;

    /* ISM metadata handles */
@@ -2964,6 +2974,16 @@ void ivas_destroy_dec(
    }

    /* HP20 filter handles */
#ifdef FIX_1585_ASAN_FORMAT_SW_ALT
    for ( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ )
    {
        if( st_ivas->mem_hp20_out[i] != NULL )
        {
            free( st_ivas->mem_hp20_out[i] );
            st_ivas->mem_hp20_out[i] = NULL;
        }
    }
#else
    if ( st_ivas->mem_hp20_out != NULL )
    {
        for ( i = 0; i < getNumChanSynthesis( st_ivas ); i++ )
@@ -2974,6 +2994,7 @@ void ivas_destroy_dec(
        free( st_ivas->mem_hp20_out );
        st_ivas->mem_hp20_out = NULL;
    }
#endif

    /* ISM metadata handles */
    ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 );
+4 −0
Original line number Diff line number Diff line
@@ -1054,7 +1054,11 @@ typedef struct Decoder_Struct
    uint16_t *bit_stream;                                   /* Pointer to bitstream buffer */
    int16_t writeFECoffset;                                 /* parameter for debugging JBM stuff */

#ifdef FIX_1585_ASAN_FORMAT_SW_ALT
    float *mem_hp20_out[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* output signals HP filter memories */
#else
    float **mem_hp20_out;                                   /* output signals HP filter memories */
#endif
    IVAS_LIMITER_HANDLE hLimiter;                           /* Limiter handle */

    /* core-decoder modules */