diff options
Diffstat (limited to 'libtiff')
32 files changed, 903 insertions, 918 deletions
diff --git a/libtiff/tif_color.c b/libtiff/tif_color.c index ac35d08d..026a534e 100644 --- a/libtiff/tif_color.c +++ b/libtiff/tif_color.c @@ -1,4 +1,4 @@ -/* $Id: tif_color.c,v 1.13 2007-03-28 02:50:41 joris Exp $ */ +/* $Id: tif_color.c,v 1.14 2007-03-31 01:04:52 joris Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler diff --git a/libtiff/tif_compress.c b/libtiff/tif_compress.c index 83f810fc..f1015190 100644 --- a/libtiff/tif_compress.c +++ b/libtiff/tif_compress.c @@ -1,4 +1,4 @@ -/* $Id: tif_compress.c,v 1.13 2007-02-24 15:03:50 dron Exp $ */ +/* $Id: tif_compress.c,v 1.14 2007-03-31 01:04:52 joris Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -49,21 +49,21 @@ TIFFNoEncode(TIFF* tif, const char* method) } int -_TIFFNoRowEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) +_TIFFNoRowEncode(TIFF* tif, uint8* pp, uint64 cc, uint16 s) { (void) pp; (void) cc; (void) s; return (TIFFNoEncode(tif, "scanline")); } int -_TIFFNoStripEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) +_TIFFNoStripEncode(TIFF* tif, uint8* pp, uint64 cc, uint16 s) { (void) pp; (void) cc; (void) s; return (TIFFNoEncode(tif, "strip")); } int -_TIFFNoTileEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) +_TIFFNoTileEncode(TIFF* tif, uint8* pp, uint64 cc, uint16 s) { (void) pp; (void) cc; (void) s; return (TIFFNoEncode(tif, "tile")); @@ -86,21 +86,21 @@ TIFFNoDecode(TIFF* tif, const char* method) } int -_TIFFNoRowDecode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) +_TIFFNoRowDecode(TIFF* tif, uint8* pp, uint64 cc, uint16 s) { (void) pp; (void) cc; (void) s; return (TIFFNoDecode(tif, "scanline")); } int -_TIFFNoStripDecode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) +_TIFFNoStripDecode(TIFF* tif, uint8* pp, uint64 cc, uint16 s) { (void) pp; (void) cc; (void) s; return (TIFFNoDecode(tif, "strip")); } int -_TIFFNoTileDecode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) +_TIFFNoTileDecode(TIFF* tif, uint8* pp, uint64 cc, uint16 s) { (void) pp; (void) cc; (void) s; return (TIFFNoDecode(tif, "tile")); @@ -116,7 +116,7 @@ _TIFFNoSeek(TIFF* tif, uint32 off) } int -_TIFFNoPreCode(TIFF* tif, tsample_t s) +_TIFFNoPreCode(TIFF* tif, uint16 s) { (void) tif; (void) s; return (1); @@ -131,16 +131,16 @@ _TIFFSetDefaultCompressionState(TIFF* tif) tif->tif_decodestatus = TRUE; tif->tif_setupdecode = _TIFFtrue; tif->tif_predecode = _TIFFNoPreCode; - tif->tif_decoderow = _TIFFNoRowDecode; + tif->tif_decoderow = _TIFFNoRowDecode; tif->tif_decodestrip = _TIFFNoStripDecode; - tif->tif_decodetile = _TIFFNoTileDecode; + tif->tif_decodetile = _TIFFNoTileDecode; tif->tif_encodestatus = TRUE; tif->tif_setupencode = _TIFFtrue; tif->tif_preencode = _TIFFNoPreCode; tif->tif_postencode = _TIFFtrue; tif->tif_encoderow = _TIFFNoRowEncode; tif->tif_encodestrip = _TIFFNoStripEncode; - tif->tif_encodetile = _TIFFNoTileEncode; + tif->tif_encodetile = _TIFFNoTileEncode; tif->tif_close = _TIFFvoid; tif->tif_seek = _TIFFNoSeek; tif->tif_cleanup = _TIFFvoid; diff --git a/libtiff/tif_dir.c b/libtiff/tif_dir.c index 04b24963..f2d0c7f9 100644 --- a/libtiff/tif_dir.c +++ b/libtiff/tif_dir.c @@ -1,4 +1,4 @@ -/* $Id: tif_dir.c,v 1.77 2007-03-24 11:48:17 joris Exp $ */ +/* $Id: tif_dir.c,v 1.78 2007-03-31 01:04:52 joris Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -167,7 +167,7 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap) if (td->td_bitspersample == 16) tif->tif_postdecode = _TIFFSwab16BitData; else if (td->td_bitspersample == 24) - tif->tif_postdecode = _TIFFSwab24BitData; + tif->tif_postdecode = _TIFFSwab24BitData; else if (td->td_bitspersample == 32) tif->tif_postdecode = _TIFFSwab32BitData; else if (td->td_bitspersample == 64) @@ -342,13 +342,13 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap) /* Try to fix up the SWAB function for complex data. */ if( td->td_sampleformat == SAMPLEFORMAT_COMPLEXINT && td->td_bitspersample == 32 - && tif->tif_postdecode == _TIFFSwab32BitData ) - tif->tif_postdecode = _TIFFSwab16BitData; + && tif->tif_postdecode == _TIFFSwab32BitData ) + tif->tif_postdecode = _TIFFSwab16BitData; else if( (td->td_sampleformat == SAMPLEFORMAT_COMPLEXINT || td->td_sampleformat == SAMPLEFORMAT_COMPLEXIEEEFP) && td->td_bitspersample == 64 - && tif->tif_postdecode == _TIFFSwab64BitData ) - tif->tif_postdecode = _TIFFSwab32BitData; + && tif->tif_postdecode == _TIFFSwab64BitData ) + tif->tif_postdecode = _TIFFSwab32BitData; break; case TIFFTAG_IMAGEDEPTH: td->td_imagedepth = va_arg(ap, uint32); @@ -750,11 +750,11 @@ _TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap) break; case TIFFTAG_STRIPOFFSETS: case TIFFTAG_TILEOFFSETS: - *va_arg(ap, uint32**) = td->td_stripoffset; - break; + *va_arg(ap, uint64**) = td->td_stripoffset; + break; case TIFFTAG_STRIPBYTECOUNTS: case TIFFTAG_TILEBYTECOUNTS: - *va_arg(ap, uint32**) = td->td_stripbytecount; + *va_arg(ap, uint64**) = td->td_stripbytecount; break; case TIFFTAG_MATTEING: *va_arg(ap, uint16*) = @@ -1035,7 +1035,7 @@ TIFFCreateDirectory(TIFF* tif) tif->tif_nextdiroff = 0; tif->tif_curoff = 0; tif->tif_row = (uint32) -1; - tif->tif_curstrip = (tstrip_t) -1; + tif->tif_curstrip = (uint32) -1; return 0; } @@ -1063,14 +1063,14 @@ TIFFDefaultDirectory(TIFF* tif) td->td_tilewidth = 0; td->td_tilelength = 0; td->td_tiledepth = 1; - td->td_stripbytecountsorted = 1; /* Our own arrays always sorted. */ + td->td_stripbytecountsorted = 1; /* Our own arrays always sorted. */ td->td_resolutionunit = RESUNIT_INCH; td->td_sampleformat = SAMPLEFORMAT_UINT; td->td_imagedepth = 1; td->td_ycbcrsubsampling[0] = 2; td->td_ycbcrsubsampling[1] = 2; td->td_ycbcrpositioning = YCBCRPOSITION_CENTERED; - tif->tif_postdecode = _TIFFNoPostDecode; + tif->tif_postdecode = _TIFFNoPostDecode; tif->tif_foundfield = NULL; tif->tif_tagmethods.vsetfield = _TIFFVSetField; tif->tif_tagmethods.vgetfield = _TIFFVGetField; @@ -1394,7 +1394,7 @@ TIFFUnlinkDirectory(TIFF* tif, tdir_t dirn) tif->tif_nextdiroff = 0; /* next write must be at end */ tif->tif_curoff = 0; tif->tif_row = (uint32) -1; - tif->tif_curstrip = (tstrip_t) -1; + tif->tif_curstrip = (uint32) -1; return (1); } diff --git a/libtiff/tif_dir.h b/libtiff/tif_dir.h index bc4392d3..8635e825 100644 --- a/libtiff/tif_dir.h +++ b/libtiff/tif_dir.h @@ -1,4 +1,4 @@ -/* $Id: tif_dir.h,v 1.32 2007-03-22 02:08:21 joris Exp $ */ +/* $Id: tif_dir.h,v 1.33 2007-03-31 01:04:52 joris Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -64,11 +64,11 @@ typedef struct { /* even though the name is misleading, td_stripsperimage is the number * of striles (=strips or tiles) per plane, and td_nstrips the total * number of striles */ - tstrile_t td_stripsperimage; - tstrile_t td_nstrips; /* size of offset & bytecount arrays */ + uint32 td_stripsperimage; + uint32 td_nstrips; /* size of offset & bytecount arrays */ uint64* td_stripoffset; uint64* td_stripbytecount; - int td_stripbytecountsorted; /* is the bytecount array sorted ascending? */ + int td_stripbytecountsorted; /* is the bytecount array sorted ascending? */ uint16 td_nsubifd; uint32* td_subifd; /* YCbCr parameters */ diff --git a/libtiff/tif_dirinfo.c b/libtiff/tif_dirinfo.c index 93381b59..153a7b7a 100644 --- a/libtiff/tif_dirinfo.c +++ b/libtiff/tif_dirinfo.c @@ -1,4 +1,4 @@ -/* $Id: tif_dirinfo.c,v 1.67 2007-03-28 02:50:41 joris Exp $ */ +/* $Id: tif_dirinfo.c,v 1.68 2007-03-31 01:04:52 joris Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -692,7 +692,7 @@ _TIFFDataSize(TIFFDataType type) TIFFDataType _TIFFSampleToTagType(TIFF* tif) { - uint32 bps = TIFFhowmany8(tif->tif_dir.td_bitspersample); ddd + uint32 bps = TIFFhowmany8_32(tif->tif_dir.td_bitspersample); switch (tif->tif_dir.td_sampleformat) { case SAMPLEFORMAT_IEEEFP: diff --git a/libtiff/tif_dirread.c b/libtiff/tif_dirread.c index 47e3d7c7..84985458 100644 --- a/libtiff/tif_dirread.c +++ b/libtiff/tif_dirread.c @@ -1,4 +1,4 @@ -/* $Id: tif_dirread.c,v 1.101 2007-03-28 02:50:41 joris Exp $ */ +/* $Id: tif_dirread.c,v 1.102 2007-03-31 01:04:52 joris Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -73,7 +73,7 @@ static int TIFFFetchPerSampleShorts(TIFF*, TIFFDirEntry*, uint16*); static int TIFFFetchPerSampleLongs(TIFF*, TIFFDirEntry*, uint32*); static int TIFFFetchPerSampleAnys(TIFF*, TIFFDirEntry*, double*); static int TIFFFetchShortArray(TIFF*, TIFFDirEntry*, uint16*); -static int TIFFFetchStripThing(TIFF*, TIFFDirEntry*, long, uint64**); +static int TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, uint32 nstrips, uint64** lpp); static int TIFFFetchRefBlackWhite(TIFF*, TIFFDirEntry*); static int TIFFFetchSubjectDistance(TIFF*, TIFFDirEntry*); static float TIFFFetchFloat(TIFF*, TIFFDirEntry*); @@ -1328,7 +1328,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEn double* mb; uint32 n; if (tif->tif_flags&TIFF_SWAB) - TIFFSwabArrayOfLong((uint32*)origdata,count); + TIFFSwabArrayOfLong((uint32*)origdata,count); TIFFCvtIEEEFloatToNative(tif,count,(float*)origdata); ma=(float*)origdata; mb=(double*)data; @@ -1904,13 +1904,13 @@ TIFFReadDirectory(TIFF* tif) * Setup appropriate structures (by strip or by tile) */ if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) { - tif->tif_dir.td_nstrips = TIFFNumberOfStrips(tif); ddd + tif->tif_dir.td_nstrips = TIFFNumberOfStrips(tif); tif->tif_dir.td_tilewidth = tif->tif_dir.td_imagewidth; tif->tif_dir.td_tilelength = tif->tif_dir.td_rowsperstrip; tif->tif_dir.td_tiledepth = tif->tif_dir.td_imagedepth; tif->tif_flags &= ~TIFF_ISTILED; } else { - tif->tif_dir.td_nstrips = TIFFNumberOfTiles(tif); + tif->tif_dir.td_nstrips = TIFFNumberOfTiles(tif); tif->tif_flags |= TIFF_ISTILED; } if (!tif->tif_dir.td_nstrips) { @@ -1997,12 +1997,12 @@ TIFFReadDirectory(TIFF* tif) break; case TIFFTAG_STRIPOFFSETS: case TIFFTAG_TILEOFFSETS: - if (!TIFFFetchStripThing(tif,dp,tif->tif_dir.td_nstrips,&tif->tif_dir.td_stripoffset)) + if (!TIFFFetchStripThing(tif,dp,tif->tif_dir.td_nstrips,&tif->tif_dir.td_stripoffset)) goto bad; break; case TIFFTAG_STRIPBYTECOUNTS: case TIFFTAG_TILEBYTECOUNTS: - if (!TIFFFetchStripThing(tif,dp,tif->tif_dir.td_nstrips,&tif->tif_dir.td_stripbytecount)) + if (!TIFFFetchStripThing(tif,dp,tif->tif_dir.td_nstrips,&tif->tif_dir.td_stripbytecount)) goto bad; break; case TIFFTAG_COLORMAP: @@ -2158,7 +2158,7 @@ TIFFReadDirectory(TIFF* tif) if ((tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG && tif->tif_dir.td_nstrips > 1) || (tif->tif_dir.td_planarconfig == PLANARCONFIG_SEPARATE && - tif->tif_dir.td_nstrips != tif->tif_dir.td_samplesperpixel)) { + tif->tif_dir.td_nstrips != tif->tif_dir.td_samplesperpixel)) { MissingRequired(tif, "StripByteCounts"); goto bad; } @@ -2209,7 +2209,7 @@ TIFFReadDirectory(TIFF* tif) && tif->tif_dir.td_compression == COMPRESSION_NONE && tif->tif_dir.td_stripbytecount[0] != tif->tif_dir.td_stripbytecount[1] && tif->tif_dir.td_stripbytecount[0] != 0 - && tif->tif_dir.td_stripbytecount[1] != 0 ) { + && tif->tif_dir.td_stripbytecount[1] != 0 ) { /* * XXX: Some vendors fill StripByteCount array with * absolutely wrong values (it can be equal to @@ -2241,7 +2241,7 @@ TIFFReadDirectory(TIFF* tif) * function in tif_write.c. */ if (tif->tif_dir.td_nstrips > 1) { - tstrip_t strip; + uint32 strip; tif->tif_dir.td_stripbytecountsorted = 1; for (strip = 1; strip < tif->tif_dir.td_nstrips; strip++) { @@ -2264,7 +2264,7 @@ TIFFReadDirectory(TIFF* tif) * side effect, however, is that the RowsPerStrip tag * value may be changed. */ - if (tif->tif_dir.td_nstrips == 1 && tif->tif_dir.td_compression == COMPRESSION_NONE && + if (tif->tif_dir.td_nstrips == 1 && tif->tif_dir.td_compression == COMPRESSION_NONE && (tif->tif_flags & (TIFF_STRIPCHOP|TIFF_ISTILED)) == TIFF_STRIPCHOP) ChopUpSingleUncompressedStrip(tif); @@ -2272,12 +2272,12 @@ TIFFReadDirectory(TIFF* tif) * Reinitialize i/o since we are starting on a new directory. */ tif->tif_row = (uint32) -1; - tif->tif_curstrip = (tstrip_t) -1; + tif->tif_curstrip = (uint32) -1; tif->tif_col = (uint32) -1; - tif->tif_curtile = (ttile_t) -1; - tif->tif_tilesize = (tsize_t) -1; + tif->tif_curtile = (uint32) -1; + tif->tif_tilesize = (uint64) -1; - tif->tif_scanlinesize = TIFFScanlineSize(tif); ddd + tif->tif_scanlinesize = TIFFScanlineSize(tif); if (!tif->tif_scanlinesize) { TIFFErrorExt(tif->tif_clientdata, module, "Cannot handle zero scanline size"); @@ -2285,7 +2285,7 @@ TIFFReadDirectory(TIFF* tif) } if (isTiled(tif)) { - tif->tif_tilesize = TIFFTileSize(tif); ddd + tif->tif_tilesize = TIFFTileSize(tif); if (!tif->tif_tilesize) { TIFFErrorExt(tif->tif_clientdata, module, "Cannot handle zero tile size"); @@ -2478,8 +2478,6 @@ TIFFReadEXIFDirectory(TIFF* tif, toff_t diroff) exifFieldInfoCount); } -/* PODD */ - static int EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) { @@ -2544,12 +2542,12 @@ EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) if (td->td_stripoffset[strip]+td->td_stripbytecount[strip] > filesize) td->td_stripbytecount[strip] = filesize - td->td_stripoffset[strip]; } else if (isTiled(tif)) { - uint32 bytespertile = TIFFTileSize(tif); ddd + uint64 bytespertile = TIFFTileSize(tif); for (strip = 0; strip < td->td_nstrips; strip++) td->td_stripbytecount[strip] = bytespertile; } else { - uint32 rowbytes = TIFFScanlineSize(tif); ddd + uint64 rowbytes = TIFFScanlineSize(tif); uint32 rowsperstrip = td->td_imagelength/td->td_stripsperimage; for (strip = 0; strip < td->td_nstrips; strip++) td->td_stripbytecount[strip] = rowbytes * rowsperstrip; @@ -2931,20 +2929,20 @@ TIFFFetchData(TIFF* tif, TIFFDirEntry* dir, char* cp) switch (dir->common.tdir_type) { case TIFF_SHORT: case TIFF_SSHORT: - TIFFSwabArrayOfShort((uint16*) cp, count); + TIFFSwabArrayOfShort((uint16*) cp, count); ddd break; case TIFF_LONG: case TIFF_SLONG: case TIFF_FLOAT: case TIFF_IFD: - TIFFSwabArrayOfLong((uint32*) cp, count); + TIFFSwabArrayOfLong((uint32*) cp, count); ddd break; case TIFF_RATIONAL: case TIFF_SRATIONAL: - TIFFSwabArrayOfLong((uint32*) cp, 2*count); + TIFFSwabArrayOfLong((uint32*) cp, 2*count); ddd break; case TIFF_DOUBLE: - TIFFSwabArrayOfDouble((double*) cp, count); + TIFFSwabArrayOfDouble((double*) cp, count); ddd break; case TIFF_LONG8: case TIFF_SLONG8: @@ -3693,7 +3691,7 @@ TIFFFetchPerSampleAnys(TIFF* tif, TIFFDirEntry* dir, double* pl) * While this routine says "strips", in fact it's also used for tiles. */ static int -TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, long nstrips, uint64** lpp) +TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, uint32 nstrips, uint64** lpp) { static const char module[] = "TIFFFetchStripThing"; enum TIFFReadDirEntryErr err; @@ -3788,7 +3786,10 @@ ChopUpSingleUncompressedStrip(TIFF* tif) uint64 bytecount = td->td_stripbytecount[0]; uint64 offset = td->td_stripoffset[0]; uint64 rowbytes = TIFFVTileSize(tif, 1), stripbytes; - tstrip_t strip, nstrips, rowsperstrip; + uint32 strip; + uint64 nstrips64; + uint32 nstrips32; + uint32 rowsperstrip; uint64* newcounts; uint64* newoffsets; @@ -3811,13 +3812,14 @@ ChopUpSingleUncompressedStrip(TIFF* tif) */ if (rowsperstrip >= td->td_rowsperstrip) return; - nstrips = (tstrip_t) TIFFhowmany(bytecount, stripbytes); ddd - if( nstrips == 0 ) /* something is wonky, do nothing. */ + nstrips64 = TIFFhowmany_64(bytecount, stripbytes); + if ((nstrips64==0)||(nstrips64>0xFFFFFFFF)) /* something is wonky, do nothing. */ return; + nstrips32 = (uint32)nstrips64; - newcounts = (uint64*) _TIFFCheckMalloc(tif, nstrips, sizeof (uint64), + newcounts = (uint64*) _TIFFCheckMalloc(tif, nstrips32, sizeof (uint64), "for chopped \"StripByteCounts\" array"); - newoffsets = (uint64*) _TIFFCheckMalloc(tif, nstrips, sizeof (uint64), + newoffsets = (uint64*) _TIFFCheckMalloc(tif, nstrips32, sizeof (uint64), "for chopped \"StripOffsets\" array"); if (newcounts == NULL || newoffsets == NULL) { /* @@ -3834,7 +3836,7 @@ ChopUpSingleUncompressedStrip(TIFF* tif) * Fill the strip information arrays with new bytecounts and offsets * that reflect the broken-up format. */ - for (strip = 0; strip < nstrips; strip++) { + for (strip = 0; strip < nstrips32; strip++) { if (stripbytes > bytecount) stripbytes = bytecount; newcounts[strip] = stripbytes; @@ -3845,7 +3847,7 @@ ChopUpSingleUncompressedStrip(TIFF* tif) /* * Replace old single strip info with multi-strip info. */ - td->td_stripsperimage = td->td_nstrips = nstrips; + td->td_stripsperimage = td->td_nstrips = nstrips32; TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip); _TIFFfree(td->td_stripbytecount); diff --git a/libtiff/tif_dirwrite.c b/libtiff/tif_dirwrite.c index 63267344..c4cb8dcf 100644 --- a/libtiff/tif_dirwrite.c +++ b/libtiff/tif_dirwrite.c @@ -1,4 +1,4 @@ -/* $Id: tif_dirwrite.c,v 1.39 2007-03-22 02:08:21 joris Exp $ */ +/* $Id: tif_dirwrite.c,v 1.40 2007-03-31 01:04:52 joris Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -223,8 +223,8 @@ _TIFFWriteDirectory(TIFF* tif, int done) dir->tdir_tag = (uint16) tag; dir->tdir_type = (uint16) TIFF_LONG; - dir->tdir_count = (uint32) td->td_nstrips; - if (!TIFFWriteLongArray(tif, dir, td->td_stripoffset)) + dir->tdir_count = (uint32) td->td_nstrips; ddd + if (!TIFFWriteLongArray(tif, dir, td->td_stripoffset)) ddd goto bad; break; case FIELD_STRIPBYTECOUNTS: @@ -241,7 +241,7 @@ _TIFFWriteDirectory(TIFF* tif, int done) dir->tdir_tag = (uint16) tag; dir->tdir_type = (uint16) TIFF_LONG; - dir->tdir_count = (uint32) td->td_nstrips; + dir->tdir_count = (uint32) td->td_nstrips; ddd if (!TIFFWriteLongArray(tif, dir, td->td_stripbytecount)) goto bad; break; @@ -374,8 +374,8 @@ _TIFFWriteDirectory(TIFF* tif, int done) * byte-swap indirect data. */ for (dir = (TIFFDirEntry*) data; dircount; dir++, dircount--) { - TIFFSwabArrayOfShort(&dir->tdir_tag, 2); - TIFFSwabArrayOfLong(&dir->tdir_count, 2); + TIFFSwabArrayOfShort(&dir->tdir_tag, 2); ddd + TIFFSwabArrayOfLong(&dir->tdir_count, 2); ddd } dircount = (uint16) nfields; TIFFSwabShort(&dircount); @@ -535,7 +535,7 @@ _TIFFWriteCustomDirectory(TIFF* tif, toff_t *pdiroff) */ for (dir = (TIFFDirEntry*) data; dircount; dir++, dircount--) { TIFFSwabArrayOfShort(&dir->tdir_tag, 2); - TIFFSwabArrayOfLong(&dir->tdir_count, 2); + TIFFSwabArrayOfLong(&dir->tdir_count, 2); ddd } dircount = (uint16) nfields; TIFFSwabShort(&dircount); @@ -1201,14 +1201,14 @@ TIFFWriteData(TIFF* tif, TIFFDirEntry* dir, char* cp) case TIFF_LONG: case TIFF_SLONG: case TIFF_FLOAT: - TIFFSwabArrayOfLong((uint32*) cp, dir->tdir_count); + TIFFSwabArrayOfLong((uint32*) cp, dir->tdir_count); ddd break; case TIFF_RATIONAL: case TIFF_SRATIONAL: - TIFFSwabArrayOfLong((uint32*) cp, 2*dir->tdir_count); + TIFFSwabArrayOfLong((uint32*) cp, 2*dir->tdir_count); ddd break; case TIFF_DOUBLE: - TIFFSwabArrayOfDouble((double*) cp, dir->tdir_count); + TIFFSwabArrayOfDouble((double*) cp, dir->tdir_count); ddd break; } } diff --git a/libtiff/tif_dumpmode.c b/libtiff/tif_dumpmode.c index 5106567f..3fc413f6 100644 --- a/libtiff/tif_dumpmode.c +++ b/libtiff/tif_dumpmode.c @@ -1,4 +1,4 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dumpmode.c,v 1.5 2006-03-25 03:09:24 joris Exp $ */ +/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dumpmode.c,v 1.6 2007-03-31 01:04:52 joris Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -35,18 +35,18 @@ * Encode a hunk of pixels. */ static int -DumpModeEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) +DumpModeEncode(TIFF* tif, uint8* pp, uint64 cc, uint16 s) { (void) s; while (cc > 0) { - tsize_t n; + uint64 n; n = cc; if (tif->tif_rawcc + n > tif->tif_rawdatasize) n = tif->tif_rawdatasize - tif->tif_rawcc; assert( n > 0 ); - + /* * Avoid copy if client has setup raw * data buffer to avoid extra copy. @@ -68,13 +68,13 @@ DumpModeEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) * Decode a hunk of pixels. */ static int -DumpModeDecode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) +DumpModeDecode(TIFF* tif, uint8* buf, uint64 cc, uint16 s) { (void) s; - if (tif->tif_rawcc < cc) { + if (tif->tif_rawcc < cc) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "DumpModeDecode: Not enough data for scanline %d", - tif->tif_row); + "DumpModeDecode: Not enough data for scanline %lud", + (unsigned long) tif->tif_row); return (0); } /* diff --git a/libtiff/tif_fax3.c b/libtiff/tif_fax3.c index 28d5a33d..1ca47566 100644 --- a/libtiff/tif_fax3.c +++ b/libtiff/tif_fax3.c @@ -1,4 +1,4 @@ -/* $Id: tif_fax3.c,v 1.45 2007-03-28 21:47:01 fwarmerdam Exp $ */ +/* $Id: tif_fax3.c,v 1.46 2007-03-31 01:04:52 joris Exp $ */ /* * Copyright (c) 1990-1997 Sam Leffler @@ -126,6 +126,7 @@ typedef struct { /* * Load any state that may be changed during decoding. */ + ddd #define CACHE_STATE(tif, sp) do { \ BitAcc = sp->data; \ BitsAvail = sp->bit; \ @@ -136,6 +137,7 @@ typedef struct { /* * Save state possibly changed during decoding. */ + ddd #define UNCACHE_STATE(tif, sp) do { \ sp->bit = BitsAvail; \ sp->data = BitAcc; \ @@ -148,7 +150,7 @@ typedef struct { * Setup state for decoding a strip. */ static int -Fax3PreDecode(TIFF* tif, tsample_t s) +Fax3PreDecode(TIFF* tif, uint16 s) { Fax3CodecState* sp = DecoderState(tif); @@ -230,7 +232,7 @@ Fax3PrematureEOF(const char* module, TIFF* tif, uint32 line, uint32 a0) * Decode the requested amount of G3 1D-encoded data. */ static int -Fax3Decode1D(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) +Fax3Decode1D(TIFF* tif, tidata_t buf, tsize_t occ, uint16 s) { DECLARE_STATE(tif, sp, "Fax3Decode1D"); @@ -269,7 +271,7 @@ Fax3Decode1D(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) * Decode the requested amount of G3 2D-encoded data. */ static int -Fax3Decode2D(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) +Fax3Decode2D(TIFF* tif, tidata_t buf, tsize_t occ, uint16 s) { DECLARE_STATE_2D(tif, sp, "Fax3Decode2D"); int is1D; /* current line is 1d/2d-encoded */ @@ -477,7 +479,7 @@ Fax3SetupState(TIFF* tif) * Calculate the scanline/tile widths. */ if (isTiled(tif)) { - rowbytes = TIFFTileRowSize(tif); + rowbytes = TIFFTileRowSize(tif); ddd rowpixels = td->td_tilewidth; } else { rowbytes = TIFFScanlineSize(tif); ddd @@ -506,9 +508,9 @@ Fax3SetupState(TIFF* tif) dsp->refruns = NULL; if (td->td_compression == COMPRESSION_CCITTFAX3 && is2DEncoding(dsp)) { /* NB: default is 1D routine */ - tif->tif_decoderow = Fax3Decode2D; - tif->tif_decodestrip = Fax3Decode2D; - tif->tif_decodetile = Fax3Decode2D; + tif->tif_decoderow = Fax3Decode2D; ddd + tif->tif_decodestrip = Fax3Decode2D; ddd + tif->tif_decodetile = Fax3Decode2D; ddd } if (needsRefLine) { /* 2d encoding */ @@ -537,6 +539,7 @@ Fax3SetupState(TIFF* tif) * CCITT Group 3 FAX Encoding. */ + ddd #define Fax3FlushBits(tif, sp) { \ if ((tif)->tif_rawcc >= (tif)->tif_rawdatasize) \ (void) TIFFFlushData1(tif); \ @@ -544,6 +547,7 @@ Fax3SetupState(TIFF* tif) (tif)->tif_rawcc++; \ (sp)->data = 0, (sp)->bit = 8; \ } +ddd #define _FlushBits(tif) { \ if ((tif)->tif_rawcc >= (tif)->tif_rawdatasize) \ (void) TIFFFlushData1(tif); \ @@ -686,7 +690,7 @@ Fax3PutEOL(TIFF* tif) * Reset encoding state at the start of a strip. */ static int -Fax3PreEncode(TIFF* tif, tsample_t s) +Fax3PreEncode(TIFF* tif, uint16 s) { Fax3CodecState* sp = EncoderState(tif); @@ -1007,7 +1011,7 @@ Fax3Encode2DRow(TIFF* tif, unsigned char* bp, unsigned char* rp, uint32 bits) * Encode a buffer of pixels. */ static int -Fax3Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +Fax3Encode(TIFF* tif, tidata_t bp, tsize_t cc, uint16 s) { Fax3CodecState* sp = EncoderState(tif); @@ -1350,15 +1354,15 @@ InitCCITTFax3(TIFF* tif) */ tif->tif_setupdecode = Fax3SetupState; tif->tif_predecode = Fax3PreDecode; - tif->tif_decoderow = Fax3Decode1D; - tif->tif_decodestrip = Fax3Decode1D; - tif->tif_decodetile = Fax3Decode1D; + tif->tif_decoderow = Fax3Decode1D; ddd + tif->tif_decodestrip = Fax3Decode1D; ddd + tif->tif_decodetile = Fax3Decode1D; ddd tif->tif_setupencode = Fax3SetupState; tif->tif_preencode = Fax3PreEncode; tif->tif_postencode = Fax3PostEncode; - tif->tif_encoderow = Fax3Encode; - tif->tif_encodestrip = Fax3Encode; - tif->tif_encodetile = Fax3Encode; + tif->tif_encoderow = Fax3Encode; ddd + tif->tif_encodestrip = Fax3Encode; ddd + tif->tif_encodetile = Fax3Encode; ddd tif->tif_close = Fax3Close; tif->tif_cleanup = Fax3Cleanup; @@ -1390,7 +1394,7 @@ TIFFInitCCITTFax3(TIFF* tif, int scheme) * Decode the requested amount of G4-encoded data. */ static int -Fax4Decode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) +Fax4Decode(TIFF* tif, tidata_t buf, tsize_t occ, uint16 s) { DECLARE_STATE_2D(tif, sp, "Fax4Decode"); @@ -1438,7 +1442,7 @@ Fax4Decode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) * Encode the requested amount of data. */ static int -Fax4Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +Fax4Encode(TIFF* tif, tidata_t bp, tsize_t cc, uint16 s) { Fax3CodecState *sp = EncoderState(tif); @@ -1473,12 +1477,12 @@ TIFFInitCCITTFax4(TIFF* tif, int scheme) if (InitCCITTFax3(tif)) { /* reuse G3 support */ _TIFFMergeFieldInfo(tif, fax4FieldInfo, N(fax4FieldInfo)); - tif->tif_decoderow = Fax4Decode; - tif->tif_decodestrip = Fax4Decode; - tif->tif_decodetile = Fax4Decode; - tif->tif_encoderow = Fax4Encode; - tif->tif_encodestrip = Fax4Encode; - tif->tif_encodetile = Fax4Encode; + tif->tif_decoderow = Fax4Decode; ddd + tif->tif_decodestrip = Fax4Decode; ddd + tif->tif_decodetile = Fax4Decode; ddd + tif->tif_encoderow = Fax4Encode; ddd + tif->tif_encodestrip = Fax4Encode; ddd + tif->tif_encodetile = Fax4Encode; ddd tif->tif_postencode = Fax4PostEncode; /* * Suppress RTC at the end of each strip. @@ -1497,7 +1501,7 @@ TIFFInitCCITTFax4(TIFF* tif, int scheme) * Decode the requested amount of RLE-encoded data. */ static int -Fax3DecodeRLE(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) +Fax3DecodeRLE(TIFF* tif, tidata_t buf, tsize_t occ, uint16 s) { DECLARE_STATE(tif, sp, "Fax3DecodeRLE"); int mode = sp->b.mode; @@ -1546,9 +1550,9 @@ TIFFInitCCITTRLE(TIFF* tif, int scheme) { (void) scheme; if (InitCCITTFax3(tif)) { /* reuse G3 support */ - tif->tif_decoderow = Fax3DecodeRLE; - tif->tif_decodestrip = Fax3DecodeRLE; - tif->tif_decodetile = Fax3DecodeRLE; + tif->tif_decoderow = Fax3DecodeRLE; ddd + tif->tif_decodestrip = Fax3DecodeRLE; ddd + tif->tif_decodetile = Fax3DecodeRLE; ddd /* * Suppress RTC+EOLs when encoding and byte-align data. */ @@ -1563,9 +1567,9 @@ TIFFInitCCITTRLEW(TIFF* tif, int scheme) { (void) scheme; if (InitCCITTFax3(tif)) { /* reuse G3 support */ - tif->tif_decoderow = Fax3DecodeRLE; - tif->tif_decodestrip = Fax3DecodeRLE; - tif->tif_decodetile = Fax3DecodeRLE; + tif->tif_decoderow = Fax3DecodeRLE; ddd + tif->tif_decodestrip = Fax3DecodeRLE; ddd + tif->tif_decodetile = Fax3DecodeRLE; ddd /* * Suppress RTC+EOLs when encoding and word-align data. */ diff --git a/libtiff/tif_getimage.c b/libtiff/tif_getimage.c index ef825483..c6d6e09d 100644 --- a/libtiff/tif_getimage.c +++ b/libtiff/tif_getimage.c @@ -1,4 +1,4 @@ -/* $Id: tif_getimage.c,v 1.64 2007-03-28 02:50:41 joris Exp $ */ +/* $Id: tif_getimage.c,v 1.65 2007-03-31 01:04:52 joris Exp $ */ /* * Copyright (c) 1991-1997 Sam Leffler @@ -624,7 +624,7 @@ gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) break; } - pos = ((row+img->row_offset) % th) * TIFFTileRowSize(tif); + pos = ((row+img->row_offset) % th) * TIFFTileRowSize(tif); ddd if (col + tw > w) { @@ -749,7 +749,7 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) } } - pos = ((row+img->row_offset) % th) * TIFFTileRowSize(tif); + pos = ((row+img->row_offset) % th) * TIFFTileRowSize(tif); ddd if (col + tw > w) { @@ -837,8 +837,8 @@ gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) nrowsub = nrow; if ((nrowsub%(img->SubsamplingVer))!=0) nrowsub+=img->SubsamplingVer-nrowsub%(img->SubsamplingVer); - if (TIFFReadEncodedStrip(tif, - TIFFComputeStrip(tif,row+img->row_offset, 0), + if (TIFFReadEncodedStrip(tif, ddd + TIFFComputeStrip(tif,row+img->row_offset, 0), ddd buf, ((row + img->row_offset)%rowsperstrip + nrowsub) * scanline) < 0 && img->stoponerr) @@ -924,21 +924,21 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) rowstoread = rowsperstrip - (row + img->row_offset) % rowsperstrip; nrow = (row + rowstoread > h ? h - row : rowstoread); offset_row = row + img->row_offset; - if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 0), + if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 0), ddd p0, ((row + img->row_offset)%rowsperstrip + nrow) * scanline) < 0 && img->stoponerr) { ret = 0; break; } - if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 1), + if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 1), ddd p1, ((row + img->row_offset)%rowsperstrip + nrow) * scanline) < 0 && img->stoponerr) { ret = 0; break; } - if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 2), + if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 2), ddd p2, ((row + img->row_offset)%rowsperstrip + nrow) * scanline) < 0 && img->stoponerr) { @@ -947,7 +947,7 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) } if (alpha) { - if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 3), + if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 3), ddd pa, ((row + img->row_offset)%rowsperstrip + nrow) * scanline) < 0 && img->stoponerr) { diff --git a/libtiff/tif_jbig.c b/libtiff/tif_jbig.c index 4fff939c..3994dc0a 100644 --- a/libtiff/tif_jbig.c +++ b/libtiff/tif_jbig.c @@ -1,4 +1,4 @@ -/* $Id: tif_jbig.c,v 1.2 2006-07-04 19:01:47 bfriesen Exp $ */ +/* $Id: tif_jbig.c,v 1.3 2007-03-31 01:04:52 joris Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -75,7 +75,7 @@ static int JBIGSetupDecode(TIFF* tif) return 1; } -static int JBIGDecode(TIFF* tif, tidata_t buffer, tsize_t size, tsample_t s) +static int JBIGDecode(TIFF* tif, tidata_t buffer, tsize_t size, uint16 s) { struct jbg_dec_state decoder; int decodeStatus = 0; @@ -84,13 +84,13 @@ static int JBIGDecode(TIFF* tif, tidata_t buffer, tsize_t size, tsample_t s) if (isFillOrder(tif, tif->tif_dir.td_fillorder)) { - TIFFReverseBits(tif->tif_rawdata, tif->tif_rawdatasize); + TIFFReverseBits(tif->tif_rawdata, tif->tif_rawdatasize); ddd } jbg_dec_init(&decoder); #if defined(HAVE_JBG_NEWLEN) - jbg_newlen(tif->tif_rawdata, tif->tif_rawdatasize); + jbg_newlen(tif->tif_rawdata, tif->tif_rawdatasize); ddd /* * I do not check the return status of jbg_newlen because even if this * function fails it does not necessarily mean that decoding the image @@ -104,7 +104,7 @@ static int JBIGDecode(TIFF* tif, tidata_t buffer, tsize_t size, tsample_t s) #endif /* HAVE_JBG_NEWLEN */ decodeStatus = jbg_dec_in(&decoder, tif->tif_rawdata, - tif->tif_rawdatasize, NULL); + tif->tif_rawdatasize, NULL); ddd if (JBG_EOK != decodeStatus) { TIFFError("JBIG", "Error (%d) decoding: %s", @@ -129,25 +129,25 @@ static int JBIGSetupEncode(TIFF* tif) return 1; } -static int JBIGCopyEncodedData(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) +static int JBIGCopyEncodedData(TIFF* tif, tidata_t pp, tsize_t cc, uint16 s) { (void) s; while (cc > 0) { tsize_t n = cc; - if (tif->tif_rawcc + n > tif->tif_rawdatasize) + if (tif->tif_rawcc + n > tif->tif_rawdatasize) ddd { - n = tif->tif_rawdatasize - tif->tif_rawcc; + n = tif->tif_rawdatasize - tif->tif_rawcc; ddd } assert(n > 0); _TIFFmemcpy(tif->tif_rawcp, pp, n); tif->tif_rawcp += n; - tif->tif_rawcc += n; + tif->tif_rawcc += n; ddd pp += n; cc -= n; - if (tif->tif_rawcc >= tif->tif_rawdatasize && + if (tif->tif_rawcc >= tif->tif_rawdatasize && ddd !TIFFFlushData1(tif)) { return (-1); @@ -163,13 +163,13 @@ static void JBIGOutputBie(unsigned char* buffer, size_t len, void *userData) if (isFillOrder(tif, tif->tif_dir.td_fillorder)) { - TIFFReverseBits(buffer, len); + TIFFReverseBits(buffer, len); ddd } JBIGCopyEncodedData(tif, buffer, len, 0); } -static int JBIGEncode(TIFF* tif, tidata_t buffer, tsize_t size, tsample_t s) +static int JBIGEncode(TIFF* tif, tidata_t buffer, tsize_t size, uint16 s) { TIFFDirectory* dir = &tif->tif_dir; struct jbg_enc_state encoder; @@ -347,10 +347,10 @@ int TIFFInitJBIG(TIFF* tif, int scheme) /* Setup the function pointers for encode, decode, and cleanup. */ tif->tif_setupdecode = JBIGSetupDecode; - tif->tif_decodestrip = JBIGDecode; + tif->tif_decodestrip = JBIGDecode; ddd tif->tif_setupencode = JBIGSetupEncode; - tif->tif_encodestrip = JBIGEncode; + tif->tif_encodestrip = JBIGEncode; ddd tif->tif_cleanup = JBIGCleanup; diff --git a/libtiff/tif_jpeg.c b/libtiff/tif_jpeg.c index 60df30b1..1cf3f21e 100644 --- a/libtiff/tif_jpeg.c +++ b/libtiff/tif_jpeg.c @@ -1,4 +1,4 @@ -/* $Id: tif_jpeg.c,v 1.51 2007-03-28 02:50:41 joris Exp $ */ +/* $Id: tif_jpeg.c,v 1.52 2007-03-31 01:04:52 joris Exp $ */ /* * Copyright (c) 1994-1997 Sam Leffler @@ -44,8 +44,8 @@ */ #include <setjmp.h> -int TIFFFillStrip(TIFF*, tstrip_t); -int TIFFFillTile(TIFF*, ttile_t); +int TIFFFillStrip(TIFF* tif, uint32 strip); +int TIFFFillTile(TIFF* tif, uint32 tile); /* We undefine FAR to avoid conflict with JPEG definition */ @@ -171,10 +171,10 @@ typedef struct { #define JState(tif) ((JPEGState*)(tif)->tif_data) -static int JPEGDecode(TIFF*, tidata_t, tsize_t, tsample_t); -static int JPEGDecodeRaw(TIFF*, tidata_t, tsize_t, tsample_t); -static int JPEGEncode(TIFF*, tidata_t, tsize_t, tsample_t); -static int JPEGEncodeRaw(TIFF*, tidata_t, tsize_t, tsample_t); +static int JPEGDecode(TIFF*, tidata_t, tsize_t, uint16); +static int JPEGDecodeRaw(TIFF*, tidata_t, tsize_t, uint16); +static int JPEGEncode(TIFF*, tidata_t, tsize_t, uint16); +static int JPEGEncodeRaw(TIFF*, tidata_t, tsize_t, uint16); static int JPEGInitializeLibJPEG( TIFF * tif, int force_encode, int force_decode ); @@ -400,7 +400,7 @@ std_init_destination(j_compress_ptr cinfo) TIFF* tif = sp->tif; sp->dest.next_output_byte = (JOCTET*) tif->tif_rawdata; - sp->dest.free_in_buffer = (size_t) tif->tif_rawdatasize; + sp->dest.free_in_buffer = (size_t) tif->tif_rawdatasize; ddd } static boolean @@ -410,10 +410,10 @@ std_empty_output_buffer(j_compress_ptr cinfo) TIFF* tif = sp->tif; /* the entire buffer has been filled */ - tif->tif_rawcc = tif->tif_rawdatasize; + tif->tif_rawcc = tif->tif_rawdatasize; ddd TIFFFlushData1(tif); sp->dest.next_output_byte = (JOCTET*) tif->tif_rawdata; - sp->dest.free_in_buffer = (size_t) tif->tif_rawdatasize; + sp->dest.free_in_buffer = (size_t) tif->tif_rawdatasize; ddd return (TRUE); } @@ -425,8 +425,8 @@ std_term_destination(j_compress_ptr cinfo) TIFF* tif = sp->tif; tif->tif_rawcp = (tidata_t) sp->dest.next_output_byte; - tif->tif_rawcc = - tif->tif_rawdatasize - (tsize_t) sp->dest.free_in_buffer; + tif->tif_rawcc = ddd + tif->tif_rawdatasize - (tsize_t) sp->dest.free_in_buffer; ddd /* NB: libtiff does the final buffer flush */ } @@ -517,7 +517,7 @@ std_init_source(j_decompress_ptr cinfo) TIFF* tif = sp->tif; sp->src.next_input_byte = (const JOCTET*) tif->tif_rawdata; - sp->src.bytes_in_buffer = (size_t) tif->tif_rawcc; + sp->src.bytes_in_buffer = (size_t) tif->tif_rawcc; ddd } static boolean @@ -671,7 +671,7 @@ JPEGSetupDecode(TIFF* tif) /* Set up for reading normal data */ TIFFjpeg_data_src(sp, tif); - tif->tif_postdecode = _TIFFNoPostDecode; /* override byte swapping */ + tif->tif_postdecode = _TIFFNoPostDecode; /* override byte swapping */ return (1); } @@ -679,7 +679,7 @@ JPEGSetupDecode(TIFF* tif) * Set up for decoding a strip or tile. */ static int -JPEGPreDecode(TIFF* tif, tsample_t s) +JPEGPreDecode(TIFF* tif, uint16 s) { JPEGState *sp = JState(tif); TIFFDirectory *td = &tif->tif_dir; @@ -709,7 +709,7 @@ JPEGPreDecode(TIFF* tif, tsample_t s) if (isTiled(tif)) { segment_width = td->td_tilewidth; segment_height = td->td_tilelength; - sp->bytesperline = TIFFTileRowSize(tif); + sp->bytesperline = TIFFTileRowSize(tif); ddd } else { if (segment_height > td->td_rowsperstrip) segment_height = td->td_rowsperstrip; @@ -850,15 +850,15 @@ JPEGPreDecode(TIFF* tif, tsample_t s) if (downsampled_output) { /* Need to use raw-data interface to libjpeg */ sp->cinfo.d.raw_data_out = TRUE; - tif->tif_decoderow = JPEGDecodeRaw; - tif->tif_decodestrip = JPEGDecodeRaw; - tif->tif_decodetile = JPEGDecodeRaw; + tif->tif_decoderow = JPEGDecodeRaw; ddd + tif->tif_decodestrip = JPEGDecodeRaw; ddd + tif->tif_decodetile = JPEGDecodeRaw; ddd } else { /* Use normal interface to libjpeg */ sp->cinfo.d.raw_data_out = FALSE; - tif->tif_decoderow = JPEGDecode; - tif->tif_decodestrip = JPEGDecode; - tif->tif_decodetile = JPEGDecode; + tif->tif_decoderow = JPEGDecode; ddd + tif->tif_decodestrip = JPEGDecode; ddd + tif->tif_decodetile = JPEGDecode; ddd } /* Start JPEG decompressor */ if (!TIFFjpeg_start_decompress(sp)) @@ -878,7 +878,7 @@ JPEGPreDecode(TIFF* tif, tsample_t s) * "Standard" case: returned data is not downsampled. */ /*ARGSUSED*/ static int -JPEGDecode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) +JPEGDecode(TIFF* tif, tidata_t buf, tsize_t cc, uint16 s) { JPEGState *sp = JState(tif); tsize_t nrows; @@ -982,7 +982,7 @@ JPEGDecode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) * Returned data is downsampled per sampling factors. */ /*ARGSUSED*/ static int -JPEGDecodeRaw(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) +JPEGDecodeRaw(TIFF* tif, tidata_t buf, tsize_t cc, uint16 s) { JPEGState *sp = JState(tif); tsize_t nrows; @@ -1291,7 +1291,7 @@ JPEGSetupEncode(TIFF* tif) * Set encoding state at the start of a strip or tile. */ static int -JPEGPreEncode(TIFF* tif, tsample_t s) +JPEGPreEncode(TIFF* tif, uint16 s) { JPEGState *sp = JState(tif); TIFFDirectory *td = &tif->tif_dir; @@ -1307,7 +1307,7 @@ JPEGPreEncode(TIFF* tif, tsample_t s) if (isTiled(tif)) { segment_width = td->td_tilewidth; segment_height = td->td_tilelength; - sp->bytesperline = TIFFTileRowSize(tif); + sp->bytesperline = TIFFTileRowSize(tif); ddd } else { segment_width = td->td_imagewidth; segment_height = td->td_imagelength - tif->tif_row; @@ -1383,15 +1383,15 @@ JPEGPreEncode(TIFF* tif, tsample_t s) if (downsampled_input) { /* Need to use raw-data interface to libjpeg */ sp->cinfo.c.raw_data_in = TRUE; - tif->tif_encoderow = JPEGEncodeRaw; - tif->tif_encodestrip = JPEGEncodeRaw; - tif->tif_encodetile = JPEGEncodeRaw; + tif->tif_encoderow = JPEGEncodeRaw; ddd + tif->tif_encodestrip = JPEGEncodeRaw; ddd + tif->tif_encodetile = JPEGEncodeRaw; ddd } else { /* Use normal interface to libjpeg */ sp->cinfo.c.raw_data_in = FALSE; - tif->tif_encoderow = JPEGEncode; - tif->tif_encodestrip = JPEGEncode; - tif->tif_encodetile = JPEGEncode; + tif->tif_encoderow = JPEGEncode; ddd + tif->tif_encodestrip = JPEGEncode; ddd + tif->tif_encodetile = JPEGEncode; ddd } /* Start JPEG compressor */ if (!TIFFjpeg_start_compress(sp, FALSE)) @@ -1412,7 +1412,7 @@ JPEGPreEncode(TIFF* tif, tsample_t s) * "Standard" case: incoming data is not downsampled. */ static int -JPEGEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) +JPEGEncode(TIFF* tif, tidata_t buf, tsize_t cc, uint16 s) { JPEGState *sp = JState(tif); tsize_t nrows; @@ -1441,7 +1441,7 @@ JPEGEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) * Incoming data is expected to be downsampled per sampling factors. */ static int -JPEGEncodeRaw(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) +JPEGEncodeRaw(TIFF* tif, tidata_t buf, tsize_t cc, uint16 s) { JPEGState *sp = JState(tif); JSAMPLE* inptr; @@ -1965,15 +1965,15 @@ TIFFInitJPEG(TIFF* tif, int scheme) */ tif->tif_setupdecode = JPEGSetupDecode; tif->tif_predecode = JPEGPreDecode; - tif->tif_decoderow = JPEGDecode; - tif->tif_decodestrip = JPEGDecode; - tif->tif_decodetile = JPEGDecode; + tif->tif_decoderow = JPEGDecode; ddd + tif->tif_decodestrip = JPEGDecode; ddd + tif->tif_decodetile = JPEGDecode; ddd tif->tif_setupencode = JPEGSetupEncode; tif->tif_preencode = JPEGPreEncode; tif->tif_postencode = JPEGPostEncode; - tif->tif_encoderow = JPEGEncode; - tif->tif_encodestrip = JPEGEncode; - tif->tif_encodetile = JPEGEncode; + tif->tif_encoderow = JPEGEncode; ddd + tif->tif_encodestrip = JPEGEncode; ddd + tif->tif_encodetile = JPEGEncode; ddd tif->tif_cleanup = JPEGCleanup; sp->defsparent = tif->tif_defstripsize; tif->tif_defstripsize = JPEGDefaultStripSize; diff --git a/libtiff/tif_luv.c b/libtiff/tif_luv.c index f7d3920f..abd0d828 100644 --- a/libtiff/tif_luv.c +++ b/libtiff/tif_luv.c @@ -1,4 +1,4 @@ -/* $Id: tif_luv.c,v 1.18 2007-03-28 02:50:41 joris Exp $ */ +/* $Id: tif_luv.c,v 1.19 2007-03-31 01:04:52 joris Exp $ */ /* * Copyright (c) 1997 Greg Ward Larson @@ -181,7 +181,7 @@ struct logLuvState { * Decode a string of 16-bit gray pixels. */ static int -LogL16Decode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) +LogL16Decode(TIFF* tif, tidata_t op, tsize_t occ, uint16 s) { LogLuvState* sp = DecoderState(tif); int shft, i, npixels; @@ -204,7 +204,7 @@ LogL16Decode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) _TIFFmemset((tdata_t) tp, 0, npixels*sizeof (tp[0])); bp = (unsigned char*) tif->tif_rawcp; - cc = tif->tif_rawcc; + cc = tif->tif_rawcc; ddd /* get each byte string */ for (shft = 2*8; (shft -= 8) >= 0; ) { for (i = 0; i < npixels && cc > 0; ) @@ -224,13 +224,13 @@ LogL16Decode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) "LogL16Decode: Not enough data at row %d (short %d pixels)", tif->tif_row, npixels - i); tif->tif_rawcp = (tidata_t) bp; - tif->tif_rawcc = cc; + tif->tif_rawcc = cc; ddd return (0); } } (*sp->tfunc)(sp, op, npixels); tif->tif_rawcp = (tidata_t) bp; - tif->tif_rawcc = cc; + tif->tif_rawcc = cc; ddd return (1); } @@ -238,7 +238,7 @@ LogL16Decode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) * Decode a string of 24-bit pixels. */ static int -LogLuvDecode24(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) +LogLuvDecode24(TIFF* tif, tidata_t op, tsize_t occ, uint16 s) { LogLuvState* sp = DecoderState(tif); int cc, i, npixels; @@ -258,14 +258,14 @@ LogLuvDecode24(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) } /* copy to array of uint32 */ bp = (unsigned char*) tif->tif_rawcp; - cc = tif->tif_rawcc; + cc = tif->tif_rawcc; ddd for (i = 0; i < npixels && cc > 0; i++) { tp[i] = bp[0] << 16 | bp[1] << 8 | bp[2]; bp += 3; cc -= 3; } tif->tif_rawcp = (tidata_t) bp; - tif->tif_rawcc = cc; + tif->tif_rawcc = cc; ddd if (i != npixels) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "LogLuvDecode24: Not enough data at row %d (short %d pixels)", @@ -280,7 +280,7 @@ LogLuvDecode24(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) * Decode a string of 32-bit pixels. */ static int -LogLuvDecode32(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) +LogLuvDecode32(TIFF* tif, tidata_t op, tsize_t occ, uint16 s) { LogLuvState* sp; int shft, i, npixels; @@ -304,7 +304,7 @@ LogLuvDecode32(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) _TIFFmemset((tdata_t) tp, 0, npixels*sizeof (tp[0])); bp = (unsigned char*) tif->tif_rawcp; - cc = tif->tif_rawcc; + cc = tif->tif_rawcc; ddd /* get each byte string */ for (shft = 4*8; (shft -= 8) >= 0; ) { for (i = 0; i < npixels && cc > 0; ) @@ -324,13 +324,13 @@ LogLuvDecode32(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) "LogLuvDecode32: Not enough data at row %d (short %d pixels)", tif->tif_row, npixels - i); tif->tif_rawcp = (tidata_t) bp; - tif->tif_rawcc = cc; + tif->tif_rawcc = cc; ddd return (0); } } (*sp->tfunc)(sp, op, npixels); tif->tif_rawcp = (tidata_t) bp; - tif->tif_rawcc = cc; + tif->tif_rawcc = cc; ddd return (1); } @@ -340,12 +340,12 @@ LogLuvDecode32(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) * is row by row. */ static int -LogLuvDecodeStrip(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +LogLuvDecodeStrip(TIFF* tif, tidata_t bp, tsize_t cc, uint16 s) { tsize_t rowlen = TIFFScanlineSize(tif); ddd assert(cc%rowlen == 0); - while (cc && (*tif->tif_decoderow)(tif, bp, rowlen, s)) + while (cc && (*tif->tif_decoderow)(tif, bp, rowlen, s)) ddd bp += rowlen, cc -= rowlen; return (cc == 0); } @@ -356,12 +356,12 @@ LogLuvDecodeStrip(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) * is row by row. */ static int -LogLuvDecodeTile(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +LogLuvDecodeTile(TIFF* tif, tidata_t bp, tsize_t cc, uint16 s) { - tsize_t rowlen = TIFFTileRowSize(tif); + tsize_t rowlen = TIFFTileRowSize(tif); ddd assert(cc%rowlen == 0); - while (cc && (*tif->tif_decoderow)(tif, bp, rowlen, s)) + while (cc && (*tif->tif_decoderow)(tif, bp, rowlen, s)) ddd bp += rowlen, cc -= rowlen; return (cc == 0); } @@ -370,7 +370,7 @@ LogLuvDecodeTile(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) * Encode a row of 16-bit pixels. */ static int -LogL16Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +LogL16Encode(TIFF* tif, tidata_t bp, tsize_t cc, uint16 s) { LogLuvState* sp = EncoderState(tif); int shft, i, j, npixels; @@ -392,16 +392,16 @@ LogL16Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) } /* compress each byte string */ op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; + occ = tif->tif_rawdatasize - tif->tif_rawcc; ddd for (shft = 2*8; (shft -= 8) >= 0; ) for (i = 0; i < npixels; i += rc) { if (occ < 4) { tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; + tif->tif_rawcc = tif->tif_rawdatasize - occ; ddd if (!TIFFFlushData1(tif)) return (-1); op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; + occ = tif->tif_rawdatasize - tif->tif_rawcc; ddd } mask = 0xff << shft; /* find next run */ for (beg = i; beg < npixels; beg += rc) { @@ -429,11 +429,11 @@ LogL16Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) if ((j = beg-i) > 127) j = 127; if (occ < j+3) { tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; + tif->tif_rawcc = tif->tif_rawdatasize - occ; ddd if (!TIFFFlushData1(tif)) return (-1); op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; + occ = tif->tif_rawdatasize - tif->tif_rawcc; ddd } *op++ = (tidataval_t) j; occ--; while (j--) { @@ -449,7 +449,7 @@ LogL16Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) rc = 0; } tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; + tif->tif_rawcc = tif->tif_rawdatasize - occ; ddd return (0); } @@ -458,7 +458,7 @@ LogL16Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) * Encode a row of 24-bit pixels. */ static int -LogLuvEncode24(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +LogLuvEncode24(TIFF* tif, tidata_t bp, tsize_t cc, uint16 s) { LogLuvState* sp = EncoderState(tif); int i, npixels, occ; @@ -478,15 +478,15 @@ LogLuvEncode24(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) } /* write out encoded pixels */ op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; + occ = tif->tif_rawdatasize - tif->tif_rawcc; ddd for (i = npixels; i--; ) { if (occ < 3) { tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; + tif->tif_rawcc = tif->tif_rawdatasize - occ; ddd if (!TIFFFlushData1(tif)) return (-1); op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; + occ = tif->tif_rawdatasize - tif->tif_rawcc; ddd } *op++ = (tidataval_t)(*tp >> 16); *op++ = (tidataval_t)(*tp >> 8 & 0xff); @@ -494,7 +494,7 @@ LogLuvEncode24(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) occ -= 3; } tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; + tif->tif_rawcc = tif->tif_rawdatasize - occ; ddd return (0); } @@ -503,7 +503,7 @@ LogLuvEncode24(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) * Encode a row of 32-bit pixels. */ static int -LogLuvEncode32(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +LogLuvEncode32(TIFF* tif, tidata_t bp, tsize_t cc, uint16 s) { LogLuvState* sp = EncoderState(tif); int shft, i, j, npixels; @@ -526,16 +526,16 @@ LogLuvEncode32(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) } /* compress each byte string */ op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; + occ = tif->tif_rawdatasize - tif->tif_rawcc; ddd for (shft = 4*8; (shft -= 8) >= 0; ) for (i = 0; i < npixels; i += rc) { if (occ < 4) { tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; + tif->tif_rawcc = tif->tif_rawdatasize - occ; ddd if (!TIFFFlushData1(tif)) return (-1); op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; + occ = tif->tif_rawdatasize - tif->tif_rawcc; ddd } mask = 0xff << shft; /* find next run */ for (beg = i; beg < npixels; beg += rc) { @@ -563,11 +563,11 @@ LogLuvEncode32(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) if ((j = beg-i) > 127) j = 127; if (occ < j+3) { tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; + tif->tif_rawcc = tif->tif_rawdatasize - occ; ddd if (!TIFFFlushData1(tif)) return (-1); op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; + occ = tif->tif_rawdatasize - tif->tif_rawcc; ddd } *op++ = (tidataval_t) j; occ--; while (j--) { @@ -583,7 +583,7 @@ LogLuvEncode32(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) rc = 0; } tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; + tif->tif_rawcc = tif->tif_rawdatasize - occ; ddd return (0); } @@ -593,12 +593,12 @@ LogLuvEncode32(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) * avoid encoding runs across row boundaries. */ static int -LogLuvEncodeStrip(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +LogLuvEncodeStrip(TIFF* tif, tidata_t bp, tsize_t cc, uint16 s) { tsize_t rowlen = TIFFScanlineSize(tif); ddd assert(cc%rowlen == 0); - while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 0) + while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 0) ddd bp += rowlen, cc -= rowlen; return (cc == 0); } @@ -608,12 +608,12 @@ LogLuvEncodeStrip(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) * avoid encoding runs across row boundaries. */ static int -LogLuvEncodeTile(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +LogLuvEncodeTile(TIFF* tif, tidata_t bp, tsize_t cc, uint16 s) { - tsize_t rowlen = TIFFTileRowSize(tif); + tsize_t rowlen = TIFFTileRowSize(tif); ddd assert(cc%rowlen == 0); - while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 0) + while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 0) ddd bp += rowlen, cc -= rowlen; return (cc == 0); } @@ -1314,13 +1314,13 @@ LogLuvSetupDecode(TIFF* tif) LogLuvState* sp = DecoderState(tif); TIFFDirectory* td = &tif->tif_dir; - tif->tif_postdecode = _TIFFNoPostDecode; + tif->tif_postdecode = _TIFFNoPostDecode; switch (td->td_photometric) { case PHOTOMETRIC_LOGLUV: if (!LogLuvInitState(tif)) break; if (td->td_compression == COMPRESSION_SGILOG24) { - tif->tif_decoderow = LogLuvDecode24; + tif->tif_decoderow = LogLuvDecode24; ddd switch (sp->user_datafmt) { case SGILOGDATAFMT_FLOAT: sp->tfunc = Luv24toXYZ; @@ -1333,7 +1333,7 @@ LogLuvSetupDecode(TIFF* tif) break; } } else { - tif->tif_decoderow = LogLuvDecode32; + tif->tif_decoderow = LogLuvDecode32; ddd switch (sp->user_datafmt) { case SGILOGDATAFMT_FLOAT: sp->tfunc = Luv32toXYZ; @@ -1350,7 +1350,7 @@ LogLuvSetupDecode(TIFF* tif) case PHOTOMETRIC_LOGL: if (!LogL16InitState(tif)) break; - tif->tif_decoderow = LogL16Decode; + tif->tif_decoderow = LogL16Decode; ddd switch (sp->user_datafmt) { case SGILOGDATAFMT_FLOAT: sp->tfunc = L16toY; @@ -1380,7 +1380,7 @@ LogLuvSetupEncode(TIFF* tif) if (!LogLuvInitState(tif)) break; if (td->td_compression == COMPRESSION_SGILOG24) { - tif->tif_encoderow = LogLuvEncode24; + tif->tif_encoderow = LogLuvEncode24; ddd switch (sp->user_datafmt) { case SGILOGDATAFMT_FLOAT: sp->tfunc = Luv24fromXYZ; @@ -1394,7 +1394,7 @@ LogLuvSetupEncode(TIFF* tif) goto notsupported; } } else { - tif->tif_encoderow = LogLuvEncode32; + tif->tif_encoderow = LogLuvEncode32; ddd switch (sp->user_datafmt) { case SGILOGDATAFMT_FLOAT: sp->tfunc = Luv32fromXYZ; @@ -1412,7 +1412,7 @@ LogLuvSetupEncode(TIFF* tif) case PHOTOMETRIC_LOGL: if (!LogL16InitState(tif)) break; - tif->tif_encoderow = LogL16Encode; + tif->tif_encoderow = LogL16Encode; ddd switch (sp->user_datafmt) { case SGILOGDATAFMT_FLOAT: sp->tfunc = L16fromY; @@ -1579,11 +1579,11 @@ TIFFInitSGILog(TIFF* tif, int scheme) * in at setup time. */ tif->tif_setupdecode = LogLuvSetupDecode; - tif->tif_decodestrip = LogLuvDecodeStrip; - tif->tif_decodetile = LogLuvDecodeTile; + tif->tif_decodestrip = LogLuvDecodeStrip; ddd + tif->tif_decodetile = LogLuvDecodeTile; ddd tif->tif_setupencode = LogLuvSetupEncode; - tif->tif_encodestrip = LogLuvEncodeStrip; - tif->tif_encodetile = LogLuvEncodeTile; + tif->tif_encodestrip = LogLuvEncodeStrip; ddd + tif->tif_encodetile = LogLuvEncodeTile; ddd tif->tif_close = LogLuvClose; tif->tif_cleanup = LogLuvCleanup; diff --git a/libtiff/tif_lzw.c b/libtiff/tif_lzw.c index 9fc0179f..050857db 100644 --- a/libtiff/tif_lzw.c +++ b/libtiff/tif_lzw.c @@ -1,4 +1,4 @@ -/* $Id: tif_lzw.c,v 1.29 2006-09-27 22:39:00 fwarmerdam Exp $ */ +/* $Id: tif_lzw.c,v 1.30 2007-03-31 01:04:52 joris Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -125,7 +125,7 @@ typedef struct code_ent { unsigned char firstchar; /* first token of string */ } code_t; -typedef int (*decodeFunc)(TIFF*, tidata_t, tsize_t, tsample_t); +typedef int (*decodeFunc)(TIFF*, tidata_t, tsize_t, uint16); typedef struct { LZWBaseState base; @@ -158,9 +158,9 @@ typedef struct { #define DecoderState(tif) ((LZWCodecState*) LZWState(tif)) #define EncoderState(tif) ((LZWCodecState*) LZWState(tif)) -static int LZWDecode(TIFF*, tidata_t, tsize_t, tsample_t); +static int LZWDecode(TIFF*, tidata_t, tsize_t, uint16); #ifdef LZW_COMPAT -static int LZWDecodeCompat(TIFF*, tidata_t, tsize_t, tsample_t); +static int LZWDecodeCompat(TIFF*, tidata_t, tsize_t, uint16); #endif static void cl_hash(LZWCodecState*); @@ -245,7 +245,7 @@ LZWSetupDecode(TIFF* tif) * Setup state for decoding a strip. */ static int -LZWPreDecode(TIFF* tif, tsample_t s) +LZWPreDecode(TIFF* tif, uint16 s) { LZWCodecState *sp = DecoderState(tif); @@ -269,9 +269,9 @@ LZWPreDecode(TIFF* tif, tsample_t s) * above will call the compatibility routines * through the dec_decode method. */ - tif->tif_decoderow = LZWDecodeCompat; - tif->tif_decodestrip = LZWDecodeCompat; - tif->tif_decodetile = LZWDecodeCompat; + tif->tif_decoderow = LZWDecodeCompat; ddd + tif->tif_decodestrip = LZWDecodeCompat; ddd + tif->tif_decodetile = LZWDecodeCompat; ddd /* * If doing horizontal differencing, must * re-setup the predictor logic since we @@ -300,7 +300,7 @@ LZWPreDecode(TIFF* tif, tsample_t s) sp->dec_restart = 0; sp->dec_nbitsmask = MAXCODE(BITS_MIN); #ifdef LZW_CHECKEOS - sp->dec_bitsleft = tif->tif_rawcc << 3; + sp->dec_bitsleft = tif->tif_rawcc << 3; ddd #endif sp->dec_free_entp = sp->dec_codetab + CODE_FIRST; /* @@ -339,7 +339,7 @@ codeLoop(TIFF* tif) } static int -LZWDecode(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) +LZWDecode(TIFF* tif, tidata_t op0, tsize_t occ0, uint16 s) { LZWCodecState *sp = DecoderState(tif); char *op = (char*) op0; @@ -542,7 +542,7 @@ LZWDecode(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) } static int -LZWDecodeCompat(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) +LZWDecodeCompat(TIFF* tif, tidata_t op0, tsize_t occ0, uint16 s) { LZWCodecState *sp = DecoderState(tif); char *op = (char*) op0; @@ -732,7 +732,7 @@ LZWSetupEncode(TIFF* tif) * Reset encoding state at the start of a strip. */ static int -LZWPreEncode(TIFF* tif, tsample_t s) +LZWPreEncode(TIFF* tif, uint16 s) { LZWCodecState *sp = EncoderState(tif); @@ -755,7 +755,7 @@ LZWPreEncode(TIFF* tif, tsample_t s) * The 4 here insures there is space for 2 max-sized * codes in LZWEncode and LZWPostDecode. */ - sp->enc_rawlimit = tif->tif_rawdata + tif->tif_rawdatasize-1 - 4; + sp->enc_rawlimit = tif->tif_rawdata + tif->tif_rawdatasize-1 - 4; ddd cl_hash(sp); /* clear hash table */ sp->enc_oldcode = (hcode_t) -1; /* generates CODE_CLEAR in LZWEncode */ return (1); @@ -795,7 +795,7 @@ LZWPreEncode(TIFF* tif, tsample_t s) * for the decoder. */ static int -LZWEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +LZWEncode(TIFF* tif, tidata_t bp, tsize_t cc, uint16 s) { register LZWCodecState *sp = EncoderState(tif); register long fcode; @@ -885,7 +885,7 @@ LZWEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) * are at least 4 bytes free--room for 2 codes. */ if (op > limit) { - tif->tif_rawcc = (tsize_t)(op - tif->tif_rawdata); + tif->tif_rawcc = (tsize_t)(op - tif->tif_rawdata); ddd TIFFFlushData1(tif); op = tif->tif_rawdata; } @@ -970,7 +970,7 @@ LZWPostEncode(TIFF* tif) int nbits = sp->lzw_nbits; if (op > sp->enc_rawlimit) { - tif->tif_rawcc = (tsize_t)(op - tif->tif_rawdata); + tif->tif_rawcc = (tsize_t)(op - tif->tif_rawdata); ddd TIFFFlushData1(tif); op = tif->tif_rawdata; } @@ -981,7 +981,7 @@ LZWPostEncode(TIFF* tif) PutNextCode(op, CODE_EOI); if (nextbits > 0) *op++ = (unsigned char)(nextdata << (8-nextbits)); - tif->tif_rawcc = (tsize_t)(op - tif->tif_rawdata); + tif->tif_rawcc = (tsize_t)(op - tif->tif_rawdata); ddd return (1); } @@ -1049,15 +1049,15 @@ TIFFInitLZW(TIFF* tif, int scheme) */ tif->tif_setupdecode = LZWSetupDecode; tif->tif_predecode = LZWPreDecode; - tif->tif_decoderow = LZWDecode; - tif->tif_decodestrip = LZWDecode; - tif->tif_decodetile = LZWDecode; + tif->tif_decoderow = LZWDecode; ddd + tif->tif_decodestrip = LZWDecode; ddd + tif->tif_decodetile = LZWDecode; ddd tif->tif_setupencode = LZWSetupEncode; tif->tif_preencode = LZWPreEncode; tif->tif_postencode = LZWPostEncode; - tif->tif_encoderow = LZWEncode; - tif->tif_encodestrip = LZWEncode; - tif->tif_encodetile = LZWEncode; + tif->tif_encoderow = LZWEncode; ddd + tif->tif_encodestrip = LZWEncode; ddd + tif->tif_encodetile = LZWEncode; ddd tif->tif_cleanup = LZWCleanup; /* * Setup predictor setup. diff --git a/libtiff/tif_next.c b/libtiff/tif_next.c index 14075894..d27a8e13 100644 --- a/libtiff/tif_next.c +++ b/libtiff/tif_next.c @@ -1,4 +1,4 @@ -/* $Id: tif_next.c,v 1.8 2006-10-12 15:00:49 dron Exp $ */ +/* $Id: tif_next.c,v 1.9 2007-03-31 01:04:52 joris Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -46,7 +46,7 @@ #define WHITE ((1<<2)-1) static int -NeXTDecode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) +NeXTDecode(TIFF* tif, tidata_t buf, tsize_t occ, uint16 s) { unsigned char *bp, *op; tsize_t cc; @@ -63,8 +63,8 @@ NeXTDecode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) *op++ = 0xff; bp = (unsigned char *)tif->tif_rawcp; - cc = tif->tif_rawcc; - scanline = tif->tif_scanlinesize; + cc = tif->tif_rawcc; ddd + scanline = tif->tif_scanlinesize; ddd for (row = buf; occ > 0; occ -= scanline, row += scanline) { n = *bp++, cc--; switch (n) { @@ -125,7 +125,7 @@ NeXTDecode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) } } tif->tif_rawcp = (tidata_t) bp; - tif->tif_rawcc = cc; + tif->tif_rawcc = cc; ddd return (1); bad: TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "NeXTDecode: Not enough data for scanline %ld", @@ -137,9 +137,9 @@ int TIFFInitNeXT(TIFF* tif, int scheme) { (void) scheme; - tif->tif_decoderow = NeXTDecode; - tif->tif_decodestrip = NeXTDecode; - tif->tif_decodetile = NeXTDecode; + tif->tif_decoderow = NeXTDecode; ddd + tif->tif_decodestrip = NeXTDecode; ddd + tif->tif_decodetile = NeXTDecode; ddd return (1); } #endif /* NEXT_SUPPORT */ diff --git a/libtiff/tif_ojpeg.c b/libtiff/tif_ojpeg.c index 2b68bc3c..5cf93a1f 100644 --- a/libtiff/tif_ojpeg.c +++ b/libtiff/tif_ojpeg.c @@ -1,4 +1,4 @@ -/* $Id: tif_ojpeg.c,v 1.24 2006-06-03 15:28:33 bfriesen Exp $ */ +/* $Id: tif_ojpeg.c,v 1.25 2007-03-31 01:04:52 joris Exp $ */ /* WARNING: The type of JPEG encapsulation defined by the TIFF Version 6.0 specification is now totally obsolete and deprecated for new applications and @@ -271,7 +271,7 @@ typedef struct { } sos_end[3]; uint8 readheader_done; uint8 writeheader_done; - tsample_t write_cursample; + uint16 write_cursample; tstrile_t write_curstrile; uint8 libjpeg_session_active; uint8 libjpeg_jpeg_query_style; @@ -315,22 +315,22 @@ static int OJPEGVSetField(TIFF* tif, ttag_t tag, va_list ap); static void OJPEGPrintDir(TIFF* tif, FILE* fd, long flags); static int OJPEGSetupDecode(TIFF* tif); -static int OJPEGPreDecode(TIFF* tif, tsample_t s); +static int OJPEGPreDecode(TIFF* tif, uint16 s); static int OJPEGPreDecodeSkipRaw(TIFF* tif); static int OJPEGPreDecodeSkipScanlines(TIFF* tif); -static int OJPEGDecode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s); +static int OJPEGDecode(TIFF* tif, tidata_t buf, tsize_t cc, uint16 s); static int OJPEGDecodeRaw(TIFF* tif, tidata_t buf, tsize_t cc); static int OJPEGDecodeScanlines(TIFF* tif, tidata_t buf, tsize_t cc); static void OJPEGPostDecode(TIFF* tif, tidata_t buf, tsize_t cc); static int OJPEGSetupEncode(TIFF* tif); -static int OJPEGPreEncode(TIFF* tif, tsample_t s); -static int OJPEGEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s); +static int OJPEGPreEncode(TIFF* tif, uint16 s); +static int OJPEGEncode(TIFF* tif, tidata_t buf, tsize_t cc, uint16 s); static int OJPEGPostEncode(TIFF* tif); static void OJPEGCleanup(TIFF* tif); static void OJPEGSubsamplingCorrect(TIFF* tif); static int OJPEGReadHeaderInfo(TIFF* tif); -static int OJPEGReadSecondarySos(TIFF* tif, tsample_t s); +static int OJPEGReadSecondarySos(TIFF* tif, uint16 s); static int OJPEGWriteHeaderInfo(TIFF* tif); static void OJPEGLibjpegSessionAbort(TIFF* tif); @@ -410,16 +410,16 @@ TIFFInitOJPEG(TIFF* tif, int scheme) /* tif codec methods */ tif->tif_setupdecode=OJPEGSetupDecode; tif->tif_predecode=OJPEGPreDecode; - tif->tif_postdecode=OJPEGPostDecode; - tif->tif_decoderow=OJPEGDecode; - tif->tif_decodestrip=OJPEGDecode; - tif->tif_decodetile=OJPEGDecode; + tif->tif_postdecode=OJPEGPostDecode; ddd + tif->tif_decoderow=OJPEGDecode; ddd + tif->tif_decodestrip=OJPEGDecode; ddd + tif->tif_decodetile=OJPEGDecode; ddd tif->tif_setupencode=OJPEGSetupEncode; tif->tif_preencode=OJPEGPreEncode; tif->tif_postencode=OJPEGPostEncode; - tif->tif_encoderow=OJPEGEncode; - tif->tif_encodestrip=OJPEGEncode; - tif->tif_encodetile=OJPEGEncode; + tif->tif_encoderow=OJPEGEncode; ddd + tif->tif_encodestrip=OJPEGEncode; ddd + tif->tif_encodetile=OJPEGEncode; ddd tif->tif_cleanup=OJPEGCleanup; tif->tif_data=(tidata_t)sp; /* tif tag methods */ @@ -610,7 +610,7 @@ OJPEGSetupDecode(TIFF* tif) } static int -OJPEGPreDecode(TIFF* tif, tsample_t s) +OJPEGPreDecode(TIFF* tif, uint16 s) { OJPEGState* sp=(OJPEGState*)tif->tif_data; tstrile_t m; @@ -640,7 +640,7 @@ OJPEGPreDecode(TIFF* tif, tsample_t s) { sp->plane_sample_offset=s; sp->write_cursample=s; - sp->write_curstrile=s*tif->tif_dir.td_stripsperimage; + sp->write_curstrile=s*tif->tif_dir.td_stripsperimage; ddd if ((sp->in_buffer_file_pos_log==0) || (sp->in_buffer_file_pos-sp->in_buffer_togo!=sp->sos_end[s].in_buffer_file_pos)) { @@ -729,7 +729,7 @@ OJPEGPreDecodeSkipScanlines(TIFF* tif) } static int -OJPEGDecode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) +OJPEGDecode(TIFF* tif, tidata_t buf, tsize_t cc, uint16 s) { OJPEGState* sp=(OJPEGState*)tif->tif_data; (void)s; @@ -833,7 +833,7 @@ OJPEGPostDecode(TIFF* tif, tidata_t buf, tsize_t cc) (void)buf; (void)cc; sp->write_curstrile++; - if (sp->write_curstrile%tif->tif_dir.td_stripsperimage==0) + if (sp->write_curstrile%tif->tif_dir.td_stripsperimage==0) ddd { assert(sp->libjpeg_session_active!=0); OJPEGLibjpegSessionAbort(tif); @@ -850,7 +850,7 @@ OJPEGSetupEncode(TIFF* tif) } static int -OJPEGPreEncode(TIFF* tif, tsample_t s) +OJPEGPreEncode(TIFF* tif, uint16 s) { static const char module[]="OJPEGPreEncode"; (void)s; @@ -859,7 +859,7 @@ OJPEGPreEncode(TIFF* tif, tsample_t s) } static int -OJPEGEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) +OJPEGEncode(TIFF* tif, tidata_t buf, tsize_t cc, uint16 s) { static const char module[]="OJPEGEncode"; (void)buf; @@ -1038,7 +1038,7 @@ OJPEGReadHeaderInfo(TIFF* tif) } static int -OJPEGReadSecondarySos(TIFF* tif, tsample_t s) +OJPEGReadSecondarySos(TIFF* tif, uint16 s) { OJPEGState* sp=(OJPEGState*)tif->tif_data; uint8 m; @@ -1210,7 +1210,7 @@ OJPEGReadHeaderInfoSec(TIFF* tif) } sp->in_buffer_source=osibsNotSetYet; sp->in_buffer_next_strile=0; - sp->in_buffer_strile_count=tif->tif_dir.td_nstrips; + sp->in_buffer_strile_count=tif->tif_dir.td_nstrips; ddd sp->in_buffer_file_togo=0; sp->in_buffer_togo=0; do @@ -1896,14 +1896,14 @@ OJPEGReadBufferFill(OJPEGState* sp) sp->in_buffer_source=osibsEof; else { - sp->in_buffer_file_pos=sp->tif->tif_dir.td_stripoffset[sp->in_buffer_next_strile]; + sp->in_buffer_file_pos=sp->tif->tif_dir.td_stripoffset[sp->in_buffer_next_strile]; ddd if (sp->in_buffer_file_pos!=0) { if (sp->in_buffer_file_pos>=sp->file_size) sp->in_buffer_file_pos=0; else { - sp->in_buffer_file_togo=sp->tif->tif_dir.td_stripbytecount[sp->in_buffer_next_strile]; + sp->in_buffer_file_togo=sp->tif->tif_dir.td_stripbytecount[sp->in_buffer_next_strile]; ddd if (sp->in_buffer_file_togo==0) sp->in_buffer_file_pos=0; else if (sp->in_buffer_file_pos+sp->in_buffer_file_togo>sp->file_size) diff --git a/libtiff/tif_open.c b/libtiff/tif_open.c index 29c72b2d..a967e0b2 100644 --- a/libtiff/tif_open.c +++ b/libtiff/tif_open.c @@ -1,4 +1,4 @@ -/* $Id: tif_open.c,v 1.34 2007-03-17 04:41:29 joris Exp $ */ +/* $Id: tif_open.c,v 1.35 2007-03-31 01:04:52 joris Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -178,7 +178,7 @@ TIFFClientOpen( tif->tif_mode = m &~ (O_CREAT|O_TRUNC); tif->tif_curdir = (tdir_t) -1; /* non-existent directory */ tif->tif_curoff = 0; - tif->tif_curstrip = (tstrip_t) -1; /* invalid strip */ + tif->tif_curstrip = (uint32) -1; /* invalid strip */ tif->tif_row = (uint32) -1; /* read/write pre-increment */ tif->tif_clientdata = clientdata; if (!readproc || !writeproc || !seekproc || !closeproc || !sizeproc) { @@ -489,7 +489,7 @@ TIFFClientOpen( !TIFFMapFileContents(tif, (tdata_t*) &tif->tif_base, &tif->tif_size)) tif->tif_flags &= ~TIFF_MAPPED; if (TIFFReadDirectory(tif)) { - tif->tif_rawcc = -1; + tif->tif_rawcc = (uint64)-1; tif->tif_flags |= TIFF_BUFFERSETUP; return (tif); } @@ -626,7 +626,7 @@ TIFFCurrentDirectory(TIFF* tif) /* * Return current strip. */ -tstrip_t +uint32 TIFFCurrentStrip(TIFF* tif) { return (tif->tif_curstrip); diff --git a/libtiff/tif_packbits.c b/libtiff/tif_packbits.c index 096c3d4f..43ea2e1a 100644 --- a/libtiff/tif_packbits.c +++ b/libtiff/tif_packbits.c @@ -1,4 +1,4 @@ -/* $Id: tif_packbits.c,v 1.14 2007-03-28 02:50:41 joris Exp $ */ +/* $Id: tif_packbits.c,v 1.15 2007-03-31 01:04:52 joris Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -34,7 +34,7 @@ #include <stdio.h> static int -PackBitsPreEncode(TIFF* tif, tsample_t s) +PackBitsPreEncode(TIFF* tif, uint16 s) { (void) s; @@ -44,7 +44,7 @@ PackBitsPreEncode(TIFF* tif, tsample_t s) * Calculate the scanline/tile-width size in bytes. */ if (isTiled(tif)) - *(tsize_t*)tif->tif_data = TIFFTileRowSize(tif); + *(tsize_t*)tif->tif_data = TIFFTileRowSize(tif); ddd else *(tsize_t*)tif->tif_data = TIFFScanlineSize(tif); ddd return (1); @@ -69,7 +69,7 @@ typedef unsigned char tidata; * Encode a run of pixels. */ static int -PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) +PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, uint16 s) { unsigned char* bp = (unsigned char*) buf; tidata_t op, ep, lastliteral; @@ -79,7 +79,7 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) (void) s; op = tif->tif_rawcp; - ep = tif->tif_rawdata + tif->tif_rawdatasize; + ep = tif->tif_rawdata + tif->tif_rawdatasize; ddd state = BASE; lastliteral = 0; while (cc > 0) { @@ -99,7 +99,7 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) */ if (state == LITERAL || state == LITERAL_RUN) { slop = op - lastliteral; - tif->tif_rawcc += lastliteral - tif->tif_rawcp; + tif->tif_rawcc += lastliteral - tif->tif_rawcp; ddd if (!TIFFFlushData1(tif)) return (-1); op = tif->tif_rawcp; @@ -107,7 +107,7 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) *op++ = *lastliteral++; lastliteral = tif->tif_rawcp; } else { - tif->tif_rawcc += op - tif->tif_rawcp; + tif->tif_rawcc += op - tif->tif_rawcp; ddd if (!TIFFFlushData1(tif)) return (-1); op = tif->tif_rawcp; @@ -183,7 +183,7 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) goto again; } } - tif->tif_rawcc += op - tif->tif_rawcp; + tif->tif_rawcc += op - tif->tif_rawcp; ddd tif->tif_rawcp = op; return (1); } @@ -196,7 +196,7 @@ PackBitsEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) * when it was encoded by strips. */ static int -PackBitsEncodeChunk(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +PackBitsEncodeChunk(TIFF* tif, tidata_t bp, tsize_t cc, uint16 s) { tsize_t rowsize = *(tsize_t*)tif->tif_data; @@ -215,7 +215,7 @@ PackBitsEncodeChunk(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) } static int -PackBitsDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) +PackBitsDecode(TIFF* tif, tidata_t op, tsize_t occ, uint16 s) { char *bp; tsize_t cc; @@ -224,7 +224,7 @@ PackBitsDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) (void) s; bp = (char*) tif->tif_rawcp; - cc = tif->tif_rawcc; + cc = tif->tif_rawcc; ddd while (cc > 0 && (long)occ > 0) { n = (long) *bp++, cc--; /* @@ -264,7 +264,7 @@ PackBitsDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) } } tif->tif_rawcp = (tidata_t) bp; - tif->tif_rawcc = cc; + tif->tif_rawcc = cc; ddd if (occ > 0) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "PackBitsDecode: Not enough data for scanline %ld", @@ -278,14 +278,14 @@ int TIFFInitPackBits(TIFF* tif, int scheme) { (void) scheme; - tif->tif_decoderow = PackBitsDecode; - tif->tif_decodestrip = PackBitsDecode; - tif->tif_decodetile = PackBitsDecode; + tif->tif_decoderow = PackBitsDecode; ddd + tif->tif_decodestrip = PackBitsDecode; ddd + tif->tif_decodetile = PackBitsDecode; ddd tif->tif_preencode = PackBitsPreEncode; tif->tif_postencode = PackBitsPostEncode; - tif->tif_encoderow = PackBitsEncode; - tif->tif_encodestrip = PackBitsEncodeChunk; - tif->tif_encodetile = PackBitsEncodeChunk; + tif->tif_encoderow = PackBitsEncode; ddd + tif->tif_encodestrip = PackBitsEncodeChunk; ddd + tif->tif_encodetile = PackBitsEncodeChunk; ddd return (1); } #endif /* PACKBITS_SUPPORT */ diff --git a/libtiff/tif_pixarlog.c b/libtiff/tif_pixarlog.c index 20c28081..4a3210e8 100644 --- a/libtiff/tif_pixarlog.c +++ b/libtiff/tif_pixarlog.c @@ -1,4 +1,4 @@ -/* $Id: tif_pixarlog.c,v 1.16 2007-03-28 02:50:41 joris Exp $ */ +/* $Id: tif_pixarlog.c,v 1.17 2007-03-31 01:04:52 joris Exp $ */ /* * Copyright (c) 1996-1997 Sam Leffler @@ -590,8 +590,8 @@ PixarLogMakeTables(PixarLogState *sp) #define DecoderState(tif) ((PixarLogState*) (tif)->tif_data) #define EncoderState(tif) ((PixarLogState*) (tif)->tif_data) -static int PixarLogEncode(TIFF*, tidata_t, tsize_t, tsample_t); -static int PixarLogDecode(TIFF*, tidata_t, tsize_t, tsample_t); +static int PixarLogEncode(TIFF*, tidata_t, tsize_t, uint16); +static int PixarLogDecode(TIFF*, tidata_t, tsize_t, uint16); #define N(a) (sizeof(a)/sizeof(a[0])) #define PIXARLOGDATAFMT_UNKNOWN -1 @@ -654,7 +654,7 @@ PixarLogSetupDecode(TIFF* tif) /* Make sure no byte swapping happens on the data * after decompression. */ - tif->tif_postdecode = _TIFFNoPostDecode; + tif->tif_postdecode = _TIFFNoPostDecode; /* for some reason, we can't do this in TIFFInitPixarLog */ @@ -689,19 +689,19 @@ PixarLogSetupDecode(TIFF* tif) * Setup state for decoding a strip. */ static int -PixarLogPreDecode(TIFF* tif, tsample_t s) +PixarLogPreDecode(TIFF* tif, uint16 s) { PixarLogState* sp = DecoderState(tif); (void) s; assert(sp != NULL); sp->stream.next_in = tif->tif_rawdata; - sp->stream.avail_in = tif->tif_rawcc; + sp->stream.avail_in = tif->tif_rawcc; ddd return (inflateReset(&sp->stream) == Z_OK); } static int -PixarLogDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) +PixarLogDecode(TIFF* tif, tidata_t op, tsize_t occ, uint16 s) { TIFFDirectory *td = &tif->tif_dir; PixarLogState* sp = DecoderState(tif); @@ -766,7 +766,7 @@ PixarLogDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) up = sp->tbuf; /* Swap bytes in the data if from a different endian machine. */ if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfShort(up, nsamples); + TIFFSwabArrayOfShort(up, nsamples); ddd /* * if llen is not an exact multiple of nsamples, the decode operation @@ -864,14 +864,14 @@ PixarLogSetupEncode(TIFF* tif) * Reset encoding state at the start of a strip. */ static int -PixarLogPreEncode(TIFF* tif, tsample_t s) +PixarLogPreEncode(TIFF* tif, uint16 s) { PixarLogState *sp = EncoderState(tif); (void) s; assert(sp != NULL); sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = tif->tif_rawdatasize; + sp->stream.avail_out = tif->tif_rawdatasize; ddd return (deflateReset(&sp->stream) == Z_OK); } @@ -1043,7 +1043,7 @@ horizontalDifference8(unsigned char *ip, int n, int stride, * Encode a chunk of pixels. */ static int -PixarLogEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +PixarLogEncode(TIFF* tif, tidata_t bp, tsize_t cc, uint16 s) { TIFFDirectory *td = &tif->tif_dir; PixarLogState *sp = EncoderState(tif); @@ -1110,10 +1110,10 @@ PixarLogEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) return (0); } if (sp->stream.avail_out == 0) { - tif->tif_rawcc = tif->tif_rawdatasize; + tif->tif_rawcc = tif->tif_rawdatasize; ddd TIFFFlushData1(tif); sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = tif->tif_rawdatasize; + sp->stream.avail_out = tif->tif_rawdatasize; ddd } } while (sp->stream.avail_in > 0); return (1); @@ -1138,12 +1138,12 @@ PixarLogPostEncode(TIFF* tif) switch (state) { case Z_STREAM_END: case Z_OK: - if (sp->stream.avail_out != (uint32)tif->tif_rawdatasize) { - tif->tif_rawcc = - tif->tif_rawdatasize - sp->stream.avail_out; + if (sp->stream.avail_out != (uint32)tif->tif_rawdatasize) { ddd + tif->tif_rawcc = ddd + tif->tif_rawdatasize - sp->stream.avail_out; ddd TIFFFlushData1(tif); sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = tif->tif_rawdatasize; + sp->stream.avail_out = tif->tif_rawdatasize; ddd } break; default: @@ -1310,15 +1310,15 @@ TIFFInitPixarLog(TIFF* tif, int scheme) */ tif->tif_setupdecode = PixarLogSetupDecode; tif->tif_predecode = PixarLogPreDecode; - tif->tif_decoderow = PixarLogDecode; - tif->tif_decodestrip = PixarLogDecode; - tif->tif_decodetile = PixarLogDecode; + tif->tif_decoderow = PixarLogDecode; ddd + tif->tif_decodestrip = PixarLogDecode; ddd + tif->tif_decodetile = PixarLogDecode; ddd tif->tif_setupencode = PixarLogSetupEncode; tif->tif_preencode = PixarLogPreEncode; tif->tif_postencode = PixarLogPostEncode; - tif->tif_encoderow = PixarLogEncode; - tif->tif_encodestrip = PixarLogEncode; - tif->tif_encodetile = PixarLogEncode; + tif->tif_encoderow = PixarLogEncode; ddd + tif->tif_encodestrip = PixarLogEncode; ddd + tif->tif_encodetile = PixarLogEncode; ddd tif->tif_close = PixarLogClose; tif->tif_cleanup = PixarLogCleanup; diff --git a/libtiff/tif_predict.c b/libtiff/tif_predict.c index a96f961a..898da053 100644 --- a/libtiff/tif_predict.c +++ b/libtiff/tif_predict.c @@ -1,4 +1,4 @@ -/* $Id: tif_predict.c,v 1.12 2007-03-28 02:50:41 joris Exp $ */ +/* $Id: tif_predict.c,v 1.13 2007-03-31 01:04:52 joris Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -41,10 +41,10 @@ static void horDiff8(TIFF*, tidata_t, tsize_t); static void horDiff16(TIFF*, tidata_t, tsize_t); static void fpAcc(TIFF*, tidata_t, tsize_t); static void fpDiff(TIFF*, tidata_t, tsize_t); -static int PredictorDecodeRow(TIFF*, tidata_t, tsize_t, tsample_t); -static int PredictorDecodeTile(TIFF*, tidata_t, tsize_t, tsample_t); -static int PredictorEncodeRow(TIFF*, tidata_t, tsize_t, tsample_t); -static int PredictorEncodeTile(TIFF*, tidata_t, tsize_t, tsample_t); +static int PredictorDecodeRow(TIFF*, tidata_t, tsize_t, uint16); +static int PredictorDecodeTile(TIFF*, tidata_t, tsize_t, uint16); +static int PredictorEncodeRow(TIFF*, tidata_t, tsize_t, uint16); +static int PredictorEncodeTile(TIFF*, tidata_t, tsize_t, uint16); static int PredictorSetup(TIFF* tif) @@ -87,7 +87,7 @@ PredictorSetup(TIFF* tif) * Calculate the scanline/tile-width size in bytes. */ if (isTiled(tif)) - sp->rowsize = TIFFTileRowSize(tif); + sp->rowsize = TIFFTileRowSize(tif); ddd else sp->rowsize = TIFFScanlineSize(tif); ddd @@ -112,12 +112,12 @@ PredictorSetupDecode(TIFF* tif) * Override default decoding method with one that does the * predictor stuff. */ - sp->coderow = tif->tif_decoderow; - tif->tif_decoderow = PredictorDecodeRow; - sp->codestrip = tif->tif_decodestrip; - tif->tif_decodestrip = PredictorDecodeTile; - sp->codetile = tif->tif_decodetile; - tif->tif_decodetile = PredictorDecodeTile; + sp->coderow = tif->tif_decoderow; ddd + tif->tif_decoderow = PredictorDecodeRow; ddd + sp->codestrip = tif->tif_decodestrip; ddd + tif->tif_decodestrip = PredictorDecodeTile; ddd + sp->codetile = tif->tif_decodetile; ddd + tif->tif_decodetile = PredictorDecodeTile; ddd /* * If the data is horizontally differenced 16-bit data that * requires byte-swapping, then it must be byte swapped before @@ -139,19 +139,19 @@ PredictorSetupDecode(TIFF* tif) * Override default decoding method with one that does the * predictor stuff. */ - sp->coderow = tif->tif_decoderow; - tif->tif_decoderow = PredictorDecodeRow; - sp->codestrip = tif->tif_decodestrip; - tif->tif_decodestrip = PredictorDecodeTile; - sp->codetile = tif->tif_decodetile; - tif->tif_decodetile = PredictorDecodeTile; + sp->coderow = tif->tif_decoderow; ddd + tif->tif_decoderow = PredictorDecodeRow; ddd + sp->codestrip = tif->tif_decodestrip; ddd + tif->tif_decodestrip = PredictorDecodeTile; ddd + sp->codetile = tif->tif_decodetile; ddd + tif->tif_decodetile = PredictorDecodeTile; ddd /* * The data should not be swapped outside of the floating * point predictor, the accumulation routine should return * byres in the native order. */ if (tif->tif_flags & TIFF_SWAB) { - tif->tif_postdecode = _TIFFNoPostDecode; + tif->tif_postdecode = _TIFFNoPostDecode; } /* * Allocate buffer to keep the decoded bytes before @@ -180,12 +180,12 @@ PredictorSetupEncode(TIFF* tif) * Override default encoding method with one that does the * predictor stuff. */ - sp->coderow = tif->tif_encoderow; - tif->tif_encoderow = PredictorEncodeRow; - sp->codestrip = tif->tif_encodestrip; - tif->tif_encodestrip = PredictorEncodeTile; - sp->codetile = tif->tif_encodetile; - tif->tif_encodetile = PredictorEncodeTile; + sp->coderow = tif->tif_encoderow; ddd + tif->tif_encoderow = PredictorEncodeRow; ddd + sp->codestrip = tif->tif_encodestrip; ddd + tif->tif_encodestrip = PredictorEncodeTile; ddd + sp->codetile = tif->tif_encodetile; ddd + tif->tif_encodetile = PredictorEncodeTile; ddd } else if (sp->predictor == 3) { @@ -194,12 +194,12 @@ PredictorSetupEncode(TIFF* tif) * Override default encoding method with one that does the * predictor stuff. */ - sp->coderow = tif->tif_encoderow; - tif->tif_encoderow = PredictorEncodeRow; - sp->codestrip = tif->tif_encodestrip; - tif->tif_encodestrip = PredictorEncodeTile; - sp->codetile = tif->tif_encodetile; - tif->tif_encodetile = PredictorEncodeTile; + sp->coderow = tif->tif_encoderow; ddd + tif->tif_encoderow = PredictorEncodeRow; ddd + sp->codestrip = tif->tif_encodestrip; dddd + tif->tif_encodestrip = PredictorEncodeTile; ddd + sp->codetile = tif->tif_encodetile; ddd + tif->tif_encodetile = PredictorEncodeTile; ddd } return 1; @@ -266,7 +266,7 @@ swabHorAcc16(TIFF* tif, tidata_t cp0, tsize_t cc) tsize_t wc = cc / 2; if (wc > stride) { - TIFFSwabArrayOfShort(wp, wc); + TIFFSwabArrayOfShort(wp, wc); ddd wc -= stride; do { REPEAT4(stride, wp[stride] += wp[0]; wp++) @@ -332,7 +332,7 @@ fpAcc(TIFF* tif, tidata_t cp0, tsize_t cc) * Decode a scanline and apply the predictor routine. */ static int -PredictorDecodeRow(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) +PredictorDecodeRow(TIFF* tif, tidata_t op0, tsize_t occ0, uint16 s) { TIFFPredictorState *sp = PredictorState(tif); @@ -355,7 +355,7 @@ PredictorDecodeRow(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) * strip/tile dimensions. */ static int -PredictorDecodeTile(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s) +PredictorDecodeTile(TIFF* tif, tidata_t op0, tsize_t occ0, uint16 s) { TIFFPredictorState *sp = PredictorState(tif); @@ -476,7 +476,7 @@ fpDiff(TIFF* tif, tidata_t cp0, tsize_t cc) } static int -PredictorEncodeRow(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +PredictorEncodeRow(TIFF* tif, tidata_t bp, tsize_t cc, uint16 s) { TIFFPredictorState *sp = PredictorState(tif); @@ -490,7 +490,7 @@ PredictorEncodeRow(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) } static int -PredictorEncodeTile(TIFF* tif, tidata_t bp0, tsize_t cc0, tsample_t s) +PredictorEncodeTile(TIFF* tif, tidata_t bp0, tsize_t cc0, uint16 s) { TIFFPredictorState *sp = PredictorState(tif); tsize_t cc = cc0, rowsize; diff --git a/libtiff/tif_print.c b/libtiff/tif_print.c index dbb1d05e..acafc3c2 100644 --- a/libtiff/tif_print.c +++ b/libtiff/tif_print.c @@ -1,4 +1,4 @@ -/* $Id: tif_print.c,v 1.36 2006-06-03 15:28:33 bfriesen Exp $ */ +/* $Id: tif_print.c,v 1.37 2007-03-31 01:04:53 joris Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -595,16 +595,16 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) (*tif->tif_tagmethods.printdir)(tif, fd, flags); if ((flags & TIFFPRINT_STRIPS) && TIFFFieldSet(tif,FIELD_STRIPOFFSETS)) { - tstrip_t s; + uint32 s; fprintf(fd, " %lu %s:\n", - (long) td->td_nstrips, + (long) td->td_nstrips, ddd isTiled(tif) ? "Tiles" : "Strips"); - for (s = 0; s < td->td_nstrips; s++) + for (s = 0; s < td->td_nstrips; s++) ddd fprintf(fd, " %3lu: [%8lu, %8lu]\n", - (unsigned long) s, - (unsigned long) td->td_stripoffset[s], - (unsigned long) td->td_stripbytecount[s]); + (unsigned long) s, ddd + (unsigned long) td->td_stripoffset[s], ddd + (unsigned long) td->td_stripbytecount[s]); ddd } } diff --git a/libtiff/tif_read.c b/libtiff/tif_read.c index 0f8134b9..2d48c757 100644 --- a/libtiff/tif_read.c +++ b/libtiff/tif_read.c @@ -1,4 +1,4 @@ -/* $Id: tif_read.c,v 1.17 2007-03-28 02:50:41 joris Exp $ */ +/* $Id: tif_read.c,v 1.18 2007-03-31 01:04:53 joris Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -31,20 +31,20 @@ #include "tiffiop.h" #include <stdio.h> - int TIFFFillStrip(TIFF*, tstrip_t); - int TIFFFillTile(TIFF*, ttile_t); -static int TIFFStartStrip(TIFF*, tstrip_t); -static int TIFFStartTile(TIFF*, ttile_t); -static int TIFFCheckRead(TIFF*, int); +int TIFFFillStrip(TIFF* tif, uint32 strip); +int TIFFFillTile(TIFF* tif, uint32 tile); +static int TIFFStartStrip(TIFF* tif, uint32 strip); +static int TIFFStartTile(TIFF* tif, uint32 tile); +static int TIFFCheckRead(TIFF*, int); -#define NOSTRIP ((tstrip_t) -1) /* undefined state */ -#define NOTILE ((ttile_t) -1) /* undefined state */ +#define NOSTRIP ((uint32) -1) /* undefined state */ +#define NOTILE ((ttile_t) -1) /* undefined state */ /* * Seek to a random row+sample in a file. */ static int -TIFFSeek(TIFF* tif, uint32 row, tsample_t sample) +TIFFSeek(TIFF* tif, uint32 row, uint16 sample) { register TIFFDirectory *td = &tif->tif_dir; tstrip_t strip; @@ -63,7 +63,7 @@ TIFFSeek(TIFF* tif, uint32 row, tsample_t sample) (unsigned long) sample, (unsigned long) td->td_samplesperpixel); return (0); } - strip = sample*td->td_stripsperimage + row/td->td_rowsperstrip; + strip = (uint32)sample*td->td_stripsperimage + row/td->td_rowsperstrip; } else strip = row / td->td_rowsperstrip; if (strip != tif->tif_curstrip) { /* different strip, refill */ @@ -93,7 +93,7 @@ TIFFSeek(TIFF* tif, uint32 row, tsample_t sample) } int -TIFFReadScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample) +TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample) { int e; @@ -104,13 +104,13 @@ TIFFReadScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample) * Decompress desired row into user buffer. */ e = (*tif->tif_decoderow) - (tif, (tidata_t) buf, tif->tif_scanlinesize, sample); + (tif, (uint8*) buf, tif->tif_scanlinesize, sample); /* we are now poised at the beginning of the next row */ tif->tif_row = row + 1; if (e) - (*tif->tif_postdecode)(tif, (tidata_t) buf, + (*tif->tif_postdecode)(tif, (uint8*) buf, tif->tif_scanlinesize); } return (e > 0 ? 1 : -1); @@ -120,89 +120,85 @@ TIFFReadScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample) * Read a strip of data and decompress the specified * amount into the user-supplied buffer. */ -tsize_t -TIFFReadEncodedStrip(TIFF* tif, tstrip_t strip, tdata_t buf, tsize_t size) +uint64 +TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, uint64 size) { + static const char module[] = "TIFFReadEncodedStrip"; TIFFDirectory *td = &tif->tif_dir; - uint32 nrows; - tsize_t stripsize; - tstrip_t sep_strip, strips_per_sep; - - if (!TIFFCheckRead(tif, 0)) - return (-1); - if (strip >= td->td_nstrips) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%ld: Strip out of range, max %ld", - (long) strip, (long) td->td_nstrips); - return (-1); + uint32 rowsperstrip; + uint32 stripsperplane; + uint32 stripinplane; + uint16 plane; + uint32 rows; + uint64 stripsize; + if (!TIFFCheckRead(tif,0)) + return((uint64)(-1)); + if (strip>=td->td_nstrips) + { + TIFFErrorExt(tif->tif_clientdata,module, + "%uld: Strip out of range, max %uld",(unsigned long)strip, + (unsigned long)td->td_nstrips); + return((uint64)(-1)); } /* * Calculate the strip size according to the number of * rows in the strip (check for truncated last strip on any * of the separations). */ - if( td->td_rowsperstrip >= td->td_imagelength ) - strips_per_sep = 1; - else - strips_per_sep = (td->td_imagelength+td->td_rowsperstrip-1) - / td->td_rowsperstrip; - - sep_strip = strip % strips_per_sep; - - if (sep_strip != strips_per_sep-1 || - (nrows = td->td_imagelength % td->td_rowsperstrip) == 0) - nrows = td->td_rowsperstrip; - - stripsize = TIFFVStripSize(tif, nrows); ddd - if (size == (tsize_t) -1) - size = stripsize; - else if (size > stripsize) - size = stripsize; - if (TIFFFillStrip(tif, strip) - && (*tif->tif_decodestrip)(tif, (tidata_t) buf, size, - (tsample_t)(strip / td->td_stripsperimage)) > 0 ) { - (*tif->tif_postdecode)(tif, (tidata_t) buf, size); - return (size); - } else - return ((tsize_t) -1); + rowsperstrip=td->td_rowsperstrip; + if (rowsperstrip>td->td_imagelength) + rowsperstrip=td->td_imagelength; + stripsperplane=((td->td_imagelength+rowsperstrip-1)/rowsperstrip); + stripinplane=(strip%stripsperplane); + plane=(strip/stripsperplane); + rows=td->td_imagelength-stripinplane*rowsperstrip; + if (rows>rowsperstrip) + rows=rowsperstrip; + stripsize=TIFFVStripSize(tif,rows); + if ((size!=(uint64)(-1))&&(size<stripsize)) + stripsize=size; + if (!TIFFFillStrip(tif,strip)) + return((uint64)(-1)); + if ((*tif->tif_decodestrip)(tif,buf,size,plane)<=0) + return((uint64)(-1)); + (*tif->tif_postdecode)(tif,buf,size); + return(size); } -static tsize_t -TIFFReadRawStrip1(TIFF* tif, - tstrip_t strip, tdata_t buf, tsize_t size, const char* module) +static uint64 +TIFFReadRawStrip1(TIFF* tif, uint32 strip, void* buf, uint64 size, + const char* module) { TIFFDirectory *td = &tif->tif_dir; assert((tif->tif_flags&TIFF_NOREADRAW)==0); if (!isMapped(tif)) { - tsize_t cc; + uint64 cc; if (!SeekOK(tif, td->td_stripoffset[strip])) { TIFFErrorExt(tif->tif_clientdata, module, - "%s: Seek error at scanline %lu, strip %lu", - tif->tif_name, + "Seek error at scanline %lu, strip %lu", (unsigned long) tif->tif_row, (unsigned long) strip); return (-1); } cc = TIFFReadFile(tif, buf, size); if (cc != size) { TIFFErrorExt(tif->tif_clientdata, module, - "%s: Read error at scanline %lu; got %lu bytes, expected %lu", + "Read error at scanline %lu; got %llu bytes, expected %llu", tif->tif_name, (unsigned long) tif->tif_row, - (unsigned long) cc, - (unsigned long) size); + (unsigned long long) cc, + (unsigned long long) size); return (-1); } } else { if (td->td_stripoffset[strip] + size > tif->tif_size) { TIFFErrorExt(tif->tif_clientdata, module, - "%s: Read error at scanline %lu, strip %lu; got %lu bytes, expected %lu", - tif->tif_name, + "Read error at scanline %lu, strip %lu; got %llu bytes, expected %llu", (unsigned long) tif->tif_row, (unsigned long) strip, - (unsigned long) tif->tif_size - td->td_stripoffset[strip], - (unsigned long) size); + (unsigned long long) tif->tif_size - td->td_stripoffset[strip], + (unsigned long long) size); return (-1); } _TIFFmemcpy(buf, tif->tif_base + td->td_stripoffset[strip], @@ -214,42 +210,36 @@ TIFFReadRawStrip1(TIFF* tif, /* * Read a strip of data from the file. */ -tsize_t -TIFFReadRawStrip(TIFF* tif, tstrip_t strip, tdata_t buf, tsize_t size) +uint64 +TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, uint64 size) { static const char module[] = "TIFFReadRawStrip"; TIFFDirectory *td = &tif->tif_dir; - /* - * FIXME: butecount should have tsize_t type, but for now libtiff - * defines tsize_t as a signed 32-bit integer and we are losing - * ability to read arrays larger than 2^31 bytes. So we are using - * uint32 instead of tsize_t here. - */ - uint32 bytecount; + uint64 bytecount; if (!TIFFCheckRead(tif, 0)) - return ((tsize_t) -1); + return ((uint64) -1); if (strip >= td->td_nstrips) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%lu: Strip out of range, max %lu", - (unsigned long) strip, - (unsigned long) td->td_nstrips); + TIFFErrorExt(tif->tif_clientdata, module, + "%lu: Strip out of range, max %lu", + (unsigned long) strip, + (unsigned long) td->td_nstrips); return ((tsize_t) -1); } if (tif->tif_flags&TIFF_NOREADRAW) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Compression scheme does not support access to raw uncompressed data"); + TIFFErrorExt(tif->tif_clientdata, module, + "Compression scheme does not support access to raw uncompressed data"); return ((tsize_t) -1); } bytecount = td->td_stripbytecount[strip]; if (bytecount <= 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%lu: Invalid strip byte count, strip %lu", - (unsigned long) bytecount, (unsigned long) strip); - return ((tsize_t) -1); + TIFFErrorExt(tif->tif_clientdata, module, + "%llu: Invalid strip byte count, strip %lu", + (unsigned long long) bytecount, (unsigned long) strip); + return ((uint64) -1); } - if (size != (tsize_t)-1 && (uint32)size < bytecount) + if (size != (uint64)-1 && size < bytecount) bytecount = size; return (TIFFReadRawStrip1(tif, strip, buf, bytecount, module)); } @@ -266,17 +256,11 @@ TIFFFillStrip(TIFF* tif, tstrip_t strip) if ((tif->tif_flags&TIFF_NOREADRAW)==0) { - /* - * FIXME: butecount should have tsize_t type, but for now - * libtiff defines tsize_t as a signed 32-bit integer and we - * are losing ability to read arrays larger than 2^31 bytes. - * So we are using uint32 instead of tsize_t here. - */ - uint32 bytecount = td->td_stripbytecount[strip]; + uint64 bytecount = td->td_stripbytecount[strip]; if (bytecount <= 0) { TIFFErrorExt(tif->tif_clientdata, module, - "%s: Invalid strip byte count %lu, strip %lu", - tif->tif_name, (unsigned long) bytecount, + "Invalid strip byte count %llu, strip %lu", + (unsigned long) bytecount, (unsigned long) strip); return (0); } @@ -315,11 +299,11 @@ TIFFFillStrip(TIFF* tif, tstrip_t strip) */ TIFFErrorExt(tif->tif_clientdata, module, - "%s: Read error on strip %lu; " - "got %lu bytes, expected %lu", - tif->tif_name, (unsigned long) strip, - (unsigned long) tif->tif_size - td->td_stripoffset[strip], - (unsigned long) bytecount); + "Read error on strip %lu; " + "got %llu bytes, expected %llu", + (unsigned long) strip, + (unsigned long long) tif->tif_size - td->td_stripoffset[strip], + (unsigned long long) bytecount); tif->tif_curstrip = NOSTRIP; return (0); } @@ -331,22 +315,19 @@ TIFFFillStrip(TIFF* tif, tstrip_t strip) * strip coming from file (perhaps should set upper * bound on the size of a buffer we'll use?). */ - if (bytecount > (uint32)tif->tif_rawdatasize) { + if (bytecount > tif->tif_rawdatasize) { tif->tif_curstrip = NOSTRIP; if ((tif->tif_flags & TIFF_MYBUFFER) == 0) { - TIFFErrorExt(tif->tif_clientdata, - module, - "%s: Data buffer too small to hold strip %lu", - tif->tif_name, - (unsigned long) strip); + TIFFErrorExt(tif->tif_clientdata, module, + "Data buffer too small to hold strip %lu", + (unsigned long) strip); return (0); } if (!TIFFReadBufferSetup(tif, 0, - TIFFroundup(bytecount, 1024))) ddd + TIFFroundup_64(bytecount, 1024))) return (0); } - if ((uint32)TIFFReadRawStrip1(tif, strip, - (unsigned char *)tif->tif_rawdata, + if (TIFFReadRawStrip1(tif, strip, tif->tif_rawdata, bytecount, module) != bytecount) return (0); if (!isFillOrder(tif, td->td_fillorder) && @@ -366,89 +347,85 @@ TIFFFillStrip(TIFF* tif, tstrip_t strip) * Read and decompress a tile of data. The * tile is selected by the (x,y,z,s) coordinates. */ -tsize_t -TIFFReadTile(TIFF* tif, - tdata_t buf, uint32 x, uint32 y, uint32 z, tsample_t s) +uint64 +TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s) { if (!TIFFCheckRead(tif, 1) || !TIFFCheckTile(tif, x, y, z, s)) return (-1); return (TIFFReadEncodedTile(tif, - TIFFComputeTile(tif, x, y, z, s), buf, (tsize_t) -1)); + TIFFComputeTile(tif, x, y, z, s), buf, (uint64) -1)); } /* * Read a tile of data and decompress the specified * amount into the user-supplied buffer. */ -tsize_t -TIFFReadEncodedTile(TIFF* tif, ttile_t tile, tdata_t buf, tsize_t size) +uint64 +TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, uint64 size) { + static const char module[] = "TIFFReadEncodedTile"; TIFFDirectory *td = &tif->tif_dir; - tsize_t tilesize = tif->tif_tilesize; + uint64 tilesize = tif->tif_tilesize; if (!TIFFCheckRead(tif, 1)) return (-1); if (tile >= td->td_nstrips) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%ld: Tile out of range, max %ld", - (long) tile, (unsigned long) td->td_nstrips); + TIFFErrorExt(tif->tif_clientdata, module, + "%lud: Tile out of range, max %lud", + (unsigned long) tile, (unsigned long) td->td_nstrips); return (-1); } - if (size == (tsize_t) -1) + if (size == (uint64) -1) size = tilesize; else if (size > tilesize) size = tilesize; if (TIFFFillTile(tif, tile) && (*tif->tif_decodetile)(tif, - (tidata_t) buf, size, (tsample_t)(tile/td->td_stripsperimage))) { - (*tif->tif_postdecode)(tif, (tidata_t) buf, size); + (uint8*) buf, size, (uint16)(tile/td->td_stripsperimage))) { + (*tif->tif_postdecode)(tif, (uint8*) buf, size); return (size); } else return (-1); } -static tsize_t -TIFFReadRawTile1(TIFF* tif, - ttile_t tile, tdata_t buf, tsize_t size, const char* module) +static uint64 +TIFFReadRawTile1(TIFF* tif, uint32 tile, void* buf, uint64 size, const char* module) { TIFFDirectory *td = &tif->tif_dir; assert((tif->tif_flags&TIFF_NOREADRAW)==0); if (!isMapped(tif)) { - tsize_t cc; + uint64 cc; if (!SeekOK(tif, td->td_stripoffset[tile])) { TIFFErrorExt(tif->tif_clientdata, module, - "%s: Seek error at row %ld, col %ld, tile %ld", - tif->tif_name, - (long) tif->tif_row, - (long) tif->tif_col, - (long) tile); - return ((tsize_t) -1); + "Seek error at row %lud, col %lud, tile %lud", + (unsigned long) tif->tif_row, + (unsigned long) tif->tif_col, + (unsigned long) tile); + return ((uint64) -1); } cc = TIFFReadFile(tif, buf, size); if (cc != size) { TIFFErrorExt(tif->tif_clientdata, module, - "%s: Read error at row %ld, col %ld; got %lu bytes, expected %lu", - tif->tif_name, - (long) tif->tif_row, - (long) tif->tif_col, - (unsigned long) cc, - (unsigned long) size); - return ((tsize_t) -1); + "Read error at row %lud, col %lud; got %llu bytes, expected %llu", + (unsigned long) tif->tif_row, + (unsigned long) tif->tif_col, + (unsigned long long) cc, + (unsigned long long) size); + return ((uint64) -1); } } else { if (td->td_stripoffset[tile] + size > tif->tif_size) { TIFFErrorExt(tif->tif_clientdata, module, - "%s: Read error at row %ld, col %ld, tile %ld; got %lu bytes, expected %lu", - tif->tif_name, - (long) tif->tif_row, - (long) tif->tif_col, - (long) tile, - (unsigned long) tif->tif_size - td->td_stripoffset[tile], - (unsigned long) size); - return ((tsize_t) -1); + "Read error at row %lud, col %lud, tile %lud; got %llu bytes, expected %llu", + (unsigned long) tif->tif_row, + (unsigned long) tif->tif_col, + (unsigned long) tile, + (unsigned long long) tif->tif_size - td->td_stripoffset[tile], + (unsigned long long) size); + return ((uint64) -1); } - _TIFFmemcpy(buf, tif->tif_base + td->td_stripoffset[tile], size); + _TIFFmemcpy(buf, tif->tif_base + td->td_stripoffset[tile], size); } return (size); } @@ -456,35 +433,29 @@ TIFFReadRawTile1(TIFF* tif, /* * Read a tile of data from the file. */ -tsize_t -TIFFReadRawTile(TIFF* tif, ttile_t tile, tdata_t buf, tsize_t size) +uint64 +TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, uint64 size) { static const char module[] = "TIFFReadRawTile"; TIFFDirectory *td = &tif->tif_dir; - /* - * FIXME: butecount should have tsize_t type, but for now libtiff - * defines tsize_t as a signed 32-bit integer and we are losing - * ability to read arrays larger than 2^31 bytes. So we are using - * uint32 instead of tsize_t here. - */ - uint32 bytecount; + uint64 bytecount; if (!TIFFCheckRead(tif, 1)) - return ((tsize_t) -1); + return ((uint64) -1); if (tile >= td->td_nstrips) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%lu: Tile out of range, max %lu", + TIFFErrorExt(tif->tif_clientdata, module, + "%lu: Tile out of range, max %lu", (unsigned long) tile, (unsigned long) td->td_nstrips); - return ((tsize_t) -1); + return ((uint64) -1); } if (tif->tif_flags&TIFF_NOREADRAW) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Compression scheme does not support access to raw uncompressed data"); - return ((tsize_t) -1); + TIFFErrorExt(tif->tif_clientdata, module, + "Compression scheme does not support access to raw uncompressed data"); + return ((uint64) -1); } bytecount = td->td_stripbytecount[tile]; - if (size != (tsize_t) -1 && (uint32)size < bytecount) + if (size != (uint64) -1 && size < bytecount) bytecount = size; return (TIFFReadRawTile1(tif, tile, buf, bytecount, module)); } @@ -494,24 +465,18 @@ TIFFReadRawTile(TIFF* tif, ttile_t tile, tdata_t buf, tsize_t size) * expanded, as necessary, to hold the tile's data. */ int -TIFFFillTile(TIFF* tif, ttile_t tile) +TIFFFillTile(TIFF* tif, uint32 tile) { static const char module[] = "TIFFFillTile"; TIFFDirectory *td = &tif->tif_dir; if ((tif->tif_flags&TIFF_NOREADRAW)==0) { - /* - * FIXME: butecount should have tsize_t type, but for now - * libtiff defines tsize_t as a signed 32-bit integer and we - * are losing ability to read arrays larger than 2^31 bytes. - * So we are using uint32 instead of tsize_t here. - */ - uint32 bytecount = td->td_stripbytecount[tile]; + uint64 bytecount = td->td_stripbytecount[tile]; if (bytecount <= 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%lu: Invalid tile byte count, tile %lu", - (unsigned long) bytecount, (unsigned long) tile); + TIFFErrorExt(tif->tif_clientdata, module, + "%llu: Invalid tile byte count, tile %lu", + (unsigned long long) bytecount, (unsigned long) tile); return (0); } if (isMapped(tif) && @@ -541,7 +506,7 @@ TIFFFillTile(TIFF* tif, ttile_t tile) * two comparisons: */ if (bytecount > tif->tif_size || - td->td_stripoffset[tile] > tif->tif_size - bytecount) { + td->td_stripoffset[tile] > tif->tif_size - bytecount) { tif->tif_curtile = NOTILE; return (0); } @@ -554,23 +519,21 @@ TIFFFillTile(TIFF* tif, ttile_t tile) * tile coming from file (perhaps should set upper * bound on the size of a buffer we'll use?). */ - if (bytecount > (uint32)tif->tif_rawdatasize) { + if (bytecount > tif->tif_rawdatasize) { tif->tif_curtile = NOTILE; if ((tif->tif_flags & TIFF_MYBUFFER) == 0) { TIFFErrorExt(tif->tif_clientdata, - module, - "%s: Data buffer too small to hold tile %ld", - tif->tif_name, - (long) tile); + module, + "Data buffer too small to hold tile %lud", + (unsigned long) tile); return (0); } if (!TIFFReadBufferSetup(tif, 0, - TIFFroundup(bytecount, 1024))) ddd + TIFFroundup_64(bytecount, 1024))) return (0); } - if ((uint32)TIFFReadRawTile1(tif, tile, - (unsigned char *)tif->tif_rawdata, - bytecount, module) != bytecount) + if (TIFFReadRawTile1(tif, tile, + tif->tif_rawdata, bytecount, module) != bytecount) return (0); if (!isFillOrder(tif, td->td_fillorder) && (tif->tif_flags & TIFF_NOBITREV) == 0) @@ -590,7 +553,7 @@ TIFFFillTile(TIFF* tif, ttile_t tile) * raw data. */ int -TIFFReadBufferSetup(TIFF* tif, tdata_t bp, tsize_t size) +TIFFReadBufferSetup(TIFF* tif, void* bp, uint64 size) { static const char module[] = "TIFFReadBufferSetup"; @@ -602,17 +565,17 @@ TIFFReadBufferSetup(TIFF* tif, tdata_t bp, tsize_t size) } if (bp) { tif->tif_rawdatasize = size; - tif->tif_rawdata = (tidata_t) bp; + tif->tif_rawdata = (uint8*) bp; tif->tif_flags &= ~TIFF_MYBUFFER; } else { - tif->tif_rawdatasize = TIFFroundup(size, 1024); ddd - tif->tif_rawdata = (tidata_t) _TIFFmalloc(tif->tif_rawdatasize); + tif->tif_rawdatasize = TIFFroundup_64(size, 1024); + tif->tif_rawdata = (uint8*) _TIFFmalloc(tif->tif_rawdatasize); tif->tif_flags |= TIFF_MYBUFFER; } if (tif->tif_rawdata == NULL) { TIFFErrorExt(tif->tif_clientdata, module, - "%s: No space for data buffer at scanline %ld", - tif->tif_name, (long) tif->tif_row); + "No space for data buffer at scanline %lud", + (unsigned long) tif->tif_row); tif->tif_rawdatasize = 0; return (0); } @@ -624,7 +587,7 @@ TIFFReadBufferSetup(TIFF* tif, tdata_t bp, tsize_t size) * strip has just been read in. */ static int -TIFFStartStrip(TIFF* tif, tstrip_t strip) +TIFFStartStrip(TIFF* tif, uint32 strip) { TIFFDirectory *td = &tif->tif_dir; @@ -638,7 +601,7 @@ TIFFStartStrip(TIFF* tif, tstrip_t strip) if (tif->tif_flags&TIFF_NOREADRAW) { tif->tif_rawcp = NULL; - tif->tif_rawcc = 0; + tif->tif_rawcc = 0; } else { @@ -646,7 +609,7 @@ TIFFStartStrip(TIFF* tif, tstrip_t strip) tif->tif_rawcc = td->td_stripbytecount[strip]; } return ((*tif->tif_predecode)(tif, - (tsample_t)(strip / td->td_stripsperimage))); + (uint16)(strip / td->td_stripsperimage))); } /* @@ -654,7 +617,7 @@ TIFFStartStrip(TIFF* tif, tstrip_t strip) * tile has just been read in. */ static int -TIFFStartTile(TIFF* tif, ttile_t tile) +TIFFStartTile(TIFF* tif, uint32 tile) { TIFFDirectory *td = &tif->tif_dir; @@ -665,10 +628,10 @@ TIFFStartTile(TIFF* tif, ttile_t tile) } tif->tif_curtile = tile; tif->tif_row = - (tile % TIFFhowmany(td->td_imagewidth, td->td_tilewidth)) * ddd + (tile % TIFFhowmany_32(td->td_imagewidth, td->td_tilewidth)) * td->td_tilelength; tif->tif_col = - (tile % TIFFhowmany(td->td_imagelength, td->td_tilelength)) * ddd + (tile % TIFFhowmany_32(td->td_imagelength, td->td_tilelength)) * td->td_tilewidth; if (tif->tif_flags&TIFF_NOREADRAW) { @@ -678,10 +641,10 @@ TIFFStartTile(TIFF* tif, ttile_t tile) else { tif->tif_rawcp = tif->tif_rawdata; - tif->tif_rawcc = td->td_stripbytecount[tile]; + tif->tif_rawcc = td->td_stripbytecount[tile]; } return ((*tif->tif_predecode)(tif, - (tsample_t)(tile/td->td_stripsperimage))); + (uint16)(tile/td->td_stripsperimage))); } static int @@ -701,13 +664,13 @@ TIFFCheckRead(TIFF* tif, int tiles) } void -_TIFFNoPostDecode(TIFF* tif, tidata_t buf, tsize_t cc) +_TIFFNoPostDecode(TIFF* tif, uint8* buf, uint64 cc) { (void) tif; (void) buf; (void) cc; } void -_TIFFSwab16BitData(TIFF* tif, tidata_t buf, tsize_t cc) +_TIFFSwab16BitData(TIFF* tif, uint8* buf, uint64 cc) { (void) tif; assert((cc & 1) == 0); @@ -715,27 +678,27 @@ _TIFFSwab16BitData(TIFF* tif, tidata_t buf, tsize_t cc) } void -_TIFFSwab24BitData(TIFF* tif, tidata_t buf, tsize_t cc) +_TIFFSwab24BitData(TIFF* tif, uint8* buf, uint64 cc) { (void) tif; assert((cc % 3) == 0); - TIFFSwabArrayOfTriples((uint8*) buf, cc/3); + TIFFSwabArrayOfTriples((uint8*) buf, cc/3); } void -_TIFFSwab32BitData(TIFF* tif, tidata_t buf, tsize_t cc) +_TIFFSwab32BitData(TIFF* tif, uint8* buf, uint64 cc) { (void) tif; assert((cc & 3) == 0); - TIFFSwabArrayOfLong((uint32*) buf, cc/4); + TIFFSwabArrayOfLong((uint32*) buf, cc/4); } void -_TIFFSwab64BitData(TIFF* tif, tidata_t buf, tsize_t cc) +_TIFFSwab64BitData(TIFF* tif, uint8* buf, uint64 cc) { (void) tif; assert((cc & 7) == 0); - TIFFSwabArrayOfDouble((double*) buf, cc/8); + TIFFSwabArrayOfDouble((double*) buf, cc/8); } /* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/libtiff/tif_strip.c b/libtiff/tif_strip.c index bbc2389a..8520f1f0 100644 --- a/libtiff/tif_strip.c +++ b/libtiff/tif_strip.c @@ -1,4 +1,4 @@ -/* $Id: tif_strip.c,v 1.20 2007-03-28 02:50:41 joris Exp $ */ +/* $Id: tif_strip.c,v 1.21 2007-03-31 01:04:53 joris Exp $ */ /* * Copyright (c) 1991-1997 Sam Leffler @@ -73,21 +73,22 @@ multiply_64(TIFF* tif, uint64 nmemb, uint64 elem_size, const char* where) /* * Compute which strip a (row,sample) value is in. */ -tstrip_t -TIFFComputeStrip(TIFF* tif, uint32 row, tsample_t sample) +uint32 +TIFFComputeStrip(TIFF* tif, uint32 row, uint16 sample) { + static const char module[] = "TIFFComputeStrip"; TIFFDirectory *td = &tif->tif_dir; tstrip_t strip; strip = row / td->td_rowsperstrip; if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { if (sample >= td->td_samplesperpixel) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + TIFFErrorExt(tif->tif_clientdata, module, "%lu: Sample out of range, max %lu", (unsigned long) sample, (unsigned long) td->td_samplesperpixel); - return ((tstrip_t) 0); + return (0); } - strip += sample*td->td_stripsperimage; + strip += (uint32)sample*td->td_stripsperimage; } return (strip); } @@ -150,7 +151,7 @@ TIFFVStripSize(TIFF* tif, uint32 nrows) samplingblocks_hor=TIFFhowmany_32(td->td_imagewidth,ycbcrsubsampling[0]); samplingblocks_ver=TIFFhowmany_32(nrows,ycbcrsubsampling[1]); samplingrow_samples=multiply_64(tif,samplingblocks_hor,samplingblock_samples,module); - samplingrow_size=TIFFhowmany_64(multiply_64(tif,samplingrow_samples,td->td_bitspersample,module),8); + samplingrow_size=TIFFhowmany8_64(multiply_64(tif,samplingrow_samples,td->td_bitspersample,module)); return(multiply_64(tif,samplingrow_size,samplingblocks_ver,module)); } else return(multiply_64(tif,nrows,TIFFScanlineSize(tif),module)); @@ -160,17 +161,19 @@ TIFFVStripSize(TIFF* tif, uint32 nrows) /* * Compute the # bytes in a raw strip. */ -tsize_t -TIFFRawStripSize(TIFF* tif, tstrip_t strip) +uint64 +TIFFRawStripSize(TIFF* tif, uint32 strip) { + static const char module[] = "TIFFRawStripSize"; TIFFDirectory* td = &tif->tif_dir; - tsize_t bytecount = td->td_stripbytecount[strip]; + uint64 bytecount = td->td_stripbytecount[strip]; - if (bytecount <= 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%lu: Invalid strip byte count, strip %lu", - (unsigned long) bytecount, (unsigned long) strip); - bytecount = (tsize_t) -1; + if (bytecount == 0) + { + TIFFErrorExt(tif->tif_clientdata, module, + "%llu: Invalid strip byte count, strip %lu", + (unsigned long long) bytecount, (unsigned long) strip); + bytecount = (uint64) -1; } return bytecount; diff --git a/libtiff/tif_swab.c b/libtiff/tif_swab.c index 6122be7c..022ffbf5 100644 --- a/libtiff/tif_swab.c +++ b/libtiff/tif_swab.c @@ -1,4 +1,4 @@ -/* $Id: tif_swab.c,v 1.6 2007-03-22 02:08:21 joris Exp $ */ +/* $Id: tif_swab.c,v 1.7 2007-03-31 01:04:53 joris Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -70,7 +70,7 @@ TIFFSwabLong8(uint64* lp) #ifndef TIFFSwabArrayOfShort void -TIFFSwabArrayOfShort(uint16* wp, register unsigned long n) +TIFFSwabArrayOfShort(register uint16* wp, uint64 n) { register unsigned char* cp; register unsigned char t; @@ -86,7 +86,7 @@ TIFFSwabArrayOfShort(uint16* wp, register unsigned long n) #ifndef TIFFSwabArrayOfTriples void -TIFFSwabArrayOfTriples(uint8* tp, unsigned long n) +TIFFSwabArrayOfTriples(register uint8* tp, uint64 n) { unsigned char* cp; unsigned char t; @@ -102,7 +102,7 @@ TIFFSwabArrayOfTriples(uint8* tp, unsigned long n) #ifndef TIFFSwabArrayOfLong void -TIFFSwabArrayOfLong(register uint32* lp, register unsigned long n) +TIFFSwabArrayOfLong(register uint32* lp, uint64 n) { register unsigned char *cp; register unsigned char t; @@ -140,8 +140,8 @@ TIFFSwabArrayOfLong8(register uint64* lp, register unsigned long n) void TIFFSwabDouble(double *dp) { - register uint32* lp = (uint32*) dp; - uint32 t; + register uint32* lp = (uint32*) dp; + uint32 t; TIFFSwabArrayOfLong(lp, 2); t = lp[0]; lp[0] = lp[1]; lp[1] = t; @@ -150,7 +150,7 @@ TIFFSwabDouble(double *dp) #ifndef TIFFSwabArrayOfDouble void -TIFFSwabArrayOfDouble(double* dp, register unsigned long n) +TIFFSwabArrayOfDouble(double* dp, uint64 n) { register uint32* lp = (uint32*) dp; register uint32 t; @@ -248,7 +248,7 @@ TIFFGetBitRevTable(int reversed) } void -TIFFReverseBits(register unsigned char* cp, register unsigned long n) +TIFFReverseBits(uint8* cp, uint64 n) { for (; n > 8; n -= 8) { cp[0] = TIFFBitRevTable[cp[0]]; diff --git a/libtiff/tif_thunder.c b/libtiff/tif_thunder.c index 98bad203..3e7dd911 100644 --- a/libtiff/tif_thunder.c +++ b/libtiff/tif_thunder.c @@ -1,4 +1,4 @@ -/* $Id: tif_thunder.c,v 1.5 2005-12-21 12:23:13 joris Exp $ */ +/* $Id: tif_thunder.c,v 1.6 2007-03-31 01:04:53 joris Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -72,7 +72,7 @@ ThunderDecode(TIFF* tif, tidata_t op, tsize_t maxpixels) tsize_t npixels; bp = (unsigned char *)tif->tif_rawcp; - cc = tif->tif_rawcc; + cc = tif->tif_rawcc; ddd lastpixel = 0; npixels = 0; while (cc > 0 && npixels < maxpixels) { @@ -119,7 +119,7 @@ ThunderDecode(TIFF* tif, tidata_t op, tsize_t maxpixels) } } tif->tif_rawcp = (tidata_t) bp; - tif->tif_rawcc = cc; + tif->tif_rawcc = cc; ddd if (npixels != maxpixels) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "ThunderDecode: %s data at scanline %ld (%lu != %lu)", @@ -131,7 +131,7 @@ ThunderDecode(TIFF* tif, tidata_t op, tsize_t maxpixels) } static int -ThunderDecodeRow(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) +ThunderDecodeRow(TIFF* tif, tidata_t buf, tsize_t occ, uint16 s) { tidata_t row = buf; @@ -139,8 +139,8 @@ ThunderDecodeRow(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s) while ((long)occ > 0) { if (!ThunderDecode(tif, row, tif->tif_dir.td_imagewidth)) return (0); - occ -= tif->tif_scanlinesize; - row += tif->tif_scanlinesize; + occ -= tif->tif_scanlinesize; ddd + row += tif->tif_scanlinesize; ddd } return (1); } @@ -149,8 +149,8 @@ int TIFFInitThunderScan(TIFF* tif, int scheme) { (void) scheme; - tif->tif_decoderow = ThunderDecodeRow; - tif->tif_decodestrip = ThunderDecodeRow; + tif->tif_decoderow = ThunderDecodeRow; ddd + tif->tif_decodestrip = ThunderDecodeRow; ddd return (1); } #endif /* THUNDER_SUPPORT */ diff --git a/libtiff/tif_tile.c b/libtiff/tif_tile.c index 025c02f1..3c9add8e 100644 --- a/libtiff/tif_tile.c +++ b/libtiff/tif_tile.c @@ -1,4 +1,4 @@ -/* $Id: tif_tile.c,v 1.13 2007-03-28 02:50:41 joris Exp $ */ +/* $Id: tif_tile.c,v 1.14 2007-03-31 01:04:53 joris Exp $ */ /* * Copyright (c) 1991-1997 Sam Leffler @@ -32,16 +32,12 @@ #include "tiffiop.h" static uint32 -summarize(TIFF* tif, size_t summand1, size_t summand2, const char* where) ddd +summarize_32(TIFF* tif, uint32 summand1, uint32 summand2, const char* where) { - /* - * XXX: We are using casting to uint32 here, because sizeof(size_t) - * may be larger than sizeof(uint32) on 64-bit architectures. - */ - uint32 bytes = summand1 + summand2; + uint32 bytes = summand1 + summand2; if (bytes - summand1 != summand2) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Integer overflow in %s", where); + TIFFErrorExt(tif->tif_clientdata, where, "Integer overflow in %s", where); bytes = 0; } @@ -49,12 +45,25 @@ summarize(TIFF* tif, size_t summand1, size_t summand2, const char* where) ddd } static uint32 -multiply(TIFF* tif, size_t nmemb, size_t elem_size, const char* where) ddd +multiply_32(TIFF* tif, uint32 nmemb, uint32 elem_size, const char* where) { - uint32 bytes = nmemb * elem_size; + uint32 bytes = nmemb * elem_size; if (elem_size && bytes / elem_size != nmemb) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Integer overflow in %s", where); + TIFFErrorExt(tif->tif_clientdata, where, "Integer overflow in %s", where); + bytes = 0; + } + + return (bytes); +} + +static uint64 +multiply_64(TIFF* tif, uint64 nmemb, uint64 elem_size, const char* where) +{ + uint64 bytes = nmemb * elem_size; + + if (elem_size && bytes / elem_size != nmemb) { + TIFFErrorExt(tif->tif_clientdata, where, "Integer overflow in %s", where); bytes = 0; } @@ -64,14 +73,14 @@ multiply(TIFF* tif, size_t nmemb, size_t elem_size, const char* where) ddd /* * Compute which tile an (x,y,z,s) value is in. */ -ttile_t -TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, tsample_t s) +uint32 +TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s) { TIFFDirectory *td = &tif->tif_dir; uint32 dx = td->td_tilewidth; uint32 dy = td->td_tilelength; uint32 dz = td->td_tiledepth; - ttile_t tile = 1; + uint32 tile = 1; if (td->td_imagedepth == 1) z = 0; @@ -82,9 +91,9 @@ TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, tsample_t s) if (dz == (uint32) -1) dz = td->td_imagedepth; if (dx != 0 && dy != 0 && dz != 0) { - uint32 xpt = TIFFhowmany(td->td_imagewidth, dx); ddd - uint32 ypt = TIFFhowmany(td->td_imagelength, dy); ddd - uint32 zpt = TIFFhowmany(td->td_imagedepth, dz); ddd + uint32 xpt = TIFFhowmany_32(td->td_imagewidth, dx); + uint32 ypt = TIFFhowmany_32(td->td_imagelength, dy); + uint32 zpt = TIFFhowmany_32(td->td_imagedepth, dz); if (td->td_planarconfig == PLANARCONFIG_SEPARATE) tile = (xpt*ypt*zpt)*s + @@ -102,7 +111,7 @@ TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, tsample_t s) * against the image bounds. */ int -TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, tsample_t s) +TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s) { TIFFDirectory *td = &tif->tif_dir; @@ -141,14 +150,14 @@ TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, tsample_t s) /* * Compute how many tiles are in an image. */ -ttile_t +uint32 TIFFNumberOfTiles(TIFF* tif) { TIFFDirectory *td = &tif->tif_dir; uint32 dx = td->td_tilewidth; uint32 dy = td->td_tilelength; uint32 dz = td->td_tiledepth; - ttile_t ntiles; + uint32 ntiles; if (dx == (uint32) -1) dx = td->td_imagewidth; @@ -157,12 +166,12 @@ TIFFNumberOfTiles(TIFF* tif) if (dz == (uint32) -1) dz = td->td_imagedepth; ntiles = (dx == 0 || dy == 0 || dz == 0) ? 0 : - multiply(tif, multiply(tif, TIFFhowmany(td->td_imagewidth, dx), ddd ddd ddd - TIFFhowmany(td->td_imagelength, dy), ddd + multiply_32(tif, multiply_32(tif, TIFFhowmany_32(td->td_imagewidth, dx), + TIFFhowmany_32(td->td_imagelength, dy), "TIFFNumberOfTiles"), - TIFFhowmany(td->td_imagedepth, dz), "TIFFNumberOfTiles"); ddd + TIFFhowmany_32(td->td_imagedepth, dz), "TIFFNumberOfTiles"); if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - ntiles = multiply(tif, ntiles, td->td_samplesperpixel, ddd + ntiles = multiply_32(tif, ntiles, td->td_samplesperpixel, "TIFFNumberOfTiles"); return (ntiles); } @@ -170,37 +179,37 @@ TIFFNumberOfTiles(TIFF* tif) /* * Compute the # bytes in each row of a tile. */ -tsize_t +uint64 TIFFTileRowSize(TIFF* tif) { TIFFDirectory *td = &tif->tif_dir; - tsize_t rowsize; + uint64 rowsize; if (td->td_tilelength == 0 || td->td_tilewidth == 0) - return ((tsize_t) 0); - rowsize = multiply(tif, td->td_bitspersample, td->td_tilewidth, ddd + return (0); + rowsize = multiply_64(tif, td->td_bitspersample, td->td_tilewidth, "TIFFTileRowSize"); if (td->td_planarconfig == PLANARCONFIG_CONTIG) - rowsize = multiply(tif, rowsize, td->td_samplesperpixel, ddd + rowsize = multiply_64(tif, rowsize, td->td_samplesperpixel, "TIFFTileRowSize"); - return ((tsize_t) TIFFhowmany8(rowsize)); ddd + return (TIFFhowmany8_64(rowsize)); } /* * Compute the # bytes in a variable length, row-aligned tile. */ -tsize_t -TIFFVTileSize(TIFF* tif, uint32 nrows) ddd +uint64 +TIFFVTileSize(TIFF* tif, uint32 nrows) { + static const char module[] = "TIFFVTileSize"; TIFFDirectory *td = &tif->tif_dir; - tsize_t tilesize; - if (td->td_tilelength == 0 || td->td_tilewidth == 0 || td->td_tiledepth == 0) - return ((tsize_t) 0); - if (td->td_planarconfig == PLANARCONFIG_CONTIG && - td->td_photometric == PHOTOMETRIC_YCBCR && - !isUpSampled(tif)) { + return (0); + if ((td->td_planarconfig==PLANARCONFIG_CONTIG)&& + (td->td_photometric == PHOTOMETRIC_YCBCR)&& + (!isUpSampled(tif))) + { /* * Packed YCbCr data contain one Cb+Cr for every * HorizontalSampling*VerticalSampling Y values. @@ -209,29 +218,29 @@ TIFFVTileSize(TIFF* tif, uint32 nrows) ddd * horizontal/vertical subsampling area include * YCbCr data for the extended image. */ - tsize_t w = - TIFFroundup(td->td_tilewidth, td->td_ycbcrsubsampling[0]); ddd - tsize_t rowsize = - TIFFhowmany8(multiply(tif, w, td->td_bitspersample, ddd ddd - "TIFFVTileSize")); - tsize_t samplingarea = - td->td_ycbcrsubsampling[0]*td->td_ycbcrsubsampling[1]; - if (samplingarea == 0) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Invalid YCbCr subsampling"); + uint16 ycbcrsubsampling[2]; + uint16 samplingblock_samples; + uint32 samplingblocks_hor; + uint32 samplingblocks_ver; + uint64 samplingrow_samples; + uint64 samplingrow_size; + assert(td->td_samplesperpixel==3); + TIFFGetField(tif,TIFFTAG_YCBCRSUBSAMPLING,ycbcrsubsampling+0, + ycbcrsubsampling+1); + if (ycbcrsubsampling[0]*ycbcrsubsampling[1]==0) + { + TIFFErrorExt(tif->tif_clientdata,module, + "Invalid YCbCr subsampling"); return 0; } - nrows = TIFFroundup(nrows, td->td_ycbcrsubsampling[1]); ddd - /* NB: don't need TIFFhowmany here 'cuz everything is rounded */ - tilesize = multiply(tif, nrows, rowsize, "TIFFVTileSize"); ddd - tilesize = summarize(tif, tilesize, ddd - multiply(tif, 2, tilesize / samplingarea, ddd - "TIFFVTileSize"), - "TIFFVTileSize"); + samplingblock_samples=ycbcrsubsampling[0]*ycbcrsubsampling[1]+2; + samplingblocks_hor=TIFFhowmany_32(td->td_tilewidth,ycbcrsubsampling[0]); + samplingblocks_ver=TIFFhowmany_32(nrows,ycbcrsubsampling[1]); + samplingrow_samples=multiply_64(tif,samplingblocks_hor,samplingblock_samples,module); + samplingrow_size=TIFFhowmany8_64(multiply_64(tif,samplingrow_samples,td->td_bitspersample,module)); + return(multiply_64(tif,samplingrow_size,samplingblocks_ver,module)); } else - tilesize = multiply(tif, nrows, TIFFTileRowSize(tif), ddd - "TIFFVTileSize"); - return ((tsize_t) - multiply(tif, tilesize, td->td_tiledepth, "TIFFVTileSize")); ddd + return(multiply_64(tif,nrows,TIFFTileRowSize(tif),module)); } /* @@ -265,9 +274,9 @@ _TIFFDefaultTileSize(TIFF* tif, uint32* tw, uint32* th) *th = 256; /* roundup to a multiple of 16 per the spec */ if (*tw & 0xf) - *tw = TIFFroundup(*tw, 16); ddd + *tw = TIFFroundup_32(*tw, 16); if (*th & 0xf) - *th = TIFFroundup(*th, 16); ddd + *th = TIFFroundup_32(*th, 16); } /* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/libtiff/tif_vms.c b/libtiff/tif_vms.c index 25363b66..872625ff 100644 --- a/libtiff/tif_vms.c +++ b/libtiff/tif_vms.c @@ -1,4 +1,4 @@ -/* $Id: tif_vms.c,v 1.5 2007-03-28 02:50:41 joris Exp $ */ +/* $Id: tif_vms.c,v 1.6 2007-03-31 01:04:53 joris Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler diff --git a/libtiff/tif_win32.c b/libtiff/tif_win32.c index 52963e49..3479e5ad 100644 --- a/libtiff/tif_win32.c +++ b/libtiff/tif_win32.c @@ -1,4 +1,4 @@ -/* $Id: tif_win32.c,v 1.22 2007-03-17 04:41:29 joris Exp $ */ +/* $Id: tif_win32.c,v 1.23 2007-03-31 01:04:53 joris Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -32,22 +32,24 @@ #include <windows.h> -static uint32 -_tiffReadProc(thandle_t fd, tdata_t buf, uint32 size) +static uint64 +_tiffReadProc(thandle_t fd, void* buf, uint64 size) { DWORD dwSizeRead; - if (!ReadFile(fd, buf, size, &dwSizeRead, NULL)) + assert((uint32)size==size); + if (!ReadFile(fd, buf, (uint32)size, &dwSizeRead, NULL)) return(0); - return ((tsize_t) dwSizeRead); + return ((uint64) dwSizeRead); } -static uint32 -_tiffWriteProc(thandle_t fd, tdata_t buf, uint32 size) +static uint64 +_tiffWriteProc(thandle_t fd, void* buf, uint64 size) { DWORD dwSizeWritten; - if (!WriteFile(fd, buf, size, &dwSizeWritten, NULL)) + assert((uint32)size==size); + if (!WriteFile(fd, buf, (uint32)size, &dwSizeWritten, NULL)) return(0); - return ((tsize_t) dwSizeWritten); + return ((uint64) dwSizeWritten); } static uint64 @@ -73,7 +75,7 @@ _tiffSeekProc(thandle_t fd, uint64 off, int whence) dwMoveMethod = FILE_BEGIN; break; } - return ((toff_t)SetFilePointer(fd, (LONG) li.LowPart, + return ((uint64)SetFilePointer(fd, (LONG) li.LowPart, (PLONG)&li.HighPart, dwMoveMethod)); } @@ -86,7 +88,9 @@ _tiffCloseProc(thandle_t fd) static uint64 _tiffSizeProc(thandle_t fd) { - return ((toff_t)GetFileSize(fd, NULL)); + ULARGE_INTEGER m; + m.LowPart=GetFileSize(fd,&m.HighPart); + return(m.QuadPart); } static int diff --git a/libtiff/tif_write.c b/libtiff/tif_write.c index 4423b2f5..edb363c2 100644 --- a/libtiff/tif_write.c +++ b/libtiff/tif_write.c @@ -1,26 +1,26 @@ -/* $Id: tif_write.c,v 1.23 2007-03-28 02:50:41 joris Exp $ */ +/* $Id: tif_write.c,v 1.24 2007-03-31 01:04:53 joris Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -32,26 +32,26 @@ #include "tiffiop.h" #include <stdio.h> -#define STRIPINCR 20 /* expansion factor on strip array */ +#define STRIPINCR 20 /* expansion factor on strip array */ -#define WRITECHECKSTRIPS(tif, module) \ +#define WRITECHECKSTRIPS(tif, module) \ (((tif)->tif_flags&TIFF_BEENWRITING) || TIFFWriteCheck((tif),0,module)) -#define WRITECHECKTILES(tif, module) \ +#define WRITECHECKTILES(tif, module) \ (((tif)->tif_flags&TIFF_BEENWRITING) || TIFFWriteCheck((tif),1,module)) -#define BUFFERCHECK(tif) \ +#define BUFFERCHECK(tif) \ ((((tif)->tif_flags & TIFF_BUFFERSETUP) && tif->tif_rawdata) || \ - TIFFWriteBufferSetup((tif), NULL, (tsize_t) -1)) + TIFFWriteBufferSetup((tif), NULL, (uint64) -1)) -static int TIFFGrowStrips(TIFF*, int, const char*); -static int TIFFAppendToStrip(TIFF*, tstrip_t, tidata_t, tsize_t); +static int TIFFGrowStrips(TIFF* tif, uint32 delta, const char* module); +static int TIFFAppendToStrip(TIFF* tif, uint32 strip, uint8* data, uint64 cc); int -TIFFWriteScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample) +TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample) { static const char module[] = "TIFFWriteScanline"; register TIFFDirectory *td; int status, imagegrew = 0; - tstrip_t strip; + uint32 strip; if (!WRITECHECKSTRIPS(tif, module)) return (-1); @@ -69,8 +69,8 @@ TIFFWriteScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample) */ if (row >= td->td_imagelength) { /* extend image */ if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Can not change \"ImageLength\" when using separate planes"); + TIFFErrorExt(tif->tif_clientdata, module, + "Can not change \"ImageLength\" when using separate planes"); return (-1); } td->td_imagelength = row+1; @@ -81,9 +81,9 @@ TIFFWriteScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample) */ if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { if (sample >= td->td_samplesperpixel) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "%d: Sample out of range, max %d", - sample, td->td_samplesperpixel); + TIFFErrorExt(tif->tif_clientdata, module, + "%lud: Sample out of range, max %lud", + (unsigned long) sample, (unsigned long) td->td_samplesperpixel); return (-1); } strip = sample*td->td_stripsperimage + row/td->td_rowsperstrip; @@ -112,7 +112,7 @@ TIFFWriteScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample) */ if (strip >= td->td_stripsperimage && imagegrew) td->td_stripsperimage = - TIFFhowmany(td->td_imagelength,td->td_rowsperstrip); ddd + TIFFhowmany_32(td->td_imagelength,td->td_rowsperstrip); tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { @@ -161,10 +161,10 @@ TIFFWriteScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample) tif->tif_row = row; } - /* swab if needed - note that source buffer will be altered */ - tif->tif_postdecode( tif, (tidata_t) buf, tif->tif_scanlinesize ); + /* swab if needed - note that source buffer will be altered */ + tif->tif_postdecode( tif, (uint8*) buf, tif->tif_scanlinesize ); - status = (*tif->tif_encoderow)(tif, (tidata_t) buf, + status = (*tif->tif_encoderow)(tif, (uint8*) buf, tif->tif_scanlinesize, sample); /* we are now poised at the beginning of the next row */ @@ -178,15 +178,15 @@ TIFFWriteScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample) * * NB: Image length must be setup before writing. */ -tsize_t -TIFFWriteEncodedStrip(TIFF* tif, tstrip_t strip, tdata_t data, tsize_t cc) +uint64 +TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, uint64 cc) { static const char module[] = "TIFFWriteEncodedStrip"; TIFFDirectory *td = &tif->tif_dir; - tsample_t sample; + uint16 sample; if (!WRITECHECKSTRIPS(tif, module)) - return ((tsize_t) -1); + return ((uint64) -1); /* * Check strip array to make sure there's space. * We don't support dynamically growing files that @@ -198,14 +198,14 @@ TIFFWriteEncodedStrip(TIFF* tif, tstrip_t strip, tdata_t data, tsize_t cc) */ if (strip >= td->td_nstrips) { if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Can not grow image by strips when using separate planes"); - return ((tsize_t) -1); + TIFFErrorExt(tif->tif_clientdata, module, + "Can not grow image by strips when using separate planes"); + return ((uint64) -1); } if (!TIFFGrowStrips(tif, 1, module)) - return ((tsize_t) -1); + return ((uint64) -1); td->td_stripsperimage = - TIFFhowmany(td->td_imagelength, td->td_rowsperstrip); ddd + TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip); } /* * Handle delayed allocation of data buffer. This @@ -213,45 +213,45 @@ TIFFWriteEncodedStrip(TIFF* tif, tstrip_t strip, tdata_t data, tsize_t cc) * info. */ if (!BUFFERCHECK(tif)) - return ((tsize_t) -1); + return ((uint64) -1); tif->tif_curstrip = strip; tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { if (!(*tif->tif_setupencode)(tif)) - return ((tsize_t) -1); + return ((uint64) -1); tif->tif_flags |= TIFF_CODERSETUP; } tif->tif_rawcc = 0; - tif->tif_rawcp = tif->tif_rawdata; + tif->tif_rawcp = tif->tif_rawdata; - if( td->td_stripbytecount[strip] > 0 ) + if( td->td_stripbytecount[strip] > 0 ) { /* if we are writing over existing tiles, zero length. */ - td->td_stripbytecount[strip] = 0; + td->td_stripbytecount[strip] = 0; - /* this forces TIFFAppendToStrip() to do a seek */ + /* this forces TIFFAppendToStrip() to do a seek */ tif->tif_curoff = 0; } tif->tif_flags &= ~TIFF_POSTENCODE; - sample = (tsample_t)(strip / td->td_stripsperimage); + sample = (uint16)(strip / td->td_stripsperimage); if (!(*tif->tif_preencode)(tif, sample)) - return ((tsize_t) -1); + return ((uint64) -1); /* swab if needed - note that source buffer will be altered */ - tif->tif_postdecode( tif, (tidata_t) data, cc ); + tif->tif_postdecode( tif, (uint8*) data, cc ); - if (!(*tif->tif_encodestrip)(tif, (tidata_t) data, cc, sample)) - return ((tsize_t) 0); + if (!(*tif->tif_encodestrip)(tif, (uint8*) data, cc, sample)) + return (0); if (!(*tif->tif_postencode)(tif)) - return ((tsize_t) -1); + return ((uint64) -1); if (!isFillOrder(tif, td->td_fillorder) && (tif->tif_flags & TIFF_NOBITREV) == 0) TIFFReverseBits(tif->tif_rawdata, tif->tif_rawcc); if (tif->tif_rawcc > 0 && !TIFFAppendToStrip(tif, strip, tif->tif_rawdata, tif->tif_rawcc)) - return ((tsize_t) -1); + return ((uint64) -1); tif->tif_rawcc = 0; tif->tif_rawcp = tif->tif_rawdata; return (cc); @@ -262,14 +262,14 @@ TIFFWriteEncodedStrip(TIFF* tif, tstrip_t strip, tdata_t data, tsize_t cc) * * NB: Image length must be setup before writing. */ -tsize_t -TIFFWriteRawStrip(TIFF* tif, tstrip_t strip, tdata_t data, tsize_t cc) +uint64 +TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, uint64 cc) { static const char module[] = "TIFFWriteRawStrip"; TIFFDirectory *td = &tif->tif_dir; if (!WRITECHECKSTRIPS(tif, module)) - return ((tsize_t) -1); + return ((uint64) -1); /* * Check strip array to make sure there's space. * We don't support dynamically growing files that @@ -281,9 +281,9 @@ TIFFWriteRawStrip(TIFF* tif, tstrip_t strip, tdata_t data, tsize_t cc) */ if (strip >= td->td_nstrips) { if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { - TIFFErrorExt(tif->tif_clientdata, tif->tif_name, - "Can not grow image by strips when using separate planes"); - return ((tsize_t) -1); + TIFFErrorExt(tif->tif_clientdata, module, + "Can not grow image by strips when using separate planes"); + return ((uint64) -1); } /* * Watch out for a growing image. The value of @@ -292,23 +292,22 @@ TIFFWriteRawStrip(TIFF* tif, tstrip_t strip, tdata_t data, tsize_t cc) */ if (strip >= td->td_stripsperimage) td->td_stripsperimage = - TIFFhowmany(td->td_imagelength,td->td_rowsperstrip); ddd + TIFFhowmany_32(td->td_imagelength,td->td_rowsperstrip); if (!TIFFGrowStrips(tif, 1, module)) - return ((tsize_t) -1); + return ((uint64) -1); } tif->tif_curstrip = strip; tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; - return (TIFFAppendToStrip(tif, strip, (tidata_t) data, cc) ? - cc : (tsize_t) -1); + return (TIFFAppendToStrip(tif, strip, (uint8*) data, cc) ? + cc : (uint64) -1); } /* * Write and compress a tile of data. The * tile is selected by the (x,y,z,s) coordinates. */ -tsize_t -TIFFWriteTile(TIFF* tif, - tdata_t buf, uint32 x, uint32 y, uint32 z, tsample_t s) +uint64 +TIFFWriteTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s) { if (!TIFFCheckTile(tif, x, y, z, s)) return (-1); @@ -319,7 +318,7 @@ TIFFWriteTile(TIFF* tif, * after the output buffer is setup in TIFFWriteBufferSetup. */ return (TIFFWriteEncodedTile(tif, - TIFFComputeTile(tif, x, y, z, s), buf, (tsize_t) -1)); + TIFFComputeTile(tif, x, y, z, s), buf, (uint64) -1)); } /* @@ -339,14 +338,14 @@ TIFFWriteEncodedTile(TIFF* tif, ttile_t tile, tdata_t data, tsize_t cc) { static const char module[] = "TIFFWriteEncodedTile"; TIFFDirectory *td; - tsample_t sample; + uint16 sample; if (!WRITECHECKTILES(tif, module)) return ((tsize_t) -1); td = &tif->tif_dir; - if (tile >= td->td_nstrips) { + if (tile >= td->td_nstrips) { ddd TIFFErrorExt(tif->tif_clientdata, module, "%s: Tile %lu out of range, max %lu", - tif->tif_name, (unsigned long) tile, (unsigned long) td->td_nstrips); + tif->tif_name, (unsigned long) tile, (unsigned long) td->td_nstrips); ddd return ((tsize_t) -1); } /* @@ -361,10 +360,10 @@ TIFFWriteEncodedTile(TIFF* tif, ttile_t tile, tdata_t data, tsize_t cc) tif->tif_rawcc = 0; tif->tif_rawcp = tif->tif_rawdata; - if( td->td_stripbytecount[tile] > 0 ) + if( td->td_stripbytecount[tile] > 0 ) { /* if we are writing over existing tiles, zero length. */ - td->td_stripbytecount[tile] = 0; + td->td_stripbytecount[tile] = 0; /* this forces TIFFAppendToStrip() to do a seek */ tif->tif_curoff = 0; @@ -385,7 +384,7 @@ TIFFWriteEncodedTile(TIFF* tif, ttile_t tile, tdata_t data, tsize_t cc) tif->tif_flags |= TIFF_CODERSETUP; } tif->tif_flags &= ~TIFF_POSTENCODE; - sample = (tsample_t)(tile/td->td_stripsperimage); + sample = (uint16)(tile/td->td_stripsperimage); if (!(*tif->tif_preencode)(tif, sample)) return ((tsize_t) -1); /* @@ -393,21 +392,21 @@ TIFFWriteEncodedTile(TIFF* tif, ttile_t tile, tdata_t data, tsize_t cc) * done so that callers can pass in some large number * (e.g. -1) and have the tile size used instead. */ - if ( cc < 1 || cc > tif->tif_tilesize) - cc = tif->tif_tilesize; + if ( cc < 1 || cc > tif->tif_tilesize) ddd + cc = tif->tif_tilesize; ddd /* swab if needed - note that source buffer will be altered */ - tif->tif_postdecode( tif, (tidata_t) data, cc ); + tif->tif_postdecode( tif, (tidata_t) data, cc ); ddd - if (!(*tif->tif_encodetile)(tif, (tidata_t) data, cc, sample)) + if (!(*tif->tif_encodetile)(tif, (tidata_t) data, cc, sample)) ddd return ((tsize_t) 0); if (!(*tif->tif_postencode)(tif)) return ((tsize_t) -1); if (!isFillOrder(tif, td->td_fillorder) && (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits((unsigned char *)tif->tif_rawdata, tif->tif_rawcc); - if (tif->tif_rawcc > 0 && !TIFFAppendToStrip(tif, tile, - tif->tif_rawdata, tif->tif_rawcc)) + TIFFReverseBits((unsigned char *)tif->tif_rawdata, tif->tif_rawcc); ddd + if (tif->tif_rawcc > 0 && !TIFFAppendToStrip(tif, tile, ddd + tif->tif_rawdata, tif->tif_rawcc)) ddd return ((tsize_t) -1); tif->tif_rawcc = 0; tif->tif_rawcp = tif->tif_rawdata; @@ -430,13 +429,13 @@ TIFFWriteRawTile(TIFF* tif, ttile_t tile, tdata_t data, tsize_t cc) if (!WRITECHECKTILES(tif, module)) return ((tsize_t) -1); - if (tile >= tif->tif_dir.td_nstrips) { + if (tile >= tif->tif_dir.td_nstrips) { ddd TIFFErrorExt(tif->tif_clientdata, module, "%s: Tile %lu out of range, max %lu", tif->tif_name, (unsigned long) tile, - (unsigned long) tif->tif_dir.td_nstrips); + (unsigned long) tif->tif_dir.td_nstrips); ddd return ((tsize_t) -1); } - return (TIFFAppendToStrip(tif, tile, (tidata_t) data, cc) ? + return (TIFFAppendToStrip(tif, tile, (tidata_t) data, cc) ? ddd cc : (tsize_t) -1); } @@ -449,28 +448,28 @@ TIFFSetupStrips(TIFF* tif) TIFFDirectory* td = &tif->tif_dir; if (isTiled(tif)) - td->td_stripsperimage = + td->td_stripsperimage = ddd isUnspecified(tif, FIELD_TILEDIMENSIONS) ? - td->td_samplesperpixel : TIFFNumberOfTiles(tif); + td->td_samplesperpixel : TIFFNumberOfTiles(tif); ddd else - td->td_stripsperimage = + td->td_stripsperimage = ddd isUnspecified(tif, FIELD_ROWSPERSTRIP) ? td->td_samplesperpixel : TIFFNumberOfStrips(tif); ddd - td->td_nstrips = td->td_stripsperimage; + td->td_nstrips = td->td_stripsperimage; ddd if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - td->td_stripsperimage /= td->td_samplesperpixel; - td->td_stripoffset = (uint32 *) - _TIFFmalloc(td->td_nstrips * sizeof (uint32)); - td->td_stripbytecount = (uint32 *) - _TIFFmalloc(td->td_nstrips * sizeof (uint32)); - if (td->td_stripoffset == NULL || td->td_stripbytecount == NULL) + td->td_stripsperimage /= td->td_samplesperpixel; ddd + td->td_stripoffset = (uint32 *) ddd + _TIFFmalloc(td->td_nstrips * sizeof (uint32)); ddd + td->td_stripbytecount = (uint32 *) ddd + _TIFFmalloc(td->td_nstrips * sizeof (uint32)); ddd + if (td->td_stripoffset == NULL || td->td_stripbytecount == NULL) ddd return (0); /* * Place data at the end-of-file * (by setting offsets to zero). */ - _TIFFmemset(td->td_stripoffset, 0, td->td_nstrips*sizeof (uint32)); - _TIFFmemset(td->td_stripbytecount, 0, td->td_nstrips*sizeof (uint32)); + _TIFFmemset(td->td_stripoffset, 0, td->td_nstrips*sizeof (uint32)); ddd + _TIFFmemset(td->td_stripbytecount, 0, td->td_nstrips*sizeof (uint32)); ddd TIFFSetFieldBit(tif, FIELD_STRIPOFFSETS); TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS); return (1); @@ -530,7 +529,7 @@ TIFFWriteCheck(TIFF* tif, int tiles, const char* module) return (0); } } - if (tif->tif_dir.td_stripoffset == NULL && !TIFFSetupStrips(tif)) { + if (tif->tif_dir.td_stripoffset == NULL && !TIFFSetupStrips(tif)) { ddd tif->tif_dir.td_nstrips = 0; TIFFErrorExt(tif->tif_clientdata, module, "%s: No space for %s arrays", tif->tif_name, isTiled(tif) ? "tile" : "strip"); @@ -546,10 +545,11 @@ TIFFWriteCheck(TIFF* tif, int tiles, const char* module) * Setup the raw data buffer used for encoding. */ int -TIFFWriteBufferSetup(TIFF* tif, tdata_t bp, tsize_t size) +TIFFWriteBufferSetup(TIFF* tif, void* bp, uint64 size) { static const char module[] = "TIFFWriteBufferSetup"; + ddd if (tif->tif_rawdata) { if (tif->tif_flags & TIFF_MYBUFFER) { _TIFFfree(tif->tif_rawdata); @@ -578,7 +578,7 @@ TIFFWriteBufferSetup(TIFF* tif, tdata_t bp, tsize_t size) } else tif->tif_flags &= ~TIFF_MYBUFFER; tif->tif_rawdata = (tidata_t) bp; - tif->tif_rawdatasize = size; + tif->tif_rawdatasize = size; ddd tif->tif_rawcc = 0; tif->tif_rawcp = tif->tif_rawdata; tif->tif_flags |= TIFF_BUFFERSETUP; @@ -589,16 +589,17 @@ TIFFWriteBufferSetup(TIFF* tif, tdata_t bp, tsize_t size) * Grow the strip data structures by delta strips. */ static int -TIFFGrowStrips(TIFF* tif, int delta, const char* module) +TIFFGrowStrips(TIFF* tif, uint32 delta, const char* module) { + ddd TIFFDirectory *td = &tif->tif_dir; uint32 *new_stripoffset, *new_stripbytecount; assert(td->td_planarconfig == PLANARCONFIG_CONTIG); - new_stripoffset = (uint32*)_TIFFrealloc(td->td_stripoffset, - (td->td_nstrips + delta) * sizeof (uint32)); - new_stripbytecount = (uint32*)_TIFFrealloc(td->td_stripbytecount, - (td->td_nstrips + delta) * sizeof (uint32)); + new_stripoffset = (uint32*)_TIFFrealloc(td->td_stripoffset, ddd + (td->td_nstrips + delta) * sizeof (uint32)); ddd + new_stripbytecount = (uint32*)_TIFFrealloc(td->td_stripbytecount, ddd + (td->td_nstrips + delta) * sizeof (uint32)); ddd if (new_stripoffset == NULL || new_stripbytecount == NULL) { if (new_stripoffset) _TIFFfree(new_stripoffset); @@ -609,13 +610,13 @@ TIFFGrowStrips(TIFF* tif, int delta, const char* module) tif->tif_name); return (0); } - td->td_stripoffset = new_stripoffset; - td->td_stripbytecount = new_stripbytecount; - _TIFFmemset(td->td_stripoffset + td->td_nstrips, + td->td_stripoffset = new_stripoffset; ddd + td->td_stripbytecount = new_stripbytecount; ddd + _TIFFmemset(td->td_stripoffset + td->td_nstrips, ddd 0, delta*sizeof (uint32)); - _TIFFmemset(td->td_stripbytecount + td->td_nstrips, + _TIFFmemset(td->td_stripbytecount + td->td_nstrips, ddd 0, delta*sizeof (uint32)); - td->td_nstrips += delta; + td->td_nstrips += delta; ddd return (1); } @@ -623,17 +624,18 @@ TIFFGrowStrips(TIFF* tif, int delta, const char* module) * Append the data to the specified strip. */ static int -TIFFAppendToStrip(TIFF* tif, tstrip_t strip, tidata_t data, tsize_t cc) +TIFFAppendToStrip(TIFF* tif, uint32 strip, uint8* data, uint64 cc) { + ddd TIFFDirectory *td = &tif->tif_dir; static const char module[] = "TIFFAppendToStrip"; - if (td->td_stripoffset[strip] == 0 || tif->tif_curoff == 0) { + if (td->td_stripoffset[strip] == 0 || tif->tif_curoff == 0) { ddd /* * No current offset, set the current strip. */ - assert(td->td_nstrips > 0); - if (td->td_stripoffset[strip] != 0) { + assert(td->td_nstrips > 0); + if (td->td_stripoffset[strip] != 0) { ddd /* * Prevent overlapping of the data chunks. We need * this to enable in place updating of the compressed @@ -641,23 +643,23 @@ TIFFAppendToStrip(TIFF* tif, tstrip_t strip, tidata_t data, tsize_t cc) * the file without any optimization of the spare * space, so such scheme is not too much effective. */ - if (td->td_stripbytecountsorted) { - if (strip == td->td_nstrips - 1 - || td->td_stripoffset[strip + 1] < - td->td_stripoffset[strip] + cc) { - td->td_stripoffset[strip] = + if (td->td_stripbytecountsorted) { + if (strip == td->td_nstrips - 1 ddd + || td->td_stripoffset[strip + 1] < ddd + td->td_stripoffset[strip] + cc) { ddd + td->td_stripoffset[strip] = ddd TIFFSeekFile(tif, (toff_t)0, SEEK_END); td->td_stripbytecountsorted = 0; } } else { tstrip_t i; - for (i = 0; i < td->td_nstrips; i++) { - if (td->td_stripoffset[i] > - td->td_stripoffset[strip] - && td->td_stripoffset[i] < - td->td_stripoffset[strip] + cc) { - td->td_stripoffset[strip] = + for (i = 0; i < td->td_nstrips; i++) { ddd + if (td->td_stripoffset[i] > ddd + td->td_stripoffset[strip] ddd + && td->td_stripoffset[i] < ddd + td->td_stripoffset[strip] + cc) { ddd + td->td_stripoffset[strip] = ddd TIFFSeekFile(tif, (toff_t)0, SEEK_END); @@ -665,7 +667,7 @@ TIFFAppendToStrip(TIFF* tif, tstrip_t strip, tidata_t data, tsize_t cc) } } - if (!SeekOK(tif, td->td_stripoffset[strip])) { + if (!SeekOK(tif, td->td_stripoffset[strip])) { ddd TIFFErrorExt(tif->tif_clientdata, module, "%s: Seek error at scanline %lu", tif->tif_name, @@ -673,9 +675,9 @@ TIFFAppendToStrip(TIFF* tif, tstrip_t strip, tidata_t data, tsize_t cc) return (0); } } else - td->td_stripoffset[strip] = + td->td_stripoffset[strip] = ddd TIFFSeekFile(tif, (toff_t) 0, SEEK_END); - tif->tif_curoff = td->td_stripoffset[strip]; + tif->tif_curoff = td->td_stripoffset[strip]; ddd } if (!WriteOK(tif, data, cc)) { @@ -684,7 +686,7 @@ TIFFAppendToStrip(TIFF* tif, tstrip_t strip, tidata_t data, tsize_t cc) return (0); } tif->tif_curoff += cc; - td->td_stripbytecount[strip] += cc; + td->td_stripbytecount[strip] += cc; ddd return (1); } @@ -699,9 +701,9 @@ TIFFFlushData1(TIFF* tif) if (tif->tif_rawcc > 0) { if (!isFillOrder(tif, tif->tif_dir.td_fillorder) && (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits((unsigned char *)tif->tif_rawdata, - tif->tif_rawcc); - if (!TIFFAppendToStrip(tif, + TIFFReverseBits((unsigned char *)tif->tif_rawdata, ddd + tif->tif_rawcc); ddd + if (!TIFFAppendToStrip(tif, ddd isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip, tif->tif_rawdata, tif->tif_rawcc)) return (0); diff --git a/libtiff/tif_zip.c b/libtiff/tif_zip.c index 9306c842..6daab1c6 100644 --- a/libtiff/tif_zip.c +++ b/libtiff/tif_zip.c @@ -1,4 +1,4 @@ -/* $Id: tif_zip.c,v 1.11 2006-09-27 22:39:00 fwarmerdam Exp $ */ +/* $Id: tif_zip.c,v 1.12 2007-03-31 01:04:53 joris Exp $ */ /* * Copyright (c) 1995-1997 Sam Leffler @@ -81,8 +81,8 @@ typedef struct { #define DecoderState(tif) ZState(tif) #define EncoderState(tif) ZState(tif) -static int ZIPEncode(TIFF*, tidata_t, tsize_t, tsample_t); -static int ZIPDecode(TIFF*, tidata_t, tsize_t, tsample_t); +static int ZIPEncode(TIFF*, tidata_t, tsize_t, uint16); +static int ZIPDecode(TIFF*, tidata_t, tsize_t, uint16); static int ZIPSetupDecode(TIFF* tif) @@ -111,7 +111,7 @@ ZIPSetupDecode(TIFF* tif) * Setup state for decoding a strip. */ static int -ZIPPreDecode(TIFF* tif, tsample_t s) +ZIPPreDecode(TIFF* tif, uint16 s) { ZIPState* sp = DecoderState(tif); @@ -122,12 +122,12 @@ ZIPPreDecode(TIFF* tif, tsample_t s) ZIPSetupDecode(tif); sp->stream.next_in = tif->tif_rawdata; - sp->stream.avail_in = tif->tif_rawcc; + sp->stream.avail_in = tif->tif_rawcc; ddd return (inflateReset(&sp->stream) == Z_OK); } static int -ZIPDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s) +ZIPDecode(TIFF* tif, tidata_t op, tsize_t occ, uint16 s) { ZIPState* sp = DecoderState(tif); static const char module[] = "ZIPDecode"; @@ -190,7 +190,7 @@ ZIPSetupEncode(TIFF* tif) * Reset encoding state at the start of a strip. */ static int -ZIPPreEncode(TIFF* tif, tsample_t s) +ZIPPreEncode(TIFF* tif, uint16 s) { ZIPState *sp = EncoderState(tif); @@ -200,7 +200,7 @@ ZIPPreEncode(TIFF* tif, tsample_t s) ZIPSetupEncode(tif); sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = tif->tif_rawdatasize; + sp->stream.avail_out = tif->tif_rawdatasize; ddd return (deflateReset(&sp->stream) == Z_OK); } @@ -208,7 +208,7 @@ ZIPPreEncode(TIFF* tif, tsample_t s) * Encode a chunk of pixels. */ static int -ZIPEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) +ZIPEncode(TIFF* tif, tidata_t bp, tsize_t cc, uint16 s) { ZIPState *sp = EncoderState(tif); static const char module[] = "ZIPEncode"; @@ -226,10 +226,10 @@ ZIPEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s) return (0); } if (sp->stream.avail_out == 0) { - tif->tif_rawcc = tif->tif_rawdatasize; + tif->tif_rawcc = tif->tif_rawdatasize; ddd TIFFFlushData1(tif); sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = tif->tif_rawdatasize; + sp->stream.avail_out = tif->tif_rawdatasize; ddd } } while (sp->stream.avail_in > 0); return (1); @@ -252,13 +252,13 @@ ZIPPostEncode(TIFF* tif) switch (state) { case Z_STREAM_END: case Z_OK: - if ((int)sp->stream.avail_out != (int)tif->tif_rawdatasize) + if ((int)sp->stream.avail_out != (int)tif->tif_rawdatasize) ddd { - tif->tif_rawcc = - tif->tif_rawdatasize - sp->stream.avail_out; + tif->tif_rawcc = ddd + tif->tif_rawdatasize - sp->stream.avail_out; ddd TIFFFlushData1(tif); sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = tif->tif_rawdatasize; + sp->stream.avail_out = tif->tif_rawdatasize; ddd } break; default: @@ -378,15 +378,15 @@ TIFFInitZIP(TIFF* tif, int scheme) */ tif->tif_setupdecode = ZIPSetupDecode; tif->tif_predecode = ZIPPreDecode; - tif->tif_decoderow = ZIPDecode; - tif->tif_decodestrip = ZIPDecode; - tif->tif_decodetile = ZIPDecode; + tif->tif_decoderow = ZIPDecode; ddd + tif->tif_decodestrip = ZIPDecode; ddd + tif->tif_decodetile = ZIPDecode; ddd tif->tif_setupencode = ZIPSetupEncode; tif->tif_preencode = ZIPPreEncode; tif->tif_postencode = ZIPPostEncode; - tif->tif_encoderow = ZIPEncode; - tif->tif_encodestrip = ZIPEncode; - tif->tif_encodetile = ZIPEncode; + tif->tif_encoderow = ZIPEncode; ddd + tif->tif_encodestrip = ZIPEncode; ddd + tif->tif_encodetile = ZIPEncode; ddd tif->tif_cleanup = ZIPCleanup; /* * Setup predictor setup. diff --git a/libtiff/tiffio.h b/libtiff/tiffio.h index 0a2d4986..3729f65e 100644 --- a/libtiff/tiffio.h +++ b/libtiff/tiffio.h @@ -1,4 +1,4 @@ -/* $Id: tiffio.h,v 1.59 2007-03-28 02:50:41 joris Exp $ */ +/* $Id: tiffio.h,v 1.60 2007-03-31 01:04:53 joris Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -261,7 +261,7 @@ extern "C" { #endif typedef void (*TIFFErrorHandler)(const char*, const char*, va_list); typedef void (*TIFFErrorHandlerExt)(thandle_t, const char*, const char*, va_list); -typedef uint32 (*TIFFReadWriteProc)(thandle_t, tdata_t, uint32); +typedef uint64 (*TIFFReadWriteProc)(thandle_t, void*, uint64); typedef uint64 (*TIFFSeekProc)(thandle_t, uint64, int); typedef int (*TIFFCloseProc)(thandle_t); typedef uint64 (*TIFFSizeProc)(thandle_t); @@ -354,9 +354,9 @@ extern int TIFFReadEXIFDirectory(TIFF*, toff_t); extern uint64 TIFFScanlineSize(TIFF*); extern uint64 TIFFRasterScanlineSize(TIFF*); extern uint64 TIFFStripSize(TIFF*); -extern tsize_t TIFFRawStripSize(TIFF*, tstrip_t); +extern uint64 TIFFRawStripSize(TIFF* tif, uint32 strip); extern uint64 TIFFVStripSize(TIFF* tif, uint32 nrows); -extern tsize_t TIFFTileRowSize(TIFF*); +extern uint64 TIFFTileRowSize(TIFF* tif); extern uint64 TIFFTileSize(TIFF*); extern uint64 TIFFVTileSize(TIFF*, uint32); extern uint32 TIFFDefaultStripSize(TIFF*, uint32); @@ -383,10 +383,10 @@ extern uint32 TIFFCurrentRow(TIFF*); extern tdir_t TIFFCurrentDirectory(TIFF*); extern tdir_t TIFFNumberOfDirectories(TIFF*); extern uint32 TIFFCurrentDirOffset(TIFF*); -extern tstrip_t TIFFCurrentStrip(TIFF*); +extern uint32 TIFFCurrentStrip(TIFF*); extern ttile_t TIFFCurrentTile(TIFF*); -extern int TIFFReadBufferSetup(TIFF*, tdata_t, tsize_t); -extern int TIFFWriteBufferSetup(TIFF*, tdata_t, tsize_t); +extern int TIFFReadBufferSetup(TIFF* tif, void* bp, uint64 size); +extern int TIFFWriteBufferSetup(TIFF* tif, void* bp, uint64 size); extern int TIFFSetupStrips(TIFF *); extern int TIFFWriteCheck(TIFF*, int, const char *); extern void TIFFFreeDirectory(TIFF*); @@ -403,21 +403,21 @@ extern int TIFFRewriteDirectory(TIFF *); extern int TIFFReassignTagToIgnore(enum TIFFIgnoreSense, int); #if defined(c_plusplus) || defined(__cplusplus) -extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0); -extern int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t = 0); -extern int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t = 0); -extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0); -extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, - int = ORIENTATION_BOTLEFT, int = 0); +extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0); +extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0); +extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0); +extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0); +extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, + int = ORIENTATION_BOTLEFT, int = 0); #else -extern void TIFFPrintDirectory(TIFF*, FILE*, long); -extern int TIFFReadScanline(TIFF*, tdata_t, uint32, tsample_t); -extern int TIFFWriteScanline(TIFF*, tdata_t, uint32, tsample_t); -extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int); -extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int, int); +extern void TIFFPrintDirectory(TIFF*, FILE*, long); +extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample); +extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample); +extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int); +extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int, int); #endif -extern int TIFFReadRGBAStrip(TIFF*, tstrip_t, uint32 * ); +extern int TIFFReadRGBAStrip(TIFF*, uint32, uint32 * ); extern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * ); extern int TIFFRGBAImageOK(TIFF*, char [1024]); extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]); @@ -434,32 +434,30 @@ extern TIFF* TIFFClientOpen(const char*, const char*, TIFFSeekProc, TIFFCloseProc, TIFFSizeProc, TIFFMapFileProc, TIFFUnmapFileProc); -extern const char* TIFFFileName(TIFF*); -extern const char* TIFFSetFileName(TIFF*, const char *); -extern void TIFFError(const char*, const char*, ...); -extern void TIFFErrorExt(thandle_t, const char*, const char*, ...); -extern void TIFFWarning(const char*, const char*, ...); -extern void TIFFWarningExt(thandle_t, const char*, const char*, ...); -extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler); -extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt); -extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler); -extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt); -extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc); -extern ttile_t TIFFComputeTile(TIFF*, uint32, uint32, uint32, tsample_t); -extern int TIFFCheckTile(TIFF*, uint32, uint32, uint32, tsample_t); -extern ttile_t TIFFNumberOfTiles(TIFF*); -extern tsize_t TIFFReadTile(TIFF*, - tdata_t, uint32, uint32, uint32, tsample_t); -extern tsize_t TIFFWriteTile(TIFF*, - tdata_t, uint32, uint32, uint32, tsample_t); -extern tstrip_t TIFFComputeStrip(TIFF*, uint32, tsample_t); +extern const char* TIFFFileName(TIFF*); +extern const char* TIFFSetFileName(TIFF*, const char *); +extern void TIFFError(const char*, const char*, ...); +extern void TIFFErrorExt(thandle_t, const char*, const char*, ...); +extern void TIFFWarning(const char*, const char*, ...); +extern void TIFFWarningExt(thandle_t, const char*, const char*, ...); +extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler); +extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt); +extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler); +extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt); +extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc); +extern uint32 TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s); +extern int TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s); +extern uint32 TIFFNumberOfTiles(TIFF*); +extern uint64 TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s); +extern uint64 TIFFWriteTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s); +extern uint32 TIFFComputeStrip(TIFF*, uint32, uint16); extern uint32 TIFFNumberOfStrips(TIFF*); -extern tsize_t TIFFReadEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t); -extern tsize_t TIFFReadRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t); -extern tsize_t TIFFReadEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t); -extern tsize_t TIFFReadRawTile(TIFF*, ttile_t, tdata_t, tsize_t); -extern tsize_t TIFFWriteEncodedStrip(TIFF*, tstrip_t, tdata_t, tsize_t); -extern tsize_t TIFFWriteRawStrip(TIFF*, tstrip_t, tdata_t, tsize_t); +extern uint64 TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, uint64 size); +extern uint64 TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, uint64 size); +extern uint64 TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, uint64 size); +extern uint64 TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, uint64 size); +extern uint64 TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, uint64 cc); +extern uint64 TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, uint64 cc); extern tsize_t TIFFWriteEncodedTile(TIFF*, ttile_t, tdata_t, tsize_t); extern tsize_t TIFFWriteRawTile(TIFF*, ttile_t, tdata_t, tsize_t); extern int TIFFDataWidth(TIFFDataType); /* table of tag datatype widths */ @@ -468,12 +466,12 @@ extern void TIFFSwabShort(uint16*); extern void TIFFSwabLong(uint32*); extern void TIFFSwabLong8(uint64*); extern void TIFFSwabDouble(double*); -extern void TIFFSwabArrayOfShort(uint16*, unsigned long); -extern void TIFFSwabArrayOfTriples(uint8*, unsigned long); -extern void TIFFSwabArrayOfLong(uint32*, unsigned long); +extern void TIFFSwabArrayOfShort(uint16* wp, uint64 n); +extern void TIFFSwabArrayOfTriples(uint8* tp, uint64 n); +extern void TIFFSwabArrayOfLong(uint32* lp, uint64 n); extern void TIFFSwabArrayOfLong8(uint64*, unsigned long); -extern void TIFFSwabArrayOfDouble(double*, unsigned long); -extern void TIFFReverseBits(unsigned char *, unsigned long); +extern void TIFFSwabArrayOfDouble(double* dp, uint64 n); +extern void TIFFReverseBits(uint8* cp, uint64 n); extern const unsigned char* TIFFGetBitRevTable(int); #ifdef LOGLUV_PUBLIC diff --git a/libtiff/tiffiop.h b/libtiff/tiffiop.h index b3f425ea..9cbfa087 100644 --- a/libtiff/tiffiop.h +++ b/libtiff/tiffiop.h @@ -1,4 +1,4 @@ -/* $Id: tiffiop.h,v 1.53 2007-03-28 02:50:41 joris Exp $ */ +/* $Id: tiffiop.h,v 1.54 2007-03-31 01:04:53 joris Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -80,17 +80,17 @@ typedef struct client_info { /* * Typedefs for ``method pointers'' used internally. */ -typedef unsigned char tidataval_t; /* internal image data value type */ -typedef tidataval_t* tidata_t; /* reference to internal image data */ +typedef unsigned char tidataval_t; /* internal image data value type */ +typedef tidataval_t* tidata_t; /* reference to internal image data */ -typedef void (*TIFFVoidMethod)(TIFF*); -typedef int (*TIFFBoolMethod)(TIFF*); -typedef int (*TIFFPreMethod)(TIFF*, tsample_t); -typedef int (*TIFFCodeMethod)(TIFF*, tidata_t, tsize_t, tsample_t); -typedef int (*TIFFSeekMethod)(TIFF*, uint32); -typedef void (*TIFFPostMethod)(TIFF*, tidata_t, tsize_t); -typedef uint32 (*TIFFStripMethod)(TIFF*, uint32); -typedef void (*TIFFTileMethod)(TIFF*, uint32*, uint32*); +typedef void (*TIFFVoidMethod)(TIFF*); +typedef int (*TIFFBoolMethod)(TIFF*); +typedef int (*TIFFPreMethod)(TIFF*, uint16); +typedef int (*TIFFCodeMethod)(TIFF* tif, uint8* buf, uint64 size, uint16 sample); +typedef int (*TIFFSeekMethod)(TIFF*, uint32); +typedef void (*TIFFPostMethod)(TIFF*, uint8*, uint64); +typedef uint32 (*TIFFStripMethod)(TIFF*, uint32); +typedef void (*TIFFTileMethod)(TIFF*, uint32*, uint32*); struct tiff { char* tif_name; /* name of open file */ @@ -135,18 +135,18 @@ struct tiff { uint16 tif_header_size; /* file's header block and its length */ const int* tif_typeshift; /* data type shift counts */ const long* tif_typemask; /* data type masks */ - uint32 tif_row; /* current scanline */ - tdir_t tif_curdir; /* current directory (index) */ - tstrip_t tif_curstrip; /* current strip for read/write */ + uint32 tif_row; /* current scanline */ + tdir_t tif_curdir; /* current directory (index) */ + uint32 tif_curstrip; /* current strip for read/write */ toff_t tif_curoff; /* current offset for read/write */ toff_t tif_dataoff; /* current offset for writing dir */ /* SubIFD support */ uint16 tif_nsubifd; /* remaining subifds to write */ toff_t tif_subifdoff; /* offset for patching SubIFD link */ /* tiling support */ - uint32 tif_col; /* current column (offset by row too) */ - ttile_t tif_curtile; /* current tile for read/write */ - tsize_t tif_tilesize; /* # of bytes in a tile */ + uint32 tif_col; /* current column (offset by row too) */ + uint32 tif_curtile; /* current tile for read/write */ + uint64 tif_tilesize; /* # of bytes in a tile */ /* compression scheme hooks */ int tif_decodestatus; TIFFBoolMethod tif_setupdecode;/* called once before predecode */ @@ -155,12 +155,12 @@ struct tiff { int tif_encodestatus; TIFFPreMethod tif_preencode; /* pre- row/strip/tile encoding */ TIFFBoolMethod tif_postencode; /* post- row/strip/tile encoding */ - TIFFCodeMethod tif_decoderow; /* scanline decoding routine */ - TIFFCodeMethod tif_encoderow; /* scanline encoding routine */ + TIFFCodeMethod tif_decoderow; /* scanline decoding routine */ + TIFFCodeMethod tif_encoderow; /* scanline encoding routine */ TIFFCodeMethod tif_decodestrip;/* strip decoding routine */ TIFFCodeMethod tif_encodestrip;/* strip encoding routine */ - TIFFCodeMethod tif_decodetile; /* tile decoding routine */ - TIFFCodeMethod tif_encodetile; /* tile encoding routine */ + TIFFCodeMethod tif_decodetile; /* tile decoding routine */ + TIFFCodeMethod tif_encodetile; /* tile encoding routine */ TIFFVoidMethod tif_close; /* cleanup-on-close routine */ TIFFSeekMethod tif_seek; /* position within a strip routine */ TIFFVoidMethod tif_cleanup; /* cleanup state routine */ @@ -168,12 +168,12 @@ struct tiff { TIFFTileMethod tif_deftilesize;/* calculate/constrain tile size */ tidata_t tif_data; /* compression scheme private data */ /* input/output buffering */ - tsize_t tif_scanlinesize;/* # of bytes in a scanline */ - tsize_t tif_scanlineskew;/* scanline skew for reading strips */ - tidata_t tif_rawdata; /* raw data buffer */ - tsize_t tif_rawdatasize;/* # of bytes in raw data buffer */ - tidata_t tif_rawcp; /* current spot in raw buffer */ - tsize_t tif_rawcc; /* bytes unread from raw buffer */ + uint64 tif_scanlinesize;/* # of bytes in a scanline */ + tsize_t tif_scanlineskew;/* scanline skew for reading strips */ + uint8* tif_rawdata; /* raw data buffer */ + uint64 tif_rawdatasize;/* # of bytes in raw data buffer */ + uint8* tif_rawcp; /* current spot in raw buffer */ + uint64 tif_rawcc; /* bytes unread from raw buffer */ /* memory-mapped file support */ tidata_t tif_base; /* base of mapped file */ uint64 tif_size; /* size of mapped file region (bytes) @@ -208,7 +208,7 @@ struct tiff { #define TIFFWriteFile(tif, buf, size) \ ((*(tif)->tif_writeproc)((tif)->tif_clientdata,buf,size)) #define TIFFSeekFile(tif, off, whence) \ - ((*(tif)->tif_seekproc)((tif)->tif_clientdata,(toff_t)(off),whence)) + ((*(tif)->tif_seekproc)((tif)->tif_clientdata,(uint64)(off),whence)) #define TIFFCloseFile(tif) \ ((*(tif)->tif_closeproc)((tif)->tif_clientdata)) #define TIFFGetFileSize(tif) \ @@ -223,15 +223,15 @@ struct tiff { */ #ifndef ReadOK #define ReadOK(tif, buf, size) \ - (TIFFReadFile(tif, (tdata_t) buf, (tsize_t)(size)) == (tsize_t)(size)) + (TIFFReadFile(tif, (void*) buf, (uint64)(size)) == (uint64)(size)) #endif #ifndef SeekOK #define SeekOK(tif, off) \ - (TIFFSeekFile(tif, (toff_t) off, SEEK_SET) == (toff_t) off) + (TIFFSeekFile(tif, (uint64) off, SEEK_SET) == (uint64) off) #endif #ifndef WriteOK #define WriteOK(tif, buf, size) \ - (TIFFWriteFile(tif, (tdata_t) buf, (tsize_t) size) == (tsize_t) size) + (TIFFWriteFile(tif, (void*) buf, (uint64) size) == (uint64) size) #endif /* NB: the uint32 casts are to silence certain ANSI-C compilers */ @@ -251,19 +251,19 @@ struct tiff { extern "C" { #endif extern int _TIFFgetMode(const char*, const char*); -extern int _TIFFNoRowEncode(TIFF*, tidata_t, tsize_t, tsample_t); -extern int _TIFFNoStripEncode(TIFF*, tidata_t, tsize_t, tsample_t); -extern int _TIFFNoTileEncode(TIFF*, tidata_t, tsize_t, tsample_t); -extern int _TIFFNoRowDecode(TIFF*, tidata_t, tsize_t, tsample_t); -extern int _TIFFNoStripDecode(TIFF*, tidata_t, tsize_t, tsample_t); -extern int _TIFFNoTileDecode(TIFF*, tidata_t, tsize_t, tsample_t); -extern void _TIFFNoPostDecode(TIFF*, tidata_t, tsize_t); -extern int _TIFFNoPreCode (TIFF*, tsample_t); +extern int _TIFFNoRowEncode(TIFF* tif, uint8* pp, uint64 cc, uint16 s); +extern int _TIFFNoStripEncode(TIFF* tif, uint8* pp, uint64 cc, uint16 s); +extern int _TIFFNoTileEncode(TIFF*, uint8* pp, uint64 cc, uint16 s); +extern int _TIFFNoRowDecode(TIFF* tif, uint8* pp, uint64 cc, uint16 s); +extern int _TIFFNoStripDecode(TIFF* tif, uint8* pp, uint64 cc, uint16 s); +extern int _TIFFNoTileDecode(TIFF*, uint8* pp, uint64 cc, uint16 s); +extern void _TIFFNoPostDecode(TIFF* tif, uint8* buf, uint64 cc); +extern int _TIFFNoPreCode (TIFF*, uint16); extern int _TIFFNoSeek(TIFF*, uint32); -extern void _TIFFSwab16BitData(TIFF*, tidata_t, tsize_t); -extern void _TIFFSwab24BitData(TIFF*, tidata_t, tsize_t); -extern void _TIFFSwab32BitData(TIFF*, tidata_t, tsize_t); -extern void _TIFFSwab64BitData(TIFF*, tidata_t, tsize_t); +extern void _TIFFSwab16BitData(TIFF* tif, uint8* buf, uint64 cc); +extern void _TIFFSwab24BitData(TIFF* tif, uint8* buf, uint64 cc); +extern void _TIFFSwab32BitData(TIFF* tif, uint8* buf, uint64 cc); +extern void _TIFFSwab64BitData(TIFF* tif, uint8* buf, uint64 cc); extern int TIFFFlushData1(TIFF*); extern int TIFFDefaultDirectory(TIFF*); extern void _TIFFSetDefaultCompressionState(TIFF*); |