FS#9160 - Use Tremor IMDCT for WMA

Attached to Project: Rockbox
Opened by MichaelGiacomelli (saratoga) - Sunday, 06 July 2008, 18:50 GMT
Last edited by MichaelGiacomelli (saratoga) - Friday, 18 July 2008, 01:24 GMT
Task Type Patches
Category Codecs
Status Closed
Assigned To No-one
Operating System SW-codec
Severity Low
Priority Normal
Reported Version Daily build (which?)
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


The Tremor IMDCT is much, much faster then the WMA (and almost certainly the FAAD) one. This patch copies the Tremor IMDCT over to libwma with minor changes to remove it's connection to Vorbis.

The resulting decoder sounds correct on the Sim and ARM, while being 4MHz faster on PP5024.

I have not tested it on Coldfire, but expect some speedup and hopefully no reduction in quality.

This task depends upon

Closed by  MichaelGiacomelli (saratoga)
Friday, 18 July 2008, 01:24 GMT
Reason for closing:  Accepted
Comment by MichaelGiacomelli (saratoga) - Sunday, 06 July 2008, 19:59 GMT
Coldfire results from IRC:

<PaulJam> saratoga: without the patch: 249,25% and with the patch: 298,75%
<PaulJam> saratoga: 128kbps (it is one of the windows example music songs)

Also, updated patch to not produce a warning. Output should be identical. If no one finds any glitches, I will try to clean this up and commit it sometime this week or next, then look into adding it to AAC.
Comment by Thom Johansen (preglow) - Monday, 07 July 2008, 10:43 GMT
Have you actually tested to see if the output is identical?
Comment by PaulJam (PaulJam) - Monday, 07 July 2008, 12:03 GMT

i just used the "write WAV" functionality of the test_codec plugin and did an ABX test using Foobar2000 to compare the output with and without the patch.
And the volume of the output with the patch applied is noticeably lower in direct comparison to the output without the patch.
Comment by Thom Johansen (preglow) - Monday, 07 July 2008, 13:04 GMT
Sounds like a wrong fixed point format is used somewhere.
Comment by MichaelGiacomelli (saratoga) - Tuesday, 08 July 2008, 23:26 GMT
Heres an updated patch.

Gives me more or less identical output (<-140dB RMS error) meaning that resolution remains well above 16 bits. We probably lost a bit of accuracy since the fixed point format in Tremor and libwma are mismatched, but I don't see much sense in rewriting the IMDCT in ARM ASM just to save some accuracy above the 16th bit.

However, this does not rule out the possibility of clipping on loud samples, so any testing is appreciated.

Edit: Sorry, patch had some other junk in it related to Tremor. Should be fixed now.
Comment by Magnus Holmgren (learman) - Wednesday, 09 July 2008, 21:20 GMT
From what I've read, an FFT-based IMDCT would be even faster, and that is what FAAD uses, as far as I can tell (though it might not be well optimized for our targets). Wouldn't it be better to try to optimize and use that one? Still, a nice speed-up for WMA.
Comment by MichaelGiacomelli (saratoga) - Wednesday, 09 July 2008, 21:47 GMT
The old IMDCT was also FFT based, but substantially slower then the Tremor one even ignoring ASM optimization. A faster FFT algorithm that was optimized for the minimum number of multiplies at the expense of adds would have been faster, but I don't know how much so. Unfortunately, few fixed point FFT implementations exist, and designing fast ones is a nontrivial task.

Regarding choice of algorithm, I've actually seen claims that both methods are fastest, so I tend to think there is not a huge difference.
Comment by MichaelGiacomelli (saratoga) - Sunday, 13 July 2008, 19:57 GMT
Corrected lowered volume on files using noise coding.
Removed some unneeded fixed point functions left over from the ffmpeg imdct.
Comment by Andree Buschmann (Buschel) - Thursday, 17 July 2008, 05:41 GMT
I would say -> go for svn. Because

a) the speed increase is significant
b) it seems you already measured a very low RMS error
c) you won't get much feedback on possible errors here

Good job!
Comment by Thom Johansen (preglow) - Thursday, 17 July 2008, 09:13 GMT
Go for it!