knik0 / faac

Freeware Advanced Audio Coder faac mirror
https://sourceforge.net/projects/faac/
Other
180 stars 60 forks source link

Memory allocations redefined #27

Closed krabiswabbie closed 5 years ago

krabiswabbie commented 5 years ago

Here is the replacement of the memory allocation method. In this function, the value of the parameter N can be either 2 BLOCK_LEN_SHORT or 2 BLOCK_LEN_LONG. Since the function is called quite often, we can avoid frequent memory allocations using static buffers of the maximum required size. In tests, this simple replacement gives a 2-3% performance gain.

fabiangreffrath commented 5 years ago

Couldn't we even get away with [BLOCK_LEN_LONG/2] then?

I mean, (N >> 2) divides by 4 and if N is at most 2 * BLOCK_LEN_LONG then the array needs to be at most of size BLOCK_LEN_LONG/2, right?

krabiswabbie commented 5 years ago

You're absolutely correct here :) This is exactly what I wanted to say :)