diff --git a/lib_com/options.h b/lib_com/options.h index e430017666666a03da3c22ffec050405920bf95d..cccc1dc2aaee11f5cc09a9e639dbeb8fb4c08d90 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -112,6 +112,7 @@ #define FIX_2095_REMOVE_UNUSED_ISAR_TABLES /* Dolby: remove unused ISAR */ #define FIX_BASOP_2560_STEREO_DFT_DEC_RESET /* FhG: BASOP issue 2560: align reset of hStereoDft->res_gains_ind_fx[][] between BASOP and float */ #define HARMONIZE_2539_cng_energy /* FhG: basop issue 2539: harmonize cng_energy with its ivas derivate */ +#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_fx.c b/lib_dec/ivas_corecoder_dec_reconfig_fx.c index 6e6ac9d3545b46c15e39f4baf6d60a8ce62f7ce3..670f559d242e2c27b59a9a43d53d832d9817b8d9 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig_fx.c +++ b/lib_dec/ivas_corecoder_dec_reconfig_fx.c @@ -477,7 +477,9 @@ ivas_error ivas_hp20_dec_reconfig_fx( ) { Word16 i, nchan_hp20; +#ifndef FIX_1585_ASAN_FORMAT_SW_ALT Word32 **old_mem_hp20_out_fx; +#endif ivas_error error; error = IVAS_ERR_OK; @@ -491,6 +493,18 @@ ivas_error ivas_hp20_dec_reconfig_fx( IF( GT_16( 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_fx[i] = (Word32 *) malloc( ( L_HP20_MEM + 2 ) * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); + } + + set32_fx( st_ivas->mem_hp20_out_fx[i], 0, L_HP20_MEM + 2 ); + } +#else /* save old mem_hp_20 pointer */ old_mem_hp20_out_fx = st_ivas->mem_hp20_out_fx; st_ivas->mem_hp20_out_fx = NULL; @@ -519,9 +533,18 @@ ivas_error ivas_hp20_dec_reconfig_fx( free( old_mem_hp20_out_fx ); old_mem_hp20_out_fx = NULL; +#endif } ELSE IF( LT_16( 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_fx[i] ); + st_ivas->mem_hp20_out_fx[i] = NULL; + } +#else /* save old mem_hp_20 pointer */ old_mem_hp20_out_fx = st_ivas->mem_hp20_out_fx; st_ivas->mem_hp20_out_fx = NULL; @@ -546,6 +569,7 @@ ivas_error ivas_hp20_dec_reconfig_fx( free( old_mem_hp20_out_fx ); old_mem_hp20_out_fx = NULL; +#endif } return error; diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 355051ccbc492dc1cf434333faa69253367e23ac..fd440677bb80e1dac0256a39c5863f83122e0f1d 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -2743,6 +2743,7 @@ ivas_error ivas_init_decoder_fx( /* 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_fx = (Word32 **) malloc( n * sizeof( Word32 * ) ) ) == NULL ) @@ -2754,7 +2755,7 @@ ivas_error ivas_init_decoder_fx( { st_ivas->mem_hp20_out_fx = NULL; } - +#endif FOR( i = 0; i < n; i++ ) { IF( ( st_ivas->mem_hp20_out_fx[i] = (Word32 *) malloc( ( L_HP20_MEM + 2 ) * sizeof( Word32 ) ) ) == NULL ) @@ -2764,6 +2765,13 @@ ivas_error ivas_init_decoder_fx( set32_fx( st_ivas->mem_hp20_out_fx[i], 0, L_HP20_MEM + 2 ); } +#ifdef FIX_1585_ASAN_FORMAT_SW_ALT + FOR( ; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) + { + st_ivas->mem_hp20_out_fx[i] = NULL; + } +#endif + /*-------------------------------------------------------------------* * Allocate and initialize rendering handles *--------------------------------------------------------------------*/ @@ -3383,7 +3391,9 @@ void ivas_initialize_handles_dec( #ifdef FIX_FMSW_DEC } #endif +#ifndef FIX_1585_ASAN_FORMAT_SW_ALT st_ivas->mem_hp20_out_fx = NULL; +#endif st_ivas->hLimiter = NULL; /* ISM metadata handles */ @@ -3527,6 +3537,16 @@ void ivas_destroy_dec_fx( } /* 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_fx[i] != NULL ) + { + free( st_ivas->mem_hp20_out_fx[i] ); + st_ivas->mem_hp20_out_fx[i] = NULL; + } + } +#else IF( st_ivas->mem_hp20_out_fx != NULL ) { FOR( i = 0; i < getNumChanSynthesis( st_ivas ); i++ ) @@ -3537,6 +3557,7 @@ void ivas_destroy_dec_fx( free( st_ivas->mem_hp20_out_fx ); st_ivas->mem_hp20_out_fx = 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 2994d56aa50576de3f4ebcbc7789d652c4aba6fc..b3c75cb3c8238b8efd57250c74777ad6919eccfd 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1119,7 +1119,11 @@ typedef struct Decoder_Struct UWord16 *bit_stream; /* Pointer to bitstream buffer */ Word16 writeFECoffset; /* parameter for debugging JBM stuff */ +#ifdef FIX_1585_ASAN_FORMAT_SW_ALT + Word32 *mem_hp20_out_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* output signals HP filter memories */ +#else Word32 **mem_hp20_out_fx; /* output signals HP filter memories */ +#endif IVAS_LIMITER_HANDLE hLimiter; /* Limiter handle */ /* core-decoder modules */