Rockbox

Tasklist

FS#6357 - Changes in codecs memory layout

Attached to Project: Rockbox
Opened by Tomasz Malesinski (tmal) - Sunday, 19 November 2006, 20:45 GMT
Last edited by Nils Wallménius (nls) - Monday, 25 October 2010, 09:45 GMT
Task Type Patches
Category Codecs
Status Closed
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

I attach three patches which change codecs memory layout and save some memory. iFP port doesn't work well yet, so I can't test them throughly. I'll be happy if someone tests them on a better supported target.

The first one puts iramcopy area and bss in the same place. Currently a copy of IRAM data in codecbuf has its own space, which is simply wasted after codec initialization. It also moves memory initialization (copying data to IRAM and cleaning bss) to a separate file codec_crt0.c. Only one variable storing a pointer to codec_api left, it is defined in codec_crt0.c too. Please test in particular if playing two files in sequence in the same and different formats work.

The second patch moves the malloc buffer from audio buffer to a free space at the end of the codec buffer. If it happens that the biggest codec in terms of code size is not the most malloc buffer hungry then we could reduce the total amount of memory spent on malloc and codec buffer. The CODEC_SIZE macro should now include the codec buffer size and malloc buffer size. I did not increase it, but it may be required.

The third patch implements a simple allocator for the vorbis decoder which allows temporary mallocs. The ogg_malloc function works as before, allocating blocks from the beginning of the malloc buffer and without the possibility to free them. The ogg_tmpmalloc allocates blocks from the other side of the malloc buffer. A sequence of most recently allocated blocks may be freed in this case. This removes the need for big static buffers which don't fit in iFP memory.

This task depends upon

Closed by  Nils Wallménius (nls)
Monday, 25 October 2010, 09:45 GMT
Reason for closing:  Accepted
Additional comments about closing:  one of these patches were committed long ago and the others have been superceded by changes in svn.
Comment by Tomasz Malesinski (tmal) - Tuesday, 21 November 2006, 07:53 GMT
I include the second patch with CODEC_SIZE increased for all targets by 512 kB (the size of the original malloc buffer). In the current version of Rockbox it would unnecessarily enlarge the swap buffers for voice support. We could, however, implement the idea of a voice codec linked to a different address than normal codecs and get rid of swap buffers.
Comment by Tomasz Malesinski (tmal) - Tuesday, 21 November 2006, 21:28 GMT
I modified the first patch to support plugins that use IRAM. There is small inefficiency, namely the iramcopy area is cleared twice - once before loading and once in PLUGIN_IRAM_INIT. Improving this would require to change every plugin.

I have not tested the affected plugins, because they don't run on iFP. It would be great if someone tested it. Perhaps I will extend my emulator to support more than 1 MB of memory, then I will be able to run those big plugins in the emulator. For now, I am just waiting for comments.
Comment by Chris (decayed.cell) - Sunday, 14 January 2007, 10:08 GMT
Needs updating for 20071401 source
Comment by Nils Wallménius (nls) - Sunday, 19 October 2008, 11:09 GMT
I synced the malloc_after_codec patch, works fine on h300 and simulator and i can now play the sample from  FS#5796  which used to crash.
Comment by Nils Wallménius (nls) - Sunday, 19 October 2008, 11:31 GMT
updated patch, bump codec api version and rename get_codec_memory to codec_get_buffer for consistency with plugins
Comment by Nils Wallménius (nls) - Sunday, 19 October 2008, 12:36 GMT
I committed a modified version of the malloc after codec patch.
What do we want to do about the others?

Loading...