|
|
|
@ -374,10 +374,10 @@ var FlateStream = (function FlateStreamClosure() {
@@ -374,10 +374,10 @@ var FlateStream = (function FlateStreamClosure() {
|
|
|
|
|
|
|
|
|
|
var cmf = str.getByte(); |
|
|
|
|
var flg = str.getByte(); |
|
|
|
|
if (cmf == -1 || flg == -1) { |
|
|
|
|
if (cmf === -1 || flg === -1) { |
|
|
|
|
error('Invalid header in flate stream: ' + cmf + ', ' + flg); |
|
|
|
|
} |
|
|
|
|
if ((cmf & 0x0f) != 0x08) { |
|
|
|
|
if ((cmf & 0x0f) !== 0x08) { |
|
|
|
|
error('Unknown compression method in flate stream: ' + cmf + ', ' + flg); |
|
|
|
|
} |
|
|
|
|
if ((((cmf << 8) + flg) % 31) !== 0) { |
|
|
|
@ -444,7 +444,7 @@ var FlateStream = (function FlateStreamClosure() {
@@ -444,7 +444,7 @@ var FlateStream = (function FlateStreamClosure() {
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
FlateStream.prototype.generateHuffmanTable = |
|
|
|
|
function flateStreamGenerateHuffmanTable(lengths) { |
|
|
|
|
function flateStreamGenerateHuffmanTable(lengths) { |
|
|
|
|
var n = lengths.length; |
|
|
|
|
|
|
|
|
|
// find max code length
|
|
|
|
@ -463,7 +463,7 @@ var FlateStream = (function FlateStreamClosure() {
@@ -463,7 +463,7 @@ var FlateStream = (function FlateStreamClosure() {
|
|
|
|
|
len <= maxLen; |
|
|
|
|
++len, code <<= 1, skip <<= 1) { |
|
|
|
|
for (var val = 0; val < n; ++val) { |
|
|
|
|
if (lengths[val] == len) { |
|
|
|
|
if (lengths[val] === len) { |
|
|
|
|
// bit-reverse the code
|
|
|
|
|
var code2 = 0; |
|
|
|
|
var t = code; |
|
|
|
@ -513,7 +513,7 @@ var FlateStream = (function FlateStreamClosure() {
@@ -513,7 +513,7 @@ var FlateStream = (function FlateStreamClosure() {
|
|
|
|
|
error('Bad block header in flate stream'); |
|
|
|
|
} |
|
|
|
|
check |= (b << 8); |
|
|
|
|
if (check != (~blockLen & 0xffff) && |
|
|
|
|
if (check !== (~blockLen & 0xffff) && |
|
|
|
|
(blockLen !== 0 || check !== 0)) { |
|
|
|
|
// Ignoring error for bad "empty" block (see issue 1277)
|
|
|
|
|
error('Bad uncompressed block length in flate stream'); |
|
|
|
@ -544,10 +544,10 @@ var FlateStream = (function FlateStreamClosure() {
@@ -544,10 +544,10 @@ var FlateStream = (function FlateStreamClosure() {
|
|
|
|
|
|
|
|
|
|
var litCodeTable; |
|
|
|
|
var distCodeTable; |
|
|
|
|
if (hdr == 1) { // compressed block, fixed codes
|
|
|
|
|
if (hdr === 1) { // compressed block, fixed codes
|
|
|
|
|
litCodeTable = fixedLitCodeTab; |
|
|
|
|
distCodeTable = fixedDistCodeTab; |
|
|
|
|
} else if (hdr == 2) { // compressed block, dynamic codes
|
|
|
|
|
} else if (hdr === 2) { // compressed block, dynamic codes
|
|
|
|
|
var numLitCodes = this.getBits(5) + 257; |
|
|
|
|
var numDistCodes = this.getBits(5) + 1; |
|
|
|
|
var numCodeLenCodes = this.getBits(4) + 4; |
|
|
|
@ -569,11 +569,11 @@ var FlateStream = (function FlateStreamClosure() {
@@ -569,11 +569,11 @@ var FlateStream = (function FlateStreamClosure() {
|
|
|
|
|
var bitsLength, bitsOffset, what; |
|
|
|
|
while (i < codes) { |
|
|
|
|
var code = this.getCode(codeLenCodeTab); |
|
|
|
|
if (code == 16) { |
|
|
|
|
if (code === 16) { |
|
|
|
|
bitsLength = 2; bitsOffset = 3; what = len; |
|
|
|
|
} else if (code == 17) { |
|
|
|
|
} else if (code === 17) { |
|
|
|
|
bitsLength = 3; bitsOffset = 3; what = (len = 0); |
|
|
|
|
} else if (code == 18) { |
|
|
|
|
} else if (code === 18) { |
|
|
|
|
bitsLength = 7; bitsOffset = 11; what = (len = 0); |
|
|
|
|
} else { |
|
|
|
|
codeLengths[i++] = len = code; |
|
|
|
@ -607,7 +607,7 @@ var FlateStream = (function FlateStreamClosure() {
@@ -607,7 +607,7 @@ var FlateStream = (function FlateStreamClosure() {
|
|
|
|
|
buffer[pos++] = code1; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
if (code1 == 256) { |
|
|
|
|
if (code1 === 256) { |
|
|
|
|
this.bufferLength = pos; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -928,7 +928,7 @@ var JpegStream = (function JpegStreamClosure() {
@@ -928,7 +928,7 @@ var JpegStream = (function JpegStreamClosure() {
|
|
|
|
|
function JpegStream_isNativelyDecodable(xref, res) { |
|
|
|
|
var cs = ColorSpace.parse(this.dict.get('ColorSpace', 'CS'), xref, res); |
|
|
|
|
var numComps = cs.numComps; |
|
|
|
|
return numComps == 1 || numComps == 3; |
|
|
|
|
return numComps === 1 || numComps === 3; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
return JpegStream; |
|
|
|
@ -1148,7 +1148,7 @@ var Ascii85Stream = (function Ascii85StreamClosure() {
@@ -1148,7 +1148,7 @@ var Ascii85Stream = (function Ascii85StreamClosure() {
|
|
|
|
|
var i; |
|
|
|
|
|
|
|
|
|
// special code for z
|
|
|
|
|
if (c == Z_LOWER_CHAR) { |
|
|
|
|
if (c === Z_LOWER_CHAR) { |
|
|
|
|
buffer = this.ensureBuffer(bufferLength + 4); |
|
|
|
|
for (i = 0; i < 4; ++i) { |
|
|
|
|
buffer[bufferLength + i] = 0; |
|
|
|
@ -1165,7 +1165,7 @@ var Ascii85Stream = (function Ascii85StreamClosure() {
@@ -1165,7 +1165,7 @@ var Ascii85Stream = (function Ascii85StreamClosure() {
|
|
|
|
|
|
|
|
|
|
input[i] = c; |
|
|
|
|
|
|
|
|
|
if (c === EOF || c == TILDA_CHAR) { |
|
|
|
|
if (c === EOF || c === TILDA_CHAR) { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -1272,7 +1272,7 @@ var RunLengthStream = (function RunLengthStreamClosure() {
@@ -1272,7 +1272,7 @@ var RunLengthStream = (function RunLengthStreamClosure() {
|
|
|
|
|
// (in addition to the second byte from the header), n = 129 through 255 -
|
|
|
|
|
// duplicate the second byte from the header (257 - n) times, n = 128 - end.
|
|
|
|
|
var repeatHeader = this.str.getBytes(2); |
|
|
|
|
if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] == 128) { |
|
|
|
|
if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) { |
|
|
|
|
this.eof = true; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -1765,7 +1765,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
@@ -1765,7 +1765,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|
|
|
|
while ((code1 = this.lookBits(12)) === 0) { |
|
|
|
|
this.eatBits(1); |
|
|
|
|
} |
|
|
|
|
if (code1 == 1) { |
|
|
|
|
if (code1 === 1) { |
|
|
|
|
this.eatBits(12); |
|
|
|
|
} |
|
|
|
|
if (this.encoding > 0) { |
|
|
|
@ -2024,7 +2024,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
@@ -2024,7 +2024,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|
|
|
|
|
|
|
|
|
var gotEOL = false; |
|
|
|
|
|
|
|
|
|
if (!this.eoblock && this.row == this.rows - 1) { |
|
|
|
|
if (!this.eoblock && this.row === this.rows - 1) { |
|
|
|
|
this.eof = true; |
|
|
|
|
} else { |
|
|
|
|
code1 = this.lookBits(12); |
|
|
|
@ -2032,10 +2032,10 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
@@ -2032,10 +2032,10 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|
|
|
|
this.eatBits(1); |
|
|
|
|
code1 = this.lookBits(12); |
|
|
|
|
} |
|
|
|
|
if (code1 == 1) { |
|
|
|
|
if (code1 === 1) { |
|
|
|
|
this.eatBits(12); |
|
|
|
|
gotEOL = true; |
|
|
|
|
} else if (code1 == EOF) { |
|
|
|
|
} else if (code1 === EOF) { |
|
|
|
|
this.eof = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -2047,7 +2047,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
@@ -2047,7 +2047,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|
|
|
|
|
|
|
|
|
if (this.eoblock && gotEOL) { |
|
|
|
|
code1 = this.lookBits(12); |
|
|
|
|
if (code1 == 1) { |
|
|
|
|
if (code1 === 1) { |
|
|
|
|
this.eatBits(12); |
|
|
|
|
if (this.encoding > 0) { |
|
|
|
|
this.lookBits(1); |
|
|
|
@ -2056,7 +2056,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
@@ -2056,7 +2056,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|
|
|
|
if (this.encoding >= 0) { |
|
|
|
|
for (i = 0; i < 4; ++i) { |
|
|
|
|
code1 = this.lookBits(12); |
|
|
|
|
if (code1 != 1) { |
|
|
|
|
if (code1 !== 1) { |
|
|
|
|
info('bad rtc code: ' + code1); |
|
|
|
|
} |
|
|
|
|
this.eatBits(12); |
|
|
|
@ -2071,11 +2071,11 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
@@ -2071,11 +2071,11 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|
|
|
|
} else if (this.err && this.eoline) { |
|
|
|
|
while (true) { |
|
|
|
|
code1 = this.lookBits(13); |
|
|
|
|
if (code1 == EOF) { |
|
|
|
|
if (code1 === EOF) { |
|
|
|
|
this.eof = true; |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
if ((code1 >> 1) == 1) { |
|
|
|
|
if ((code1 >> 1) === 1) { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
this.eatBits(1); |
|
|
|
@ -2151,7 +2151,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
@@ -2151,7 +2151,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|
|
|
|
var limitValue = limit || 0; |
|
|
|
|
for (var i = start; i <= end; ++i) { |
|
|
|
|
var code = this.lookBits(i); |
|
|
|
|
if (code == EOF) { |
|
|
|
|
if (code === EOF) { |
|
|
|
|
return [true, 1, false]; |
|
|
|
|
} |
|
|
|
|
if (i < end) { |
|
|
|
@ -2159,7 +2159,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
@@ -2159,7 +2159,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|
|
|
|
} |
|
|
|
|
if (!limitValue || code >= limitValue) { |
|
|
|
|
var p = table[code - limitValue]; |
|
|
|
|
if (p[0] == i) { |
|
|
|
|
if (p[0] === i) { |
|
|
|
|
this.eatBits(i); |
|
|
|
|
return [true, p[1], true]; |
|
|
|
|
} |
|
|
|
@ -2197,7 +2197,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
@@ -2197,7 +2197,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|
|
|
|
var p; |
|
|
|
|
if (this.eoblock) { |
|
|
|
|
code = this.lookBits(12); |
|
|
|
|
if (code == EOF) { |
|
|
|
|
if (code === EOF) { |
|
|
|
|
return 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -2233,7 +2233,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
@@ -2233,7 +2233,7 @@ var CCITTFaxStream = (function CCITTFaxStreamClosure() {
|
|
|
|
|
var code, p; |
|
|
|
|
if (this.eoblock) { |
|
|
|
|
code = this.lookBits(13); |
|
|
|
|
if (code == EOF) { |
|
|
|
|
if (code === EOF) { |
|
|
|
|
return 1; |
|
|
|
|
} |
|
|
|
|
if ((code >> 7) === 0) { |
|
|
|
@ -2381,7 +2381,7 @@ var LZWStream = (function LZWStreamClosure() {
@@ -2381,7 +2381,7 @@ var LZWStream = (function LZWStreamClosure() {
|
|
|
|
|
} else { |
|
|
|
|
currentSequence[currentSequenceLength++] = currentSequence[0]; |
|
|
|
|
} |
|
|
|
|
} else if (code == 256) { |
|
|
|
|
} else if (code === 256) { |
|
|
|
|
codeLength = 9; |
|
|
|
|
nextCode = 258; |
|
|
|
|
currentSequenceLength = 0; |
|
|
|
|