diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/fitz/filter-jbig2.c | 15 |
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) |