dev builds
themes manual
device status forums
mailing lists
IRC bugs
dev guide

Search | Go
Wiki > Main > SoundCodecs > CodecMemoryUsage (r15)

Codec Memory Usage


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.

Overview of codec memory consumption

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.


Details about codec memory layout


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 nano 2G when compiled for AAC-LC only and when incluing SBR+PS (r29864):
Profile IRAM IBSS BSS Text malloc total
AAC-HE (SBR+PS) 41.600 77.824 68.664 161.872 123.468 462 KB
AAC-LC 38.144 38.912 43.556 80.880 0 197 KB

On an iPod Video the memory usage looks different due to a different IRAM/DRAM configuration (r29864):
Profile IRAM IBSS BSS Text malloc total
AAC-HE (SBR+PS) 41.600 38.912 68.672 163.888 162.324 464 KB
AAC-LC 38.144 38.912 43.568 80.928 0 197 KB

libm4a is used for container parsing. Depending on the type of file and its duration the 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

MPEG Audio

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.

Support code


Uses malloc() for the seek tables. Depending on the files the seek tables may require up to several hundred KB.
Edit | Attach | Print version | History: r18 | r16 < r15 < r14 < r13 | Backlinks | View wiki text | More topic actions...
r15 - 18 Aug 2011 - 21:54:48 - AndreeBuschmann

Parents: SoundCodecs
Copyright by the contributing authors.