add initialization l_buf and d_buf

This commit is contained in:
nik 2014-02-16 23:54:54 -03:00
parent 42237287cb
commit 7644f9f3db
2 changed files with 5 additions and 2 deletions

View file

@ -999,6 +999,9 @@ function deflateInit2(strm, level, method, windowBits, memLevel, strategy) {
s.pending_buf_size = s.lit_bufsize * 4;
s.pending_buf = utils.arrayCreate(s.pending_buf_size);
s.d_buf = Math.floor(s.lit_bufsize / 2);
s.l_buf = (1 + 2) * s.lit_bufsize;
s.level = level;
s.strategy = strategy;
s.method = method;

View file

@ -162,12 +162,12 @@ function send_bits(s, value, length) {
var len = length, val;
if (s.bi_valid > (Buf_size - len)) {
val = value;
s.bi_buf |= val << s.bi_valid;
s.bi_buf |= (val << s.bi_valid) & 0xffff;
put_short(s, s.bi_buf);
s.bi_buf = val >> (Buf_size - s.bi_valid);
s.bi_valid += len - Buf_size;
} else {
s.bi_buf |= value << s.bi_valid;
s.bi_buf |= (value << s.bi_valid) & 0xffff;
s.bi_valid += len;
}
}