Update to libtiff-4.0.6 (#764)

This commit is contained in:
Matthieu Darbois 2016-05-01 18:05:46 +02:00
parent 4f11e89c80
commit b51d088267
17 changed files with 538 additions and 348 deletions

View File

@ -55,6 +55,11 @@ SET(TARGET_FILES
IF(UNIX)
SET(TARGET_FILES ${TARGET_FILES} tif_unix.c)
# Large file support
# This might not catch every possibility catered for by
# AC_SYS_LARGEFILE.
add_definitions(-D_FILE_OFFSET_BITS=64)
set(_FILE_OFFSET_BITS 64)
ELSE()
SET(TARGET_FILES ${TARGET_FILES} tif_win32.c)
ENDIF()
@ -70,6 +75,7 @@ endif()
include(CheckIncludeFiles)
include(CheckSymbolExists)
include(CheckFunctionExists)
include(CheckCSourceCompiles)
CHECK_INCLUDE_FILES("zlib.h" HAVE_ZLIB_H)
CHECK_INCLUDE_FILES("jpeglib.h" HAVE_JPEGLIB_H)
@ -135,6 +141,19 @@ CHECK_FUNCTION_EXISTS(strtol HAVE_STRTOL)
CHECK_FUNCTION_EXISTS(strtoul HAVE_STRTOUL)
CHECK_FUNCTION_EXISTS(strtoull HAVE_STRTOULL)
# May be inlined, so check it compiles:
check_c_source_compiles("
#include <stdio.h>
int main(void) {
char buf[10];
snprintf(buf, 10, \"Test %d\", 1);
return 0;
}" HAVE_SNPRINTF)
if(NOT HAVE_SNPRINTF)
SET(TARGET_FILES ${TARGET_FILES} snprintf.c)
endif()
include(CheckTypeSize)
CHECK_TYPE_SIZE("signed int" SIZEOF_SIGNED_INT)
@ -162,20 +181,23 @@ if(HAVE_STDINT_H)
if(NOT HAVE_SSIZE_T)
if("${CMAKE_SIZEOF_VOID_P}" EQUAL 8)
set(TIFF_SSIZE_T int64_t)
set(TIFF_SSIZE_FORMAT "%lld")
set(TIFF_SIZE_FORMAT "%llu")
elseif("${CMAKE_SIZEOF_VOID_P}" EQUAL 4)
set(TIFF_SSIZE_T int32_t)
set(TIFF_SSIZE_FORMAT "%d")
set(TIFF_SIZE_FORMAT "%u")
else()
message(FATAL_ERROR "unknown ssize_t")
endif()
else()
set(TIFF_SSIZE_T ssize_t)
endif()
set(TIFF_INT32_FORMAT "\"%d\"")
set(TIFF_UINT32_FORMAT "\"%u\"")
set(TIFF_INT64_FORMAT "\"%ld\"")
set(TIFF_UINT64_FORMAT "\"%lu\"")
set(TIFF_PTRDIFF_FORMAT "\"%ld\"")
set(TIFF_SSIZE_FORMAT "\"%ld\"")
set(TIFF_INT32_FORMAT "%d")
set(TIFF_UINT32_FORMAT "%u")
set(TIFF_INT64_FORMAT "%lld")
set(TIFF_UINT64_FORMAT "%llu")
set(TIFF_PTRDIFF_FORMAT "%ld")
else()
set(TIFF_INT8_T "signed __int8")
set(TIFF_INT16_T "signed __int16")
@ -189,24 +211,27 @@ else()
if(NOT HAVE_SSIZE_T)
if("${CMAKE_SIZEOF_VOID_P}" EQUAL 8)
set(TIFF_SSIZE_T "signed __int64")
set(TIFF_SSIZE_FORMAT "%lld")
set(TIFF_SIZE_FORMAT "%llu")
elseif("${CMAKE_SIZEOF_VOID_P}" EQUAL 4)
set(TIFF_SSIZE_T "signed __int32")
set(TIFF_SSIZE_FORMAT "%d")
set(TIFF_SIZE_FORMAT "%u")
else()
message(FATAL_ERROR "unknown ssize_t")
endif()
else()
set(TIFF_SSIZE_T ssize_t)
endif()
set(TIFF_INT32_FORMAT "\"%d\"")
set(TIFF_UINT32_FORMAT "\"%u\"")
set(TIFF_INT64_FORMAT "\"%ld\"")
set(TIFF_UINT64_FORMAT "\"%lu\"")
set(TIFF_PTRDIFF_FORMAT "\"%ld\"")
set(TIFF_SSIZE_FORMAT "\"%ld\"")
set(TIFF_INT32_FORMAT "%d")
set(TIFF_UINT32_FORMAT "%u")
set(TIFF_INT64_FORMAT "%lld")
set(TIFF_UINT64_FORMAT "%llu")
set(TIFF_PTRDIFF_FORMAT "%ld")
endif()
#
set(VERSION "\"4.0.1\"")
set(VERSION "\"4.0.6\"")
set(PACKAGE_VERSION ${VERSION})
set(PACKAGE "\"tiff\"")
@ -232,7 +257,7 @@ FOREACH(KEYWORD "inline" "__inline__" "__inline")
COMPILE_DEFINITIONS "-Dinline=${KEYWORD}")
IF(C_HAS_${KEYWORD})
SET(C_INLINE TRUE)
SET(INLINE "${KEYWORD}")
SET(INLINE_KEYWORD "${KEYWORD}")
ENDIF(C_HAS_${KEYWORD})
ENDIF(NOT DEFINED C_INLINE)
ENDFOREACH(KEYWORD)

60
thirdparty/libtiff/libport.h vendored Normal file
View File

@ -0,0 +1,60 @@
/* $Id: libport.h,v 1.5 2015-08-19 02:31:04 bfriesen Exp $ */
/*
* Copyright (c) 2009 Frank Warmerdam
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee, provided
* that (i) the above copyright notices and this permission notice appear in
* all copies of the software and related documentation, and (ii) the names of
* Sam Leffler and Silicon Graphics may not be used in any advertising or
* publicity relating to the software without the specific, prior written
* permission of Sam Leffler and Silicon Graphics.
*
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
*
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
#ifndef _LIBPORT_
#define _LIBPORT_
int getopt(int argc, char * const argv[], const char *optstring);
extern char *optarg;
extern int opterr;
extern int optind;
extern int optopt;
int strcasecmp(const char *s1, const char *s2);
#ifndef HAVE_GETOPT
# define HAVE_GETOPT 1
#endif
#if 0
unsigned long strtoul(const char *nptr, char **endptr, int base);
#endif
#if 0
void *
lfind(const void *key, const void *base, size_t *nmemb, size_t size,
int(*compar)(const void *, const void *));
#endif
#if !defined(HAVE_SNPRINTF)
#undef vsnprintf
#define vsnprintf _TIFF_vsnprintf_f
#undef snprintf
#define snprintf _TIFF_snprintf_f
int snprintf(char* str, size_t size, const char* format, ...);
#endif
#endif /* ndef _LIBPORT_ */

38
thirdparty/libtiff/snprintf.c vendored Normal file
View File

@ -0,0 +1,38 @@
/**
* Workaround for lack of snprintf(3) in Visual Studio. See
* http://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010/8712996#8712996
* It's a trivial wrapper around the builtin _vsnprintf_s and
* _vscprintf functions.
*/
#ifdef _MSC_VER
#include <stdio.h>
#include <stdarg.h>
#include "libport.h"
int _TIFF_vsnprintf_f(char* str, size_t size, const char* format, va_list ap)
{
int count = -1;
if (size != 0)
count = _vsnprintf_s(str, size, _TRUNCATE, format, ap);
if (count == -1)
count = _vscprintf(format, ap);
return count;
}
int _TIFF_snprintf_f(char* str, size_t size, const char* format, ...)
{
int count;
va_list ap;
va_start(ap, format);
count = vsnprintf(str, size, format, ap);
va_end(ap);
return count;
}
#endif // _MSC_VER

View File

@ -1,4 +1,4 @@
/* $Id: tif_codec.c,v 1.16 2013-05-02 14:44:29 tgl Exp $ */
/* $Id: tif_codec.c,v 1.17 2015-08-19 02:31:04 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -108,8 +108,7 @@ _notConfigured(TIFF* tif)
const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression);
char compression_code[20];
snprintf(compression_code, sizeof(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 );

View File

@ -1,357 +1,237 @@
/* libtiff/tif_config.h.in. Generated from configure.ac by autoheader. */
/* Define if building universal (internal helper macro) */
#cmakedefine AC_APPLE_UNIVERSAL_BUILD
/* libtiff/tif_config.h.cmake.in. Not generated, but originated from autoheader. */
/* This file must be kept up-to-date with needed substitutions from libtiff/tif_config.h.in. */
/* Support CCITT Group 3 & 4 algorithms */
#cmakedefine CCITT_SUPPORT @CCITT_SUPPORT@
#cmakedefine CCITT_SUPPORT 1
/* Pick up YCbCr subsampling info from the JPEG data stream to support files
lacking the tag (default enabled). */
#cmakedefine CHECK_JPEG_YCBCR_SUBSAMPLING @CHECK_JPEG_YCBCR_SUBSAMPLING@
#cmakedefine CHECK_JPEG_YCBCR_SUBSAMPLING 1
/* enable partial strip reading for large strips (experimental) */
#cmakedefine CHUNKY_STRIP_READ_SUPPORT
#cmakedefine CHUNKY_STRIP_READ_SUPPORT 1
/* Support C++ stream API (requires C++ compiler) */
#cmakedefine CXX_SUPPORT @CXX_SUPPORT@
/* Treat extra sample as alpha (default enabled). The RGBA interface will
treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many
packages produce RGBA files but don't mark the alpha properly. */
#cmakedefine DEFAULT_EXTRASAMPLE_AS_ALPHA @DEFAULT_EXTRASAMPLE_AS_ALPHA@
#cmakedefine CXX_SUPPORT 1
/* enable deferred strip/tile offset/size loading (experimental) */
#cmakedefine DEFER_STRILE_LOAD @DEFER_STRILE_LOAD@
#cmakedefine DEFER_STRILE_LOAD 1
/* Define to 1 if you have the <assert.h> header file. */
#cmakedefine HAVE_ASSERT_H @HAVE_ASSERT_H@
#cmakedefine HAVE_ASSERT_H 1
/* Define to 1 if you have the <dlfcn.h> header file. */
#cmakedefine HAVE_DLFCN_H @HAVE_DLFCN_H@
#cmakedefine HAVE_DLFCN_H 1
/* Define to 1 if you have the <fcntl.h> header file. */
#cmakedefine HAVE_FCNTL_H @HAVE_FCNTL_H@
#cmakedefine HAVE_FCNTL_H 1
/* Define to 1 if you have the `floor' function. */
#cmakedefine HAVE_FLOOR @HAVE_FLOOR@
#cmakedefine HAVE_FLOOR 1
/* Define to 1 if you have the `getopt' function. */
#cmakedefine HAVE_GETOPT @HAVE_GETOPT@
#cmakedefine HAVE_GETOPT 1
/* Define to 1 if you have the <GLUT/glut.h> header file. */
#cmakedefine HAVE_GLUT_GLUT_H @HAVE_GLUT_GLUT_H@
#cmakedefine HAVE_GLUT_GLUT_H 1
/* Define to 1 if you have the <GL/glut.h> header file. */
#cmakedefine HAVE_GL_GLUT_H @HAVE_GL_GLUT_H@
#cmakedefine HAVE_GL_GLUT_H 1
/* Define to 1 if you have the <GL/glu.h> header file. */
#cmakedefine HAVE_GL_GLU_H @HAVE_GL_GLU_H@
#cmakedefine HAVE_GL_GLU_H 1
/* Define to 1 if you have the <GL/gl.h> header file. */
#cmakedefine HAVE_GL_GL_H @HAVE_GL_GL_H@
/* Define as 0 or 1 according to the floating point format suported by the
machine */
#define HAVE_IEEEFP 1
/* Define to 1 if the system has the type `int16'. */
#cmakedefine HAVE_INT16
/* Define to 1 if the system has the type `int32'. */
#cmakedefine HAVE_INT32
/* Define to 1 if the system has the type `int8'. */
#cmakedefine HAVE_INT8
#cmakedefine HAVE_GL_GL_H 1
/* Define to 1 if you have the <inttypes.h> header file. */
#cmakedefine HAVE_INTTYPES_H @HAVE_INTTYPES_H@
#cmakedefine HAVE_INTTYPES_H 1
/* Define to 1 if you have the <io.h> header file. */
#cmakedefine HAVE_IO_H @HAVE_IO_H@
#cmakedefine HAVE_IO_H 1
/* Define to 1 if you have the `isascii' function. */
#cmakedefine HAVE_ISASCII @HAVE_ISASCII@
#cmakedefine HAVE_ISASCII 1
/* Define to 1 if you have the `jbg_newlen' function. */
#cmakedefine HAVE_JBG_NEWLEN @HAVE_JBG_NEWLEN@
#cmakedefine HAVE_JBG_NEWLEN 1
/* Define to 1 if you have the `lfind' function. */
#cmakedefine HAVE_LFIND @HAVE_LFIND@
/* Define to 1 if you have the `c' library (-lc). */
#cmakedefine HAVE_LIBC @HAVE_LIBC@
/* Define to 1 if you have the `m' library (-lm). */
#cmakedefine HAVE_LIBM @HAVE_LIBM@
#cmakedefine HAVE_LFIND 1
/* Define to 1 if you have the <limits.h> header file. */
#cmakedefine HAVE_LIMITS_H @HAVE_LIMITS_H@
#cmakedefine HAVE_LIMITS_H 1
/* Define to 1 if you have the <malloc.h> header file. */
#cmakedefine HAVE_MALLOC_H @HAVE_MALLOC_H@
#cmakedefine HAVE_MALLOC_H 1
/* Define to 1 if you have the `memmove' function. */
#cmakedefine HAVE_MEMMOVE @HAVE_MEMMOVE@
#cmakedefine HAVE_MEMMOVE 1
/* Define to 1 if you have the <memory.h> header file. */
#cmakedefine HAVE_MEMORY_H @HAVE_MEMORY_H@
#cmakedefine HAVE_MEMORY_H 1
/* Define to 1 if you have the `memset' function. */
#cmakedefine HAVE_MEMSET @HAVE_MEMSET@
#cmakedefine HAVE_MEMSET 1
/* Define to 1 if you have the `mmap' function. */
#cmakedefine HAVE_MMAP @HAVE_MMAP@
#cmakedefine HAVE_MMAP 1
/* Define to 1 if you have the <OpenGL/glu.h> header file. */
#cmakedefine HAVE_OPENGL_GLU_H @HAVE_OPENGL_GLU_H@
#cmakedefine HAVE_OPENGL_GLU_H 1
/* Define to 1 if you have the <OpenGL/gl.h> header file. */
#cmakedefine HAVE_OPENGL_GL_H @HAVE_OPENGL_GL_H@
#cmakedefine HAVE_OPENGL_GL_H 1
/* Define to 1 if you have the `pow' function. */
#cmakedefine HAVE_POW @HAVE_POW@
/* Define if you have POSIX threads libraries and header files. */
#cmakedefine HAVE_PTHREAD
#cmakedefine HAVE_POW 1
/* Define to 1 if you have the <search.h> header file. */
#cmakedefine HAVE_SEARCH_H @HAVE_SEARCH_H@
#cmakedefine HAVE_SEARCH_H 1
/* Define to 1 if you have the `setmode' function. */
#cmakedefine HAVE_SETMODE @HAVE_SETMODE@
#cmakedefine HAVE_SETMODE 1
/* Define to 1 if you have the `snprintf' function. */
#cmakedefine HAVE_SNPRINTF 1
/* Define to 1 if you have the `sqrt' function. */
#cmakedefine HAVE_SQRT @HAVE_SQRT@
#cmakedefine HAVE_SQRT 1
/* Define to 1 if you have the <stdint.h> header file. */
#cmakedefine HAVE_STDINT_H @HAVE_STDINT_H@
/* Define to 1 if you have the <stdlib.h> header file. */
#cmakedefine HAVE_STDLIB_H @HAVE_STDLIB_H@
#cmakedefine HAVE_STDINT_H 1
/* Define to 1 if you have the `strcasecmp' function. */
#cmakedefine HAVE_STRCASECMP @HAVE_STRCASECMP@
#cmakedefine HAVE_STRCASECMP 1
/* Define to 1 if you have the `strchr' function. */
#cmakedefine HAVE_STRCHR @HAVE_STRCHR@
#cmakedefine HAVE_STRCHR 1
/* Define to 1 if you have the <strings.h> header file. */
#cmakedefine HAVE_STRINGS_H @HAVE_STRINGS_H@
#cmakedefine HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#cmakedefine HAVE_STRING_H @HAVE_STRING_H@
#cmakedefine HAVE_STRING_H 1
/* Define to 1 if you have the `strrchr' function. */
#cmakedefine HAVE_STRRCHR @HAVE_STRRCHR@
#cmakedefine HAVE_STRRCHR 1
/* Define to 1 if you have the `strstr' function. */
#cmakedefine HAVE_STRSTR @HAVE_STRSTR@
#cmakedefine HAVE_STRSTR 1
/* Define to 1 if you have the `strtol' function. */
#cmakedefine HAVE_STRTOL @HAVE_STRTOL@
#cmakedefine HAVE_STRTOL 1
/* Define to 1 if you have the `strtoul' function. */
#cmakedefine HAVE_STRTOUL @HAVE_STRTOUL@
#cmakedefine HAVE_STRTOUL 1
/* Define to 1 if you have the `strtoull' function. */
#cmakedefine HAVE_STRTOULL @HAVE_STRTOULL@
/* Define to 1 if you have the <sys/stat.h> header file. */
#cmakedefine HAVE_SYS_STAT_H @HAVE_SYS_STAT_H@
#cmakedefine HAVE_STRTOULL 1
/* Define to 1 if you have the <sys/time.h> header file. */
#cmakedefine HAVE_SYS_TIME_H @HAVE_SYS_TIME_H@
#cmakedefine HAVE_SYS_TIME_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#cmakedefine HAVE_SYS_TYPES_H @HAVE_SYS_TYPES_H@
#cmakedefine HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#cmakedefine HAVE_UNISTD_H @HAVE_UNISTD_H@
/* Use nonstandard varargs form for the GLU tesselator callback */
#cmakedefine HAVE_VARARGS_GLU_TESSCB
/* Define to 1 if you have the <windows.h> header file. */
#cmakedefine HAVE_WINDOWS_H @HAVE_WINDOWS_H@
/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian
(Intel) */
#define HOST_BIGENDIAN @HOST_BIGENDIAN@
/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */
#cmakedefine HOST_FILLORDER @HOST_FILLORDER@
/* Support ISO JBIG compression (requires JBIG-KIT library) */
#cmakedefine JBIG_SUPPORT
#cmakedefine HAVE_UNISTD_H 1
/* 8/12 bit libjpeg dual mode enabled */
#cmakedefine JPEG_DUAL_MODE_8_12
/* Support JPEG compression (requires IJG JPEG library) */
#cmakedefine JPEG_SUPPORT @JPEG_SUPPORT@
#cmakedefine JPEG_DUAL_MODE_8_12 1
/* 12bit libjpeg primary include file with path */
#cmakedefine LIBJPEG_12_PATH
/* Support LogLuv high dynamic range encoding */
#define LOGLUV_SUPPORT 1
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
#define LIBJPEG_12_PATH @LIBJPEG_12_PATH@
/* Support LZMA2 compression */
#cmakedefine LZMA_SUPPORT @LZMA_SUPPORT@
/* Support LZW algorithm */
#define LZW_SUPPORT 1
/* Support Microsoft Document Imaging format */
#cmakedefine MDI_SUPPORT @MDI_SUPPORT@
/* Support NeXT 2-bit RLE algorithm */
#define NEXT_SUPPORT 1
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
#cmakedefine NO_MINUS_C_MINUS_O @NO_MINUS_C_MINUS_O@
/* Support Old JPEG compresson (read-only) */
#cmakedefine OJPEG_SUPPORT
#cmakedefine LZMA_SUPPORT 1
/* Name of package */
#cmakedefine PACKAGE @PACKAGE@
#define PACKAGE "@PACKAGE_NAME@"
/* Define to the address where bug reports for this package should be sent. */
#cmakedefine PACKAGE_BUGREPORT
#define PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@"
/* Define to the full name of this package. */
#cmakedefine PACKAGE_NAME
#define PACKAGE_NAME "@PACKAGE_NAME@"
/* Define to the full name and version of this package. */
#cmakedefine PACKAGE_STRING
#define PACKAGE_STRING "@PACKAGE_STRING@"
/* Define to the one symbol short name of this package. */
#cmakedefine PACKAGE_TARNAME
#define PACKAGE_TARNAME "@PACKAGE_TARNAME@"
/* Define to the home page for this package. */
#undef PACKAGE_URL
#define PACKAGE_URL "@PACKAGE_URL@"
/* Define to the version of this package. */
#cmakedefine PACKAGE_VERSION @PACKAGE_VERSION@
/* Support Macintosh PackBits algorithm */
#define PACKBITS_SUPPORT 1
/* Support Pixar log-format algorithm (requires Zlib) */
#cmakedefine PIXARLOG_SUPPORT @PIXARLOG_SUPPORT@
/* Define to necessary symbol if this constant uses a non-standard name on
your system. */
#cmakedefine PTHREAD_CREATE_JOINABLE
#define PACKAGE_VERSION "@PACKAGE_VERSION@"
/* The size of `signed int', as computed by sizeof. */
#cmakedefine SIZEOF_SIGNED_INT @SIZEOF_SIGNED_INT@
#define SIZEOF_SIGNED_INT @SIZEOF_SIGNED_INT@
/* The size of `signed long', as computed by sizeof. */
#cmakedefine SIZEOF_SIGNED_LONG @SIZEOF_SIGNED_LONG@
#define SIZEOF_SIGNED_LONG @SIZEOF_SIGNED_LONG@
/* The size of `signed long long', as computed by sizeof. */
#cmakedefine SIZEOF_SIGNED_LONG_LONG @SIZEOF_SIGNED_LONG_LONG@
#define SIZEOF_SIGNED_LONG_LONG @SIZEOF_SIGNED_LONG_LONG@
/* The size of `signed short', as computed by sizeof. */
#cmakedefine SIZEOF_SIGNED_SHORT @SIZEOF_SIGNED_SHORT@
#define SIZEOF_SIGNED_SHORT @SIZEOF_SIGNED_SHORT@
/* The size of `unsigned char *', as computed by sizeof. */
#cmakedefine SIZEOF_UNSIGNED_CHAR_P @SIZEOF_UNSIGNED_CHAR_P@
#define SIZEOF_UNSIGNED_CHAR_P @SIZEOF_UNSIGNED_CHAR_P@
/* The size of `unsigned int', as computed by sizeof. */
#cmakedefine SIZEOF_UNSIGNED_INT @SIZEOF_UNSIGNED_INT@
#define SIZEOF_UNSIGNED_INT @SIZEOF_UNSIGNED_INT@
/* The size of `unsigned long', as computed by sizeof. */
#cmakedefine SIZEOF_UNSIGNED_LONG @SIZEOF_UNSIGNED_LONG@
#define SIZEOF_UNSIGNED_LONG @SIZEOF_UNSIGNED_LONG@
/* The size of `unsigned long long', as computed by sizeof. */
#cmakedefine SIZEOF_UNSIGNED_LONG_LONG @SIZEOF_UNSIGNED_LONG_LONG@
#define SIZEOF_UNSIGNED_LONG_LONG @SIZEOF_UNSIGNED_LONG_LONG@
/* The size of `unsigned short', as computed by sizeof. */
#cmakedefine SIZEOF_UNSIGNED_SHORT @SIZEOF_UNSIGNED_SHORT@
/* Define to 1 if you have the ANSI C header files. */
#cmakedefine STDC_HEADERS @STDC_HEADERS@
/* Support strip chopping (whether or not to convert single-strip uncompressed
images to mutiple strips of specified size to reduce memory usage) */
#cmakedefine STRIPCHOP_DEFAULT @STRIPCHOP_DEFAULT@
#define SIZEOF_UNSIGNED_SHORT @SIZEOF_UNSIGNED_SHORT@
/* Default size of the strip in bytes (when strip chopping enabled) */
#cmakedefine STRIP_SIZE_DEFAULT @STRIP_SIZE_DEFAULT@
/* Enable SubIFD tag (330) support */
#cmakedefine SUBIFD_SUPPORT @SUBIFD_SUPPORT@
/* Support ThunderScan 4-bit RLE algorithm */
#cmakedefine THUNDER_SUPPORT @THUNDER_SUPPORT@
/* Signed 16-bit type */
#cmakedefine TIFF_INT16_T @TIFF_INT16_T@
#define STRIP_SIZE_DEFAULT @STRIP_SIZE_DEFAULT@
/* Signed 32-bit type formatter */
#cmakedefine TIFF_INT32_FORMAT @TIFF_INT32_FORMAT@
/* Signed 32-bit type */
#cmakedefine TIFF_INT32_T @TIFF_INT32_T@
#define TIFF_INT32_FORMAT "@TIFF_INT32_FORMAT@"
/* Signed 64-bit type formatter */
#cmakedefine TIFF_INT64_FORMAT @TIFF_INT64_FORMAT@
/* Signed 64-bit type */
#cmakedefine TIFF_INT64_T @TIFF_INT64_T@
/* Signed 8-bit type */
#cmakedefine TIFF_INT8_T @TIFF_INT8_T@
#define TIFF_INT64_FORMAT "@TIFF_INT64_FORMAT@"
/* Pointer difference type formatter */
#cmakedefine TIFF_PTRDIFF_FORMAT @TIFF_PTRDIFF_FORMAT@
#define TIFF_PTRDIFF_FORMAT "@TIFF_PTRDIFF_FORMAT@"
/* Pointer difference type */
#cmakedefine TIFF_PTRDIFF_T @TIFF_PTRDIFF_T@
/* Unsigned size type formatter */
#define TIFF_SIZE_FORMAT "@TIFF_SIZE_FORMAT@"
/* Signed size type formatter */
#cmakedefine TIFF_SSIZE_FORMAT @TIFF_SSIZE_FORMAT@
/* Signed size type */
#cmakedefine TIFF_SSIZE_T @TIFF_SSIZE_T@
/* Unsigned 16-bit type */
#cmakedefine TIFF_UINT16_T @TIFF_UINT16_T@
#define TIFF_SSIZE_FORMAT "@TIFF_SSIZE_FORMAT@"
/* Unsigned 32-bit type formatter */
#cmakedefine TIFF_UINT32_FORMAT @TIFF_UINT32_FORMAT@
/* Unsigned 32-bit type */
#cmakedefine TIFF_UINT32_T @TIFF_UINT32_T@
#define TIFF_UINT32_FORMAT "@TIFF_UINT32_FORMAT@"
/* Unsigned 64-bit type formatter */
#cmakedefine TIFF_UINT64_FORMAT @TIFF_UINT64_FORMAT@
/* Unsigned 64-bit type */
#cmakedefine TIFF_UINT64_T @TIFF_UINT64_T@
#define TIFF_UINT64_FORMAT "@TIFF_UINT64_FORMAT@"
/* Unsigned 8-bit type */
#cmakedefine TIFF_UINT8_T @TIFF_UINT8_T@
#define TIFF_UINT8_T @TIFF_UINT8_T@
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#cmakedefine TIME_WITH_SYS_TIME @TIME_WITH_SYS_TIME@
#undef TIME_WITH_SYS_TIME
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
#cmakedefine TM_IN_SYS_TIME
#cmakedefine TM_IN_SYS_TIME 1
/* define to use win32 IO system */
#cmakedefine USE_WIN32_FILEIO
#cmakedefine USE_WIN32_FILEIO 1
/* Version number of package */
#cmakedefine VERSION @VERSION@
#define VERSION "@PACKAGE_VERSION@"
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
@ -361,38 +241,21 @@
# endif
#else
# ifndef WORDS_BIGENDIAN
#cmakedefine WORDS_BIGENDIAN @WORDS_BIGENDIAN@
# undef WORDS_BIGENDIAN
# endif
#endif
/* Define to 1 if the X Window System is missing or not being used. */
#cmakedefine X_DISPLAY_MISSING
/* Support Deflate compression */
#cmakedefine ZIP_SUPPORT @ZIP_SUPPORT@
/* Number of bits in a file offset, on hosts where this is settable. */
#cmakedefine _FILE_OFFSET_BITS @_FILE_OFFSET_BITS@
/* Define for large files, on AIX-style hosts. */
#cmakedefine _LARGE_FILES
/* Define to empty if `const' does not conform to ANSI C. */
#cmakedefine const
/* Visual Studio 2015 / VC 14 / MSVC 19.00 finally has snprintf() */
#if defined(_MSC_VER) && _MSC_VER < 1900
#define snprintf _snprintf
#endif
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
#define inline @INLINE@
#define inline @INLINE_KEYWORD@
#endif
/* Define to `long int' if <sys/types.h> does not define. */
#cmakedefine off_t
#undef off_t
/* Define to `unsigned int' if <sys/types.h> does not define. */
#cmakedefine size_t
#undef size_t

View File

@ -40,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
@ -119,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
@ -382,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

View File

@ -1,4 +1,4 @@
/* $Id: tif_dirread.c,v 1.187 2015-05-31 21:09:33 bfriesen Exp $ */
/* $Id: tif_dirread.c,v 1.191 2015-09-05 20:31:41 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -3174,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)
@ -3192,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);
@ -3209,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);
@ -3266,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)

View File

@ -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];

View File

@ -1,4 +1,4 @@
/* $Id: tif_jpeg.c,v 1.118 2015-06-10 13:17:41 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));
}
@ -1889,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) {
@ -2379,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
}

View File

@ -1,4 +1,4 @@
/* $Id: tif_lzw.c,v 1.47 2015-06-13 05:03:50 faxguy 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 */
@ -367,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;
@ -836,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; \
@ -872,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;
@ -1034,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;
@ -1048,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);
}

View File

@ -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

View File

@ -1,4 +1,4 @@
/* $Id: tif_print.c,v 1.61 2012-12-12 22:50:18 tgl 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);
@ -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;

View File

@ -1,4 +1,4 @@
/* $Id: tif_unix.c,v 1.26 2015-06-16 15:33:17 erouault Exp $ */
/* $Id: tif_unix.c,v 1.27 2015-08-19 02:31:04 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -55,6 +55,10 @@
#include "tiffiop.h"
#define TIFF_IO_MAX 2147483647U
typedef union fd_as_handle_union
{
int fd;
@ -65,42 +69,71 @@ static tmsize_t
_tiffReadProc(thandle_t fd, void* buf, tmsize_t size)
{
fd_as_handle_union_t fdh;
size_t size_io = (size_t) size;
if ((tmsize_t) size_io != size)
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;
}
fdh.h = fd;
return ((tmsize_t) read(fdh.fd, buf, size_io));
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)
{
fd_as_handle_union_t fdh;
size_t size_io = (size_t) size;
if ((tmsize_t) size_io != size)
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;
}
fdh.h = fd;
return ((tmsize_t) write(fdh.fd, buf, size_io));
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)
{
fd_as_handle_union_t fdh;
off_t off_io = (off_t) off;
_TIFF_off_t off_io = (_TIFF_off_t) off;
if ((uint64) off_io != off)
{
errno=EINVAL;
return (uint64) -1; /* this is really gross */
}
fdh.h = fd;
return((uint64)lseek(fdh.fd,off_io,whence));
return((uint64)_TIFF_lseek_f(fdh.fd,off_io,whence));
}
static int
@ -114,10 +147,10 @@ _tiffCloseProc(thandle_t fd)
static uint64
_tiffSizeProc(thandle_t fd)
{
struct stat sb;
_TIFF_stat_s sb;
fd_as_handle_union_t fdh;
fdh.h = fd;
if (fstat(fdh.fd,&sb)<0)
if (_TIFF_fstat_f(fdh.fd,&sb)<0)
return(0);
else
return((uint64)sb.st_size);
@ -245,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);
}

View File

@ -1,4 +1,4 @@
/* $Id: tif_win32.c,v 1.40 2012-11-18 17:51:52 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);

View File

@ -15,6 +15,39 @@
#include <unistd.h>
#endif
/* Signed 16-bit type */
#define TIFF_INT16_T @TIFF_INT16_T@
/* Signed 32-bit type */
#define TIFF_INT32_T @TIFF_INT32_T@
/* Signed 64-bit type */
#define TIFF_INT64_T @TIFF_INT64_T@
/* Signed 8-bit type */
#define TIFF_INT8_T @TIFF_INT8_T@
/* Unsigned 16-bit type */
#define TIFF_UINT16_T @TIFF_UINT16_T@
/* Unsigned 32-bit type */
#define TIFF_UINT32_T @TIFF_UINT32_T@
/* Unsigned 64-bit type */
#define TIFF_UINT64_T @TIFF_UINT64_T@
/* Unsigned 8-bit type */
#define TIFF_UINT8_T @TIFF_UINT8_T@
/* Unsigned size type */
#define TIFF_SIZE_T @TIFF_SIZE_T@
/* Signed size type */
#define TIFF_SSIZE_T @TIFF_SSIZE_T@
/* Pointer difference type */
#define TIFF_PTRDIFF_T @TIFF_PTRDIFF_T@
/* Define as 0 or 1 according to the floating point format suported by the
machine */
#define HAVE_IEEEFP 1

View File

@ -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
@ -57,6 +57,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"
@ -258,6 +264,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

View File

@ -1,4 +1,4 @@
#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.0.4\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 20150621
#define TIFFLIB_VERSION 20150912