diff options
| author | Jim Kukunas <james.t.kukunas@linux.intel.com> | 2013-07-18 13:19:05 -0700 |
|---|---|---|
| committer | Jim Kukunas <james.t.kukunas@linux.intel.com> | 2014-07-26 15:53:17 -0700 |
| commit | d948170e11e4eaa68cce189e5ea10a4d41e01437 (patch) | |
| tree | 61d57f3abbc292e2a063b49e46ee19d9d82a8c2b /trees.c | |
| parent | 3684659f485b63f7482a8dc600f51112c556ce9d (diff) | |
| download | Project-Tick-d948170e11e4eaa68cce189e5ea10a4d41e01437.tar.gz Project-Tick-d948170e11e4eaa68cce189e5ea10a4d41e01437.zip | |
deflate: add new deflate_quick strategy for level 1
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
Diffstat (limited to 'trees.c')
| -rw-r--r-- | trees.c | 80 |
1 files changed, 4 insertions, 76 deletions
@@ -47,9 +47,6 @@ #define MAX_BL_BITS 7 /* Bit length codes must not exceed MAX_BL_BITS bits */ -#define END_BLOCK 256 -/* end of block literal code */ - #define REP_3_6 16 /* repeat previous bit length 3-6 times (2 bits of repeat count) */ @@ -83,7 +80,7 @@ local const uch bl_order[BL_CODES] #if defined(GEN_TREES_H) || !defined(STDC) /* non ANSI compilers may not accept trees.h */ -local ct_data static_ltree[L_CODES+2]; +ZLIB_INTERNAL ct_data static_ltree[L_CODES+2]; /* The static literal tree. Since the bit lengths are imposed, there is no * need for the L_CODES extra codes used during heap construction. However * The codes 286 and 287 are needed to build a canonical tree (see _tr_init @@ -150,7 +147,6 @@ local void compress_block OF((deflate_state *s, const ct_data *ltree, const ct_data *dtree)); local int detect_data_type OF((deflate_state *s)); local unsigned bi_reverse OF((unsigned value, int length)); -local void bi_windup OF((deflate_state *s)); local void bi_flush OF((deflate_state *s)); local void copy_block OF((deflate_state *s, charf *buf, unsigned len, int header)); @@ -159,75 +155,6 @@ local void copy_block OF((deflate_state *s, charf *buf, unsigned len, local void gen_trees_header OF((void)); #endif -#ifndef DEBUG -# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) - /* Send a code of the given tree. c and tree must not have side effects */ - -#else /* DEBUG */ -# define send_code(s, c, tree) \ - { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \ - send_bits(s, tree[c].Code, tree[c].Len); } -#endif - -/* =========================================================================== - * Output a short LSB first on the stream. - * IN assertion: there is enough room in pendingBuf. - */ -#define put_short(s, w) { \ - put_byte(s, (uch)((w) & 0xff)); \ - put_byte(s, (uch)((ush)(w) >> 8)); \ -} - -/* =========================================================================== - * Send a value on a given number of bits. - * IN assertion: length <= 16 and value fits in length bits. - */ -#ifdef DEBUG -local void send_bits OF((deflate_state *s, int value, int length)); - -local void send_bits(s, value, length) - deflate_state *s; - int value; /* value to send */ - int length; /* number of bits */ -{ - Tracevv((stderr," l %2d v %4x ", length, value)); - Assert(length > 0 && length <= 15, "invalid length"); - s->bits_sent += (ulg)length; - - /* If not enough room in bi_buf, use (valid) bits from bi_buf and - * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid)) - * unused bits in value. - */ - if (s->bi_valid > (int)Buf_size - length) { - s->bi_buf |= (ush)value << s->bi_valid; - put_short(s, s->bi_buf); - s->bi_buf = (ush)value >> (Buf_size - s->bi_valid); - s->bi_valid += length - Buf_size; - } else { - s->bi_buf |= (ush)value << s->bi_valid; - s->bi_valid += length; - } -} -#else /* !DEBUG */ - -#define send_bits(s, value, length) \ -{ int len = length;\ - if (s->bi_valid > (int)Buf_size - len) {\ - int val = value;\ - s->bi_buf |= (ush)val << s->bi_valid;\ - put_short(s, s->bi_buf);\ - s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\ - s->bi_valid += len - Buf_size;\ - } else {\ - s->bi_buf |= (ush)(value) << s->bi_valid;\ - s->bi_valid += len;\ - }\ -} -#endif /* DEBUG */ - - -/* the arguments must not have side effects */ - /* =========================================================================== * Initialize the various 'constant' tables. */ @@ -334,7 +261,7 @@ void gen_trees_header() fprintf(header, "/* header created automatically with -DGEN_TREES_H */\n\n"); - fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n"); + fprintf(header, "ZLIB_INTERNAL const ct_data static_ltree[L_CODES+2] = {\n"); for (i = 0; i < L_CODES+2; i++) { fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code, static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5)); @@ -1183,7 +1110,7 @@ local void bi_flush(s) /* =========================================================================== * Flush the bit buffer and align the output on a byte boundary */ -local void bi_windup(s) +ZLIB_INTERNAL void bi_windup(s) deflate_state *s; { if (s->bi_valid > 8) { @@ -1224,3 +1151,4 @@ local void copy_block(s, buf, len, header) put_byte(s, *buf++); } } + |
