summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-11-12 18:44:31 +0100
committerTor Andersson <tor.andersson@artifex.com>2018-11-12 20:25:17 +0100
commita70d48f3b7ff17ac18daa97b5da0c8d3347969fa (patch)
tree2e97107048a6e56efe1f6d31a49ad020ae4aeced /source
parentf722c477e86360863dc812280b7f083b9a5a106e (diff)
downloadmupdf-a70d48f3b7ff17ac18daa97b5da0c8d3347969fa.tar.xz
Fix 699094: Never decompress JPX streams in mutool clean.
Diffstat (limited to 'source')
-rw-r--r--source/pdf/pdf-write.c47
1 files changed, 35 insertions, 12 deletions
diff --git a/source/pdf/pdf-write.c b/source/pdf/pdf-write.c
index 0fe311c1..fd56c60b 100644
--- a/source/pdf/pdf-write.c
+++ b/source/pdf/pdf-write.c
@@ -1813,29 +1813,41 @@ static void expandstream(fz_context *ctx, pdf_document *doc, pdf_write_state *op
}
}
-static int is_image_filter(const char *s)
+static int is_image_filter(pdf_obj *s)
{
- if (!strcmp(s, "CCITTFaxDecode") || !strcmp(s, "CCF") ||
- !strcmp(s, "DCTDecode") || !strcmp(s, "DCT") ||
- !strcmp(s, "RunLengthDecode") || !strcmp(s, "RL") ||
- !strcmp(s, "JBIG2Decode") ||
- !strcmp(s, "JPXDecode"))
- return 1;
- return 0;
+ return
+ s == PDF_NAME(CCITTFaxDecode) || s == PDF_NAME(CCF) ||
+ s == PDF_NAME(DCTDecode) || s == PDF_NAME(DCT) ||
+ s == PDF_NAME(RunLengthDecode) || s == PDF_NAME(RL) ||
+ s == PDF_NAME(JBIG2Decode) ||
+ s == PDF_NAME(JPXDecode);
}
static int filter_implies_image(fz_context *ctx, pdf_obj *o)
{
- if (!o)
- return 0;
if (pdf_is_name(ctx, o))
- return is_image_filter(pdf_to_name(ctx, o));
+ return is_image_filter(o);
+ if (pdf_is_array(ctx, o))
+ {
+ int i, len;
+ len = pdf_array_len(ctx, o);
+ for (i = 0; i < len; i++)
+ if (is_image_filter(pdf_array_get(ctx, o, i)))
+ return 1;
+ }
+ return 0;
+}
+
+static int is_jpx_filter(fz_context *ctx, pdf_obj *o)
+{
+ if (o == PDF_NAME(JPXDecode))
+ return 1;
if (pdf_is_array(ctx, o))
{
int i, len;
len = pdf_array_len(ctx, o);
for (i = 0; i < len; i++)
- if (is_image_filter(pdf_to_name(ctx, pdf_array_get(ctx, o, i))))
+ if (pdf_array_get(ctx, o, i) == PDF_NAME(JPXDecode))
return 1;
}
return 0;
@@ -1874,6 +1886,15 @@ static int is_font_stream(fz_context *ctx, pdf_obj *obj)
return 0;
}
+static int is_jpx_stream(fz_context *ctx, pdf_obj *obj)
+{
+ pdf_obj *o;
+ if (o = pdf_dict_get(ctx, obj, PDF_NAME(Filter)), is_jpx_filter(ctx, o))
+ return 1;
+ return 0;
+}
+
+
static int is_xml_metadata(fz_context *ctx, pdf_obj *obj)
{
if (pdf_name_eq(ctx, pdf_dict_get(ctx, obj, PDF_NAME(Type)), PDF_NAME(Metadata)))
@@ -1950,6 +1971,8 @@ static void writeobject(fz_context *ctx, pdf_document *doc, pdf_write_state *opt
do_deflate = 1, do_expand = 0;
if (is_xml_metadata(ctx, obj))
do_deflate = 0, do_expand = 0;
+ if (is_jpx_stream(ctx, obj))
+ do_deflate = 0, do_expand = 0;
if (do_expand)
expandstream(ctx, doc, opts, obj, num, gen, do_deflate);
else