diff --git a/lib_com/options.h b/lib_com/options.h index ab964e0b239f9ada96a62962a2a9f53cdf65b8c6..ef31d7758f9770efadc3d0d53962fce02abddd5c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -165,6 +165,8 @@ #define FIX_FLOAT_1560_SVD_NO_OPT_MAX_W_SIGN /* FhG: float issue 1560: Avoid optimizing the division on the result of maxWithSign() with -funsafe-math-optimizations */ #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_ALT /* VA: float issue 1585: alternative fix memory leaks with format switching */ + /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c index b66b8c54adf0cf4cacb3b4dc7d445f5fddbf32a6..a8ef4a43c5bbbffac5191189671897051f524853 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -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; diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 6e117aeaeaf123ad3ec363c5a075790ca9c9b4b8..c3c3252aaed0087ad1cc16764240091c38c4ad1e 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -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 ); diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 577b564508dd8b7216190cfbf891938dbc7bab57..18611feb914ba09edcfb9077a50b8da880f6ae15 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -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 */