From b2c820e11bdec61fc38dde8d7d0fd3b35fc7ccfa Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Sun, 30 Apr 2017 03:38:10 +0800 Subject: tiff: Set k>0 for CCITT fax group 3 1D/2D compression. Previously, if a TIFF file was encoded using CCITT fax group 3 compression and mixing 1D and 2D codes, the fax decoder was not instructed to parse the 1D/2D indication bit after EOL. This caused later issues when parsing the succeeding 1D/2D code, e.g. resulting in the decoder encountering a negative 1D code and returning with an error. Setting k>0 means the 1D/2D indication bit is parsed. The CCITT fax group 3 specification recommends setting k based on the vertical resolution. MuPDF's fax decoder depends only on if k is <0, 0 or >0, not its value (as recommended by the PDF specification). Therefore it is not necessary to use the vertical resolution to determine a particular value for k. --- source/fitz/load-tiff.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/fitz/load-tiff.c b/source/fitz/load-tiff.c index 4bc8be75..c8449dc9 100644 --- a/source/fitz/load-tiff.c +++ b/source/fitz/load-tiff.c @@ -332,7 +332,9 @@ tiff_decode_data(fz_context *ctx, struct tiff *tiff, unsigned char *rp, unsigned case 3: case 4: stm = fz_open_faxd(ctx, stm, - tiff->compression == 4 ? -1 : 0, + tiff->compression == 4 ? -1 : + tiff->compression == 2 ? 0 : + tiff->g3opts & 1, 0, tiff->compression == 2, tiff->imagewidth, -- cgit v1.2.3