image-rs / deflate-rs

An implementation of a DEFLATE encoder in rust
Apache License 2.0
53 stars 14 forks source link

Hash chains are not updated correctly in some cases. #15

Closed oyvindln closed 7 years ago

oyvindln commented 7 years ago

This seems to significantly degrade compression ratio on many larger files.

oyvindln commented 7 years ago

So it seems the main issue was that adding bytes from the lookahead window to the hash chain before sliding, resulting in the values added to head pointing to the wrong place.

Additionally, the first byte after the lz77 output buffer is reset ends up being added to the hash table twice also caused some issues.