Merge branch 'fix_bug_2800' into 'master'
Fix libtiff 4.0.8 regression when reading LZW-compressed strips with scanline API See merge request libtiff/libtiff!31
This commit is contained in:
commit
7bad03e938
@ -71,6 +71,9 @@
|
||||
/* Define to 1 if you have the `lfind' function. */
|
||||
#undef HAVE_LFIND
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the `mmap' function. */
|
||||
#undef HAVE_MMAP
|
||||
|
||||
|
@ -133,6 +133,7 @@ typedef struct {
|
||||
long dec_restart; /* restart count */
|
||||
#ifdef LZW_CHECKEOS
|
||||
uint64 dec_bitsleft; /* available bits in raw data */
|
||||
tmsize_t old_tif_rawcc; /* value of tif_rawcc at the end of the previous TIFLZWDecode() call */
|
||||
#endif
|
||||
decodeFunc dec_decode; /* regular or backwards compatible */
|
||||
code_t* dec_codep; /* current recognized code */
|
||||
@ -318,6 +319,7 @@ LZWPreDecode(TIFF* tif, uint16 s)
|
||||
sp->dec_nbitsmask = MAXCODE(BITS_MIN);
|
||||
#ifdef LZW_CHECKEOS
|
||||
sp->dec_bitsleft = 0;
|
||||
sp->old_tif_rawcc = 0;
|
||||
#endif
|
||||
sp->dec_free_entp = sp->dec_codetab + CODE_FIRST;
|
||||
/*
|
||||
@ -425,7 +427,7 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
|
||||
|
||||
bp = (unsigned char *)tif->tif_rawcp;
|
||||
#ifdef LZW_CHECKEOS
|
||||
sp->dec_bitsleft = (((uint64)tif->tif_rawcc) << 3);
|
||||
sp->dec_bitsleft += (((uint64)tif->tif_rawcc - sp->old_tif_rawcc) << 3);
|
||||
#endif
|
||||
nbits = sp->lzw_nbits;
|
||||
nextdata = sp->lzw_nextdata;
|
||||
@ -553,6 +555,9 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
|
||||
|
||||
tif->tif_rawcc -= (tmsize_t)( (uint8*) bp - tif->tif_rawcp );
|
||||
tif->tif_rawcp = (uint8*) bp;
|
||||
#ifdef LZW_CHECKEOS
|
||||
sp->old_tif_rawcc = tif->tif_rawcc;
|
||||
#endif
|
||||
sp->lzw_nbits = (unsigned short) nbits;
|
||||
sp->lzw_nextdata = nextdata;
|
||||
sp->lzw_nextbits = nextbits;
|
||||
@ -656,7 +661,7 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
|
||||
|
||||
bp = (unsigned char *)tif->tif_rawcp;
|
||||
#ifdef LZW_CHECKEOS
|
||||
sp->dec_bitsleft = (((uint64)tif->tif_rawcc) << 3);
|
||||
sp->dec_bitsleft += (((uint64)tif->tif_rawcc - sp->old_tif_rawcc) << 3);
|
||||
#endif
|
||||
nbits = sp->lzw_nbits;
|
||||
nextdata = sp->lzw_nextdata;
|
||||
@ -774,6 +779,9 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
|
||||
|
||||
tif->tif_rawcc -= (tmsize_t)( (uint8*) bp - tif->tif_rawcp );
|
||||
tif->tif_rawcp = (uint8*) bp;
|
||||
#ifdef LZW_CHECKEOS
|
||||
sp->old_tif_rawcc = tif->tif_rawcc;
|
||||
#endif
|
||||
sp->lzw_nbits = (unsigned short)nbits;
|
||||
sp->lzw_nextdata = nextdata;
|
||||
sp->lzw_nextbits = nextbits;
|
||||
|
@ -44,6 +44,7 @@ set(TESTSCRIPTS
|
||||
tiffcp-logluv.sh
|
||||
tiffcp-thumbnail.sh
|
||||
tiffcp-lzw-compat.sh
|
||||
tiffcp-lzw-scanline-decode.sh
|
||||
tiffdump.sh
|
||||
tiffinfo.sh
|
||||
tiffcp-split.sh
|
||||
@ -120,7 +121,8 @@ set(TIFFIMAGES
|
||||
images/rgb-3c-16b.tiff
|
||||
images/rgb-3c-8b.tiff
|
||||
images/quad-tile.jpg.tiff
|
||||
images/quad-lzw-compat.tiff)
|
||||
images/quad-lzw-compat.tiff
|
||||
images/lzw-single-strip.tiff)
|
||||
|
||||
set(BMPIMAGES
|
||||
images/palette-1c-8b.bmp
|
||||
@ -335,6 +337,7 @@ add_convert_test(tiffcp g32d "-c g3:2d" "images/miniswhite-1c-1b.ti
|
||||
add_convert_test(tiffcp g32dfill "-c g3:2d:fill" "images/miniswhite-1c-1b.tiff" FALSE)
|
||||
add_convert_test(tiffcp g4 "-c g4" "images/miniswhite-1c-1b.tiff" FALSE)
|
||||
add_convert_test(tiffcp none "-c none" "images/quad-lzw-compat.tiff" FALSE)
|
||||
add_convert_test(tiffcp noner1 "-c none -r 1" "images/lzw-single-strip.tiff" FALSE)
|
||||
add_convert_test_multi(tiffcp tiffcp "" logluv "-c none" "-c sgilog" ""
|
||||
"images/logluv-3c-16b.tiff" FALSE)
|
||||
add_convert_test_multi(tiffcp thumbnail "" thumbnail "g3:1d" "" ""
|
||||
|
@ -79,6 +79,7 @@ TESTSCRIPTS = \
|
||||
tiffcp-logluv.sh \
|
||||
tiffcp-thumbnail.sh \
|
||||
tiffcp-lzw-compat.sh \
|
||||
tiffcp-lzw-scanline-decode.sh \
|
||||
tiffdump.sh \
|
||||
tiffinfo.sh \
|
||||
tiffcp-split.sh \
|
||||
@ -158,7 +159,8 @@ TIFFIMAGES = \
|
||||
images/rgb-3c-16b.tiff \
|
||||
images/rgb-3c-8b.tiff \
|
||||
images/quad-tile.jpg.tiff \
|
||||
images/quad-lzw-compat.tiff
|
||||
images/quad-lzw-compat.tiff \
|
||||
images/lzw-single-strip.tiff
|
||||
|
||||
PNMIMAGES = \
|
||||
images/minisblack-1c-8b.pgm \
|
||||
|
@ -41,6 +41,7 @@ IMG_RGB_3C_16B=${IMAGES}/rgb-3c-16b.tiff
|
||||
IMG_RGB_3C_8B=${IMAGES}/rgb-3c-8b.tiff
|
||||
IMG_MINISBLACK_2C_8B_ALPHA=${IMAGES}/minisblack-2c-8b-alpha.tiff
|
||||
IMG_QUAD_LZW_COMPAT=${IMAGES}/quad-lzw-compat.tiff
|
||||
IMG_LZW_SINGLE_STROP=${IMAGES}/lzw-single-strip.tiff
|
||||
|
||||
IMG_MINISWHITE_1C_1B_PBM=${IMAGES}/miniswhite-1c-1b.pbm
|
||||
IMG_MINISBLACK_1C_8B_PGM=${IMAGES}/minisblack-1c-8b.pgm
|
||||
|
BIN
test/images/lzw-single-strip.tiff
Normal file
BIN
test/images/lzw-single-strip.tiff
Normal file
Binary file not shown.
6
test/tiffcp-lzw-scanline-decode.sh
Executable file
6
test/tiffcp-lzw-scanline-decode.sh
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Basic sanity check for tiffcp with LZW decompression
|
||||
#
|
||||
. ${srcdir:-.}/common.sh
|
||||
f_test_convert "${TIFFCP} -c none -r 1" "${IMG_LZW_SINGLE_STROP}" "o-tiffcp-lzw-scanline-decode.tiff"
|
Loading…
Reference in New Issue
Block a user