Lines Matching refs:s

12s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)…  function
4069 var s = strm.state;
4072 var len = s.pending;
4078 utils.arraySet(strm.output, s.pending_buf, s.pending_out, len, strm.next_out);
4080 s.pending_out += len;
4083 s.pending -= len;
4084 if (s.pending === 0) {
4085 s.pending_out = 0;
4090 function flush_block_only (s, last) { argument
4091 …trees._tr_flush_block(s, (s.block_start >= 0 ? s.block_start : -1), s.strstart - s.block_start, la…
4092 s.block_start = s.strstart;
4093 flush_pending(s.strm);
4097 function put_byte(s, b) { argument
4098 s.pending_buf[s.pending++] = b;
4107 function putShortMSB(s, b) { argument
4110 s.pending_buf[s.pending++] = (b >>> 8) & 0xff;
4111 s.pending_buf[s.pending++] = b & 0xff;
4155 function longest_match(s, cur_match) { argument
4156 var chain_length = s.max_chain_length; /* max hash chain length */
4157 var scan = s.strstart; /* current string */
4160 var best_len = s.prev_length; /* best match length so far */
4161 var nice_match = s.nice_match; /* stop if match long enough */
4162 var limit = (s.strstart > (s.w_size - MIN_LOOKAHEAD)) ?
4163 s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0/*NIL*/;
4165 var _win = s.window; // shortcut
4167 var wmask = s.w_mask;
4168 var prev = s.prev;
4174 var strend = s.strstart + MAX_MATCH;
4184 if (s.prev_length >= s.good_match) {
4190 if (nice_match > s.lookahead) { nice_match = s.lookahead; }
4241 s.match_start = cur_match;
4251 if (best_len <= s.lookahead) {
4254 return s.lookahead;
4268 function fill_window(s) { argument
4269 var _w_size = s.w_size;
4275 more = s.window_size - s.lookahead - s.strstart;
4295 if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {
4297 utils.arraySet(s.window, s.window, _w_size, _w_size, 0);
4298 s.match_start -= _w_size;
4299 s.strstart -= _w_size;
4301 s.block_start -= _w_size;
4310 n = s.hash_size;
4313 m = s.head[--p];
4314 s.head[p] = (m >= _w_size ? m - _w_size : 0);
4320 m = s.prev[--p];
4321 s.prev[p] = (m >= _w_size ? m - _w_size : 0);
4329 if (s.strm.avail_in === 0) {
4345 n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more);
4346 s.lookahead += n;
4349 if (s.lookahead + s.insert >= MIN_MATCH) {
4350 str = s.strstart - s.insert;
4351 s.ins_h = s.window[str];
4354 s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + 1]) & s.hash_mask;
4358 while (s.insert) {
4360 s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH-1]) & s.hash_mask;
4362 s.prev[str & s.w_mask] = s.head[s.ins_h];
4363 s.head[s.ins_h] = str;
4365 s.insert--;
4366 if (s.lookahead + s.insert < MIN_MATCH) {
4375 } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0);
4424 function deflate_stored(s, flush) { argument
4430 if (max_block_size > s.pending_buf_size - 5) {
4431 max_block_size = s.pending_buf_size - 5;
4437 if (s.lookahead <= 1) {
4446 fill_window(s);
4447 if (s.lookahead === 0 && flush === Z_NO_FLUSH) {
4451 if (s.lookahead === 0) {
4459 s.strstart += s.lookahead;
4460 s.lookahead = 0;
4463 var max_start = s.block_start + max_block_size;
4465 if (s.strstart === 0 || s.strstart >= max_start) {
4467 s.lookahead = s.strstart - max_start;
4468 s.strstart = max_start;
4470 flush_block_only(s, false);
4471 if (s.strm.avail_out === 0) {
4481 if (s.strstart - s.block_start >= (s.w_size - MIN_LOOKAHEAD)) {
4483 flush_block_only(s, false);
4484 if (s.strm.avail_out === 0) {
4491 s.insert = 0;
4495 flush_block_only(s, true);
4496 if (s.strm.avail_out === 0) {
4503 if (s.strstart > s.block_start) {
4505 flush_block_only(s, false);
4506 if (s.strm.avail_out === 0) {
4522 function deflate_fast(s, flush) { argument
4532 if (s.lookahead < MIN_LOOKAHEAD) {
4533 fill_window(s);
4534 if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {
4537 if (s.lookahead === 0) {
4546 if (s.lookahead >= MIN_MATCH) {
4548 s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
4549 hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
4550 s.head[s.ins_h] = s.strstart;
4557 if (hash_head !== 0/*NIL*/ && ((s.strstart - hash_head) <= (s.w_size - MIN_LOOKAHEAD))) {
4562 s.match_length = longest_match(s, hash_head);
4565 if (s.match_length >= MIN_MATCH) {
4570 bflush = trees._tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH);
4572 s.lookahead -= s.match_length;
4577 if (s.match_length <= s.max_lazy_match/*max_insert_length*/ && s.lookahead >= MIN_MATCH) {
4578 s.match_length--; /* string at strstart already in table */
4580 s.strstart++;
4582s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
4583 hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
4584 s.head[s.ins_h] = s.strstart;
4589 } while (--s.match_length !== 0);
4590 s.strstart++;
4593 s.strstart += s.match_length;
4594 s.match_length = 0;
4595 s.ins_h = s.window[s.strstart];
4597 s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + 1]) & s.hash_mask;
4610 bflush = trees._tr_tally(s, 0, s.window[s.strstart]);
4612 s.lookahead--;
4613 s.strstart++;
4617 flush_block_only(s, false);
4618 if (s.strm.avail_out === 0) {
4624 s.insert = ((s.strstart < (MIN_MATCH-1)) ? s.strstart : MIN_MATCH-1);
4627 flush_block_only(s, true);
4628 if (s.strm.avail_out === 0) {
4634 if (s.last_lit) {
4636 flush_block_only(s, false);
4637 if (s.strm.avail_out === 0) {
4650 function deflate_slow(s, flush) { argument
4663 if (s.lookahead < MIN_LOOKAHEAD) {
4664 fill_window(s);
4665 if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {
4668 if (s.lookahead === 0) { break; } /* flush the current block */
4675 if (s.lookahead >= MIN_MATCH) {
4677 s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
4678 hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
4679 s.head[s.ins_h] = s.strstart;
4685 s.prev_length = s.match_length;
4686 s.prev_match = s.match_start;
4687 s.match_length = MIN_MATCH-1;
4689 if (hash_head !== 0/*NIL*/ && s.prev_length < s.max_lazy_match &&
4690 s.strstart - hash_head <= (s.w_size-MIN_LOOKAHEAD)/*MAX_DIST(s)*/) {
4695 s.match_length = longest_match(s, hash_head);
4698 if (s.match_length <= 5 &&
4699 …(s.strategy === Z_FILTERED || (s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096/*…
4704 s.match_length = MIN_MATCH-1;
4710 if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) {
4711 max_insert = s.strstart + s.lookahead - MIN_MATCH;
4718 bflush = trees._tr_tally(s, s.strstart - 1- s.prev_match, s.prev_length - MIN_MATCH);
4724 s.lookahead -= s.prev_length-1;
4725 s.prev_length -= 2;
4727 if (++s.strstart <= max_insert) {
4729s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;
4730 hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
4731 s.head[s.ins_h] = s.strstart;
4734 } while (--s.prev_length !== 0);
4735 s.match_available = 0;
4736 s.match_length = MIN_MATCH-1;
4737 s.strstart++;
4741 flush_block_only(s, false);
4742 if (s.strm.avail_out === 0) {
4748 } else if (s.match_available) {
4755 bflush = trees._tr_tally(s, 0, s.window[s.strstart-1]);
4759 flush_block_only(s, false);
4762 s.strstart++;
4763 s.lookahead--;
4764 if (s.strm.avail_out === 0) {
4771 s.match_available = 1;
4772 s.strstart++;
4773 s.lookahead--;
4777 if (s.match_available) {
4780 bflush = trees._tr_tally(s, 0, s.window[s.strstart-1]);
4782 s.match_available = 0;
4784 s.insert = s.strstart < MIN_MATCH-1 ? s.strstart : MIN_MATCH-1;
4787 flush_block_only(s, true);
4788 if (s.strm.avail_out === 0) {
4794 if (s.last_lit) {
4796 flush_block_only(s, false);
4797 if (s.strm.avail_out === 0) {
4812 function deflate_rle(s, flush) { argument
4817 var _win = s.window;
4824 if (s.lookahead <= MAX_MATCH) {
4825 fill_window(s);
4826 if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH) {
4829 if (s.lookahead === 0) { break; } /* flush the current block */
4833 s.match_length = 0;
4834 if (s.lookahead >= MIN_MATCH && s.strstart > 0) {
4835 scan = s.strstart - 1;
4838 strend = s.strstart + MAX_MATCH;
4846 s.match_length = MAX_MATCH - (strend - scan);
4847 if (s.match_length > s.lookahead) {
4848 s.match_length = s.lookahead;
4855 if (s.match_length >= MIN_MATCH) {
4859 bflush = trees._tr_tally(s, 1, s.match_length - MIN_MATCH);
4861 s.lookahead -= s.match_length;
4862 s.strstart += s.match_length;
4863 s.match_length = 0;
4868 bflush = trees._tr_tally(s, 0, s.window[s.strstart]);
4870 s.lookahead--;
4871 s.strstart++;
4875 flush_block_only(s, false);
4876 if (s.strm.avail_out === 0) {
4882 s.insert = 0;
4885 flush_block_only(s, true);
4886 if (s.strm.avail_out === 0) {
4892 if (s.last_lit) {
4894 flush_block_only(s, false);
4895 if (s.strm.avail_out === 0) {
4907 function deflate_huff(s, flush) { argument
4912 if (s.lookahead === 0) {
4913 fill_window(s);
4914 if (s.lookahead === 0) {
4923 s.match_length = 0;
4926 bflush = trees._tr_tally(s, 0, s.window[s.strstart]);
4927 s.lookahead--;
4928 s.strstart++;
4931 flush_block_only(s, false);
4932 if (s.strm.avail_out === 0) {
4938 s.insert = 0;
4941 flush_block_only(s, true);
4942 if (s.strm.avail_out === 0) {
4948 if (s.last_lit) {
4950 flush_block_only(s, false);
4951 if (s.strm.avail_out === 0) {
4993 function lm_init(s) { argument
4994 s.window_size = 2 * s.w_size;
4997 zero(s.head); // Fill with NIL (= 0);
5001 s.max_lazy_match = configuration_table[s.level].max_lazy;
5002 s.good_match = configuration_table[s.level].good_length;
5003 s.nice_match = configuration_table[s.level].nice_length;
5004 s.max_chain_length = configuration_table[s.level].max_chain;
5006 s.strstart = 0;
5007 s.block_start = 0;
5008 s.lookahead = 0;
5009 s.insert = 0;
5010 s.match_length = s.prev_length = MIN_MATCH - 1;
5011 s.match_available = 0;
5012 s.ins_h = 0;
5206 var s;
5215 s = strm.state;
5216 s.pending = 0;
5217 s.pending_out = 0;
5219 if (s.wrap < 0) {
5220 s.wrap = -s.wrap;
5223 s.status = (s.wrap ? INIT_STATE : BUSY_STATE);
5224 strm.adler = (s.wrap === 2) ?
5228 s.last_flush = Z_NO_FLUSH;
5229 trees._tr_init(s);
5284 var s = new DeflateState();
5286 strm.state = s;
5287 s.strm = strm;
5289 s.wrap = wrap;
5290 s.gzhead = null;
5291 s.w_bits = windowBits;
5292 s.w_size = 1 << s.w_bits;
5293 s.w_mask = s.w_size - 1;
5295 s.hash_bits = memLevel + 7;
5296 s.hash_size = 1 << s.hash_bits;
5297 s.hash_mask = s.hash_size - 1;
5298 s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH);
5300 s.window = new utils.Buf8(s.w_size * 2);
5301 s.head = new utils.Buf16(s.hash_size);
5302 s.prev = new utils.Buf16(s.w_size);
5307 s.lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
5309 s.pending_buf_size = s.lit_bufsize * 4;
5310 s.pending_buf = new utils.Buf8(s.pending_buf_size);
5312 s.d_buf = s.lit_bufsize >> 1;
5313 s.l_buf = (1 + 2) * s.lit_bufsize;
5315 s.level = level;
5316 s.strategy = strategy;
5317 s.method = method;
5328 var old_flush, s;
5336 s = strm.state;
5340 (s.status === FINISH_STATE && flush !== Z_FINISH)) {
5344 s.strm = strm; /* just in case */
5345 old_flush = s.last_flush;
5346 s.last_flush = flush;
5349 if (s.status === INIT_STATE) {
5351 if (s.wrap === 2) { // GZIP header
5353 put_byte(s, 31);
5354 put_byte(s, 139);
5355 put_byte(s, 8);
5356 if (!s.gzhead) { // s->gzhead == Z_NULL
5357 put_byte(s, 0);
5358 put_byte(s, 0);
5359 put_byte(s, 0);
5360 put_byte(s, 0);
5361 put_byte(s, 0);
5362 put_byte(s, s.level === 9 ? 2 :
5363 (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?
5365 put_byte(s, OS_CODE);
5366 s.status = BUSY_STATE;
5369 put_byte(s, (s.gzhead.text ? 1 : 0) +
5370 (s.gzhead.hcrc ? 2 : 0) +
5371 (!s.gzhead.extra ? 0 : 4) +
5372 (!s.gzhead.name ? 0 : 8) +
5373 (!s.gzhead.comment ? 0 : 16)
5375 put_byte(s, s.gzhead.time & 0xff);
5376 put_byte(s, (s.gzhead.time >> 8) & 0xff);
5377 put_byte(s, (s.gzhead.time >> 16) & 0xff);
5378 put_byte(s, (s.gzhead.time >> 24) & 0xff);
5379 put_byte(s, s.level === 9 ? 2 :
5380 (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?
5382 put_byte(s, s.gzhead.os & 0xff);
5383 if (s.gzhead.extra && s.gzhead.extra.length) {
5384 put_byte(s, s.gzhead.extra.length & 0xff);
5385 put_byte(s, (s.gzhead.extra.length >> 8) & 0xff);
5387 if (s.gzhead.hcrc) {
5388 strm.adler = crc32(strm.adler, s.pending_buf, s.pending, 0);
5390 s.gzindex = 0;
5391 s.status = EXTRA_STATE;
5396 var header = (Z_DEFLATED + ((s.w_bits - 8) << 4)) << 8;
5399 if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) {
5401 } else if (s.level < 6) {
5403 } else if (s.level === 6) {
5409 if (s.strstart !== 0) { header |= PRESET_DICT; }
5412 s.status = BUSY_STATE;
5413 putShortMSB(s, header);
5416 if (s.strstart !== 0) {
5417 putShortMSB(s, strm.adler >>> 16);
5418 putShortMSB(s, strm.adler & 0xffff);
5425 if (s.status === EXTRA_STATE) {
5426 if (s.gzhead.extra/* != Z_NULL*/) {
5427 beg = s.pending; /* start of bytes to update crc */
5429 while (s.gzindex < (s.gzhead.extra.length & 0xffff)) {
5430 if (s.pending === s.pending_buf_size) {
5431 if (s.gzhead.hcrc && s.pending > beg) {
5432 strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
5435 beg = s.pending;
5436 if (s.pending === s.pending_buf_size) {
5440 put_byte(s, s.gzhead.extra[s.gzindex] & 0xff);
5441 s.gzindex++;
5443 if (s.gzhead.hcrc && s.pending > beg) {
5444 strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
5446 if (s.gzindex === s.gzhead.extra.length) {
5447 s.gzindex = 0;
5448 s.status = NAME_STATE;
5452 s.status = NAME_STATE;
5455 if (s.status === NAME_STATE) {
5456 if (s.gzhead.name/* != Z_NULL*/) {
5457 beg = s.pending; /* start of bytes to update crc */
5461 if (s.pending === s.pending_buf_size) {
5462 if (s.gzhead.hcrc && s.pending > beg) {
5463 strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
5466 beg = s.pending;
5467 if (s.pending === s.pending_buf_size) {
5473 if (s.gzindex < s.gzhead.name.length) {
5474 val = s.gzhead.name.charCodeAt(s.gzindex++) & 0xff;
5478 put_byte(s, val);
5481 if (s.gzhead.hcrc && s.pending > beg){
5482 strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
5485 s.gzindex = 0;
5486 s.status = COMMENT_STATE;
5490 s.status = COMMENT_STATE;
5493 if (s.status === COMMENT_STATE) {
5494 if (s.gzhead.comment/* != Z_NULL*/) {
5495 beg = s.pending; /* start of bytes to update crc */
5499 if (s.pending === s.pending_buf_size) {
5500 if (s.gzhead.hcrc && s.pending > beg) {
5501 strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
5504 beg = s.pending;
5505 if (s.pending === s.pending_buf_size) {
5511 if (s.gzindex < s.gzhead.comment.length) {
5512 val = s.gzhead.comment.charCodeAt(s.gzindex++) & 0xff;
5516 put_byte(s, val);
5519 if (s.gzhead.hcrc && s.pending > beg) {
5520 strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);
5523 s.status = HCRC_STATE;
5527 s.status = HCRC_STATE;
5530 if (s.status === HCRC_STATE) {
5531 if (s.gzhead.hcrc) {
5532 if (s.pending + 2 > s.pending_buf_size) {
5535 if (s.pending + 2 <= s.pending_buf_size) {
5536 put_byte(s, strm.adler & 0xff);
5537 put_byte(s, (strm.adler >> 8) & 0xff);
5539 s.status = BUSY_STATE;
5543 s.status = BUSY_STATE;
5549 if (s.pending !== 0) {
5558 s.last_flush = -1;
5572 if (s.status === FINISH_STATE && strm.avail_in !== 0) {
5578 if (strm.avail_in !== 0 || s.lookahead !== 0 ||
5579 (flush !== Z_NO_FLUSH && s.status !== FINISH_STATE)) {
5580 var bstate = (s.strategy === Z_HUFFMAN_ONLY) ? deflate_huff(s, flush) :
5581 (s.strategy === Z_RLE ? deflate_rle(s, flush) :
5582 configuration_table[s.level].func(s, flush));
5585 s.status = FINISH_STATE;
5589 s.last_flush = -1;
5603 trees._tr_align(s);
5607 trees._tr_stored_block(s, 0, 0, false);
5613 zero(s.head); // Fill with NIL (= 0);
5615 if (s.lookahead === 0) {
5616 s.strstart = 0;
5617 s.block_start = 0;
5618 s.insert = 0;
5624 s.last_flush = -1; /* avoid BUF_ERROR at next call, see above */
5633 if (s.wrap <= 0) { return Z_STREAM_END; }
5636 if (s.wrap === 2) {
5637 put_byte(s, strm.adler & 0xff);
5638 put_byte(s, (strm.adler >> 8) & 0xff);
5639 put_byte(s, (strm.adler >> 16) & 0xff);
5640 put_byte(s, (strm.adler >> 24) & 0xff);
5641 put_byte(s, strm.total_in & 0xff);
5642 put_byte(s, (strm.total_in >> 8) & 0xff);
5643 put_byte(s, (strm.total_in >> 16) & 0xff);
5644 put_byte(s, (strm.total_in >> 24) & 0xff);
5648 putShortMSB(s, strm.adler >>> 16);
5649 putShortMSB(s, strm.adler & 0xffff);
5656 if (s.wrap > 0) { s.wrap = -s.wrap; }
5658 return s.pending !== 0 ? Z_OK : Z_STREAM_END;
8103 function put_short (s, w) { argument
8106 s.pending_buf[s.pending++] = (w) & 0xff;
8107 s.pending_buf[s.pending++] = (w >>> 8) & 0xff;
8115 function send_bits(s, value, length) { argument
8116 if (s.bi_valid > (Buf_size - length)) {
8117 s.bi_buf |= (value << s.bi_valid) & 0xffff;
8118 put_short(s, s.bi_buf);
8119 s.bi_buf = value >> (Buf_size - s.bi_valid);
8120 s.bi_valid += length - Buf_size;
8122 s.bi_buf |= (value << s.bi_valid) & 0xffff;
8123 s.bi_valid += length;
8128 function send_code(s, c, tree) { argument
8129 send_bits(s, tree[c*2]/*.Code*/, tree[c*2 + 1]/*.Len*/);
8152 function bi_flush(s) { argument
8153 if (s.bi_valid === 16) {
8154 put_short(s, s.bi_buf);
8155 s.bi_buf = 0;
8156 s.bi_valid = 0;
8158 } else if (s.bi_valid >= 8) {
8159 s.pending_buf[s.pending++] = s.bi_buf & 0xff;
8160 s.bi_buf >>= 8;
8161 s.bi_valid -= 8;
8176 function gen_bitlen(s, desc) argument
8195 s.bl_count[bits] = 0;
8201 tree[s.heap[s.heap_max]*2 + 1]/*.Len*/ = 0; /* root of the heap */
8203 for (h = s.heap_max+1; h < HEAP_SIZE; h++) {
8204 n = s.heap[h];
8215 s.bl_count[bits]++;
8221 s.opt_len += f * (bits + xbits);
8223 s.static_len += f * (stree[n*2 + 1]/*.Len*/ + xbits);
8234 while (s.bl_count[bits] === 0) { bits--; }
8235 s.bl_count[bits]--; /* move one leaf down the tree */
8236 s.bl_count[bits+1] += 2; /* move one overflow item as its brother */
8237 s.bl_count[max_length]--;
8250 n = s.bl_count[bits];
8252 m = s.heap[--h];
8256 s.opt_len += (bits - tree[m*2 + 1]/*.Len*/)*tree[m*2]/*.Freq*/;
8415 function init_block(s) { argument
8419 for (n = 0; n < L_CODES; n++) { s.dyn_ltree[n*2]/*.Freq*/ = 0; }
8420 for (n = 0; n < D_CODES; n++) { s.dyn_dtree[n*2]/*.Freq*/ = 0; }
8421 for (n = 0; n < BL_CODES; n++) { s.bl_tree[n*2]/*.Freq*/ = 0; }
8423 s.dyn_ltree[END_BLOCK*2]/*.Freq*/ = 1;
8424 s.opt_len = s.static_len = 0;
8425 s.last_lit = s.matches = 0;
8432 function bi_windup(s) argument
8434 if (s.bi_valid > 8) {
8435 put_short(s, s.bi_buf);
8436 } else if (s.bi_valid > 0) {
8438 s.pending_buf[s.pending++] = s.bi_buf;
8440 s.bi_buf = 0;
8441 s.bi_valid = 0;
8448 function copy_block(s, buf, len, header) argument
8454 bi_windup(s); /* align on byte boundary */
8457 put_short(s, len);
8458 put_short(s, ~len);
8463 utils.arraySet(s.pending_buf, s.window, buf, len, s.pending);
8464 s.pending += len;
8484 function pqdownheap(s, tree, k) argument
8489 var v = s.heap[k];
8491 while (j <= s.heap_len) {
8493 if (j < s.heap_len &&
8494 smaller(tree, s.heap[j+1], s.heap[j], s.depth)) {
8498 if (smaller(tree, v, s.heap[j], s.depth)) { break; }
8501 s.heap[k] = s.heap[j];
8507 s.heap[k] = v;
8517 function compress_block(s, ltree, dtree) argument
8528 if (s.last_lit !== 0) {
8530 dist = (s.pending_buf[s.d_buf + lx*2] << 8) | (s.pending_buf[s.d_buf + lx*2 + 1]);
8531 lc = s.pending_buf[s.l_buf + lx];
8535 send_code(s, lc, ltree); /* send a literal byte */
8540 send_code(s, code+LITERALS+1, ltree); /* send the length code */
8544 send_bits(s, lc, extra); /* send the extra length bits */
8550 send_code(s, code, dtree); /* send the distance code */
8554 send_bits(s, dist, extra); /* send the extra distance bits */
8562 } while (lx < s.last_lit);
8565 send_code(s, END_BLOCK, ltree);
8577 function build_tree(s, desc) argument
8593 s.heap_len = 0;
8594 s.heap_max = HEAP_SIZE;
8598 s.heap[++s.heap_len] = max_code = n;
8599 s.depth[n] = 0;
8611 while (s.heap_len < 2) {
8612 node = s.heap[++s.heap_len] = (max_code < 2 ? ++max_code : 0);
8614 s.depth[node] = 0;
8615 s.opt_len--;
8618 s.static_len -= stree[node*2 + 1]/*.Len*/;
8627 for (n = (s.heap_len >> 1/*int /2*/); n >= 1; n--) { pqdownheap(s, tree, n); }
8636 n = s.heap[1/*SMALLEST*/];
8637 s.heap[1/*SMALLEST*/] = s.heap[s.heap_len--];
8638 pqdownheap(s, tree, 1/*SMALLEST*/);
8641 m = s.heap[1/*SMALLEST*/]; /* m = node of next least frequency */
8643 s.heap[--s.heap_max] = n; /* keep the nodes sorted by frequency */
8644 s.heap[--s.heap_max] = m;
8648 s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1;
8652 s.heap[1/*SMALLEST*/] = node++;
8653 pqdownheap(s, tree, 1/*SMALLEST*/);
8655 } while (s.heap_len >= 2);
8657 s.heap[--s.heap_max] = s.heap[1/*SMALLEST*/];
8662 gen_bitlen(s, desc);
8665 gen_codes(tree, max_code, s.bl_count);
8673 function scan_tree(s, tree, max_code) argument
8702 s.bl_tree[curlen * 2]/*.Freq*/ += count;
8706 if (curlen !== prevlen) { s.bl_tree[curlen * 2]/*.Freq*/++; }
8707 s.bl_tree[REP_3_6*2]/*.Freq*/++;
8710 s.bl_tree[REPZ_3_10*2]/*.Freq*/++;
8713 s.bl_tree[REPZ_11_138*2]/*.Freq*/++;
8739 function send_tree(s, tree, max_code) argument
8768 do { send_code(s, curlen, s.bl_tree); } while (--count !== 0);
8772 send_code(s, curlen, s.bl_tree);
8776 send_code(s, REP_3_6, s.bl_tree);
8777 send_bits(s, count-3, 2);
8780 send_code(s, REPZ_3_10, s.bl_tree);
8781 send_bits(s, count-3, 3);
8784 send_code(s, REPZ_11_138, s.bl_tree);
8785 send_bits(s, count-11, 7);
8810 function build_bl_tree(s) { argument
8814 scan_tree(s, s.dyn_ltree, s.l_desc.max_code);
8815 scan_tree(s, s.dyn_dtree, s.d_desc.max_code);
8818 build_tree(s, s.bl_desc);
8828 if (s.bl_tree[bl_order[max_blindex]*2 + 1]/*.Len*/ !== 0) {
8833 s.opt_len += 3*(max_blindex+1) + 5+5+4;
8846 function send_all_trees(s, lcodes, dcodes, blcodes) argument
8856 send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */
8857 send_bits(s, dcodes-1, 5);
8858 send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */
8861 send_bits(s, s.bl_tree[bl_order[rank]*2 + 1]/*.Len*/, 3);
8865 send_tree(s, s.dyn_ltree, lcodes-1); /* literal tree */
8868 send_tree(s, s.dyn_dtree, dcodes-1); /* distance tree */
8886 function detect_data_type(s) { argument
8896 if ((black_mask & 1) && (s.dyn_ltree[n*2]/*.Freq*/ !== 0)) {
8902 if (s.dyn_ltree[9 * 2]/*.Freq*/ !== 0 || s.dyn_ltree[10 * 2]/*.Freq*/ !== 0 ||
8903 s.dyn_ltree[13 * 2]/*.Freq*/ !== 0) {
8907 if (s.dyn_ltree[n * 2]/*.Freq*/ !== 0) {
8924 function _tr_init(s) argument
8932 s.l_desc = new TreeDesc(s.dyn_ltree, static_l_desc);
8933 s.d_desc = new TreeDesc(s.dyn_dtree, static_d_desc);
8934 s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc);
8936 s.bi_buf = 0;
8937 s.bi_valid = 0;
8940 init_block(s);
8947 function _tr_stored_block(s, buf, stored_len, last) argument
8953 send_bits(s, (STORED_BLOCK<<1)+(last ? 1 : 0), 3); /* send block type */
8954 copy_block(s, buf, stored_len, true); /* with header */
8962 function _tr_align(s) { argument
8963 send_bits(s, STATIC_TREES<<1, 3);
8964 send_code(s, END_BLOCK, static_ltree);
8965 bi_flush(s);
8973 function _tr_flush_block(s, buf, stored_len, last) argument
8983 if (s.level > 0) {
8986 if (s.strm.data_type === Z_UNKNOWN) {
8987 s.strm.data_type = detect_data_type(s);
8991 build_tree(s, s.l_desc);
8995 build_tree(s, s.d_desc);
9005 max_blindex = build_bl_tree(s);
9008 opt_lenb = (s.opt_len+3+7) >>> 3;
9009 static_lenb = (s.static_len+3+7) >>> 3;
9031 _tr_stored_block(s, buf, stored_len, last);
9033 } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) {
9035 send_bits(s, (STATIC_TREES<<1) + (last ? 1 : 0), 3);
9036 compress_block(s, static_ltree, static_dtree);
9039 send_bits(s, (DYN_TREES<<1) + (last ? 1 : 0), 3);
9040 send_all_trees(s, s.l_desc.max_code+1, s.d_desc.max_code+1, max_blindex+1);
9041 compress_block(s, s.dyn_ltree, s.dyn_dtree);
9047 init_block(s);
9050 bi_windup(s);
9060 function _tr_tally(s, dist, lc) argument
9067 s.pending_buf[s.d_buf + s.last_lit * 2] = (dist >>> 8) & 0xff;
9068 s.pending_buf[s.d_buf + s.last_lit * 2 + 1] = dist & 0xff;
9070 s.pending_buf[s.l_buf + s.last_lit] = lc & 0xff;
9071 s.last_lit++;
9075 s.dyn_ltree[lc*2]/*.Freq*/++;
9077 s.matches++;
9084 s.dyn_ltree[(_length_code[lc]+LITERALS+1) * 2]/*.Freq*/++;
9085 s.dyn_dtree[d_code(dist) * 2]/*.Freq*/++;
9111 return (s.last_lit === s.lit_bufsize-1);