Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Packet oriented lossless compression library

Tags:

c++

c

compression

Does anyone know of a free (non-GPL), decently performing compression library that supports packet oriented compression in C/C++?

With packet oriented, I mean the kind of feature QuickLZ (GPL) has, where multiple packets of a stream can be compressed and decompressed individually while a history is being maintained across packets to achieve sensible compression.

I'd favor compression ratio over CPU usage as long as the CPU usage isn't ridiculous, but I've had a hard time finding this feature at all, so anything is of interest.

like image 978
porgarmingduod Avatar asked May 10 '11 11:05

porgarmingduod


People also ask

What is the best lossless compression?

The most successful compressors are XM and GeCo. For eukaryotes XM is slightly better in compression ratio, though for sequences larger than 100 MB its computational requirements are impractical.

What is a lossless compression example?

Examples of lossless compression include GZIP, Brotli, WebP, and PNG, Lossy compression, on the other hand, uses inexact approximations by discarding some data from the original file, making it an irreversible compression method.

What is lossless compression which file types use it?

Lossless compression refers to compression in which the image is reduced without any quality loss. Usually this is done by removing unnecessary metadata from JPEG and PNG files. RAW, BMP, GIF, and PNG are all lossless image formats.

What is lossless compression best used for?

Lossless compression is generally used for so-called "discrete" data, such as database records, spreadsheets, word-processing files, and even some kinds of image and video information. Text compression is a significant area for lossless compression.


Video Answer


2 Answers

zlib's main deflate() function takes a flush parameter, which allows various different flushing modes. If you pass Z_SYNC_FLUSH at the end of each packet, that should produce the desired effect.

The details are explained in the zLib manual.

bzip2 has flushing functionality as well, which might let you do this kind of thing. See http://www.bzip.org/1.0.5/bzip2-manual-1.0.5.html#bzCompress

like image 148
pmdj Avatar answered Sep 21 '22 01:09

pmdj


Google's Snappy may be a good option, if you need speed more than compression and are just looking to save a moderate amount of space.

Alternatively, Ilia Muraviev put a small piece of compression code called BALZ in public domain some time ago. It is quite decent for many kinds of data.

Both of these support stream flushing and independent state variables to do multiple, concurrent streams across packets.

like image 40
Seth Avatar answered Sep 19 '22 01:09

Seth