[Zlib-devel] Z_RLE for zlib-1.2.0

Cosmin Truta cosmin at cs.toronto.edu
Wed Mar 12 20:31:00 EST 2003


[I am cc:-ing to png-implement list]
Quick introduction for the png-implementers:
I am making public the Z_RLE compression strategy, which was
implemented a while ago, but I didn't do enough testing until now.

This is the original proposal [Feb 2000]:

  http://www.cs.toronto.edu/~cosmin/pngtech/z_rle.html

And here is the implementation, to be plugged into the upcoming
zlib-1.2.0:

  http://www.cs.toronto.edu/~cosmin/pngtech/z_rle/


On Wed, 12 Mar 2003, Gilles Vollant wrote:

> Note that contrib/minizip/zip.c and minizip.c must also be modified

I looked inside the code, and I saw deflateInit being called with
strategy=0; no other strategies involved. So the addition of Z_RLE
shouldn't require a change in minizip.

More than that: like the other fancy strategies (Z_FILTERED,
Z_HUFFMAN_ONLY), Z_RLE isn't supposed to be used for compression of
general data. Z_DEFAULT_STRATEGY==0 is by far the best, and it should
always be used in (g)zip or (g)zip-like programs.

> Can you compare for us the advantage of each strategy:
> - Z_FILTERED
> - Z_HUFFMAN_ONLY
> - your Z_RLE
>
> In speed/size ratio, better strategy for different data...

Sorry, I should have said this in my previous email:
Z_RLE is mainly intended for PNG compression or other multimedia data.
This page

  http://www.cs.toronto.edu/~cosmin/pngtech/z_rle.html

explains the motivation: primarily, when compressing PNG files,
Z_RLE is faster and many times better than compr_level=1.
For whoever goes with Z_HUFFMAN_ONLY for high speed and fair
compression, Z_RLE is a better bet.

Z_RLE also shows improvements over Z_HUFFMAN_ONLY when compressing
source code (because of the text indentation), but in other
non-multimedia cases (such as general binary files) it doesn't
improve over Z_HUFFMAN_ONLY at all.
However, in all these cases, Z_DEFAULT_STRATEGY with compr_level=1
is even better than all other strategies.


Experimentally, I noticed that Z_RLE is about 2-10% slower than
Z_HUFFMAN_ONLY.


[Also for the png-implementers:]
zlib-1.2.0 is available for testing:
  http://www.alumni.caltech.edu/~madler/zlib-1.2.0.tar.gz


Best regards,
Cosmin


> -----Original Message-----
> From: Zlib-devel-admin at zlib.net [mailto:Zlib-devel-admin at zlib.net] On
> Behalf Of Cosmin Truta
> Sent: Wednesday, March 12, 2003 5:31 PM
> To: Zlib-devel at zlib.net
> Subject: [Zlib-devel] Z_RLE for zlib-1.2.0
>
>
>
> Hello, zlib developers,
>
> About a year ago I was promising to implement a new strategy, Z_RLE.
>
> Well, I am happy to bring it to you now, just in time (I hope) for the
> release of zlib-1.2.0.
>
> See
>
>   http://www.cs.toronto.edu/~cosmin/pngtech/z_rle/
>
> or download
>
>
> http://www.cs.toronto.edu/~cosmin/pngtech/z_rle/deflate-120-rle-full.zip
>
> There is not really much change in the source files, and most of it was
> done some time ago, but I had to test it myself first, and decide there
> are good reasons to stay that way. I had some bigger intentions, which
> couldn't materialize due to lack of time. The good news is that the
> essential work is done.
>
> I felt it's important for this API addition to make it into the very
> first of the zlib-1.2.x series, because it's easier to remember just
> "the zlib-1.2.x series supports the Z_RLE strategy", rather than "in
> order to compile your program that uses Z_RLE, you need at least
> zlib-1.2.2" or so.
>
> If, on the other hand, you cannot include the Z_RLE implementation in
> the 1.2.0 release, I wrote an alternative as a dummy Z_RLE that acts
> just like Z_HUFFMAN_ONLY. This should be easy to integrate, the changes
> are small and straightforward. Its advantage is that users' code won't
> break the compilation if it is being built using zlib-1.2.0, instead of
> a later, required version.
>
> The patch archives contain the modified versions of
> zlib.h, deflate.c, gzio.c, minigzip.c, as well as "unified diff" files.
>
> I run pretty intensive testing (I think), using OptiPNG. This way I
> tested lots of combinations automatically. minigzip and Info-Zip's zip
> are other programs I used for testing.
>
> I also have other (minor) proposed changes for deflation. The web page
> given above provides extensive information about the modifications, the
> implementation decisions, and the testing involved.
>
>
> Best regards,
> Cosmin
>
>
> _______________________________________________
> Zlib-devel mailing list
> Zlib-devel at zlib.net
> http://zlib.net/mailman/listinfo/zlib-devel_madler.net
>





More information about the Zlib-devel mailing list