summaryrefslogtreecommitdiff
path: root/source/fitz/filter-jbig2.c
diff options
context:
space:
mode:
authorSimon Bünzli <zeniko@gmail.com>2014-01-03 12:02:08 +0100
committerRobin Watts <robin.watts@artifex.com>2014-01-06 13:13:40 +0000
commit833c6a84bd7edf531b6074e9e13dd5ae57f21f12 (patch)
treee7c12e014570ce7f865a8a719ae8b0da7d9ad71c /source/fitz/filter-jbig2.c
parentc3a3103636764aa14ec97c340681ff6cbc63d10d (diff)
downloadmupdf-833c6a84bd7edf531b6074e9e13dd5ae57f21f12.tar.xz
show jbig2dec warnings/errors in stderr
This helps debugging issues with JBIG2 images. Conflicts: source/fitz/filter-jbig2.c
Diffstat (limited to 'source/fitz/filter-jbig2.c')
-rw-r--r--source/fitz/filter-jbig2.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/source/fitz/filter-jbig2.c b/source/fitz/filter-jbig2.c
index d3d5c5fa..2771d070 100644
--- a/source/fitz/filter-jbig2.c
+++ b/source/fitz/filter-jbig2.c
@@ -70,6 +70,17 @@ rebind_jbig2d(fz_stream *s)
return state->chain;
}
+static int
+error_callback(void *data, const char *msg, Jbig2Severity severity, int32_t seg_idx)
+{
+ fz_context *ctx = data;
+ if (severity == JBIG2_SEVERITY_FATAL)
+ fz_warn(ctx, "jbig2dec error: %s (segment %d)", msg, seg_idx);
+ else if (severity == JBIG2_SEVERITY_WARNING)
+ fz_warn(ctx, "jbig2dec warning: %s (segment %d)", msg, seg_idx);
+ return 0;
+}
+
fz_stream *
fz_open_jbig2d(fz_stream *chain, fz_buffer *globals)
{
@@ -84,7 +95,7 @@ fz_open_jbig2d(fz_stream *chain, fz_buffer *globals)
state->ctx = NULL;
state->gctx = NULL;
state->chain = chain;
- state->ctx = jbig2_ctx_new(NULL, JBIG2_OPTIONS_EMBEDDED, NULL, NULL, NULL);
+ state->ctx = jbig2_ctx_new(NULL, JBIG2_OPTIONS_EMBEDDED, NULL, error_callback, ctx);
state->page = NULL;
state->idx = 0;
@@ -92,7 +103,7 @@ fz_open_jbig2d(fz_stream *chain, fz_buffer *globals)
{
jbig2_data_in(state->ctx, globals->data, globals->len);
state->gctx = jbig2_make_global_ctx(state->ctx);
- state->ctx = jbig2_ctx_new(NULL, JBIG2_OPTIONS_EMBEDDED, state->gctx, NULL, NULL);
+ state->ctx = jbig2_ctx_new(NULL, JBIG2_OPTIONS_EMBEDDED, state->gctx, error_callback, ctx);
}
}
fz_catch(ctx)