• Home
  • Raw
  • Download

Lines Matching refs:s

73 typedef block_state (*compress_func) OF((deflate_state *s, int flush));
76 local void fill_window OF((deflate_state *s));
77 local block_state deflate_stored OF((deflate_state *s, int flush));
78 local block_state deflate_fast OF((deflate_state *s, int flush));
80 local block_state deflate_slow OF((deflate_state *s, int flush));
82 local block_state deflate_rle OF((deflate_state *s, int flush));
83 local block_state deflate_huff OF((deflate_state *s, int flush));
84 local void lm_init OF((deflate_state *s));
85 local void putShortMSB OF((deflate_state *s, uInt b));
90 uInt longest_match OF((deflate_state *s, IPos cur_match));
92 local uInt longest_match OF((deflate_state *s, IPos cur_match));
96 local void check_match OF((deflate_state *s, IPos start, IPos match,
167 #define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask) argument
181 #define INSERT_STRING(s, str, match_head) \ argument
182 (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
183 match_head = s->head[s->ins_h], \
184 s->head[s->ins_h] = (Pos)(str))
186 #define INSERT_STRING(s, str, match_head) \ argument
187 (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
188 match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \
189 s->head[s->ins_h] = (Pos)(str))
196 #define CLEAR_HASH(s) \ argument
197 s->head[s->hash_size-1] = NIL; \
198 zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
224 deflate_state *s; local
277 s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state));
278 if (s == Z_NULL) return Z_MEM_ERROR;
279 strm->state = (struct internal_state FAR *)s;
280 s->strm = strm;
282 s->wrap = wrap;
283 s->gzhead = Z_NULL;
284 s->w_bits = windowBits;
285 s->w_size = 1 << s->w_bits;
286 s->w_mask = s->w_size - 1;
288 s->hash_bits = memLevel + 7;
289 s->hash_size = 1 << s->hash_bits;
290 s->hash_mask = s->hash_size - 1;
291 s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);
293 s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte));
294 s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos));
295 s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos));
297 s->high_water = 0; /* nothing written to s->window yet */
299 s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
301 overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
302 s->pending_buf = (uchf *) overlay;
303 s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L);
305 if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
306 s->pending_buf == Z_NULL) {
307 s->status = FINISH_STATE;
312 s->d_buf = overlay + s->lit_bufsize/sizeof(ush);
313 s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;
315 s->level = level;
316 s->strategy = strategy;
317 s->method = (Byte)method;
328 deflate_state *s; local
336 s = strm->state;
337 wrap = s->wrap;
338 if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead)
344 s->wrap = 0; /* avoid computing Adler-32 in read_buf */
347 if (dictLength >= s->w_size) {
349 CLEAR_HASH(s);
350 s->strstart = 0;
351 s->block_start = 0L;
352 s->insert = 0;
354 dictionary += dictLength - s->w_size; /* use the tail */
355 dictLength = s->w_size;
363 fill_window(s);
364 while (s->lookahead >= MIN_MATCH) {
365 str = s->strstart;
366 n = s->lookahead - (MIN_MATCH-1);
368 UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);
370 s->prev[str & s->w_mask] = s->head[s->ins_h];
372 s->head[s->ins_h] = (Pos)str;
375 s->strstart = str;
376 s->lookahead = MIN_MATCH-1;
377 fill_window(s);
379 s->strstart += s->lookahead;
380 s->block_start = (long)s->strstart;
381 s->insert = s->lookahead;
382 s->lookahead = 0;
383 s->match_length = s->prev_length = MIN_MATCH-1;
384 s->match_available = 0;
387 s->wrap = wrap;
395 deflate_state *s; local
406 s = (deflate_state *)strm->state;
407 s->pending = 0;
408 s->pending_out = s->pending_buf;
410 if (s->wrap < 0) {
411 s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */
413 s->status = s->wrap ? INIT_STATE : BUSY_STATE;
416 s->wrap == 2 ? crc32(0L, Z_NULL, 0) :
419 s->last_flush = Z_NO_FLUSH;
421 _tr_init(s);
469 deflate_state *s; local
473 s = strm->state;
474 if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3))
477 put = Buf_size - s->bi_valid;
480 s->bi_buf |= (ush)((value & ((1 << put) - 1)) << s->bi_valid);
481 s->bi_valid += put;
482 _tr_flush_bits(s);
495 deflate_state *s; local
500 s = strm->state;
510 func = configuration_table[s->level].func;
512 if ((strategy != s->strategy || func != configuration_table[level].func) &&
516 if (err == Z_BUF_ERROR && s->pending == 0)
519 if (s->level != level) {
520 s->level = level;
521 s->max_lazy_match = configuration_table[level].max_lazy;
522 s->good_match = configuration_table[level].good_length;
523 s->nice_match = configuration_table[level].nice_length;
524 s->max_chain_length = configuration_table[level].max_chain;
526 s->strategy = strategy;
538 deflate_state *s; local
541 s = strm->state;
542 s->good_match = good_length;
543 s->max_lazy_match = max_lazy;
544 s->nice_match = nice_length;
545 s->max_chain_length = max_chain;
570 deflate_state *s; local
583 s = strm->state;
584 switch (s->wrap) {
589 wraplen = 6 + (s->strstart ? 4 : 0);
593 if (s->gzhead != Z_NULL) { /* user-supplied gzip header */
594 if (s->gzhead->extra != Z_NULL)
595 wraplen += 2 + s->gzhead->extra_len;
596 str = s->gzhead->name;
601 str = s->gzhead->comment;
606 if (s->gzhead->hcrc)
615 if (s->w_bits != 15 || s->hash_bits != 8 + 7)
628 local void putShortMSB (s, b) in putShortMSB() argument
629 deflate_state *s; in putShortMSB()
632 put_byte(s, (Byte)(b >> 8));
633 put_byte(s, (Byte)(b & 0xff));
646 deflate_state *s = strm->state; local
648 _tr_flush_bits(s);
649 len = s->pending;
653 zmemcpy(strm->next_out, s->pending_out, len);
655 s->pending_out += len;
658 s->pending -= len;
659 if (s->pending == 0) {
660 s->pending_out = s->pending_buf;
670 deflate_state *s; local
676 s = strm->state;
680 (s->status == FINISH_STATE && flush != Z_FINISH)) {
685 s->strm = strm; /* just in case */
686 old_flush = s->last_flush;
687 s->last_flush = flush;
690 if (s->status == INIT_STATE) {
692 if (s->wrap == 2) {
694 put_byte(s, 31);
695 put_byte(s, 139);
696 put_byte(s, 8);
697 if (s->gzhead == Z_NULL) {
698 put_byte(s, 0);
699 put_byte(s, 0);
700 put_byte(s, 0);
701 put_byte(s, 0);
702 put_byte(s, 0);
703 put_byte(s, s->level == 9 ? 2 :
704 (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
706 put_byte(s, OS_CODE);
707 s->status = BUSY_STATE;
710 put_byte(s, (s->gzhead->text ? 1 : 0) +
711 (s->gzhead->hcrc ? 2 : 0) +
712 (s->gzhead->extra == Z_NULL ? 0 : 4) +
713 (s->gzhead->name == Z_NULL ? 0 : 8) +
714 (s->gzhead->comment == Z_NULL ? 0 : 16)
716 put_byte(s, (Byte)(s->gzhead->time & 0xff));
717 put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff));
718 put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff));
719 put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff));
720 put_byte(s, s->level == 9 ? 2 :
721 (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
723 put_byte(s, s->gzhead->os & 0xff);
724 if (s->gzhead->extra != Z_NULL) {
725 put_byte(s, s->gzhead->extra_len & 0xff);
726 put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
728 if (s->gzhead->hcrc)
729 strm->adler = crc32(strm->adler, s->pending_buf,
730 s->pending);
731 s->gzindex = 0;
732 s->status = EXTRA_STATE;
738 uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
741 if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
743 else if (s->level < 6)
745 else if (s->level == 6)
750 if (s->strstart != 0) header |= PRESET_DICT;
753 s->status = BUSY_STATE;
754 putShortMSB(s, header);
757 if (s->strstart != 0) {
758 putShortMSB(s, (uInt)(strm->adler >> 16));
759 putShortMSB(s, (uInt)(strm->adler & 0xffff));
765 if (s->status == EXTRA_STATE) {
766 if (s->gzhead->extra != Z_NULL) {
767 uInt beg = s->pending; /* start of bytes to update crc */
769 while (s->gzindex < (s->gzhead->extra_len & 0xffff)) {
770 if (s->pending == s->pending_buf_size) {
771 if (s->gzhead->hcrc && s->pending > beg)
772 strm->adler = crc32(strm->adler, s->pending_buf + beg,
773 s->pending - beg);
775 beg = s->pending;
776 if (s->pending == s->pending_buf_size)
779 put_byte(s, s->gzhead->extra[s->gzindex]);
780 s->gzindex++;
782 if (s->gzhead->hcrc && s->pending > beg)
783 strm->adler = crc32(strm->adler, s->pending_buf + beg,
784 s->pending - beg);
785 if (s->gzindex == s->gzhead->extra_len) {
786 s->gzindex = 0;
787 s->status = NAME_STATE;
791 s->status = NAME_STATE;
793 if (s->status == NAME_STATE) {
794 if (s->gzhead->name != Z_NULL) {
795 uInt beg = s->pending; /* start of bytes to update crc */
799 if (s->pending == s->pending_buf_size) {
800 if (s->gzhead->hcrc && s->pending > beg)
801 strm->adler = crc32(strm->adler, s->pending_buf + beg,
802 s->pending - beg);
804 beg = s->pending;
805 if (s->pending == s->pending_buf_size) {
810 val = s->gzhead->name[s->gzindex++];
811 put_byte(s, val);
813 if (s->gzhead->hcrc && s->pending > beg)
814 strm->adler = crc32(strm->adler, s->pending_buf + beg,
815 s->pending - beg);
817 s->gzindex = 0;
818 s->status = COMMENT_STATE;
822 s->status = COMMENT_STATE;
824 if (s->status == COMMENT_STATE) {
825 if (s->gzhead->comment != Z_NULL) {
826 uInt beg = s->pending; /* start of bytes to update crc */
830 if (s->pending == s->pending_buf_size) {
831 if (s->gzhead->hcrc && s->pending > beg)
832 strm->adler = crc32(strm->adler, s->pending_buf + beg,
833 s->pending - beg);
835 beg = s->pending;
836 if (s->pending == s->pending_buf_size) {
841 val = s->gzhead->comment[s->gzindex++];
842 put_byte(s, val);
844 if (s->gzhead->hcrc && s->pending > beg)
845 strm->adler = crc32(strm->adler, s->pending_buf + beg,
846 s->pending - beg);
848 s->status = HCRC_STATE;
851 s->status = HCRC_STATE;
853 if (s->status == HCRC_STATE) {
854 if (s->gzhead->hcrc) {
855 if (s->pending + 2 > s->pending_buf_size)
857 if (s->pending + 2 <= s->pending_buf_size) {
858 put_byte(s, (Byte)(strm->adler & 0xff));
859 put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
861 s->status = BUSY_STATE;
865 s->status = BUSY_STATE;
870 if (s->pending != 0) {
879 s->last_flush = -1;
893 if (s->status == FINISH_STATE && strm->avail_in != 0) {
899 if (strm->avail_in != 0 || s->lookahead != 0 ||
900 (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
903 bstate = s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) :
904 (s->strategy == Z_RLE ? deflate_rle(s, flush) :
905 (*(configuration_table[s->level].func))(s, flush));
908 s->status = FINISH_STATE;
912 s->last_flush = -1; /* avoid BUF_ERROR next call, see above */
925 _tr_align(s);
927 _tr_stored_block(s, (char*)0, 0L, 0);
932 CLEAR_HASH(s); /* forget history */
933 if (s->lookahead == 0) {
934 s->strstart = 0;
935 s->block_start = 0L;
936 s->insert = 0;
942 s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */
950 if (s->wrap <= 0) return Z_STREAM_END;
954 if (s->wrap == 2) {
955 put_byte(s, (Byte)(strm->adler & 0xff));
956 put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
957 put_byte(s, (Byte)((strm->adler >> 16) & 0xff));
958 put_byte(s, (Byte)((strm->adler >> 24) & 0xff));
959 put_byte(s, (Byte)(strm->total_in & 0xff));
960 put_byte(s, (Byte)((strm->total_in >> 8) & 0xff));
961 put_byte(s, (Byte)((strm->total_in >> 16) & 0xff));
962 put_byte(s, (Byte)((strm->total_in >> 24) & 0xff));
967 putShortMSB(s, (uInt)(strm->adler >> 16));
968 putShortMSB(s, (uInt)(strm->adler & 0xffff));
974 if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */
975 return s->pending != 0 ? Z_OK : Z_STREAM_END;
1106 local void lm_init (s) in lm_init() argument
1107 deflate_state *s; in lm_init()
1109 s->window_size = (ulg)2L*s->w_size;
1111 CLEAR_HASH(s);
1115 s->max_lazy_match = configuration_table[s->level].max_lazy;
1116 s->good_match = configuration_table[s->level].good_length;
1117 s->nice_match = configuration_table[s->level].nice_length;
1118 s->max_chain_length = configuration_table[s->level].max_chain;
1120 s->strstart = 0;
1121 s->block_start = 0L;
1122 s->lookahead = 0;
1123 s->insert = 0;
1124 s->match_length = s->prev_length = MIN_MATCH-1;
1125 s->match_available = 0;
1126 s->ins_h = 0;
1148 local uInt longest_match(s, cur_match) in longest_match() argument
1149 deflate_state *s; in longest_match()
1152 unsigned chain_length = s->max_chain_length;/* max hash chain length */
1153 register Bytef *scan = s->window + s->strstart; /* current string */
1156 int best_len = s->prev_length; /* best match length so far */
1157 int nice_match = s->nice_match; /* stop if match long enough */
1158 IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
1159 s->strstart - (IPos)MAX_DIST(s) : NIL;
1163 Posf *prev = s->prev;
1164 uInt wmask = s->w_mask;
1170 register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;
1174 register Bytef *strend = s->window + s->strstart + MAX_MATCH;
1182 Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
1185 if (s->prev_length >= s->good_match) {
1191 if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
1193 Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
1196 Assert(cur_match < s->strstart, "no future");
1197 match = s->window + cur_match;
1234 Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
1266 Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
1274 s->match_start = cur_match;
1287 if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
1288 return s->lookahead;
1297 local uInt longest_match(s, cur_match) in longest_match() argument
1298 deflate_state *s; in longest_match()
1301 register Bytef *scan = s->window + s->strstart; /* current string */
1304 register Bytef *strend = s->window + s->strstart + MAX_MATCH;
1309 Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
1311 Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
1313 Assert(cur_match < s->strstart, "no future");
1315 match = s->window + cur_match;
1340 Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
1346 s->match_start = cur_match;
1347 return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead;
1356 local void check_match(s, start, match, length) in check_match() argument
1357 deflate_state *s; in check_match()
1362 if (zmemcmp(s->window + match,
1363 s->window + start, length) != EQUAL) {
1367 fprintf(stderr, "%c%c", s->window[match++], s->window[start++]);
1373 do { putc(s->window[start++], stderr); } while (--length != 0);
1377 # define check_match(s, start, match, length) argument
1390 local void fill_window(s) in fill_window() argument
1391 deflate_state *s; in fill_window()
1396 uInt wsize = s->w_size;
1398 Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
1401 more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
1405 if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
1419 if (s->strstart >= wsize+MAX_DIST(s)) {
1421 zmemcpy(s->window, s->window+wsize, (unsigned)wsize);
1422 s->match_start -= wsize;
1423 s->strstart -= wsize; /* we now have strstart >= MAX_DIST */
1424 s->block_start -= (long) wsize;
1432 n = s->hash_size;
1433 p = &s->head[n];
1441 p = &s->prev[n];
1452 if (s->strm->avail_in == 0) break;
1467 n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);
1468 s->lookahead += n;
1471 if (s->lookahead + s->insert >= MIN_MATCH) {
1472 uInt str = s->strstart - s->insert;
1473 s->ins_h = s->window[str];
1474 UPDATE_HASH(s, s->ins_h, s->window[str + 1]);
1478 while (s->insert) {
1479 UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);
1481 s->prev[str & s->w_mask] = s->head[s->ins_h];
1483 s->head[s->ins_h] = (Pos)str;
1485 s->insert--;
1486 if (s->lookahead + s->insert < MIN_MATCH)
1494 } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
1503 if (s->high_water < s->window_size) {
1504 ulg curr = s->strstart + (ulg)(s->lookahead);
1507 if (s->high_water < curr) {
1511 init = s->window_size - curr;
1514 zmemzero(s->window + curr, (unsigned)init);
1515 s->high_water = curr + init;
1517 else if (s->high_water < (ulg)curr + WIN_INIT) {
1522 init = (ulg)curr + WIN_INIT - s->high_water;
1523 if (init > s->window_size - s->high_water)
1524 init = s->window_size - s->high_water;
1525 zmemzero(s->window + s->high_water, (unsigned)init);
1526 s->high_water += init;
1530 Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
1538 #define FLUSH_BLOCK_ONLY(s, last) { \ argument
1539 _tr_flush_block(s, (s->block_start >= 0L ? \
1540 (charf *)&s->window[(unsigned)s->block_start] : \
1542 (ulg)((long)s->strstart - s->block_start), \
1544 s->block_start = s->strstart; \
1545 flush_pending(s->strm); \
1550 #define FLUSH_BLOCK(s, last) { \ argument
1551 FLUSH_BLOCK_ONLY(s, last); \
1552 if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \
1564 local block_state deflate_stored(s, flush) in deflate_stored() argument
1565 deflate_state *s; in deflate_stored()
1574 if (max_block_size > s->pending_buf_size - 5) {
1575 max_block_size = s->pending_buf_size - 5;
1581 if (s->lookahead <= 1) {
1583 Assert(s->strstart < s->w_size+MAX_DIST(s) ||
1584 s->block_start >= (long)s->w_size, "slide too late");
1586 fill_window(s);
1587 if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more;
1589 if (s->lookahead == 0) break; /* flush the current block */
1591 Assert(s->block_start >= 0L, "block gone");
1593 s->strstart += s->lookahead;
1594 s->lookahead = 0;
1597 max_start = s->block_start + max_block_size;
1598 if (s->strstart == 0 || (ulg)s->strstart >= max_start) {
1600 s->lookahead = (uInt)(s->strstart - max_start);
1601 s->strstart = (uInt)max_start;
1602 FLUSH_BLOCK(s, 0);
1607 if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) {
1608 FLUSH_BLOCK(s, 0);
1611 s->insert = 0;
1613 FLUSH_BLOCK(s, 1);
1616 if ((long)s->strstart > s->block_start)
1617 FLUSH_BLOCK(s, 0);
1628 local block_state deflate_fast(s, flush) in deflate_fast() argument
1629 deflate_state *s; in deflate_fast()
1641 if (s->lookahead < MIN_LOOKAHEAD) {
1642 fill_window(s);
1643 if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
1646 if (s->lookahead == 0) break; /* flush the current block */
1653 if (s->lookahead >= MIN_MATCH) {
1654 INSERT_STRING(s, s->strstart, hash_head);
1660 if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) {
1665 s->match_length = longest_match (s, hash_head);
1668 if (s->match_length >= MIN_MATCH) {
1669 check_match(s, s->strstart, s->match_start, s->match_length);
1671 _tr_tally_dist(s, s->strstart - s->match_start,
1672 s->match_length - MIN_MATCH, bflush);
1674 s->lookahead -= s->match_length;
1680 if (s->match_length <= s->max_insert_length &&
1681 s->lookahead >= MIN_MATCH) {
1682 s->match_length--; /* string at strstart already in table */
1684 s->strstart++;
1685 INSERT_STRING(s, s->strstart, hash_head);
1689 } while (--s->match_length != 0);
1690 s->strstart++;
1694 s->strstart += s->match_length;
1695 s->match_length = 0;
1696 s->ins_h = s->window[s->strstart];
1697 UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
1707 Tracevv((stderr,"%c", s->window[s->strstart]));
1708 _tr_tally_lit (s, s->window[s->strstart], bflush);
1709 s->lookahead--;
1710 s->strstart++;
1712 if (bflush) FLUSH_BLOCK(s, 0);
1714 s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;
1716 FLUSH_BLOCK(s, 1);
1719 if (s->last_lit)
1720 FLUSH_BLOCK(s, 0);
1730 local block_state deflate_slow(s, flush) in deflate_slow() argument
1731 deflate_state *s; in deflate_slow()
1744 if (s->lookahead < MIN_LOOKAHEAD) {
1745 fill_window(s);
1746 if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
1749 if (s->lookahead == 0) break; /* flush the current block */
1756 if (s->lookahead >= MIN_MATCH) {
1757 INSERT_STRING(s, s->strstart, hash_head);
1762 s->prev_length = s->match_length, s->prev_match = s->match_start;
1763 s->match_length = MIN_MATCH-1;
1765 if (hash_head != NIL && s->prev_length < s->max_lazy_match &&
1766 s->strstart - hash_head <= MAX_DIST(s)) {
1771 s->match_length = longest_match (s, hash_head);
1774 if (s->match_length <= 5 && (s->strategy == Z_FILTERED
1776 || (s->match_length == MIN_MATCH &&
1777 s->strstart - s->match_start > TOO_FAR)
1784 s->match_length = MIN_MATCH-1;
1790 if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {
1791 uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
1794 check_match(s, s->strstart-1, s->prev_match, s->prev_length);
1796 _tr_tally_dist(s, s->strstart -1 - s->prev_match,
1797 s->prev_length - MIN_MATCH, bflush);
1804 s->lookahead -= s->prev_length-1;
1805 s->prev_length -= 2;
1807 if (++s->strstart <= max_insert) {
1808 INSERT_STRING(s, s->strstart, hash_head);
1810 } while (--s->prev_length != 0);
1811 s->match_available = 0;
1812 s->match_length = MIN_MATCH-1;
1813 s->strstart++;
1815 if (bflush) FLUSH_BLOCK(s, 0);
1817 } else if (s->match_available) {
1822 Tracevv((stderr,"%c", s->window[s->strstart-1]));
1823 _tr_tally_lit(s, s->window[s->strstart-1], bflush);
1825 FLUSH_BLOCK_ONLY(s, 0);
1827 s->strstart++;
1828 s->lookahead--;
1829 if (s->strm->avail_out == 0) return need_more;
1834 s->match_available = 1;
1835 s->strstart++;
1836 s->lookahead--;
1840 if (s->match_available) {
1841 Tracevv((stderr,"%c", s->window[s->strstart-1]));
1842 _tr_tally_lit(s, s->window[s->strstart-1], bflush);
1843 s->match_available = 0;
1845 s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;
1847 FLUSH_BLOCK(s, 1);
1850 if (s->last_lit)
1851 FLUSH_BLOCK(s, 0);
1861 local block_state deflate_rle(s, flush) in deflate_rle() argument
1862 deflate_state *s; in deflate_rle()
1874 if (s->lookahead <= MAX_MATCH) {
1875 fill_window(s);
1876 if (s->lookahead <= MAX_MATCH && flush == Z_NO_FLUSH) {
1879 if (s->lookahead == 0) break; /* flush the current block */
1883 s->match_length = 0;
1884 if (s->lookahead >= MIN_MATCH && s->strstart > 0) {
1885 scan = s->window + s->strstart - 1;
1888 strend = s->window + s->strstart + MAX_MATCH;
1895 s->match_length = MAX_MATCH - (int)(strend - scan);
1896 if (s->match_length > s->lookahead)
1897 s->match_length = s->lookahead;
1899 Assert(scan <= s->window+(uInt)(s->window_size-1), "wild scan");
1903 if (s->match_length >= MIN_MATCH) {
1904 check_match(s, s->strstart, s->strstart - 1, s->match_length);
1906 _tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush);
1908 s->lookahead -= s->match_length;
1909 s->strstart += s->match_length;
1910 s->match_length = 0;
1913 Tracevv((stderr,"%c", s->window[s->strstart]));
1914 _tr_tally_lit (s, s->window[s->strstart], bflush);
1915 s->lookahead--;
1916 s->strstart++;
1918 if (bflush) FLUSH_BLOCK(s, 0);
1920 s->insert = 0;
1922 FLUSH_BLOCK(s, 1);
1925 if (s->last_lit)
1926 FLUSH_BLOCK(s, 0);
1934 local block_state deflate_huff(s, flush) in deflate_huff() argument
1935 deflate_state *s; in deflate_huff()
1942 if (s->lookahead == 0) {
1943 fill_window(s);
1944 if (s->lookahead == 0) {
1952 s->match_length = 0;
1953 Tracevv((stderr,"%c", s->window[s->strstart]));
1954 _tr_tally_lit (s, s->window[s->strstart], bflush);
1955 s->lookahead--;
1956 s->strstart++;
1957 if (bflush) FLUSH_BLOCK(s, 0);
1959 s->insert = 0;
1961 FLUSH_BLOCK(s, 1);
1964 if (s->last_lit)
1965 FLUSH_BLOCK(s, 0);