Rockbox

  • Status Closed
  • Percent Complete
    100%
  • Task Type Patches
  • Category Codecs
  • Assigned To No-one
  • Operating System All players
  • Severity Low
  • Priority Very Low
  • Reported Version
  • Due in Version Undecided
  • Due Date Undecided
  • Votes
  • Private
Attached to Project: Rockbox
Opened by tmal - 2006-11-19
Last edited by nls - 2010-10-25

FS#6357 - Changes in codecs memory layout

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.

Closed by  nls
2010-10-25 09:45
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.

tmal commented on 2006-11-21 07:53

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.

tmal commented on 2006-11-21 21:28

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.

Needs updating for 20071401 source

nls commented on 2008-10-19 11:09

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.

nls commented on 2008-10-19 11:31

updated patch, bump codec api version and rename get_codec_memory to codec_get_buffer for consistency with plugins

nls commented on 2008-10-19 12:36

I committed a modified version of the malloc after codec patch.
What do we want to do about the others?

Loading...

Available keyboard shortcuts

Tasklist

Task Details

Task Editing