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;
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.
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 .
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).
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With