From 07db0e13692f60227684ac1118d9fbc84d30ca95 Mon Sep 17 00:00:00 2001 From: Stefan Bayer Date: Wed, 16 Nov 2022 08:11:56 +0100 Subject: [PATCH] reduce static memory in the MDFT FB at the encoder for all non-SPAR/DirAC modes, under define FIX_126_MDFT_FB_STATIC_MEM, active, BE --- lib_com/ivas_fb_mixer.c | 23 ++++++++++++++++++++--- lib_com/options.h | 1 + 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index 53ad90d01f..8e60b4f841 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -186,16 +186,27 @@ ivas_error ivas_FB_mixer_open( frame_len = (int16_t) ( sampling_rate / FRAMES_PER_SEC ); + if ( ( hFbMixer = (IVAS_FB_MIXER_HANDLE) count_malloc( sizeof( IVAS_FB_MIXER_DATA ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); } - if ( ( hFbMixer->pFb = (ivas_filterbank_t *) count_malloc( sizeof( ivas_filterbank_t ) ) ) == NULL ) +#ifdef FIX_126_MDFT_FB_STATIC_MEM + if ( fb_cfg->num_out_chans > 0 ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); +#endif + if ( ( hFbMixer->pFb = (ivas_filterbank_t *) count_malloc( sizeof( ivas_filterbank_t ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for FB mixer encoder" ); + } +#ifdef FIX_126_MDFT_FB_STATIC_MEM } - + else + { + hFbMixer->pFb = NULL; + } +#endif if ( fb_cfg->active_w_mixing == -1 ) { num_chs_alloc = 0; @@ -312,10 +323,13 @@ ivas_error ivas_FB_mixer_open( } else { +#ifndef FIX_126_MDFT_FB_STATIC_MEM int16_t k; +#endif /* ignore all the deeper filter bank stuff for now */ hFbMixer->num_diff_bands = 0; +#ifndef FIX_126_MDFT_FB_STATIC_MEM hFbMixer->pFb->fb_consts.pFilterbank_bins_per_band = NULL; hFbMixer->pFb->fb_consts.pFilterbank_bins_start_offset = NULL; @@ -332,6 +346,7 @@ ivas_error ivas_FB_mixer_open( { hFbMixer->pFb->fb_bin_to_band.pFb_bin_to_band[i] = NULL; } +#endif } hFbMixer->fb_cfg = fb_cfg; @@ -1059,10 +1074,12 @@ static ivas_error ivas_filterbank_setup( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong FB in ivas_filterbank_setup()!" ); } } +#ifndef FIX_126_MDFT_FB_STATIC_MEM else { hFbMixer->pFb->filterbank_num_bands = 0; } +#endif hFbMixer->cross_fade_end_offset = pCfg->fade_len + pCfg->pcm_offset; hFbMixer->cross_fade_start_offset = hFbMixer->cross_fade_end_offset - pCfg->fade_len; diff --git a/lib_com/options.h b/lib_com/options.h index 553d57a755..a9fcac0178 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -155,6 +155,7 @@ #define REMOVE_SID_HARM_LEFTOVERS /* Issue 192: remove leftovers from the SID bitrate harmonization */ #define FIX_MCT_UNINIT_MEM /* Issue 166: Reading of uninitialized memory in TCX range coder */ #define FIX_IGF_NOISE_REPETITION /* Issue 182: fix repetition of same noise in IGF */ +#define FIX_126_MDFT_FB_STATIC_MEM /* Issue 126: reduce static mem consumption of the MDFT FB for non-SBA formats */ /* ################## End DEVELOPMENT switches ######################### */ -- GitLab