summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/libtiff/libtiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/libtiff/libtiff')
-rw-r--r--src/3rdparty/libtiff/libtiff/libtiff.def276
-rw-r--r--src/3rdparty/libtiff/libtiff/mkg3states.c5
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_codec.c4
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_config.h35
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_config.h.in31
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_config.vc.h64
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_dir.c68
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_dirinfo.c32
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_dirread.c77
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_dirwrite.c7
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_fax3.c5
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_getimage.c159
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_jpeg.c329
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_luv.c16
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_lzw.c59
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_next.c25
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_ojpeg.c21
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_pixarlog.c20
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_predict.c144
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_print.c12
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_read.c43
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_stream.cxx19
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_strip.c12
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_tile.c29
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_unix.c86
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_win32.c36
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_write.c40
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_zip.c27
-rw-r--r--src/3rdparty/libtiff/libtiff/tiff.h5
-rw-r--r--src/3rdparty/libtiff/libtiff/tiffconf.vc.h25
-rw-r--r--src/3rdparty/libtiff/libtiff/tiffiop.h55
-rw-r--r--src/3rdparty/libtiff/libtiff/tiffvers.h4
32 files changed, 1209 insertions, 561 deletions
diff --git a/src/3rdparty/libtiff/libtiff/libtiff.def b/src/3rdparty/libtiff/libtiff/libtiff.def
index 892ad23..98228f1 100644
--- a/src/3rdparty/libtiff/libtiff/libtiff.def
+++ b/src/3rdparty/libtiff/libtiff/libtiff.def
@@ -1,158 +1,164 @@
-EXPORTS TIFFOpen
- TIFFOpenW
- TIFFGetVersion
+EXPORTS TIFFAccessTagMethods
+ TIFFCIELabToRGBInit
+ TIFFCIELabToXYZ
+ TIFFCheckTile
+ TIFFCheckpointDirectory
TIFFCleanup
+ TIFFClientOpen
+ TIFFClientdata
TIFFClose
+ TIFFComputeStrip
+ TIFFComputeTile
+ TIFFCreateCustomDirectory
+ TIFFCreateDirectory
+ TIFFCreateEXIFDirectory
+ TIFFCurrentDirOffset
+ TIFFCurrentDirectory
+ TIFFCurrentRow
+ TIFFCurrentStrip
+ TIFFCurrentTile
+ TIFFDataWidth
+ TIFFDefaultStripSize
+ TIFFDefaultTileSize
+ TIFFError
+ TIFFErrorExt
+ TIFFFdOpen
+ TIFFFieldDataType
+ TIFFFieldName
+ TIFFFieldPassCount
+ TIFFFieldReadCount
+ TIFFFieldTag
+ TIFFFieldWithName
+ TIFFFieldWithTag
+ TIFFFieldWriteCount
+ TIFFFileName
+ TIFFFileno
+ TIFFFindCODEC
+ TIFFFindField
TIFFFlush
TIFFFlushData
+ TIFFFreeDirectory
+ TIFFGetBitRevTable
+ TIFFGetClientInfo
+ TIFFGetCloseProc
+ TIFFGetConfiguredCODECs
TIFFGetField
- TIFFVGetField
TIFFGetFieldDefaulted
- TIFFVGetFieldDefaulted
- TIFFGetTagListEntry
- TIFFGetTagListCount
- TIFFReadDirectory
- TIFFScanlineSize64
- TIFFScanlineSize
- TIFFStripSize64
- TIFFStripSize
- TIFFVStripSize64
- TIFFVStripSize
- TIFFRawStripSize64
- TIFFRawStripSize
- TIFFTileRowSize64
- TIFFTileRowSize
- TIFFTileSize64
- TIFFTileSize
- TIFFVTileSize64
- TIFFVTileSize
- TIFFFileno
- TIFFSetFileno
+ TIFFGetMapFileProc
TIFFGetMode
- TIFFIsTiled
- TIFFIsByteSwapped
+ TIFFGetReadProc
+ TIFFGetSeekProc
+ TIFFGetSizeProc
+ TIFFGetTagListCount
+ TIFFGetTagListEntry
+ TIFFGetUnmapFileProc
+ TIFFGetVersion
+ TIFFGetWriteProc
TIFFIsBigEndian
+ TIFFIsByteSwapped
+ TIFFIsCODECConfigured
TIFFIsMSB2LSB
+ TIFFIsTiled
TIFFIsUpSampled
- TIFFCIELabToRGBInit
- TIFFCIELabToXYZ
- TIFFXYZToRGB
- TIFFYCbCrToRGBInit
- TIFFYCbCrtoRGB
- TIFFCurrentRow
- TIFFCurrentDirectory
- TIFFCurrentStrip
- TIFFCurrentTile
- TIFFDataWidth
- TIFFReadBufferSetup
- TIFFWriteBufferSetup
- TIFFSetupStrips
TIFFLastDirectory
- TIFFSetDirectory
- TIFFSetSubDirectory
- TIFFUnlinkDirectory
- TIFFSetField
- TIFFVSetField
- TIFFCheckpointDirectory
- TIFFWriteDirectory
- TIFFRewriteDirectory
+ TIFFMergeFieldInfo
+ TIFFNumberOfDirectories
+ TIFFNumberOfStrips
+ TIFFNumberOfTiles
+ TIFFOpen
+ TIFFOpenW
TIFFPrintDirectory
- TIFFReadScanline
- TIFFWriteScanline
+ TIFFRGBAImageBegin
+ TIFFRGBAImageEnd
+ TIFFRGBAImageGet
+ TIFFRGBAImageOK
+ TIFFRasterScanlineSize
+ TIFFRasterScanlineSize64
+ TIFFRawStripSize
+ TIFFRawStripSize64
+ TIFFReadBufferSetup
+ TIFFReadCustomDirectory
+ TIFFReadDirectory
+ TIFFReadEXIFDirectory
+ TIFFReadEncodedStrip
+ TIFFReadEncodedTile
TIFFReadRGBAImage
TIFFReadRGBAImageOriented
- TIFFFdOpen
- TIFFClientOpen
- TIFFFileName
- TIFFError
- TIFFErrorExt
- TIFFWarning
- TIFFWarningExt
+ TIFFReadRGBAStrip
+ TIFFReadRGBATile
+ TIFFReadRawStrip
+ TIFFReadRawTile
+ TIFFReadScanline
+ TIFFReadTile
+ TIFFRegisterCODEC
+ TIFFReverseBits
+ TIFFRewriteDirectory
+ TIFFScanlineSize
+ TIFFScanlineSize64
+ TIFFSetClientInfo
+ TIFFSetClientdata
+ TIFFSetCompressionScheme
+ TIFFSetDirectory
TIFFSetErrorHandler
TIFFSetErrorHandlerExt
+ TIFFSetField
+ TIFFSetFileName
+ TIFFSetFileno
+ TIFFSetMode
+ TIFFSetSubDirectory
+ TIFFSetTagExtender
TIFFSetWarningHandler
TIFFSetWarningHandlerExt
- TIFFComputeTile
- TIFFCheckTile
- TIFFNumberOfTiles
- TIFFReadTile
- TIFFWriteTile
- TIFFComputeStrip
- TIFFNumberOfStrips
- TIFFRGBAImageBegin
- TIFFRGBAImageGet
- TIFFRGBAImageEnd
- TIFFReadEncodedStrip
- TIFFReadRawStrip
- TIFFReadEncodedTile
- TIFFReadRawTile
- TIFFReadRGBATile
- TIFFReadRGBAStrip
- TIFFWriteEncodedStrip
- TIFFWriteRawStrip
- TIFFWriteEncodedTile
- TIFFWriteRawTile
TIFFSetWriteOffset
- TIFFSwabFloat
- TIFFSwabDouble
- TIFFSwabShort
- TIFFSwabLong
- TIFFSwabArrayOfShort
- TIFFSwabArrayOfLong
- TIFFSwabArrayOfFloat
+ TIFFSetupStrips
+ TIFFStripSize
+ TIFFStripSize64
TIFFSwabArrayOfDouble
+ TIFFSwabArrayOfFloat
+ TIFFSwabArrayOfLong
+ TIFFSwabArrayOfLong8
+ TIFFSwabArrayOfShort
TIFFSwabArrayOfTriples
- TIFFReverseBits
- TIFFGetBitRevTable
- TIFFDefaultStripSize
- TIFFDefaultTileSize
- TIFFRasterScanlineSize64
- TIFFRasterScanlineSize
- _TIFFmalloc
- _TIFFrealloc
- _TIFFfree
- _TIFFmemset
- _TIFFmemcpy
- _TIFFmemcmp
- _TIFFCheckMalloc
- TIFFCreateDirectory
- TIFFSetTagExtender
- TIFFFieldWithName
- TIFFFieldWithTag
- TIFFFieldTag
- TIFFFieldName
- TIFFFieldDataType
- TIFFFieldPassCount
- TIFFFieldReadCount
- TIFFFieldWriteCount
- TIFFCurrentDirOffset
- TIFFWriteCheck
- TIFFRGBAImageOK
- TIFFNumberOfDirectories
- TIFFSetFileName
- TIFFSetClientdata
- TIFFSetMode
- TIFFClientdata
- TIFFGetReadProc
- TIFFGetWriteProc
- TIFFGetSeekProc
- TIFFGetCloseProc
- TIFFGetSizeProc
- TIFFGetMapFileProc
- TIFFGetUnmapFileProc
- TIFFIsCODECConfigured
- TIFFGetConfiguredCODECs
- TIFFFindCODEC
- TIFFRegisterCODEC
- TIFFUnRegisterCODEC
- TIFFFreeDirectory
- TIFFReadCustomDirectory
- TIFFReadEXIFDirectory
- TIFFAccessTagMethods
- TIFFGetClientInfo
- TIFFSetClientInfo
+ TIFFSwabDouble
+ TIFFSwabFloat
+ TIFFSwabLong
TIFFSwabLong8
- TIFFSwabArrayOfLong8
- TIFFFindField
+ TIFFSwabShort
+ TIFFTileRowSize
+ TIFFTileRowSize64
+ TIFFTileSize
+ TIFFTileSize64
+ TIFFUnRegisterCODEC
+ TIFFUnlinkDirectory
TIFFUnsetField
- TIFFMergeFieldInfo
+ TIFFVGetField
+ TIFFVGetFieldDefaulted
+ TIFFVSetField
+ TIFFVStripSize
+ TIFFVStripSize64
+ TIFFVTileSize
+ TIFFVTileSize64
+ TIFFWarning
+ TIFFWarningExt
+ TIFFWriteBufferSetup
+ TIFFWriteCheck
+ TIFFWriteCustomDirectory
+ TIFFWriteDirectory
+ TIFFWriteEncodedStrip
+ TIFFWriteEncodedTile
+ TIFFWriteRawStrip
+ TIFFWriteRawTile
+ TIFFWriteScanline
+ TIFFWriteTile
+ TIFFXYZToRGB
+ TIFFYCbCrToRGBInit
+ TIFFYCbCrtoRGB
+ _TIFFCheckMalloc
+ _TIFFCheckRealloc
+ _TIFFRewriteField
+ _TIFFfree
+ _TIFFmalloc
+ _TIFFmemcmp
+ _TIFFmemcpy
+ _TIFFmemset
+ _TIFFrealloc
diff --git a/src/3rdparty/libtiff/libtiff/mkg3states.c b/src/3rdparty/libtiff/libtiff/mkg3states.c
index 1df9ccc..16ad3c2 100644
--- a/src/3rdparty/libtiff/libtiff/mkg3states.c
+++ b/src/3rdparty/libtiff/libtiff/mkg3states.c
@@ -1,4 +1,4 @@
-/* "$Id: mkg3states.c,v 1.11 2010-03-10 18:56:48 bfriesen Exp $ */
+/* "$Id: mkg3states.c,v 1.12 2015-06-21 01:09:09 bfriesen Exp $ */
/*
* Copyright (c) 1991-1997 Sam Leffler
@@ -383,8 +383,11 @@ main(int argc, char* argv[])
FILE* fd;
char* outputfile;
int c;
+
+#if !HAVE_DECL_OPTARG
extern int optind;
extern char* optarg;
+#endif
while ((c = getopt(argc, argv, "c:s:bp")) != -1)
switch (c) {
diff --git a/src/3rdparty/libtiff/libtiff/tif_codec.c b/src/3rdparty/libtiff/libtiff/tif_codec.c
index e201667..7cb46f6 100644
--- a/src/3rdparty/libtiff/libtiff/tif_codec.c
+++ b/src/3rdparty/libtiff/libtiff/tif_codec.c
@@ -1,4 +1,4 @@
-/* $Id: tif_codec.c,v 1.15 2010-12-14 12:53:00 dron Exp $ */
+/* $Id: tif_codec.c,v 1.17 2015-08-19 02:31:04 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@@ -108,7 +108,7 @@ _notConfigured(TIFF* tif)
const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression);
char compression_code[20];
- sprintf( compression_code, "%d", tif->tif_dir.td_compression );
+ sprintf(compression_code, "%d",tif->tif_dir.td_compression );
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"%s compression support is not configured",
c ? c->name : compression_code );
diff --git a/src/3rdparty/libtiff/libtiff/tif_config.h b/src/3rdparty/libtiff/libtiff/tif_config.h
index 64ab64b..a6bf38c 100644
--- a/src/3rdparty/libtiff/libtiff/tif_config.h
+++ b/src/3rdparty/libtiff/libtiff/tif_config.h
@@ -38,6 +38,10 @@
/* Define to 1 if you have the <assert.h> header file. */
#define HAVE_ASSERT_H 1
+/* Define to 1 if you have the declaration of `optarg', and to 0 if you don't.
+ */
+#define HAVE_DECL_OPTARG 0
+
/* Define to 1 if you have the <dlfcn.h> header file. */
/* #undef HAVE_DLFCN_H */
@@ -49,6 +53,9 @@
/* Define to 1 if you have the `floor' function. */
/* #undef HAVE_FLOOR */
+/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
+/* #undef HAVE_FSEEKO */
+
/* Define to 1 if you have the `getopt' function. */
/* #undef HAVE_GETOPT */
@@ -101,9 +108,6 @@
/* Define to 1 if you have the `c' library (-lc). */
/* #undef HAVE_LIBC */
-/* Define to 1 if you have the `m' library (-lm). */
-/* #undef HAVE_LIBM */
-
/* Define to 1 if you have the <limits.h> header file. */
/* #undef HAVE_LIMITS_H */
@@ -142,6 +146,11 @@
/* Define to 1 if you have the `setmode' function. */
/* #undef HAVE_SETMODE */
+/* Define to 1 if you have the `snprintf' function. */
+#if defined(snprintf) || (!defined(_MSC_VER) || _MSC_VER >= 1900)
+#define HAVE_SNPRINTF 1
+#endif
+
/* Define to 1 if you have the `sqrt' function. */
/* #undef HAVE_SQRT */
@@ -220,8 +229,7 @@
/* Support LogLuv high dynamic range encoding */
/* #undef LOGLUV_SUPPORT */
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
- */
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
/* #undef LT_OBJDIR */
/* Support LZMA2 compression */
@@ -236,9 +244,6 @@
/* Support NeXT 2-bit RLE algorithm */
/* #undef NEXT_SUPPORT */
-/* Define to 1 if your C compiler doesn't accept -c and -o together. */
-/* #undef NO_MINUS_C_MINUS_O */
-
/* Support Old JPEG compresson (read-only) */
/* #undef OJPEG_SUPPORT */
@@ -261,7 +266,7 @@
/* #undef PACKAGE_URL */
/* Define to the version of this package. */
-#define PACKAGE_VERSION "4.0.3"
+#define PACKAGE_VERSION "4.0.6"
/* Support Macintosh PackBits algorithm */
/* #undef PACKBITS_SUPPORT */
@@ -285,6 +290,9 @@
/* The size of `signed short', as computed by sizeof. */
/* #undef SIZEOF_SIGNED_SHORT */
+/* The size of `size_t', as computed by sizeof. */
+/* #undef SIZEOF_SIZE_T */
+
/* The size of `unsigned char *', as computed by sizeof. */
/* #undef SIZEOF_UNSIGNED_CHAR_P */
@@ -340,6 +348,12 @@
/* Pointer difference type */
#define TIFF_PTRDIFF_T ptrdiff_t
+/* Size type formatter */
+/* #undef TIFF_SIZE_FORMAT */
+
+/* Unsigned size type */
+/* #undef TIFF_SIZE_T */
+
/* Signed size type formatter */
#if QT_POINTER_SIZE == 4
#define TIFF_SSIZE_FORMAT "%ld"
@@ -404,6 +418,9 @@
/* Number of bits in a file offset, on hosts where this is settable. */
/* #undef _FILE_OFFSET_BITS */
+/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
+/* #undef _LARGEFILE_SOURCE */
+
/* Define for large files, on AIX-style hosts. */
/* #undef _LARGE_FILES */
diff --git a/src/3rdparty/libtiff/libtiff/tif_config.h.in b/src/3rdparty/libtiff/libtiff/tif_config.h.in
index b2cea35..a4b2e60 100644
--- a/src/3rdparty/libtiff/libtiff/tif_config.h.in
+++ b/src/3rdparty/libtiff/libtiff/tif_config.h.in
@@ -27,6 +27,10 @@
/* Define to 1 if you have the <assert.h> header file. */
#undef HAVE_ASSERT_H
+/* Define to 1 if you have the declaration of `optarg', and to 0 if you don't.
+ */
+#undef HAVE_DECL_OPTARG
+
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
@@ -36,6 +40,9 @@
/* Define to 1 if you have the `floor' function. */
#undef HAVE_FLOOR
+/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
+#undef HAVE_FSEEKO
+
/* Define to 1 if you have the `getopt' function. */
#undef HAVE_GETOPT
@@ -79,9 +86,6 @@
/* Define to 1 if you have the `lfind' function. */
#undef HAVE_LFIND
-/* Define to 1 if you have the `m' library (-lm). */
-#undef HAVE_LIBM
-
/* Define to 1 if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
@@ -118,6 +122,9 @@
/* Define to 1 if you have the `setmode' function. */
#undef HAVE_SETMODE
+/* Define to 1 if you have the `snprintf' function. */
+#undef HAVE_SNPRINTF
+
/* Define to 1 if you have the `sqrt' function. */
#undef HAVE_SQRT
@@ -194,8 +201,7 @@
/* Support LogLuv high dynamic range encoding */
#undef LOGLUV_SUPPORT
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
- */
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
#undef LT_OBJDIR
/* Support LZMA2 compression */
@@ -210,9 +216,6 @@
/* Support NeXT 2-bit RLE algorithm */
#undef NEXT_SUPPORT
-/* Define to 1 if your C compiler doesn't accept -c and -o together. */
-#undef NO_MINUS_C_MINUS_O
-
/* Support Old JPEG compresson (read-only) */
#undef OJPEG_SUPPORT
@@ -259,6 +262,9 @@
/* The size of `signed short', as computed by sizeof. */
#undef SIZEOF_SIGNED_SHORT
+/* The size of `size_t', as computed by sizeof. */
+#undef SIZEOF_SIZE_T
+
/* The size of `unsigned char *', as computed by sizeof. */
#undef SIZEOF_UNSIGNED_CHAR_P
@@ -314,6 +320,12 @@
/* Pointer difference type */
#undef TIFF_PTRDIFF_T
+/* Size type formatter */
+#undef TIFF_SIZE_FORMAT
+
+/* Unsigned size type */
+#undef TIFF_SIZE_T
+
/* Signed size type formatter */
#undef TIFF_SSIZE_FORMAT
@@ -376,6 +388,9 @@
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS
+/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
+#undef _LARGEFILE_SOURCE
+
/* Define for large files, on AIX-style hosts. */
#undef _LARGE_FILES
diff --git a/src/3rdparty/libtiff/libtiff/tif_config.vc.h b/src/3rdparty/libtiff/libtiff/tif_config.vc.h
index c297cf3..7e6c5c2 100644
--- a/src/3rdparty/libtiff/libtiff/tif_config.vc.h
+++ b/src/3rdparty/libtiff/libtiff/tif_config.vc.h
@@ -1,3 +1,6 @@
+#ifndef _TIF_CONFIG_H_
+#define _TIF_CONFIG_H_
+
/* Define to 1 if you have the <assert.h> header file. */
#define HAVE_ASSERT_H 1
@@ -26,6 +29,9 @@
/* Define to 1 if you have the `setmode' function. */
#define HAVE_SETMODE 1
+/* Define to 1 if you have the declaration of `optarg', and to 0 if you don't. */
+#define HAVE_DECL_OPTARG 0
+
/* The size of a `int', as computed by sizeof. */
#define SIZEOF_INT 4
@@ -44,10 +50,64 @@
/* Unsigned 64-bit type */
#define TIFF_UINT64_T unsigned __int64
+#if _WIN64
+/*
+ Windows 64-bit build
+*/
+
+/* Pointer difference type */
+# define TIFF_PTRDIFF_T TIFF_INT64_T
+
+/* The size of `size_t', as computed by sizeof. */
+# define SIZEOF_SIZE_T 8
+
+/* Size type formatter */
+# define TIFF_SIZE_FORMAT TIFF_INT64_FORMAT
+
+/* Unsigned size type */
+# define TIFF_SIZE_T TIFF_UINT64_T
+
+/* Signed size type formatter */
+# define TIFF_SSIZE_FORMAT TIFF_INT64_FORMAT
+
+/* Signed size type */
+# define TIFF_SSIZE_T TIFF_INT64_T
+
+#else
+/*
+ Windows 32-bit build
+*/
+
+/* Pointer difference type */
+# define TIFF_PTRDIFF_T signed int
+
+/* The size of `size_t', as computed by sizeof. */
+# define SIZEOF_SIZE_T 4
+
+/* Size type formatter */
+# define TIFF_SIZE_FORMAT "%u"
+
+/* Size type formatter */
+# define TIFF_SIZE_FORMAT "%u"
+
+/* Unsigned size type */
+# define TIFF_SIZE_T unsigned int
+
+/* Signed size type formatter */
+# define TIFF_SSIZE_FORMAT "%d"
+
+/* Signed size type */
+# define TIFF_SSIZE_T signed int
+
+#endif
+
/* Set the native cpu bit order */
#define HOST_FILLORDER FILLORDER_LSB2MSB
+/* Visual Studio 2015 / VC 14 / MSVC 19.00 finally has snprintf() */
+#if defined(_MSC_VER) && _MSC_VER < 1900
#define snprintf _snprintf
+#endif
/* Define to 1 if your processor stores words with the most significant byte
first (like Motorola and SPARC, unlike Intel and VAX). */
@@ -62,6 +122,10 @@
#endif
#define lfind _lfind
+
+#pragma warning(disable : 4996) /* function deprecation warnings */
+
+#endif /* _TIF_CONFIG_H_ */
/*
* Local Variables:
* mode: c
diff --git a/src/3rdparty/libtiff/libtiff/tif_dir.c b/src/3rdparty/libtiff/libtiff/tif_dir.c
index 8bf3ea7..73212c0 100644
--- a/src/3rdparty/libtiff/libtiff/tif_dir.c
+++ b/src/3rdparty/libtiff/libtiff/tif_dir.c
@@ -1,4 +1,4 @@
-/* $Id: tif_dir.c,v 1.113 2012-06-14 20:32:53 fwarmerdam Exp $ */
+/* $Id: tif_dir.c,v 1.121 2015-05-31 23:11:43 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@@ -160,10 +160,12 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
TIFFDirectory* td = &tif->tif_dir;
int status = 1;
uint32 v32, i, v;
+ double dblval;
char* s;
const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
uint32 standard_tag = tag;
-
+ if( fip == NULL ) /* cannot happen since OkToChangeTag() already checks it */
+ return 0;
/*
* We want to force the custom code to be used for custom
* fields even if the tag happens to match a well known
@@ -283,10 +285,16 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
setDoubleArrayOneValue(&td->td_smaxsamplevalue, va_arg(ap, double), td->td_samplesperpixel);
break;
case TIFFTAG_XRESOLUTION:
- td->td_xresolution = (float) va_arg(ap, double);
+ dblval = va_arg(ap, double);
+ if( dblval < 0 )
+ goto badvaluedouble;
+ td->td_xresolution = (float) dblval;
break;
case TIFFTAG_YRESOLUTION:
- td->td_yresolution = (float) va_arg(ap, double);
+ dblval = va_arg(ap, double);
+ if( dblval < 0 )
+ goto badvaluedouble;
+ td->td_yresolution = (float) dblval;
break;
case TIFFTAG_PLANARCONFIG:
v = (uint16) va_arg(ap, uint16_vap);
@@ -449,11 +457,11 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
* happens, for example, when tiffcp is used to convert between
* compression schemes and codec-specific tags are blindly copied.
*/
- if(fip == NULL || fip->field_bit != FIELD_CUSTOM) {
+ if(fip->field_bit != FIELD_CUSTOM) {
TIFFErrorExt(tif->tif_clientdata, module,
"%s: Invalid %stag \"%s\" (not supported by codec)",
tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "",
- fip ? fip->field_name : "Unknown");
+ fip->field_name);
status = 0;
break;
}
@@ -693,6 +701,16 @@ badvalue32:
va_end(ap);
}
return (0);
+badvaluedouble:
+ {
+ const TIFFField* fip=TIFFFieldWithTag(tif,tag);
+ TIFFErrorExt(tif->tif_clientdata, module,
+ "%s: Bad value %f for \"%s\" tag",
+ tif->tif_name, dblval,
+ fip ? fip->field_name : "Unknown");
+ va_end(ap);
+ }
+ return (0);
}
/*
@@ -809,6 +827,8 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
int ret_val = 1;
uint32 standard_tag = tag;
const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY);
+ if( fip == NULL ) /* cannot happen since TIFFGetField() already checks it */
+ return 0;
/*
* We want to force the custom code to be used for custom
@@ -1006,14 +1026,14 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
* get a tag that is not valid for the image's
* codec then we'll arrive here.
*/
- if( fip == NULL || fip->field_bit != FIELD_CUSTOM )
+ if( fip->field_bit != FIELD_CUSTOM )
{
TIFFErrorExt(tif->tif_clientdata, "_TIFFVGetField",
"%s: Invalid %stag \"%s\" "
"(not supported by codec)",
tif->tif_name,
isPseudoTag(tag) ? "pseudo-" : "",
- fip ? fip->field_name : "Unknown");
+ fip->field_name);
ret_val = 0;
break;
}
@@ -1302,8 +1322,20 @@ TIFFDefaultDirectory(TIFF* tif)
tif->tif_tagmethods.printdir = NULL;
/*
* Give client code a chance to install their own
- * tag extensions & methods, prior to compression overloads.
+ * tag extensions & methods, prior to compression overloads,
+ * but do some prior cleanup first. (http://trac.osgeo.org/gdal/ticket/5054)
*/
+ if (tif->tif_nfieldscompat > 0) {
+ uint32 i;
+
+ for (i = 0; i < tif->tif_nfieldscompat; i++) {
+ if (tif->tif_fieldscompat[i].allocated_size)
+ _TIFFfree(tif->tif_fieldscompat[i].fields);
+ }
+ _TIFFfree(tif->tif_fieldscompat);
+ tif->tif_nfieldscompat = 0;
+ tif->tif_fieldscompat = NULL;
+ }
if (_TIFFextender)
(*_TIFFextender)(tif);
(void) TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
@@ -1344,6 +1376,7 @@ TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off)
if (((uint64)poffa!=poff)||(poffb<poffa)||(poffb<(tmsize_t)sizeof(uint16))||(poffb>tif->tif_size))
{
TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory count");
+ *nextdir=0;
return(0);
}
_TIFFmemcpy(&dircount,tif->tif_base+poffa,sizeof(uint16));
@@ -1453,7 +1486,8 @@ TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off)
(void) TIFFSeekFile(tif,
dircount16*20, SEEK_CUR);
if (!ReadOK(tif, nextdir, sizeof (uint64))) {
- TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory link",
+ TIFFErrorExt(tif->tif_clientdata, module,
+ "%s: Error fetching directory link",
tif->tif_name);
return (0);
}
@@ -1470,6 +1504,7 @@ TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off)
uint16
TIFFNumberOfDirectories(TIFF* tif)
{
+ static const char module[] = "TIFFNumberOfDirectories";
uint64 nextdir;
uint16 n;
if (!(tif->tif_flags&TIFF_BIGTIFF))
@@ -1478,7 +1513,18 @@ TIFFNumberOfDirectories(TIFF* tif)
nextdir = tif->tif_header.big.tiff_diroff;
n = 0;
while (nextdir != 0 && TIFFAdvanceDirectory(tif, &nextdir, NULL))
- n++;
+ {
+ if (n != 65535) {
+ ++n;
+ }
+ else
+ {
+ TIFFErrorExt(tif->tif_clientdata, module,
+ "Directory count exceeded 65535 limit,"
+ " giving up on counting.");
+ return (65535);
+ }
+ }
return (n);
}
diff --git a/src/3rdparty/libtiff/libtiff/tif_dirinfo.c b/src/3rdparty/libtiff/libtiff/tif_dirinfo.c
index d319931..7db4bdb 100644
--- a/src/3rdparty/libtiff/libtiff/tif_dirinfo.c
+++ b/src/3rdparty/libtiff/libtiff/tif_dirinfo.c
@@ -1,4 +1,4 @@
-/* $Id: tif_dirinfo.c,v 1.117 2012-08-19 16:56:34 bfriesen Exp $ */
+/* $Id: tif_dirinfo.c,v 1.121 2014-05-07 01:58:46 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@@ -128,6 +128,8 @@ tiffFields[] = {
{ TIFFTAG_PIXAR_FOVCOT, 1, 1, TIFF_FLOAT, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FieldOfViewCotangent", NULL },
{ TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN, 16, 16, TIFF_FLOAT, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MatrixWorldToScreen", NULL },
{ TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA, 16, 16, TIFF_FLOAT, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MatrixWorldToCamera", NULL },
+ { TIFFTAG_CFAREPEATPATTERNDIM, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "CFARepeatPatternDim", NULL },
+ { TIFFTAG_CFAPATTERN, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "CFAPattern" , NULL},
{ TIFFTAG_COPYRIGHT, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Copyright", NULL },
/* end Pixar tags */
{ TIFFTAG_RICHTIFFIPTC, -3, -3, TIFF_LONG, 0, TIFF_SETGET_C32_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "RichTIFFIPTC", NULL },
@@ -193,19 +195,19 @@ tiffFields[] = {
{ 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 */
+ { TIFFTAG_INDEXED, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "Indexed", NULL },
+ { TIFFTAG_GLOBALPARAMETERSIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, 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 TIFF/FX tags */
/* begin pseudo tags */
};
@@ -711,7 +713,7 @@ _TIFFCreateAnonField(TIFF *tif, uint32 tag, TIFFDataType field_type)
* note that this name is a special sign to TIFFClose() and
* _TIFFSetupFields() to free the field
*/
- sprintf(fld->field_name, "Tag %d", (int) tag);
+ snprintf(fld->field_name, 32, "Tag %d", (int) tag);
return fld;
}
diff --git a/src/3rdparty/libtiff/libtiff/tif_dirread.c b/src/3rdparty/libtiff/libtiff/tif_dirread.c
index 19a26e2..a0dc68b 100644
--- a/src/3rdparty/libtiff/libtiff/tif_dirread.c
+++ b/src/3rdparty/libtiff/libtiff/tif_dirread.c
@@ -1,4 +1,4 @@
-/* $Id: tif_dirread.c,v 1.178 2012-08-19 16:56:34 bfriesen Exp $ */
+/* $Id: tif_dirread.c,v 1.191 2015-09-05 20:31:41 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@@ -2172,11 +2172,6 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8Array(TIFF* tif, TIFFDirEn
break;
}
_TIFFfree(origdata);
- if (err!=TIFFReadDirEntryErrOk)
- {
- _TIFFfree(data);
- return(err);
- }
*value=data;
return(TIFFReadDirEntryErrOk);
}
@@ -2414,11 +2409,6 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF* tif, TIFFDirEnt
break;
}
_TIFFfree(origdata);
- if (err!=TIFFReadDirEntryErrOk)
- {
- _TIFFfree(data);
- return(err);
- }
*value=data;
return(TIFFReadDirEntryErrOk);
}
@@ -2657,11 +2647,6 @@ TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEntry* direntry, double** value)
break;
}
_TIFFfree(origdata);
- if (err!=TIFFReadDirEntryErrOk)
- {
- _TIFFfree(data);
- return(err);
- }
*value=data;
return(TIFFReadDirEntryErrOk);
}
@@ -2723,11 +2708,6 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8Array(TIFF* tif, TIFFDirEntr
break;
}
_TIFFfree(origdata);
- if (err!=TIFFReadDirEntryErrOk)
- {
- _TIFFfree(data);
- return(err);
- }
*value=data;
return(TIFFReadDirEntryErrOk);
}
@@ -3194,11 +3174,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSlong(int32 value)
/*
* Largest 32-bit unsigned integer value.
*/
-#if defined(__WIN32__) && defined(_MSC_VER)
-# define TIFF_UINT32_MAX 0xFFFFFFFFI64
-#else
-# define TIFF_UINT32_MAX 0xFFFFFFFFLL
-#endif
+#define TIFF_UINT32_MAX 0xFFFFFFFFU
static enum TIFFReadDirEntryErr
TIFFReadDirEntryCheckRangeLongLong8(uint64 value)
@@ -3212,7 +3188,7 @@ TIFFReadDirEntryCheckRangeLongLong8(uint64 value)
static enum TIFFReadDirEntryErr
TIFFReadDirEntryCheckRangeLongSlong8(int64 value)
{
- if ((value<0) || (value > TIFF_UINT32_MAX))
+ if ((value < 0) || (value > (int64) TIFF_UINT32_MAX))
return(TIFFReadDirEntryErrRange);
else
return(TIFFReadDirEntryErrOk);
@@ -3229,19 +3205,21 @@ TIFFReadDirEntryCheckRangeSlongLong(uint32 value)
return(TIFFReadDirEntryErrOk);
}
+/* Check that the 8-byte unsigned value can fit in a 4-byte unsigned range */
static enum TIFFReadDirEntryErr
TIFFReadDirEntryCheckRangeSlongLong8(uint64 value)
{
- if (value > 0x7FFFFFFFUL)
+ if (value > 0x7FFFFFFF)
return(TIFFReadDirEntryErrRange);
else
return(TIFFReadDirEntryErrOk);
}
+/* Check that the 8-byte signed value can fit in a 4-byte signed range */
static enum TIFFReadDirEntryErr
TIFFReadDirEntryCheckRangeSlongSlong8(int64 value)
{
- if ((value < 0L-0x80000000L) || (value > 0x7FFFFFFFL))
+ if ((value < 0-((int64) 0x7FFFFFFF+1)) || (value > 0x7FFFFFFF))
return(TIFFReadDirEntryErrRange);
else
return(TIFFReadDirEntryErrOk);
@@ -3286,11 +3264,7 @@ TIFFReadDirEntryCheckRangeLong8Slong8(int64 value)
/*
* Largest 64-bit signed integer value.
*/
-#if defined(__WIN32__) && defined(_MSC_VER)
-# define TIFF_INT64_MAX 0x7FFFFFFFFFFFFFFFI64
-#else
-# define TIFF_INT64_MAX 0x7FFFFFFFFFFFFFFFLL
-#endif
+#define TIFF_INT64_MAX ((int64)(((uint64) ~0) >> 1))
static enum TIFFReadDirEntryErr
TIFFReadDirEntryCheckRangeSlong8Long8(uint64 value)
@@ -3374,7 +3348,7 @@ static void TIFFReadDirEntryOutputErr(TIFF* tif, enum TIFFReadDirEntryErr err, c
} else {
switch (err) {
case TIFFReadDirEntryErrCount:
- TIFFErrorExt(tif->tif_clientdata, module,
+ TIFFWarningExt(tif->tif_clientdata, module,
"Incorrect count for \"%s\"; tag ignored",
tagname);
break;
@@ -3430,6 +3404,8 @@ TIFFReadDirectory(TIFF* tif)
const TIFFField* fip;
uint32 fii=FAILED_FII;
toff_t nextdiroff;
+ int bitspersample_read = FALSE;
+
tif->tif_diroff=tif->tif_nextdiroff;
if (!TIFFCheckDirOffset(tif,tif->tif_nextdiroff))
return 0; /* last offset or bad offset (IFD looping) */
@@ -3706,6 +3682,8 @@ TIFFReadDirectory(TIFF* tif)
}
if (!TIFFSetField(tif,dp->tdir_tag,value))
goto bad;
+ if( dp->tdir_tag == TIFFTAG_BITSPERSAMPLE )
+ bitspersample_read = TRUE;
}
break;
case TIFFTAG_SMINSAMPLEVALUE:
@@ -3763,6 +3741,19 @@ TIFFReadDirectory(TIFF* tif)
uint32 countrequired;
uint32 incrementpersample;
uint16* value=NULL;
+ /* It would be dangerous to instanciate those tag values */
+ /* since if td_bitspersample has not yet been read (due to */
+ /* unordered tags), it could be read afterwards with a */
+ /* values greater than the default one (1), which may cause */
+ /* crashes in user code */
+ if( !bitspersample_read )
+ {
+ fip = TIFFFieldWithTag(tif,dp->tdir_tag);
+ TIFFWarningExt(tif->tif_clientdata,module,
+ "Ignoring %s since BitsPerSample tag not found",
+ fip ? fip->field_name : "unknown tagname");
+ continue;
+ }
countpersample=(1L<<tif->tif_dir.td_bitspersample);
if ((dp->tdir_tag==TIFFTAG_TRANSFERFUNCTION)&&(dp->tdir_count==(uint64)countpersample))
{
@@ -4278,7 +4269,8 @@ EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount)
TIFFDirectory *td = &tif->tif_dir;
uint32 strip;
- _TIFFFillStriles( tif );
+ if( !_TIFFFillStriles( tif ) )
+ return -1;
if (td->td_stripbytecount)
_TIFFfree(td->td_stripbytecount);
@@ -4377,6 +4369,11 @@ TIFFCheckDirOffset(TIFF* tif, uint64 diroff)
if (diroff == 0) /* no more directories */
return 0;
+ if (tif->tif_dirnumber == 65535) {
+ TIFFErrorExt(tif->tif_clientdata, "TIFFCheckDirOffset",
+ "Cannot handle more than 65535 TIFF directories");
+ return 0;
+ }
for (n = 0; n < tif->tif_dirnumber && tif->tif_dirlist; n++) {
if (tif->tif_dirlist[n] == diroff)
@@ -4396,7 +4393,10 @@ TIFFCheckDirOffset(TIFF* tif, uint64 diroff)
tif->tif_dirnumber, 2 * sizeof(uint64), "for IFD list");
if (!new_dirlist)
return 0;
- tif->tif_dirlistsize = 2 * tif->tif_dirnumber;
+ if( tif->tif_dirnumber >= 32768 )
+ tif->tif_dirlistsize = 65535;
+ else
+ tif->tif_dirlistsize = 2 * tif->tif_dirnumber;
tif->tif_dirlist = new_dirlist;
}
@@ -4708,6 +4708,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover)
return 0;
}
fip=tif->tif_fields[fii];
+ assert(fip != NULL); /* should not happen */
assert(fip->set_field_type!=TIFF_SETGET_OTHER); /* if so, we shouldn't arrive here but deal with this in specialized code */
assert(fip->set_field_type!=TIFF_SETGET_INT); /* if so, we shouldn't arrive here as this is only the case for pseudo-tags */
err=TIFFReadDirEntryErrOk;
@@ -5355,7 +5356,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover)
}
if (err!=TIFFReadDirEntryErrOk)
{
- TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : "unknown tagname",recover);
+ TIFFReadDirEntryOutputErr(tif,err,module,fip->field_name,recover);
return(0);
}
return(1);
diff --git a/src/3rdparty/libtiff/libtiff/tif_dirwrite.c b/src/3rdparty/libtiff/libtiff/tif_dirwrite.c
index fa20609..a0fd8dc 100644
--- a/src/3rdparty/libtiff/libtiff/tif_dirwrite.c
+++ b/src/3rdparty/libtiff/libtiff/tif_dirwrite.c
@@ -1,4 +1,4 @@
-/* $Id: tif_dirwrite.c,v 1.77 2012-07-06 19:18:31 bfriesen Exp $ */
+/* $Id: tif_dirwrite.c,v 1.78 2015-05-31 00:38:46 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@@ -2839,14 +2839,15 @@ _TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype,
"Error writing directory link");
return (0);
}
-
- _TIFFfree( buf_to_write );
}
else
{
memcpy( &entry_offset, buf_to_write, count*TIFFDataWidth(datatype));
}
+ _TIFFfree( buf_to_write );
+ buf_to_write = 0;
+
/* -------------------------------------------------------------------- */
/* Adjust the directory entry. */
/* -------------------------------------------------------------------- */
diff --git a/src/3rdparty/libtiff/libtiff/tif_fax3.c b/src/3rdparty/libtiff/libtiff/tif_fax3.c
index 2b2dccd..bbe7255 100644
--- a/src/3rdparty/libtiff/libtiff/tif_fax3.c
+++ b/src/3rdparty/libtiff/libtiff/tif_fax3.c
@@ -1,4 +1,4 @@
-/* $Id: tif_fax3.c,v 1.74 2012-06-21 02:01:31 fwarmerdam Exp $ */
+/* $Id: tif_fax3.c,v 1.75 2015-08-30 20:49:55 erouault Exp $ */
/*
* Copyright (c) 1990-1997 Sam Leffler
@@ -442,8 +442,9 @@ _TIFFFax3fillruns(unsigned char* buf, uint32* runs, uint32* erun, uint32 lastx)
FILL(n, cp);
run &= 7;
}
+ /* Explicit 0xff masking to make icc -check=conversions happy */
if (run)
- cp[0] |= 0xff00 >> run;
+ cp[0] = (unsigned char)((cp[0] | (0xff00 >> run))&0xff);
} else
cp[0] |= _fillmasks[run]>>bx;
x += runs[1];
diff --git a/src/3rdparty/libtiff/libtiff/tif_getimage.c b/src/3rdparty/libtiff/libtiff/tif_getimage.c
index a85273c..f49b73f 100644
--- a/src/3rdparty/libtiff/libtiff/tif_getimage.c
+++ b/src/3rdparty/libtiff/libtiff/tif_getimage.c
@@ -1,4 +1,4 @@
-/* $Id: tif_getimage.c,v 1.82 2012-06-06 00:17:49 fwarmerdam Exp $ */
+/* $Id: tif_getimage.c,v 1.90 2015-06-17 01:34:08 bfriesen Exp $ */
/*
* Copyright (c) 1991-1997 Sam Leffler
@@ -182,8 +182,23 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024])
"Planarconfiguration", td->td_planarconfig);
return (0);
}
+ if( td->td_samplesperpixel != 3 )
+ {
+ sprintf(emsg,
+ "Sorry, can not handle image with %s=%d",
+ "Samples/pixel", td->td_samplesperpixel);
+ return 0;
+ }
break;
case PHOTOMETRIC_CIELAB:
+ if( td->td_samplesperpixel != 3 || td->td_bitspersample != 8 )
+ {
+ sprintf(emsg,
+ "Sorry, can not handle image with %s=%d and %s=%d",
+ "Samples/pixel", td->td_samplesperpixel,
+ "Bits/sample", td->td_bitspersample);
+ return 0;
+ }
break;
default:
sprintf(emsg, "Sorry, can not handle image with %s=%d",
@@ -597,6 +612,10 @@ gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
int32 fromskew, toskew;
uint32 nrow;
int ret = 1, flip;
+ uint32 this_tw, tocol;
+ int32 this_toskew, leftmost_toskew;
+ int32 leftmost_fromskew;
+ uint32 leftmost_tw;
buf = (unsigned char*) _TIFFmalloc(TIFFTileSize(tif));
if (buf == 0) {
@@ -617,37 +636,50 @@ gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
toskew = -(int32)(tw - w);
}
+ /*
+ * Leftmost tile is clipped on left side if col_offset > 0.
+ */
+ leftmost_fromskew = img->col_offset % tw;
+ leftmost_tw = tw - leftmost_fromskew;
+ leftmost_toskew = toskew + leftmost_fromskew;
for (row = 0; row < h; row += nrow)
{
rowstoread = th - (row + img->row_offset) % th;
nrow = (row + rowstoread > h ? h - row : rowstoread);
- for (col = 0; col < w; col += tw)
+ fromskew = leftmost_fromskew;
+ this_tw = leftmost_tw;
+ this_toskew = leftmost_toskew;
+ tocol = 0;
+ col = img->col_offset;
+ while (tocol < w)
{
- if (TIFFReadTile(tif, buf, col+img->col_offset,
+ if (TIFFReadTile(tif, buf, col,
row+img->row_offset, 0, 0)==(tmsize_t)(-1) && img->stoponerr)
{
ret = 0;
break;
}
-
- pos = ((row+img->row_offset) % th) * TIFFTileRowSize(tif);
-
- if (col + tw > w)
- {
- /*
- * Tile is clipped horizontally. Calculate
- * visible portion and skewing factors.
- */
- uint32 npix = w - col;
- fromskew = tw - npix;
- (*put)(img, raster+y*w+col, col, y,
- npix, nrow, fromskew, toskew + fromskew, buf + pos);
- }
- else
- {
- (*put)(img, raster+y*w+col, col, y, tw, nrow, 0, toskew, buf + pos);
- }
- }
+ pos = ((row+img->row_offset) % th) * TIFFTileRowSize(tif) + \
+ ((tmsize_t) fromskew * img->samplesperpixel);
+ if (tocol + this_tw > w)
+ {
+ /*
+ * Rightmost tile is clipped on right side.
+ */
+ fromskew = tw - (w - tocol);
+ this_tw = tw - fromskew;
+ this_toskew = toskew + fromskew;
+ }
+ (*put)(img, raster+y*w+tocol, tocol, y, this_tw, nrow, fromskew, this_toskew, buf + pos);
+ tocol += this_tw;
+ col += this_tw;
+ /*
+ * After the leftmost tile, tiles are no longer clipped on left side.
+ */
+ fromskew = 0;
+ this_tw = tw;
+ this_toskew = toskew;
+ }
y += (flip & FLIP_VERTICALLY ? -(int32) nrow : (int32) nrow);
}
@@ -698,6 +730,10 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
uint32 nrow;
int ret = 1, flip;
int colorchannels;
+ uint32 this_tw, tocol;
+ int32 this_toskew, leftmost_toskew;
+ int32 leftmost_fromskew;
+ uint32 leftmost_tw;
tilesize = TIFFTileSize(tif);
bufsize = TIFFSafeMultiply(tmsize_t,alpha?4:3,tilesize);
@@ -742,20 +778,31 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
break;
}
+ /*
+ * Leftmost tile is clipped on left side if col_offset > 0.
+ */
+ leftmost_fromskew = img->col_offset % tw;
+ leftmost_tw = tw - leftmost_fromskew;
+ leftmost_toskew = toskew + leftmost_fromskew;
for (row = 0; row < h; row += nrow)
{
rowstoread = th - (row + img->row_offset) % th;
nrow = (row + rowstoread > h ? h - row : rowstoread);
- for (col = 0; col < w; col += tw)
+ fromskew = leftmost_fromskew;
+ this_tw = leftmost_tw;
+ this_toskew = leftmost_toskew;
+ tocol = 0;
+ col = img->col_offset;
+ while (tocol < w)
{
- if (TIFFReadTile(tif, p0, col+img->col_offset,
+ if (TIFFReadTile(tif, p0, col,
row+img->row_offset,0,0)==(tmsize_t)(-1) && img->stoponerr)
{
ret = 0;
break;
}
if (colorchannels > 1
- && TIFFReadTile(tif, p1, col+img->col_offset,
+ && TIFFReadTile(tif, p1, col,
row+img->row_offset,0,1) == (tmsize_t)(-1)
&& img->stoponerr)
{
@@ -763,7 +810,7 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
break;
}
if (colorchannels > 1
- && TIFFReadTile(tif, p2, col+img->col_offset,
+ && TIFFReadTile(tif, p2, col,
row+img->row_offset,0,2) == (tmsize_t)(-1)
&& img->stoponerr)
{
@@ -771,7 +818,7 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
break;
}
if (alpha
- && TIFFReadTile(tif,pa,col+img->col_offset,
+ && TIFFReadTile(tif,pa,col,
row+img->row_offset,0,colorchannels) == (tmsize_t)(-1)
&& img->stoponerr)
{
@@ -779,23 +826,27 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
break;
}
- pos = ((row+img->row_offset) % th) * TIFFTileRowSize(tif);
-
- if (col + tw > w)
+ pos = ((row+img->row_offset) % th) * TIFFTileRowSize(tif) + \
+ ((tmsize_t) fromskew * img->samplesperpixel);
+ if (tocol + this_tw > w)
{
/*
- * Tile is clipped horizontally. Calculate
- * visible portion and skewing factors.
+ * Rightmost tile is clipped on right side.
*/
- uint32 npix = w - col;
- fromskew = tw - npix;
- (*put)(img, raster+y*w+col, col, y,
- npix, nrow, fromskew, toskew + fromskew,
- p0 + pos, p1 + pos, p2 + pos, (alpha?(pa+pos):NULL));
- } else {
- (*put)(img, raster+y*w+col, col, y,
- tw, nrow, 0, toskew, p0 + pos, p1 + pos, p2 + pos, (alpha?(pa+pos):NULL));
+ fromskew = tw - (w - tocol);
+ this_tw = tw - fromskew;
+ this_toskew = toskew + fromskew;
}
+ (*put)(img, raster+y*w+tocol, tocol, y, this_tw, nrow, fromskew, this_toskew, \
+ p0 + pos, p1 + pos, p2 + pos, (alpha?(pa+pos):NULL));
+ tocol += this_tw;
+ col += this_tw;
+ /*
+ * After the leftmost tile, tiles are no longer clipped on left side.
+ */
+ fromskew = 0;
+ this_tw = tw;
+ this_toskew = toskew;
}
y += (flip & FLIP_VERTICALLY ?-(int32) nrow : (int32) nrow);
@@ -842,6 +893,12 @@ gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
int32 fromskew, toskew;
int ret = 1, flip;
+ TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING, &subsamplinghor, &subsamplingver);
+ if( subsamplingver == 0 ) {
+ TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "Invalid vertical YCbCr subsampling");
+ return (0);
+ }
+
buf = (unsigned char*) _TIFFmalloc(TIFFStripSize(tif));
if (buf == 0) {
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "No space for strip buffer");
@@ -859,7 +916,7 @@ gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
}
TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip);
- TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING, &subsamplinghor, &subsamplingver);
+
scanline = TIFFScanlineSize(tif);
fromskew = (w < imagewidth ? imagewidth - w : 0);
for (row = 0; row < h; row += nrow)
@@ -879,7 +936,8 @@ gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
break;
}
- pos = ((row + img->row_offset) % rowsperstrip) * scanline;
+ pos = ((row + img->row_offset) % rowsperstrip) * scanline + \
+ ((tmsize_t) img->col_offset * img->samplesperpixel);
(*put)(img, raster+y*w, 0, y, w, nrow, fromskew, toskew, buf + pos);
y += (flip & FLIP_VERTICALLY ? -(int32) nrow : (int32) nrow);
}
@@ -1010,7 +1068,8 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
}
}
- pos = ((row + img->row_offset) % rowsperstrip) * scanline;
+ pos = ((row + img->row_offset) % rowsperstrip) * scanline + \
+ ((tmsize_t) img->col_offset * img->samplesperpixel);
(*put)(img, raster+y*w, 0, y, w, nrow, fromskew, toskew, p0 + pos, p1 + pos,
p2 + pos, (alpha?(pa+pos):NULL));
y += (flip & FLIP_VERTICALLY ? -(int32) nrow : (int32) nrow);
@@ -1852,7 +1911,7 @@ DECLAREContigPutFunc(putcontig8bitYCbCr42tile)
(void) y;
fromskew = (fromskew * 10) / 4;
- if ((h & 3) == 0 && (w & 1) == 0) {
+ if ((w & 3) == 0 && (h & 1) == 0) {
for (; h >= 2; h -= 2) {
x = w>>2;
do {
@@ -1929,7 +1988,7 @@ DECLAREContigPutFunc(putcontig8bitYCbCr41tile)
/* XXX adjust fromskew */
do {
x = w>>2;
- do {
+ while(x>0) {
int32 Cb = pp[4];
int32 Cr = pp[5];
@@ -1940,7 +1999,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr41tile)
cp += 4;
pp += 6;
- } while (--x);
+ x--;
+ }
if( (w&3) != 0 )
{
@@ -2031,7 +2091,7 @@ DECLAREContigPutFunc(putcontig8bitYCbCr21tile)
fromskew = (fromskew * 4) / 2;
do {
x = w>>1;
- do {
+ while(x>0) {
int32 Cb = pp[2];
int32 Cr = pp[3];
@@ -2040,7 +2100,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr21tile)
cp += 2;
pp += 4;
- } while (--x);
+ x --;
+ }
if( (w&1) != 0 )
{
@@ -2541,7 +2602,7 @@ PickContigCase(TIFFRGBAImage* img)
* must always be <= horizontal subsampling; so
* there are only a few possibilities and we just
* enumerate the cases.
- * Joris: added support for the [1,2] case, nonetheless, to accomodate
+ * Joris: added support for the [1,2] case, nonetheless, to accommodate
* some OJPEG files
*/
uint16 SubsamplingHor;
diff --git a/src/3rdparty/libtiff/libtiff/tif_jpeg.c b/src/3rdparty/libtiff/libtiff/tif_jpeg.c
index b61b91b..a970eb1 100644
--- a/src/3rdparty/libtiff/libtiff/tif_jpeg.c
+++ b/src/3rdparty/libtiff/libtiff/tif_jpeg.c
@@ -1,4 +1,4 @@
-/* $Id: tif_jpeg.c,v 1.111 2012-07-06 18:48:04 bfriesen Exp $ */
+/* $Id: tif_jpeg.c,v 1.119 2015-08-15 20:13:07 bfriesen Exp $ */
/*
* Copyright (c) 1994-1997 Sam Leffler
@@ -252,6 +252,9 @@ TIFFjpeg_create_compress(JPEGState* sp)
sp->err.error_exit = TIFFjpeg_error_exit;
sp->err.output_message = TIFFjpeg_output_message;
+ /* set client_data to avoid UMR warning from tools like Purify */
+ sp->cinfo.c.client_data = NULL;
+
return CALLVJPEG(sp, jpeg_create_compress(&sp->cinfo.c));
}
@@ -263,6 +266,9 @@ TIFFjpeg_create_decompress(JPEGState* sp)
sp->err.error_exit = TIFFjpeg_error_exit;
sp->err.output_message = TIFFjpeg_output_message;
+ /* set client_data to avoid UMR warning from tools like Purify */
+ sp->cinfo.d.client_data = NULL;
+
return CALLVJPEG(sp, jpeg_create_decompress(&sp->cinfo.d));
}
@@ -658,7 +664,9 @@ alloc_downsampled_buffers(TIFF* tif, jpeg_component_info* comp_info,
#define JPEG_MARKER_SOF0 0xC0
#define JPEG_MARKER_SOF1 0xC1
-#define JPEG_MARKER_SOF3 0xC3
+#define JPEG_MARKER_SOF2 0xC2
+#define JPEG_MARKER_SOF9 0xC9
+#define JPEG_MARKER_SOF10 0xCA
#define JPEG_MARKER_DHT 0xC4
#define JPEG_MARKER_SOI 0xD8
#define JPEG_MARKER_SOS 0xDA
@@ -729,6 +737,7 @@ JPEGFixupTagsSubsampling(TIFF* tif)
_TIFFFillStriles( tif );
if( tif->tif_dir.td_stripbytecount == NULL
+ || tif->tif_dir.td_stripoffset == NULL
|| tif->tif_dir.td_stripbytecount[0] == 0 )
{
/* Do not even try to check if the first strip/tile does not
@@ -816,8 +825,11 @@ JPEGFixupTagsSubsamplingSec(struct JPEGFixupTagsSubsamplingData* data)
JPEGFixupTagsSubsamplingSkip(data,n);
}
break;
- case JPEG_MARKER_SOF0:
- case JPEG_MARKER_SOF1:
+ case JPEG_MARKER_SOF0: /* Baseline sequential Huffman */
+ case JPEG_MARKER_SOF1: /* Extended sequential Huffman */
+ case JPEG_MARKER_SOF2: /* Progressive Huffman: normally not allowed by TechNote, but that doesn't hurt supporting it */
+ case JPEG_MARKER_SOF9: /* Extended sequential arithmetic */
+ case JPEG_MARKER_SOF10: /* Progressive arithmetic: normally not allowed by TechNote, but that doesn't hurt supporting it */
/* this marker contains the subsampling factors we're scanning for */
{
uint16 n;
@@ -992,7 +1004,7 @@ JPEGSetupDecode(TIFF* tif)
/*
* Set up for decoding a strip or tile.
*/
-static int
+/*ARGSUSED*/ static int
JPEGPreDecode(TIFF* tif, uint16 s)
{
JPEGState *sp = JState(tif);
@@ -1168,7 +1180,8 @@ JPEGPreDecode(TIFF* tif, uint16 s)
* Decode a chunk of pixels.
* "Standard" case: returned data is not downsampled.
*/
-/*ARGSUSED*/ static int
+#if !JPEG_LIB_MK1_OR_12BIT
+static int
JPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
{
JPEGState *sp = JState(tif);
@@ -1187,91 +1200,137 @@ JPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
nrows = cc / sp->bytesperline;
if (cc % sp->bytesperline)
- TIFFWarningExt(tif->tif_clientdata, tif->tif_name, "fractional scanline not read");
+ TIFFWarningExt(tif->tif_clientdata, tif->tif_name,
+ "fractional scanline not read");
if( nrows > (tmsize_t) sp->cinfo.d.image_height )
nrows = sp->cinfo.d.image_height;
/* data is expected to be read in multiples of a scanline */
if (nrows)
- {
- JSAMPROW line_work_buf = NULL;
+ {
+ do
+ {
+ /*
+ * In the libjpeg6b-9a 8bit case. We read directly into
+ * the TIFF buffer.
+ */
+ JSAMPROW bufptr = (JSAMPROW)buf;
- /*
- * For 6B, only use temporary buffer for 12 bit imagery.
- * For Mk1 always use it.
- */
-#if !defined(JPEG_LIB_MK1)
- if( sp->cinfo.d.data_precision == 12 )
-#endif
- {
- line_work_buf = (JSAMPROW)
- _TIFFmalloc(sizeof(short) * sp->cinfo.d.output_width
- * sp->cinfo.d.num_components );
- }
+ if (TIFFjpeg_read_scanlines(sp, &bufptr, 1) != 1)
+ return (0);
- do {
- if( line_work_buf != NULL )
- {
- /*
- * In the MK1 case, we aways read into a 16bit buffer, and then
- * pack down to 12bit or 8bit. In 6B case we only read into 16
- * bit buffer for 12bit data, which we need to repack.
- */
- if (TIFFjpeg_read_scanlines(sp, &line_work_buf, 1) != 1)
- return (0);
+ ++tif->tif_row;
+ buf += sp->bytesperline;
+ cc -= sp->bytesperline;
+ } while (--nrows > 0);
+ }
- if( sp->cinfo.d.data_precision == 12 )
- {
- int value_pairs = (sp->cinfo.d.output_width
- * sp->cinfo.d.num_components) / 2;
- int iPair;
+ /* Update information on consumed data */
+ tif->tif_rawcp = (uint8*) sp->src.next_input_byte;
+ tif->tif_rawcc = sp->src.bytes_in_buffer;
+
+ /* Close down the decompressor if we've finished the strip or tile. */
+ return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height
+ || TIFFjpeg_finish_decompress(sp);
+}
+#endif /* !JPEG_LIB_MK1_OR_12BIT */
- for( iPair = 0; iPair < value_pairs; iPair++ )
- {
- unsigned char *out_ptr =
- ((unsigned char *) buf) + iPair * 3;
- JSAMPLE *in_ptr = line_work_buf + iPair * 2;
+#if JPEG_LIB_MK1_OR_12BIT
+/*ARGSUSED*/ static int
+JPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
+{
+ JPEGState *sp = JState(tif);
+ tmsize_t nrows;
+ (void) s;
- out_ptr[0] = (in_ptr[0] & 0xff0) >> 4;
- out_ptr[1] = ((in_ptr[0] & 0xf) << 4)
- | ((in_ptr[1] & 0xf00) >> 8);
- out_ptr[2] = ((in_ptr[1] & 0xff) >> 0);
- }
- }
- else if( sp->cinfo.d.data_precision == 8 )
- {
- int value_count = (sp->cinfo.d.output_width
- * sp->cinfo.d.num_components);
- int iValue;
+ /*
+ ** Update available information, buffer may have been refilled
+ ** between decode requests
+ */
+ sp->src.next_input_byte = (const JOCTET*) tif->tif_rawcp;
+ sp->src.bytes_in_buffer = (size_t) tif->tif_rawcc;
- for( iValue = 0; iValue < value_count; iValue++ )
- {
- ((unsigned char *) buf)[iValue] =
- line_work_buf[iValue] & 0xff;
- }
- }
- }
- else
- {
- /*
- * In the libjpeg6b 8bit case. We read directly into the
- * TIFF buffer.
- */
- JSAMPROW bufptr = (JSAMPROW)buf;
+ if( sp->bytesperline == 0 )
+ return 0;
+
+ nrows = cc / sp->bytesperline;
+ if (cc % sp->bytesperline)
+ TIFFWarningExt(tif->tif_clientdata, tif->tif_name,
+ "fractional scanline not read");
- if (TIFFjpeg_read_scanlines(sp, &bufptr, 1) != 1)
- return (0);
- }
+ if( nrows > (tmsize_t) sp->cinfo.d.image_height )
+ nrows = sp->cinfo.d.image_height;
- ++tif->tif_row;
- buf += sp->bytesperline;
- cc -= sp->bytesperline;
- } while (--nrows > 0);
+ /* data is expected to be read in multiples of a scanline */
+ if (nrows)
+ {
+ JSAMPROW line_work_buf = NULL;
- if( line_work_buf != NULL )
- _TIFFfree( line_work_buf );
- }
+ /*
+ * For 6B, only use temporary buffer for 12 bit imagery.
+ * For Mk1 always use it.
+ */
+ if( sp->cinfo.d.data_precision == 12 )
+ {
+ line_work_buf = (JSAMPROW)
+ _TIFFmalloc(sizeof(short) * sp->cinfo.d.output_width
+ * sp->cinfo.d.num_components );
+ }
+
+ do
+ {
+ if( line_work_buf != NULL )
+ {
+ /*
+ * In the MK1 case, we aways read into a 16bit
+ * buffer, and then pack down to 12bit or 8bit.
+ * In 6B case we only read into 16 bit buffer
+ * for 12bit data, which we need to repack.
+ */
+ if (TIFFjpeg_read_scanlines(sp, &line_work_buf, 1) != 1)
+ return (0);
+
+ if( sp->cinfo.d.data_precision == 12 )
+ {
+ int value_pairs = (sp->cinfo.d.output_width
+ * sp->cinfo.d.num_components) / 2;
+ int iPair;
+
+ for( iPair = 0; iPair < value_pairs; iPair++ )
+ {
+ unsigned char *out_ptr =
+ ((unsigned char *) buf) + iPair * 3;
+ JSAMPLE *in_ptr = line_work_buf + iPair * 2;
+
+ out_ptr[0] = (in_ptr[0] & 0xff0) >> 4;
+ out_ptr[1] = ((in_ptr[0] & 0xf) << 4)
+ | ((in_ptr[1] & 0xf00) >> 8);
+ out_ptr[2] = ((in_ptr[1] & 0xff) >> 0);
+ }
+ }
+ else if( sp->cinfo.d.data_precision == 8 )
+ {
+ int value_count = (sp->cinfo.d.output_width
+ * sp->cinfo.d.num_components);
+ int iValue;
+
+ for( iValue = 0; iValue < value_count; iValue++ )
+ {
+ ((unsigned char *) buf)[iValue] =
+ line_work_buf[iValue] & 0xff;
+ }
+ }
+ }
+
+ ++tif->tif_row;
+ buf += sp->bytesperline;
+ cc -= sp->bytesperline;
+ } while (--nrows > 0);
+
+ if( line_work_buf != NULL )
+ _TIFFfree( line_work_buf );
+ }
/* Update information on consumed data */
tif->tif_rawcp = (uint8*) sp->src.next_input_byte;
@@ -1279,8 +1338,9 @@ JPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
/* Close down the decompressor if we've finished the strip or tile. */
return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height
- || TIFFjpeg_finish_decompress(sp);
+ || TIFFjpeg_finish_decompress(sp);
}
+#endif /* JPEG_LIB_MK1_OR_12BIT */
/*ARGSUSED*/ static int
DecodeRowError(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
@@ -1451,6 +1511,15 @@ unsuppress_quant_table (JPEGState* sp, int tblno)
}
static void
+suppress_quant_table (JPEGState* sp, int tblno)
+{
+ JQUANT_TBL* qtbl;
+
+ if ((qtbl = sp->cinfo.c.quant_tbl_ptrs[tblno]) != NULL)
+ qtbl->sent_table = TRUE;
+}
+
+static void
unsuppress_huff_table (JPEGState* sp, int tblno)
{
JHUFF_TBL* htbl;
@@ -1461,6 +1530,17 @@ unsuppress_huff_table (JPEGState* sp, int tblno)
htbl->sent_table = FALSE;
}
+static void
+suppress_huff_table (JPEGState* sp, int tblno)
+{
+ JHUFF_TBL* htbl;
+
+ if ((htbl = sp->cinfo.c.dc_huff_tbl_ptrs[tblno]) != NULL)
+ htbl->sent_table = TRUE;
+ if ((htbl = sp->cinfo.c.ac_huff_tbl_ptrs[tblno]) != NULL)
+ htbl->sent_table = TRUE;
+}
+
static int
prepare_JPEGTables(TIFF* tif)
{
@@ -1510,17 +1590,38 @@ JPEGSetupEncode(TIFF* tif)
assert(sp != NULL);
assert(!sp->cinfo.comm.is_decompressor);
+ sp->photometric = td->td_photometric;
+
/*
* Initialize all JPEG parameters to default values.
* Note that jpeg_set_defaults needs legal values for
* in_color_space and input_components.
*/
- sp->cinfo.c.in_color_space = JCS_UNKNOWN;
- sp->cinfo.c.input_components = 1;
+ if (td->td_planarconfig == PLANARCONFIG_CONTIG) {
+ sp->cinfo.c.input_components = td->td_samplesperpixel;
+ if (sp->photometric == PHOTOMETRIC_YCBCR) {
+ if (sp->jpegcolormode == JPEGCOLORMODE_RGB) {
+ sp->cinfo.c.in_color_space = JCS_RGB;
+ } else {
+ sp->cinfo.c.in_color_space = JCS_YCbCr;
+ }
+ } 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 && 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;
+ else
+ sp->cinfo.c.in_color_space = JCS_UNKNOWN;
+ }
+ } else {
+ sp->cinfo.c.input_components = 1;
+ sp->cinfo.c.in_color_space = JCS_UNKNOWN;
+ }
if (!TIFFjpeg_set_defaults(sp))
return (0);
/* Set per-file parameters */
- sp->photometric = td->td_photometric;
switch (sp->photometric) {
case PHOTOMETRIC_YCBCR:
sp->h_sampling = td->td_ycbcrsubsampling[0];
@@ -1680,10 +1781,7 @@ JPEGPreEncode(TIFF* tif, uint16 s)
if (td->td_planarconfig == PLANARCONFIG_CONTIG) {
sp->cinfo.c.input_components = td->td_samplesperpixel;
if (sp->photometric == PHOTOMETRIC_YCBCR) {
- if (sp->jpegcolormode == JPEGCOLORMODE_RGB) {
- sp->cinfo.c.in_color_space = JCS_RGB;
- } else {
- sp->cinfo.c.in_color_space = JCS_YCbCr;
+ if (sp->jpegcolormode != JPEGCOLORMODE_RGB) {
if (sp->h_sampling != 1 || sp->v_sampling != 1)
downsampled_input = TRUE;
}
@@ -1696,21 +1794,11 @@ JPEGPreEncode(TIFF* tif, uint16 s)
sp->cinfo.c.comp_info[0].h_samp_factor = sp->h_sampling;
sp->cinfo.c.comp_info[0].v_samp_factor = sp->v_sampling;
} 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 && 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;
- else
- sp->cinfo.c.in_color_space = JCS_UNKNOWN;
if (!TIFFjpeg_set_colorspace(sp, sp->cinfo.c.in_color_space))
return (0);
/* jpeg_set_colorspace set all sampling factors to 1 */
}
} else {
- sp->cinfo.c.input_components = 1;
- sp->cinfo.c.in_color_space = JCS_UNKNOWN;
if (!TIFFjpeg_set_colorspace(sp, JCS_UNKNOWN))
return (0);
sp->cinfo.c.comp_info[0].component_id = s;
@@ -1725,14 +1813,30 @@ JPEGPreEncode(TIFF* tif, uint16 s)
sp->cinfo.c.write_JFIF_header = FALSE;
sp->cinfo.c.write_Adobe_marker = FALSE;
/* set up table handling correctly */
- if (!TIFFjpeg_set_quality(sp, sp->jpegquality, FALSE))
+ /* calling TIFFjpeg_set_quality() causes quantization tables to be flagged */
+ /* as being to be emitted, which we don't want in the JPEGTABLESMODE_QUANT */
+ /* mode, so we must manually suppress them. However TIFFjpeg_set_quality() */
+ /* should really be called when dealing with files with directories with */
+ /* mixed qualities. see http://trac.osgeo.org/gdal/ticket/3539 */
+ if (!TIFFjpeg_set_quality(sp, sp->jpegquality, FALSE))
return (0);
- if (! (sp->jpegtablesmode & JPEGTABLESMODE_QUANT)) {
+ if (sp->jpegtablesmode & JPEGTABLESMODE_QUANT) {
+ suppress_quant_table(sp, 0);
+ suppress_quant_table(sp, 1);
+ }
+ else {
unsuppress_quant_table(sp, 0);
unsuppress_quant_table(sp, 1);
}
if (sp->jpegtablesmode & JPEGTABLESMODE_HUFF)
+ {
+ /* Explicit suppression is only needed if we did not go through the */
+ /* prepare_JPEGTables() code path, which may be the case if updating */
+ /* an existing file */
+ suppress_huff_table(sp, 0);
+ suppress_huff_table(sp, 1);
sp->cinfo.c.optimize_coding = FALSE;
+ }
else
sp->cinfo.c.optimize_coding = TRUE;
if (downsampled_input) {
@@ -1791,7 +1895,14 @@ 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
+ if (!line16)
+ {
+ TIFFErrorExt(tif->tif_clientdata,
+ "JPEGEncode",
+ "Failed to allocate memory");
+
+ return 0;
+ }
}
while (nrows-- > 0) {
@@ -1966,13 +2077,10 @@ JPEGCleanup(TIFF* tif)
tif->tif_tagmethods.vgetfield = sp->vgetparent;
tif->tif_tagmethods.vsetfield = sp->vsetparent;
tif->tif_tagmethods.printdir = sp->printdir;
-
- if( sp != NULL ) {
- if( sp->cinfo_initialized )
- TIFFjpeg_destroy(sp); /* release libjpeg resources */
- if (sp->jpegtables) /* tag value */
- _TIFFfree(sp->jpegtables);
- }
+ 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;
@@ -2284,8 +2392,17 @@ 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);
+ if (sp->jpegtables)
+ {
+ _TIFFmemset(sp->jpegtables, 0, SIZE_OF_JPEGTABLES);
+ }
+ else
+ {
+ TIFFErrorExt(tif->tif_clientdata,
+ "TIFFInitJPEG",
+ "Failed to allocate memory for JPEG tables");
+ return 0;
+ }
#undef SIZE_OF_JPEGTABLES
}
diff --git a/src/3rdparty/libtiff/libtiff/tif_luv.c b/src/3rdparty/libtiff/libtiff/tif_luv.c
index eba6c08..4e328ba 100644
--- a/src/3rdparty/libtiff/libtiff/tif_luv.c
+++ b/src/3rdparty/libtiff/libtiff/tif_luv.c
@@ -1,4 +1,4 @@
-/* $Id: tif_luv.c,v 1.35 2011-04-02 20:54:09 bfriesen Exp $ */
+/* $Id: tif_luv.c,v 1.40 2015-06-21 01:09:09 bfriesen Exp $ */
/*
* Copyright (c) 1997 Greg Ward Larson
@@ -379,6 +379,9 @@ LogLuvDecodeStrip(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
{
tmsize_t rowlen = TIFFScanlineSize(tif);
+ if (rowlen == 0)
+ return 0;
+
assert(cc%rowlen == 0);
while (cc && (*tif->tif_decoderow)(tif, bp, rowlen, s))
bp += rowlen, cc -= rowlen;
@@ -395,6 +398,9 @@ LogLuvDecodeTile(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
{
tmsize_t rowlen = TIFFTileRowSize(tif);
+ if (rowlen == 0)
+ return 0;
+
assert(cc%rowlen == 0);
while (cc && (*tif->tif_decoderow)(tif, bp, rowlen, s))
bp += rowlen, cc -= rowlen;
@@ -644,6 +650,9 @@ LogLuvEncodeStrip(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
{
tmsize_t rowlen = TIFFScanlineSize(tif);
+ if (rowlen == 0)
+ return 0;
+
assert(cc%rowlen == 0);
while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 1)
bp += rowlen, cc -= rowlen;
@@ -659,6 +668,9 @@ LogLuvEncodeTile(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
{
tmsize_t rowlen = TIFFTileRowSize(tif);
+ if (rowlen == 0)
+ return 0;
+
assert(cc%rowlen == 0);
while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 1)
bp += rowlen, cc -= rowlen;
@@ -683,7 +695,9 @@ LogLuvEncodeTile(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
+#undef log2 /* Conflict with C'99 function */
#define log2(x) ((1./M_LN2)*log(x))
+#undef exp2 /* Conflict with C'99 function */
#define exp2(x) exp(M_LN2*(x))
#define itrunc(x,m) ((m)==SGILOGENCODE_NODITHER ? \
diff --git a/src/3rdparty/libtiff/libtiff/tif_lzw.c b/src/3rdparty/libtiff/libtiff/tif_lzw.c
index fd9c7a0..9b76dd0 100644
--- a/src/3rdparty/libtiff/libtiff/tif_lzw.c
+++ b/src/3rdparty/libtiff/libtiff/tif_lzw.c
@@ -1,4 +1,4 @@
-/* $Id: tif_lzw.c,v 1.45 2011-04-02 20:54:09 bfriesen Exp $ */
+/* $Id: tif_lzw.c,v 1.49 2015-08-30 21:07:44 erouault Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@@ -94,7 +94,7 @@ typedef struct {
unsigned short nbits; /* # of bits/code */
unsigned short maxcode; /* maximum code for lzw_nbits */
unsigned short free_ent; /* next free entry in hash table */
- long nextdata; /* next bits of i/o */
+ unsigned long nextdata; /* next bits of i/o */
long nextbits; /* # of valid bits in lzw_nextdata */
int rw_mode; /* preserve rw_mode from init */
@@ -268,6 +268,8 @@ LZWPreDecode(TIFF* tif, uint16 s)
if( sp->dec_codetab == NULL )
{
tif->tif_setupdecode( tif );
+ if( sp->dec_codetab == NULL )
+ return (0);
}
/*
@@ -365,7 +367,8 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
unsigned char *bp;
hcode_t code;
int len;
- long nbits, nextbits, nextdata, nbitsmask;
+ long nbits, nextbits, nbitsmask;
+ unsigned long nextdata;
code_t *codep, *free_entp, *maxcodep, *oldcodep;
(void) s;
@@ -434,16 +437,18 @@ LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
if (code == CODE_EOI)
break;
if (code == CODE_CLEAR) {
- free_entp = sp->dec_codetab + CODE_FIRST;
- _TIFFmemset(free_entp, 0,
- (CSIZE - CODE_FIRST) * sizeof (code_t));
- nbits = BITS_MIN;
- nbitsmask = MAXCODE(BITS_MIN);
- maxcodep = sp->dec_codetab + nbitsmask-1;
- NextCode(tif, sp, bp, code, GetNextCode);
+ do {
+ free_entp = sp->dec_codetab + CODE_FIRST;
+ _TIFFmemset(free_entp, 0,
+ (CSIZE - CODE_FIRST) * sizeof (code_t));
+ nbits = BITS_MIN;
+ nbitsmask = MAXCODE(BITS_MIN);
+ maxcodep = sp->dec_codetab + nbitsmask-1;
+ NextCode(tif, sp, bp, code, GetNextCode);
+ } while (code == CODE_CLEAR); /* consecutive CODE_CLEAR codes */
if (code == CODE_EOI)
break;
- if (code >= CODE_CLEAR) {
+ if (code > CODE_CLEAR) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"LZWDecode: Corrupted LZW table at scanline %d",
tif->tif_row);
@@ -653,16 +658,18 @@ LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s)
if (code == CODE_EOI)
break;
if (code == CODE_CLEAR) {
- free_entp = sp->dec_codetab + CODE_FIRST;
- _TIFFmemset(free_entp, 0,
- (CSIZE - CODE_FIRST) * sizeof (code_t));
- nbits = BITS_MIN;
- nbitsmask = MAXCODE(BITS_MIN);
- maxcodep = sp->dec_codetab + nbitsmask;
- NextCode(tif, sp, bp, code, GetNextCodeCompat);
+ do {
+ free_entp = sp->dec_codetab + CODE_FIRST;
+ _TIFFmemset(free_entp, 0,
+ (CSIZE - CODE_FIRST) * sizeof (code_t));
+ nbits = BITS_MIN;
+ nbitsmask = MAXCODE(BITS_MIN);
+ maxcodep = sp->dec_codetab + nbitsmask;
+ NextCode(tif, sp, bp, code, GetNextCodeCompat);
+ } while (code == CODE_CLEAR); /* consecutive CODE_CLEAR codes */
if (code == CODE_EOI)
break;
- if (code >= CODE_CLEAR) {
+ if (code > CODE_CLEAR) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"LZWDecode: Corrupted LZW table at scanline %d",
tif->tif_row);
@@ -830,13 +837,15 @@ LZWPreEncode(TIFF* tif, uint16 s)
} else \
rat = (incount<<8) / outcount; \
}
+
+/* Explicit 0xff masking to make icc -check=conversions happy */
#define PutNextCode(op, c) { \
nextdata = (nextdata << nbits) | c; \
nextbits += nbits; \
- *op++ = (unsigned char)(nextdata >> (nextbits-8)); \
+ *op++ = (unsigned char)((nextdata >> (nextbits-8))&0xff); \
nextbits -= 8; \
if (nextbits >= 8) { \
- *op++ = (unsigned char)(nextdata >> (nextbits-8)); \
+ *op++ = (unsigned char)((nextdata >> (nextbits-8))&0xff); \
nextbits -= 8; \
} \
outcount += nbits; \
@@ -866,7 +875,8 @@ LZWEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
hcode_t ent;
long disp;
long incount, outcount, checkpoint;
- long nextdata, nextbits;
+ unsigned long nextdata;
+ long nextbits;
int free_ent, maxcode, nbits;
uint8* op;
uint8* limit;
@@ -1028,7 +1038,7 @@ LZWPostEncode(TIFF* tif)
register LZWCodecState *sp = EncoderState(tif);
uint8* op = tif->tif_rawcp;
long nextbits = sp->lzw_nextbits;
- long nextdata = sp->lzw_nextdata;
+ unsigned long nextdata = sp->lzw_nextdata;
long outcount = sp->enc_outcount;
int nbits = sp->lzw_nbits;
@@ -1042,8 +1052,9 @@ LZWPostEncode(TIFF* tif)
sp->enc_oldcode = (hcode_t) -1;
}
PutNextCode(op, CODE_EOI);
+ /* Explicit 0xff masking to make icc -check=conversions happy */
if (nextbits > 0)
- *op++ = (unsigned char)(nextdata << (8-nextbits));
+ *op++ = (unsigned char)((nextdata << (8-nextbits))&0xff);
tif->tif_rawcc = (tmsize_t)(op - tif->tif_rawdata);
return (1);
}
diff --git a/src/3rdparty/libtiff/libtiff/tif_next.c b/src/3rdparty/libtiff/libtiff/tif_next.c
index 524e127..17e0311 100644
--- a/src/3rdparty/libtiff/libtiff/tif_next.c
+++ b/src/3rdparty/libtiff/libtiff/tif_next.c
@@ -1,4 +1,4 @@
-/* $Id: tif_next.c,v 1.13 2010-03-10 18:56:48 bfriesen Exp $ */
+/* $Id: tif_next.c,v 1.16 2014-12-29 12:09:11 erouault Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@@ -71,7 +71,7 @@ NeXTDecode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s)
TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be read");
return (0);
}
- for (row = buf; occ > 0; occ -= scanline, row += scanline) {
+ for (row = buf; cc > 0 && occ > 0; occ -= scanline, row += scanline) {
n = *bp++, cc--;
switch (n) {
case LITERALROW:
@@ -90,6 +90,8 @@ NeXTDecode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s)
* The scanline has a literal span that begins at some
* offset.
*/
+ if( cc < 4 )
+ goto bad;
off = (bp[0] * 256) + bp[1];
n = (bp[2] * 256) + bp[3];
if (cc < 4+n || off+n > scanline)
@@ -102,6 +104,8 @@ NeXTDecode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s)
default: {
uint32 npixels = 0, grey;
uint32 imagewidth = tif->tif_dir.td_imagewidth;
+ if( isTiled(tif) )
+ imagewidth = tif->tif_dir.td_tilewidth;
/*
* The scanline is composed of a sequence of constant
@@ -139,10 +143,27 @@ bad:
return (0);
}
+static int
+NeXTPreDecode(TIFF* tif, uint16 s)
+{
+ static const char module[] = "NeXTPreDecode";
+ TIFFDirectory *td = &tif->tif_dir;
+ (void)s;
+
+ if( td->td_bitspersample != 2 )
+ {
+ TIFFErrorExt(tif->tif_clientdata, module, "Unsupported BitsPerSample = %d",
+ td->td_bitspersample);
+ return (0);
+ }
+ return (1);
+}
+
int
TIFFInitNeXT(TIFF* tif, int scheme)
{
(void) scheme;
+ tif->tif_predecode = NeXTPreDecode;
tif->tif_decoderow = NeXTDecode;
tif->tif_decodestrip = NeXTDecode;
tif->tif_decodetile = NeXTDecode;
diff --git a/src/3rdparty/libtiff/libtiff/tif_ojpeg.c b/src/3rdparty/libtiff/libtiff/tif_ojpeg.c
index 6ea3c38..23d4062 100644
--- a/src/3rdparty/libtiff/libtiff/tif_ojpeg.c
+++ b/src/3rdparty/libtiff/libtiff/tif_ojpeg.c
@@ -1,4 +1,4 @@
-/* $Id: tif_ojpeg.c,v 1.56 2012-05-24 03:15:18 fwarmerdam Exp $ */
+/* $Id: tif_ojpeg.c,v 1.60 2015-05-31 00:38:46 bfriesen 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
@@ -39,7 +39,7 @@
OF THIS SOFTWARE.
Joris Van Damme and/or AWare Systems may be available for custom
- developement. If you like what you see, and need anything similar or related,
+ development. If you like what you see, and need anything similar or related,
contact <info@awaresystems.be>.
*/
@@ -141,7 +141,7 @@
* OJPEG_BUFFER: Define the size of the desired buffer here. Should be small enough so as to guarantee
* instant processing, optimal streaming and optimal use of processor cache, but also big
* enough so as to not result in significant call overhead. It should be at least a few
- * bytes to accomodate some structures (this is verified in asserts), but it would not be
+ * bytes to accommodate some structures (this is verified in asserts), but it would not be
* sensible to make it this small anyway, and it should be at most 64K since it is indexed
* with uint16. We recommend 2K.
* EGYPTIANWALK: You could also define EGYPTIANWALK here, but it is not used anywhere and has
@@ -528,6 +528,8 @@ OJPEGVSetField(TIFF* tif, uint32 tag, va_list ap)
uint32 ma;
uint64* mb;
uint32 n;
+ const TIFFField* fip;
+
switch(tag)
{
case TIFFTAG_JPEGIFOFFSET:
@@ -597,7 +599,10 @@ OJPEGVSetField(TIFF* tif, uint32 tag, va_list ap)
default:
return (*sp->vsetparent)(tif,tag,ap);
}
- TIFFSetFieldBit(tif,TIFFFieldWithTag(tif,tag)->field_bit);
+ fip = TIFFFieldWithTag(tif,tag);
+ if( fip == NULL ) /* shouldn't happen */
+ return(0);
+ TIFFSetFieldBit(tif,fip->field_bit);
tif->tif_flags|=TIFF_DIRTYDIRECT;
return(1);
}
@@ -1492,14 +1497,17 @@ OJPEGReadHeaderInfoSecStreamDht(TIFF* tif)
nb[sizeof(uint32)+1]=JPEG_MARKER_DHT;
nb[sizeof(uint32)+2]=(m>>8);
nb[sizeof(uint32)+3]=(m&255);
- if (OJPEGReadBlock(sp,m-2,&nb[sizeof(uint32)+4])==0)
+ if (OJPEGReadBlock(sp,m-2,&nb[sizeof(uint32)+4])==0) {
+ _TIFFfree(nb);
return(0);
+ }
o=nb[sizeof(uint32)+4];
if ((o&240)==0)
{
if (3<o)
{
TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DHT marker in JPEG data");
+ _TIFFfree(nb);
return(0);
}
if (sp->dctable[o]!=0)
@@ -1511,12 +1519,14 @@ OJPEGReadHeaderInfoSecStreamDht(TIFF* tif)
if ((o&240)!=16)
{
TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DHT marker in JPEG data");
+ _TIFFfree(nb);
return(0);
}
o&=15;
if (3<o)
{
TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DHT marker in JPEG data");
+ _TIFFfree(nb);
return(0);
}
if (sp->actable[o]!=0)
@@ -1955,6 +1965,7 @@ OJPEGReadBufferFill(OJPEGState* sp)
break;
case osibsJpegInterchangeFormat:
sp->in_buffer_source=osibsStrile;
+ break;
case osibsStrile:
if (!_TIFFFillStriles( sp->tif )
|| sp->tif->tif_dir.td_stripoffset == NULL
diff --git a/src/3rdparty/libtiff/libtiff/tif_pixarlog.c b/src/3rdparty/libtiff/libtiff/tif_pixarlog.c
index e583117..044c411 100644
--- a/src/3rdparty/libtiff/libtiff/tif_pixarlog.c
+++ b/src/3rdparty/libtiff/libtiff/tif_pixarlog.c
@@ -1,4 +1,4 @@
-/* $Id: tif_pixarlog.c,v 1.38 2012-06-21 01:01:53 fwarmerdam Exp $ */
+/* $Id: tif_pixarlog.c,v 1.39 2012-12-10 17:27:13 tgl Exp $ */
/*
* Copyright (c) 1996-1997 Sam Leffler
@@ -644,6 +644,20 @@ multiply_ms(tmsize_t m1, tmsize_t m2)
return bytes;
}
+static tmsize_t
+add_ms(tmsize_t m1, tmsize_t m2)
+{
+ tmsize_t bytes = m1 + m2;
+
+ /* if either input is zero, assume overflow already occurred */
+ if (m1 == 0 || m2 == 0)
+ bytes = 0;
+ else if (bytes <= m1 || bytes <= m2)
+ bytes = 0;
+
+ return bytes;
+}
+
static int
PixarLogFixupTags(TIFF* tif)
{
@@ -671,9 +685,11 @@ PixarLogSetupDecode(TIFF* tif)
td->td_samplesperpixel : 1);
tbuf_size = multiply_ms(multiply_ms(multiply_ms(sp->stride, td->td_imagewidth),
td->td_rowsperstrip), sizeof(uint16));
+ /* add one more stride in case input ends mid-stride */
+ tbuf_size = add_ms(tbuf_size, sizeof(uint16) * sp->stride);
if (tbuf_size == 0)
return (0); /* TODO: this is an error return without error report through TIFFErrorExt */
- sp->tbuf = (uint16 *) _TIFFmalloc(tbuf_size+sizeof(uint16)*sp->stride);
+ sp->tbuf = (uint16 *) _TIFFmalloc(tbuf_size);
if (sp->tbuf == NULL)
return (0);
if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN)
diff --git a/src/3rdparty/libtiff/libtiff/tif_predict.c b/src/3rdparty/libtiff/libtiff/tif_predict.c
index f93c664..1388dde 100644
--- a/src/3rdparty/libtiff/libtiff/tif_predict.c
+++ b/src/3rdparty/libtiff/libtiff/tif_predict.c
@@ -1,4 +1,4 @@
-/* $Id: tif_predict.c,v 1.32 2010-03-10 18:56:49 bfriesen Exp $ */
+/* $Id: tif_predict.c,v 1.35 2015-08-31 15:05:57 erouault Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@@ -42,6 +42,8 @@ static void swabHorAcc32(TIFF* tif, uint8* cp0, tmsize_t cc);
static void horDiff8(TIFF* tif, uint8* cp0, tmsize_t cc);
static void horDiff16(TIFF* tif, uint8* cp0, tmsize_t cc);
static void horDiff32(TIFF* tif, uint8* cp0, tmsize_t cc);
+static void swabHorDiff16(TIFF* tif, uint8* cp0, tmsize_t cc);
+static void swabHorDiff32(TIFF* tif, uint8* cp0, tmsize_t cc);
static void fpAcc(TIFF* tif, uint8* cp0, tmsize_t cc);
static void fpDiff(TIFF* tif, uint8* cp0, tmsize_t cc);
static int PredictorDecodeRow(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s);
@@ -207,7 +209,24 @@ PredictorSetupEncode(TIFF* tif)
sp->encodetile = tif->tif_encodetile;
tif->tif_encodetile = PredictorEncodeTile;
}
- }
+
+ /*
+ * If the data is horizontally differenced 16-bit data that
+ * requires byte-swapping, then it must be byte swapped after
+ * the differenciation step. We do this with a special-purpose
+ * routine and override the normal post decoding logic that
+ * the library setup when the directory was read.
+ */
+ if (tif->tif_flags & TIFF_SWAB) {
+ if (sp->encodepfunc == horDiff16) {
+ sp->encodepfunc = swabHorDiff16;
+ tif->tif_postdecode = _TIFFNoPostDecode;
+ } else if (sp->encodepfunc == horDiff32) {
+ sp->encodepfunc = swabHorDiff32;
+ tif->tif_postdecode = _TIFFNoPostDecode;
+ }
+ }
+ }
else if (sp->predictor == 3) {
sp->encodepfunc = fpDiff;
@@ -239,12 +258,18 @@ PredictorSetupEncode(TIFF* tif)
case 0: ; \
}
+/* Remarks related to C standard compliance in all below functions : */
+/* - to avoid any undefined behaviour, we only operate on unsigned types */
+/* since the behaviour of "overflows" is defined (wrap over) */
+/* - when storing into the byte stream, we explicitly mask with 0xff so */
+/* as to make icc -check=conversions happy (not necessary by the standard) */
+
static void
horAcc8(TIFF* tif, uint8* cp0, tmsize_t cc)
{
tmsize_t stride = PredictorState(tif)->stride;
- char* cp = (char*) cp0;
+ unsigned char* cp = (unsigned char*) cp0;
assert((cc%stride)==0);
if (cc > stride) {
/*
@@ -257,9 +282,9 @@ horAcc8(TIFF* tif, uint8* cp0, tmsize_t cc)
cc -= 3;
cp += 3;
while (cc>0) {
- cp[0] = (char) (cr += cp[0]);
- cp[1] = (char) (cg += cp[1]);
- cp[2] = (char) (cb += cp[2]);
+ cp[0] = (unsigned char) ((cr += cp[0]) & 0xff);
+ cp[1] = (unsigned char) ((cg += cp[1]) & 0xff);
+ cp[2] = (unsigned char) ((cb += cp[2]) & 0xff);
cc -= 3;
cp += 3;
}
@@ -271,10 +296,10 @@ horAcc8(TIFF* tif, uint8* cp0, tmsize_t cc)
cc -= 4;
cp += 4;
while (cc>0) {
- cp[0] = (char) (cr += cp[0]);
- cp[1] = (char) (cg += cp[1]);
- cp[2] = (char) (cb += cp[2]);
- cp[3] = (char) (ca += cp[3]);
+ cp[0] = (unsigned char) ((cr += cp[0]) & 0xff);
+ cp[1] = (unsigned char) ((cg += cp[1]) & 0xff);
+ cp[2] = (unsigned char) ((cb += cp[2]) & 0xff);
+ cp[3] = (unsigned char) ((ca += cp[3]) & 0xff);
cc -= 4;
cp += 4;
}
@@ -282,7 +307,7 @@ horAcc8(TIFF* tif, uint8* cp0, tmsize_t cc)
cc -= stride;
do {
REPEAT4(stride, cp[stride] =
- (char) (cp[stride] + *cp); cp++)
+ (unsigned char) ((cp[stride] + *cp) & 0xff); cp++)
cc -= stride;
} while (cc>0);
}
@@ -292,20 +317,11 @@ horAcc8(TIFF* tif, uint8* cp0, tmsize_t cc)
static void
swabHorAcc16(TIFF* tif, uint8* cp0, tmsize_t cc)
{
- tmsize_t stride = PredictorState(tif)->stride;
uint16* wp = (uint16*) cp0;
tmsize_t wc = cc / 2;
- assert((cc%(2*stride))==0);
-
- if (wc > stride) {
- TIFFSwabArrayOfShort(wp, wc);
- wc -= stride;
- do {
- REPEAT4(stride, wp[stride] += wp[0]; wp++)
- wc -= stride;
- } while (wc > 0);
- }
+ TIFFSwabArrayOfShort(wp, wc);
+ horAcc16(tif, cp0, cc);
}
static void
@@ -320,7 +336,7 @@ horAcc16(TIFF* tif, uint8* cp0, tmsize_t cc)
if (wc > stride) {
wc -= stride;
do {
- REPEAT4(stride, wp[stride] += wp[0]; wp++)
+ REPEAT4(stride, wp[stride] = (uint16)(((unsigned int)wp[stride] + (unsigned int)wp[0]) & 0xffff); wp++)
wc -= stride;
} while (wc > 0);
}
@@ -329,20 +345,11 @@ horAcc16(TIFF* tif, uint8* cp0, tmsize_t cc)
static void
swabHorAcc32(TIFF* tif, uint8* cp0, tmsize_t cc)
{
- tmsize_t stride = PredictorState(tif)->stride;
uint32* wp = (uint32*) cp0;
tmsize_t wc = cc / 4;
- assert((cc%(4*stride))==0);
-
- if (wc > stride) {
- TIFFSwabArrayOfLong(wp, wc);
- wc -= stride;
- do {
- REPEAT4(stride, wp[stride] += wp[0]; wp++)
- wc -= stride;
- } while (wc > 0);
- }
+ TIFFSwabArrayOfLong(wp, wc);
+ horAcc32(tif, cp0, cc);
}
static void
@@ -382,7 +389,8 @@ fpAcc(TIFF* tif, uint8* cp0, tmsize_t cc)
return;
while (count > stride) {
- REPEAT4(stride, cp[stride] += cp[0]; cp++)
+ REPEAT4(stride, cp[stride] =
+ (unsigned char) ((cp[stride] + cp[0]) & 0xff); cp++)
count -= stride;
}
@@ -456,7 +464,7 @@ horDiff8(TIFF* tif, uint8* cp0, tmsize_t cc)
{
TIFFPredictorState* sp = PredictorState(tif);
tmsize_t stride = sp->stride;
- char* cp = (char*) cp0;
+ unsigned char* cp = (unsigned char*) cp0;
assert((cc%stride)==0);
@@ -466,33 +474,33 @@ horDiff8(TIFF* tif, uint8* cp0, tmsize_t cc)
* Pipeline the most common cases.
*/
if (stride == 3) {
- int r1, g1, b1;
- int r2 = cp[0];
- int g2 = cp[1];
- int b2 = cp[2];
+ unsigned int r1, g1, b1;
+ unsigned int r2 = cp[0];
+ unsigned int g2 = cp[1];
+ unsigned int b2 = cp[2];
do {
- r1 = cp[3]; cp[3] = r1-r2; r2 = r1;
- g1 = cp[4]; cp[4] = g1-g2; g2 = g1;
- b1 = cp[5]; cp[5] = b1-b2; b2 = b1;
+ r1 = cp[3]; cp[3] = (unsigned char)((r1-r2)&0xff); r2 = r1;
+ g1 = cp[4]; cp[4] = (unsigned char)((g1-g2)&0xff); g2 = g1;
+ b1 = cp[5]; cp[5] = (unsigned char)((b1-b2)&0xff); b2 = b1;
cp += 3;
} while ((cc -= 3) > 0);
} else if (stride == 4) {
- int r1, g1, b1, a1;
- int r2 = cp[0];
- int g2 = cp[1];
- int b2 = cp[2];
- int a2 = cp[3];
+ unsigned int r1, g1, b1, a1;
+ unsigned int r2 = cp[0];
+ unsigned int g2 = cp[1];
+ unsigned int b2 = cp[2];
+ unsigned int a2 = cp[3];
do {
- r1 = cp[4]; cp[4] = r1-r2; r2 = r1;
- g1 = cp[5]; cp[5] = g1-g2; g2 = g1;
- b1 = cp[6]; cp[6] = b1-b2; b2 = b1;
- a1 = cp[7]; cp[7] = a1-a2; a2 = a1;
+ r1 = cp[4]; cp[4] = (unsigned char)((r1-r2)&0xff); r2 = r1;
+ g1 = cp[5]; cp[5] = (unsigned char)((g1-g2)&0xff); g2 = g1;
+ b1 = cp[6]; cp[6] = (unsigned char)((b1-b2)&0xff); b2 = b1;
+ a1 = cp[7]; cp[7] = (unsigned char)((a1-a2)&0xff); a2 = a1;
cp += 4;
} while ((cc -= 4) > 0);
} else {
cp += cc - 1;
do {
- REPEAT4(stride, cp[stride] -= cp[0]; cp--)
+ REPEAT4(stride, cp[stride] = (unsigned char)((cp[stride] - cp[0])&0xff); cp--)
} while ((cc -= stride) > 0);
}
}
@@ -503,7 +511,7 @@ horDiff16(TIFF* tif, uint8* cp0, tmsize_t cc)
{
TIFFPredictorState* sp = PredictorState(tif);
tmsize_t stride = sp->stride;
- int16 *wp = (int16*) cp0;
+ uint16 *wp = (uint16*) cp0;
tmsize_t wc = cc/2;
assert((cc%(2*stride))==0);
@@ -512,18 +520,29 @@ horDiff16(TIFF* tif, uint8* cp0, tmsize_t cc)
wc -= stride;
wp += wc - 1;
do {
- REPEAT4(stride, wp[stride] -= wp[0]; wp--)
+ REPEAT4(stride, wp[stride] = (uint16)(((unsigned int)wp[stride] - (unsigned int)wp[0]) & 0xffff); wp--)
wc -= stride;
} while (wc > 0);
}
}
static void
+swabHorDiff16(TIFF* tif, uint8* cp0, tmsize_t cc)
+{
+ uint16* wp = (uint16*) cp0;
+ tmsize_t wc = cc / 2;
+
+ horDiff16(tif, cp0, cc);
+
+ TIFFSwabArrayOfShort(wp, wc);
+}
+
+static void
horDiff32(TIFF* tif, uint8* cp0, tmsize_t cc)
{
TIFFPredictorState* sp = PredictorState(tif);
tmsize_t stride = sp->stride;
- int32 *wp = (int32*) cp0;
+ uint32 *wp = (uint32*) cp0;
tmsize_t wc = cc/4;
assert((cc%(4*stride))==0);
@@ -538,6 +557,17 @@ horDiff32(TIFF* tif, uint8* cp0, tmsize_t cc)
}
}
+static void
+swabHorDiff32(TIFF* tif, uint8* cp0, tmsize_t cc)
+{
+ uint32* wp = (uint32*) cp0;
+ tmsize_t wc = cc / 4;
+
+ horDiff32(tif, cp0, cc);
+
+ TIFFSwabArrayOfLong(wp, wc);
+}
+
/*
* Floating point predictor differencing routine.
*/
@@ -573,7 +603,7 @@ fpDiff(TIFF* tif, uint8* cp0, tmsize_t cc)
cp = (uint8 *) cp0;
cp += cc - stride - 1;
for (count = cc; count > stride; count -= stride)
- REPEAT4(stride, cp[stride] -= cp[0]; cp--)
+ REPEAT4(stride, cp[stride] = (unsigned char)((cp[stride] - cp[0])&0xff); cp--)
}
static int
diff --git a/src/3rdparty/libtiff/libtiff/tif_print.c b/src/3rdparty/libtiff/libtiff/tif_print.c
index 402666d..7b1a422 100644
--- a/src/3rdparty/libtiff/libtiff/tif_print.c
+++ b/src/3rdparty/libtiff/libtiff/tif_print.c
@@ -1,4 +1,4 @@
-/* $Id: tif_print.c,v 1.60 2012-08-19 16:56:35 bfriesen Exp $ */
+/* $Id: tif_print.c,v 1.62 2015-08-19 02:31:04 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@@ -35,7 +35,7 @@
#include <ctype.h>
static void
-_TIFFprintAsciiBounded(FILE* fd, const char* cp, int max_chars);
+_TIFFprintAsciiBounded(FILE* fd, const char* cp, size_t max_chars);
static const char *photoNames[] = {
"min-is-white", /* PHOTOMETRIC_MINISWHITE */
@@ -395,7 +395,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
for (cp = td->td_inknames;
i > 0 && cp < td->td_inknames + td->td_inknameslen;
cp = strchr(cp,'\0')+1, i--) {
- int max_chars =
+ size_t max_chars =
td->td_inknameslen - (cp - td->td_inknames);
fputs(sep, fd);
_TIFFprintAsciiBounded(fd, cp, max_chars);
@@ -582,10 +582,10 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
continue;
if(fip->field_passcount) {
- if (fip->field_readcount == TIFF_VARIABLE ) {
+ if (fip->field_readcount == TIFF_VARIABLE2 ) {
if(TIFFGetField(tif, tag, &value_count, &raw_data) != 1)
continue;
- } else if (fip->field_readcount == TIFF_VARIABLE2 ) {
+ } else if (fip->field_readcount == TIFF_VARIABLE ) {
uint16 small_value_count;
if(TIFFGetField(tif, tag, &small_value_count, &raw_data) != 1)
continue;
@@ -679,7 +679,7 @@ _TIFFprintAscii(FILE* fd, const char* cp)
}
static void
-_TIFFprintAsciiBounded(FILE* fd, const char* cp, int max_chars)
+_TIFFprintAsciiBounded(FILE* fd, const char* cp, size_t max_chars)
{
for (; max_chars > 0 && *cp != '\0'; cp++, max_chars--) {
const char* tp;
diff --git a/src/3rdparty/libtiff/libtiff/tif_read.c b/src/3rdparty/libtiff/libtiff/tif_read.c
index fe36e68..5cb419b 100644
--- a/src/3rdparty/libtiff/libtiff/tif_read.c
+++ b/src/3rdparty/libtiff/libtiff/tif_read.c
@@ -1,4 +1,4 @@
-/* $Id: tif_read.c,v 1.41 2012-07-06 19:22:58 bfriesen Exp $ */
+/* $Id: tif_read.c,v 1.45 2015-06-07 22:35:40 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@@ -47,7 +47,7 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart )
{
static const char module[] = "TIFFFillStripPartial";
register TIFFDirectory *td = &tif->tif_dir;
- uint64 unused_data;
+ tmsize_t unused_data;
uint64 read_offset;
tmsize_t cc, to_read;
/* tmsize_t bytecountm; */
@@ -117,7 +117,7 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart )
if( (uint64) to_read > td->td_stripbytecount[strip]
- tif->tif_rawdataoff - tif->tif_rawdataloaded )
{
- to_read = td->td_stripbytecount[strip]
+ to_read = (tmsize_t) td->td_stripbytecount[strip]
- tif->tif_rawdataoff - tif->tif_rawdataloaded;
}
@@ -458,7 +458,7 @@ TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size)
return ((tmsize_t)(-1));
}
bytecount = td->td_stripbytecount[strip];
- if (bytecount <= 0) {
+ if ((int64)bytecount <= 0) {
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
TIFFErrorExt(tif->tif_clientdata, module,
"%I64u: Invalid strip byte count, strip %lu",
@@ -498,7 +498,7 @@ TIFFFillStrip(TIFF* tif, uint32 strip)
if ((tif->tif_flags&TIFF_NOREADRAW)==0)
{
uint64 bytecount = td->td_stripbytecount[strip];
- if (bytecount <= 0) {
+ if ((int64)bytecount <= 0) {
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
TIFFErrorExt(tif->tif_clientdata, module,
"Invalid strip byte count %I64u, strip %lu",
@@ -801,7 +801,7 @@ TIFFFillTile(TIFF* tif, uint32 tile)
if ((tif->tif_flags&TIFF_NOREADRAW)==0)
{
uint64 bytecount = td->td_stripbytecount[tile];
- if (bytecount <= 0) {
+ if ((int64)bytecount <= 0) {
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
TIFFErrorExt(tif->tif_clientdata, module,
"%I64u: Invalid tile byte count, tile %lu",
@@ -930,8 +930,11 @@ TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size)
tif->tif_flags &= ~TIFF_MYBUFFER;
} else {
tif->tif_rawdatasize = (tmsize_t)TIFFroundup_64((uint64)size, 1024);
- if (tif->tif_rawdatasize==0)
- tif->tif_rawdatasize=(tmsize_t)(-1);
+ if (tif->tif_rawdatasize==0) {
+ TIFFErrorExt(tif->tif_clientdata, module,
+ "Invalid buffer size");
+ return (0);
+ }
tif->tif_rawdata = (uint8*) _TIFFmalloc(tif->tif_rawdatasize);
tif->tif_flags |= TIFF_MYBUFFER;
}
@@ -987,10 +990,12 @@ TIFFStartStrip(TIFF* tif, uint32 strip)
static int
TIFFStartTile(TIFF* tif, uint32 tile)
{
+ static const char module[] = "TIFFStartTile";
TIFFDirectory *td = &tif->tif_dir;
+ uint32 howmany32;
- if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount)
- return 0;
+ if (!_TIFFFillStriles( tif ) || !tif->tif_dir.td_stripbytecount)
+ return 0;
if ((tif->tif_flags & TIFF_CODERSETUP) == 0) {
if (!(*tif->tif_setupdecode)(tif))
@@ -998,12 +1003,18 @@ TIFFStartTile(TIFF* tif, uint32 tile)
tif->tif_flags |= TIFF_CODERSETUP;
}
tif->tif_curtile = tile;
- tif->tif_row =
- (tile % TIFFhowmany_32(td->td_imagewidth, td->td_tilewidth)) *
- td->td_tilelength;
- tif->tif_col =
- (tile % TIFFhowmany_32(td->td_imagelength, td->td_tilelength)) *
- td->td_tilewidth;
+ howmany32=TIFFhowmany_32(td->td_imagewidth, td->td_tilewidth);
+ if (howmany32 == 0) {
+ TIFFErrorExt(tif->tif_clientdata,module,"Zero tiles");
+ return 0;
+ }
+ tif->tif_row = (tile % howmany32) * td->td_tilelength;
+ howmany32=TIFFhowmany_32(td->td_imagelength, td->td_tilelength);
+ if (howmany32 == 0) {
+ TIFFErrorExt(tif->tif_clientdata,module,"Zero tiles");
+ return 0;
+ }
+ tif->tif_col = (tile % howmany32) * td->td_tilewidth;
tif->tif_flags &= ~TIFF_BUF4WRITE;
if (tif->tif_flags&TIFF_NOREADRAW)
{
diff --git a/src/3rdparty/libtiff/libtiff/tif_stream.cxx b/src/3rdparty/libtiff/libtiff/tif_stream.cxx
index 163447e..ecca1fd 100644
--- a/src/3rdparty/libtiff/libtiff/tif_stream.cxx
+++ b/src/3rdparty/libtiff/libtiff/tif_stream.cxx
@@ -1,4 +1,4 @@
-/* $Id: tif_stream.cxx,v 1.11 2010-12-11 23:12:29 faxguy Exp $ */
+/* $Id: tif_stream.cxx,v 1.13 2015-05-28 01:50:22 bfriesen Exp $ */
/*
* Copyright (c) 1988-1996 Sam Leffler
@@ -340,12 +340,16 @@ _tiffisCloseProc(thandle_t fd)
static int
_tiffDummyMapProc(thandle_t , void** base, toff_t* size )
{
+ (void) base;
+ (void) size;
return (0);
}
static void
_tiffDummyUnmapProc(thandle_t , void* base, toff_t size )
{
+ (void) base;
+ (void) size;
}
/*
@@ -417,9 +421,10 @@ TIFFStreamOpen(const char* name, istream *is)
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
- Local Variables:
- mode: c
- indent-tabs-mode: true
- c-basic-offset: 8
- End:
-*/
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 8
+ * fill-column: 78
+ * End:
+ */
+
diff --git a/src/3rdparty/libtiff/libtiff/tif_strip.c b/src/3rdparty/libtiff/libtiff/tif_strip.c
index 568e489..6cac71d 100644
--- a/src/3rdparty/libtiff/libtiff/tif_strip.c
+++ b/src/3rdparty/libtiff/libtiff/tif_strip.c
@@ -1,4 +1,4 @@
-/* $Id: tif_strip.c,v 1.35 2012-06-06 05:33:55 fwarmerdam Exp $ */
+/* $Id: tif_strip.c,v 1.36 2015-06-07 22:35:40 bfriesen Exp $ */
/*
* Copyright (c) 1991-1997 Sam Leffler
@@ -317,7 +317,14 @@ TIFFScanlineSize64(TIFF* tif)
}
}
else
+ {
scanline_size=TIFFhowmany_64(_TIFFMultiply64(tif,td->td_imagewidth,td->td_bitspersample,module),8);
+ }
+ if (scanline_size == 0)
+ {
+ TIFFErrorExt(tif->tif_clientdata,module,"Computed scanline size is zero");
+ return 0;
+ }
return(scanline_size);
}
tmsize_t
@@ -328,8 +335,7 @@ TIFFScanlineSize(TIFF* tif)
tmsize_t n;
m=TIFFScanlineSize64(tif);
n=(tmsize_t)m;
- if ((uint64)n!=m)
- {
+ if ((uint64)n!=m) {
TIFFErrorExt(tif->tif_clientdata,module,"Integer arithmetic overflow");
n=0;
}
diff --git a/src/3rdparty/libtiff/libtiff/tif_tile.c b/src/3rdparty/libtiff/libtiff/tif_tile.c
index 0ff7e85..388e168 100644
--- a/src/3rdparty/libtiff/libtiff/tif_tile.c
+++ b/src/3rdparty/libtiff/libtiff/tif_tile.c
@@ -1,4 +1,4 @@
-/* $Id: tif_tile.c,v 1.23 2012-06-06 05:33:55 fwarmerdam Exp $ */
+/* $Id: tif_tile.c,v 1.24 2015-06-07 22:35:40 bfriesen Exp $ */
/*
* Copyright (c) 1991-1997 Sam Leffler
@@ -143,17 +143,40 @@ TIFFNumberOfTiles(TIFF* tif)
uint64
TIFFTileRowSize64(TIFF* tif)
{
+ static const char module[] = "TIFFTileRowSize64";
TIFFDirectory *td = &tif->tif_dir;
uint64 rowsize;
+ uint64 tilerowsize;
- if (td->td_tilelength == 0 || td->td_tilewidth == 0)
+ if (td->td_tilelength == 0)
+ {
+ TIFFErrorExt(tif->tif_clientdata,module,"Tile length is zero");
+ return 0;
+ }
+ if (td->td_tilewidth == 0)
+ {
+ TIFFErrorExt(tif->tif_clientdata,module,"Tile width is zero");
return (0);
+ }
rowsize = _TIFFMultiply64(tif, td->td_bitspersample, td->td_tilewidth,
"TIFFTileRowSize");
if (td->td_planarconfig == PLANARCONFIG_CONTIG)
+ {
+ if (td->td_samplesperpixel == 0)
+ {
+ TIFFErrorExt(tif->tif_clientdata,module,"Samples per pixel is zero");
+ return 0;
+ }
rowsize = _TIFFMultiply64(tif, rowsize, td->td_samplesperpixel,
"TIFFTileRowSize");
- return (TIFFhowmany8_64(rowsize));
+ }
+ tilerowsize=TIFFhowmany8_64(rowsize);
+ if (tilerowsize == 0)
+ {
+ TIFFErrorExt(tif->tif_clientdata,module,"Computed tile row size is zero");
+ return 0;
+ }
+ return (tilerowsize);
}
tmsize_t
TIFFTileRowSize(TIFF* tif)
diff --git a/src/3rdparty/libtiff/libtiff/tif_unix.c b/src/3rdparty/libtiff/libtiff/tif_unix.c
index 1387558..81e9d66 100644
--- a/src/3rdparty/libtiff/libtiff/tif_unix.c
+++ b/src/3rdparty/libtiff/libtiff/tif_unix.c
@@ -1,4 +1,4 @@
-/* $Id: tif_unix.c,v 1.23 2012-06-01 21:40:59 fwarmerdam Exp $ */
+/* $Id: tif_unix.c,v 1.27 2015-08-19 02:31:04 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@@ -55,53 +55,102 @@
#include "tiffiop.h"
+
+#define TIFF_IO_MAX 2147483647U
+
+
+typedef union fd_as_handle_union
+{
+ int fd;
+ thandle_t h;
+} fd_as_handle_union_t;
+
static tmsize_t
_tiffReadProc(thandle_t fd, void* buf, tmsize_t size)
{
- size_t size_io = (size_t) size;
- if ((tmsize_t) size_io != size)
+ fd_as_handle_union_t fdh;
+ const size_t bytes_total = (size_t) size;
+ size_t bytes_read;
+ tmsize_t count = -1;
+ if ((tmsize_t) bytes_total != size)
{
errno=EINVAL;
return (tmsize_t) -1;
}
- return ((tmsize_t) read((int) fd, buf, size_io));
+ fdh.h = fd;
+ for (bytes_read=0; bytes_read < bytes_total; bytes_read+=count)
+ {
+ char *buf_offset = (char *) buf+bytes_read;
+ size_t io_size = bytes_total-bytes_read;
+ if (io_size > TIFF_IO_MAX)
+ io_size = TIFF_IO_MAX;
+ count=read(fdh.fd, buf_offset, (TIFFIOSize_t) io_size);
+ if (count <= 0)
+ break;
+ }
+ if (count < 0)
+ return (tmsize_t)-1;
+ return (tmsize_t) bytes_read;
}
static tmsize_t
_tiffWriteProc(thandle_t fd, void* buf, tmsize_t size)
{
- size_t size_io = (size_t) size;
- if ((tmsize_t) size_io != size)
+ fd_as_handle_union_t fdh;
+ const size_t bytes_total = (size_t) size;
+ size_t bytes_written;
+ tmsize_t count = -1;
+ if ((tmsize_t) bytes_total != size)
{
errno=EINVAL;
return (tmsize_t) -1;
}
- return ((tmsize_t) write((int) fd, buf, size_io));
+ fdh.h = fd;
+ for (bytes_written=0; bytes_written < bytes_total; bytes_written+=count)
+ {
+ const char *buf_offset = (char *) buf+bytes_written;
+ size_t io_size = bytes_total-bytes_written;
+ if (io_size > TIFF_IO_MAX)
+ io_size = TIFF_IO_MAX;
+ count=write(fdh.fd, buf_offset, (TIFFIOSize_t) io_size);
+ if (count <= 0)
+ break;
+ }
+ if (count < 0)
+ return (tmsize_t)-1;
+ return (tmsize_t) bytes_written;
+ /* return ((tmsize_t) write(fdh.fd, buf, bytes_total)); */
}
static uint64
_tiffSeekProc(thandle_t fd, uint64 off, int whence)
{
- off_t off_io = (off_t) off;
+ fd_as_handle_union_t fdh;
+ _TIFF_off_t off_io = (_TIFF_off_t) off;
if ((uint64) off_io != off)
{
errno=EINVAL;
return (uint64) -1; /* this is really gross */
}
- return((uint64)lseek((int)fd,off_io,whence));
+ fdh.h = fd;
+ return((uint64)_TIFF_lseek_f(fdh.fd,off_io,whence));
}
static int
_tiffCloseProc(thandle_t fd)
{
- return(close((int)fd));
+ fd_as_handle_union_t fdh;
+ fdh.h = fd;
+ return(close(fdh.fd));
}
static uint64
_tiffSizeProc(thandle_t fd)
{
- struct stat sb;
- if (fstat((int)fd,&sb)<0)
+ _TIFF_stat_s sb;
+ fd_as_handle_union_t fdh;
+ fdh.h = fd;
+ if (_TIFF_fstat_f(fdh.fd,&sb)<0)
return(0);
else
return((uint64)sb.st_size);
@@ -116,8 +165,10 @@ _tiffMapProc(thandle_t fd, void** pbase, toff_t* psize)
uint64 size64 = _tiffSizeProc(fd);
tmsize_t sizem = (tmsize_t)size64;
if ((uint64)sizem==size64) {
+ fd_as_handle_union_t fdh;
+ fdh.h = fd;
*pbase = (void*)
- mmap(0, (size_t)sizem, PROT_READ, MAP_SHARED, (int) fd, 0);
+ mmap(0, (size_t)sizem, PROT_READ, MAP_SHARED, fdh.fd, 0);
if (*pbase != (void*) -1) {
*psize = (tmsize_t)sizem;
return (1);
@@ -155,8 +206,10 @@ TIFFFdOpen(int fd, const char* name, const char* mode)
{
TIFF* tif;
+ fd_as_handle_union_t fdh;
+ fdh.fd = fd;
tif = TIFFClientOpen(name, mode,
- (thandle_t) fd,
+ fdh.h,
_tiffReadProc, _tiffWriteProc,
_tiffSeekProc, _tiffCloseProc, _tiffSizeProc,
_tiffMapProc, _tiffUnmapProc);
@@ -225,7 +278,7 @@ TIFFOpenW(const wchar_t* name, const char* mode)
fd = _wopen(name, m, 0666);
if (fd < 0) {
- TIFFErrorExt(0, module, "%s: Cannot open", name);
+ TIFFErrorExt(0, module, "%ls: Cannot open", name);
return ((TIFF *)0);
}
@@ -257,6 +310,9 @@ TIFFOpenW(const wchar_t* name, const char* mode)
void*
_TIFFmalloc(tmsize_t s)
{
+ if (s == 0)
+ return ((void *) NULL);
+
return (malloc((size_t) s));
}
diff --git a/src/3rdparty/libtiff/libtiff/tif_win32.c b/src/3rdparty/libtiff/libtiff/tif_win32.c
index 5fa828f..fdc2ee6 100644
--- a/src/3rdparty/libtiff/libtiff/tif_win32.c
+++ b/src/3rdparty/libtiff/libtiff/tif_win32.c
@@ -1,4 +1,4 @@
-/* $Id: tif_win32.c,v 1.39 2011-12-22 17:07:57 bfriesen Exp $ */
+/* $Id: tif_win32.c,v 1.41 2015-08-23 20:12:44 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@@ -28,6 +28,31 @@
* TIFF Library Win32-specific Routines. Adapted from tif_unix.c 4/5/95 by
* Scott Wagner (wagner@itek.com), Itek Graphix, Rochester, NY USA
*/
+
+/*
+ CreateFileA/CreateFileW return type 'HANDLE'.
+
+ thandle_t is declared like
+
+ DECLARE_HANDLE(thandle_t);
+
+ in tiffio.h.
+
+ Windows (from winnt.h) DECLARE_HANDLE logic looks like
+
+ #ifdef STRICT
+ typedef void *HANDLE;
+ #define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
+ #else
+ typedef PVOID HANDLE;
+ #define DECLARE_HANDLE(name) typedef HANDLE name
+ #endif
+
+ See http://bugzilla.maptools.org/show_bug.cgi?id=1941 for problems in WIN64
+ builds resulting from this. Unfortunately, the proposed patch was lost.
+
+*/
+
#include "tiffiop.h"
#include <windows.h>
@@ -214,7 +239,7 @@ TIFFFdOpen(int ifd, const char* name, const char* mode)
break;
}
}
- tif = TIFFClientOpen(name, mode, (thandle_t)ifd,
+ tif = TIFFClientOpen(name, mode, (thandle_t)ifd, /* FIXME: WIN64 cast to pointer warning */
_tiffReadProc, _tiffWriteProc,
_tiffSeekProc, _tiffCloseProc, _tiffSizeProc,
fSuppressMap ? _tiffDummyMapProc : _tiffMapProc,
@@ -259,7 +284,7 @@ TIFFOpen(const char* name, const char* mode)
return ((TIFF *)0);
}
- tif = TIFFFdOpen((int)fd, name, mode);
+ tif = TIFFFdOpen((int)fd, name, mode); /* FIXME: WIN64 cast from pointer to int warning */
if(!tif)
CloseHandle(fd);
return tif;
@@ -314,7 +339,7 @@ TIFFOpenW(const wchar_t* name, const char* mode)
NULL, NULL);
}
- tif = TIFFFdOpen((int)fd,
+ tif = TIFFFdOpen((int)fd, /* FIXME: WIN64 cast from pointer to int warning */
(mbname != NULL) ? mbname : "<unknown>", mode);
if(!tif)
CloseHandle(fd);
@@ -329,6 +354,9 @@ TIFFOpenW(const wchar_t* name, const char* mode)
void*
_TIFFmalloc(tmsize_t s)
{
+ if (s == 0)
+ return ((void *) NULL);
+
return (malloc((size_t) s));
}
diff --git a/src/3rdparty/libtiff/libtiff/tif_write.c b/src/3rdparty/libtiff/libtiff/tif_write.c
index 8792123..7996c31 100644
--- a/src/3rdparty/libtiff/libtiff/tif_write.c
+++ b/src/3rdparty/libtiff/libtiff/tif_write.c
@@ -1,4 +1,4 @@
-/* $Id: tif_write.c,v 1.37 2012-08-13 22:10:17 fwarmerdam Exp $ */
+/* $Id: tif_write.c,v 1.42 2015-06-07 23:00:23 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@@ -115,6 +115,10 @@ TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample)
if (strip >= td->td_stripsperimage && imagegrew)
td->td_stripsperimage =
TIFFhowmany_32(td->td_imagelength,td->td_rowsperstrip);
+ if (td->td_stripsperimage == 0) {
+ TIFFErrorExt(tif->tif_clientdata, module, "Zero strips per image");
+ return (-1);
+ }
tif->tif_row =
(strip % td->td_stripsperimage) * td->td_rowsperstrip;
if ((tif->tif_flags & TIFF_CODERSETUP) == 0) {
@@ -220,6 +224,11 @@ TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc)
tif->tif_flags |= TIFF_BUF4WRITE;
tif->tif_curstrip = strip;
+ if (td->td_stripsperimage == 0) {
+ TIFFErrorExt(tif->tif_clientdata, module, "Zero strips per image");
+ return ((tmsize_t) -1);
+ }
+
tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip;
if ((tif->tif_flags & TIFF_CODERSETUP) == 0) {
if (!(*tif->tif_setupencode)(tif))
@@ -233,7 +242,7 @@ TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc)
/* 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( tif->tif_rawdatasize <= (tmsize_t)td->td_stripbytecount[strip] )
{
if( !(TIFFWriteBufferSetup(tif, NULL,
(tmsize_t)TIFFroundup_64((uint64)(td->td_stripbytecount[strip] + 1), 1024))) )
@@ -311,6 +320,10 @@ TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc)
return ((tmsize_t) -1);
}
tif->tif_curstrip = strip;
+ if (td->td_stripsperimage == 0) {
+ TIFFErrorExt(tif->tif_clientdata, module,"Zero strips per image");
+ return ((tmsize_t) -1);
+ }
tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip;
return (TIFFAppendToStrip(tif, strip, (uint8*) data, cc) ?
cc : (tmsize_t) -1);
@@ -353,6 +366,7 @@ TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc)
static const char module[] = "TIFFWriteEncodedTile";
TIFFDirectory *td;
uint16 sample;
+ uint32 howmany32;
if (!WRITECHECKTILES(tif, module))
return ((tmsize_t)(-1));
@@ -379,7 +393,7 @@ TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc)
/* 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( tif->tif_rawdatasize <= (tmsize_t) td->td_stripbytecount[tile] )
{
if( !(TIFFWriteBufferSetup(tif, NULL,
(tmsize_t)TIFFroundup_64((uint64)(td->td_stripbytecount[tile] + 1), 1024))) )
@@ -391,17 +405,25 @@ TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc)
tif->tif_curoff = 0;
}
- tif->tif_rawcc = 0;
- tif->tif_rawcp = tif->tif_rawdata;
+ tif->tif_rawcc = 0;
+ tif->tif_rawcp = tif->tif_rawdata;
/*
* Compute tiles per row & per column to compute
* current row and column
*/
- tif->tif_row = (tile % TIFFhowmany_32(td->td_imagelength, td->td_tilelength))
- * td->td_tilelength;
- tif->tif_col = (tile % TIFFhowmany_32(td->td_imagewidth, td->td_tilewidth))
- * td->td_tilewidth;
+ howmany32=TIFFhowmany_32(td->td_imagelength, td->td_tilelength);
+ if (howmany32 == 0) {
+ TIFFErrorExt(tif->tif_clientdata,module,"Zero tiles");
+ return ((tmsize_t)(-1));
+ }
+ tif->tif_row = (tile % howmany32) * td->td_tilelength;
+ howmany32=TIFFhowmany_32(td->td_imagewidth, td->td_tilewidth);
+ if (howmany32 == 0) {
+ TIFFErrorExt(tif->tif_clientdata,module,"Zero tiles");
+ return ((tmsize_t)(-1));
+ }
+ tif->tif_col = (tile % howmany32) * td->td_tilewidth;
if ((tif->tif_flags & TIFF_CODERSETUP) == 0) {
if (!(*tif->tif_setupencode)(tif))
diff --git a/src/3rdparty/libtiff/libtiff/tif_zip.c b/src/3rdparty/libtiff/libtiff/tif_zip.c
index f5aa2a9..22e9f35 100644
--- a/src/3rdparty/libtiff/libtiff/tif_zip.c
+++ b/src/3rdparty/libtiff/libtiff/tif_zip.c
@@ -1,4 +1,4 @@
-/* $Id: tif_zip.c,v 1.31 2011-01-06 16:00:23 fwarmerdam Exp $ */
+/* $Id: tif_zip.c,v 1.33 2014-12-25 18:29:11 erouault Exp $ */
/*
* Copyright (c) 1995-1997 Sam Leffler
@@ -36,7 +36,7 @@
* of the library: this code assumes the 1.0 API and also depends on
* the ability to write the zlib header multiple times (one per strip)
* which was not possible with versions prior to 0.95. Note also that
- * older versions of this codec avoided this bug by supressing the header
+ * older versions of this codec avoided this bug by suppressing the header
* entirely. This means that files written with the old library cannot
* be read; they should be converted to a different compression scheme
* and then reconverted.
@@ -61,6 +61,8 @@
#error "Antiquated ZLIB software; you must use version 1.0 or later"
#endif
+#define SAFE_MSG(sp) ((sp)->stream.msg == NULL ? "" : (sp)->stream.msg)
+
/*
* State block for each open TIFF
* file using ZIP compression/decompression.
@@ -106,7 +108,7 @@ ZIPSetupDecode(TIFF* tif)
}
if (inflateInit(&sp->stream) != Z_OK) {
- TIFFErrorExt(tif->tif_clientdata, module, "%s", sp->stream.msg);
+ TIFFErrorExt(tif->tif_clientdata, module, "%s", SAFE_MSG(sp));
return (0);
} else {
sp->state |= ZSTATE_INIT_DECODE;
@@ -174,14 +176,14 @@ ZIPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s)
if (state == Z_DATA_ERROR) {
TIFFErrorExt(tif->tif_clientdata, module,
"Decoding error at scanline %lu, %s",
- (unsigned long) tif->tif_row, sp->stream.msg);
+ (unsigned long) tif->tif_row, SAFE_MSG(sp));
if (inflateSync(&sp->stream) != Z_OK)
return (0);
continue;
}
if (state != Z_OK) {
- TIFFErrorExt(tif->tif_clientdata, module, "ZLib error: %s",
- sp->stream.msg);
+ TIFFErrorExt(tif->tif_clientdata, module,
+ "ZLib error: %s", SAFE_MSG(sp));
return (0);
}
} while (sp->stream.avail_out > 0);
@@ -211,7 +213,7 @@ ZIPSetupEncode(TIFF* tif)
}
if (deflateInit(&sp->stream, sp->zipquality) != Z_OK) {
- TIFFErrorExt(tif->tif_clientdata, module, "%s", sp->stream.msg);
+ TIFFErrorExt(tif->tif_clientdata, module, "%s", SAFE_MSG(sp));
return (0);
} else {
sp->state |= ZSTATE_INIT_ENCODE;
@@ -273,8 +275,9 @@ ZIPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
}
do {
if (deflate(&sp->stream, Z_NO_FLUSH) != Z_OK) {
- TIFFErrorExt(tif->tif_clientdata, module, "Encoder error: %s",
- sp->stream.msg);
+ TIFFErrorExt(tif->tif_clientdata, module,
+ "Encoder error: %s",
+ SAFE_MSG(sp));
return (0);
}
if (sp->stream.avail_out == 0) {
@@ -313,8 +316,8 @@ ZIPPostEncode(TIFF* tif)
}
break;
default:
- TIFFErrorExt(tif->tif_clientdata, module, "ZLib error: %s",
- sp->stream.msg);
+ TIFFErrorExt(tif->tif_clientdata, module,
+ "ZLib error: %s", SAFE_MSG(sp));
return (0);
}
} while (state != Z_STREAM_END);
@@ -359,7 +362,7 @@ ZIPVSetField(TIFF* tif, uint32 tag, va_list ap)
if (deflateParams(&sp->stream,
sp->zipquality, Z_DEFAULT_STRATEGY) != Z_OK) {
TIFFErrorExt(tif->tif_clientdata, module, "ZLib error: %s",
- sp->stream.msg);
+ SAFE_MSG(sp));
return (0);
}
}
diff --git a/src/3rdparty/libtiff/libtiff/tiff.h b/src/3rdparty/libtiff/libtiff/tiff.h
index 19b4e79..bc46acd 100644
--- a/src/3rdparty/libtiff/libtiff/tiff.h
+++ b/src/3rdparty/libtiff/libtiff/tiff.h
@@ -1,4 +1,4 @@
-/* $Id: tiff.h,v 1.68 2012-08-19 16:56:35 bfriesen Exp $ */
+/* $Id: tiff.h,v 1.69 2014-04-02 17:23:06 fwarmerdam Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@@ -201,6 +201,7 @@ typedef enum {
#define PHOTOMETRIC_CIELAB 8 /* !1976 CIE L*a*b* */
#define PHOTOMETRIC_ICCLAB 9 /* ICC L*a*b* [Adobe TIFF Technote 4] */
#define PHOTOMETRIC_ITULAB 10 /* ITU L*a*b* */
+#define PHOTOMETRIC_CFA 32803 /* color filter array */
#define PHOTOMETRIC_LOGL 32844 /* CIE Log2(L) */
#define PHOTOMETRIC_LOGLUV 32845 /* CIE Log2(L) (u',v') */
#define TIFFTAG_THRESHHOLDING 263 /* +thresholding used on data */
@@ -402,6 +403,8 @@ typedef enum {
#define TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA 33306
/* tag 33405 is a private tag registered to Eastman Kodak */
#define TIFFTAG_WRITERSERIALNUMBER 33405 /* device serial number */
+#define TIFFTAG_CFAREPEATPATTERNDIM 33421 /* dimensions of CFA pattern */
+#define TIFFTAG_CFAPATTERN 33422 /* color filter array pattern */
/* tag 33432 is listed in the 6.0 spec w/ unknown ownership */
#define TIFFTAG_COPYRIGHT 33432 /* copyright string */
/* IPTC TAG from RichTIFF specifications */
diff --git a/src/3rdparty/libtiff/libtiff/tiffconf.vc.h b/src/3rdparty/libtiff/libtiff/tiffconf.vc.h
index 680f839..c8c6c65 100644
--- a/src/3rdparty/libtiff/libtiff/tiffconf.vc.h
+++ b/src/3rdparty/libtiff/libtiff/tiffconf.vc.h
@@ -55,22 +55,23 @@
/* Unsigned 64-bit type */
#define TIFF_UINT64_T unsigned __int64
+#if _WIN64
+/*
+ Windows 64-bit build
+*/
+
/* Signed size type */
-#if defined(_WIN64)
-#define TIFF_SSIZE_T signed __int64
-#else
-#define TIFF_SSIZE_T signed int
-#endif
+# define TIFF_SSIZE_T TIFF_INT64_T
-/* Signed size type formatter */
-#if defined(_WIN64)
-#define TIFF_SSIZE_FORMAT "%I64d"
#else
-#define TIFF_SSIZE_FORMAT "%ld"
-#endif
+/*
+ Windows 32-bit build
+*/
-/* Pointer difference type */
-#define TIFF_PTRDIFF_T long
+/* Signed size type */
+# define TIFF_SSIZE_T signed int
+
+#endif
/* Compatibility stuff. */
diff --git a/src/3rdparty/libtiff/libtiff/tiffiop.h b/src/3rdparty/libtiff/libtiff/tiffiop.h
index 916c998..e5d862b 100644
--- a/src/3rdparty/libtiff/libtiff/tiffiop.h
+++ b/src/3rdparty/libtiff/libtiff/tiffiop.h
@@ -1,4 +1,4 @@
-/* $Id: tiffiop.h,v 1.84 2012-05-30 01:50:17 fwarmerdam Exp $ */
+/* $Id: tiffiop.h,v 1.87 2015-08-23 17:49:01 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@@ -61,6 +61,12 @@ extern void *lfind(const void *, const void *, size_t *, size_t,
int (*)(const void *, const void *));
#endif
+#if !defined(HAVE_SNPRINTF) && !defined(HAVE__SNPRINTF)
+#undef snprintf
+#define snprintf _TIFF_snprintf_f
+extern int snprintf(char* str, size_t size, const char* format, ...);
+#endif
+
#include "tiffio.h"
#include "tif_dir.h"
@@ -262,6 +268,53 @@ struct tiff {
#define TIFFArrayCount(a) (sizeof (a) / sizeof ((a)[0]))
+/*
+ Support for large files.
+
+ Windows read/write APIs support only 'unsigned int' rather than 'size_t'.
+ Windows off_t is only 32-bit, even in 64-bit builds.
+*/
+#if defined(HAVE_FSEEKO)
+/*
+ Use fseeko() and ftello() if they are available since they use
+ 'off_t' rather than 'long'. It is wrong to use fseeko() and
+ ftello() only on systems with special LFS support since some systems
+ (e.g. FreeBSD) support a 64-bit off_t by default.
+
+ For MinGW, __MSVCRT_VERSION__ must be at least 0x800 to expose these
+ interfaces. The MinGW compiler must support the requested version. MinGW
+ does not distribute the CRT (it is supplied by Microsoft) so the correct CRT
+ must be available on the target computer in order for the program to run.
+*/
+#if defined(HAVE_FSEEKO)
+# define fseek(stream,offset,whence) fseeko(stream,offset,whence)
+# define ftell(stream,offset,whence) ftello(stream,offset,whence)
+#endif
+#endif
+#if defined(__WIN32__) && \
+ !(defined(_MSC_VER) && _MSC_VER < 1400) && \
+ !(defined(__MSVCRT_VERSION__) && __MSVCRT_VERSION__ < 0x800)
+typedef unsigned int TIFFIOSize_t;
+#define _TIFF_lseek_f(fildes,offset,whence) _lseeki64(fildes,/* __int64 */ offset,whence)
+/* #define _TIFF_tell_f(fildes) /\* __int64 *\/ _telli64(fildes) */
+#define _TIFF_fseek_f(stream,offset,whence) _fseeki64(stream,/* __int64 */ offset,whence)
+#define _TIFF_fstat_f(fildes,stat_buff) _fstati64(fildes,/* struct _stati64 */ stat_buff)
+/* #define _TIFF_ftell_f(stream) /\* __int64 *\/ _ftelli64(stream) */
+/* #define _TIFF_stat_f(path,stat_buff) _stati64(path,/\* struct _stati64 *\/ stat_buff) */
+#define _TIFF_stat_s struct _stati64
+#define _TIFF_off_t __int64
+#else
+typedef size_t TIFFIOSize_t;
+#define _TIFF_lseek_f(fildes,offset,whence) lseek(fildes,offset,whence)
+/* #define _TIFF_tell_f(fildes) (_TIFF_lseek_f(fildes,0,SEEK_CUR)) */
+#define _TIFF_fseek_f(stream,offset,whence) fseek(stream,offset,whence)
+#define _TIFF_fstat_f(fildes,stat_buff) fstat(fildes,stat_buff)
+/* #define _TIFF_ftell_f(stream) ftell(stream) */
+/* #define _TIFF_stat_f(path,stat_buff) stat(path,stat_buff) */
+#define _TIFF_stat_s struct stat
+#define _TIFF_off_t off_t
+#endif
+
#if defined(__cplusplus)
extern "C" {
#endif
diff --git a/src/3rdparty/libtiff/libtiff/tiffvers.h b/src/3rdparty/libtiff/libtiff/tiffvers.h
index 40edc81..e965814 100644
--- a/src/3rdparty/libtiff/libtiff/tiffvers.h
+++ b/src/3rdparty/libtiff/libtiff/tiffvers.h
@@ -1,4 +1,4 @@
-#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.0.3\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
+#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.0.6\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 20120922
+#define TIFFLIB_VERSION 20150912