var wsize; /* window size or zero if not using window */
var whave; /* valid bytes in the window */
var wnext; /* window write index */
- var window; /* allocated sliding window, if wsize != 0 */
+ // Use `s_window` instead `window`, avoid conflict with instrumentation tools
+ var s_window; /* allocated sliding window, if wsize != 0 */
var hold; /* local strm.hold */
var bits; /* local strm.bits */
var lcode; /* local strm.lencode */
wsize = state.wsize;
whave = state.whave;
wnext = state.wnext;
- window = state.window;
+ s_window = state.window;
hold = state.hold;
bits = state.bits;
lcode = state.lencode;
//#endif
}
from = 0; // window index
- from_source = window;
+ from_source = s_window;
if (wnext === 0) { /* very common case */
from += wsize - op;
if (op < len) { /* some from window */
len -= op;
do {
- output[_out++] = window[from++];
+ output[_out++] = s_window[from++];
} while (--op);
from = _out - dist; /* rest from output */
from_source = output;
if (op < len) { /* some from end of window */
len -= op;
do {
- output[_out++] = window[from++];
+ output[_out++] = s_window[from++];
} while (--op);
from = 0;
if (wnext < len) { /* some from start of window */
op = wnext;
len -= op;
do {
- output[_out++] = window[from++];
+ output[_out++] = s_window[from++];
} while (--op);
from = _out - dist; /* rest from output */
from_source = output;
if (op < len) { /* some from window */
len -= op;
do {
- output[_out++] = window[from++];
+ output[_out++] = s_window[from++];
} while (--op);
from = _out - dist; /* rest from output */
from_source = output;
module.exports = ZStream;
-},{}],"/partial_inflator.js":[function(require,module,exports){
-var zlib = require('./lib/zlib/inflate.js');
-var ZStream = require('./lib/zlib/zstream.js');
+},{}],8:[function(require,module,exports){
+var zlib = require('../node_modules/pako/lib/zlib/inflate.js');
+var ZStream = require('../node_modules/pako/lib/zlib/zstream.js');
var Inflate = function () {
this.strm = new ZStream();
};
Inflate.prototype = {
- inflate: function (data, flush) {
+ inflate: function (data, flush, expected) {
this.strm.input = data;
this.strm.avail_in = this.strm.input.length;
this.strm.next_in = 0;
this.strm.next_out = 0;
+ // resize our output buffer if it's too small
+ // (we could just use multiple chunks, but that would cause an extra
+ // allocation each time to flatten the chunks)
+ if (expected > this.chunkSize) {
+ this.chunkSize = expected;
+ this.strm.output = new Uint8Array(this.chunkSize);
+ }
+
this.strm.avail_out = this.chunkSize;
zlib.inflate(this.strm, flush);
module.exports = {Inflate: Inflate};
-},{"./lib/zlib/inflate.js":5,"./lib/zlib/zstream.js":7}]},{},[])("/partial_inflator.js")
-});
+},{"../node_modules/pako/lib/zlib/inflate.js":5,"../node_modules/pako/lib/zlib/zstream.js":7}]},{},[8])(8)
+});
\ No newline at end of file
var resetStreams = 0;
var streamId = -1;
- var decompress = function (data) {
+ var decompress = function (data, expected) {
for (var i = 0; i < 4; i++) {
if ((resetStreams >> i) & 1) {
this._FBU.zlibs[i].reset();
+ console.debug('RESET!');
Util.Info("Reset zlib stream " + i);
}
}
//var uncompressed = this._FBU.zlibs[streamId].uncompress(data, 0);
- var uncompressed = this._FBU.zlibs[streamId].inflate(data, true);
+ var uncompressed = this._FBU.zlibs[streamId].inflate(data, true, expected);
/*if (uncompressed.status !== 0) {
Util.Error("Invalid data in zlib stream");
}*/
if (raw) {
data = this._sock.rQshiftBytes(cl_data);
} else {
- data = decompress(this._sock.rQshiftBytes(cl_data));
+ data = decompress(this._sock.rQshiftBytes(cl_data), rowSize * this._FBU.height);
}
// Convert indexed (palette based) image data to RGB
if (raw) {
data = this._sock.rQshiftBytes(cl_data);
} else {
- data = decompress(this._sock.rQshiftBytes(cl_data));
+ data = decompress(this._sock.rQshiftBytes(cl_data), uncompressedSize);
}
this._display.blitRgbImage(this._FBU.x, this._FBU.y, this._FBU.width, this._FBU.height, data, 0, false);
-var zlib = require('./lib/zlib/inflate.js');
-var ZStream = require('./lib/zlib/zstream.js');
+var zlib = require('../node_modules/pako/lib/zlib/inflate.js');
+var ZStream = require('../node_modules/pako/lib/zlib/zstream.js');
var Inflate = function () {
this.strm = new ZStream();
};
Inflate.prototype = {
- inflate: function (data, flush) {
+ inflate: function (data, flush, expected) {
this.strm.input = data;
this.strm.avail_in = this.strm.input.length;
this.strm.next_in = 0;
this.strm.next_out = 0;
+ // resize our output buffer if it's too small
+ // (we could just use multiple chunks, but that would cause an extra
+ // allocation each time to flatten the chunks)
+ if (expected > this.chunkSize) {
+ this.chunkSize = expected;
+ this.strm.output = new Uint8Array(this.chunkSize);
+ }
+
this.strm.avail_out = this.chunkSize;
zlib.inflate(this.strm, flush);