views:

617

answers:

9

Hello, i'm writing project that stores data, so i need to compress it. I've tried zlib but it's bottleneck of my project. So maybe there is faster solution. I don't need a great compress ratio, but i'm looking for really fast compression. Are there any other data compression libraries except zlib, that are really free and can be used in proprietary software (project, i'm working on, isn't GPL-based). My project is on C++ and I need to compress char* arrays of text.

+4  A: 

A very fast compression algorithm is LZO. Benchmarks on the site show that decompression is comparable in speed to memcpy().

The free version of LZO is GPL licensed, but there is also a commercial version of the library in LZO Professional. Also, from the documentation:

Special licenses for commercial and other applications which are not willing to accept the GNU General Public License are available by contacting the author.

Greg Hewgill
+3  A: 

Since you need something that is quick but not necessarily the best compression ever, you might consider a library that does RLE (run-length encoding) compression. One implementation is librle, which is under the BSD license, which is pretty permissible for proprietary use.

jgottula
+1  A: 

Yes, bzip2 has a BSD license.

DigitalRoss
bzip2 is generally slower than gzip, though with better compression
Martin Beckett
+4  A: 

I think 7zip is public domain. LZMA compression.

7-Zip

KFro
`7zip` is (much?) slower than either 'gzip' or 'bzip2'. It's the usual trade-off- slower, but compresses better.
johne
johne: Not necessarily. My E4500 compresses 100Mb roughly in about 10 seconds (LZMA compression).
nhaa123
`LZO` and `liblzf` approach `memcpy()` speeds- if I remember the E4500 XDBus backplane speeds correctly, they will both compress your 100Mb file in < 1 second.
johne
It's typically slower than gzip, but faster than bzip2. It has better compression than both of them.
Adam Goode
+3  A: 

Another answer already mentions LZO, which is sort of the default "I need faster (de)compression" solution.

Another one I've found is liblzf. Pretty close to LZO in terms of speed and compression rates. LZO has a GPL license, whereas liblzf has a BSD license (which, IMHO, is an advantage).

johne
+2  A: 

Intel Integrated Performance Primitives has samples that implements variety of compressions:

  • bzip2-compatible library The ipp_bzip2 sample demonstrates how to use Intel IPP Data Compression domain functions for implementation of bzip2/libbzip2 (a program and library for lossless, block-sorting data compression and new improvements on threading optimization for bzip
  • GZIP-compatible library The IPP_GZIP sample illustrates the way of implementing effective lossless data compression solution by using Intel IPP Data Compression domain API. Additionally, this sample shows the ways of parallelizing application using OpenMP and other methods to advanced benefits on multi-core environment.
  • zlib-compatible library (new!) This code sample illustrates how to build a zlib-compatible data compression library using the optimized LZ77 and Huffman coding functions in Intel IPP.
  • General data compression examples Illustrates how to use functions provided by the Intel IPP data compression domain. Includes Huffman encoding/decoding, RLE encoding/decoding, MoveToFront (MTF), Burrows-Wheeler Transformations (BWT), General Interval Transform (GIT), and Lempel-Ziv-Storer-Szymanski (LZSS) functions.

IPP is not free, but it really fast. It supports Windows and Linux.

Kirill V. Lyadvinsky
+2  A: 

Here are a few:

FastLZ -- fast and lightweight, MIT license unless you want to use it under a GPL license

LZJB -- also fast and pretty lightweight, used as default compression algorithm for Sun's ZFS

James Snyder
A: 

I'm doing a nonGPL hardware project and I need a compression algorithm that is very fast, offers relatively good compression and has minimal memory requirements. LZO fits the bill perfectly.

Two questions:

  1. Anyone knows the ballpark figure for commercial LZO licences?
  2. There has been some debate on which algorithms offer good compression and fast decompression, but no talk about minimal memory requirements. Any ideas?
stricjux
+1  A: 

I have used a LZSS implementation from Haruhiko Okumura. The licensing is not clear from his site but some versions was released with a "Use, distribute, and modify this program freely" line included and the code is used freely by commercial vendors.

Another option could be the lzfx lib that implement LZF. It is released under a BSD Licence.

Gerhard
Haruhiko Okumuras page says: `Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution 2.1 Japan License.`
smerlin