|
|
@ -345,8 +345,9 @@ var FlateStream = (function() { |
|
|
|
DecodeStream.call(this); |
|
|
|
DecodeStream.call(this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
constructor.prototype = { |
|
|
|
constructor.prototype = Object.create(DecodeStream.prototype); |
|
|
|
getBits: function(bits) { |
|
|
|
|
|
|
|
|
|
|
|
constructor.prototype.getBits = function(bits) { |
|
|
|
var codeSize = this.codeSize; |
|
|
|
var codeSize = this.codeSize; |
|
|
|
var codeBuf = this.codeBuf; |
|
|
|
var codeBuf = this.codeBuf; |
|
|
|
var bytes = this.bytes; |
|
|
|
var bytes = this.bytes; |
|
|
@ -364,8 +365,8 @@ var FlateStream = (function() { |
|
|
|
this.codeSize = codeSize -= bits; |
|
|
|
this.codeSize = codeSize -= bits; |
|
|
|
this.bytesPos = bytesPos; |
|
|
|
this.bytesPos = bytesPos; |
|
|
|
return b; |
|
|
|
return b; |
|
|
|
}, |
|
|
|
}; |
|
|
|
getCode: function(table) { |
|
|
|
constructor.prototype.getCode = function(table) { |
|
|
|
var codes = table[0]; |
|
|
|
var codes = table[0]; |
|
|
|
var maxLen = table[1]; |
|
|
|
var maxLen = table[1]; |
|
|
|
var codeSize = this.codeSize; |
|
|
|
var codeSize = this.codeSize; |
|
|
@ -389,8 +390,8 @@ var FlateStream = (function() { |
|
|
|
this.codeSize = (codeSize - codeLen); |
|
|
|
this.codeSize = (codeSize - codeLen); |
|
|
|
this.bytesPos = bytesPos; |
|
|
|
this.bytesPos = bytesPos; |
|
|
|
return codeVal; |
|
|
|
return codeVal; |
|
|
|
}, |
|
|
|
}; |
|
|
|
generateHuffmanTable: function(lengths) { |
|
|
|
constructor.prototype.generateHuffmanTable = function(lengths) { |
|
|
|
var n = lengths.length; |
|
|
|
var n = lengths.length; |
|
|
|
|
|
|
|
|
|
|
|
// find max code length
|
|
|
|
// find max code length
|
|
|
@ -426,8 +427,8 @@ var FlateStream = (function() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return [codes, maxLen]; |
|
|
|
return [codes, maxLen]; |
|
|
|
}, |
|
|
|
}; |
|
|
|
readBlock: function() { |
|
|
|
constructor.prototype.readBlock = function() { |
|
|
|
function repeat(stream, array, len, offset, what) { |
|
|
|
function repeat(stream, array, len, offset, what) { |
|
|
|
var repeat = stream.getBits(len) + offset; |
|
|
|
var repeat = stream.getBits(len) + offset; |
|
|
|
while (repeat-- > 0) |
|
|
|
while (repeat-- > 0) |
|
|
@ -507,10 +508,10 @@ var FlateStream = (function() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
litCodeTable = this.generateHuffmanTable( |
|
|
|
litCodeTable = |
|
|
|
codeLengths.slice(0, numLitCodes)); |
|
|
|
this.generateHuffmanTable(codeLengths.slice(0, numLitCodes)); |
|
|
|
distCodeTable = this.generateHuffmanTable( |
|
|
|
distCodeTable = |
|
|
|
codeLengths.slice(numLitCodes, codes)); |
|
|
|
this.generateHuffmanTable(codeLengths.slice(numLitCodes, codes)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
error("Unknown block type in flate stream"); |
|
|
|
error("Unknown block type in flate stream"); |
|
|
|
} |
|
|
|
} |
|
|
@ -543,16 +544,8 @@ var FlateStream = (function() { |
|
|
|
buffer[pos] = buffer[pos - dist]; |
|
|
|
buffer[pos] = buffer[pos - dist]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var thisPrototype = constructor.prototype; |
|
|
|
|
|
|
|
var superPrototype = DecodeStream.prototype; |
|
|
|
|
|
|
|
for (var i in superPrototype) { |
|
|
|
|
|
|
|
if (!thisPrototype[i]) |
|
|
|
|
|
|
|
thisPrototype[i] = superPrototype[i]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return constructor; |
|
|
|
return constructor; |
|
|
|
})(); |
|
|
|
})(); |
|
|
|
|
|
|
|
|
|
|
@ -586,8 +579,9 @@ var PredictorStream = (function() { |
|
|
|
DecodeStream.call(this); |
|
|
|
DecodeStream.call(this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
constructor.prototype = { |
|
|
|
constructor.prototype = Object.create(DecodeStream.prototype); |
|
|
|
readBlockTiff : function() { |
|
|
|
|
|
|
|
|
|
|
|
constructor.prototype.readBlockTiff = function() { |
|
|
|
var buffer = this.buffer; |
|
|
|
var buffer = this.buffer; |
|
|
|
var pos = this.pos; |
|
|
|
var pos = this.pos; |
|
|
|
|
|
|
|
|
|
|
@ -651,8 +645,8 @@ var PredictorStream = (function() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
this.bufferLength += rowBytes; |
|
|
|
this.bufferLength += rowBytes; |
|
|
|
}, |
|
|
|
}; |
|
|
|
readBlockPng : function() { |
|
|
|
constructor.prototype.readBlockPng = function() { |
|
|
|
var buffer = this.buffer; |
|
|
|
var buffer = this.buffer; |
|
|
|
var pos = this.pos; |
|
|
|
var pos = this.pos; |
|
|
|
|
|
|
|
|
|
|
@ -726,16 +720,8 @@ var PredictorStream = (function() { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
this.bufferLength += rowBytes; |
|
|
|
this.bufferLength += rowBytes; |
|
|
|
}, |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var thisPrototype = constructor.prototype; |
|
|
|
|
|
|
|
var superPrototype = DecodeStream.prototype; |
|
|
|
|
|
|
|
for (var i in superPrototype) { |
|
|
|
|
|
|
|
if (!thisPrototype[i]) |
|
|
|
|
|
|
|
thisPrototype[i] = superPrototype[i]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return constructor; |
|
|
|
return constructor; |
|
|
|
})(); |
|
|
|
})(); |
|
|
|
|
|
|
|
|
|
|
|