workaround for OJPEG 'Fractional scanline' bug in tif_getimage.c

This commit is contained in:
Joris Van Damme 2007-03-08 03:07:42 +00:00
parent f547b2607b
commit 7cff22e59c
3 changed files with 48 additions and 33 deletions

View File

@ -1,3 +1,11 @@
2007-03-07 Joris Van Damme <joris.at.lebbeke@skynet.be>
* libtiff/tif_getimage.c: workaround for 'Fractional scanline' error reading
OJPEG images with rowsperstrip that is not a multiple of vertical subsampling
factor. This bug is mentioned in:
http://bugzilla.remotesensing.org/show_bug.cgi?id=1390
http://www.asmail.be/msg0054766825.html
2007-03-07 Joris Van Damme <joris.at.lebbeke@skynet.be>
* libtiff/tif_win32.c: made inclusion of windows.h unconditional

View File

@ -1,4 +1,4 @@
/* $Id: tif_getimage.c,v 1.62 2007-03-08 02:18:31 joris Exp $ */
/* $Id: tif_getimage.c,v 1.63 2007-03-08 03:07:42 joris Exp $ */
/*
* Copyright (c) 1991-1997 Sam Leffler
@ -431,6 +431,8 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024])
photoTag, img->photometric);
return (0);
}
img->SubsamplingHor = 1;
img->SubsamplingVer = 1;
img->Map = NULL;
img->BWmap = NULL;
img->PALmap = NULL;
@ -800,7 +802,7 @@ gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
{
TIFF* tif = img->tif;
tileContigRoutine put = img->put.contig;
uint32 row, y, nrow, rowstoread;
uint32 row, y, nrow, nrowsub, rowstoread;
uint32 pos;
unsigned char* buf;
uint32 rowsperstrip;
@ -832,10 +834,13 @@ gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
{
rowstoread = rowsperstrip - (row + img->row_offset) % rowsperstrip;
nrow = (row + rowstoread > h ? h - row : rowstoread);
nrowsub = nrow;
if ((nrowsub%(img->SubsamplingVer))!=0)
nrowsub+=img->SubsamplingVer-nrowsub%(img->SubsamplingVer);
if (TIFFReadEncodedStrip(tif,
TIFFComputeStrip(tif,row+img->row_offset, 0),
buf,
((row + img->row_offset)%rowsperstrip + nrow) * scanline) < 0
((row + img->row_offset)%rowsperstrip + nrowsub) * scanline) < 0
&& img->stoponerr)
{
ret = 0;
@ -2431,7 +2436,6 @@ PickContigCase(TIFFRGBAImage* img)
{
if (initYCbCrConversion(img)!=0)
{
uint16 hs, vs;
/*
* The 6.0 spec says that subsampling must be
* one of 1, 2, or 4, and that vertical subsampling
@ -2441,8 +2445,8 @@ PickContigCase(TIFFRGBAImage* img)
* Joris: added support for the [1,2] case, nonetheless, to accomodate
* some OJPEG files
*/
TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, &hs, &vs);
switch ((hs<<4)|vs) {
TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, &img->SubsamplingHor, &img->SubsamplingVer);
switch ((img->SubsamplingHor<<4)|img->SubsamplingVer) {
case 0x44:
img->put.contig = putcontig8bitYCbCr44tile;
break;

View File

@ -1,4 +1,4 @@
/* $Id: tiffio.h,v 1.55 2006-06-30 19:08:03 dron Exp $ */
/* $Id: tiffio.h,v 1.56 2007-03-08 03:07:42 joris Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -188,38 +188,41 @@ typedef void (*tileSeparateRoutine)
* RGBA-reader state.
*/
struct _TIFFRGBAImage {
TIFF* tif; /* image handle */
int stoponerr; /* stop on read error */
int isContig; /* data is packed/separate */
int alpha; /* type of alpha data present */
uint32 width; /* image width */
uint32 height; /* image height */
uint16 bitspersample; /* image bits/sample */
uint16 samplesperpixel; /* image samples/pixel */
uint16 orientation; /* image orientation */
uint16 req_orientation; /* requested orientation */
uint16 photometric; /* image photometric interp */
uint16* redcmap; /* colormap pallete */
uint16* greencmap;
uint16* bluecmap;
/* get image data routine */
int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32);
TIFF* tif; /* image handle */
int stoponerr; /* stop on read error */
int isContig; /* data is packed/separate */
int alpha; /* type of alpha data present */
uint32 width; /* image width */
uint32 height; /* image height */
uint16 SubsamplingHor; /* subsampling factors */
uint16 SubsamplingVer;
uint16 bitspersample; /* image bits/sample */
uint16 samplesperpixel; /* image samples/pixel */
uint16 orientation; /* image orientation */
uint16 req_orientation; /* requested orientation */
uint16 photometric; /* image photometric interp */
uint16* redcmap; /* colormap pallete */
uint16* greencmap;
uint16* bluecmap;
/* get image data routine */
int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32);
/* put decoded strip/tile */
union {
void (*any)(TIFFRGBAImage*);
tileContigRoutine contig;
tileSeparateRoutine separate;
} put; /* put decoded strip/tile */
TIFFRGBValue* Map; /* sample mapping array */
uint32** BWmap; /* black&white map */
uint32** PALmap; /* palette image map */
TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */
TIFFCIELabToRGB* cielab; /* CIE L*a*b conversion state */
tileContigRoutine contig;
tileSeparateRoutine separate;
} put;
TIFFRGBValue* Map; /* sample mapping array */
uint32** BWmap; /* black&white map */
uint32** PALmap; /* palette image map */
TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */
TIFFCIELabToRGB* cielab; /* CIE L*a*b conversion state */
uint8* UaToAa; /* Unassociated alpha to associated alpha convertion LUT */
uint8* Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */
int row_offset;
int col_offset;
int row_offset;
int col_offset;
};
/*