55 " deflate 1.2.11 Copyright 1995-2017 Jean-loup Gailly and Mark Adler ";
91 # pragma message("Assembler code may have bugs -- use at your own risk") 92 void match_init
OF((
void));
111 # define TOO_FAR 4096 155 #define RANK(f) (((f) * 2) - ((f) > 4 ? 9 : 0)) 163 #define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask) 177 #define INSERT_STRING(s, str, match_head) \ 178 (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ 179 match_head = s->head[s->ins_h], \ 180 s->head[s->ins_h] = (Pos)(str)) 182 #define INSERT_STRING(s, str, match_head) \ 183 (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ 184 match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \ 185 s->head[s->ins_h] = (Pos)(str)) 192 #define CLEAR_HASH(s) \ 194 s->head[s->hash_size-1] = NIL; \ 195 zmemzero((Bytef *)s->head, \ 196 (unsigned)(s->hash_size-1)*sizeof(*s->head)); \ 209 uInt wsize =
s->w_size;
215 *
p = (
Pos)(
m >= wsize ?
m - wsize :
NIL);
222 *
p = (
Pos)(
m >= wsize ?
m - wsize :
NIL);
316 s->w_size = 1 <<
s->w_bits;
317 s->w_mask =
s->w_size - 1;
319 s->hash_bits = (
uInt)memLevel + 7;
320 s->hash_size = 1 <<
s->hash_bits;
321 s->hash_mask =
s->hash_size - 1;
330 s->lit_bufsize = 1 << (memLevel + 6);
333 s->pending_buf = (
uchf *) overlay;
334 s->pending_buf_size = (
ulg)
s->lit_bufsize * (
sizeof(
ush)+2
L);
343 s->d_buf = overlay +
s->lit_bufsize/
sizeof(
ush);
344 s->l_buf =
s->pending_buf + (1+
sizeof(
ush))*
s->lit_bufsize;
403 if (dictLength >=
s->w_size) {
411 dictLength =
s->w_size;
417 strm->avail_in = dictLength;
426 s->prev[
str &
s->w_mask] =
s->head[
s->ins_h];
435 s->strstart +=
s->lookahead;
436 s->block_start = (
long)
s->strstart;
437 s->insert =
s->lookahead;
440 s->match_available = 0;
459 len =
s->strstart +
s->lookahead;
479 strm->total_in =
strm->total_out = 0;
485 s->pending_out =
s->pending_buf;
561 s->bi_buf |= (
ush)((
value & ((1 <<
put) - 1)) <<
s->bi_valid);
598 if (
strm->avail_out == 0)
602 if (
s->level == 0 &&
s->matches != 0) {
631 s->good_match = (
uInt)good_length;
632 s->max_lazy_match = (
uInt)max_lazy;
633 s->nice_match = nice_length;
634 s->max_chain_length = (
uInt)max_chain;
660 uLong complen, wraplen;
663 complen = sourceLen +
664 ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5;
677 wraplen = 6 + (
s->strstart ? 4 : 0);
684 if (
s->gzhead->extra !=
Z_NULL)
685 wraplen += 2 +
s->gzhead->extra_len;
686 str =
s->gzhead->name;
691 str =
s->gzhead->comment;
706 if (
s->w_bits != 15 ||
s->hash_bits != 8 + 7)
707 return complen + wraplen;
710 return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
711 (sourceLen >> 25) + 13 - 6 + wraplen;
742 if (
len == 0)
return;
746 s->pending_out +=
len;
750 if (
s->pending == 0) {
751 s->pending_out =
s->pending_buf;
758 #define HCRC_UPDATE(beg) \ 760 if (s->gzhead->hcrc && s->pending > (beg)) \ 761 strm->adler = crc32(strm->adler, s->pending_buf + (beg), \ 762 s->pending - (beg)); \ 785 old_flush =
s->last_flush;
789 if (
s->pending != 0) {
791 if (
strm->avail_out == 0) {
824 else if (
s->level < 6)
826 else if (
s->level == 6)
830 header |= (level_flags << 6);
837 if (
s->strstart != 0) {
846 if (
s->pending != 0) {
872 if (
s->pending != 0) {
879 (
s->gzhead->hcrc ? 2 : 0) +
880 (
s->gzhead->extra ==
Z_NULL ? 0 : 4) +
881 (
s->gzhead->name ==
Z_NULL ? 0 : 8) +
882 (
s->gzhead->comment ==
Z_NULL ? 0 : 16)
892 if (
s->gzhead->extra !=
Z_NULL) {
894 put_byte(
s, (
s->gzhead->extra_len >> 8) & 0xff);
904 if (
s->gzhead->extra !=
Z_NULL) {
905 ulg beg =
s->pending;
906 uInt left = (
s->gzhead->extra_len & 0xffff) -
s->gzindex;
910 s->gzhead->extra +
s->gzindex,
copy);
911 s->pending =
s->pending_buf_size;
915 if (
s->pending != 0) {
923 s->gzhead->extra +
s->gzindex,
left);
931 if (
s->gzhead->name !=
Z_NULL) {
932 ulg beg =
s->pending;
935 if (
s->pending ==
s->pending_buf_size) {
938 if (
s->pending != 0) {
953 if (
s->gzhead->comment !=
Z_NULL) {
954 ulg beg =
s->pending;
957 if (
s->pending ==
s->pending_buf_size) {
960 if (
s->pending != 0) {
966 val =
s->gzhead->comment[
s->gzindex++];
974 if (
s->gzhead->hcrc) {
975 if (
s->pending + 2 >
s->pending_buf_size) {
977 if (
s->pending != 0) {
990 if (
s->pending != 0) {
999 if (
strm->avail_in != 0 ||
s->lookahead != 0 ||
1012 if (
strm->avail_out == 0) {
1034 if (
s->lookahead == 0) {
1036 s->block_start = 0
L;
1042 if (
strm->avail_out == 0) {
1074 if (
s->wrap > 0)
s->wrap = -
s->wrap;
1135 ds->pending_buf = (
uchf *) overlay;
1148 ds->pending_out =
ds->pending_buf + (
ss->pending_out -
ss->pending_buf);
1149 ds->d_buf = overlay +
ds->lit_bufsize/
sizeof(
ush);
1150 ds->l_buf =
ds->pending_buf + (1+
sizeof(
ush))*
ds->lit_bufsize;
1152 ds->l_desc.dyn_tree =
ds->dyn_ltree;
1153 ds->d_desc.dyn_tree =
ds->dyn_dtree;
1154 ds->bl_desc.dyn_tree =
ds->bl_tree;
1172 unsigned len =
strm->avail_in;
1175 if (
len == 0)
return 0;
1180 if (
strm->state->wrap == 1) {
1184 else if (
strm->state->wrap == 2) {
1200 s->window_size = (
ulg)2
L*
s->w_size;
1212 s->block_start = 0
L;
1216 s->match_available = 0;
1243 unsigned chain_length =
s->max_chain_length;
1244 register Bytef *scan =
s->window +
s->strstart;
1247 int best_len = (
int)
s->prev_length;
1255 uInt wmask =
s->w_mask;
1262 register ush scan_start = *(
ushf*)scan;
1263 register ush scan_end = *(
ushf*)(scan+best_len-1);
1266 register Byte scan_end1 = scan[best_len-1];
1267 register Byte scan_end = scan[best_len];
1276 if (
s->prev_length >=
s->good_match) {
1288 match =
s->window + cur_match;
1298 #if (defined(UNALIGNED_OK) && MAX_MATCH == 258) 1302 if (*(
ushf*)(
match+best_len-1) != scan_end ||
1325 Assert(scan <= s->
window+(
unsigned)(
s->window_size-1),
"wild scan");
1326 if (*scan == *
match) scan++;
1333 if (
match[best_len] != scan_end ||
1334 match[best_len-1] != scan_end1 ||
1336 *++
match != scan[1])
continue;
1351 }
while (*++scan == *++
match && *++scan == *++
match &&
1352 *++scan == *++
match && *++scan == *++
match &&
1353 *++scan == *++
match && *++scan == *++
match &&
1354 *++scan == *++
match && *++scan == *++
match &&
1357 Assert(scan <= s->
window+(
unsigned)(
s->window_size-1),
"wild scan");
1364 if (
len > best_len) {
1365 s->match_start = cur_match;
1369 scan_end = *(
ushf*)(scan+best_len-1);
1371 scan_end1 = scan[best_len-1];
1372 scan_end = scan[best_len];
1375 }
while ((cur_match =
prev[cur_match & wmask]) >
limit 1376 && --chain_length != 0);
1378 if ((
uInt)best_len <=
s->lookahead)
return (
uInt)best_len;
1379 return s->lookahead;
1392 register Bytef *scan =
s->window +
s->strstart;
1406 match =
s->window + cur_match;
1418 scan += 2,
match += 2;
1425 }
while (*++scan == *++
match && *++scan == *++
match &&
1426 *++scan == *++
match && *++scan == *++
match &&
1427 *++scan == *++
match && *++scan == *++
match &&
1428 *++scan == *++
match && *++scan == *++
match &&
1431 Assert(scan <= s->
window+(
unsigned)(
s->window_size-1),
"wild scan");
1437 s->match_start = cur_match;
1464 z_error(
"invalid match");
1466 if (z_verbose > 1) {
1472 # define check_match(s, start, match, length) 1490 uInt wsize =
s->w_size;
1498 if (
sizeof(
int) <= 2) {
1499 if (more == 0 &&
s->strstart == 0 &&
s->lookahead == 0) {
1502 }
else if (more == (
unsigned)(-1)) {
1515 zmemcpy(
s->window,
s->window+wsize, (
unsigned)wsize - more);
1516 s->match_start -= wsize;
1517 s->strstart -= wsize;
1518 s->block_start -= (
long) wsize;
1522 if (
s->strm->avail_in == 0)
break;
1535 Assert(more >= 2,
"more < 2");
1537 n =
read_buf(
s->strm,
s->window +
s->strstart +
s->lookahead, more);
1543 s->ins_h =
s->window[
str];
1551 s->prev[
str &
s->w_mask] =
s->head[
s->ins_h];
1573 if (
s->high_water <
s->window_size) {
1574 ulg curr =
s->strstart + (
ulg)(
s->lookahead);
1577 if (
s->high_water < curr) {
1581 init =
s->window_size - curr;
1585 s->high_water = curr +
init;
1593 if (
init >
s->window_size -
s->high_water)
1594 init =
s->window_size -
s->high_water;
1596 s->high_water +=
init;
1601 "not enough room for search");
1608 #define FLUSH_BLOCK_ONLY(s, last) { \ 1609 _tr_flush_block(s, (s->block_start >= 0L ? \ 1610 (charf *)&s->window[(unsigned)s->block_start] : \ 1612 (ulg)((long)s->strstart - s->block_start), \ 1614 s->block_start = s->strstart; \ 1615 flush_pending(s->strm); \ 1616 Tracev((stderr,"[FLUSH]")); \ 1620 #define FLUSH_BLOCK(s, last) { \ 1621 FLUSH_BLOCK_ONLY(s, last); \ 1622 if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \ 1626 #define MAX_STORED 65535 1629 #define MIN(a, b) ((a) > (b) ? (b) : (a)) 1654 unsigned min_block =
MIN(
s->pending_buf_size - 5,
s->w_size);
1661 unsigned used =
s->strm->avail_in;
1668 have = (
s->bi_valid + 42) >> 3;
1669 if (
s->strm->avail_out < have)
1672 have =
s->strm->avail_out - have;
1673 left =
s->strstart -
s->block_start;
1696 s->pending_buf[
s->pending - 4] =
len;
1697 s->pending_buf[
s->pending - 3] =
len >> 8;
1698 s->pending_buf[
s->pending - 2] = ~
len;
1699 s->pending_buf[
s->pending - 1] = ~
len >> 8;
1706 s->compressed_len +=
len << 3;
1707 s->bits_sent +=
len << 3;
1715 s->strm->next_out +=
left;
1716 s->strm->avail_out -=
left;
1717 s->strm->total_out +=
left;
1718 s->block_start +=
left;
1727 s->strm->next_out +=
len;
1728 s->strm->avail_out -=
len;
1729 s->strm->total_out +=
len;
1731 }
while (
last == 0);
1739 used -=
s->strm->avail_in;
1744 if (
used >=
s->w_size) {
1746 zmemcpy(
s->window,
s->strm->next_in -
s->w_size,
s->w_size);
1747 s->strstart =
s->w_size;
1750 if (
s->window_size -
s->strstart <=
used) {
1752 s->strstart -=
s->w_size;
1753 zmemcpy(
s->window,
s->window +
s->w_size,
s->strstart);
1758 s->strstart +=
used;
1760 s->block_start =
s->strstart;
1761 s->insert +=
MIN(
used,
s->w_size -
s->insert);
1763 if (
s->high_water <
s->strstart)
1764 s->high_water =
s->strstart;
1772 s->strm->avail_in == 0 && (
long)
s->strstart ==
s->block_start)
1776 have =
s->window_size -
s->strstart - 1;
1777 if (
s->strm->avail_in > have &&
s->block_start >= (
long)
s->w_size) {
1779 s->block_start -=
s->w_size;
1780 s->strstart -=
s->w_size;
1781 zmemcpy(
s->window,
s->window +
s->w_size,
s->strstart);
1786 if (have >
s->strm->avail_in)
1787 have =
s->strm->avail_in;
1790 s->strstart += have;
1792 if (
s->high_water <
s->strstart)
1793 s->high_water =
s->strstart;
1800 have = (
s->bi_valid + 42) >> 3;
1803 min_block =
MIN(have,
s->w_size);
1804 left =
s->strstart -
s->block_start;
1805 if (
left >= min_block ||
1807 s->strm->avail_in == 0 &&
left <= have)) {
1812 s->block_start +=
len;
1845 if (
s->lookahead == 0)
break;
1859 if (hash_head !=
NIL &&
s->strstart - hash_head <=
MAX_DIST(
s)) {
1873 s->lookahead -=
s->match_length;
1879 if (
s->match_length <=
s->max_insert_length &&
1888 }
while (--
s->match_length != 0);
1893 s->strstart +=
s->match_length;
1894 s->match_length = 0;
1895 s->ins_h =
s->window[
s->strstart];
1948 if (
s->lookahead == 0)
break;
1961 s->prev_length =
s->match_length,
s->prev_match =
s->match_start;
1964 if (hash_head !=
NIL &&
s->prev_length <
s->max_lazy_match &&
1989 if (
s->prev_length >=
MIN_MATCH &&
s->match_length <=
s->prev_length) {
2003 s->lookahead -=
s->prev_length-1;
2004 s->prev_length -= 2;
2006 if (++
s->strstart <= max_insert) {
2009 }
while (--
s->prev_length != 0);
2010 s->match_available = 0;
2016 }
else if (
s->match_available) {
2028 if (
s->strm->avail_out == 0)
return need_more;
2033 s->match_available = 1;
2039 if (
s->match_available) {
2042 s->match_available = 0;
2066 Bytef *scan, *strend;
2078 if (
s->lookahead == 0)
break;
2082 s->match_length = 0;
2083 if (
s->lookahead >=
MIN_MATCH &&
s->strstart > 0) {
2084 scan =
s->window +
s->strstart - 1;
2086 if (
prev == *++scan &&
prev == *++scan &&
prev == *++scan) {
2089 }
while (
prev == *++scan &&
prev == *++scan &&
2090 prev == *++scan &&
prev == *++scan &&
2091 prev == *++scan &&
prev == *++scan &&
2092 prev == *++scan &&
prev == *++scan &&
2095 if (
s->match_length >
s->lookahead)
2096 s->match_length =
s->lookahead;
2107 s->lookahead -=
s->match_length;
2108 s->strstart +=
s->match_length;
2109 s->match_length = 0;
2141 if (
s->lookahead == 0) {
2143 if (
s->lookahead == 0) {
2151 s->match_length = 0;
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
int ZEXPORT deflateGetDictionary(z_streamp strm, Bytef *dictionary, uInt *dictLength)
int ZEXPORT deflateParams(z_streamp strm, int level, int strategy)
block_state compress_func OF((deflate_state *s, int flush))
block_state deflate_slow(deflate_state *s, int flush)
#define INSERT_STRING(s, str, match_head)
void putShortMSB(deflate_state *s, uInt b)
#define check_match(s, start, match, length)
struct outqueuenode * head
block_state deflate_fast(deflate_state *s, int flush)
void ZLIB_INTERNAL _tr_align(deflate_state *s)
#define zmemzero(dest, len)
#define Z_DEFAULT_COMPRESSION
#define UPDATE_HASH(s, h, c)
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy, const char *version, int stream_size)
uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen)
int ZEXPORT deflateEnd(z_streamp strm)
int ZEXPORT deflatePrime(z_streamp strm, int bits, int value)
unsigned read_buf(z_streamp strm, Bytef *buf, unsigned size)
const char deflate_copyright[]
GLenum GLuint GLenum GLsizei const GLchar * buf
#define _tr_tally_lit(s, c, flush)
const config configuration_table[10]
void fill_window(deflate_state *s)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
#define ZFREE(strm, addr)
GLenum GLuint GLenum GLsizei length
static const WCHAR version[]
int ZEXPORT deflateCopy(z_streamp dest, z_streamp source)
static const struct encodedFiletime times[]
int ZEXPORT deflateTune(z_streamp strm, int good_length, int max_lazy, int nice_length, int max_chain)
void ZLIB_INTERNAL _tr_init(deflate_state *s)
_Check_return_opt_ _CRTIMP int __cdecl putc(_In_ int _Ch, _Inout_ FILE *_File)
void(* free_func)(voidpf opaque, voidpf address)
GLboolean GLboolean GLboolean b
static const unsigned char dictionary[][3]
int const char int stream_size
int deflateStateCheck(z_streamp strm)
void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s)
block_state deflate_rle(deflate_state *s, int flush)
#define _tr_tally_dist(s, distance, length, flush)
int ZEXPORT deflate(z_streamp strm, int flush)
GLsizei const GLfloat * value
void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf, ulg stored_len, int last)
static IHTMLWindow2 * window
#define ZALLOC(strm, items, size)
gz_header FAR * gz_headerp
block_state deflate_stored(deflate_state *s, int flush)
static unsigned __int64 next
uInt longest_match(deflate_state *s, IPos cur_match)
void zcfree(voidpf opaque, voidpf ptr)
GLsizei GLsizei GLchar * source
int zmemcmp(Bytef *s1, const Bytef *s2, uInt len) const
void slide_hash(deflate_state *s)
int ZEXPORT deflateResetKeep(z_streamp strm)
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
int ZEXPORT deflateSetDictionary(z_streamp strm, const Bytef *dictionary, uInt dictLength)
voidpf zcalloc(voidpf opaque, unsigned items, unsigned size)
int ZEXPORT deflateSetHeader(z_streamp strm, gz_headerp head)
#define FLUSH_BLOCK(s, last)
#define crc32(crc, buf, len)
int ZEXPORT deflateInit_(z_streamp strm, int level, const char *version, int stream_size)
voidpf(* alloc_func)(voidpf opaque, uInt items, uInt size)
void flush_pending(z_streamp strm)
int ZEXPORT deflateReset(z_streamp strm)
int ZEXPORT deflatePending(z_streamp strm, unsigned *pending, int *bits)
#define wrap(journal, var)
block_state deflate_huff(deflate_state *s, int flush)
void lm_init(deflate_state *s)
static SERVICE_STATUS status
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
#define Assert(cond, msg)
#define Z_DEFAULT_STRATEGY
#define ERR_RETURN(strm, err)
static unsigned(__cdecl *hash_bstr)(bstr_t s)
#define FLUSH_BLOCK_ONLY(s, last)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *