madler / zlib

A massively spiffy yet delicately unobtrusive compression library.
http://zlib.net/
Other
5.71k stars 2.45k forks source link

Should deflateBound return the tight bound for default w_bits and memLevel 9? #822

Closed michalc closed 1 year ago

michalc commented 1 year ago

At the moment in deflateBound if memLevel is 9 with default w_bits, then it looks like one of the conservative bounds is returned. This strikes me as odd since sizes should(?) be smaller than for memLevel 8 when the lower/tighter bound is returned.

Can the tight bound be returned instead in this case? So specifically

if (s->w_bits != 15 || s->hash_bits != 8 + 7)

changed to

if (s->w_bits != 15 || s->hash_bits < 8 + 7)

(If so - am happy to raise a PR)

madler commented 1 year ago

No. In fact it can be larger.

michalc commented 1 year ago

Oh good to know!