Lines Matching refs:s

13s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)…  function
6039 var s = strm.state;
6042 var len = s.pending;
6048 utils.arraySet(strm.output, s.pending_buf, s.pending_out, len, strm.next_out);
6050 s.pending_out += len;
6053 s.pending -= len;
6054 if (s.pending === 0) {
6055 s.pending_out = 0;
6060 function flush_block_only(s, last) { argument
6061 …trees._tr_flush_block(s, (s.block_start >= 0 ? s.block_start : -1), s.strstart - s.block_start, la…
6062 s.block_start = s.strstart;
6063 flush_pending(s.strm);
6067 function put_byte(s, b) { argument
6068 s.pending_buf[s.pending++] = b;
6077 function putShortMSB(s, b) { argument
6080 s.pending_buf[s.pending++] = (b >>> 8) & 0xff;
6081 s.pending_buf[s.pending++] = b & 0xff;
6126 function longest_match(s, cur_match) { argument
6127 var chain_length = s.max_chain_length; /* max hash chain length */
6128 var scan = s.strstart; /* current string */
6131 var best_len = s.prev_length; /* best match length so far */
6132 var nice_match = s.nice_match; /* stop if match long enough */
6133 var limit = (s.strstart > (s.w_size - MIN_LOOKAHEAD)) ?
6134 s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0/*NIL*/;
6136 var _win = s.window; // shortcut
6138 var wmask = s.w_mask;
6139 var prev = s.prev;
6145 var strend = s.strstart + MAX_MATCH;
6155 if (s.prev_length >= s.good_match) {
6161 if (nice_match > s.lookahead) { nice_match = s.lookahead; }
6212 s.match_start = cur_match;
6222 if (best_len <= s.lookahead) {
6225 return s.lookahead;
6239 function fill_window(s) { argument
6240 var _w_size = s.w_size;
6246 more = s.window_size - s.lookahead - s.strstart;
6266 if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {
6268 utils.arraySet(s.window, s.window, _w_size, _w_size, 0);
6269 s.match_start -= _w_size;
6270 s.strstart -= _w_size;
6272 s.block_start -= _w_size;
6281 n = s.hash_size;
6284 m = s.head[--p];
6285 s.head[p] = (m >= _w_size ? m - _w_size : 0);
6291 m = s.prev[--p];
6292 s.prev[p] = (m >= _w_size ? m - _w_size : 0);
6300 if (s.strm.avail_in === 0) {
6316 n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more);
6317 s.lookahead += n;
6320 if (s.lookahead + s.insert >= MIN_MATCH) {
6321 str = s.strstart - s.insert;
6322 s.ins_h = s.window[str];
6325 s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + 1]) & s.hash_mask;
6329 while (s.insert) {
6331 s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;
6333 s.prev[str & s.w_mask] = s.head[s.ins_h];
6334 s.head[s.ins_h] = str;
6336 s.insert--;
6337 if (s.lookahead + s.insert < MIN_MATCH) {
6346 } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0);
6395 function deflate_stored(s, flush) { argument
6401 if (max_block_size > s.pending_buf_size - 5) {
6402 max_block_size = s.pending_buf_size - 5;
6408 if (s.lookahead <= 1) {
6417 fill_window(s);
6418 if (s.lookahead === 0 && flush === Z_NO_FLUSH) {
6422 if (s.lookahead === 0) {
6430 s.strstart += s.lookahead;
6431 s.lookahead = 0;
6434 var max_start = s.block_start + max_block_size;
6436 if (s.strstart === 0 || s.strstart >= max_start) {
6438 s.lookahead = s.strstart - max_start;
6439 s.strstart = max_start;
6441 flush_block_only(s, false);
6442 if (s.strm.avail_out === 0) {
6452 if (s.strstart - s.block_start >= (s.w_size - MIN_LOOKAHEAD)) {
6454 flush_block_only(s, false);
6455 if (s.strm.avail_out === 0) {
6462 s.insert = 0;
6466 flush_block_only(s, true);
6467 if (s.strm.avail_out === 0) {
6474 if (s.strstart > s.block_start) {
6476 flush_block_only(s, false);
6477 if (s.strm.avail_out === 0) {
6493 function deflate_fast(s, flush) { argument
6503 if (s.lookahead < MIN_LOOKAHEAD) {
6504 fill_window(s);
6505 if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {
6508 if (s.lookahead === 0) {
6517 if (s.lookahead >= MIN_MATCH) {
6519 s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
6520 hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
6521 s.head[s.ins_h] = s.strstart;
6528 if (hash_head !== 0/*NIL*/ && ((s.strstart - hash_head) <= (s.w_size - MIN_LOOKAHEAD))) {
6533 s.match_length = longest_match(s, hash_head);
6536 if (s.match_length >= MIN_MATCH) {
6541 bflush = trees._tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH);
6543 s.lookahead -= s.match_length;
6548 if (s.match_length <= s.max_lazy_match/*max_insert_length*/ && s.lookahead >= MIN_MATCH) {
6549 s.match_length--; /* string at strstart already in table */
6551 s.strstart++;
6553s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
6554 hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
6555 s.head[s.ins_h] = s.strstart;
6560 } while (--s.match_length !== 0);
6561 s.strstart++;
6564 s.strstart += s.match_length;
6565 s.match_length = 0;
6566 s.ins_h = s.window[s.strstart];
6568 s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + 1]) & s.hash_mask;
6581 bflush = trees._tr_tally(s, 0, s.window[s.strstart]);
6583 s.lookahead--;
6584 s.strstart++;
6588 flush_block_only(s, false);
6589 if (s.strm.avail_out === 0) {
6595 s.insert = ((s.strstart < (MIN_MATCH - 1)) ? s.strstart : MIN_MATCH - 1);
6598 flush_block_only(s, true);
6599 if (s.strm.avail_out === 0) {
6605 if (s.last_lit) {
6607 flush_block_only(s, false);
6608 if (s.strm.avail_out === 0) {
6621 function deflate_slow(s, flush) { argument
6634 if (s.lookahead < MIN_LOOKAHEAD) {
6635 fill_window(s);
6636 if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {
6639 if (s.lookahead === 0) { break; } /* flush the current block */
6646 if (s.lookahead >= MIN_MATCH) {
6648 s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
6649 hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
6650 s.head[s.ins_h] = s.strstart;
6656 s.prev_length = s.match_length;
6657 s.prev_match = s.match_start;
6658 s.match_length = MIN_MATCH - 1;
6660 if (hash_head !== 0/*NIL*/ && s.prev_length < s.max_lazy_match &&
6661 s.strstart - hash_head <= (s.w_size - MIN_LOOKAHEAD)/*MAX_DIST(s)*/) {
6666 s.match_length = longest_match(s, hash_head);
6669 if (s.match_length <= 5 &&
6670 …(s.strategy === Z_FILTERED || (s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096/*…
6675 s.match_length = MIN_MATCH - 1;
6681 if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) {
6682 max_insert = s.strstart + s.lookahead - MIN_MATCH;
6689 bflush = trees._tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH);
6695 s.lookahead -= s.prev_length - 1;
6696 s.prev_length -= 2;
6698 if (++s.strstart <= max_insert) {
6700s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
6701 hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
6702 s.head[s.ins_h] = s.strstart;
6705 } while (--s.prev_length !== 0);
6706 s.match_available = 0;
6707 s.match_length = MIN_MATCH - 1;
6708 s.strstart++;
6712 flush_block_only(s, false);
6713 if (s.strm.avail_out === 0) {
6719 } else if (s.match_available) {
6726 bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);
6730 flush_block_only(s, false);
6733 s.strstart++;
6734 s.lookahead--;
6735 if (s.strm.avail_out === 0) {
6742 s.match_available = 1;
6743 s.strstart++;
6744 s.lookahead--;
6748 if (s.match_available) {
6751 bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);
6753 s.match_available = 0;
6755 s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;
6758 flush_block_only(s, true);
6759 if (s.strm.avail_out === 0) {
6765 if (s.last_lit) {
6767 flush_block_only(s, false);
6768 if (s.strm.avail_out === 0) {
6783 function deflate_rle(s, flush) { argument
6788 var _win = s.window;
6795 if (s.lookahead <= MAX_MATCH) {
6796 fill_window(s);
6797 if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH) {
6800 if (s.lookahead === 0) { break; } /* flush the current block */
6804 s.match_length = 0;
6805 if (s.lookahead >= MIN_MATCH && s.strstart > 0) {
6806 scan = s.strstart - 1;
6809 strend = s.strstart + MAX_MATCH;
6817 s.match_length = MAX_MATCH - (strend - scan);
6818 if (s.match_length > s.lookahead) {
6819 s.match_length = s.lookahead;
6826 if (s.match_length >= MIN_MATCH) {
6830 bflush = trees._tr_tally(s, 1, s.match_length - MIN_MATCH);
6832 s.lookahead -= s.match_length;
6833 s.strstart += s.match_length;
6834 s.match_length = 0;
6839 bflush = trees._tr_tally(s, 0, s.window[s.strstart]);
6841 s.lookahead--;
6842 s.strstart++;
6846 flush_block_only(s, false);
6847 if (s.strm.avail_out === 0) {
6853 s.insert = 0;
6856 flush_block_only(s, true);
6857 if (s.strm.avail_out === 0) {
6863 if (s.last_lit) {
6865 flush_block_only(s, false);
6866 if (s.strm.avail_out === 0) {
6878 function deflate_huff(s, flush) { argument
6883 if (s.lookahead === 0) {
6884 fill_window(s);
6885 if (s.lookahead === 0) {
6894 s.match_length = 0;
6897 bflush = trees._tr_tally(s, 0, s.window[s.strstart]);
6898 s.lookahead--;
6899 s.strstart++;
6902 flush_block_only(s, false);
6903 if (s.strm.avail_out === 0) {
6909 s.insert = 0;
6912 flush_block_only(s, true);
6913 if (s.strm.avail_out === 0) {
6919 if (s.last_lit) {
6921 flush_block_only(s, false);
6922 if (s.strm.avail_out === 0) {
6964 function lm_init(s) { argument
6965 s.window_size = 2 * s.w_size;
6968 zero(s.head); // Fill with NIL (= 0);
6972 s.max_lazy_match = configuration_table[s.level].max_lazy;
6973 s.good_match = configuration_table[s.level].good_length;
6974 s.nice_match = configuration_table[s.level].nice_length;
6975 s.max_chain_length = configuration_table[s.level].max_chain;
6977 s.strstart = 0;
6978 s.block_start = 0;
6979 s.lookahead = 0;
6980 s.insert = 0;
6981 s.match_length = s.prev_length = MIN_MATCH - 1;
6982 s.match_available = 0;
6983 s.ins_h = 0;
7177 var s;
7186 s = strm.state;
7187 s.pending = 0;
7188 s.pending_out = 0;
7190 if (s.wrap < 0) {
7191 s.wrap = -s.wrap;
7194 s.status = (s.wrap ? INIT_STATE : BUSY_STATE);
7195 strm.adler = (s.wrap === 2) ?
7199 s.last_flush = Z_NO_FLUSH;
7200 trees._tr_init(s);
7255 var s = new DeflateState();
7257 strm.state = s;
7258 s.strm = strm;
7260 s.wrap = wrap;
7261 s.gzhead = null;
7262 s.w_bits = windowBits;
7263 s.w_size = 1 << s.w_bits;
7264 s.w_mask = s.w_size - 1;
7266 s.hash_bits = memLevel + 7;
7267 s.hash_size = 1 << s.hash_bits;
7268 s.hash_mask = s.hash_size - 1;
7269 s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH);
7271 s.window = new utils.Buf8(s.w_size * 2);
7272 s.head = new utils.Buf16(s.hash_size);
7273 s.prev = new utils.Buf16(s.w_size);
7278 s.lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
7280 s.pending_buf_size = s.lit_bufsize * 4;
7284 s.pending_buf = new utils.Buf8(s.pending_buf_size);
7288 s.d_buf = 1 * s.lit_bufsize;
7291 s.l_buf = (1 + 2) * s.lit_bufsize;
7293 s.level = level;
7294 s.strategy = strategy;
7295 s.method = method;
7306 var old_flush, s;
7314 s = strm.state;
7318 (s.status === FINISH_STATE && flush !== Z_FINISH)) {
7322 s.strm = strm; /* just in case */
7323 old_flush = s.last_flush;
7324 s.last_flush = flush;
7327 if (s.status === INIT_STATE) {
7329 if (s.wrap === 2) { // GZIP header
7331 put_byte(s, 31);
7332 put_byte(s, 139);
7333 put_byte(s, 8);
7334 if (!s.gzhead) { // s->gzhead == Z_NULL
7335 put_byte(s, 0);
7336 put_byte(s, 0);
7337 put_byte(s, 0);
7338 put_byte(s, 0);
7339 put_byte(s, 0);
7340 put_byte(s, s.level === 9 ? 2 :
7341 (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?
7343 put_byte(s, OS_CODE);
7344 s.status = BUSY_STATE;
7347 put_byte(s, (s.gzhead.text ? 1 : 0) +
7348 (s.gzhead.hcrc ? 2 : 0) +
7349 (!s.gzhead.extra ? 0 : 4) +
7350 (!s.gzhead.name ? 0 : 8) +
7351 (!s.gzhead.comment ? 0 : 16)
7353 put_byte(s, s.gzhead.time & 0xff);
7354 put_byte(s, (s.gzhead.time >> 8) & 0xff);
7355 put_byte(s, (s.gzhead.time >> 16) & 0xff);
7356 put_byte(s, (s.gzhead.time >> 24) & 0xff);
7357 put_byte(s, s.level === 9 ? 2 :
7358 (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?
7360 put_byte(s, s.gzhead.os & 0xff);
7361 if (s.gzhead.extra && s.gzhead.extra.length) {
7362 put_byte(s, s.gzhead.extra.length & 0xff);
7363 put_byte(s, (s.gzhead.extra.length >> 8) & 0xff);
7365 if (s.gzhead.hcrc) {
7366 strm.adler = crc32(strm.adler, s.pending_buf, s.pending, 0);
7368 s.gzindex = 0;
7369 s.status = EXTRA_STATE;
7374 var header = (Z_DEFLATED + ((s.w_bits - 8) << 4)) << 8;
7377 if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) {
7379 } else if (s.level < 6) {
7381 } else if (s.level === 6) {
7387 if (s.strstart !== 0) { header |= PRESET_DICT; }
7390 s.status = BUSY_STATE;
7391 putShortMSB(s, header);
7394 if (s.strstart !== 0) {
7395 putShortMSB(s, strm.adler >>> 16);
7396 putShortMSB(s, strm.adler & 0xffff);
7403 if (s.status === EXTRA_STATE) {
7404 if (s.gzhead.extra/* != Z_NULL*/) {
7405 beg = s.pending; /* start of bytes to update crc */
7407 while (s.gzindex < (s.gzhead.extra.length & 0xffff)) {
7408 if (s.pending === s.pending_buf_size) {
7409 if (s.gzhead.hcrc && s.pending > beg) {
7410 strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
7413 beg = s.pending;
7414 if (s.pending === s.pending_buf_size) {
7418 put_byte(s, s.gzhead.extra[s.gzindex] & 0xff);
7419 s.gzindex++;
7421 if (s.gzhead.hcrc && s.pending > beg) {
7422 strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
7424 if (s.gzindex === s.gzhead.extra.length) {
7425 s.gzindex = 0;
7426 s.status = NAME_STATE;
7430 s.status = NAME_STATE;
7433 if (s.status === NAME_STATE) {
7434 if (s.gzhead.name/* != Z_NULL*/) {
7435 beg = s.pending; /* start of bytes to update crc */
7439 if (s.pending === s.pending_buf_size) {
7440 if (s.gzhead.hcrc && s.pending > beg) {
7441 strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
7444 beg = s.pending;
7445 if (s.pending === s.pending_buf_size) {
7451 if (s.gzindex < s.gzhead.name.length) {
7452 val = s.gzhead.name.charCodeAt(s.gzindex++) & 0xff;
7456 put_byte(s, val);
7459 if (s.gzhead.hcrc && s.pending > beg) {
7460 strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
7463 s.gzindex = 0;
7464 s.status = COMMENT_STATE;
7468 s.status = COMMENT_STATE;
7471 if (s.status === COMMENT_STATE) {
7472 if (s.gzhead.comment/* != Z_NULL*/) {
7473 beg = s.pending; /* start of bytes to update crc */
7477 if (s.pending === s.pending_buf_size) {
7478 if (s.gzhead.hcrc && s.pending > beg) {
7479 strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
7482 beg = s.pending;
7483 if (s.pending === s.pending_buf_size) {
7489 if (s.gzindex < s.gzhead.comment.length) {
7490 val = s.gzhead.comment.charCodeAt(s.gzindex++) & 0xff;
7494 put_byte(s, val);
7497 if (s.gzhead.hcrc && s.pending > beg) {
7498 strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
7501 s.status = HCRC_STATE;
7505 s.status = HCRC_STATE;
7508 if (s.status === HCRC_STATE) {
7509 if (s.gzhead.hcrc) {
7510 if (s.pending + 2 > s.pending_buf_size) {
7513 if (s.pending + 2 <= s.pending_buf_size) {
7514 put_byte(s, strm.adler & 0xff);
7515 put_byte(s, (strm.adler >> 8) & 0xff);
7517 s.status = BUSY_STATE;
7521 s.status = BUSY_STATE;
7527 if (s.pending !== 0) {
7536 s.last_flush = -1;
7550 if (s.status === FINISH_STATE && strm.avail_in !== 0) {
7556 if (strm.avail_in !== 0 || s.lookahead !== 0 ||
7557 (flush !== Z_NO_FLUSH && s.status !== FINISH_STATE)) {
7558 var bstate = (s.strategy === Z_HUFFMAN_ONLY) ? deflate_huff(s, flush) :
7559 (s.strategy === Z_RLE ? deflate_rle(s, flush) :
7560 configuration_table[s.level].func(s, flush));
7563 s.status = FINISH_STATE;
7567 s.last_flush = -1;
7581 trees._tr_align(s);
7585 trees._tr_stored_block(s, 0, 0, false);
7591 zero(s.head); // Fill with NIL (= 0);
7593 if (s.lookahead === 0) {
7594 s.strstart = 0;
7595 s.block_start = 0;
7596 s.insert = 0;
7602 s.last_flush = -1; /* avoid BUF_ERROR at next call, see above */
7611 if (s.wrap <= 0) { return Z_STREAM_END; }
7614 if (s.wrap === 2) {
7615 put_byte(s, strm.adler & 0xff);
7616 put_byte(s, (strm.adler >> 8) & 0xff);
7617 put_byte(s, (strm.adler >> 16) & 0xff);
7618 put_byte(s, (strm.adler >> 24) & 0xff);
7619 put_byte(s, strm.total_in & 0xff);
7620 put_byte(s, (strm.total_in >> 8) & 0xff);
7621 put_byte(s, (strm.total_in >> 16) & 0xff);
7622 put_byte(s, (strm.total_in >> 24) & 0xff);
7626 putShortMSB(s, strm.adler >>> 16);
7627 putShortMSB(s, strm.adler & 0xffff);
7634 if (s.wrap > 0) { s.wrap = -s.wrap; }
7636 return s.pending !== 0 ? Z_OK : Z_STREAM_END;
7671 var s;
7683 s = strm.state;
7684 wrap = s.wrap;
7686 if (wrap === 2 || (wrap === 1 && s.status !== INIT_STATE) || s.lookahead) {
7696 s.wrap = 0; /* avoid computing Adler-32 in read_buf */
7699 if (dictLength >= s.w_size) {
7702 zero(s.head); // Fill with NIL (= 0);
7703 s.strstart = 0;
7704 s.block_start = 0;
7705 s.insert = 0;
7709 tmpDict = new utils.Buf8(s.w_size);
7710 utils.arraySet(tmpDict, dictionary, dictLength - s.w_size, s.w_size, 0);
7712 dictLength = s.w_size;
7721 fill_window(s);
7722 while (s.lookahead >= MIN_MATCH) {
7723 str = s.strstart;
7724 n = s.lookahead - (MIN_MATCH - 1);
7727 s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;
7729 s.prev[str & s.w_mask] = s.head[s.ins_h];
7731 s.head[s.ins_h] = str;
7734 s.strstart = str;
7735 s.lookahead = MIN_MATCH - 1;
7736 fill_window(s);
7738 s.strstart += s.lookahead;
7739 s.block_start = s.strstart;
7740 s.insert = s.lookahead;
7741 s.lookahead = 0;
7742 s.match_length = s.prev_length = MIN_MATCH - 1;
7743 s.match_available = 0;
7747 s.wrap = wrap;
10316 function put_short(s, w) { argument
10319 s.pending_buf[s.pending++] = (w) & 0xff;
10320 s.pending_buf[s.pending++] = (w >>> 8) & 0xff;
10328 function send_bits(s, value, length) { argument
10329 if (s.bi_valid > (Buf_size - length)) {
10330 s.bi_buf |= (value << s.bi_valid) & 0xffff;
10331 put_short(s, s.bi_buf);
10332 s.bi_buf = value >> (Buf_size - s.bi_valid);
10333 s.bi_valid += length - Buf_size;
10335 s.bi_buf |= (value << s.bi_valid) & 0xffff;
10336 s.bi_valid += length;
10341 function send_code(s, c, tree) { argument
10342 send_bits(s, tree[c * 2]/*.Code*/, tree[c * 2 + 1]/*.Len*/);
10365 function bi_flush(s) { argument
10366 if (s.bi_valid === 16) {
10367 put_short(s, s.bi_buf);
10368 s.bi_buf = 0;
10369 s.bi_valid = 0;
10371 } else if (s.bi_valid >= 8) {
10372 s.pending_buf[s.pending++] = s.bi_buf & 0xff;
10373 s.bi_buf >>= 8;
10374 s.bi_valid -= 8;
10389 function gen_bitlen(s, desc) argument
10408 s.bl_count[bits] = 0;
10414 tree[s.heap[s.heap_max] * 2 + 1]/*.Len*/ = 0; /* root of the heap */
10416 for (h = s.heap_max + 1; h < HEAP_SIZE; h++) {
10417 n = s.heap[h];
10428 s.bl_count[bits]++;
10434 s.opt_len += f * (bits + xbits);
10436 s.static_len += f * (stree[n * 2 + 1]/*.Len*/ + xbits);
10447 while (s.bl_count[bits] === 0) { bits--; }
10448 s.bl_count[bits]--; /* move one leaf down the tree */
10449 s.bl_count[bits + 1] += 2; /* move one overflow item as its brother */
10450 s.bl_count[max_length]--;
10463 n = s.bl_count[bits];
10465 m = s.heap[--h];
10469 s.opt_len += (bits - tree[m * 2 + 1]/*.Len*/) * tree[m * 2]/*.Freq*/;
10628 function init_block(s) { argument
10632 for (n = 0; n < L_CODES; n++) { s.dyn_ltree[n * 2]/*.Freq*/ = 0; }
10633 for (n = 0; n < D_CODES; n++) { s.dyn_dtree[n * 2]/*.Freq*/ = 0; }
10634 for (n = 0; n < BL_CODES; n++) { s.bl_tree[n * 2]/*.Freq*/ = 0; }
10636 s.dyn_ltree[END_BLOCK * 2]/*.Freq*/ = 1;
10637 s.opt_len = s.static_len = 0;
10638 s.last_lit = s.matches = 0;
10645 function bi_windup(s) argument
10647 if (s.bi_valid > 8) {
10648 put_short(s, s.bi_buf);
10649 } else if (s.bi_valid > 0) {
10651 s.pending_buf[s.pending++] = s.bi_buf;
10653 s.bi_buf = 0;
10654 s.bi_valid = 0;
10661 function copy_block(s, buf, len, header) argument
10667 bi_windup(s); /* align on byte boundary */
10670 put_short(s, len);
10671 put_short(s, ~len);
10676 utils.arraySet(s.pending_buf, s.window, buf, len, s.pending);
10677 s.pending += len;
10697 function pqdownheap(s, tree, k) argument
10702 var v = s.heap[k];
10704 while (j <= s.heap_len) {
10706 if (j < s.heap_len &&
10707 smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) {
10711 if (smaller(tree, v, s.heap[j], s.depth)) { break; }
10714 s.heap[k] = s.heap[j];
10720 s.heap[k] = v;
10730 function compress_block(s, ltree, dtree) argument
10741 if (s.last_lit !== 0) {
10743 dist = (s.pending_buf[s.d_buf + lx * 2] << 8) | (s.pending_buf[s.d_buf + lx * 2 + 1]);
10744 lc = s.pending_buf[s.l_buf + lx];
10748 send_code(s, lc, ltree); /* send a literal byte */
10753 send_code(s, code + LITERALS + 1, ltree); /* send the length code */
10757 send_bits(s, lc, extra); /* send the extra length bits */
10763 send_code(s, code, dtree); /* send the distance code */
10767 send_bits(s, dist, extra); /* send the extra distance bits */
10775 } while (lx < s.last_lit);
10778 send_code(s, END_BLOCK, ltree);
10790 function build_tree(s, desc) argument
10806 s.heap_len = 0;
10807 s.heap_max = HEAP_SIZE;
10811 s.heap[++s.heap_len] = max_code = n;
10812 s.depth[n] = 0;
10824 while (s.heap_len < 2) {
10825 node = s.heap[++s.heap_len] = (max_code < 2 ? ++max_code : 0);
10827 s.depth[node] = 0;
10828 s.opt_len--;
10831 s.static_len -= stree[node * 2 + 1]/*.Len*/;
10840 for (n = (s.heap_len >> 1/*int /2*/); n >= 1; n--) { pqdownheap(s, tree, n); }
10849 n = s.heap[1/*SMALLEST*/];
10850 s.heap[1/*SMALLEST*/] = s.heap[s.heap_len--];
10851 pqdownheap(s, tree, 1/*SMALLEST*/);
10854 m = s.heap[1/*SMALLEST*/]; /* m = node of next least frequency */
10856 s.heap[--s.heap_max] = n; /* keep the nodes sorted by frequency */
10857 s.heap[--s.heap_max] = m;
10861 s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1;
10865 s.heap[1/*SMALLEST*/] = node++;
10866 pqdownheap(s, tree, 1/*SMALLEST*/);
10868 } while (s.heap_len >= 2);
10870 s.heap[--s.heap_max] = s.heap[1/*SMALLEST*/];
10875 gen_bitlen(s, desc);
10878 gen_codes(tree, max_code, s.bl_count);
10886 function scan_tree(s, tree, max_code) argument
10915 s.bl_tree[curlen * 2]/*.Freq*/ += count;
10919 if (curlen !== prevlen) { s.bl_tree[curlen * 2]/*.Freq*/++; }
10920 s.bl_tree[REP_3_6 * 2]/*.Freq*/++;
10923 s.bl_tree[REPZ_3_10 * 2]/*.Freq*/++;
10926 s.bl_tree[REPZ_11_138 * 2]/*.Freq*/++;
10952 function send_tree(s, tree, max_code) argument
10981 do { send_code(s, curlen, s.bl_tree); } while (--count !== 0);
10985 send_code(s, curlen, s.bl_tree);
10989 send_code(s, REP_3_6, s.bl_tree);
10990 send_bits(s, count - 3, 2);
10993 send_code(s, REPZ_3_10, s.bl_tree);
10994 send_bits(s, count - 3, 3);
10997 send_code(s, REPZ_11_138, s.bl_tree);
10998 send_bits(s, count - 11, 7);
11023 function build_bl_tree(s) { argument
11027 scan_tree(s, s.dyn_ltree, s.l_desc.max_code);
11028 scan_tree(s, s.dyn_dtree, s.d_desc.max_code);
11031 build_tree(s, s.bl_desc);
11041 if (s.bl_tree[bl_order[max_blindex] * 2 + 1]/*.Len*/ !== 0) {
11046 s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4;
11059 function send_all_trees(s, lcodes, dcodes, blcodes) argument
11069 send_bits(s, lcodes - 257, 5); /* not +255 as stated in appnote.txt */
11070 send_bits(s, dcodes - 1, 5);
11071 send_bits(s, blcodes - 4, 4); /* not -3 as stated in appnote.txt */
11074 send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1]/*.Len*/, 3);
11078 send_tree(s, s.dyn_ltree, lcodes - 1); /* literal tree */
11081 send_tree(s, s.dyn_dtree, dcodes - 1); /* distance tree */
11099 function detect_data_type(s) { argument
11109 if ((black_mask & 1) && (s.dyn_ltree[n * 2]/*.Freq*/ !== 0)) {
11115 if (s.dyn_ltree[9 * 2]/*.Freq*/ !== 0 || s.dyn_ltree[10 * 2]/*.Freq*/ !== 0 ||
11116 s.dyn_ltree[13 * 2]/*.Freq*/ !== 0) {
11120 if (s.dyn_ltree[n * 2]/*.Freq*/ !== 0) {
11137 function _tr_init(s) argument
11145 s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc);
11146 s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc);
11147 s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc);
11149 s.bi_buf = 0;
11150 s.bi_valid = 0;
11153 init_block(s);
11160 function _tr_stored_block(s, buf, stored_len, last) argument
11166 send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3); /* send block type */
11167 copy_block(s, buf, stored_len, true); /* with header */
11175 function _tr_align(s) { argument
11176 send_bits(s, STATIC_TREES << 1, 3);
11177 send_code(s, END_BLOCK, static_ltree);
11178 bi_flush(s);
11186 function _tr_flush_block(s, buf, stored_len, last) argument
11196 if (s.level > 0) {
11199 if (s.strm.data_type === Z_UNKNOWN) {
11200 s.strm.data_type = detect_data_type(s);
11204 build_tree(s, s.l_desc);
11208 build_tree(s, s.d_desc);
11218 max_blindex = build_bl_tree(s);
11221 opt_lenb = (s.opt_len + 3 + 7) >>> 3;
11222 static_lenb = (s.static_len + 3 + 7) >>> 3;
11244 _tr_stored_block(s, buf, stored_len, last);
11246 } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) {
11248 send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3);
11249 compress_block(s, static_ltree, static_dtree);
11252 send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3);
11253 send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1);
11254 compress_block(s, s.dyn_ltree, s.dyn_dtree);
11260 init_block(s);
11263 bi_windup(s);
11273 function _tr_tally(s, dist, lc) argument
11280 s.pending_buf[s.d_buf + s.last_lit * 2] = (dist >>> 8) & 0xff;
11281 s.pending_buf[s.d_buf + s.last_lit * 2 + 1] = dist & 0xff;
11283 s.pending_buf[s.l_buf + s.last_lit] = lc & 0xff;
11284 s.last_lit++;
11288 s.dyn_ltree[lc * 2]/*.Freq*/++;
11290 s.matches++;
11297 s.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2]/*.Freq*/++;
11298 s.dyn_dtree[d_code(dist) * 2]/*.Freq*/++;
11324 return (s.last_lit === s.lit_bufsize - 1);