G5 Optimized LAME

LAME is my perferred MP3 encoder, but it’s kind of slow, even on my dual-cpu G5. Now, the G4 and G5 processors have a special instruction set called Altivec which should, in theory, speed up certain tasks. Photoshop, Final Cut Pro and even Apple’s own iTunes take advantage of this. LAME does not, but I was thinking that it should. I’m currently using LAME installed from sources from Fink, so I thought I was getting a somewhat optimized version. I was wrong. After a little searching I found this page that has some flags to use when you compile LAME from source (it’s really easy, don’t worry). You don’t have to use the ones in the main article there, scroll down a bit and there’s a simplified version:

./configure –enable-static –disable-shared CFLAGS=”-fast”

Then a “make” and “sudo make install” and you’re all set. Here’s the results of a test I performed on a 2:14 .wav file (rock song, fairly complex) with various encoding settings (CPU time in minutes:seconds. lower is better, kbps shown for VBR modes):

Fink Version (3.93)
preset standard – 1:35 (217.2 kbps)
preset fast standard – 0:46 (210.0 kbps)
preset extreme – 1:30 (240.0 kbps)
preset fast extreme – 0:48 (235.2 kbps)
preset insane – 0:43
preset cbr 128 – 0:56
preset cbr 192 – 0:53
preset 128 – 0:57 (123.6 kbps)
preset 192 – 0:52 (189.7 kbps)

G5 Optimized (3.96.1)
preset standard – 0:16 (204.7 kbps)
preset fast standard – 0:11 (226.0 kbps)
preset extreme – 0:15 (249.3 kbps)
preset fast extreme – 0:11
preset cbr 128 – 0:12
preset cbr 192 – 0:12
preset 128 – 0:13 (125.5 kbps)
preset 192 – 0:11 (191.8 kbps)

As you can see, there’s a 4-6x speed up across the board. This is not taking into account any additional speedups in the code from version 3.93 to 3.96.1, but I can’t see it making that big of a difference.