Skip to content

External HRTF Useless memory (in Param renderer)

The option to use external HRTF tables (-hrtf ext_table) uses too much unnecessary heap memory: at the initialization, the handles of all binauralizers are allocated though only one is used at a given operating point.

For example, ISM2 rendered to binaural output gives

ivas_HRTF_binary_open()             54 malloc sizeof( TDREND_HRFILT_FiltSet_t )     860 bytes   100%
ivas_HRTF_CRend_binary_open()       97 malloc sizeof( HRTFS_CREND )                  20 bytes   100%
ivas_HRTF_fastconv_binary_open()   143 malloc sizeof( HRTFS_FASTCONV )              592 bytes   100%
ivas_HRTF_parambin_binary_open()   185 malloc sizeof( HRTFS_PARAMBIN )            16080 bytes   100%
ivas_HRTF_statistics_binary_open() 226 malloc sizeof( HRTFS_STATISTICS )             16 bytes    99%

At this operating point, the TD renderer is used while heap memory is allocated for other renderers as well. The most useless memory is allocated for the Parametric renderer.

A solution would be to avoid the allocation of unnecessary handles at all.

Alternatively, the Param. renderer struct definition should be rewritten as:

typedef struct ivas_hrtfs_parambin_struct
{
#ifdef FIX
    float *hrtfShCoeffsRe[BINAURAL_CHANNELS][HRTF_SH_CHANNELS];
    float *hrtfShCoeffsIm[BINAURAL_CHANNELS][HRTF_SH_CHANNELS];

    float *parametricReverberationTimes;
    float *parametricReverberationEneCorrections;
    float *parametricEarlyPartEneCorrection;
#else
    float hrtfShCoeffsRe[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS];
    float hrtfShCoeffsIm[BINAURAL_CHANNELS][HRTF_SH_CHANNELS][HRTF_NUM_BINS];

    float parametricReverberationTimes[CLDFB_NO_CHANNELS_MAX];
    float parametricReverberationEneCorrections[CLDFB_NO_CHANNELS_MAX];
    float parametricEarlyPartEneCorrection[CLDFB_NO_CHANNELS_MAX];
#endif

} HRTFS_PARAMBIN, *HRTFS_PARAMBIN_HANDLE;

which would be in any case beneficial for rendering to other sampling rates than 48 kHz.