diff --git a/Modules/ThirdParty/TIFF/src/itktiff/COPYRIGHT b/Modules/ThirdParty/TIFF/src/itktiff/COPYRIGHT index 8282186151e..dc255dec691 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/COPYRIGHT +++ b/Modules/ThirdParty/TIFF/src/itktiff/COPYRIGHT @@ -1,7 +1,7 @@ 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 @@ -9,13 +9,13 @@ 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. diff --git a/Modules/ThirdParty/TIFF/src/itktiff/README b/Modules/ThirdParty/TIFF/src/itktiff/README index 3826cc8cf30..df1118d8ca9 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/README +++ b/Modules/ThirdParty/TIFF/src/itktiff/README @@ -1,13 +1,15 @@ -Header +$Header: /cvs/maptools/cvsroot/libtiff/README,v 1.7 2012-02-18 21:53:27 bfriesen Exp $ TIFF Software Distribution -------------------------- This file is just a placeholder; all the documentation is now in HTML in the html directory. To view the documentation point your -favorite WWW viewer at html/index.html; e.g. +favorite WWW viewer at html/index.html; - netscape html/index.html +e.g. + + firefox html/index.html If you don't have an HTML viewer then you can read the HTML source or fetch a PostScript version of this documentation from the directory @@ -22,7 +24,7 @@ want to do is: % su # make install -More information, email contacts, and mailing list information can be +More information, email contacts, and mailing list information can be found online at http://www.remotesensing.org/libtiff/. @@ -39,7 +41,7 @@ The legal way of saying that is: 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 @@ -47,13 +49,13 @@ 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. diff --git a/Modules/ThirdParty/TIFF/src/itktiff/RELEASE-DATE b/Modules/ThirdParty/TIFF/src/itktiff/RELEASE-DATE index 4ba9f1d8cfa..f0326d2ca57 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/RELEASE-DATE +++ b/Modules/ThirdParty/TIFF/src/itktiff/RELEASE-DATE @@ -1 +1 @@ -20050315 +20120922 diff --git a/Modules/ThirdParty/TIFF/src/itktiff/VERSION b/Modules/ThirdParty/TIFF/src/itktiff/VERSION index 2956a5b1e50..c4e41f94594 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/VERSION +++ b/Modules/ThirdParty/TIFF/src/itktiff/VERSION @@ -1 +1 @@ -4.0.0beta7 +4.0.3 diff --git a/Modules/ThirdParty/TIFF/src/itktiff/dist/newalpha b/Modules/ThirdParty/TIFF/src/itktiff/dist/newalpha deleted file mode 100755 index 3967342c81c..00000000000 --- a/Modules/ThirdParty/TIFF/src/itktiff/dist/newalpha +++ /dev/null @@ -1,8 +0,0 @@ -#! /bin/sh -# Header -if test -r tiff.alpha; then - ALPHA=`cat tiff.alpha`; rm -f tiff.alpha - echo "$ALPHA" | awk '{ printf "define ALPHA %1d\n", $3+1}' > tiff.alpha -else - echo "define ALPHA 001" >tiff.alpha -fi diff --git a/Modules/ThirdParty/TIFF/src/itktiff/dist/newversion b/Modules/ThirdParty/TIFF/src/itktiff/dist/newversion deleted file mode 100755 index 5602620a7c2..00000000000 --- a/Modules/ThirdParty/TIFF/src/itktiff/dist/newversion +++ /dev/null @@ -1,31 +0,0 @@ -#! /bin/sh -# Header -# -# TIFF Software -# -# Copyright (c) 1994-1996 Sam Leffler -# Copyright (c) 1994-1996 Silicon Graphics, Inc. -# -# 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. -# -# 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 -# OF THIS SOFTWARE. -# -rm -f tiff.version -awk ' -{ print "define TIFF_VNUM \"" $1 " (" $2 ")\"" } -' ../VERSION > tiff.version diff --git a/Modules/ThirdParty/TIFF/src/itktiff/dist/tiff.alpha b/Modules/ThirdParty/TIFF/src/itktiff/dist/tiff.alpha deleted file mode 100644 index a78fd0b8c41..00000000000 --- a/Modules/ThirdParty/TIFF/src/itktiff/dist/tiff.alpha +++ /dev/null @@ -1 +0,0 @@ -define ALPHA diff --git a/Modules/ThirdParty/TIFF/src/itktiff/dist/tiff.spec b/Modules/ThirdParty/TIFF/src/itktiff/dist/tiff.spec deleted file mode 100644 index e08e3120800..00000000000 --- a/Modules/ThirdParty/TIFF/src/itktiff/dist/tiff.spec +++ /dev/null @@ -1,68 +0,0 @@ -# Header -# -# TIFF Software -# -# Copyright (c) 1994-1997 Sam Leffler -# Copyright (c) 1994-1997 Silicon Graphics, Inc. -# -# 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. -# -# 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 -# OF THIS SOFTWARE. -# -define CUR_MAJ_VERS 1006 # Major Version number -define CUR_MIN_VERS 001 # Minor Version number -define CUR_VERS ${CUR_MAJ_VERS}${CUR_MIN_VERS}${ALPHA} -define TIFF_NAME "TIFF" - -include tiff.version -include tiff.alpha - -product tiff - id "${TIFF_NAME} Tools, Version ${TIFF_VNUM}" - inplace - - image sw - id "${TIFF_NAME} Software" - version "${CUR_VERS}" - subsys tools default - id "${TIFF_NAME} Tools & Library DSO" - exp "tiff.sw.tools" - endsubsys - subsys dev - id "${TIFF_NAME} Developement Software" - exp "tiff.sw.dev" - endsubsys - endimage - - image man - id "${TIFF_NAME} Documentation" - version "${CUR_VERS}" - subsys tools default - id "${TIFF_NAME} Tools Manual Pages" - exp "tiff.man.tools" - endsubsys - subsys dev - id "${TIFF_NAME} Library Manual Pages" - exp "tiff.man.dev" - endsubsys - subsys html - id "${TIFF_NAME} HTML Materials" - exp "tiff.man.html" - endsubsys - endimage -endproduct diff --git a/Modules/ThirdParty/TIFF/src/itktiff/dist/tiff.version b/Modules/ThirdParty/TIFF/src/itktiff/dist/tiff.version deleted file mode 100644 index 9c5a223d76f..00000000000 --- a/Modules/ThirdParty/TIFF/src/itktiff/dist/tiff.version +++ /dev/null @@ -1 +0,0 @@ -define TIFF_VNUM "3.5.7 ()" diff --git a/Modules/ThirdParty/TIFF/src/itktiff/itktiff.def b/Modules/ThirdParty/TIFF/src/itktiff/itktiff.def index 10f0bb3e690..7489cacee22 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/itktiff.def +++ b/Modules/ThirdParty/TIFF/src/itktiff/itktiff.def @@ -1,88 +1,88 @@ EXPORTS TIFFOpen - TIFFGetVersion - TIFFClose - TIFFFlush - TIFFFlushData - TIFFGetField - TIFFVGetField - TIFFGetFieldDefaulted - TIFFVGetFieldDefaulted - TIFFReadDirectory - TIFFScanlineSize - TIFFStripSize - TIFFVStripSize - TIFFTileRowSize - TIFFTileSize - TIFFVTileSize - TIFFFileno - TIFFGetMode - TIFFIsTiled - TIFFIsByteSwapped - TIFFCurrentRow - TIFFCurrentDirectory - TIFFCurrentStrip - TIFFCurrentTile - TIFFReadBufferSetup - TIFFLastDirectory - TIFFSetDirectory - TIFFSetSubDirectory - TIFFUnlinkDirectory - TIFFSetField - TIFFVSetField - TIFFWriteDirectory - TIFFRewriteDirectory - TIFFPrintDirectory - TIFFReadScanline - TIFFWriteScanline - TIFFReadRGBAImage - TIFFPrintDirectory - TIFFReadScanline - TIFFWriteScanline - TIFFReadRGBAImage - TIFFFdOpen - TIFFClientOpen - TIFFFileName - TIFFError - TIFFWarning - TIFFSetErrorHandler - TIFFSetWarningHandler - TIFFComputeTile - TIFFCheckTile - TIFFNumberOfTiles - TIFFReadTile - TIFFWriteTile - TIFFComputeStrip - TIFFNumberOfStrips - TIFFReadEncodedStrip - TIFFReadRawStrip - TIFFReadEncodedTile - TIFFReadRawTile - TIFFReadRGBATile - TIFFReadRGBAStrip - TIFFWriteEncodedStrip - TIFFWriteRawStrip - TIFFWriteEncodedTile - TIFFWriteRawTile - TIFFSetWriteOffset - TIFFSwabShort - TIFFSwabLong - TIFFSwabArrayOfShort - TIFFSwabArrayOfLong - TIFFSwabArrayOfDouble - TIFFReverseBits - TIFFGetBitRevTable - TIFFDefaultStripSize - TIFFDefaultTileSize - TIFFRasterScanlineSize - _TIFFmalloc - _TIFFrealloc - _TIFFfree - _TIFFmemset - _TIFFmemcpy - _TIFFmemcmp - TIFFCreateDirectory - TIFFDefaultStripSize + TIFFGetVersion + TIFFClose + TIFFFlush + TIFFFlushData + TIFFGetField + TIFFVGetField + TIFFGetFieldDefaulted + TIFFVGetFieldDefaulted + TIFFReadDirectory + TIFFScanlineSize + TIFFStripSize + TIFFVStripSize + TIFFTileRowSize + TIFFTileSize + TIFFVTileSize + TIFFFileno + TIFFGetMode + TIFFIsTiled + TIFFIsByteSwapped + TIFFCurrentRow + TIFFCurrentDirectory + TIFFCurrentStrip + TIFFCurrentTile + TIFFReadBufferSetup + TIFFLastDirectory + TIFFSetDirectory + TIFFSetSubDirectory + TIFFUnlinkDirectory + TIFFSetField + TIFFVSetField + TIFFWriteDirectory + TIFFRewriteDirectory + TIFFPrintDirectory + TIFFReadScanline + TIFFWriteScanline + TIFFReadRGBAImage + TIFFPrintDirectory + TIFFReadScanline + TIFFWriteScanline + TIFFReadRGBAImage + TIFFFdOpen + TIFFClientOpen + TIFFFileName + TIFFError + TIFFWarning + TIFFSetErrorHandler + TIFFSetWarningHandler + TIFFComputeTile + TIFFCheckTile + TIFFNumberOfTiles + TIFFReadTile + TIFFWriteTile + TIFFComputeStrip + TIFFNumberOfStrips + TIFFReadEncodedStrip + TIFFReadRawStrip + TIFFReadEncodedTile + TIFFReadRawTile + TIFFReadRGBATile + TIFFReadRGBAStrip + TIFFWriteEncodedStrip + TIFFWriteRawStrip + TIFFWriteEncodedTile + TIFFWriteRawTile + TIFFSetWriteOffset + TIFFSwabShort + TIFFSwabLong + TIFFSwabArrayOfShort + TIFFSwabArrayOfLong + TIFFSwabArrayOfDouble + TIFFReverseBits + TIFFGetBitRevTable + TIFFDefaultStripSize + TIFFDefaultTileSize + TIFFRasterScanlineSize + _TIFFmalloc + _TIFFrealloc + _TIFFfree + _TIFFmemset + _TIFFmemcpy + _TIFFmemcmp + TIFFCreateDirectory + TIFFDefaultStripSize diff --git a/Modules/ThirdParty/TIFF/src/itktiff/mkspans.c b/Modules/ThirdParty/TIFF/src/itktiff/mkspans.c index 5c00ef70684..68f73484666 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/mkspans.c +++ b/Modules/ThirdParty/TIFF/src/itktiff/mkspans.c @@ -4,23 +4,23 @@ * Copyright (c) 1991-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. */ diff --git a/Modules/ThirdParty/TIFF/src/itktiff/mkversion.c b/Modules/ThirdParty/TIFF/src/itktiff/mkversion.c index 761ae4f5f27..1d4ffaca23e 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/mkversion.c +++ b/Modules/ThirdParty/TIFF/src/itktiff/mkversion.c @@ -4,23 +4,23 @@ * Copyright (c) 1995-1997 Sam Leffler * Copyright (c) 1995-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. */ @@ -139,10 +139,10 @@ main(int argc, char* argv[]) fclose(fd); sprintf( tiffLibVersion, "#define TIFFLIB_VERSION %4.4s%2.2s%2.2s", - rawReleaseDate+6, + rawReleaseDate+6, rawReleaseDate+0, rawReleaseDate+3 ); - + /* * Emit the version.h file. */ @@ -159,13 +159,13 @@ main(int argc, char* argv[]) fprintf(fd, "Copyright (c) 1988-1996 Sam Leffler\\n"); fprintf(fd, "Copyright (c) 1991-1996 Silicon Graphics, Inc.\"\n"); - fprintf( fd, + fprintf( fd, "/*\n" " * This define can be used in code that requires\n" " * compilation-related definitions specific to a\n" " * version or versions of the library. Runtime\n" " * version checking should be done based on the\n" - " * string returned by TIFFGetVersion.\n" + " * string returned by TIFFGetVersion.\n" " */\n" ); fprintf(fd, "%s\n", tiffLibVersion ); diff --git a/Modules/ThirdParty/TIFF/src/itktiff/tif_dir.c b/Modules/ThirdParty/TIFF/src/itktiff/tif_dir.c index 122dcb221a1..ae1e2aa91b0 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/tif_dir.c +++ b/Modules/ThirdParty/TIFF/src/itktiff/tif_dir.c @@ -1,4 +1,4 @@ -/* $Id: tif_dir.c,v 1.107 2011-02-18 20:53:04 fwarmerdam Exp $ */ +/* $Id: tif_dir.c,v 1.113 2012-06-14 20:32:53 fwarmerdam Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -122,6 +122,10 @@ setExtraSamples(TIFFDirectory* td, va_list ap, uint32* v) #undef EXTRASAMPLE_COREL_UNASSALPHA } +/* + * Confirm we have "samplesperpixel" ink names separated by \0. Returns + * zero if the ink names are not as expected. + */ static uint32 checkInkNamesString(TIFF* tif, uint32 slen, const char* s) { @@ -132,9 +136,9 @@ checkInkNamesString(TIFF* tif, uint32 slen, const char* s) const char* ep = s+slen; const char* cp = s; for (; i > 0; i--) { - for (; *cp != '\0'; cp++) - if (cp >= ep) - goto bad; + for (; cp < ep && *cp != '\0'; cp++) {} + if (cp >= ep) + goto bad; cp++; /* skip \0 */ } return ((uint32)(cp-s)); @@ -157,8 +161,20 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) int status = 1; uint32 v32, i, v; char* s; + const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY); + uint32 standard_tag = tag; + + /* + * We want to force the custom code to be used for custom + * fields even if the tag happens to match a well known + * one - important for reinterpreted handling of standard + * tag values in custom directories (ie. EXIF) + */ + if (fip->field_bit == FIELD_CUSTOM) { + standard_tag = 0; + } - switch (tag) { + switch (standard_tag) { case TIFFTAG_SUBFILETYPE: td->td_subfiletype = (uint32) va_arg(ap, uint32); break; @@ -423,7 +439,6 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) default: { TIFFTagValue *tv; int tv_size, iCustom; - const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY); /* * This can happen if multiple images are open with different @@ -550,109 +565,108 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) goto end; } - if ((fip->field_passcount + if (fip->field_tag == TIFFTAG_DOTRANGE + && strcmp(fip->field_name,"DotRange") == 0) { + /* TODO: This is an evil exception and should not have been + handled this way ... likely best if we move it into + the directory structure with an explicit field in + libtiff 4.1 and assign it a FIELD_ value */ + uint16 v[2]; + v[0] = (uint16)va_arg(ap, int); + v[1] = (uint16)va_arg(ap, int); + _TIFFmemcpy(tv->value, &v, 4); + } + + else if (fip->field_passcount || fip->field_writecount == TIFF_VARIABLE || fip->field_writecount == TIFF_VARIABLE2 || fip->field_writecount == TIFF_SPP - || tv->count > 1) - && fip->field_tag != TIFFTAG_PAGENUMBER - && fip->field_tag != TIFFTAG_HALFTONEHINTS - && fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING - && fip->field_tag != TIFFTAG_DOTRANGE) { + || tv->count > 1) { _TIFFmemcpy(tv->value, va_arg(ap, void *), tv->count * tv_size); } else { - /* - * XXX: The following loop required to handle - * TIFFTAG_PAGENUMBER, TIFFTAG_HALFTONEHINTS, - * TIFFTAG_YCBCRSUBSAMPLING and TIFFTAG_DOTRANGE tags. - * These tags are actually arrays and should be passed as - * array pointers to TIFFSetField() function, but actually - * passed as a list of separate values. This behaviour - * must be changed in the future! - */ - int i; char *val = (char *)tv->value; - - for (i = 0; i < tv->count; i++, val += tv_size) { - switch (fip->field_type) { - case TIFF_BYTE: - case TIFF_UNDEFINED: - { - uint8 v = (uint8)va_arg(ap, int); - _TIFFmemcpy(val, &v, tv_size); - } - break; - case TIFF_SBYTE: - { - int8 v = (int8)va_arg(ap, int); - _TIFFmemcpy(val, &v, tv_size); - } - break; - case TIFF_SHORT: - { - uint16 v = (uint16)va_arg(ap, int); - _TIFFmemcpy(val, &v, tv_size); - } - break; - case TIFF_SSHORT: - { - int16 v = (int16)va_arg(ap, int); - _TIFFmemcpy(val, &v, tv_size); - } - break; - case TIFF_LONG: - case TIFF_IFD: - { - uint32 v = va_arg(ap, uint32); - _TIFFmemcpy(val, &v, tv_size); - } - break; - case TIFF_SLONG: - { - int32 v = va_arg(ap, int32); - _TIFFmemcpy(val, &v, tv_size); - } - break; - case TIFF_LONG8: - case TIFF_IFD8: - { - uint64 v = va_arg(ap, uint64); - _TIFFmemcpy(val, &v, tv_size); - } - break; - case TIFF_SLONG8: - { - int64 v = va_arg(ap, int64); - _TIFFmemcpy(val, &v, tv_size); - } - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - case TIFF_FLOAT: - { - float v = (float)va_arg(ap, double); - _TIFFmemcpy(val, &v, tv_size); - } - break; - case TIFF_DOUBLE: - { - double v = va_arg(ap, double); - _TIFFmemcpy(val, &v, tv_size); - } - break; - default: - _TIFFmemset(val, 0, tv_size); - status = 0; - break; + assert( tv->count == 1 ); + + switch (fip->field_type) { + case TIFF_BYTE: + case TIFF_UNDEFINED: + { + uint8 v = (uint8)va_arg(ap, int); + _TIFFmemcpy(val, &v, tv_size); } + break; + case TIFF_SBYTE: + { + int8 v = (int8)va_arg(ap, int); + _TIFFmemcpy(val, &v, tv_size); + } + break; + case TIFF_SHORT: + { + uint16 v = (uint16)va_arg(ap, int); + _TIFFmemcpy(val, &v, tv_size); + } + break; + case TIFF_SSHORT: + { + int16 v = (int16)va_arg(ap, int); + _TIFFmemcpy(val, &v, tv_size); + } + break; + case TIFF_LONG: + case TIFF_IFD: + { + uint32 v = va_arg(ap, uint32); + _TIFFmemcpy(val, &v, tv_size); + } + break; + case TIFF_SLONG: + { + int32 v = va_arg(ap, int32); + _TIFFmemcpy(val, &v, tv_size); + } + break; + case TIFF_LONG8: + case TIFF_IFD8: + { + uint64 v = va_arg(ap, uint64); + _TIFFmemcpy(val, &v, tv_size); + } + break; + case TIFF_SLONG8: + { + int64 v = va_arg(ap, int64); + _TIFFmemcpy(val, &v, tv_size); + } + break; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + case TIFF_FLOAT: + { + float v = (float)va_arg(ap, double); + _TIFFmemcpy(val, &v, tv_size); + } + break; + case TIFF_DOUBLE: + { + double v = va_arg(ap, double); + _TIFFmemcpy(val, &v, tv_size); + } + break; + default: + _TIFFmemset(val, 0, tv_size); + status = 0; + break; } } } } } if (status) { - TIFFSetFieldBit(tif, TIFFFieldWithTag(tif, tag)->field_bit); + const TIFFField* fip=TIFFFieldWithTag(tif,tag); + if (fip) + TIFFSetFieldBit(tif, fip->field_bit); tif->tif_flags |= TIFF_DIRTYDIRECT; } @@ -660,18 +674,24 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) va_end(ap); return (status); badvalue: - TIFFErrorExt(tif->tif_clientdata, module, + { + const TIFFField* fip=TIFFFieldWithTag(tif,tag); + TIFFErrorExt(tif->tif_clientdata, module, "%s: Bad value %u for \"%s\" tag", tif->tif_name, v, - TIFFFieldWithTag(tif, tag)->field_name); - va_end(ap); + fip ? fip->field_name : "Unknown"); + va_end(ap); + } return (0); badvalue32: - TIFFErrorExt(tif->tif_clientdata, module, + { + const TIFFField* fip=TIFFFieldWithTag(tif,tag); + TIFFErrorExt(tif->tif_clientdata, module, "%s: Bad value %u for \"%s\" tag", tif->tif_name, v32, - TIFFFieldWithTag(tif, tag)->field_name); - va_end(ap); + fip ? fip->field_name : "Unknown"); + va_end(ap); + } return (0); } @@ -787,8 +807,20 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) { TIFFDirectory* td = &tif->tif_dir; int ret_val = 1; + uint32 standard_tag = tag; + const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY); + + /* + * We want to force the custom code to be used for custom + * fields even if the tag happens to match a well known + * one - important for reinterpreted handling of standard + * tag values in custom directories (ie. EXIF) + */ + if (fip->field_bit == FIELD_CUSTOM) { + standard_tag = 0; + } - switch (tag) { + switch (standard_tag) { case TIFFTAG_SUBFILETYPE: *va_arg(ap, uint32*) = td->td_subfiletype; break; @@ -963,8 +995,6 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) break; default: { - const TIFFField* fip = - TIFFFindField(tif, tag, TIFF_ANY); int i; /* @@ -1005,84 +1035,85 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) *va_arg(ap, uint16*) = (uint16)tv->count; *va_arg(ap, void **) = tv->value; ret_val = 1; + } else if (fip->field_tag == TIFFTAG_DOTRANGE + && strcmp(fip->field_name,"DotRange") == 0) { + /* TODO: This is an evil exception and should not have been + handled this way ... likely best if we move it into + the directory structure with an explicit field in + libtiff 4.1 and assign it a FIELD_ value */ + *va_arg(ap, uint16*) = ((uint16 *)tv->value)[0]; + *va_arg(ap, uint16*) = ((uint16 *)tv->value)[1]; + ret_val = 1; } else { - if ((fip->field_type == TIFF_ASCII + if (fip->field_type == TIFF_ASCII || fip->field_readcount == TIFF_VARIABLE || fip->field_readcount == TIFF_VARIABLE2 || fip->field_readcount == TIFF_SPP - || tv->count > 1) - && fip->field_tag != TIFFTAG_PAGENUMBER - && fip->field_tag != TIFFTAG_HALFTONEHINTS - && fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING - && fip->field_tag != TIFFTAG_DOTRANGE) { + || tv->count > 1) { *va_arg(ap, void **) = tv->value; ret_val = 1; } else { - int j; char *val = (char *)tv->value; - - for (j = 0; j < tv->count; - j++, val += _TIFFDataSize(tv->info->field_type)) { - switch (fip->field_type) { - case TIFF_BYTE: - case TIFF_UNDEFINED: - *va_arg(ap, uint8*) = - *(uint8 *)val; - ret_val = 1; - break; - case TIFF_SBYTE: - *va_arg(ap, int8*) = - *(int8 *)val; - ret_val = 1; - break; - case TIFF_SHORT: - *va_arg(ap, uint16*) = - *(uint16 *)val; - ret_val = 1; - break; - case TIFF_SSHORT: - *va_arg(ap, int16*) = - *(int16 *)val; - ret_val = 1; - break; - case TIFF_LONG: - case TIFF_IFD: - *va_arg(ap, uint32*) = - *(uint32 *)val; - ret_val = 1; - break; - case TIFF_SLONG: - *va_arg(ap, int32*) = - *(int32 *)val; - ret_val = 1; - break; - case TIFF_LONG8: - case TIFF_IFD8: - *va_arg(ap, uint64*) = - *(uint64 *)val; - ret_val = 1; - break; - case TIFF_SLONG8: - *va_arg(ap, int64*) = - *(int64 *)val; - ret_val = 1; - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - case TIFF_FLOAT: - *va_arg(ap, float*) = - *(float *)val; - ret_val = 1; - break; - case TIFF_DOUBLE: - *va_arg(ap, double*) = - *(double *)val; - ret_val = 1; - break; - default: - ret_val = 0; - break; - } + assert( tv->count == 1 ); + switch (fip->field_type) { + case TIFF_BYTE: + case TIFF_UNDEFINED: + *va_arg(ap, uint8*) = + *(uint8 *)val; + ret_val = 1; + break; + case TIFF_SBYTE: + *va_arg(ap, int8*) = + *(int8 *)val; + ret_val = 1; + break; + case TIFF_SHORT: + *va_arg(ap, uint16*) = + *(uint16 *)val; + ret_val = 1; + break; + case TIFF_SSHORT: + *va_arg(ap, int16*) = + *(int16 *)val; + ret_val = 1; + break; + case TIFF_LONG: + case TIFF_IFD: + *va_arg(ap, uint32*) = + *(uint32 *)val; + ret_val = 1; + break; + case TIFF_SLONG: + *va_arg(ap, int32*) = + *(int32 *)val; + ret_val = 1; + break; + case TIFF_LONG8: + case TIFF_IFD8: + *va_arg(ap, uint64*) = + *(uint64 *)val; + ret_val = 1; + break; + case TIFF_SLONG8: + *va_arg(ap, int64*) = + *(int64 *)val; + ret_val = 1; + break; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + case TIFF_FLOAT: + *va_arg(ap, float*) = + *(float *)val; + ret_val = 1; + break; + case TIFF_DOUBLE: + *va_arg(ap, double*) = + *(double *)val; + ret_val = 1; + break; + default: + ret_val = 0; + break; } } } @@ -1206,6 +1237,35 @@ TIFFCreateDirectory(TIFF* tif) return 0; } +int +TIFFCreateCustomDirectory(TIFF* tif, const TIFFFieldArray* infoarray) +{ + TIFFDefaultDirectory(tif); + + /* + * Reset the field definitions to match the application provided list. + * Hopefully TIFFDefaultDirectory() won't have done anything irreversable + * based on it's assumption this is an image directory. + */ + _TIFFSetupFields(tif, infoarray); + + tif->tif_diroff = 0; + tif->tif_nextdiroff = 0; + tif->tif_curoff = 0; + tif->tif_row = (uint32) -1; + tif->tif_curstrip = (uint32) -1; + + return 0; +} + +int +TIFFCreateEXIFDirectory(TIFF* tif) +{ + const TIFFFieldArray* exifFieldArray; + exifFieldArray = _TIFFGetExifFields(); + return TIFFCreateCustomDirectory(tif, exifFieldArray); +} + /* * Setup a default directory structure. */ diff --git a/Modules/ThirdParty/TIFF/src/itktiff/tif_dirinfo.c b/Modules/ThirdParty/TIFF/src/itktiff/tif_dirinfo.c index c34c06f3c6d..920ffd462b9 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/tif_dirinfo.c +++ b/Modules/ThirdParty/TIFF/src/itktiff/tif_dirinfo.c @@ -1,4 +1,4 @@ -/* $Id: tif_dirinfo.c,v 1.112 2011-01-24 21:06:31 olivier Exp $ */ +/* $Id: tif_dirinfo.c,v 1.117 2012-08-19 16:56:34 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -37,7 +37,7 @@ * * NOTE: The second field (field_readcount) and third field (field_writecount) * sometimes use the values TIFF_VARIABLE (-1), TIFF_VARIABLE2 (-3) - * and TIFFTAG_SPP (-2). The macros should be used but would throw off + * and TIFF_SPP (-2). The macros should be used but would throw off * the formatting of the code, so please interprete the -1, -2 and -3 * values accordingly. */ @@ -190,9 +190,23 @@ tiffFields[] = { { TIFFTAG_ASSHOTPREPROFILEMATRIX, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "AsShotPreProfileMatrix", NULL }, { TIFFTAG_CURRENTICCPROFILE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "CurrentICCProfile", NULL }, { TIFFTAG_CURRENTPREPROFILEMATRIX, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "CurrentPreProfileMatrix", NULL }, + { TIFFTAG_PERSAMPLE, 0, 0, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "PerSample", NULL}, + /* end DNG tags */ + /* begin TIFF/FX tags */ + { TIFFTAG_INDEXED, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "Indexed" }, + { TIFFTAG_GLOBALPARAMETERSIFD, 1, 1, TIFF_IFD, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "GlobalParametersIFD", NULL }, + { TIFFTAG_PROFILETYPE, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ProfileType", NULL }, + { TIFFTAG_FAXPROFILE, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "FaxProfile", NULL }, + { TIFFTAG_CODINGMETHODS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "CodingMethods", NULL }, + { TIFFTAG_VERSIONYEAR, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "VersionYear", NULL }, + { TIFFTAG_MODENUMBER, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ModeNumber", NULL }, + { TIFFTAG_DECODE, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "Decode", NULL }, + { TIFFTAG_IMAGEBASECOLOR, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ImageBaseColor", NULL }, + { TIFFTAG_T82OPTIONS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "T82Options", NULL }, + { TIFFTAG_STRIPROWCOUNTS, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "StripRowCounts", NULL }, + { TIFFTAG_IMAGELAYER, 2, 2, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ImageLayer", NULL }, /* end DNG tags */ /* begin pseudo tags */ - { TIFFTAG_PERSAMPLE, 0, 0, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "PerSample", NULL}, }; static TIFFField @@ -348,7 +362,7 @@ _TIFFMergeFields(TIFF* tif, const TIFFField info[], uint32 n) { static const char module[] = "_TIFFMergeFields"; static const char reason[] = "for fields array"; - TIFFField** tp; + /* TIFFField** tp; */ uint32 i; tif->tif_foundfield = NULL; @@ -369,7 +383,7 @@ _TIFFMergeFields(TIFF* tif, const TIFFField info[], uint32 n) return 0; } - tp = tif->tif_fields + tif->tif_nfields; + /* tp = tif->tif_fields + tif->tif_nfields; */ for (i = 0; i < n; i++) { const TIFFField *fip = TIFFFindField(tif, info[i].field_tag, TIFF_ANY); @@ -556,6 +570,42 @@ TIFFFieldWithName(TIFF* tif, const char *field_name) return (fip); } +uint32 +TIFFFieldTag(const TIFFField* fip) +{ + return fip->field_tag; +} + +const char * +TIFFFieldName(const TIFFField* fip) +{ + return fip->field_name; +} + +TIFFDataType +TIFFFieldDataType(const TIFFField* fip) +{ + return fip->field_type; +} + +int +TIFFFieldPassCount(const TIFFField* fip) +{ + return fip->field_passcount; +} + +int +TIFFFieldReadCount(const TIFFField* fip) +{ + return fip->field_readcount; +} + +int +TIFFFieldWriteCount(const TIFFField* fip) +{ + return fip->field_writecount; +} + const TIFFField* _TIFFFindOrRegisterField(TIFF *tif, uint32 tag, TIFFDataType dt) @@ -896,75 +946,6 @@ TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], uint32 n) return 0; } -const TIFFFieldInfo* -TIFFFindFieldInfoByName(TIFF* tif, const char *field_name, TIFFDataType dt) -{ -#if 0 - TIFFFieldInfo key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, 0, NULL, NULL}; - TIFFFieldInfo* pkey = &key; - const TIFFFieldInfo **ret; - if (tif->tif_foundfield - && streq(tif->tif_foundfield->field_name, field_name) - && (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type)) - return (tif->tif_foundfield); - - /* If we are invoked with no field information, then just return. */ - if ( !tif->tif_fields ) { - return NULL; - } - - /* NB: use sorted search (e.g. binary search) */ - - key.field_name = (char *)field_name; - key.field_type = dt; - - ret = (const TIFFFieldInfo **) - td_lfind(&pkey, tif->tif_fields, &tif->tif_nfields, - sizeof(TIFFFieldInfo *), tagNameCompare ); - return tif->tif_foundfield = (ret ? *ret : NULL); -#else - (void) tif; - (void) field_name; - (void) dt; -#endif - return NULL; -} - -const TIFFFieldInfo* -TIFFFindFieldInfo(TIFF* tif, uint32 tag, TIFFDataType dt) -{ -#if 0 - TIFFFieldInfo key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, 0, NULL, NULL}; - TIFFFieldInfo* pkey = &key; - const TIFFFieldInfo **ret; - if (tif->tif_foundfield && tif->tif_foundfield->field_tag == tag && - (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type)) - return tif->tif_foundfield; - - /* If we are invoked with no field information, then just return. */ - if ( !tif->tif_fields ) { - return NULL; - } - - /* NB: use sorted search (e.g. binary search) */ - - key.field_tag = tag; - key.field_type = dt; - - ret = (const TIFFFieldInfo **) bsearch(&pkey, - tif->tif_fields, - tif->tif_nfields, - sizeof(TIFFFieldInfo *), - tagCompare); - return tif->tif_foundfield = (ret ? *ret : NULL); -#else - (void) tif; - (void) tag; - (void) dt; -#endif - return NULL; -} - /* vim: set ts=8 sts=8 sw=8 noet: */ /* diff --git a/Modules/ThirdParty/TIFF/src/itktiff/tif_dirread.c b/Modules/ThirdParty/TIFF/src/itktiff/tif_dirread.c index 9c1b18fe0ea..58c9e0feae3 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/tif_dirread.c +++ b/Modules/ThirdParty/TIFF/src/itktiff/tif_dirread.c @@ -1,4 +1,4 @@ -/* $Id: tif_dirread.c,v 1.167 2011-02-18 20:53:04 fwarmerdam Exp $ */ +/* $Id: tif_dirread.c,v 1.178 2012-08-19 16:56:34 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -3313,10 +3313,15 @@ TIFFReadDirEntryData(TIFF* tif, uint64 offset, tmsize_t size, void* dest) if (!ReadOK(tif,dest,size)) return(TIFFReadDirEntryErrIo); } else { - tmsize_t ma,mb; - ma=(tmsize_t)offset; + size_t ma,mb; + ma=(size_t)offset; mb=ma+size; - if (((uint64)ma!=offset)||(mbtif->tif_size)) + if (((uint64)ma!=offset) + || (mb < ma) + || (mb - ma != (size_t) size) + || (mb < (size_t)size) + || (mb > (size_t)tif->tif_size) + ) return(TIFFReadDirEntryErrIo); _TIFFmemcpy(dest,tif->tif_base+ma,size); } @@ -3439,6 +3444,11 @@ TIFFReadDirectory(TIFF* tif) return 0; } TIFFReadDirectoryCheckOrder(tif,dir,dircount); + + /* + * Mark duplicates of any tag to be ignored (bugzilla 1994) + * to avoid certain pathological problems. + */ { TIFFDirEntry* ma; uint16 mb; @@ -3453,6 +3463,7 @@ TIFFReadDirectory(TIFF* tif) } } } + tif->tif_flags &= ~TIFF_BEENWRITING; /* reset before new dir */ tif->tif_flags &= ~TIFF_BUF4WRITE; /* reset before new dir */ /* free any old stuff and reinit */ @@ -3592,7 +3603,8 @@ TIFFReadDirectory(TIFF* tif) if ((tif->tif_dir.td_compression==COMPRESSION_OJPEG)&& (tif->tif_dir.td_planarconfig==PLANARCONFIG_SEPARATE)) { - _TIFFFillStriles(tif); + if (!_TIFFFillStriles(tif)) + goto bad; dp=TIFFReadDirectoryFindEntry(tif,dir,dircount,TIFFTAG_STRIPOFFSETS); if ((dp!=0)&&(dp->tdir_count==1)) { @@ -3688,7 +3700,8 @@ TIFFReadDirectory(TIFF* tif) err=TIFFReadDirEntryPersampleShort(tif,dp,&value); if (err!=TIFFReadDirEntryErrOk) { - TIFFReadDirEntryOutputErr(tif,err,module,TIFFFieldWithTag(tif,dp->tdir_tag)->field_name,0); + fip = TIFFFieldWithTag(tif,dp->tdir_tag); + TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : "unknown tagname",0); goto bad; } if (!TIFFSetField(tif,dp->tdir_tag,value)) @@ -3709,7 +3722,8 @@ TIFFReadDirectory(TIFF* tif) err = TIFFReadDirEntryDoubleArray(tif, dp, &data); if (err!=TIFFReadDirEntryErrOk) { - TIFFReadDirEntryOutputErr(tif,err,module,TIFFFieldWithTag(tif,dp->tdir_tag)->field_name,0); + fip = TIFFFieldWithTag(tif,dp->tdir_tag); + TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : "unknown tagname",0); goto bad; } saved_flags = tif->tif_flags; @@ -3765,7 +3779,10 @@ TIFFReadDirectory(TIFF* tif) else err=TIFFReadDirEntryShortArray(tif,dp,&value); if (err!=TIFFReadDirEntryErrOk) - TIFFReadDirEntryOutputErr(tif,err,module,TIFFFieldWithTag(tif,dp->tdir_tag)->field_name,1); + { + fip = TIFFFieldWithTag(tif,dp->tdir_tag); + TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : "unknown tagname",1); + } else { TIFFSetField(tif,dp->tdir_tag,value,value+incrementpersample,value+2*incrementpersample); @@ -3905,8 +3922,7 @@ TIFFReadDirectory(TIFF* tif) } TIFFWarningExt(tif->tif_clientdata, module, "TIFF directory is missing required " - "\"%s\" field, calculating from imagelength", - TIFFFieldWithTag(tif,TIFFTAG_STRIPBYTECOUNTS)->field_name); + "\"StripByteCounts\" field, calculating from imagelength"); if (EstimateStripByteCounts(tif, dir, dircount) < 0) goto bad; /* @@ -3941,8 +3957,7 @@ TIFFReadDirectory(TIFF* tif) * of estimating the size of a one strip image. */ TIFFWarningExt(tif->tif_clientdata, module, - "Bogus \"%s\" field, ignoring and calculating from imagelength", - TIFFFieldWithTag(tif,TIFFTAG_STRIPBYTECOUNTS)->field_name); + "Bogus \"StripByteCounts\" field, ignoring and calculating from imagelength"); if(EstimateStripByteCounts(tif, dir, dircount) < 0) goto bad; @@ -3964,8 +3979,7 @@ TIFFReadDirectory(TIFF* tif) * information. */ TIFFWarningExt(tif->tif_clientdata, module, - "Wrong \"%s\" field, ignoring and calculating from imagelength", - TIFFFieldWithTag(tif,TIFFTAG_STRIPBYTECOUNTS)->field_name); + "Wrong \"StripByteCounts\" field, ignoring and calculating from imagelength"); if (EstimateStripByteCounts(tif, dir, dircount) < 0) goto bad; #endif /* !defined(DEFER_STRILE_LOAD) */ @@ -4021,7 +4035,11 @@ TIFFReadDirectory(TIFF* tif) (tif->tif_dir.td_nstrips==1)&& (tif->tif_dir.td_compression==COMPRESSION_NONE)&& ((tif->tif_flags&(TIFF_STRIPCHOP|TIFF_ISTILED))==TIFF_STRIPCHOP)) + { + if ( !_TIFFFillStriles(tif) || !tif->tif_dir.td_stripbytecount ) + return 0; ChopUpSingleUncompressedStrip(tif); + } /* * Clear the dirty directory flag. @@ -4260,7 +4278,7 @@ EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) TIFFDirectory *td = &tif->tif_dir; uint32 strip; - _TIFFFillStriles( tif ); + _TIFFFillStriles( tif ); if (td->td_stripbytecount) _TIFFfree(td->td_stripbytecount); @@ -4395,15 +4413,17 @@ static int CheckDirCount(TIFF* tif, TIFFDirEntry* dir, uint32 count) { if ((uint64)count > dir->tdir_count) { + const TIFFField* fip = TIFFFieldWithTag(tif, dir->tdir_tag); TIFFWarningExt(tif->tif_clientdata, tif->tif_name, "incorrect count for field \"%s\" (" TIFF_UINT64_FORMAT ", expecting %u); tag ignored", - TIFFFieldWithTag(tif, dir->tdir_tag)->field_name, + fip ? fip->field_name : "unknown tagname", dir->tdir_count, count); return (0); } else if ((uint64)count < dir->tdir_count) { + const TIFFField* fip = TIFFFieldWithTag(tif, dir->tdir_tag); TIFFWarningExt(tif->tif_clientdata, tif->tif_name, "incorrect count for field \"%s\" (" TIFF_UINT64_FORMAT ", expecting %u); tag trimmed", - TIFFFieldWithTag(tif, dir->tdir_tag)->field_name, + fip ? fip->field_name : "unknown tagname", dir->tdir_count, count); dir->tdir_count = count; return (1); @@ -4575,6 +4595,12 @@ TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir, dircount16 = (uint16)dircount64; dirsize = 20; } + if (dircount16 == 0 ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Sanity check on directory count failed, zero tag directories not supported"); + return 0; + } origdir = _TIFFCheckMalloc(tif, dircount16, dirsize, "to read TIFF directory"); @@ -4672,7 +4698,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) static const char module[] = "TIFFFetchNormalTag"; enum TIFFReadDirEntryErr err; uint32 fii; - const TIFFField* fip; + const TIFFField* fip = NULL; TIFFReadDirectoryFindFieldInfo(tif,dp->tdir_tag,&fii); if( fii == FAILED_FII ) { @@ -4740,7 +4766,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) break; case TIFF_SETGET_UINT8: { - uint8 data; + uint8 data=0; assert(fip->field_readcount==1); assert(fip->field_passcount==0); err=TIFFReadDirEntryByte(tif,dp,&data); @@ -4834,8 +4860,12 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) uint16* data; assert(fip->field_readcount==2); assert(fip->field_passcount==0); - if (dp->tdir_count!=2) + if (dp->tdir_count!=2) { + TIFFWarningExt(tif->tif_clientdata,module, + "incorrect count for field \"%s\", expected 2, got %d", + fip->field_name,(int)dp->tdir_count); return(0); + } err=TIFFReadDirEntryShortArray(tif,dp,&data); if (err==TIFFReadDirEntryErrOk) { @@ -4852,8 +4882,12 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) uint8* data; assert(fip->field_readcount>=1); assert(fip->field_passcount==0); - if (dp->tdir_count!=(uint64)fip->field_readcount) - /* corrupt file */; + if (dp->tdir_count!=(uint64)fip->field_readcount) { + TIFFWarningExt(tif->tif_clientdata,module, + "incorrect count for field \"%s\", expected %d, got %d", + fip->field_name,(int) fip->field_readcount, (int)dp->tdir_count); + return 0; + } else { err=TIFFReadDirEntryByteArray(tif,dp,&data); @@ -5321,7 +5355,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) } if (err!=TIFFReadDirEntryErrOk) { - TIFFReadDirEntryOutputErr(tif,err,module,fip->field_name,recover); + TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : "unknown tagname",recover); return(0); } return(1); @@ -5340,15 +5374,18 @@ TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, uint32 nstrips, uint64** lpp) err=TIFFReadDirEntryLong8Array(tif,dir,&data); if (err!=TIFFReadDirEntryErrOk) { - TIFFReadDirEntryOutputErr(tif,err,module,TIFFFieldWithTag(tif,dir->tdir_tag)->field_name,0); + const TIFFField* fip = TIFFFieldWithTag(tif,dir->tdir_tag); + TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : "unknown tagname",0); return(0); } if (dir->tdir_count!=(uint64)nstrips) { uint64* resizeddata; resizeddata=(uint64*)_TIFFCheckMalloc(tif,nstrips,sizeof(uint64),"for strip array"); - if (resizeddata==0) + if (resizeddata==0) { + _TIFFfree(data); return(0); + } if (dir->tdir_count<(uint64)nstrips) { _TIFFmemcpy(resizeddata,data,(uint32)dir->tdir_count*sizeof(uint64)); @@ -5443,8 +5480,6 @@ ChopUpSingleUncompressedStrip(TIFF* tif) uint64* newcounts; uint64* newoffsets; - _TIFFFillStriles(tif); - bytecount = td->td_stripbytecount[0]; offset = td->td_stripoffset[0]; assert(td->td_planarconfig == PLANARCONFIG_CONTIG); diff --git a/Modules/ThirdParty/TIFF/src/itktiff/tif_dirwrite.c b/Modules/ThirdParty/TIFF/src/itktiff/tif_dirwrite.c index 2107af5415c..5ec18f8cde2 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/tif_dirwrite.c +++ b/Modules/ThirdParty/TIFF/src/itktiff/tif_dirwrite.c @@ -1,4 +1,4 @@ -/* $Id: tif_dirwrite.c,v 1.76 2011-02-18 20:53:04 fwarmerdam Exp $ */ +/* $Id: tif_dirwrite.c,v 1.77 2012-07-06 19:18:31 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -2570,7 +2570,7 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, tmsize_t count, void* data) { static const char module[] = "TIFFResetField"; - const TIFFField* fip = NULL; + /* const TIFFField* fip = NULL; */ uint16 dircount; tmsize_t dirsize; uint8 direntry_raw[20]; @@ -2586,7 +2586,7 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, /* -------------------------------------------------------------------- */ /* Find field definition. */ /* -------------------------------------------------------------------- */ - fip = TIFFFindField(tif, tag, TIFF_ANY); + /*fip =*/ TIFFFindField(tif, tag, TIFF_ANY); /* -------------------------------------------------------------------- */ /* Do some checking this is a straight forward case. */ diff --git a/Modules/ThirdParty/TIFF/src/itktiff/tif_fax3.c b/Modules/ThirdParty/TIFF/src/itktiff/tif_fax3.c index 4623ed7f79a..233b1e0fe1f 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/tif_fax3.c +++ b/Modules/ThirdParty/TIFF/src/itktiff/tif_fax3.c @@ -1,4 +1,4 @@ -/* $Id: tif_fax3.c,v 1.72 2010-06-09 17:17:13 bfriesen Exp $ */ +/* $Id: tif_fax3.c,v 1.74 2012-06-21 02:01:31 fwarmerdam Exp $ */ /* * Copyright (c) 1990-1997 Sam Leffler @@ -526,6 +526,7 @@ Fax3SetupState(TIFF* tif) "for Group 3/4 run arrays"); if (dsp->runs == NULL) return (0); + memset( dsp->runs, 0, TIFFSafeMultiply(uint32,nruns,2)*sizeof(uint32)); dsp->curruns = dsp->runs; if (needsRefLine) dsp->refruns = dsp->runs + nruns; diff --git a/Modules/ThirdParty/TIFF/src/itktiff/tif_getimage.c b/Modules/ThirdParty/TIFF/src/itktiff/tif_getimage.c index b89ac81fb6e..7ca7afbca33 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/tif_getimage.c +++ b/Modules/ThirdParty/TIFF/src/itktiff/tif_getimage.c @@ -1,4 +1,4 @@ -/* $Id: tif_getimage.c,v 1.78 2011-02-23 21:46:09 fwarmerdam Exp $ */ +/* $Id: tif_getimage.c,v 1.82 2012-06-06 00:17:49 fwarmerdam Exp $ */ /* * Copyright (c) 1991-1997 Sam Leffler @@ -692,6 +692,7 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) unsigned char* p2; unsigned char* pa; tmsize_t tilesize; + tmsize_t bufsize; int32 fromskew, toskew; int alpha = img->alpha; uint32 nrow; @@ -699,12 +700,17 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) int colorchannels; tilesize = TIFFTileSize(tif); - buf = (unsigned char*) _TIFFmalloc((alpha?4:3)*tilesize); + bufsize = TIFFSafeMultiply(tmsize_t,alpha?4:3,tilesize); + if (bufsize == 0) { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "Integer overflow in %s", "gtTileSeparate"); + return (0); + } + buf = (unsigned char*) _TIFFmalloc(bufsize); if (buf == 0) { TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", "No space for tile buffer"); return (0); } - _TIFFmemset(buf, 0, (alpha?4:3)*tilesize); + _TIFFmemset(buf, 0, bufsize); p0 = buf; p1 = p0 + tilesize; p2 = p1 + tilesize; @@ -917,17 +923,23 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) uint32 rowsperstrip, offset_row; uint32 imagewidth = img->width; tmsize_t stripsize; + tmsize_t bufsize; int32 fromskew, toskew; int alpha = img->alpha; int ret = 1, flip, colorchannels; stripsize = TIFFStripSize(tif); - p0 = buf = (unsigned char *)_TIFFmalloc((alpha?4:3)*stripsize); + bufsize = TIFFSafeMultiply(tmsize_t,alpha?4:3,stripsize); + if (bufsize == 0) { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "Integer overflow in %s", "gtStripSeparate"); + return (0); + } + p0 = buf = (unsigned char *)_TIFFmalloc(bufsize); if (buf == 0) { TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "No space for tile buffer"); return (0); } - _TIFFmemset(buf, 0, (alpha?4:3)*stripsize); + _TIFFmemset(buf, 0, bufsize); p1 = p0 + stripsize; p2 = p1 + stripsize; pa = (alpha?(p2+stripsize):NULL); @@ -1196,6 +1208,26 @@ DECLAREContigPutFunc(putgreytile) } } +/* + * 8-bit greyscale with associated alpha => colormap/RGBA + */ +DECLAREContigPutFunc(putagreytile) +{ + int samplesperpixel = img->samplesperpixel; + uint32** BWmap = img->BWmap; + + (void) y; + while (h-- > 0) { + for (x = w; x-- > 0;) + { + *cp++ = BWmap[*pp][0] & (*(pp+1) << 24 | ~A1); + pp += samplesperpixel; + } + cp += toskew; + pp += fromskew; + } +} + /* * 16-bit greyscale => colormap/RGB */ @@ -1494,6 +1526,26 @@ DECLARESepPutFunc(putRGBAAseparate8bittile) } } +/* + * 8-bit unpacked CMYK samples => RGBA + */ +DECLARESepPutFunc(putCMYKseparate8bittile) +{ + (void) img; (void) y; + while (h-- > 0) { + uint32 rv, gv, bv, kv; + for (x = w; x-- > 0;) { + kv = 255 - *a++; + rv = (kv*(255-*r++))/255; + gv = (kv*(255-*g++))/255; + bv = (kv*(255-*b++))/255; + *cp++ = PACK4(rv,gv,bv,255); + } + SKEW4(r, g, b, a, fromskew); + cp += toskew; + } +} + /* * 8-bit unpacked samples => RGBA w/ unassociated alpha */ @@ -2461,7 +2513,10 @@ PickContigCase(TIFFRGBAImage* img) img->put.contig = put16bitbwtile; break; case 8: - img->put.contig = putgreytile; + if (img->alpha && img->samplesperpixel == 2) + img->put.contig = putagreytile; + else + img->put.contig = putgreytile; break; case 4: img->put.contig = put4bitbwtile; @@ -2540,58 +2595,65 @@ PickSeparateCase(TIFFRGBAImage* img) img->get = TIFFIsTiled(img->tif) ? gtTileSeparate : gtStripSeparate; img->put.separate = NULL; switch (img->photometric) { - case PHOTOMETRIC_MINISWHITE: - case PHOTOMETRIC_MINISBLACK: - /* greyscale images processed pretty much as RGB by gtTileSeparate */ - case PHOTOMETRIC_RGB: - switch (img->bitspersample) { - case 8: - if (img->alpha == EXTRASAMPLE_ASSOCALPHA) - img->put.separate = putRGBAAseparate8bittile; - else if (img->alpha == EXTRASAMPLE_UNASSALPHA) - { - if (BuildMapUaToAa(img)) - img->put.separate = putRGBUAseparate8bittile; - } - else - img->put.separate = putRGBseparate8bittile; - break; - case 16: - if (img->alpha == EXTRASAMPLE_ASSOCALPHA) - { - if (BuildMapBitdepth16To8(img)) - img->put.separate = putRGBAAseparate16bittile; - } - else if (img->alpha == EXTRASAMPLE_UNASSALPHA) - { - if (BuildMapBitdepth16To8(img) && - BuildMapUaToAa(img)) - img->put.separate = putRGBUAseparate16bittile; - } - else - { - if (BuildMapBitdepth16To8(img)) - img->put.separate = putRGBseparate16bittile; - } - break; + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: + /* greyscale images processed pretty much as RGB by gtTileSeparate */ + case PHOTOMETRIC_RGB: + switch (img->bitspersample) { + case 8: + if (img->alpha == EXTRASAMPLE_ASSOCALPHA) + img->put.separate = putRGBAAseparate8bittile; + else if (img->alpha == EXTRASAMPLE_UNASSALPHA) + { + if (BuildMapUaToAa(img)) + img->put.separate = putRGBUAseparate8bittile; } + else + img->put.separate = putRGBseparate8bittile; break; - case PHOTOMETRIC_YCBCR: - if ((img->bitspersample==8) && (img->samplesperpixel==3)) + case 16: + if (img->alpha == EXTRASAMPLE_ASSOCALPHA) { - if (initYCbCrConversion(img)!=0) - { - uint16 hs, vs; - TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, &hs, &vs); - switch ((hs<<4)|vs) { - case 0x11: - img->put.separate = putseparate8bitYCbCr11tile; - break; - /* TODO: add other cases here */ - } - } + if (BuildMapBitdepth16To8(img)) + img->put.separate = putRGBAAseparate16bittile; + } + else if (img->alpha == EXTRASAMPLE_UNASSALPHA) + { + if (BuildMapBitdepth16To8(img) && + BuildMapUaToAa(img)) + img->put.separate = putRGBUAseparate16bittile; + } + else + { + if (BuildMapBitdepth16To8(img)) + img->put.separate = putRGBseparate16bittile; } break; + } + break; + case PHOTOMETRIC_SEPARATED: + if (img->bitspersample == 8 && img->samplesperpixel == 4) + { + img->alpha = 1; // Not alpha, but seems like the only way to get 4th band + img->put.separate = putCMYKseparate8bittile; + } + break; + case PHOTOMETRIC_YCBCR: + if ((img->bitspersample==8) && (img->samplesperpixel==3)) + { + if (initYCbCrConversion(img)!=0) + { + uint16 hs, vs; + TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, &hs, &vs); + switch ((hs<<4)|vs) { + case 0x11: + img->put.separate = putseparate8bitYCbCr11tile; + break; + /* TODO: add other cases here */ + } + } + } + break; } return ((img->get!=NULL) && (img->put.separate!=NULL)); } diff --git a/Modules/ThirdParty/TIFF/src/itktiff/tif_jpeg.c b/Modules/ThirdParty/TIFF/src/itktiff/tif_jpeg.c index 0a09d8ea364..ef2fa9fcf6a 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/tif_jpeg.c +++ b/Modules/ThirdParty/TIFF/src/itktiff/tif_jpeg.c @@ -1,4 +1,4 @@ -/* $Id: tif_jpeg.c,v 1.101 2011-02-23 21:58:00 fwarmerdam Exp $ */ +/* $Id: tif_jpeg.c,v 1.111 2012-07-06 18:48:04 bfriesen Exp $ */ /* * Copyright (c) 1994-1997 Sam Leffler @@ -1094,50 +1094,13 @@ JPEGPreDecode(TIFF* tif, uint16 s) /* Component 0 should have expected sampling factors */ if (sp->cinfo.d.comp_info[0].h_samp_factor != sp->h_sampling || sp->cinfo.d.comp_info[0].v_samp_factor != sp->v_sampling) { - TIFFWarningExt(tif->tif_clientdata, module, - "Improper JPEG sampling factors %d,%d\n" - "Apparently should be %d,%d.", - sp->cinfo.d.comp_info[0].h_samp_factor, - sp->cinfo.d.comp_info[0].v_samp_factor, - sp->h_sampling, sp->v_sampling); - - /* - * There are potential security issues here - * for decoders that have already allocated - * buffers based on the expected sampling - * factors. Lets check the sampling factors - * dont exceed what we were expecting. - */ - if (sp->cinfo.d.comp_info[0].h_samp_factor - > sp->h_sampling - || sp->cinfo.d.comp_info[0].v_samp_factor - > sp->v_sampling) { - TIFFErrorExt(tif->tif_clientdata, - module, - "Cannot honour JPEG sampling factors" - " that exceed those specified."); - return (0); - } - - /* - * XXX: Files written by the Intergraph software - * has different sampling factors stored in the - * TIFF tags and in the JPEG structures. We will - * try to deduce Intergraph files by the presense - * of the tag 33918. - */ - if (!TIFFFindField(tif, 33918, TIFF_ANY)) { - TIFFWarningExt(tif->tif_clientdata, module, - "Decompressor will try reading with " - "sampling %d,%d.", - sp->cinfo.d.comp_info[0].h_samp_factor, - sp->cinfo.d.comp_info[0].v_samp_factor); - - sp->h_sampling = (uint16) - sp->cinfo.d.comp_info[0].h_samp_factor; - sp->v_sampling = (uint16) - sp->cinfo.d.comp_info[0].v_samp_factor; - } + TIFFErrorExt(tif->tif_clientdata, module, + "Improper JPEG sampling factors %d,%d\n" + "Apparently should be %d,%d.", + sp->cinfo.d.comp_info[0].h_samp_factor, + sp->cinfo.d.comp_info[0].v_samp_factor, + sp->h_sampling, sp->v_sampling); + return (0); } /* Rest should have sampling factors 1,1 */ for (ci = 1; ci < sp->cinfo.d.num_components; ci++) { @@ -1159,11 +1122,11 @@ JPEGPreDecode(TIFF* tif, uint16 s) if (td->td_planarconfig == PLANARCONFIG_CONTIG && sp->photometric == PHOTOMETRIC_YCBCR && sp->jpegcolormode == JPEGCOLORMODE_RGB) { - /* Convert YCbCr to RGB */ + /* Convert YCbCr to RGB */ sp->cinfo.d.jpeg_color_space = JCS_YCbCr; sp->cinfo.d.out_color_space = JCS_RGB; } else { - /* Suppress colorspace handling */ + /* Suppress colorspace handling */ sp->cinfo.d.jpeg_color_space = JCS_UNKNOWN; sp->cinfo.d.out_color_space = JCS_UNKNOWN; if (td->td_planarconfig == PLANARCONFIG_CONTIG && @@ -1174,6 +1137,9 @@ JPEGPreDecode(TIFF* tif, uint16 s) if (downsampled_output) { /* Need to use raw-data interface to libjpeg */ sp->cinfo.d.raw_data_out = TRUE; +#if JPEG_LIB_VERSION >= 70 + sp->cinfo.d.do_fancy_upsampling = FALSE; +#endif /* JPEG_LIB_VERSION >= 70 */ tif->tif_decoderow = DecodeRowError; tif->tif_decodestrip = JPEGDecodeRaw; tif->tif_decodetile = JPEGDecodeRaw; @@ -1348,18 +1314,23 @@ JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) #if defined(JPEG_LIB_MK1_OR_12BIT) unsigned short* tmpbuf = _TIFFmalloc(sizeof(unsigned short) * - sp->cinfo.d.output_width * - sp->cinfo.d.num_components); + sp->cinfo.d.output_width * + sp->cinfo.d.num_components); + if(tmpbuf==NULL) { + TIFFErrorExt(tif->tif_clientdata, "JPEGDecodeRaw", + "Out of memory"); + return 0; + } #endif do { jpeg_component_info *compptr; int ci, clumpoffset; - if( cc < sp->bytesperline * sp->v_sampling ) { - TIFFErrorExt(tif->tif_clientdata, "JPEGDecodeRaw", - "application buffer not large enough for all data."); - return 0; + if( cc < sp->bytesperline ) { + TIFFErrorExt(tif->tif_clientdata, "JPEGDecodeRaw", + "application buffer not large enough for all data."); + return 0; } /* Reload downsampled-data buffer if needed */ @@ -1375,20 +1346,25 @@ JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) */ clumpoffset = 0; /* first sample in clump */ for (ci = 0, compptr = sp->cinfo.d.comp_info; - ci < sp->cinfo.d.num_components; - ci++, compptr++) { + ci < sp->cinfo.d.num_components; + ci++, compptr++) { int hsamp = compptr->h_samp_factor; int vsamp = compptr->v_samp_factor; int ypos; for (ypos = 0; ypos < vsamp; ypos++) { JSAMPLE *inptr = sp->ds_buffer[ci][sp->scancount*vsamp + ypos]; + JDIMENSION nclump; #if defined(JPEG_LIB_MK1_OR_12BIT) JSAMPLE *outptr = (JSAMPLE*)tmpbuf + clumpoffset; #else JSAMPLE *outptr = (JSAMPLE*)buf + clumpoffset; + if (cc < (tmsize_t) (clumpoffset + samples_per_clump*(clumps_per_line-1) + hsamp)) { + TIFFErrorExt(tif->tif_clientdata, "JPEGDecodeRaw", + "application buffer not large enough for all data, possible subsampling issue"); + return 0; + } #endif - JDIMENSION nclump; if (hsamp == 1) { /* fast path for at least Cb and Cr */ @@ -1399,7 +1375,7 @@ JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) } else { int xpos; - /* general case */ + /* general case */ for (nclump = clumps_per_line; nclump-- > 0; ) { for (xpos = 0; xpos < hsamp; xpos++) outptr[xpos] = *inptr++; @@ -1422,9 +1398,9 @@ JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) } } else - { /* 12-bit */ + { /* 12-bit */ int value_pairs = (sp->cinfo.d.output_width - * sp->cinfo.d.num_components) / 2; + * sp->cinfo.d.num_components) / 2; int iPair; for( iPair = 0; iPair < value_pairs; iPair++ ) { @@ -1432,7 +1408,7 @@ JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) JSAMPLE *in_ptr = (JSAMPLE *) (tmpbuf + iPair * 2); out_ptr[0] = (in_ptr[0] & 0xff0) >> 4; out_ptr[1] = ((in_ptr[0] & 0xf) << 4) - | ((in_ptr[1] & 0xf00) >> 8); + | ((in_ptr[1] & 0xf00) >> 8); out_ptr[2] = ((in_ptr[1] & 0xff) >> 0); } } @@ -1441,12 +1417,9 @@ JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) sp->scancount ++; tif->tif_row += sp->v_sampling; -/* - buf += clumps_per_line*samples_per_clump; - cc -= clumps_per_line*samples_per_clump; -*/ - buf += sp->bytesperline * sp->v_sampling; - cc -= sp->bytesperline * sp->v_sampling; + + buf += sp->bytesperline; + cc -= sp->bytesperline; nrows -= sp->v_sampling; } while (nrows > 0); @@ -1459,7 +1432,7 @@ JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) /* Close down the decompressor if done. */ return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height - || TIFFjpeg_finish_decompress(sp); + || TIFFjpeg_finish_decompress(sp); } @@ -1724,7 +1697,7 @@ JPEGPreEncode(TIFF* tif, uint16 s) } else { if ((td->td_photometric == PHOTOMETRIC_MINISWHITE || td->td_photometric == PHOTOMETRIC_MINISBLACK) && td->td_samplesperpixel == 1) sp->cinfo.c.in_color_space = JCS_GRAYSCALE; - else if (td->td_photometric == PHOTOMETRIC_RGB) + else if (td->td_photometric == PHOTOMETRIC_RGB && td->td_samplesperpixel == 3) sp->cinfo.c.in_color_space = JCS_RGB; else if (td->td_photometric == PHOTOMETRIC_SEPARATED && td->td_samplesperpixel == 4) sp->cinfo.c.in_color_space = JCS_CMYK; @@ -1817,6 +1790,7 @@ JPEGEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) { line16_count = (sp->bytesperline * 2) / 3; line16 = (short *) _TIFFmalloc(sizeof(short) * line16_count); + // FIXME: undiagnosed malloc failure } while (nrows-- > 0) { @@ -1992,10 +1966,12 @@ JPEGCleanup(TIFF* tif) tif->tif_tagmethods.vsetfield = sp->vsetparent; tif->tif_tagmethods.printdir = sp->printdir; - if( sp->cinfo_initialized ) - TIFFjpeg_destroy(sp); /* release libjpeg resources */ - if (sp->jpegtables) /* tag value */ - _TIFFfree(sp->jpegtables); + if( sp != NULL ) { + if( sp->cinfo_initialized ) + TIFFjpeg_destroy(sp); /* release libjpeg resources */ + if (sp->jpegtables) /* tag value */ + _TIFFfree(sp->jpegtables); + } _TIFFfree(tif->tif_data); /* release local state */ tif->tif_data = NULL; @@ -2126,13 +2102,15 @@ JPEGPrintDir(TIFF* tif, FILE* fd, long flags) JPEGState* sp = JState(tif); assert(sp != NULL); - (void) flags; - if (TIFFFieldSet(tif,FIELD_JPEGTABLES)) - fprintf(fd, " JPEG Tables: (%lu bytes)\n", - (unsigned long) sp->jpegtables_length); - if (sp->printdir) - (*sp->printdir)(tif, fd, flags); + + if( sp != NULL ) { + if (TIFFFieldSet(tif,FIELD_JPEGTABLES)) + fprintf(fd, " JPEG Tables: (%lu bytes)\n", + (unsigned long) sp->jpegtables_length); + if (sp->printdir) + (*sp->printdir)(tif, fd, flags); + } } static uint32 @@ -2183,8 +2161,6 @@ JPEGDefaultTileSize(TIFF* tif, uint32* tw, uint32* th) static int JPEGInitializeLibJPEG( TIFF * tif, int decompress ) { JPEGState* sp = JState(tif); - uint64* byte_counts = NULL; - int data_is_empty = TRUE; if(sp->cinfo_initialized) { @@ -2198,24 +2174,6 @@ static int JPEGInitializeLibJPEG( TIFF * tif, int decompress ) sp->cinfo_initialized = 0; } - /* - * Do we have tile data already? Make sure we initialize the - * the state in decompressor mode if we have tile data, even if we - * are not in read-only file access mode. - */ - if( TIFFIsTiled( tif ) - && TIFFGetField( tif, TIFFTAG_TILEBYTECOUNTS, &byte_counts ) - && byte_counts != NULL ) - { - data_is_empty = byte_counts[0] == 0; - } - if( !TIFFIsTiled( tif ) - && TIFFGetField( tif, TIFFTAG_STRIPBYTECOUNTS, &byte_counts) - && byte_counts != NULL ) - { - data_is_empty = byte_counts[0] == 0; - } - /* * Initialize libjpeg. */ @@ -2325,6 +2283,7 @@ here hopefully is harmless. */ sp->jpegtables_length = SIZE_OF_JPEGTABLES; sp->jpegtables = (void *) _TIFFmalloc(sp->jpegtables_length); + // FIXME: NULL-deref after malloc failure _TIFFmemset(sp->jpegtables, 0, SIZE_OF_JPEGTABLES); #undef SIZE_OF_JPEGTABLES } diff --git a/Modules/ThirdParty/TIFF/src/itktiff/tif_jpeg_12.c b/Modules/ThirdParty/TIFF/src/itktiff/tif_jpeg_12.c index 8ce2d1cd2ee..a497dede71f 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/tif_jpeg_12.c +++ b/Modules/ThirdParty/TIFF/src/itktiff/tif_jpeg_12.c @@ -17,7 +17,7 @@ int TIFFReInitJPEG_12( TIFF *tif, int scheme, int is_encode ) assert(scheme == COMPRESSION_JPEG); sp = JState(tif); - sp->tif = tif; /* back link */ + sp->tif = tif; /* back link */ /* * Override parent get/set field methods. @@ -44,7 +44,7 @@ int TIFFReInitJPEG_12( TIFF *tif, int scheme, int is_encode ) tif->tif_cleanup = JPEGCleanup; tif->tif_defstripsize = JPEGDefaultStripSize; tif->tif_deftilesize = JPEGDefaultTileSize; - tif->tif_flags |= TIFF_NOBITREV; /* no bit reversal, please */ + tif->tif_flags |= TIFF_NOBITREV; /* no bit reversal, please */ sp->cinfo_initialized = FALSE; diff --git a/Modules/ThirdParty/TIFF/src/itktiff/tif_lzma.c b/Modules/ThirdParty/TIFF/src/itktiff/tif_lzma.c index 6e7dea0a39d..a6e4bc9956b 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/tif_lzma.c +++ b/Modules/ThirdParty/TIFF/src/itktiff/tif_lzma.c @@ -1,4 +1,4 @@ -/* $Id: tif_lzma.c,v 1.3 2011-02-22 21:55:13 fwarmerdam Exp $ */ +/* $Id: tif_lzma.c,v 1.4 2011-12-22 00:29:29 bfriesen Exp $ */ /* * Copyright (c) 2010, Andrey Kiselev @@ -220,7 +220,7 @@ LZMADecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) return 0; } - tif->tif_rawcp = sp->stream.next_in; + tif->tif_rawcp = (uint8 *)sp->stream.next_in; /* cast away const */ tif->tif_rawcc = sp->stream.avail_in; return 1; diff --git a/Modules/ThirdParty/TIFF/src/itktiff/tif_ojpeg.c b/Modules/ThirdParty/TIFF/src/itktiff/tif_ojpeg.c index 9d7cd6eaf38..f598ea4ecd4 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/tif_ojpeg.c +++ b/Modules/ThirdParty/TIFF/src/itktiff/tif_ojpeg.c @@ -1,4 +1,4 @@ -/* $Id: tif_ojpeg.c,v 1.53 2011-04-02 19:30:20 bfriesen Exp $ */ +/* $Id: tif_ojpeg.c,v 1.56 2012-05-24 03:15:18 fwarmerdam 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 @@ -1146,7 +1146,9 @@ OJPEGWriteHeaderInfo(TIFF* tif) OJPEGState* sp=(OJPEGState*)tif->tif_data; uint8** m; uint32 n; - assert(sp->libjpeg_session_active==0); + /* if a previous attempt failed, don't try again */ + if (sp->libjpeg_session_active != 0) + return 0; sp->out_state=ososSoi; sp->restart_index=0; jpeg_std_error(&(sp->libjpeg_jpeg_error_mgr)); @@ -1433,12 +1435,15 @@ OJPEGReadHeaderInfoSecStreamDqt(TIFF* tif) nb[sizeof(uint32)+1]=JPEG_MARKER_DQT; nb[sizeof(uint32)+2]=0; nb[sizeof(uint32)+3]=67; - if (OJPEGReadBlock(sp,65,&nb[sizeof(uint32)+4])==0) + if (OJPEGReadBlock(sp,65,&nb[sizeof(uint32)+4])==0) { + _TIFFfree(nb); return(0); + } o=nb[sizeof(uint32)+4]&15; if (3tif_clientdata,module,"Corrupt DQT marker in JPEG data"); + _TIFFfree(nb); return(0); } if (sp->qtable[o]!=0) @@ -1951,6 +1956,11 @@ OJPEGReadBufferFill(OJPEGState* sp) case osibsJpegInterchangeFormat: sp->in_buffer_source=osibsStrile; case osibsStrile: + if (!_TIFFFillStriles( sp->tif ) + || sp->tif->tif_dir.td_stripoffset == NULL + || sp->tif->tif_dir.td_stripbytecount == NULL) + return 0; + if (sp->in_buffer_next_strile==sp->in_buffer_strile_count) sp->in_buffer_source=osibsEof; else diff --git a/Modules/ThirdParty/TIFF/src/itktiff/tif_packbits.c b/Modules/ThirdParty/TIFF/src/itktiff/tif_packbits.c index bcbfeaaa3e9..b2b1bee3971 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/tif_packbits.c +++ b/Modules/ThirdParty/TIFF/src/itktiff/tif_packbits.c @@ -1,4 +1,4 @@ -/* $Id: tif_packbits.c,v 1.20 2010-03-10 18:56:49 bfriesen Exp $ */ +/* $Id: tif_packbits.c,v 1.22 2012-06-20 05:25:33 fwarmerdam Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -197,7 +197,7 @@ PackBitsEncodeChunk(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) while (cc > 0) { tmsize_t chunk = rowsize; - + if( cc < chunk ) chunk = cc; @@ -241,7 +241,7 @@ PackBitsDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) n = (long)occ; } occ -= n; - b = *bp++, cc--; /* TODO: may be reading past input buffer here when input data is corrupt or ends prematurely */ + b = *bp++, cc--; while (n-- > 0) *op++ = (uint8) b; } else { /* copy next n+1 bytes literally */ @@ -252,7 +252,13 @@ PackBitsDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) (unsigned long) ((tmsize_t)n - occ + 1)); n = (long)occ - 1; } - _TIFFmemcpy(op, bp, ++n); /* TODO: may be reading past input buffer here when input data is corrupt or ends prematurely */ + if (cc < (tmsize_t) (n+1)) + { + TIFFWarningExt(tif->tif_clientdata, module, + "Terminating PackBitsDecode due to lack of data."); + break; + } + _TIFFmemcpy(op, bp, ++n); op += n; occ -= n; bp += n; cc -= n; } diff --git a/Modules/ThirdParty/TIFF/src/itktiff/tif_pixarlog.c b/Modules/ThirdParty/TIFF/src/itktiff/tif_pixarlog.c index 2b79d91db1a..dfb96413d67 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/tif_pixarlog.c +++ b/Modules/ThirdParty/TIFF/src/itktiff/tif_pixarlog.c @@ -1,4 +1,4 @@ -/* $Id: tif_pixarlog.c,v 1.35 2011-01-06 16:00:23 fwarmerdam Exp $ */ +/* $Id: tif_pixarlog.c,v 1.38 2012-06-21 01:01:53 fwarmerdam Exp $ */ /* * Copyright (c) 1996-1997 Sam Leffler @@ -90,7 +90,7 @@ */ #include "tif_predict.h" -#include "itk_zlib.h" +#include "zlib.h" #include #include @@ -120,9 +120,9 @@ horizontalAccumulateF(uint16 *wp, int n, int stride, float *op, if (n >= stride) { mask = CODE_MASK; if (stride == 3) { - t0 = ToLinearF[cr = wp[0]]; - t1 = ToLinearF[cg = wp[1]]; - t2 = ToLinearF[cb = wp[2]]; + t0 = ToLinearF[cr = (wp[0] & mask)]; + t1 = ToLinearF[cg = (wp[1] & mask)]; + t2 = ToLinearF[cb = (wp[2] & mask)]; op[0] = t0; op[1] = t1; op[2] = t2; @@ -139,10 +139,10 @@ horizontalAccumulateF(uint16 *wp, int n, int stride, float *op, op[2] = t2; } } else if (stride == 4) { - t0 = ToLinearF[cr = wp[0]]; - t1 = ToLinearF[cg = wp[1]]; - t2 = ToLinearF[cb = wp[2]]; - t3 = ToLinearF[ca = wp[3]]; + t0 = ToLinearF[cr = (wp[0] & mask)]; + t1 = ToLinearF[cg = (wp[1] & mask)]; + t2 = ToLinearF[cb = (wp[2] & mask)]; + t3 = ToLinearF[ca = (wp[3] & mask)]; op[0] = t0; op[1] = t1; op[2] = t2; @@ -186,9 +186,9 @@ horizontalAccumulate12(uint16 *wp, int n, int stride, int16 *op, if (n >= stride) { mask = CODE_MASK; if (stride == 3) { - t0 = ToLinearF[cr = wp[0]] * SCALE12; - t1 = ToLinearF[cg = wp[1]] * SCALE12; - t2 = ToLinearF[cb = wp[2]] * SCALE12; + t0 = ToLinearF[cr = (wp[0] & mask)] * SCALE12; + t1 = ToLinearF[cg = (wp[1] & mask)] * SCALE12; + t2 = ToLinearF[cb = (wp[2] & mask)] * SCALE12; op[0] = CLAMP12(t0); op[1] = CLAMP12(t1); op[2] = CLAMP12(t2); @@ -205,10 +205,10 @@ horizontalAccumulate12(uint16 *wp, int n, int stride, int16 *op, op[2] = CLAMP12(t2); } } else if (stride == 4) { - t0 = ToLinearF[cr = wp[0]] * SCALE12; - t1 = ToLinearF[cg = wp[1]] * SCALE12; - t2 = ToLinearF[cb = wp[2]] * SCALE12; - t3 = ToLinearF[ca = wp[3]] * SCALE12; + t0 = ToLinearF[cr = (wp[0] & mask)] * SCALE12; + t1 = ToLinearF[cg = (wp[1] & mask)] * SCALE12; + t2 = ToLinearF[cb = (wp[2] & mask)] * SCALE12; + t3 = ToLinearF[ca = (wp[3] & mask)] * SCALE12; op[0] = CLAMP12(t0); op[1] = CLAMP12(t1); op[2] = CLAMP12(t2); @@ -250,9 +250,9 @@ horizontalAccumulate16(uint16 *wp, int n, int stride, uint16 *op, if (n >= stride) { mask = CODE_MASK; if (stride == 3) { - op[0] = ToLinear16[cr = wp[0]]; - op[1] = ToLinear16[cg = wp[1]]; - op[2] = ToLinear16[cb = wp[2]]; + op[0] = ToLinear16[cr = (wp[0] & mask)]; + op[1] = ToLinear16[cg = (wp[1] & mask)]; + op[2] = ToLinear16[cb = (wp[2] & mask)]; n -= 3; while (n > 0) { wp += 3; @@ -263,10 +263,10 @@ horizontalAccumulate16(uint16 *wp, int n, int stride, uint16 *op, op[2] = ToLinear16[(cb += wp[2]) & mask]; } } else if (stride == 4) { - op[0] = ToLinear16[cr = wp[0]]; - op[1] = ToLinear16[cg = wp[1]]; - op[2] = ToLinear16[cb = wp[2]]; - op[3] = ToLinear16[ca = wp[3]]; + op[0] = ToLinear16[cr = (wp[0] & mask)]; + op[1] = ToLinear16[cg = (wp[1] & mask)]; + op[2] = ToLinear16[cb = (wp[2] & mask)]; + op[3] = ToLinear16[ca = (wp[3] & mask)]; n -= 4; while (n > 0) { wp += 4; @@ -345,9 +345,9 @@ horizontalAccumulate8(uint16 *wp, int n, int stride, unsigned char *op, if (n >= stride) { mask = CODE_MASK; if (stride == 3) { - op[0] = ToLinear8[cr = wp[0]]; - op[1] = ToLinear8[cg = wp[1]]; - op[2] = ToLinear8[cb = wp[2]]; + op[0] = ToLinear8[cr = (wp[0] & mask)]; + op[1] = ToLinear8[cg = (wp[1] & mask)]; + op[2] = ToLinear8[cb = (wp[2] & mask)]; n -= 3; while (n > 0) { n -= 3; @@ -358,10 +358,10 @@ horizontalAccumulate8(uint16 *wp, int n, int stride, unsigned char *op, op[2] = ToLinear8[(cb += wp[2]) & mask]; } } else if (stride == 4) { - op[0] = ToLinear8[cr = wp[0]]; - op[1] = ToLinear8[cg = wp[1]]; - op[2] = ToLinear8[cb = wp[2]]; - op[3] = ToLinear8[ca = wp[3]]; + op[0] = ToLinear8[cr = (wp[0] & mask)]; + op[1] = ToLinear8[cg = (wp[1] & mask)]; + op[2] = ToLinear8[cb = (wp[2] & mask)]; + op[3] = ToLinear8[ca = (wp[3] & mask)]; n -= 4; while (n > 0) { n -= 4; @@ -396,9 +396,9 @@ horizontalAccumulate8abgr(uint16 *wp, int n, int stride, unsigned char *op, mask = CODE_MASK; if (stride == 3) { op[0] = 0; - t1 = ToLinear8[cb = wp[2]]; - t2 = ToLinear8[cg = wp[1]]; - t3 = ToLinear8[cr = wp[0]]; + t1 = ToLinear8[cb = (wp[2] & mask)]; + t2 = ToLinear8[cg = (wp[1] & mask)]; + t3 = ToLinear8[cr = (wp[0] & mask)]; op[1] = t1; op[2] = t2; op[3] = t3; @@ -416,10 +416,10 @@ horizontalAccumulate8abgr(uint16 *wp, int n, int stride, unsigned char *op, op[3] = t3; } } else if (stride == 4) { - t0 = ToLinear8[ca = wp[3]]; - t1 = ToLinear8[cb = wp[2]]; - t2 = ToLinear8[cg = wp[1]]; - t3 = ToLinear8[cr = wp[0]]; + t0 = ToLinear8[ca = (wp[3] & mask)]; + t1 = ToLinear8[cb = (wp[2] & mask)]; + t2 = ToLinear8[cg = (wp[1] & mask)]; + t3 = ToLinear8[cr = (wp[0] & mask)]; op[0] = t0; op[1] = t1; op[2] = t2; @@ -673,7 +673,7 @@ PixarLogSetupDecode(TIFF* tif) td->td_rowsperstrip), sizeof(uint16)); if (tbuf_size == 0) return (0); /* TODO: this is an error return without error report through TIFFErrorExt */ - sp->tbuf = (uint16 *) _TIFFmalloc(tbuf_size); + sp->tbuf = (uint16 *) _TIFFmalloc(tbuf_size+sizeof(uint16)*sp->stride); if (sp->tbuf == NULL) return (0); if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN) diff --git a/Modules/ThirdParty/TIFF/src/itktiff/tif_predict.c b/Modules/ThirdParty/TIFF/src/itktiff/tif_predict.c index d716ae9e073..d37c674a43d 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/tif_predict.c +++ b/Modules/ThirdParty/TIFF/src/itktiff/tif_predict.c @@ -391,7 +391,7 @@ fpAcc(TIFF* tif, uint8* cp0, tmsize_t cc) for (count = 0; count < wc; count++) { uint32 byte; for (byte = 0; byte < bps; byte++) { - #ifdef WORDS_BIGENDIAN + #if WORDS_BIGENDIAN cp[bps * count + byte] = tmp[byte * wc + count]; #else cp[bps * count + byte] = @@ -560,7 +560,7 @@ fpDiff(TIFF* tif, uint8* cp0, tmsize_t cc) for (count = 0; count < wc; count++) { uint32 byte; for (byte = 0; byte < bps; byte++) { - #ifdef WORDS_BIGENDIAN + #if WORDS_BIGENDIAN cp[byte * wc + count] = tmp[bps * count + byte]; #else cp[(bps - byte - 1) * wc + count] = diff --git a/Modules/ThirdParty/TIFF/src/itktiff/tif_print.c b/Modules/ThirdParty/TIFF/src/itktiff/tif_print.c index fad7e48a139..5d48104bb4e 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/tif_print.c +++ b/Modules/ThirdParty/TIFF/src/itktiff/tif_print.c @@ -1,4 +1,4 @@ -/* $Id: tif_print.c,v 1.54 2011-04-02 20:54:09 bfriesen Exp $ */ +/* $Id: tif_print.c,v 1.60 2012-08-19 16:56:35 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -34,6 +34,9 @@ #include +static void +_TIFFprintAsciiBounded(FILE* fd, const char* cp, int max_chars); + static const char *photoNames[] = { "min-is-white", /* PHOTOMETRIC_MINISWHITE */ "min-is-black", /* PHOTOMETRIC_MINISBLACK */ @@ -44,6 +47,8 @@ static const char *photoNames[] = { "YCbCr", /* PHOTOMETRIC_YCBCR */ "7 (0x7)", "CIE L*a*b*", /* PHOTOMETRIC_CIELAB */ + "ICC L*a*b*", /* PHOTOMETRIC_ICCLAB */ + "ITU L*a*b*" /* PHOTOMETRIC_ITULAB */ }; #define NPHOTONAMES (sizeof (photoNames) / sizeof (photoNames[0])) @@ -135,34 +140,51 @@ _TIFFPrintField(FILE* fd, const TIFFField *fip, } static int -_TIFFPrettyPrintField(TIFF* tif, FILE* fd, uint32 tag, +_TIFFPrettyPrintField(TIFF* tif, const TIFFField *fip, FILE* fd, uint32 tag, uint32 value_count, void *raw_data) { (void) tif; + /* do not try to pretty print auto-defined fields */ + if (strncmp(fip->field_name,"Tag ", 4) == 0) { + return 0; + } + switch (tag) { case TIFFTAG_INKSET: - fprintf(fd, " Ink Set: "); - switch (*((uint16*)raw_data)) { + if (value_count == 2 && fip->field_type == TIFF_SHORT) { + fprintf(fd, " Ink Set: "); + switch (*((uint16*)raw_data)) { case INKSET_CMYK: fprintf(fd, "CMYK\n"); break; default: fprintf(fd, "%u (0x%x)\n", - *((uint16*)raw_data), - *((uint16*)raw_data)); + *((uint16*)raw_data), + *((uint16*)raw_data)); break; + } + return 1; } - return 1; + return 0; + case TIFFTAG_DOTRANGE: - fprintf(fd, " Dot Range: %u-%u\n", + if (value_count == 2 && fip->field_type == TIFF_SHORT) { + fprintf(fd, " Dot Range: %u-%u\n", ((uint16*)raw_data)[0], ((uint16*)raw_data)[1]); - return 1; + return 1; + } + return 0; + case TIFFTAG_WHITEPOINT: - fprintf(fd, " White Point: %g-%g\n", + if (value_count == 2 && fip->field_type == TIFF_RATIONAL) { + fprintf(fd, " White Point: %g-%g\n", ((float *)raw_data)[0], ((float *)raw_data)[1]); - return 1; + return 1; + } + return 0; + case TIFFTAG_XMLPACKET: { uint32 i; @@ -182,19 +204,25 @@ _TIFFPrettyPrintField(TIFF* tif, FILE* fd, uint32 tag, " RichTIFFIPTC Data: , %lu bytes\n", (unsigned long) value_count * 4); return 1; + case TIFFTAG_PHOTOSHOP: fprintf(fd, " Photoshop Data: , %lu bytes\n", (unsigned long) value_count); return 1; + case TIFFTAG_ICCPROFILE: fprintf(fd, " ICC Profile: , %lu bytes\n", (unsigned long) value_count); return 1; + case TIFFTAG_STONITS: - fprintf(fd, + if (value_count == 1 && fip->field_type == TIFF_DOUBLE) { + fprintf(fd, " Sample to Nits conversion factor: %.4e\n", *((double*)raw_data)); - return 1; + return 1; + } + return 0; } return 0; @@ -364,9 +392,13 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) fprintf(fd, " Ink Names: "); i = td->td_samplesperpixel; sep = ""; - for (cp = td->td_inknames; i > 0; cp = strchr(cp,'\0')+1, i--) { + for (cp = td->td_inknames; + i > 0 && cp < td->td_inknames + td->td_inknameslen; + cp = strchr(cp,'\0')+1, i--) { + int max_chars = + td->td_inknameslen - (cp - td->td_inknames); fputs(sep, fd); - _TIFFprintAscii(fd, cp); + _TIFFprintAsciiBounded(fd, cp, max_chars); sep = ", "; } fputs("\n", fd); @@ -449,14 +481,16 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) if (TIFFFieldSet(tif,FIELD_MAXSAMPLEVALUE)) fprintf(fd, " Max Sample Value: %u\n", td->td_maxsamplevalue); if (TIFFFieldSet(tif,FIELD_SMINSAMPLEVALUE)) { + int count = (tif->tif_flags & TIFF_PERSAMPLE) ? td->td_samplesperpixel : 1; fprintf(fd, " SMin Sample Value:"); - for (i = 0; i < td->td_samplesperpixel; ++i) + for (i = 0; i < count; ++i) fprintf(fd, " %g", td->td_sminsamplevalue[i]); fprintf(fd, "\n"); } if (TIFFFieldSet(tif,FIELD_SMAXSAMPLEVALUE)) { + int count = (tif->tif_flags & TIFF_PERSAMPLE) ? td->td_samplesperpixel : 1; fprintf(fd, " SMax Sample Value:"); - for (i = 0; i < td->td_samplesperpixel; ++i) + for (i = 0; i < count; ++i) fprintf(fd, " %g", td->td_smaxsamplevalue[i]); fprintf(fd, "\n"); } @@ -548,8 +582,19 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) continue; if(fip->field_passcount) { - if(TIFFGetField(tif, tag, &value_count, &raw_data) != 1) + if (fip->field_readcount == TIFF_VARIABLE ) { + if(TIFFGetField(tif, tag, &value_count, &raw_data) != 1) + continue; + } else if (fip->field_readcount == TIFF_VARIABLE2 ) { + uint16 small_value_count; + if(TIFFGetField(tif, tag, &small_value_count, &raw_data) != 1) + continue; + value_count = small_value_count; + } else { + assert (fip->field_readcount == TIFF_VARIABLE + || fip->field_readcount == TIFF_VARIABLE2); continue; + } } else { if (fip->field_readcount == TIFF_VARIABLE || fip->field_readcount == TIFF_VARIABLE2) @@ -558,46 +603,28 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) value_count = td->td_samplesperpixel; else value_count = fip->field_readcount; - if ((fip->field_type == TIFF_ASCII - || fip->field_readcount == TIFF_VARIABLE - || fip->field_readcount == TIFF_VARIABLE2 - || fip->field_readcount == TIFF_SPP - || value_count > 1) - && fip->field_tag != TIFFTAG_PAGENUMBER - && fip->field_tag != TIFFTAG_HALFTONEHINTS - && fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING - && fip->field_tag != TIFFTAG_DOTRANGE) { + if (fip->field_tag == TIFFTAG_DOTRANGE + && strcmp(fip->field_name,"DotRange") == 0) { + /* TODO: This is an evil exception and should not have been + handled this way ... likely best if we move it into + the directory structure with an explicit field in + libtiff 4.1 and assign it a FIELD_ value */ + static uint16 dotrange[2]; + raw_data = dotrange; + TIFFGetField(tif, tag, dotrange+0, dotrange+1); + } else if (fip->field_type == TIFF_ASCII + || fip->field_readcount == TIFF_VARIABLE + || fip->field_readcount == TIFF_VARIABLE2 + || fip->field_readcount == TIFF_SPP + || value_count > 1) { if(TIFFGetField(tif, tag, &raw_data) != 1) continue; - } else if (fip->field_tag != TIFFTAG_PAGENUMBER - && fip->field_tag != TIFFTAG_HALFTONEHINTS - && fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING - && fip->field_tag != TIFFTAG_DOTRANGE) { - raw_data = _TIFFmalloc( - _TIFFDataSize(fip->field_type) - * value_count); - mem_alloc = 1; - if(TIFFGetField(tif, tag, raw_data) != 1) { - _TIFFfree(raw_data); - continue; - } } else { - /* - * XXX: Should be fixed and removed, - * see the notes related to - * TIFFTAG_PAGENUMBER, - * TIFFTAG_HALFTONEHINTS, - * TIFFTAG_YCBCRSUBSAMPLING and - * TIFFTAG_DOTRANGE tags in tif_dir.c. - */ - char *tmp; raw_data = _TIFFmalloc( _TIFFDataSize(fip->field_type) * value_count); - tmp = raw_data; mem_alloc = 1; - if(TIFFGetField(tif, tag, tmp, - tmp + _TIFFDataSize(fip->field_type)) != 1) { + if(TIFFGetField(tif, tag, raw_data) != 1) { _TIFFfree(raw_data); continue; } @@ -610,7 +637,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) * _TIFFPrettyPrintField() fall down and print it as * any other tag. */ - if (!_TIFFPrettyPrintField(tif, fd, tag, value_count, raw_data)) + if (!_TIFFPrettyPrintField(tif, fip, fd, tag, value_count, raw_data)) _TIFFPrintField(fd, fip, value_count, raw_data); if(mem_alloc) @@ -648,7 +675,13 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) void _TIFFprintAscii(FILE* fd, const char* cp) { - for (; *cp != '\0'; cp++) { + _TIFFprintAsciiBounded( fd, cp, strlen(cp)); +} + +static void +_TIFFprintAsciiBounded(FILE* fd, const char* cp, int max_chars) +{ + for (; max_chars > 0 && *cp != '\0'; cp++, max_chars--) { const char* tp; if (isprint((int)*cp)) { diff --git a/Modules/ThirdParty/TIFF/src/itktiff/tif_read.c b/Modules/ThirdParty/TIFF/src/itktiff/tif_read.c index ce15082e192..74c4c2a3206 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/tif_read.c +++ b/Modules/ThirdParty/TIFF/src/itktiff/tif_read.c @@ -1,4 +1,4 @@ -/* $Id: tif_read.c,v 1.37 2011-04-02 20:54:09 bfriesen Exp $ */ +/* $Id: tif_read.c,v 1.41 2012-07-06 19:22:58 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -50,9 +50,10 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart ) uint64 unused_data; uint64 read_offset; tmsize_t cc, to_read; - tmsize_t bytecountm; + /* tmsize_t bytecountm; */ - _TIFFFillStriles( tif ); + if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount) + return 0; /* * Expand raw data buffer, if needed, to hold data @@ -60,7 +61,7 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart ) * bound on the size of a buffer we'll use?). */ - bytecountm=(tmsize_t) td->td_stripbytecount[strip]; + /* bytecountm=(tmsize_t) td->td_stripbytecount[strip]; */ if (read_ahead*2 > tif->tif_rawdatasize) { assert( restart ); @@ -92,6 +93,7 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart ) if( unused_data > 0 ) { + assert((tif->tif_flags&TIFF_BUFFERMMAP)==0); memmove( tif->tif_rawdata, tif->tif_rawcp, unused_data ); } @@ -119,6 +121,7 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart ) - tif->tif_rawdataoff - tif->tif_rawdataloaded; } + assert((tif->tif_flags&TIFF_BUFFERMMAP)==0); cc = TIFFReadFile(tif, tif->tif_rawdata + unused_data, to_read); if (cc != to_read) { @@ -144,8 +147,10 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart ) tif->tif_rawcp = tif->tif_rawdata; if (!isFillOrder(tif, td->td_fillorder) && - (tif->tif_flags & TIFF_NOBITREV) == 0) + (tif->tif_flags & TIFF_NOBITREV) == 0) { + assert((tif->tif_flags&TIFF_BUFFERMMAP)==0); TIFFReverseBits(tif->tif_rawdata + unused_data, to_read ); + } /* ** When starting a strip from the beginning we need to @@ -199,7 +204,8 @@ TIFFSeek(TIFF* tif, uint32 row, uint16 sample ) * read it a few lines at a time? */ #if defined(CHUNKY_STRIP_READ_SUPPORT) - _TIFFFillStriles( tif ); + if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount) + return 0; whole_strip = tif->tif_dir.td_stripbytecount[strip] < 10 || isMapped(tif); #else @@ -360,7 +366,8 @@ TIFFReadRawStrip1(TIFF* tif, uint32 strip, void* buf, tmsize_t size, { TIFFDirectory *td = &tif->tif_dir; - _TIFFFillStriles( tif ); + if (!_TIFFFillStriles( tif )) + return ((tmsize_t)(-1)); assert((tif->tif_flags&TIFF_NOREADRAW)==0); if (!isMapped(tif)) { @@ -485,7 +492,8 @@ TIFFFillStrip(TIFF* tif, uint32 strip) static const char module[] = "TIFFFillStrip"; TIFFDirectory *td = &tif->tif_dir; - _TIFFFillStriles( tif ); + if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount) + return 0; if ((tif->tif_flags&TIFF_NOREADRAW)==0) { @@ -518,8 +526,11 @@ TIFFFillStrip(TIFF* tif, uint32 strip) * buffer (if they try to, the application will get a * fault since the file is mapped read-only). */ - if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) + if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) { _TIFFfree(tif->tif_rawdata); + tif->tif_rawdata = NULL; + tif->tif_rawdatasize = 0; + } tif->tif_flags &= ~TIFF_MYBUFFER; /* * We must check for overflow, potentially causing @@ -561,6 +572,14 @@ TIFFFillStrip(TIFF* tif, uint32 strip) tif->tif_rawdata = tif->tif_base + (tmsize_t)td->td_stripoffset[strip]; tif->tif_rawdataoff = 0; tif->tif_rawdataloaded = (tmsize_t) bytecount; + + /* + * When we have tif_rawdata reference directly into the memory mapped file + * we need to be pretty careful about how we use the rawdata. It is not + * a general purpose working buffer as it normally otherwise is. So we + * keep track of this fact to avoid using it improperly. + */ + tif->tif_flags |= TIFF_BUFFERMMAP; } else { /* * Expand raw data buffer, if needed, to hold data @@ -585,6 +604,11 @@ TIFFFillStrip(TIFF* tif, uint32 strip) if (!TIFFReadBufferSetup(tif, 0, bytecountm)) return (0); } + if (tif->tif_flags&TIFF_BUFFERMMAP) { + tif->tif_curstrip = NOSTRIP; + if (!TIFFReadBufferSetup(tif, 0, bytecountm)) + return (0); + } if (TIFFReadRawStrip1(tif, strip, tif->tif_rawdata, bytecountm, module) != bytecountm) return (0); @@ -654,7 +678,8 @@ TIFFReadRawTile1(TIFF* tif, uint32 tile, void* buf, tmsize_t size, const char* m { TIFFDirectory *td = &tif->tif_dir; - _TIFFFillStriles( tif ); + if (!_TIFFFillStriles( tif )) + return ((tmsize_t)(-1)); assert((tif->tif_flags&TIFF_NOREADRAW)==0); if (!isMapped(tif)) { @@ -770,7 +795,8 @@ TIFFFillTile(TIFF* tif, uint32 tile) static const char module[] = "TIFFFillTile"; TIFFDirectory *td = &tif->tif_dir; - _TIFFFillStriles( tif ); + if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount) + return 0; if ((tif->tif_flags&TIFF_NOREADRAW)==0) { @@ -803,8 +829,11 @@ TIFFFillTile(TIFF* tif, uint32 tile) * buffer (if they try to, the application will get a * fault since the file is mapped read-only). */ - if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) + if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) { _TIFFfree(tif->tif_rawdata); + tif->tif_rawdata = NULL; + tif->tif_rawdatasize = 0; + } tif->tif_flags &= ~TIFF_MYBUFFER; /* * We must check for overflow, potentially causing @@ -825,6 +854,7 @@ TIFFFillTile(TIFF* tif, uint32 tile) tif->tif_base + (tmsize_t)td->td_stripoffset[tile]; tif->tif_rawdataoff = 0; tif->tif_rawdataloaded = (tmsize_t) bytecount; + tif->tif_flags |= TIFF_BUFFERMMAP; } else { /* * Expand raw data buffer, if needed, to hold data @@ -849,6 +879,12 @@ TIFFFillTile(TIFF* tif, uint32 tile) if (!TIFFReadBufferSetup(tif, 0, bytecountm)) return (0); } + if (tif->tif_flags&TIFF_BUFFERMMAP) { + tif->tif_curtile = NOTILE; + if (!TIFFReadBufferSetup(tif, 0, bytecountm)) + return (0); + } + if (TIFFReadRawTile1(tif, tile, tif->tif_rawdata, bytecountm, module) != bytecountm) return (0); @@ -880,10 +916,13 @@ TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size) static const char module[] = "TIFFReadBufferSetup"; assert((tif->tif_flags&TIFF_NOREADRAW)==0); + tif->tif_flags &= ~TIFF_BUFFERMMAP; + if (tif->tif_rawdata) { if (tif->tif_flags & TIFF_MYBUFFER) _TIFFfree(tif->tif_rawdata); tif->tif_rawdata = NULL; + tif->tif_rawdatasize = 0; } if (bp) { tif->tif_rawdatasize = size; @@ -915,7 +954,8 @@ TIFFStartStrip(TIFF* tif, uint32 strip) { TIFFDirectory *td = &tif->tif_dir; - _TIFFFillStriles( tif ); + if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount) + return 0; if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { if (!(*tif->tif_setupdecode)(tif)) @@ -949,7 +989,8 @@ TIFFStartTile(TIFF* tif, uint32 tile) { TIFFDirectory *td = &tif->tif_dir; - _TIFFFillStriles( tif ); + if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount) + return 0; if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { if (!(*tif->tif_setupdecode)(tif)) diff --git a/Modules/ThirdParty/TIFF/src/itktiff/tif_strip.c b/Modules/ThirdParty/TIFF/src/itktiff/tif_strip.c index fe13e5b97a5..82d6816ab27 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/tif_strip.c +++ b/Modules/ThirdParty/TIFF/src/itktiff/tif_strip.c @@ -1,4 +1,4 @@ -/* $Id: tif_strip.c,v 1.34 2011-04-02 20:54:09 bfriesen Exp $ */ +/* $Id: tif_strip.c,v 1.35 2012-06-06 05:33:55 fwarmerdam Exp $ */ /* * Copyright (c) 1991-1997 Sam Leffler @@ -107,11 +107,13 @@ TIFFVStripSize64(TIFF* tif, uint32 nrows) } TIFFGetFieldDefaulted(tif,TIFFTAG_YCBCRSUBSAMPLING,ycbcrsubsampling+0, ycbcrsubsampling+1); - if (((ycbcrsubsampling[0]!=1)&&(ycbcrsubsampling[0]!=2)&&(ycbcrsubsampling[0]!=4)) || - ((ycbcrsubsampling[1]!=1)&&(ycbcrsubsampling[1]!=2)&&(ycbcrsubsampling[1]!=4))) + if ((ycbcrsubsampling[0] != 1 && ycbcrsubsampling[0] != 2 && ycbcrsubsampling[0] != 4) + ||(ycbcrsubsampling[1] != 1 && ycbcrsubsampling[1] != 2 && ycbcrsubsampling[1] != 4)) { TIFFErrorExt(tif->tif_clientdata,module, - "Invalid YCbCr subsampling"); + "Invalid YCbCr subsampling (%dx%d)", + ycbcrsubsampling[0], + ycbcrsubsampling[1] ); return 0; } samplingblock_samples=ycbcrsubsampling[0]*ycbcrsubsampling[1]+2; diff --git a/Modules/ThirdParty/TIFF/src/itktiff/tif_swab.c b/Modules/ThirdParty/TIFF/src/itktiff/tif_swab.c index 2781c56d8bd..717c744b560 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/tif_swab.c +++ b/Modules/ThirdParty/TIFF/src/itktiff/tif_swab.c @@ -31,6 +31,7 @@ */ #include "tiffiop.h" +#ifndef TIFFSwabShort void TIFFSwabShort(uint16* wp) { @@ -39,7 +40,9 @@ TIFFSwabShort(uint16* wp) assert(sizeof(uint16)==2); t = cp[1]; cp[1] = cp[0]; cp[0] = t; } +#endif +#ifndef TIFFSwabLong void TIFFSwabLong(uint32* lp) { @@ -49,7 +52,9 @@ TIFFSwabLong(uint32* lp) t = cp[3]; cp[3] = cp[0]; cp[0] = t; t = cp[2]; cp[2] = cp[1]; cp[1] = t; } +#endif +#ifndef TIFFSwabLong8 void TIFFSwabLong8(uint64* lp) { @@ -61,7 +66,9 @@ TIFFSwabLong8(uint64* lp) t = cp[5]; cp[5] = cp[2]; cp[2] = t; t = cp[4]; cp[4] = cp[3]; cp[3] = t; } +#endif +#ifndef TIFFSwabArrayOfShort void TIFFSwabArrayOfShort(register uint16* wp, tmsize_t n) { @@ -75,7 +82,9 @@ TIFFSwabArrayOfShort(register uint16* wp, tmsize_t n) wp++; } } +#endif +#ifndef TIFFSwabArrayOfTriples void TIFFSwabArrayOfTriples(register uint8* tp, tmsize_t n) { @@ -89,7 +98,9 @@ TIFFSwabArrayOfTriples(register uint8* tp, tmsize_t n) tp += 3; } } +#endif +#ifndef TIFFSwabArrayOfLong void TIFFSwabArrayOfLong(register uint32* lp, tmsize_t n) { @@ -104,7 +115,9 @@ TIFFSwabArrayOfLong(register uint32* lp, tmsize_t n) lp++; } } +#endif +#ifndef TIFFSwabArrayOfLong8 void TIFFSwabArrayOfLong8(register uint64* lp, tmsize_t n) { @@ -121,7 +134,9 @@ TIFFSwabArrayOfLong8(register uint64* lp, tmsize_t n) lp++; } } +#endif +#ifndef TIFFSwabFloat void TIFFSwabFloat(float* fp) { @@ -131,7 +146,9 @@ TIFFSwabFloat(float* fp) t = cp[3]; cp[3] = cp[0]; cp[0] = t; t = cp[2]; cp[2] = cp[1]; cp[1] = t; } +#endif +#ifndef TIFFSwabArrayOfFloat void TIFFSwabArrayOfFloat(register float* fp, tmsize_t n) { @@ -146,7 +163,9 @@ TIFFSwabArrayOfFloat(register float* fp, tmsize_t n) fp++; } } +#endif +#ifndef TIFFSwabDouble void TIFFSwabDouble(double *dp) { @@ -158,7 +177,9 @@ TIFFSwabDouble(double *dp) t = cp[5]; cp[5] = cp[2]; cp[2] = t; t = cp[4]; cp[4] = cp[3]; cp[3] = t; } +#endif +#ifndef TIFFSwabArrayOfDouble void TIFFSwabArrayOfDouble(double* dp, tmsize_t n) { @@ -175,6 +196,7 @@ TIFFSwabArrayOfDouble(double* dp, tmsize_t n) dp++; } } +#endif /* * Bit reversal tables. TIFFBitRevTable[] gives diff --git a/Modules/ThirdParty/TIFF/src/itktiff/tif_thunder.c b/Modules/ThirdParty/TIFF/src/itktiff/tif_thunder.c index d8e3b8c1231..b4a9d6dfde6 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/tif_thunder.c +++ b/Modules/ThirdParty/TIFF/src/itktiff/tif_thunder.c @@ -169,7 +169,7 @@ ThunderDecodeRow(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) { static const char module[] = "ThunderDecodeRow"; uint8* row = buf; - + (void) s; if (occ % tif->tif_scanlinesize) { diff --git a/Modules/ThirdParty/TIFF/src/itktiff/tif_tile.c b/Modules/ThirdParty/TIFF/src/itktiff/tif_tile.c index 713fb0f3893..4af2b26a22c 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/tif_tile.c +++ b/Modules/ThirdParty/TIFF/src/itktiff/tif_tile.c @@ -1,4 +1,4 @@ -/* $Id: tif_tile.c,v 1.22 2010-07-01 15:33:28 dron Exp $ */ +/* $Id: tif_tile.c,v 1.23 2012-06-06 05:33:55 fwarmerdam Exp $ */ /* * Copyright (c) 1991-1997 Sam Leffler @@ -203,12 +203,13 @@ TIFFVTileSize64(TIFF* tif, uint32 nrows) uint64 samplingrow_size; TIFFGetFieldDefaulted(tif,TIFFTAG_YCBCRSUBSAMPLING,ycbcrsubsampling+0, ycbcrsubsampling+1); - assert((ycbcrsubsampling[0]==1)||(ycbcrsubsampling[0]==2)||(ycbcrsubsampling[0]==4)); - assert((ycbcrsubsampling[1]==1)||(ycbcrsubsampling[1]==2)||(ycbcrsubsampling[1]==4)); - if (ycbcrsubsampling[0]*ycbcrsubsampling[1]==0) + if ((ycbcrsubsampling[0] != 1 && ycbcrsubsampling[0] != 2 && ycbcrsubsampling[0] != 4) + ||(ycbcrsubsampling[1] != 1 && ycbcrsubsampling[1] != 2 && ycbcrsubsampling[1] != 4)) { TIFFErrorExt(tif->tif_clientdata,module, - "Invalid YCbCr subsampling"); + "Invalid YCbCr subsampling (%dx%d)", + ycbcrsubsampling[0], + ycbcrsubsampling[1] ); return 0; } samplingblock_samples=ycbcrsubsampling[0]*ycbcrsubsampling[1]+2; diff --git a/Modules/ThirdParty/TIFF/src/itktiff/tif_unix.c b/Modules/ThirdParty/TIFF/src/itktiff/tif_unix.c index f5d95cef388..6073430a9b2 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/tif_unix.c +++ b/Modules/ThirdParty/TIFF/src/itktiff/tif_unix.c @@ -1,4 +1,4 @@ -/* $Id: tif_unix.c,v 1.22 2010-03-10 18:56:49 bfriesen Exp $ */ +/* $Id: tif_unix.c,v 1.23 2012-06-01 21:40:59 fwarmerdam Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -186,7 +186,11 @@ TIFFOpen(const char* name, const char* mode) fd = open(name, m, 0666); if (fd < 0) { - TIFFErrorExt(0, module, "%s: Cannot open", name); + if (errno > 0 && strerror(errno) != NULL ) { + TIFFErrorExt(0, module, "%s: %s", name, strerror(errno) ); + } else { + TIFFErrorExt(0, module, "%s: Cannot open", name); + } return ((TIFF *)0); } @@ -241,9 +245,9 @@ TIFFOpenW(const wchar_t* name, const char* mode) tif = TIFFFdOpen((int)fd, (mbname != NULL) ? mbname : "", mode); - + _TIFFfree(mbname); - + if(!tif) close(fd); return tif; diff --git a/Modules/ThirdParty/TIFF/src/itktiff/tif_win32.c b/Modules/ThirdParty/TIFF/src/itktiff/tif_win32.c index 8d02463952f..d694bb56e03 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/tif_win32.c +++ b/Modules/ThirdParty/TIFF/src/itktiff/tif_win32.c @@ -1,4 +1,4 @@ -/* $Id: tif_win32.c,v 1.38 2011-02-09 18:05:00 fwarmerdam Exp $ */ +/* $Id: tif_win32.c,v 1.39 2011-12-22 17:07:57 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -377,7 +377,7 @@ Win32WarningHandler(const char* module, const char* fmt, va_list ap) LPCTSTR szTitleText = "%s Warning"; LPCTSTR szDefaultModule = "LIBTIFF"; LPCTSTR szTmpModule = (module == NULL) ? szDefaultModule : module; - int nBufSize = (strlen(szTmpModule) + + SIZE_T nBufSize = (strlen(szTmpModule) + strlen(szTitleText) + strlen(fmt) + 256)*sizeof(char); if ((szTitle = (LPTSTR)LocalAlloc(LMEM_FIXED, nBufSize)) == NULL) @@ -408,7 +408,7 @@ Win32ErrorHandler(const char* module, const char* fmt, va_list ap) LPCTSTR szTitleText = "%s Error"; LPCTSTR szDefaultModule = "LIBTIFF"; LPCTSTR szTmpModule = (module == NULL) ? szDefaultModule : module; - int nBufSize = (strlen(szTmpModule) + + SIZE_T nBufSize = (strlen(szTmpModule) + strlen(szTitleText) + strlen(fmt) + 256)*sizeof(char); if ((szTitle = (LPTSTR)LocalAlloc(LMEM_FIXED, nBufSize)) == NULL) diff --git a/Modules/ThirdParty/TIFF/src/itktiff/tif_write.c b/Modules/ThirdParty/TIFF/src/itktiff/tif_write.c index 42ed5413d07..d55c49e7d75 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/tif_write.c +++ b/Modules/ThirdParty/TIFF/src/itktiff/tif_write.c @@ -1,4 +1,4 @@ -/* $Id: tif_write.c,v 1.36 2011-02-18 20:53:04 fwarmerdam Exp $ */ +/* $Id: tif_write.c,v 1.37 2012-08-13 22:10:17 fwarmerdam Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -227,16 +227,27 @@ TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc) tif->tif_flags |= TIFF_CODERSETUP; } - tif->tif_rawcc = 0; - tif->tif_rawcp = tif->tif_rawdata; - if( td->td_stripbytecount[strip] > 0 ) { + /* Make sure that at the first attempt of rewriting the tile, we will have */ + /* more bytes available in the output buffer than the previous byte count, */ + /* so that TIFFAppendToStrip() will detect the overflow when it is called the first */ + /* time if the new compressed tile is bigger than the older one. (GDAL #4771) */ + if( tif->tif_rawdatasize <= td->td_stripbytecount[strip] ) + { + if( !(TIFFWriteBufferSetup(tif, NULL, + (tmsize_t)TIFFroundup_64((uint64)(td->td_stripbytecount[strip] + 1), 1024))) ) + return ((tmsize_t)(-1)); + } + /* Force TIFFAppendToStrip() to consider placing data at end of file. */ tif->tif_curoff = 0; } + tif->tif_rawcc = 0; + tif->tif_rawcp = tif->tif_rawdata; + tif->tif_flags &= ~TIFF_POSTENCODE; sample = (uint16)(strip / td->td_stripsperimage); if (!(*tif->tif_preencode)(tif, sample)) @@ -362,16 +373,27 @@ TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc) tif->tif_flags |= TIFF_BUF4WRITE; tif->tif_curtile = tile; - tif->tif_rawcc = 0; - tif->tif_rawcp = tif->tif_rawdata; - if( td->td_stripbytecount[tile] > 0 ) { + /* Make sure that at the first attempt of rewriting the tile, we will have */ + /* more bytes available in the output buffer than the previous byte count, */ + /* so that TIFFAppendToStrip() will detect the overflow when it is called the first */ + /* time if the new compressed tile is bigger than the older one. (GDAL #4771) */ + if( tif->tif_rawdatasize <= td->td_stripbytecount[tile] ) + { + if( !(TIFFWriteBufferSetup(tif, NULL, + (tmsize_t)TIFFroundup_64((uint64)(td->td_stripbytecount[tile] + 1), 1024))) ) + return ((tmsize_t)(-1)); + } + /* Force TIFFAppendToStrip() to consider placing data at end of file. */ tif->tif_curoff = 0; } + tif->tif_rawcc = 0; + tif->tif_rawcp = tif->tif_rawdata; + /* * Compute tiles per row & per column to compute * current row and column diff --git a/Modules/ThirdParty/TIFF/src/itktiff/tiff.h b/Modules/ThirdParty/TIFF/src/itktiff/tiff.h index 72340305471..1932cc7d487 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/tiff.h +++ b/Modules/ThirdParty/TIFF/src/itktiff/tiff.h @@ -1,5 +1,4 @@ -#include "itk_tiff_mangle.h" -/* Id */ +/* $Id: tiff.h,v 1.68 2012-08-19 16:56:35 bfriesen Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -26,9 +25,8 @@ */ #ifndef _TIFF_ -#define _TIFF_ +#define _TIFF_ -#include "tiffconf.h" #include "tif_config.h" /* @@ -168,6 +166,8 @@ typedef enum { #define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */ #define COMPRESSION_OJPEG 6 /* !6.0 JPEG */ #define COMPRESSION_JPEG 7 /* %JPEG DCT compression */ +#define COMPRESSION_T85 9 /* !TIFF/FX T.85 JBIG compression */ +#define COMPRESSION_T43 10 /* !TIFF/FX T.43 colour by layered JBIG compression */ #define COMPRESSION_NEXT 32766 /* NeXT 2-bit RLE */ #define COMPRESSION_CCITTRLEW 32771 /* #1 w/ word alignment */ #define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */ @@ -321,6 +321,30 @@ typedef enum { [Adobe TIFF Technote 3] */ #define TIFFTAG_JPEGTABLES 347 /* %JPEG table stream */ #define TIFFTAG_OPIPROXY 351 /* %OPI Proxy [Adobe TIFF technote] */ +/* Tags 400-435 are from the TIFF/FX spec */ +#define TIFFTAG_GLOBALPARAMETERSIFD 400 /* ! */ +#define TIFFTAG_PROFILETYPE 401 /* ! */ +#define PROFILETYPE_UNSPECIFIED 0 /* ! */ +#define PROFILETYPE_G3_FAX 1 /* ! */ +#define TIFFTAG_FAXPROFILE 402 /* ! */ +#define FAXPROFILE_S 1 /* !TIFF/FX FAX profile S */ +#define FAXPROFILE_F 2 /* !TIFF/FX FAX profile F */ +#define FAXPROFILE_J 3 /* !TIFF/FX FAX profile J */ +#define FAXPROFILE_C 4 /* !TIFF/FX FAX profile C */ +#define FAXPROFILE_L 5 /* !TIFF/FX FAX profile L */ +#define FAXPROFILE_M 6 /* !TIFF/FX FAX profile LM */ +#define TIFFTAG_CODINGMETHODS 403 /* !TIFF/FX coding methods */ +#define CODINGMETHODS_T4_1D (1 << 1) /* !T.4 1D */ +#define CODINGMETHODS_T4_2D (1 << 2) /* !T.4 2D */ +#define CODINGMETHODS_T6 (1 << 3) /* !T.6 */ +#define CODINGMETHODS_T85 (1 << 4) /* !T.85 JBIG */ +#define CODINGMETHODS_T42 (1 << 5) /* !T.42 JPEG */ +#define CODINGMETHODS_T43 (1 << 6) /* !T.43 colour by layered JBIG */ +#define TIFFTAG_VERSIONYEAR 404 /* !TIFF/FX version year */ +#define TIFFTAG_MODENUMBER 405 /* !TIFF/FX mode number */ +#define TIFFTAG_DECODE 433 /* !TIFF/FX decode */ +#define TIFFTAG_IMAGEBASECOLOR 434 /* !TIFF/FX image base colour */ +#define TIFFTAG_T82OPTIONS 435 /* !TIFF/FX T.82 options */ /* * Tags 512-521 are obsoleted by Technical Note #2 which specifies a * revised JPEG-in-TIFF scheme. @@ -342,6 +366,7 @@ typedef enum { #define YCBCRPOSITION_CENTERED 1 /* !as in PostScript Level 2 */ #define YCBCRPOSITION_COSITED 2 /* !as in CCIR 601-1 */ #define TIFFTAG_REFERENCEBLACKWHITE 532 /* !colorimetry info */ +#define TIFFTAG_STRIPROWCOUNTS 559 /* !TIFF/FX strip row counts */ #define TIFFTAG_XMLPACKET 700 /* %XML packet [Adobe XMP Specification, January 2004 */ @@ -408,6 +433,7 @@ typedef enum { #define TIFFTAG_EXIFIFD 34665 /* Pointer to EXIF private directory */ /* tag 34750 is a private tag registered to Adobe? */ #define TIFFTAG_ICCPROFILE 34675 /* ICC profile data */ +#define TIFFTAG_IMAGELAYER 34732 /* !TIFF/FX image layer information */ /* tag 34750 is a private tag registered to Pixel Magic */ #define TIFFTAG_JBIGOPTIONS 34750 /* JBIG options */ #define TIFFTAG_GPSIFD 34853 /* Pointer to GPS private directory */ diff --git a/Modules/ThirdParty/TIFF/src/itktiff/tiffio.h b/Modules/ThirdParty/TIFF/src/itktiff/tiffio.h index 2ac079b7c28..eb028b28adf 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/tiffio.h +++ b/Modules/ThirdParty/TIFF/src/itktiff/tiffio.h @@ -1,4 +1,4 @@ -/* $Id: tiffio.h,v 1.86 2010-03-10 18:56:49 bfriesen Exp $ */ +/* $Id: tiffio.h,v 1.91 2012-07-29 15:45:29 tgl Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -319,6 +319,13 @@ extern const TIFFField* TIFFFindField(TIFF *, uint32, TIFFDataType); extern const TIFFField* TIFFFieldWithTag(TIFF*, uint32); extern const TIFFField* TIFFFieldWithName(TIFF*, const char *); +extern uint32 TIFFFieldTag(const TIFFField*); +extern const char* TIFFFieldName(const TIFFField*); +extern TIFFDataType TIFFFieldDataType(const TIFFField*); +extern int TIFFFieldPassCount(const TIFFField*); +extern int TIFFFieldReadCount(const TIFFField*); +extern int TIFFFieldWriteCount(const TIFFField*); + typedef int (*TIFFVSetMethod)(TIFF*, uint32, va_list); typedef int (*TIFFVGetMethod)(TIFF*, uint32, va_list); typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long); @@ -392,6 +399,8 @@ extern int TIFFSetupStrips(TIFF *); extern int TIFFWriteCheck(TIFF*, int, const char *); extern void TIFFFreeDirectory(TIFF*); extern int TIFFCreateDirectory(TIFF*); +extern int TIFFCreateCustomDirectory(TIFF*,const TIFFFieldArray*); +extern int TIFFCreateEXIFDirectory(TIFF*); extern int TIFFLastDirectory(TIFF*); extern int TIFFSetDirectory(TIFF*, uint16); extern int TIFFSetSubDirectory(TIFF*, uint64); @@ -400,6 +409,7 @@ extern int TIFFSetField(TIFF*, uint32, ...); extern int TIFFVSetField(TIFF*, uint32, va_list); extern int TIFFUnsetField(TIFF*, uint32); extern int TIFFWriteDirectory(TIFF *); +extern int TIFFWriteCustomDirectory(TIFF *, uint64 *); extern int TIFFCheckpointDirectory(TIFF *); extern int TIFFRewriteDirectory(TIFF *); @@ -437,10 +447,10 @@ extern TIFF* TIFFClientOpen(const char*, const char*, TIFFMapFileProc, TIFFUnmapFileProc); extern const char* TIFFFileName(TIFF*); extern const char* TIFFSetFileName(TIFF*, const char *); -extern void TIFFError(const char*, const char*, ...) __attribute__((format (printf,2,3))); -extern void TIFFErrorExt(thandle_t, const char*, const char*, ...) __attribute__((format (printf,3,4))); -extern void TIFFWarning(const char*, const char*, ...) __attribute__((format (printf,2,3))); -extern void TIFFWarningExt(thandle_t, const char*, const char*, ...) __attribute__((format (printf,3,4))); +extern void TIFFError(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3))); +extern void TIFFErrorExt(thandle_t, const char*, const char*, ...) __attribute__((__format__ (__printf__,3,4))); +extern void TIFFWarning(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3))); +extern void TIFFWarningExt(thandle_t, const char*, const char*, ...) __attribute__((__format__ (__printf__,3,4))); extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler); extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt); extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler); @@ -530,9 +540,6 @@ typedef struct { } TIFFFieldInfo; extern int TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], uint32); -extern const TIFFFieldInfo* TIFFFindFieldInfo(TIFF*, uint32, TIFFDataType); -extern const TIFFFieldInfo* TIFFFindFieldInfoByName(TIFF* , const char *, - TIFFDataType); #if defined(c_plusplus) || defined(__cplusplus) } diff --git a/Modules/ThirdParty/TIFF/src/itktiff/tiffio.hxx b/Modules/ThirdParty/TIFF/src/itktiff/tiffio.hxx index ed994f11565..3367d2515cb 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/tiffio.hxx +++ b/Modules/ThirdParty/TIFF/src/itktiff/tiffio.hxx @@ -4,28 +4,28 @@ * 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. */ #ifndef _TIFFIO_HXX_ -#define _TIFFIO_HXX_ +#define _TIFFIO_HXX_ /* * TIFF I/O library definitions which provide C++ streams API. diff --git a/Modules/ThirdParty/TIFF/src/itktiff/tiffiop.h b/Modules/ThirdParty/TIFF/src/itktiff/tiffiop.h index 678e8adf11d..2a8e99d6aba 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/tiffiop.h +++ b/Modules/ThirdParty/TIFF/src/itktiff/tiffiop.h @@ -1,4 +1,4 @@ -/* $Id: tiffiop.h,v 1.82 2011-02-18 20:53:05 fwarmerdam Exp $ */ +/* $Id: tiffiop.h,v 1.84 2012-05-30 01:50:17 fwarmerdam Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -121,6 +121,7 @@ struct tiff { #define TIFF_BUF4WRITE 0x100000 /* rawcc bytes are for writing */ #define TIFF_DIRTYSTRIP 0x200000 /* stripoffsets/stripbytecount dirty*/ #define TIFF_PERSAMPLE 0x400000 /* get/set per sample tags as arrays */ + #define TIFF_BUFFERMMAP 0x800000 /* read buffer (tif_rawdata) points into mmap() memory */ uint64 tif_diroff; /* file offset of current directory */ uint64 tif_nextdiroff; /* file offset of following directory */ uint64* tif_dirlist; /* list of offsets to already seen directories to prevent IFD looping */ @@ -250,7 +251,7 @@ struct tiff { #define TIFFroundup_64(x, y) (TIFFhowmany_64(x,y)*(y)) /* Safe multiply which returns zero if there is an integer overflow */ -#define TIFFSafeMultiply(t,v,m) ((((t)m != (t)0) && (((t)((v*m)/m)) == (t)v)) ? (t)(v*m) : (t)0) +#define TIFFSafeMultiply(t,v,m) ((((t)(m) != (t)0) && (((t)(((v)*(m))/(m))) == (t)(v))) ? (t)((v)*(m)) : (t)0) #define TIFFmax(A,B) ((A)>(B)?(A):(B)) #define TIFFmin(A,B) ((A)<(B)?(A):(B)) diff --git a/Modules/ThirdParty/TIFF/src/itktiff/tiffvers.h b/Modules/ThirdParty/TIFF/src/itktiff/tiffvers.h index 44ed853c849..40edc813d5f 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/tiffvers.h +++ b/Modules/ThirdParty/TIFF/src/itktiff/tiffvers.h @@ -1,4 +1,4 @@ -#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.0.0beta7\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." +#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.0.3\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." /* * This define can be used in code that requires * compilation-related definitions specific to a @@ -6,4 +6,4 @@ * version checking should be done based on the * string returned by TIFFGetVersion. */ -#define TIFFLIB_VERSION 20110409 +#define TIFFLIB_VERSION 20120922