Fixed jpeg encoder last bytes flushing bug #1876
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prerequisites
Description
I've made quite a mistake during jpeg encoder optimization for last bytes flushing to the stream:
uint
buffer size is 4 for simplicity. Let's say we have 3 bits to pad with 1's for full byte and write to the stream:So extra 6 bytes written on top of 1 byte with actual information. Same setup with fix from this PR:
This bug wasn't critical and actually isn't spottable by photoshop or JpegSnoop as extra written bytes do not corrupt resulting jpeg but it's still a problem introduced in one of my PRs (I'm really sorry).
I've tested a couple of images from test folder and got following binary size difference:
Calliphora.jpg:
master: 257.540b
PR: 257.537b
winter420_noninterleaved.jpg: -
master: 248.048b
PR: 248.042b