In the "Maximum Expansion Factor" section of the zlib technical details it is stated "In the worst possible case, where the other block types would expand the data, deflation falls back to stored (uncompressed) blocks."
I am having a hard time figuring out where in the zlib compress/deflate code this decision actually happens. I can see that deflate_stored
is called when the selected level
is 0, which makes sense, but besides that I don't see it being used.
If someone can point me in the right direction that would be helpful.
Also, what is the block granularity (in terms of the uncompressed data) that these decisions are taken? I understand that in deflate the uncompressed block can be upto 64KB, but there is no defined block size for the compressed chunks. Clearly it has to do with how useful the huffman codes are for the blocks but it would be nice to know if there was a block size at which these decisions are taken.