Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compact decompression library for embedded use

Tags:

We're currently creating a device for a customer that will get a block of data (like, say, 5-10KB) from a PC application. This is a bit simplified, so assume that the data must be passed and uncompressed a lot, not just once a year. The communication channel is really, really slow, so we'd like to compress the data beforehand, pass to the device and let it uncompress the data to its internal flash. The device itself, however, runs on a micro controller that is not really fast and does not have a lot of memory. It has enough flash memory to store the result, and can uncompress the data block as it is received, but it may not have enough RAM to store the entire compressed or uncompressed (or even both!) data blocks. And of course, it doesn't have an operating system or other luxury.

This means we need a sufficiently fast uncompression algorithm that does not use a lot of memory. The compression can be slow and ugly, since we're doing it on the PC side. C or .NET code preferred though for compression, to make things easier. The uncompression code should be in C, since it's unlikely that someone has an ASM optimized version for our controller.

We found LZO, which would be almost perfect for us, but it has a so-called "free" license (GPL) by default, which makes it totally unusable for our customer. The author says that commercial licenses are available on request, but unfortunately he's currently unreachable (for non-technical reasons, like the news on his site say).

I found a few other libraries, including the puff.c from zlib, and we're still investigating, but I thought I'd ask for your experience:

Which compression algorithm and/or library do you recommend for embedded purposes, given that the decompression device has really limited resources and source code and a commercial license are required?

like image 870
OregonGhost Avatar asked Sep 22 '10 08:09

OregonGhost


People also ask

What is data compressor in embedded system?

The data compressor takes in a sequence of input symbols and then produces a stream of output symbols. Assume for simplicity that the input symbols are one byte in length. The output symbols are variable length,sowe have to choose a format in which to deliver the output data.

Can compressed data be decompressed?

For example, when a picture's file size is compressed, its quality remains the same. The file can be decompressed to its original quality without any loss of data. This compression method is also known as reversible compression.


2 Answers

You might want to check out one of these which are not GPL and are fairly compact implementations:

  • fastlz - MIT license, fairly simple code
  • lzjb - sun CDDL, used in zfs for compression, simple and very short
  • liblzf - BSD-style license, small, fast
  • lzfx - BSD-style, based on liblzf, small, fast

Those algorithms are all based on the original algorithm of Lempel–Ziv–Welch (They have all LZ in common) https://en.wikipedia.org/wiki/Lempel–Ziv–Welch

like image 77
James Snyder Avatar answered Sep 20 '22 19:09

James Snyder


I have used LZSS. I used code from Haruhiko Okumura as base. It uses the last portion of uncompressed data(2K) as dictionary. This code can be modified to not require a temporary ring buffer if you have no memory. 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 by commercial vendors.

Here is an implementation based on the same code that forms part of the Allegro game library. Allegro licensing is giftware or zlib.

Another option could be the lzfx lib that implement LZF. I have not used it yet but it seems nice. Also uses previous results so it has low memory requirements and is released under a BSD Licence.

like image 39
Gerhard Avatar answered Sep 21 '22 19:09

Gerhard