Closed nemequ closed 8 years ago
This is issue #14 - apparently never fully fixed. I will look into this in a few days.
This is now hopefully fixed in 60ef3852dbd49cb8504c8500033d471fc3344834.
Previously I was not taking into account the fact that for the last chunk of data the end-of-stream symbol would cause another symbol to be written as 9 bits as well, which adds up to 32 additional bytes to the data (+2 for the end-of-stream 9 bits and the 2-byte alignment).
The last thing to test just to make sure it works is a stream that has each byte 0-255 exactly 256 times each and is uncompressible. This may end up requiring it to be +33 instead of +32. I just need to come up with how to design that compression-killer...
Calculated it for the theoretical I described above:
floor((9*256*1 + 8*256*255 + 9*1*1 + 16 + 15) / 16) * 2 - 65536 = 36
So it actually needs to be +34 (not including the +2 for 2-byte alignment).
With
I get
I think the problem is in the compressor, not the size calculation, since it doesn't seem to matter how much room I give it (e.g., adding 65536 bytes to
compressed_size
has no effect).