Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

BadWolf

macrumors newbie
Original poster
Feb 11, 2009
3
0
Hi,

The compress function on the mac os, uses an adaptive Lempel-Ziv algorithm. I searched online and I couldn't really find a good summary concerning the function's operation. Does anyone know whether the algorithm compresses files while reading them (like the adaptive huffman coding algorithm) or whether it reads the files once to construct a frequency table and then reads the file once more to compress it (like regular huffman coding)? Also, does anyone know where on the system the c and h files for compress are stored?

Thank you for your help,

BadWolf
 

Gruffalo

macrumors newbie
Jan 27, 2006
13
0
Hi,

The compress function on the mac os, uses an adaptive Lempel-Ziv algorithm. I searched online and I couldn't really find a good summary concerning the function's operation. Does anyone know whether the algorithm compresses files while reading them (like the adaptive huffman coding algorithm) or whether it reads the files once to construct a frequency table and then reads the file once more to compress it (like regular huffman coding)? Also, does anyone know where on the system the c and h files for compress are stored?

Thank you for your help,

BadWolf

Wikipedia's explanation of the standard LZW algorithm seems pretty clear to me, but to directly answer your question, it produces a compressed stream in a single pass.

Apple no longer make the system source available, however, I'd guess that the compress in OS X is identical to that used on other *BSD derivatives. You could have a look at the FreeBSD source code directly for the gory details. Zopen.c contains the guts of the algorithm.
 

BadWolf

macrumors newbie
Original poster
Feb 11, 2009
3
0
Thank You

Thanks for the confirmation on the function operation, for some reason, the wiki just wasn't clear enough for me. I had actually found the BSD code, but I experience problems when it called upon include files "sys/param.h" and so forth. I guess I'll keep playing with it, and I'll check out the darwinsource as well. thanks again!:)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.