Wiki > Main > CodecMemoryUsage (compare)
Difference: CodecMemoryUsage (r18 vs. r17)
This page is for documenting the memory usage of Rockbox codecs, with a view to reducing the size of the codec buffer (the amount of memory reserved for codecs).
Once this page starts to get populated, and we know what information is important, we should perhaps change to a table format.
The following graphic displays the memory layout for all codecs. The measurement has been done with a iPod Video build. I have manually added the dynamic memory allocation for AAC-HE files. Not visible is the dynamic amount of memory which is consumed by the m4a seek table (aac, alac), ape and vorbis. Those can additionally allocate up to several hundreds KB depending on the files.
Since a rework malloc() is only used by libm4a and when decoding AAC-HE (SBR, PS). AAC-HE can be compiled with FAAD_STATIC_ALLOC to use static buffers only. AAC-LC generally uses static buffers. Under rockbox AAC-HE is only build for targets with CODEC_SIZE >= 512 KB.
Measured memory usage in bytes on iPod Video (PP5022) when compiled for AAC-LC, AAC-HE (SBR) and AAC-HE (SBR+PS) based on r30514:
libm4a is used for container parsing. Depending on the type of file and its duration the additionally required amount of memory easily reaches several hundred KB.
No malloc() use. Uses libm4a for container parsing.
Uses malloc() for seek table.
No malloc() use. Seektable stored in a static array, containing a maximum of 5000 seekpoints. Each array element is 10 bytes (padded to 12 bytes on ARM for alignment) - a total of 60000 bytes. In the case of a file with more than 5000 seekpoints, the codec will just store the first 5000, with the effect that seeking in later parts of the file will be slightly slower (but still functional) - seekpoints aren't required for seeking, they just provide clues to help seek faster. In reality, files are likely to have far fewer seekpoints - see discussion in comments at top of apps/codecs/flac.c
Codec has a few malloc(), but none are used in Rockbox.
No malloc() use. A fixed size seek table uses 8192 entries whereas each entry by default represents one frame. If a file has more than 8192 frames the time resolution of the seek table is reduced to cover the whole file length (e.g. 4 frames per entry).
The Ogg framing code uses malloc(). The codec code itself has malloc(), but none are used in Rockbox.
Uses malloc() everywhere. Memory usage varies widely between encoders and bitrates (differences of 500KB+ are possible). Removing malloc() is not feasible given how the format works.
r18 - 03 May 2012 - 18:33:10 - MichaelGiacomelliRevision r18 - 03 May 2012 - 18:33 - MichaelGiacomelli
Revision r17 - 19 Dec 2011 - 20:49 - AndreeBuschmann
Copyright © by the contributing authors.