gfx/inflate.h
DEFLATE, because PNG is a container around it.
#include <sonore/gfx/inflate.h>- 2types
On this page
Design notes
Why this is written rather than depended on
The alternative is vendoring miniz or stb_image, which are both fine and both permissively licensed. This SDK already parses TrueType itself and rasterises itself rather than taking a library for either, on the argument that the small thing you understand beats the big thing you do not. DEFLATE is the same size of problem as those: one Huffman decoder, three block types, and a sliding window.
It is also the part of a PNG decoder where a bug is a SECURITY bug. Every length and every distance in the stream is attacker-controlled, and a decoder that trusts them reads or writes outside its buffers. Writing it means every one of those bounds is a line somebody chose, and the tests below aim at exactly those lines rather than at "does this image look right".
What it implements
RFC 1951 in full: stored, fixed-Huffman and dynamic-Huffman blocks. Plus the two-byte RFC 1950 zlib wrapper PNG puts around it. Not implemented, because nothing produces them: preset dictionaries, and the reserved block type 3 which is an error by definition.
Types 2
A canonical Huffman decoder built from code lengths.
DEFLATE never transmits the codes themselves, only how LONG each symbol's code is; the codes follow from the lengths by a rule both ends know. That is the whole trick of the format and it is why this table is rebuilt for every dynamic block.
Raw DEFLATE and zlib-wrapped DEFLATE.
limit is not optional. A compressed stream is a handful of bytes that can legitimately expand to gigabytes, and a decoder with no ceiling turns a malformed preset or a hostile PNG into an out-of-memory kill of the HOST -- which is a plugin taking a DAW down with it.