FS#7833 - Optimizations to Vorbis codec

Attached to Project: Rockbox
Opened by Tomasz Malesinski (tmal) - Tuesday, 25 September 2007, 21:20 GMT
Last edited by Jens Arnold (amiconn) - Friday, 25 January 2008, 18:53 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 1
Private No


I attach a few patches that improve efficiency of the Vorbis codec. I would like them to be tested on various targets. The patches are independent.

codebook.patch includes a faster vorbis_book_decodevv_add function for one common case. It also doesn't inline decode_packed_block, because inlining such a big function confuses gcc making it fail to allocate registers properly in the loop after the call to decode_packed_block.

mdct_arm.patch contains a part of mdct.c rewritten in ARM assembly. It saves some cycles, mostly by using ldm/stm where possible (gcc is not very good at it). It also does less inlining which makes it more cache friendly and easier to fit in IRAM.

vbpcm.patch tries to put the output of the codec in vb->pcm, which is usually in IRAM, unlike v->pcm.
This task depends upon

Closed by  Jens Arnold (amiconn)
Friday, 25 January 2008, 18:53 GMT
Reason for closing:  Accepted
Additional comments about closing:  The crash on gigabeat if the code is enabled is fixed now (gigabeat uses no IRAM), but the asm mdct is kept disabled because the C code is slightly faster.
Comment by Nils Wallménius (nls) - Wednesday, 26 September 2007, 17:26 GMT
Very nice work! :-D

I tested on my h300

vbpcm.patch 300% -> 333% realtime

codebook.patch 300% -> 312% realtime
(minor nitpick though, there's an unused variable in vorbis_book_decodevv_add_2ch_even)

both 300% -> 341% realtime

Thank you very much.
Comment by Phil Light (phillight) - Wednesday, 26 September 2007, 20:01 GMT
Using all three patches reduces boost ratio on my e200 from 30-35% to ~15%, for ~96kbps Vorbis files.
Comment by Thom Johansen (preglow) - Thursday, 27 September 2007, 14:03 GMT
Nice, 262.21% to 282.03% on H120 and 203.72% to 232.02% on Ipod Nano, both on a 202kbps file.
I see no reason not to commit this :)
Comment by Jens Arnold (amiconn) - Wednesday, 23 January 2008, 21:01 GMT
Reopening the task was not really necessary, as the crash fix for gigabeat disabled the assembler optimisations for gigabeat *only*. All other arm targets use the optimised code. I have prepared a patch that enables the assembler code for gigabeat as well, hopefully without crashing. Needs testing, and I don't own a gigabeat.