Expand on the deflate strategy parameter in zlib.h.

This commit is contained in:
Mark Adler 2024-02-07 10:48:55 -08:00
parent e342bb3dae
commit 96d3e9e3dd
1 changed files with 15 additions and 12 deletions

27
zlib.h
View File

@ -587,18 +587,21 @@ ZEXTERN int ZEXPORT deflateInit2(z_streamp strm,
The strategy parameter is used to tune the compression algorithm. Use the The strategy parameter is used to tune the compression algorithm. Use the
value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no filter (or predictor), Z_RLE to limit match distances to one (run-length
string match), or Z_RLE to limit match distances to one (run-length encoding), or Z_HUFFMAN_ONLY to force Huffman encoding only (no string
encoding). Filtered data consists mostly of small values with a somewhat matching). Filtered data consists mostly of small values with a somewhat
random distribution. In this case, the compression algorithm is tuned to random distribution, as produced by the PNG filters. In this case, the
compress them better. The effect of Z_FILTERED is to force more Huffman compression algorithm is tuned to compress them better. The effect of
coding and less string matching; it is somewhat intermediate between Z_FILTERED is to force more Huffman coding and less string matching than the
Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as default; it is intermediate between Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY.
fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The Z_RLE is almost as fast as Z_HUFFMAN_ONLY, but should give better
strategy parameter only affects the compression ratio but not the compression for PNG image data than Huffman only. The degree of string
correctness of the compressed output even if it is not set appropriately. matching from most to none is: Z_DEFAULT_STRATEGY, Z_FILTERED, Z_RLE, then
Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler Z_HUFFMAN. The strategy parameter affects the compression ratio but never
decoder for special applications. the correctness of the compressed output, even if it is not set optimally
for the given data. Z_FIXED uses the default string matching, but prevents
the use of dynamic Huffman codes, allowing for a simpler decoder for special
applications.
deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid