Codec performance comparison
2010-07-11 00:03:00
I recently did some performance comparisons of various codecs in Rockbox on arm9e (specifically a Sansa Clipv2). For this test I clocked the CPU and memory at 40MHz, to mimic the typical low power settings an MP3 players CPU would run at while in low power mode with the screen off. The results are pretty interesting.128k (give or take for AC3) lossy files: a52_stereo_192.ac3 17.29MHz mpc_128.mpc 18.01MHz wma_128.wma 19.26MHz vorbis_128.ogg 20.16MHz nero_128.m4a 24.26MHz lame_128.mp3 26.35MHz Vorbis uses tremor, mp3 uses libmad, mpc uses peter's fixed point decoder, wma uses my fixed point port of ffmpeg's decoder, nero uses libfaad combined with a lot of code from ffmpeg and a52 uses liba52.Some caveats : AAC isn't as well optimized as the others. It uses the same transform, windowing code as Vorbis, but libfaad is kind of a mess. Vorbis and WMA are pretty well optimized. MP3 is extremely well optimized, and probably faster then a lot of commercially shipping decoders judging by the much better battery life in rockbox then the retail firmware when decoding mp3. All the pure MDCT codecs use the same MDCT, which is pretty close to the performance arm ltd claims for their optimized mdct. MP3 uses its own MDCT, which is within in assembly and within a few instructions of the best known algorithm. All low power, low accuracy, etc modes are disabled. All codecs decode at full resolution, typically > 16 bit.Some thoughts : A52 is really fast because its really simple. It has two transform block sizes, both of which are shorter then most codecs. In stereo mode its basically nothing but huffman, inverse quant, and then mdct. AAC is really complicated and the spec isn't freely available, which makes optimizing it difficult. MP3 is really slow compared to pure MDCT codecs or pure subband codecs in spite of intense optimization. This is because it has to do both an MDCT (like Vorbis, AAC, WMA, etc) and a synthesis filterbank (like MPC). Neglecting the synthesis filterbank, it performs similarly to the other small block sized mdct codec, a52. This leads to decreased battery life using the format. WMA uses the most complicated MDCT scheme of the codecs, but is otherwise extremely simple at mid to high bitrates (low bitrate coding is more complicated). Consequently, its very fast and very easy to optimize. In terms of quality per decode time, it and vorbis are probably towards the top. People say vorbis is slow, but actually its one of the fastest formats tested. Its fairly complicated, but reasonably easy to optimize and in general efficiently designed. It does have a very annoying habit of using an unpredictable amount of memory though. Some files can use up to 500KB of RAM, but most modern ones only need < 250KB. Annoying. I didn't post ATRAC3 results because I don't have an encoder, but its also really, really slow because its a hybrid format like MP3 with a lot of really weird stuff added on top that no other format uses. ffmpeg codecs are typically the fastest and best written.Lossless Formats flac_5.flac 7.07MHz flac_8.flac 7.67MHz wv_fastx3.wv 24.11MHz wv_normx4.wv 28.69MHz true_audio.tta 36.62MHz ape_c1000.ape 40.66MHz wv_high.wv 45.07MHz ape_c2000.ape 57.69MHz ape_c3000.ape 86.34MHz ape_c4000.ape 221.24MHz Some caveats : flac uses ffmpeg, ape uses rockbox (which was since ported to ffmpeg), wavpack and TTA are the official decoders. Lossless formats are more boring to me, so I can't say as much about them. All the formats are really well optimized, though flac, and ape are probably the best optimized.Some thoughts : FLAC is amazingly efficient. Its probably the fastest compressed format in remotely widespread use. All formats seem to compress about the same, so if you want to use lossless on batteries, you should probably look at flac first. APE is really, really slow. I didn't benchmark c5000 at low clock speed since I didn't have all night, but it nees around 900MHz. I would not use APE on a portable device. Wavpack is probably fast enough that you wouldn't notice much difference in battery life verses flac. Most devices can't lower the clock below 20MHz anyway. More results if anyone is interested:http://www.rockbox.org/wiki/CodecPerforman...0MHz_PCLK_40MHz