summaryrefslogtreecommitdiff
path: root/deflate_quick.c
AgeCommit message (Collapse)Author
2021-03-17Fix block_open handling in deflate_quick()Ilya Leoshkevich
The attached test fails with "inflate() failed", because the deflate stream that it produces ends up being corrupted. Bisect points to the commit e7bb6db09a18 ("Replace hash_bits, hash_size and hash_mask with defines."), but it's most likely a coincidence. In any case, the reason is that if we happen to simultaneously exhaust all the buffers (in, out and bi), we return finish_started without writing the end of block symbol, which will never happen afterwards. Fix by adding another check to the tricky condition: if we are in the middle of a block, return need_more instead of finish_started.
2021-03-16Fix bi_valid handling in deflate_quick()Ilya Leoshkevich iii@linux.ibm.com
The attached test started failing after commit ad89d5131b29 ("Don't write end of last block when returning finish_started."): either with "bi_buf not flushed" message in debug builds, or by producing corrupted output in release builds. The problem is that we must not return finish_started when bi_buf is not empty, because the bits there will be lost. Fix by checking that bi_valid is not 0.
2020-10-18Fixed unsigned integer overflow ASAN error when hash_head > s->strstart.Nathan Moinvaziri
zlib-ng/deflate_medium.c:244:47: runtime error: unsigned integer overflow: 58442 - 58452 cannot be represented in type 'unsigned int' Co-authored-by: Mika Lindqvist <postmaster@raasu.org> Co-authored-by: Hans Kristian Rosbach <hk-git@circlestorm.org>
2020-08-31Rename ZLIB_INTERNAL to Z_INTERNAL for consistency.Nathan Moinvaziri
2020-08-27Fix some of the old and new conversion warnings in deflate*Hans Kristian Rosbach
2020-07-14Return proper exit code after flushing end block in deflate_quick when no ↵Nathan Moinvaziri
available output.
2020-07-03Add likely/unlikely hinting to all deflate algorithms.Hans Kristian Rosbach
2020-06-28Don't write end of last block when returning finish_started.Nathan Moinvaziri
2020-06-28Fixed avail_out == 0 conditional not returning need_more in deflate_quick.Nathan Moinvaziri
Fixed ending block when returning need_more caused problems with inflate. So instead of ending the block each time the function returns to finish the last block, we check upon start to see if it is the last block and if the last block has been started, and if not it will close the previous block and start the last block.
2020-06-27Fixed whitespace in deflate_quick.Nathan Moinvaziri
2020-06-18Move check to start block out of main loop for performance reasons.Nathan Moinvaziri
2020-06-18Fixed deflate_quick to not emit a block when there is no available input. ↵Nathan Moinvaziri
Pigz requires no blocks to be emitted in certain instances when calling deflate with Z_BLOCK. Fixed end block not being emitted between calls to deflate_quick causing invalid stored block lengths in certain instances.
2020-06-08Move check for match length in deflate_quick to check_match.Nathan Moinvaziri
2020-06-08Make deflate_quick algorithm available to all architectures. #205Nathan Moinvaziri
2014-10-14Separate arch-specific code into separate foldershansr
2014-10-12Remove workarounds for non-ANSI-C compatible compilers (Part 2)hansr
-Removing usage of OF() definition
2014-07-26Add forward declarations for fill_window_sse and flush_pending to ↵Martin O. Pollard
deflate_quick.c.
2014-07-26deflate: add new deflate_quick strategy for level 1Jim Kukunas
The deflate_quick strategy is designed to provide maximum deflate performance. deflate_quick achieves this through: - only checking the first hash match - using a small inline SSE4.2-optimized longest_match - forcing a window size of 8K, and using a precomputed dist/len table - forcing the static Huffman tree and emitting codes immediately instead of tallying This patch changes the scope of flush_pending, bi_windup, and static_ltree to ZLIB_INTERNAL and moves END_BLOCK, send_code, put_short, and send_bits to deflate.h. Updates the configure script to enable by default for x86. On systems without SSE4.2, fallback is to deflate_fast strategy. Fixes #6 Fixes #8