zlib icon indicating copy to clipboard operation
zlib copied to clipboard

Manual issue on "strategy" parameter

Open MasterInQuestion opened this issue 1 year ago • 0 comments

    https://www.zlib.net/manual.html#Advanced     The description on "strategy" parameter:     "The effect of Z_FILTERED is to force more Huffman coding and less string matching; it is somewhat intermediate between Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY."     .     Potentially misleading. (than what?)     [ May trap permissive parsing: "The effect of Z_HUFFMAN_ONLY is to force more Huffman coding and less string matching ..." ]

    Recommended change: [[

<p id="strategy" style="white-space: pre-wrap; word-wrap: break-word"
>	The <tt>strategy</tt> parameter is used to tune the compression algorithm:
	|0| Use the value <tt>Z_DEFAULT_STRATEGY</tt> for normal data.
	|1| <tt>Z_FILTERED</tt> for data produced by a filter (or predictor).
	|2| <tt>Z_HUFFMAN_ONLY</tt> to force Huffman encoding only (no string match).
	|3| <tt>Z_RLE</tt> to limit match distances to 1 (Run-Length Encoding).
	|4| <tt>Z_FIXED</tt> prevents the use of dynamic Huffman codes. [ Allowing simpler decoder for certain applications. ]

	Filtered data consist mostly of small values with somewhat random distribution.
	In this case, the compression algorithm may be tuned to compress them better.

	The effect of <tt>Z_FILTERED</tt> is to force more Huffman coding and less string matching than <tt>Z_DEFAULT_STRATEGY</tt>: somewhat the intermediate between <tt>Z_DEFAULT_STRATEGY</tt> and <tt>Z_HUFFMAN_ONLY</tt>.
	<tt>Z_RLE</tt> is designed to be almost as fast as <tt>Z_HUFFMAN_ONLY</tt>, but gives better compression for PNG image data.

	The <tt>strategy</tt> parameter affects only the compression ratio not the correctness of compressed output: even if set inappropriately.
</p>

]]     Per [ https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes ], and some testing: "id" should be used instead of "name" for HTML anchor. ("name" mostly doesn't work)     "id" also doesn't have to be unique: see [ https://github.com/MasterInQuestion/Markup/blob/main/!clock.htm ] for example.     .     The wrapper is derived from [ https://github.com/MasterInQuestion/Markup/blob/main/Verbose.htm ].

    See also:     https://github.com/madler/zlib/blob/36e369e1a54b35a978dc584496af69a07ec2d71a/zlib.h#L588-L601     (plain text identical) [[     The strategy parameter is used to tune the compression algorithm:     |0| Use the value Z_DEFAULT_STRATEGY for normal data.     |1| Z_FILTERED for data produced by a filter (or predictor).     |2| Z_HUFFMAN_ONLY to force Huffman encoding only (no string match).     |3| Z_RLE to limit match distances to 1 (Run-Length Encoding).     |4| Z_FIXED prevents the use of dynamic Huffman codes. [ Allowing simpler decoder for certain applications. ]

    Filtered data consist mostly of small values with somewhat random distribution.     In this case, the compression algorithm may be tuned to compress them better.

    The effect of Z_FILTERED is to force more Huffman coding and less string matching than Z_DEFAULT_STRATEGY: somewhat the intermediate between Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY.     Z_RLE is designed to be almost as fast as Z_HUFFMAN_ONLY, but gives better compression for PNG image data.

    The strategy parameter affects only the compression ratio not the correctness of compressed output: even if set inappropriately. ]]

    Also, though I haven't verified the exact implementation: but empirically Z_FILTERED feels like a superset of Z_HUFFMAN_ONLY?     Output size of Z_HUFFMAN_ONLY was never smaller than Z_DEFAULT_STRATEGY or Z_FILTERED?

    "Z_RLE is designed to be almost as fast as Z_HUFFMAN_ONLY, but gives better compression for PNG image data." <^>    "gives" (guaranteed) or "may give"? or "generally gives"?

    Are Z_HUFFMAN_ONLY, Z_RLE, Z_FIXED all capped versions of Z_FILTERED? (subset of Z_FILTERED?)

MasterInQuestion avatar Jan 22 '24 01:01 MasterInQuestion