This is the bug/patch tracker for Rockbox. Click here for more information.
Quick links: Bugs · Patches · Rockbox frontpage
FS#12077 - No mallocs in libfaad
Attached to Project:
Rockbox
Opened by Andree Buschmann (Buschel) - Friday, 22 April 2011, 04:10 GMT+2
Last edited by Andree Buschmann (Buschel) - Sunday, 24 April 2011, 22:29 GMT+2
Opened by Andree Buschmann (Buschel) - Friday, 22 April 2011, 04:10 GMT+2
Last edited by Andree Buschmann (Buschel) - Sunday, 24 April 2011, 22:29 GMT+2
|
DetailsThe attached patch removes malloc from the libfaad codec. The patch works fine on simulation with several AAC and AAC-HE files. It compiles and links for iPod Video and LogikDax (lowmemory target). No test runs on targets o far.
What has been done: - Replace malloc() with static buffers. - Remove free(). - Set several defines (MAX_CHANNELS, MAX_SYNTAX_ELEMENTS) to reasonable values to limit the memory consumption What needs to be done: - Cleanup (I think one or two arrays might not be needed anymore). - Test and maybe some performance tweaking on targets |
This task depends upon
Closed by Andree Buschmann (Buschel)
Sunday, 24 April 2011, 22:29 GMT+2
Reason for closing: Accepted
Additional comments about closing: Submitted with r29778.
Sunday, 24 April 2011, 22:29 GMT+2
Reason for closing: Accepted
Additional comments about closing: Submitted with r29778.
Interesting option after rework: In apps/aac.c and raac.c there are 2 large IRAM arrays defined which are used set to time_out[] and fb_intermed[] in the decoder. The array used for fb_intermed[] can be moved to the decoder library itself and removed in the codec. The array used for time_out[] is problematic: AAC-decoding needs an array size of [2][1024], AAC-HE needs [2][2048]. This array is significant for speed and should therefor be located in IRAM, but there is only enough IRAM for [2][1024] even on targets with larger amount of IRAM. Current solution: A [2][1024] array (gb_time_buffer) is located in IRAM, an additional [2][2048] array (s_time_buffer) is located in RAM. The codec decides if IRAM or RAM can be used. As a result the decoder has [2][1024] = 8 KB of unused IRAM when decoding AAC-HE.
Possible solution: Define generic buffer in IRAM (similar to what malloc did) and decide how to use it depending on AAC/AAC-HE.
- Declare qmfs/qmfa direclty in sbr-type, do not use static declarations for those arrays anymore.
- Remove all unneeded _init() and _free() functions.
- Add formerly unused NeAACDecPostSeekReset() to apps/codecs/aac.c
Reason for this is that static allocation of those arrays will use this memory always. For AAC-LC files this memory is wasted and will reduce the amount of memory available for m4a tables. This might impact the maximum length of files to be able to play.
Only exception: XLR fits into IRAM, in this case always allocate statically. The advantage in speed is ~10 MHz on a nano 2G.