summaryrefslogtreecommitdiff
path: root/source/fitz/load-tiff.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-06-11 16:01:53 +0100
committerRobin Watts <robin.watts@artifex.com>2016-06-14 12:53:03 +0100
commitc0759acc6e5bd8167ab4983fc51eb1212da6a216 (patch)
treeb46f6a783f5e6dd8e09fc7c0ca318ac34b88fb81 /source/fitz/load-tiff.c
parent60edbbde3a384401cbefe338e55e7a5f52cad5f4 (diff)
downloadmupdf-c0759acc6e5bd8167ab4983fc51eb1212da6a216.tar.xz
Update TIFF LZW decode.
TIFF 5.0 uses a slightly laxer set of rules for TIFF decode. Specifically, when we hit the maximum code, we are not required to send a clear code immediately, but it can overrrun. We don't bother storing codes > 12 bits, because they can never be used. This avoids the need to extend the table.
Diffstat (limited to 'source/fitz/load-tiff.c')
-rw-r--r--source/fitz/load-tiff.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/source/fitz/load-tiff.c b/source/fitz/load-tiff.c
index f7661a8d..3df9f7c8 100644
--- a/source/fitz/load-tiff.c
+++ b/source/fitz/load-tiff.c
@@ -155,9 +155,9 @@ fz_decode_tiff_packbits(fz_context *ctx, struct tiff *tiff, fz_stream *chain, un
}
static void
-fz_decode_tiff_lzw(fz_context *ctx, struct tiff *tiff, fz_stream *chain, unsigned char *wp, int wlen)
+fz_decode_tiff_lzw(fz_context *ctx, struct tiff *tiff, fz_stream *chain, unsigned char *wp, int wlen, int old_tiff)
{
- fz_stream *stm = fz_open_lzwd(ctx, chain, 1, 9, 0);
+ fz_stream *stm = fz_open_lzwd(ctx, chain, old_tiff ? 0 : 1, 9, old_tiff ? 1 : 0, old_tiff);
fz_read(ctx, stm, wp, wlen);
fz_drop_stream(ctx, stm);
}
@@ -457,7 +457,7 @@ fz_decode_tiff_strips(fz_context *ctx, struct tiff *tiff)
fz_decode_tiff_fax(ctx, tiff, 4, stm, wp, wlen);
break;
case 5:
- fz_decode_tiff_lzw(ctx, tiff, stm, wp, wlen);
+ fz_decode_tiff_lzw(ctx, tiff, stm, wp, wlen, (rp[0] == 0 && rp[1] & 1));
break;
case 6:
fz_warn(ctx, "deprecated JPEG in TIFF compression not fully supported");