Move audio channels memory from stack to heap
This ticket intends to discuss a proposal to move audio channels memory from stack to heap.
Currently, the allocated memory related to input/output audio channels equals to the maximum of input/output channels in the framework, i.e. 16, and allocated on the stack. There is a number of IVAS_fmToDo
comments in the framework that questions whether these memories should not be moved to the intra-frame heap and allocated dynamically. In turn, only a necessary memory related to the number of actually used channels would be allocated and thus the overall codec RAM usage would be lowered.
So far, the WMC tool was not able to measure the intra-frame heap, i.e. memory allocated by malloc()
and deallocated by free()
at every frame. With the new WMC tool, this feature is now available.
The related buffers are
ivas_enc()
{
float data_f[MAX_INPUT_CHANNELS][L_FRAME48k]; /* IVAS_fmToDo: buffer can be allocated dynamically based on the number of analysed channels */
...
ivas_dec()
{
float output[MAX_OUTPUT_CHANNELS][L_FRAME48k]; /* 'float' buffer for output synthesis, MAX_OUTPUT_CHANNELS channels */ /* IVAS_fmToDo: buffer can be allocated dynamically based on the actual number of output channels */
...
On the other hand, the renderer now uses a logic where the input/output data buffers are allocated on the heap using the inter-frame heap memory
inBufferSize = frameSize_smpls * totalNumInChannels;
outBufferSize = frameSize_smpls * numOutChannels;
inpInt16Buffer = count_malloc( inBufferSize * sizeof( int16_t ) );
inFloatBuffer = count_malloc( inBufferSize * sizeof( float ) );
outInt16Buffer = count_malloc( outBufferSize * sizeof( int16_t ) );
outFloatBuffer = count_malloc( outBufferSize * sizeof( float ) );
which is not optimal as these buffers could be allocated on intra-frame heap.
Note: a similar discussion concerns changes proposed in #78 (closed) and the JBM functionality proposal.