PNG: deflate and zlib
Asked Answered
T

1

3

I'm trying to understand compression in PNG - but I seem to

find a lot of contradictory information online ... I would like to understand - how is searching done in the LZ77-part: hash table with linked lists? is this defined in deflate? or implemented in zlib? is there a choice of the search method? - can PNG encoders/decoders set some parameters for the compression (strategy, filter, etc.) or is there a default for PNG? - does the LZ77-part do greedy or lazy evaluation? or is this an option too? - and finally: the 2 Huffman trees, are they compressed in a third tree, and all three of them are encoded? or are the 2 trees encoded with only their codelengths?

Is the zlib implementation different from other deflate implementations?? Perhaps that is where all my confusion comes from?

Thank you for any help!! I need this for my new job

LuCu

Transonic answered 16/2, 2014 at 21:8 Comment(3)
Some of your questions are answered in the official specification: w3.org/TR/PNG-Compression.htmlLara
See also: zlib.net/feldspar.htmlAgee
Yes there is a default for libpng (it uses the zlib default), but the settings for strategy and level can be reset via libpng functions such as png_set_compression_level(png_ptr, level). The setting for filter also has a libpng default and can be set via png_set_filter().Albumen
C
6

PNG compression is in the zlib format. The zlib format uses deflate. The code used is commonly the zlib library.

The algorithm used for compression is not specified by the format. The zlib library deflate algorithm uses hash chains to search for matching strings in a sliding window. zlib's deflate takes several parameters for compression tuning -- see deflateInit2().

The deflate format specifies the compression of the Huffman codes at the front of dynamic blocks. The literal/length and distance code code lengths are run-length and Huffman coded themselves.

There are other implementations of deflate compressors in the LZMA SDK and Google's zopfli, where both of those use more intensive approaches that take more time for small gains in compression.

Cystolith answered 17/2, 2014 at 3:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.