From 5339040ebdf88f5e8df912586962bcd2fcda0333 Mon Sep 17 00:00:00 2001 From: "Sven M. Hallberg" <pesco@khjk.org> Date: Fri, 20 Dec 2019 15:53:50 +0100 Subject: [PATCH] support TIFF predictor for BitsPerComponent = 8 --- pdf.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pdf.c b/pdf.c index 72b33ef..6a74caf 100644 --- a/pdf.c +++ b/pdf.c @@ -622,7 +622,8 @@ depred_png(struct predictor *pred, uint8_t *inp, size_t sz) if (x == pred->rowsz) { done = h_parse_chunk(pred->sp, pred->buf, pred->rowsz); pred->c = pred->x = 0; - pred->predfun = NULL; + if (pred->num != 2) /* support for 8-bpc TIFF */ + pred->predfun = NULL; } } @@ -660,10 +661,21 @@ FlateDecode(HAllocator *mm__, HCountedArray *parms, HBytes b, HParser *p) if (pred.num == 1) depredict = depred_none; else { - // XXX add TIFF predictor if (pred.num >= 10 && pred.num <= 15) depredict = depred_png; - else { + else if (pred.num == 2) { + /* for 8-bpc TIFF pred. 2, we can reuse PNG Sub */ + if (pred.bpc == 8) { + pred.predfun = pp_sub; /* predict left */ + depredict = depred_png; + } else { + // XXX add general TIFF predictor (bpc != 8) + fprintf(stderr, "FlateDecode: /Predictor %d " + "not supported for /BitsPerComponent %d\n", + pred.num, pred.bpc); + return NULL; + } + } else { fprintf(stderr, "FlateDecode: /Predictor %d" " not supported\n", pred.num); return NULL; -- GitLab