Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly is DEFAULT_COMPRESSION?

Tags:

Of the possible DEFLATE compression levels [0 .. 9], which one exactly Java's Deflater.DEFAULT_COMPRESSION correspond to? In the Java source code, I see it as public static final int DEFAULT_COMPRESSION = -1;

like image 617
kolistivra Avatar asked May 10 '13 15:05

kolistivra


People also ask

What zlib means?

zlib (/ˈziːlɪb/ or "zeta-lib", /ˈziːtəˌlɪb/) is a software library used for data compression. zlib was written by Jean-loup Gailly and Mark Adler and is an abstraction of the DEFLATE compression algorithm used in their gzip file compression program.

How does zlib work?

LZ77 compression algorithm works by using a sliding window to find sequences of data that are repeated, and encoding each repeated sequence by a pair of numbers called a length-distance pair .

How does the DEFLATE algorithm work?

The deflation algorithm used by gzip (also zip and zlib) is a variation of LZ77 (Lempel-Ziv 1977, see reference below). It finds duplicated strings in the input data. The second occurrence of a string is replaced by a pointer to the previous string, in the form of a pair (distance,length).

What is zlib compression level?

The compression ratio of zlib ranges between 2:1 to 5:1. Additionally, it provides ten compression levels, and different levels have different compression ratios and speeds. zlib algorithm uses Deflate method for compression and Inflate method for decompression.


1 Answers

Z_DEFAULT_COMPRESSION is intended to be a good compromise between speed and compression effectiveness. It is the knee in the curve. The actual level that it's currently equivalent to, 6, is an internal choice that could change in future versions if the compression algorithm changes. So you should not depend on it remaining equivalent to level 6.

like image 156
Mark Adler Avatar answered Oct 08 '22 10:10

Mark Adler