From cab4983cb9853dae2f720c59109eabe8253da09d Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 12 Dec 2022 09:08:33 +0100 Subject: [PATCH] fix Issue 78: compute consumption of Stack memory in DirAC decoder as intra-frame heap; under INTRAFRAME_HEAP_MANAGEMENT --- lib_com/options.h | 3 +++ lib_dec/ivas_dirac_dec.c | 13 ++++++++++++- lib_dec/ivas_stat_dec.h | 3 ++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 2011fb56b4..953e1e4de5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -164,6 +164,9 @@ #define FIX_ITD_CNG /* Eri: Fix for CNG ITD */ +#define INTRAFRAME_HEAP_MANAGEMENT /* Issue 78: compute consumption of Stack memory in DirAC decoder as intra-frame heap */ + + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ #endif diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index f2273de26d..c143557744 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -759,12 +759,14 @@ ivas_error ivas_dirac_dec_config( /* output synthesis */ ivas_dirac_dec_output_synthesis_init( hDirAC, nchan_out_woLFE ); +#ifndef INTRAFRAME_HEAP_MANAGEMENT /* Allocate stack memory */ if ( flag_config != DIRAC_OPEN ) { ivas_dirac_free_mem( &( hDirAC->stack_mem ) ); } ivas_dirac_alloc_mem( hDirAC, st_ivas->renderer_type, &( hDirAC->stack_mem ) ); +#endif mvs2s( DirAC_block_grouping, hDirAC->block_grouping, MAX_PARAM_SPATIAL_SUBFRAMES + 1 ); @@ -1090,8 +1092,9 @@ void ivas_dirac_dec_close( hDirAC->masa_stereo_type_detect = NULL; } +#ifndef INTRAFRAME_HEAP_MANAGEMENT ivas_dirac_free_mem( &( hDirAC->stack_mem ) ); - +#endif count_free( hDirAC ); return; @@ -1827,7 +1830,11 @@ void ivas_dirac_dec( /* Initialize aux buffers */ hDirAC = st_ivas->hDirAC; +#ifdef INTRAFRAME_HEAP_MANAGEMENT + ivas_dirac_alloc_mem( hDirAC, st_ivas->renderer_type, &DirAC_mem ); +#else DirAC_mem = st_ivas->hDirAC->stack_mem; +#endif reference_power = DirAC_mem.reference_power; reference_power_smooth = DirAC_mem.reference_power + hDirAC->num_freq_bands; @@ -2495,6 +2502,10 @@ void ivas_dirac_dec( } } +#ifdef INTRAFRAME_HEAP_MANAGEMENT + ivas_dirac_free_mem( &DirAC_mem ); +#endif + wmops_sub_end(); return; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index a18f826921..6ffadde3a0 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -704,8 +704,9 @@ typedef struct ivas_dirac_dec_data_structure float *proto_frame_f; float *proto_frame_dec_f; +#ifndef INTRAFRAME_HEAP_MANAGEMENT DIRAC_DEC_STACK_MEM stack_mem; - +#endif MASA_STEREO_TYPE_DETECT *masa_stereo_type_detect; int16_t num_ele_spk_no_diffuse_rendering; -- GitLab