FS#5219 - Performance optimizations for libmad mp3 decoder (mainly iH1xxx) Part.II

Attached to Project: Rockbox
Opened by Toni (ahellmann) - Sunday, 23 April 2006, 18:49 GMT
Task Type Patches
Category Codecs
Status Closed
Assigned To No-one
Operating System Iriver H100 series
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


The three patches give a cumulative performance increase of ~19% to the swcodec on iHxxx players. At least the huffdecode.patch should affect other swcodec based players too. I measured following boost ratio on my H120:
current: 10% @34MHz => 43.0MHz realtime
patches: 3% @34MHz => 36.7MHz realtime
This leads to ~15% performance improvement on the whole system. If the cpu speed is the main battery eater, then 1h more play time can be expected from these patches if the "normal" cpu speed is lowered to 34MHz.

The optimizations in detail:
* simplify bit read functions (and extend to 32bit access)
* restructure huffdecode function (less if/else statements)
* more effective bit caching
* less error checking on inconsistent mp3 input data

* reduce multiple access of identical scalefactors
* usage of all four emac accus

* reduce number of variables
* extend the asm code to odd / even segments
* remove double access of identical scalefactors

The output of the modified sw is exactly the same as with current sw for consistent mp3 files. For inconsistent files it may differ slightly.

The following table shows a time measurement with current sw and patched sw. The used test file has been encoded with lame -preset extreme option:

function: current patched
huffdecode 23F 1B7 => 6% of total < huffdecode.patch (algorithmic changes)
joint stereo F E
aliasreduce 66 65
imdct 296 1D8 => 8% of total < imdct.patch (more asm optimized)
dct32 191 185
synth_full 21C 1B2 => 5% of total < synth.patch (more asm optimized)
sum 8F7 739 => 19% faster swcodec on H1xx/H3xx
This task depends upon

Closed by  Thom Johansen (preglow)
Thursday, 27 April 2006, 19:52 GMT
Reason for closing:  Accepted
Additional comments about closing:  Great work, as usual!
Comment by Toni (ahellmann) - Tuesday, 25 April 2006, 20:04 GMT
Bugfixes for huffdecode.patch:
* use correct min number of bits in huffdecode (use logical instead of experimental values :-)
* remove the empty swap() macro with betoh32()