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
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.
来源:https://stackoverflow.com/questions/21816646/png-deflate-and-zlib