-
Notifications
You must be signed in to change notification settings - Fork 155
Fix buffer size dependency for no-end zlib #644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
I was testing this locally in combination with #640 and that seems to be important. I was quite defensive with the implementation of the flush behavior and it won't indicate all available data as available but instead performs the same as the usual decoding. This is due to potential internal buffering in This should eliminate the need for a loop as well, the |
|
Turns out the comprehensive fix seemed even harder that the above comment. It goes like this: the currently published code detects whether the IDAT sequence (or fdat) is finished by comparing the next chunk type. For this, it consumes the input stream to fill the bytes that go into Now, this code relies on the caller retrying the So the idea for the fix is now to delay the state change entirely until we can do it without flushing, i.e. until the image data itself has ended. |
|
This seems to improve performance. Some quite significantly. (I think it mostly avoids the weird forced buffer allocations we previously had in the flush call). Alas, it's almost suspicious so no benchmark numbers for now. |
|
I've been thinking about this more, and I believe that the only reason we need to produce more data in Instead, it might be possible to remain in the
Yes, the only time you need to call fdeflate decompression in a loop is if you provide more input data or output space on subsequent iterations. Also for the record: the comment that |
Draft to be benchmarked.
Ensure that the buffer is fully flushed before checking for an end-of-file marker via the bool-flag in
fdeflate. We first pass an empty input without setting the flag and repeat the whole flush cycle if that still yielded data. That same data could previously be masked by the missing end-of-file error.See: image-rs/fdeflate#58 (comment)