From 802c3b710cb45cfaecd7aeaea2523bf6bb0243fc Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Mon, 24 Oct 2022 11:21:59 +0200 Subject: [PATCH 1/2] small optimization for ALLRAD memory allocation --- lib_com/options.h | 1 + lib_dec/ivas_allrad_dec.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index b988fcb581..ab48e7d68a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -152,6 +152,7 @@ #define FIX_155_HP20_ISSUE /* Issue 155: apply hp20 on all input channels instead of just 2 channels */ #define EFAP_FIX_POLY /* Issue 167: fix bug in EFAP polygon selection */ #define SBA_HOA_HBR_IMPROV /* issue 91: Improvements to SBA high bitrate HOA3 coding */ +#define ALLRAD_OPTIM /* Issue 159: Optimize memory allocation for ALLRAD */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_allrad_dec.c b/lib_dec/ivas_allrad_dec.c index d4301c07ac..ee1d1d1b72 100644 --- a/lib_dec/ivas_allrad_dec.c +++ b/lib_dec/ivas_allrad_dec.c @@ -108,7 +108,11 @@ ivas_error ivas_sba_get_hoa_dec_matrix( /* Allocate memory */ assert( *hoa_dec_mtx == NULL && "hoa_dec_mtx != NULL" ); +#ifdef ALLRAD_OPTIM + if ( ( *hoa_dec_mtx = (float *) count_malloc( SBA_NHARM_HOA3 * ( hOutSetup.nchan_out_woLFE + hOutSetup.num_lfe ) * sizeof( float ) ) ) == NULL ) +#else if ( ( *hoa_dec_mtx = (float *) count_malloc( SBA_NHARM_HOA3 * MAX_OUTPUT_CHANNELS * sizeof( float ) ) ) == NULL ) +#endif { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "ALLRAD: Cannot allocate memory!" ) ); } -- GitLab From d2cb29a387219df8661646f584b2a3046d3ab25d Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Mon, 24 Oct 2022 11:49:27 +0200 Subject: [PATCH 2/2] small changes -allocation for LFE channel not needed, slightly reduce EFAP memory usage too (cannot have more than 16 output loudspeakers) --- lib_com/ivas_cnst.h | 4 ++++ lib_dec/ivas_allrad_dec.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 7d84adbb12..0512cf27e6 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1319,7 +1319,11 @@ typedef enum #define PANNING_ELE_RESOLUTION 5 #define EFAP_MAX_CHAN_NUM 5 /* Maximum number of channels that constitute a polygon, 4 or 5 */ +#ifdef ALLRAD_OPTIM +#define EFAP_MAX_POLY_SET 50 /* Upper bound on number of polygons; with a Speaker setup of 16.0, we obtain 44 polygons/triangles in the matlab implementation. */ +#else #define EFAP_MAX_POLY_SET 70 /* Upper bound on number of polygons; with a Speaker setup of 26.0, we obtain 54 polygons/triangles in the matlab implementation. */ +#endif #define EFAP_MODE_EFAP 0 /* EFAP Panning */ #define EFAP_MODE_EFIP 1 /* EFIP Panning */ diff --git a/lib_dec/ivas_allrad_dec.c b/lib_dec/ivas_allrad_dec.c index ee1d1d1b72..13e4f3c241 100644 --- a/lib_dec/ivas_allrad_dec.c +++ b/lib_dec/ivas_allrad_dec.c @@ -109,7 +109,7 @@ ivas_error ivas_sba_get_hoa_dec_matrix( /* Allocate memory */ assert( *hoa_dec_mtx == NULL && "hoa_dec_mtx != NULL" ); #ifdef ALLRAD_OPTIM - if ( ( *hoa_dec_mtx = (float *) count_malloc( SBA_NHARM_HOA3 * ( hOutSetup.nchan_out_woLFE + hOutSetup.num_lfe ) * sizeof( float ) ) ) == NULL ) + if ( ( *hoa_dec_mtx = (float *) count_malloc( SBA_NHARM_HOA3 * ( hOutSetup.nchan_out_woLFE ) * sizeof( float ) ) ) == NULL ) #else if ( ( *hoa_dec_mtx = (float *) count_malloc( SBA_NHARM_HOA3 * MAX_OUTPUT_CHANNELS * sizeof( float ) ) ) == NULL ) #endif -- GitLab