1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 09:38:06 +02:00

Let Parser_makeFilter pass in the DecodeParms data to various image Streams, instead of re-fetching it in various [...]Stream.prototype.ensureBuffer methods

In `Parser_filter` the `DecodeParms` data is fetched and passed to `Parser_makeFilter`, where we also make sure that a `Ref` is resolved to a direct object.
We can thus pass this along to the various image `Stream` constructors, to avoid the current situation where we lookup/resolve data that is already available.
Note also that we currently do *not* handle the case where `DecodeParms` is an Array entirely correct in the various image `Stream`s, and this patch fixes that for free.
This commit is contained in:
Jonas Jenwald 2016-10-14 17:19:50 +02:00
parent c1a34ffbcd
commit c8f83d6487
2 changed files with 20 additions and 23 deletions

View file

@ -539,6 +539,9 @@ var Parser = (function ParserClosure() {
var filter = dict.get('Filter', 'F');
var params = dict.get('DecodeParms', 'DP');
if (isName(filter)) {
if (isArray(params)) {
params = params[0];
}
return this.makeFilter(stream, filter.name, length, params);
}
@ -599,11 +602,11 @@ var Parser = (function ParserClosure() {
}
if (name === 'DCTDecode' || name === 'DCT') {
xrefStreamStats[StreamType.DCT] = true;
return new JpegStream(stream, maybeLength, stream.dict);
return new JpegStream(stream, maybeLength, stream.dict, params);
}
if (name === 'JPXDecode' || name === 'JPX') {
xrefStreamStats[StreamType.JPX] = true;
return new JpxStream(stream, maybeLength, stream.dict);
return new JpxStream(stream, maybeLength, stream.dict, params);
}
if (name === 'ASCII85Decode' || name === 'A85') {
xrefStreamStats[StreamType.A85] = true;
@ -623,7 +626,7 @@ var Parser = (function ParserClosure() {
}
if (name === 'JBIG2Decode') {
xrefStreamStats[StreamType.JBIG] = true;
return new Jbig2Stream(stream, maybeLength, stream.dict);
return new Jbig2Stream(stream, maybeLength, stream.dict, params);
}
warn('filter "' + name + '" not supported yet');
return stream;