mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:17:44 +00:00
LibPDF+LibGfx: Pass jbig2-filtered data to JBIG2ImageDecoderPlugin
Except for /JBIG2Globals, which we bail out on for now. In my 1000 files, 13 use JBIG2, and of those, 2 use JBIG2Globals (0000372.pdf e.g. page 11 and 0000857.pdf e.g. page 1), and only one (the latter) of the two uses the same JBIG2Globals stream for more than a single image. JBIG2ImageDecoderPlugin cannot decode the data yet, so no behavior change, but with `#define JBIG2_DEBUG 1` at the top of that file, it now prints segment header info for PDFs containing JBIG2 data :^)
This commit is contained in:
parent
bd60d1db7e
commit
953f6c5d9b
5 changed files with 26 additions and 5 deletions
|
@ -112,6 +112,7 @@
|
|||
X(Info) \
|
||||
X(Intent) \
|
||||
X(JBIG2Decode) \
|
||||
X(JBIG2Globals) \
|
||||
X(JPXDecode) \
|
||||
X(K) \
|
||||
X(Keywords) \
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <LibCompress/LZWDecoder.h>
|
||||
#include <LibCompress/PackBitsDecoder.h>
|
||||
#include <LibGfx/ImageFormats/CCITTDecoder.h>
|
||||
#include <LibGfx/ImageFormats/JBIG2Loader.h>
|
||||
#include <LibGfx/ImageFormats/JPEGLoader.h>
|
||||
#include <LibGfx/ImageFormats/PNGLoader.h>
|
||||
#include <LibPDF/CommonNames.h>
|
||||
|
@ -33,7 +34,7 @@ PDFErrorOr<ByteBuffer> Filter::decode(ReadonlyBytes bytes, DeprecatedFlyString c
|
|||
if (encoding_type == CommonNames::CCITTFaxDecode)
|
||||
return decode_ccitt(bytes, decode_parms);
|
||||
if (encoding_type == CommonNames::JBIG2Decode)
|
||||
return decode_jbig2(bytes);
|
||||
return decode_jbig2(bytes, decode_parms);
|
||||
if (encoding_type == CommonNames::DCTDecode)
|
||||
return decode_dct(bytes);
|
||||
if (encoding_type == CommonNames::JPXDecode)
|
||||
|
@ -333,9 +334,15 @@ PDFErrorOr<ByteBuffer> Filter::decode_ccitt(ReadonlyBytes bytes, RefPtr<DictObje
|
|||
return decoded;
|
||||
}
|
||||
|
||||
PDFErrorOr<ByteBuffer> Filter::decode_jbig2(ReadonlyBytes)
|
||||
PDFErrorOr<ByteBuffer> Filter::decode_jbig2(ReadonlyBytes bytes, RefPtr<DictObject> decode_parms)
|
||||
{
|
||||
return Error::rendering_unsupported_error("JBIG2 Filter is unsupported");
|
||||
// 3.3.6 JBIG2Decode Filter
|
||||
if (decode_parms) {
|
||||
if (decode_parms->contains(CommonNames::JBIG2Globals))
|
||||
return Error::rendering_unsupported_error("JBIG2Globals is not yet supported");
|
||||
}
|
||||
|
||||
return TRY(Gfx::JBIG2ImageDecoderPlugin::decode_embedded(bytes));
|
||||
}
|
||||
|
||||
PDFErrorOr<ByteBuffer> Filter::decode_dct(ReadonlyBytes bytes)
|
||||
|
|
|
@ -26,7 +26,7 @@ private:
|
|||
static PDFErrorOr<ByteBuffer> decode_flate(ReadonlyBytes bytes, RefPtr<DictObject> decode_parms);
|
||||
static PDFErrorOr<ByteBuffer> decode_run_length(ReadonlyBytes bytes);
|
||||
static PDFErrorOr<ByteBuffer> decode_ccitt(ReadonlyBytes bytes, RefPtr<DictObject> decode_parms);
|
||||
static PDFErrorOr<ByteBuffer> decode_jbig2(ReadonlyBytes bytes);
|
||||
static PDFErrorOr<ByteBuffer> decode_jbig2(ReadonlyBytes bytes, RefPtr<DictObject> decode_parms);
|
||||
static PDFErrorOr<ByteBuffer> decode_dct(ReadonlyBytes bytes);
|
||||
static PDFErrorOr<ByteBuffer> decode_jpx(ReadonlyBytes bytes);
|
||||
static PDFErrorOr<ByteBuffer> decode_crypt(ReadonlyBytes bytes);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue