FS#10467 - [mp3 codec] Patch that reduces consumption of stack.

Attached to Project: Rockbox
Opened by Yoshihisa Uchida (Uchida) - Sunday, 26 July 2009, 03:53 GMT
Last edited by MichaelGiacomelli (saratoga) - Sunday, 23 August 2009, 15:51 GMT
Task Type Patches
Category Codecs
Status Closed
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version Daily build (which?)
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


The mp3 codec consumes very a lot of stack compared with other codec files.

codec_thread'stack usage:
mp3: 92 %
wav: 16 %
aac: 16 %
ogg: 17 %
flac: 16 %

I create the patch to which mp3 codec did not consume stack so much.

After patch apply: mp3 stack usage 17%
This task depends upon

Closed by  MichaelGiacomelli (saratoga)
Sunday, 23 August 2009, 15:51 GMT
Reason for closing:  Rejected
Additional comments about closing:  High stack usage for codecs is a good thing since it represented efficient usage of memory. This patch simply replaces fast IRAM with slower DRAM for no reason that I can find.

Thanks for the attempt though, more people looking at MP3 are always welcome.
Comment by Magnus Holmgren (learman) - Sunday, 26 July 2009, 10:22 GMT
Since it moves buffers out of iram (where the stack is), have you checked how it affects performance? It could have a noticeable impact on coldfire targets...
Comment by MichaelGiacomelli (saratoga) - Monday, 27 July 2009, 22:42 GMT
The high stack use is intentional to improve performance. Unused stack represents wasted IRAM and is not desirable in my opinion.
Comment by alex wallis (alexwallis646) - Thursday, 20 August 2009, 12:08 GMT
I have been running this patch for a while now, and so far I have experienced no problems. Though admittedly I haven't been running really high quality mp3s such as 320 kbs or 256 kbs and I imagine if this patch is going to cause problems it will do on very high quality mp3s. But so far mp3 playback is fine. This is being run on an h140 if its of any interest.
Comment by alex wallis (alexwallis646) - Sunday, 23 August 2009, 15:48 GMT
Hi. today I listened to several mp3 files of 320 kbs on my h140 with this patch applied. I experienced no player freezes or crashes. I had no problems with choppy audio or anything. Obviously I don't know if decoding was worse with this patch applied I can only speak from a users point of view and say I didn't hear any obvious problems, but I guess someone might want to look at various technical statistics to see if there are any problems the average user might not notice.