From 833c6a84bd7edf531b6074e9e13dd5ae57f21f12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20B=C3=BCnzli?= Date: Fri, 3 Jan 2014 12:02:08 +0100 Subject: show jbig2dec warnings/errors in stderr This helps debugging issues with JBIG2 images. Conflicts: source/fitz/filter-jbig2.c --- source/fitz/filter-jbig2.c | 15 +++++++++++++-- 1 file 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) -- cgit v1.2.3