summaryrefslogtreecommitdiff
path: root/deflate_p.h
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2016-11-05 08:43:29 -0700
committerHans Kristian Rosbach <hk-git@circlestorm.org>2017-02-06 12:40:06 +0100
commit40039a039c26da37cdc972aa650a9ea40e310f20 (patch)
tree63d5bbdfcc02adfca7dfe1c357fe1b67a2e826b1 /deflate_p.h
parente84a42f7a34c7f8728d669a747d149907ec9818c (diff)
Speed up deflation for level 0 (storing).
The previous code slid the window and the hash table and copied every input byte three times in order to just write the data as stored blocks with no compression. This commit minimizes sliding and copying, especially for large input and output buffers. Level 0 compression is now more than 20 times faster than before the commit. Most of the speedup is due to deferring hash table slides until deflateParams() is called to change the compression level away from 0. More speedup is due to copying directly from next_in to next_out when the amounts of available input data and output space permit it, avoiding the intermediate pending buffer. Additionally, only the last 32K of the used input data is copied back to the sliding window when large input buffers are provided.
Diffstat (limited to 'deflate_p.h')
-rw-r--r--deflate_p.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/deflate_p.h b/deflate_p.h
index 67dc6eb..6c9957a 100644
--- a/deflate_p.h
+++ b/deflate_p.h
@@ -80,4 +80,10 @@ static inline Pos insert_string(deflate_state *const s, const Pos str, uInt coun
if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \
}
+/* Maximum stored block length in deflate format (not including header). */
+#define MAX_STORED 65535
+
+/* Minimum of a and b. */
+#define MIN(a, b) ((a) > (b) ? (b) : (a))
+
#endif