function compress_block(s, ltree, dtree)
	//    deflate_state *s;
	//    const ct_data *ltree; /* literal tree */
	//    const ct_data *dtree; /* distance tree */
	{
	  var dist;           /* distance of matched string */
	  var lc;             /* match length or unmatched char (if dist == 0) */
	  var lx = 0;         /* running index in l_buf */
	  var code;           /* the code to send */
	  var extra;          /* number of extra bits to send */
	
	  if (s.last_lit !== 0) {
	    do {
	      dist = (s.pending_buf[s.d_buf + lx*2] << 8) | (s.pending_buf[s.d_buf + lx*2 + 1]);
	      lc = s.pending_buf[s.l_buf + lx];
	      lx++;
	
	      if (dist === 0) {
	        send_code(s, lc, ltree); /* send a literal byte */
	        //Tracecv(isgraph(lc), (stderr," '%c' ", lc));
	      } else {
	        /* Here, lc is the match length - MIN_MATCH */
	        code = _length_code[lc];
	        send_code(s, code+LITERALS+1, ltree); /* send the length code */
	        extra = extra_lbits[code];
	        if (extra !== 0) {
	          lc -= base_length[code];
	          send_bits(s, lc, extra);       /* send the extra length bits */
	        }
	        dist--; /* dist is now the match distance - 1 */
	        code = d_code(dist);
	        //Assert (code < D_CODES, "bad d_code");
	
	        send_code(s, code, dtree);       /* send the distance code */
	        extra = extra_dbits[code];
	        if (extra !== 0) {
	          dist -= base_dist[code];
	          send_bits(s, dist, extra);   /* send the extra distance bits */
	        }
	      } /* literal or match pair ? */
	
	      /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
	      //Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,
	      //       "pendingBuf overflow");
	
	    } while (lx < s.last_lit);
	  }
	
	  send_code(s, END_BLOCK, ltree);
	}
/* ===========================================================================
	 * Send the block data compressed using the given Huffman trees
	 */
Send the block data compressed using the given Huffman trees
Send the block data compressed using the given Huffman trees
function compress_block(s, ltree, dtree)
	{
	  var dist;           
	  var lc;             
	  var lx = 0;         
	  var code;           
	  var extra;          
	  if (s.last_lit !== 0) {
	    do {
	      dist = (s.pending_buf[s.d_buf + lx*2] << 8) | (s.pending_buf[s.d_buf + lx*2 + 1]);
	      lc = s.pending_buf[s.l_buf + lx];
	      lx++;
	      if (dist === 0) {
	        send_code(s, lc, ltree); 
	      } else {
	        code = _length_code[lc];
	        send_code(s, code+LITERALS+1, ltree); 
	        extra = extra_lbits[code];
	        if (extra !== 0) {
	          lc -= base_length[code];
	          send_bits(s, lc, extra);       
	        }
	        dist--; 
	        code = d_code(dist);
	        send_code(s, code, dtree);       
	        extra = extra_dbits[code];
	        if (extra !== 0) {
	          dist -= base_dist[code];
	          send_bits(s, dist, extra);   
	        }
	      } 
	    } while (lx < s.last_lit);
	  }
	  send_code(s, END_BLOCK, ltree);
	}
function compress_block ( s , ltree , dtree ) { var dist ; var lc ; var lx = 0 ; var code ; var extra ; if ( s . last_lit !== 0 ) { do { dist = ( s . pending_buf [ s . d_buf + lx * 2 ] << 8 ) | ( s . pending_buf [ s . d_buf + lx * 2 + 1 ] ) ; lc = s . pending_buf [ s . l_buf + lx ] ; lx ++ ; if ( dist === 0 ) { send_code ( s , lc , ltree ) ; } else { code = _length_code [ lc ] ; send_code ( s , code + LITERALS + 1 , ltree ) ; extra = extra_lbits [ code ] ; if ( extra !== 0 ) { lc -= base_length [ code ] ; send_bits ( s , lc , extra ) ; } dist -- ; code = d_code ( dist ) ; send_code ( s , code , dtree ) ; extra = extra_dbits [ code ] ; if ( extra !== 0 ) { dist -= base_dist [ code ] ; send_bits ( s , dist , extra ) ; } } } while ( lx < s . last_lit ) ; } send_code ( s , END_BLOCK , ltree ) ; }
Send the block data compressed using the given Huffman trees
Send the block data compressed using the given Huffman trees
//    deflate_state *s; //    const ct_data *ltree; /* literal tree */ //    const ct_data *dtree; /* distance tree */ /* distance of matched string */ /* match length or unmatched char (if dist == 0) */ /* running index in l_buf */ /* the code to send */ /* number of extra bits to send */ /* send a literal byte */ //Tracecv(isgraph(lc), (stderr," '%c' ", lc)); /* Here, lc is the match length - MIN_MATCH */ /* send the length code */ /* send the extra length bits */ /* dist is now the match distance - 1 */ //Assert (code < D_CODES, "bad d_code"); /* send the distance code */ /* send the extra distance bits */ /* literal or match pair ? */ /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */ //Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx, //       "pendingBuf overflow");