Open Source ALAC Decoder |
Open Source ALAC Decoder |
Mar 5 2005, 20:28
Post
#1
|
|
|
A/V Moderator Group: Members Posts: 278 Joined: 22-February 03 Member No.: 5132 |
Hi, David Hammerton from the ffmpeg mailing list wrote a reverse engineered ALAC decoder.
QUOTE Located here is a basic decoder for Apple Lossless Audio Codec files (ALAC). ALAC is a proprietary lossless audio compression scheme. Apple never released any documents on the format. What I provide here is a C implementation of a decoder, written from reverse engineering the file format. It turns out that most of the algorithms in the codec are fairly well known. ALAC uses an adaptive FIR prediction algorithm and stores the error values using a modified rice or golumb algorithm. Further details are in alac.c. Although an encoder is not provided, by using the decoder as a sort of specification it should be fairly trivial to write an encoder. By exploiting other lossless audio encoders, such as FLAC, the task will be much easier. Although one wouldn't be able to copy the compression algorithms verbatim, as adaptive compression is used in ALAC and not in FLAC. There are, however, a bunch of academic papers on the issue. The program located here will not be able to handle all ALAC files, it can only handle mono or stereo files. ALAC allows up to 8 channels. It should be trivial to finish the implementation once I find files that I can test it with. Likewise the decoder only supports 16bit sample sizes. Again, it should be trivial to fix. The decoder is fairly self explanatory, it can read an ALAC stream from either a file or from stdin, and write it as raw PCM data or as a WAV file to either stdout or a file. In theory one should be able to stream data to the decoder. I uploaded a binary here. Not sure about the legality of this, I will remove if necessary. |
|
|
|
![]() |
Mar 6 2005, 21:24
Post
#2
|
|
|
FLAC Developer Group: Developer Posts: 1526 Joined: 27-February 02 Member No.: 1408 |
just got finished looking over the decoder source... first, that is one fantastic feat of reverse engineering.
second, ALAC does not resemble MPEG4-ALS, at least not the MPEG4-ALS I have read about. some differences: - ALAC transmits FIR coeffs directly w/linear quantization, ALS transmits arcsin transform of reflection coeffs - ALAC adapts the FIR coeffs while ALS appears not to - ALAC has more complicated stereo decorrelation - ALAC adapts the rice parameter while coding the residual, ALS uses 1 or 4 fixed parameters per block. ALS also has a mode which mixes rice and block codes - ALAC has only 8 channels vs ALS' 256. the ALAC design is similar to FLAC: - first stage: optional interchannel decorrelation - second stage: FIR interchannel decorrelation - - (both have optional verbatim coding) - - (both have optional fixed low-order predictors) - third stage: residue coding with rice codes - also, before second stage, FLAC has a 'wasted-bits' step which might have an ALAC analogue, it is hard to tell from the source some differences: 1. interchannel decorrelation can use a linear combination of mid and side channels whereas FLAC computes only mid and side channels 2. ALAC FIR decorrelation adapts based on the sign of some measurement (have to look into that more) 3. rice parameter adapts, where FLAC uses precomputed parameters that are also transmitted from those differences we can infer some things. first, the decode complexity is higher that FLAC: there is an extra multiply per sample because of 1), 2) causes a few extra adds per sample times predictor order at least, and 3) is also more complex by an amount I haven't really quantified yet. it is now clear also that the high decode speed on apple hardware is due to significant PPC optimization. so it looks like apple did not make ALAC because FLAC's decode complexity was too high. also, even with all these "improvements" the compression ratio of ALAC is similar to (but seems to average slightly lower) than FLAC. so it wasn't made to blow FLAC out of the water on compression. what's left? either they just wanted something proprietary (well that didn't last long) or it has some unknown advantage on hi-res audio that isn't supported by the encoder yet. Josh |
|
|
|
Mar 7 2005, 11:50
Post
#3
|
|
![]() Group: Members (Donating) Posts: 158 Joined: 27-January 04 Member No.: 11536 |
QUOTE (jcoalson @ Mar 6 2005, 12:24 PM) just got finished looking over the decoder source... first, that is one fantastic feat of reverse engineering. Very interesting feedback josh thanks...(...) so it looks like apple did not make ALAC because FLAC's decode complexity was too high. also, even with all these "improvements" the compression ratio of ALAC is similar to (but seems to average slightly lower) than FLAC. so it wasn't made to blow FLAC out of the water on compression. what's left? either they just wanted something proprietary (well that didn't last long) or it has some unknown advantage on hi-res audio that isn't supported by the encoder yet. Josh Anyway the "unmotived" proprietary choice didn't surprised me too much from Apple... This post has been edited by Tang: Mar 7 2005, 11:54 |
|
|
|
Bonzi Open Source ALAC Decoder Mar 5 2005, 20:28
jcoalson very cool. I was about half-way done reverse engi... Mar 5 2005, 21:26
guruboolez Very nice new
I suppose that foobar2000, winamp o... Mar 5 2005, 22:34
Tec9SD QUOTE (guruboolez @ Mar 5 2005, 04:34 PM)Very... Mar 7 2005, 02:34
yong QUOTE (Tec9SD @ Mar 7 2005, 09:34 AM)QUOTE (g... Mar 7 2005, 11:42
Bonzi I should say that the binary that I uploaded is ju... Mar 5 2005, 22:50
guruboolez QUOTE (Bonzi @ Mar 5 2005, 10:50 PM)I should ... Mar 6 2005, 00:09
rjamorim Amazing shit.
/me goes to change the lossless com... Mar 6 2005, 00:27
guest0101 QUOTE (rjamorim @ Mar 5 2005, 04:27 PM)... Mar 6 2005, 00:35
krmathis QUOTE (guest0101 @ Mar 6 2005, 12:35 AM)Anybo... Mar 6 2005, 17:28
rjamorim QUOTE (solaris @ Mar 6 2005, 01:28 PM)I'v... Mar 6 2005, 17:34
krmathis QUOTE (rjamorim @ Mar 6 2005, 05:34 PM)Sweet.... Mar 6 2005, 18:08
Mike Giacomelli I think under MacOS you could just unzip it, brows... Mar 6 2005, 02:37
guest0101 QUOTE (Mike Giacomelli @ Mar 5 2005, 06:37 PM... Mar 6 2005, 03:42
Dibrom QUOTE (guest0101 @ Mar 5 2005, 06:42 PM)QUOTE... Mar 6 2005, 04:00
guest0101 QUOTE (Dibrom @ Mar 5 2005, 08:00 PM)You need... Mar 6 2005, 05:28
svkelley It would be great to also extract the tags and the... Mar 6 2005, 03:26
JEN QUOTE (rjamorim @ Mar 6 2005, 12:27 AM)... Mar 6 2005, 09:55
rjamorim QUOTE (JEN @ Mar 6 2005, 05:55 AM)When will t... Mar 6 2005, 16:09
ffooky On my 1.25 gHz/ 768MB eMac it seems significantly... Mar 6 2005, 12:56
Latexxx This hasn't been optimised in any way. So it i... Mar 6 2005, 13:01
JEN QUOTE (rjamorim @ Mar 6 2005, 04:09 PM)QUOTE ... Mar 6 2005, 16:35
Busemann QUOTE (jcoalson @ Mar 6 2005, 12:24 PM)what... Mar 7 2005, 12:43
jcoalson QUOTE (Busemann @ Mar 7 2005, 06:43 AM)Well, ... Mar 7 2005, 16:45
guest0101 Uh, oh, now the news outlets just released a story... Mar 7 2005, 18:09
AtaqueEG Do you think we will see software implementation (... Mar 6 2005, 21:53
guest0101 Well it appears that news sources are quoting/meti... Mar 7 2005, 15:39
xmixahlx this wasn't not mentioned here, and i thought ... Mar 7 2005, 21:17
yong Did someone know?
Mplayer(Daily CVS version) now i... Apr 2 2005, 10:38
keytotime Could somebody please compile the latest version f... Oct 26 2006, 01:13
kurtnoise For windows I guess ?
http://kurtnoise.free.fr/in... Oct 26 2006, 09:19
john33 Updated Win32 compiles at Rarewares Lossless page ... Oct 26 2006, 09:48
keytotime Wow That was Fast. Thank You. Oct 26 2006, 12:19![]() ![]() |
|
Lo-Fi Version | Time is now: 23rd May 2013 - 15:33 |