(s, ltree, dtree)
| 22948 | * Send the block data compressed using the given Huffman trees |
| 22949 | */ |
| 22950 | function compress_block(s, ltree, dtree) |
| 22951 | // deflate_state *s; |
| 22952 | // const ct_data *ltree; /* literal tree */ |
| 22953 | // const ct_data *dtree; /* distance tree */ |
| 22954 | { |
| 22955 | var dist; /* distance of matched string */ |
| 22956 | var lc; /* match length or unmatched char (if dist == 0) */ |
| 22957 | var lx = 0; /* running index in l_buf */ |
| 22958 | var code; /* the code to send */ |
| 22959 | var extra; /* number of extra bits to send */ |
| 22960 | |
| 22961 | if (s.last_lit !== 0) { |
| 22962 | do { |
| 22963 | dist = (s.pending_buf[s.d_buf + lx * 2] << 8) | (s.pending_buf[s.d_buf + lx * 2 + 1]); |
| 22964 | lc = s.pending_buf[s.l_buf + lx]; |
| 22965 | lx++; |
| 22966 | |
| 22967 | if (dist === 0) { |
| 22968 | send_code(s, lc, ltree); /* send a literal byte */ |
| 22969 | //Tracecv(isgraph(lc), (stderr," '%c' ", lc)); |
| 22970 | } else { |
| 22971 | /* Here, lc is the match length - MIN_MATCH */ |
| 22972 | code = _length_code[lc]; |
| 22973 | send_code(s, code + LITERALS + 1, ltree); /* send the length code */ |
| 22974 | extra = extra_lbits[code]; |
| 22975 | if (extra !== 0) { |
| 22976 | lc -= base_length[code]; |
| 22977 | send_bits(s, lc, extra); /* send the extra length bits */ |
| 22978 | } |
| 22979 | dist--; /* dist is now the match distance - 1 */ |
| 22980 | code = d_code(dist); |
| 22981 | //Assert (code < D_CODES, "bad d_code"); |
| 22982 | |
| 22983 | send_code(s, code, dtree); /* send the distance code */ |
| 22984 | extra = extra_dbits[code]; |
| 22985 | if (extra !== 0) { |
| 22986 | dist -= base_dist[code]; |
| 22987 | send_bits(s, dist, extra); /* send the extra distance bits */ |
| 22988 | } |
| 22989 | } /* literal or match pair ? */ |
| 22990 | |
| 22991 | /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */ |
| 22992 | //Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx, |
| 22993 | // "pendingBuf overflow"); |
| 22994 | |
| 22995 | } while (lx < s.last_lit); |
| 22996 | } |
| 22997 | |
| 22998 | send_code(s, END_BLOCK, ltree); |
| 22999 | } |
| 23000 | |
| 23001 | |
| 23002 | /* =========================================================================== |
no test coverage detected