-.\" $OpenBSD: compress.3,v 1.26 2024/01/20 11:16:27 tb Exp $
+.\" $OpenBSD: compress.3,v 1.27 2024/02/07 20:51:38 tb Exp $
.\"
.\" Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
.\"
.\"
.\" This page corresponds to zlib version 1.2.3
.\"
-.Dd $Mdocdate: January 20 2024 $
+.Dd $Mdocdate: February 7 2024 $
.Dt COMPRESS 3
.Os
.Sh NAME
.Dv Z_FILTERED
for data produced by a filter
.Pq or predictor ;
-.Dv Z_HUFFMAN_ONLY
-to force Huffman encoding only
-.Pq no string match ,
-or
.Dv Z_RLE
to limit match distances to one
-.Pq run-length encoding .
+.Pq run-length encoding ,
+or
+.Dv Z_HUFFMAN_ONLY
+to force Huffman encoding only
+.Pq no string match .
Filtered data consists mostly of small values with a
-somewhat random distribution.
+somewhat random distribution,
+as produced by the PNG filters.
In this case, the compression algorithm is tuned to compress them better.
The effect of
.Dv Z_FILTERED
-is to force more Huffman coding and less string matching;
-it is somewhat intermediate between
+is to force more Huffman coding and less string matching than the default;
+it is intermediate between
.Dv Z_DEFAULT_STRATEGY
and
.Dv Z_HUFFMAN_ONLY .
.Dv Z_RLE
-is designed to be almost as fast as
+is almost as fast as
.Dv Z_HUFFMAN_ONLY ,
-but gives better compression for PNG image data.
+but should give better compression for PNG image data than Huffman only.
+The degree of string matching from most to none is:
+.Dv Z_DEFAULT_STRATEGY ,
+.Dv Z_FILTERED ,
+.Dv Z_RLE ,
+then
+.Dv Z_HUFFMAN .
The
.Fa strategy
-parameter only affects the compression ratio but not the correctness of the
-compressed output, even if it is not set appropriately.
+parameter affects the compression ratio but never the correctness of the
+compressed output, even if it is not set optimally for the given data.
.Dv Z_FIXED
-prevents the use of dynamic Huffman codes,
+uses the default string matching,
+but prevents the use of dynamic Huffman codes,
allowing for a simpler decoder for special applications.
.Pp
.Fn deflateInit2