3rdparty: update libtiff 4.0.9
This commit is contained in:
Vendored
+360
-12
@@ -4,27 +4,372 @@
|
||||
# ----------------------------------------------------------------------------
|
||||
project(${TIFF_LIBRARY})
|
||||
|
||||
include(CheckCSourceCompiles)
|
||||
include(CheckFunctionExists)
|
||||
include(CheckIncludeFile)
|
||||
|
||||
check_include_file(assert.h HAVE_ASSERT_H)
|
||||
check_include_file(fcntl.h HAVE_FCNTL_H)
|
||||
check_include_file(io.h HAVE_IO_H)
|
||||
check_function_exists(jbg_newlen HAVE_JBG_NEWLEN)
|
||||
check_include_file(search.h HAVE_SEARCH_H)
|
||||
check_include_file(string.h HAVE_STRING_H)
|
||||
|
||||
# Find libm, if available
|
||||
find_library(M_LIBRARY m)
|
||||
|
||||
check_include_file(assert.h HAVE_ASSERT_H)
|
||||
if(NOT MSVC)
|
||||
check_include_file(dlfcn.h HAVE_DLFCN_H)
|
||||
endif()
|
||||
check_include_file(fcntl.h HAVE_FCNTL_H)
|
||||
check_include_file(inttypes.h HAVE_INTTYPES_H)
|
||||
check_include_file(io.h HAVE_IO_H)
|
||||
check_include_file(limits.h HAVE_LIMITS_H)
|
||||
check_include_file(malloc.h HAVE_MALLOC_H)
|
||||
check_include_file(memory.h HAVE_MEMORY_H)
|
||||
check_include_file(search.h HAVE_SEARCH_H)
|
||||
check_include_file(stdint.h HAVE_STDINT_H)
|
||||
check_include_file(string.h HAVE_STRING_H)
|
||||
if(NOT MSVC)
|
||||
check_include_file(strings.h HAVE_STRINGS_H)
|
||||
check_include_file(sys/time.h HAVE_SYS_TIME_H)
|
||||
endif()
|
||||
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
|
||||
if(NOT MSVC)
|
||||
check_include_file(unistd.h HAVE_UNISTD_H)
|
||||
check_function_exists(mmap HAVE_MMAP)
|
||||
check_include_file(unistd.h HAVE_UNISTD_H)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
set(INLINE_KEYWORD "inline")
|
||||
else()
|
||||
# Inspired from /usr/share/autoconf/autoconf/c.m4
|
||||
foreach(inline_keyword "inline" "__inline__" "__inline")
|
||||
if(NOT DEFINED C_INLINE)
|
||||
set(CMAKE_REQUIRED_DEFINITIONS_SAVE ${CMAKE_REQUIRED_DEFINITIONS})
|
||||
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
||||
"-Dinline=${inline_keyword}")
|
||||
check_c_source_compiles("
|
||||
typedef int foo_t;
|
||||
static inline foo_t static_foo() {return 0;}
|
||||
foo_t foo(){return 0;}
|
||||
int main(int argc, char *argv[]) {return 0;}"
|
||||
C_HAS_${inline_keyword})
|
||||
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS_SAVE})
|
||||
if(C_HAS_${inline_keyword})
|
||||
set(C_INLINE TRUE)
|
||||
set(INLINE_KEYWORD "${inline_keyword}")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
if(NOT DEFINED C_INLINE)
|
||||
set(INLINE_KEYWORD)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
# Check type sizes
|
||||
# NOTE: Could be replaced with C99 <stdint.h>
|
||||
check_type_size("signed short" SIZEOF_SIGNED_SHORT)
|
||||
check_type_size("unsigned short" SIZEOF_UNSIGNED_SHORT)
|
||||
check_type_size("signed int" SIZEOF_SIGNED_INT)
|
||||
check_type_size("unsigned int" SIZEOF_UNSIGNED_INT)
|
||||
check_type_size("signed long" SIZEOF_SIGNED_LONG)
|
||||
check_type_size("unsigned long" SIZEOF_UNSIGNED_LONG)
|
||||
check_type_size("signed long long" SIZEOF_SIGNED_LONG_LONG)
|
||||
check_type_size("unsigned long long" SIZEOF_UNSIGNED_LONG_LONG)
|
||||
check_type_size("unsigned char *" SIZEOF_UNSIGNED_CHAR_P)
|
||||
|
||||
set(CMAKE_EXTRA_INCLUDE_FILES_SAVE ${CMAKE_EXTRA_INCLUDE_FILES})
|
||||
set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} "stddef.h")
|
||||
check_type_size("size_t" SIZEOF_SIZE_T)
|
||||
check_type_size("ptrdiff_t" SIZEOF_PTRDIFF_T)
|
||||
set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES_SAVE})
|
||||
|
||||
set(TIFF_INT8_T "signed char")
|
||||
set(TIFF_UINT8_T "unsigned char")
|
||||
|
||||
set(TIFF_INT16_T "signed short")
|
||||
set(TIFF_UINT16_T "unsigned short")
|
||||
|
||||
if(SIZEOF_SIGNED_INT EQUAL 4)
|
||||
set(TIFF_INT32_T "signed int")
|
||||
set(TIFF_INT32_FORMAT "%d")
|
||||
elseif(SIZEOF_SIGNED_LONG EQUAL 4)
|
||||
set(TIFF_INT32_T "signed long")
|
||||
set(TIFF_INT32_FORMAT "%ld")
|
||||
endif()
|
||||
|
||||
if(SIZEOF_UNSIGNED_INT EQUAL 4)
|
||||
set(TIFF_UINT32_T "unsigned int")
|
||||
set(TIFF_UINT32_FORMAT "%u")
|
||||
elseif(SIZEOF_UNSIGNED_LONG EQUAL 4)
|
||||
set(TIFF_UINT32_T "unsigned long")
|
||||
set(TIFF_UINT32_FORMAT "%lu")
|
||||
endif()
|
||||
|
||||
if(SIZEOF_SIGNED_LONG EQUAL 8)
|
||||
set(TIFF_INT64_T "signed long")
|
||||
set(TIFF_INT64_FORMAT "%ld")
|
||||
elseif(SIZEOF_SIGNED_LONG_LONG EQUAL 8)
|
||||
set(TIFF_INT64_T "signed long long")
|
||||
if(MINGW)
|
||||
set(TIFF_INT64_FORMAT "%I64d")
|
||||
else()
|
||||
set(TIFF_INT64_FORMAT "%lld")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(SIZEOF_UNSIGNED_LONG EQUAL 8)
|
||||
set(TIFF_UINT64_T "unsigned long")
|
||||
set(TIFF_UINT64_FORMAT "%lu")
|
||||
elseif(SIZEOF_UNSIGNED_LONG_LONG EQUAL 8)
|
||||
set(TIFF_UINT64_T "unsigned long long")
|
||||
if(MINGW)
|
||||
set(TIFF_UINT64_FORMAT "%I64u")
|
||||
else()
|
||||
set(TIFF_UINT64_FORMAT "%llu")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(SIZEOF_UNSIGNED_INT EQUAL SIZEOF_SIZE_T)
|
||||
set(TIFF_SIZE_T "unsigned int")
|
||||
set(TIFF_SIZE_FORMAT "%u")
|
||||
elseif(SIZEOF_UNSIGNED_LONG EQUAL SIZEOF_SIZE_T)
|
||||
set(TIFF_SIZE_T "unsigned long")
|
||||
set(TIFF_SIZE_FORMAT "%lu")
|
||||
elseif(SIZEOF_UNSIGNED_LONG_LONG EQUAL SIZEOF_SIZE_T)
|
||||
set(TIFF_SIZE_T "unsigned long")
|
||||
if(MINGW)
|
||||
set(TIFF_SIZE_FORMAT "%I64u")
|
||||
else()
|
||||
set(TIFF_SIZE_FORMAT "%llu")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(SIZEOF_SIGNED_INT EQUAL SIZEOF_UNSIGNED_CHAR_P)
|
||||
set(TIFF_SSIZE_T "signed int")
|
||||
set(TIFF_SSIZE_FORMAT "%d")
|
||||
elseif(SIZEOF_SIGNED_LONG EQUAL SIZEOF_UNSIGNED_CHAR_P)
|
||||
set(TIFF_SSIZE_T "signed long")
|
||||
set(TIFF_SSIZE_FORMAT "%ld")
|
||||
elseif(SIZEOF_SIGNED_LONG_LONG EQUAL SIZEOF_UNSIGNED_CHAR_P)
|
||||
set(TIFF_SSIZE_T "signed long long")
|
||||
if(MINGW)
|
||||
set(TIFF_SSIZE_FORMAT "%I64d")
|
||||
else()
|
||||
set(TIFF_SSIZE_FORMAT "%lld")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT SIZEOF_PTRDIFF_T)
|
||||
set(TIFF_PTRDIFF_T "${TIFF_SSIZE_T}")
|
||||
set(TIFF_PTRDIFF_FORMAT "${SSIZE_FORMAT}")
|
||||
else()
|
||||
set(TIFF_PTRDIFF_T "ptrdiff_t")
|
||||
set(TIFF_PTRDIFF_FORMAT "%ld")
|
||||
endif()
|
||||
|
||||
# Nonstandard int types
|
||||
if(NOT MSVC)
|
||||
check_type_size(INT8 int8)
|
||||
set(HAVE_INT8 ${INT8})
|
||||
check_type_size(INT16 int16)
|
||||
set(HAVE_INT16 ${INT16})
|
||||
check_type_size(INT32 int32)
|
||||
set(HAVE_INT32 ${INT32})
|
||||
endif()
|
||||
|
||||
# Check functions
|
||||
if(NOT MSVC)
|
||||
set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${M_LIBRARY})
|
||||
check_function_exists(floor HAVE_FLOOR)
|
||||
check_function_exists(pow HAVE_POW)
|
||||
check_function_exists(sqrt HAVE_SQRT)
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE})
|
||||
endif()
|
||||
|
||||
if(NOT MSVC)
|
||||
check_function_exists(isascii HAVE_ISASCII)
|
||||
check_function_exists(memset HAVE_MEMSET)
|
||||
check_function_exists(mmap HAVE_MMAP)
|
||||
check_function_exists(getopt HAVE_GETOPT)
|
||||
endif()
|
||||
check_function_exists(memmove HAVE_MEMMOVE)
|
||||
check_function_exists(setmode HAVE_SETMODE)
|
||||
check_function_exists(strcasecmp HAVE_STRCASECMP)
|
||||
check_function_exists(strchr HAVE_STRCHR)
|
||||
check_function_exists(strrchr HAVE_STRRCHR)
|
||||
check_function_exists(strstr HAVE_STRSTR)
|
||||
check_function_exists(strtol HAVE_STRTOL)
|
||||
check_function_exists(strtol HAVE_STRTOUL)
|
||||
check_function_exists(strtoull HAVE_STRTOULL)
|
||||
check_function_exists(lfind HAVE_LFIND)
|
||||
|
||||
# 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)
|
||||
add_definitions(-DNEED_LIBPORT)
|
||||
endif()
|
||||
|
||||
# CPU bit order
|
||||
set(fillorder FILLORDER_MSB2LSB)
|
||||
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "i.*86.*" OR
|
||||
CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64.*" OR
|
||||
CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64.*")
|
||||
set(fillorder FILLORDER_LSB2MSB)
|
||||
endif()
|
||||
set(HOST_FILLORDER ${fillorder} CACHE STRING "Native CPU bit order")
|
||||
mark_as_advanced(HOST_FILLORDER)
|
||||
|
||||
# CPU endianness
|
||||
include(TestBigEndian)
|
||||
test_big_endian(bigendian)
|
||||
if(bigendian)
|
||||
set(bigendian ON)
|
||||
else()
|
||||
set(bigendian OFF)
|
||||
endif()
|
||||
set(HOST_BIG_ENDIAN ${bigendian} CACHE STRING "Native CPU bit order")
|
||||
mark_as_advanced(HOST_BIG_ENDIAN)
|
||||
if(HOST_BIG_ENDIAN)
|
||||
set(HOST_BIG_ENDIAN 1)
|
||||
else()
|
||||
set(HOST_BIG_ENDIAN 0)
|
||||
endif()
|
||||
|
||||
# IEEE floating point
|
||||
set(HAVE_IEEEFP 1 CACHE STRING "IEEE floating point is available")
|
||||
mark_as_advanced(HAVE_IEEEFP)
|
||||
|
||||
# Large file support
|
||||
if(UNIX OR MINGW)
|
||||
# This might not catch every possibility catered for by
|
||||
# AC_SYS_LARGEFILE.
|
||||
add_definitions(-D_FILE_OFFSET_BITS=64)
|
||||
set(FILE_OFFSET_BITS 64)
|
||||
endif()
|
||||
|
||||
# Documentation install directory (default to cmake project docdir)
|
||||
set(LIBTIFF_DOCDIR "${CMAKE_INSTALL_FULL_DOCDIR}")
|
||||
|
||||
# Options to enable and disable internal codecs
|
||||
|
||||
option(ccitt "support for CCITT Group 3 & 4 algorithms" ON)
|
||||
set(CCITT_SUPPORT ${ccitt})
|
||||
|
||||
option(packbits "support for Macintosh PackBits algorithm" ON)
|
||||
set(PACKBITS_SUPPORT ${packbits})
|
||||
|
||||
option(lzw "support for LZW algorithm" ON)
|
||||
set(LZW_SUPPORT ${lzw})
|
||||
|
||||
option(thunder "support for ThunderScan 4-bit RLE algorithm" ON)
|
||||
set(THUNDER_SUPPORT ${thunder})
|
||||
|
||||
option(next "support for NeXT 2-bit RLE algorithm" ON)
|
||||
set(NEXT_SUPPORT ${next})
|
||||
|
||||
option(logluv "support for LogLuv high dynamic range algorithm" ON)
|
||||
set(LOGLUV_SUPPORT ${logluv})
|
||||
|
||||
# Option for Microsoft Document Imaging
|
||||
option(mdi "support for Microsoft Document Imaging" ON)
|
||||
set(MDI_SUPPORT ${mdi})
|
||||
|
||||
# ZLIB
|
||||
set(ZLIB_SUPPORT 0)
|
||||
if(ZLIB_LIBRARY)
|
||||
set(ZLIB_SUPPORT 1)
|
||||
endif()
|
||||
set(ZIP_SUPPORT ${ZLIB_SUPPORT})
|
||||
|
||||
set(PIXARLOG_SUPPORT FALSE)
|
||||
|
||||
# JPEG
|
||||
set(JPEG_SUPPORT FALSE)
|
||||
if(HAVE_JPEG)
|
||||
set(JPEG_SUPPORT TRUE)
|
||||
include_directories(${JPEG_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
option(old-jpeg "support for Old JPEG compression (read-only)" OFF) # OpenCV: changed to OFF
|
||||
set(OJPEG_SUPPORT FALSE)
|
||||
if(JPEG_SUPPORT AND old-jpeg)
|
||||
set(OJPEG_SUPPORT TRUE)
|
||||
endif()
|
||||
|
||||
# OpenCV: turned off
|
||||
set(JBIG_SUPPORT 0)
|
||||
set(LZMA_SUPPORT 0) # OpenCV: turned off
|
||||
set(JPEG12_FOUND FALSE) # OpenCV: turned off
|
||||
set(STRIPCHOP_DEFAULT)
|
||||
set(STRIP_SIZE_DEFAULT 8192)
|
||||
|
||||
# Win32 IO
|
||||
set(win32_io FALSE)
|
||||
if(WIN32 AND NOT WINRT)
|
||||
set(USE_WIN32_FILEIO 1)
|
||||
set(win32_io TRUE)
|
||||
endif()
|
||||
set(USE_WIN32_FILEIO ${win32_io} CACHE BOOL "Use win32 IO system (Microsoft Windows only)")
|
||||
if(USE_WIN32_FILEIO)
|
||||
set(USE_WIN32_FILEIO TRUE)
|
||||
else()
|
||||
set(USE_WIN32_FILEIO FALSE)
|
||||
endif()
|
||||
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tif_config.h.cmakein"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/tif_config.h" @ONLY)
|
||||
# Orthogonal features
|
||||
|
||||
# OpenCV: turned ON
|
||||
set(SUBIFD_SUPPORT 1)
|
||||
set(DEFAULT_EXTRASAMPLE_AS_ALPHA 1)
|
||||
set(CHECK_JPEG_YCBCR_SUBSAMPLING 1)
|
||||
|
||||
if(JPEG_INCLUDE_DIR)
|
||||
list(APPEND TIFF_INCLUDES ${JPEG_INCLUDE_DIR})
|
||||
endif()
|
||||
if(JPEG12_INCLUDE_DIR)
|
||||
list(APPEND TIFF_INCLUDES ${JPEG12_INCLUDE_DIR})
|
||||
endif()
|
||||
if(JBIG_INCLUDE_DIR)
|
||||
list(APPEND TIFF_INCLUDES ${JBIG_INCLUDE_DIR})
|
||||
endif()
|
||||
if(LIBLZMA_INCLUDE_DIRS)
|
||||
list(APPEND TIFF_INCLUDES ${LIBLZMA_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
# Libraries required by libtiff
|
||||
set(TIFF_LIBRARY_DEPS)
|
||||
if(M_LIBRARY)
|
||||
list(APPEND TIFF_LIBRARY_DEPS ${M_LIBRARY})
|
||||
endif()
|
||||
if(ZLIB_LIBRARIES)
|
||||
list(APPEND TIFF_LIBRARY_DEPS ${ZLIB_LIBRARIES})
|
||||
endif()
|
||||
if(JPEG_LIBRARIES)
|
||||
list(APPEND TIFF_LIBRARY_DEPS ${JPEG_LIBRARIES})
|
||||
endif()
|
||||
if(JPEG12_LIBRARIES)
|
||||
list(APPEND TIFF_LIBRARY_DEPS ${JPEG12_LIBRARIES})
|
||||
endif()
|
||||
if(JBIG_LIBRARIES)
|
||||
list(APPEND TIFF_LIBRARY_DEPS ${JBIG_LIBRARIES})
|
||||
endif()
|
||||
if(LIBLZMA_LIBRARIES)
|
||||
list(APPEND TIFF_LIBRARY_DEPS ${LIBLZMA_LIBRARIES})
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tif_config.h.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/tif_config.h"
|
||||
@ONLY)
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tiffconf.h.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/tiffconf.h"
|
||||
@ONLY)
|
||||
|
||||
ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}" ${ZLIB_INCLUDE_DIRS})
|
||||
|
||||
@@ -79,6 +424,7 @@ set(lib_srcs
|
||||
uvcode.h
|
||||
tiffio.hxx
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/tif_config.h"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/tiffconf.h"
|
||||
)
|
||||
|
||||
if(WIN32 AND NOT WINRT)
|
||||
@@ -92,7 +438,9 @@ ocv_warnings_disable(CMAKE_C_FLAGS -Wno-unused-but-set-variable -Wmissing-protot
|
||||
-Wmisleading-indentation
|
||||
)
|
||||
ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-parameter) # clang
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wmissing-declarations -Wunused-parameter)
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wmissing-declarations -Wunused-parameter
|
||||
-Wundef # tiffiop.h: #if __clang_major__ >= 4
|
||||
)
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4018 /wd4100 /wd4127 /wd4311 /wd4701 /wd4706) # vs2005
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244) # vs2008
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4267 /wd4305 /wd4306) # vs2008 Win64
|
||||
|
||||
Vendored
+255
-237
@@ -1,26 +1,26 @@
|
||||
/* $Id: tif_aux.c,v 1.26 2010-07-01 15:33:28 dron Exp $ */
|
||||
/* $Id: tif_aux.c,v 1.31 2017-11-17 20:21:00 erouault Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1991-1997 Sam Leffler
|
||||
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
@@ -36,126 +36,130 @@
|
||||
uint32
|
||||
_TIFFMultiply32(TIFF* tif, uint32 first, uint32 second, const char* where)
|
||||
{
|
||||
uint32 bytes = first * second;
|
||||
uint32 bytes = first * second;
|
||||
|
||||
if (second && bytes / second != first) {
|
||||
TIFFErrorExt(tif->tif_clientdata, where, "Integer overflow in %s", where);
|
||||
bytes = 0;
|
||||
}
|
||||
if (second && bytes / second != first) {
|
||||
TIFFErrorExt(tif->tif_clientdata, where, "Integer overflow in %s", where);
|
||||
bytes = 0;
|
||||
}
|
||||
|
||||
return bytes;
|
||||
return bytes;
|
||||
}
|
||||
|
||||
uint64
|
||||
_TIFFMultiply64(TIFF* tif, uint64 first, uint64 second, const char* where)
|
||||
{
|
||||
uint64 bytes = first * second;
|
||||
uint64 bytes = first * second;
|
||||
|
||||
if (second && bytes / second != first) {
|
||||
TIFFErrorExt(tif->tif_clientdata, where, "Integer overflow in %s", where);
|
||||
bytes = 0;
|
||||
}
|
||||
if (second && bytes / second != first) {
|
||||
TIFFErrorExt(tif->tif_clientdata, where, "Integer overflow in %s", where);
|
||||
bytes = 0;
|
||||
}
|
||||
|
||||
return bytes;
|
||||
return bytes;
|
||||
}
|
||||
|
||||
void*
|
||||
_TIFFCheckRealloc(TIFF* tif, void* buffer,
|
||||
tmsize_t nmemb, tmsize_t elem_size, const char* what)
|
||||
tmsize_t nmemb, tmsize_t elem_size, const char* what)
|
||||
{
|
||||
void* cp = NULL;
|
||||
tmsize_t bytes = nmemb * elem_size;
|
||||
void* cp = NULL;
|
||||
tmsize_t bytes = nmemb * elem_size;
|
||||
|
||||
/*
|
||||
* XXX: Check for integer overflow.
|
||||
*/
|
||||
if (nmemb && elem_size && bytes / elem_size == nmemb)
|
||||
cp = _TIFFrealloc(buffer, bytes);
|
||||
/*
|
||||
* XXX: Check for integer overflow.
|
||||
*/
|
||||
if (nmemb && elem_size && bytes / elem_size == nmemb)
|
||||
cp = _TIFFrealloc(buffer, bytes);
|
||||
|
||||
if (cp == NULL) {
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||
"Failed to allocate memory for %s "
|
||||
"(%ld elements of %ld bytes each)",
|
||||
what,(long) nmemb, (long) elem_size);
|
||||
}
|
||||
if (cp == NULL) {
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||
"Failed to allocate memory for %s "
|
||||
"(%ld elements of %ld bytes each)",
|
||||
what,(long) nmemb, (long) elem_size);
|
||||
}
|
||||
|
||||
return cp;
|
||||
return cp;
|
||||
}
|
||||
|
||||
void*
|
||||
_TIFFCheckMalloc(TIFF* tif, tmsize_t nmemb, tmsize_t elem_size, const char* what)
|
||||
{
|
||||
return _TIFFCheckRealloc(tif, NULL, nmemb, elem_size, what);
|
||||
return _TIFFCheckRealloc(tif, NULL, nmemb, elem_size, what);
|
||||
}
|
||||
|
||||
static int
|
||||
TIFFDefaultTransferFunction(TIFFDirectory* td)
|
||||
{
|
||||
uint16 **tf = td->td_transferfunction;
|
||||
tmsize_t i, n, nbytes;
|
||||
uint16 **tf = td->td_transferfunction;
|
||||
tmsize_t i, n, nbytes;
|
||||
|
||||
tf[0] = tf[1] = tf[2] = 0;
|
||||
if (td->td_bitspersample >= sizeof(tmsize_t) * 8 - 2)
|
||||
return 0;
|
||||
tf[0] = tf[1] = tf[2] = 0;
|
||||
if (td->td_bitspersample >= sizeof(tmsize_t) * 8 - 2)
|
||||
return 0;
|
||||
|
||||
n = ((tmsize_t)1)<<td->td_bitspersample;
|
||||
nbytes = n * sizeof (uint16);
|
||||
if (!(tf[0] = (uint16 *)_TIFFmalloc(nbytes)))
|
||||
return 0;
|
||||
tf[0][0] = 0;
|
||||
for (i = 1; i < n; i++) {
|
||||
double t = (double)i/((double) n-1.);
|
||||
tf[0][i] = (uint16)floor(65535.*pow(t, 2.2) + .5);
|
||||
}
|
||||
n = ((tmsize_t)1)<<td->td_bitspersample;
|
||||
nbytes = n * sizeof (uint16);
|
||||
tf[0] = (uint16 *)_TIFFmalloc(nbytes);
|
||||
if (tf[0] == NULL)
|
||||
return 0;
|
||||
tf[0][0] = 0;
|
||||
for (i = 1; i < n; i++) {
|
||||
double t = (double)i/((double) n-1.);
|
||||
tf[0][i] = (uint16)floor(65535.*pow(t, 2.2) + .5);
|
||||
}
|
||||
|
||||
if (td->td_samplesperpixel - td->td_extrasamples > 1) {
|
||||
if (!(tf[1] = (uint16 *)_TIFFmalloc(nbytes)))
|
||||
goto bad;
|
||||
_TIFFmemcpy(tf[1], tf[0], nbytes);
|
||||
if (!(tf[2] = (uint16 *)_TIFFmalloc(nbytes)))
|
||||
goto bad;
|
||||
_TIFFmemcpy(tf[2], tf[0], nbytes);
|
||||
}
|
||||
return 1;
|
||||
if (td->td_samplesperpixel - td->td_extrasamples > 1) {
|
||||
tf[1] = (uint16 *)_TIFFmalloc(nbytes);
|
||||
if(tf[1] == NULL)
|
||||
goto bad;
|
||||
_TIFFmemcpy(tf[1], tf[0], nbytes);
|
||||
tf[2] = (uint16 *)_TIFFmalloc(nbytes);
|
||||
if (tf[2] == NULL)
|
||||
goto bad;
|
||||
_TIFFmemcpy(tf[2], tf[0], nbytes);
|
||||
}
|
||||
return 1;
|
||||
|
||||
bad:
|
||||
if (tf[0])
|
||||
_TIFFfree(tf[0]);
|
||||
if (tf[1])
|
||||
_TIFFfree(tf[1]);
|
||||
if (tf[2])
|
||||
_TIFFfree(tf[2]);
|
||||
tf[0] = tf[1] = tf[2] = 0;
|
||||
return 0;
|
||||
if (tf[0])
|
||||
_TIFFfree(tf[0]);
|
||||
if (tf[1])
|
||||
_TIFFfree(tf[1]);
|
||||
if (tf[2])
|
||||
_TIFFfree(tf[2]);
|
||||
tf[0] = tf[1] = tf[2] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
TIFFDefaultRefBlackWhite(TIFFDirectory* td)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
if (!(td->td_refblackwhite = (float *)_TIFFmalloc(6*sizeof (float))))
|
||||
return 0;
|
||||
td->td_refblackwhite = (float *)_TIFFmalloc(6*sizeof (float));
|
||||
if (td->td_refblackwhite == NULL)
|
||||
return 0;
|
||||
if (td->td_photometric == PHOTOMETRIC_YCBCR) {
|
||||
/*
|
||||
* YCbCr (Class Y) images must have the ReferenceBlackWhite
|
||||
* tag set. Fix the broken images, which lacks that tag.
|
||||
*/
|
||||
td->td_refblackwhite[0] = 0.0F;
|
||||
td->td_refblackwhite[1] = td->td_refblackwhite[3] =
|
||||
td->td_refblackwhite[5] = 255.0F;
|
||||
td->td_refblackwhite[2] = td->td_refblackwhite[4] = 128.0F;
|
||||
} else {
|
||||
/*
|
||||
* Assume RGB (Class R)
|
||||
*/
|
||||
for (i = 0; i < 3; i++) {
|
||||
td->td_refblackwhite[2*i+0] = 0;
|
||||
td->td_refblackwhite[2*i+1] =
|
||||
(float)((1L<<td->td_bitspersample)-1L);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
/*
|
||||
* YCbCr (Class Y) images must have the ReferenceBlackWhite
|
||||
* tag set. Fix the broken images, which lacks that tag.
|
||||
*/
|
||||
td->td_refblackwhite[0] = 0.0F;
|
||||
td->td_refblackwhite[1] = td->td_refblackwhite[3] =
|
||||
td->td_refblackwhite[5] = 255.0F;
|
||||
td->td_refblackwhite[2] = td->td_refblackwhite[4] = 128.0F;
|
||||
} else {
|
||||
/*
|
||||
* Assume RGB (Class R)
|
||||
*/
|
||||
for (i = 0; i < 3; i++) {
|
||||
td->td_refblackwhite[2*i+0] = 0;
|
||||
td->td_refblackwhite[2*i+1] =
|
||||
(float)((1L<<td->td_bitspersample)-1L);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -163,132 +167,139 @@ TIFFDefaultRefBlackWhite(TIFFDirectory* td)
|
||||
* value if the tag is not present in the directory.
|
||||
*
|
||||
* NB: We use the value in the directory, rather than
|
||||
* explcit values so that defaults exist only one
|
||||
* explicit values so that defaults exist only one
|
||||
* place in the library -- in TIFFDefaultDirectory.
|
||||
*/
|
||||
int
|
||||
TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap)
|
||||
{
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
|
||||
if (TIFFVGetField(tif, tag, ap))
|
||||
return (1);
|
||||
switch (tag) {
|
||||
case TIFFTAG_SUBFILETYPE:
|
||||
*va_arg(ap, uint32 *) = td->td_subfiletype;
|
||||
return (1);
|
||||
case TIFFTAG_BITSPERSAMPLE:
|
||||
*va_arg(ap, uint16 *) = td->td_bitspersample;
|
||||
return (1);
|
||||
case TIFFTAG_THRESHHOLDING:
|
||||
*va_arg(ap, uint16 *) = td->td_threshholding;
|
||||
return (1);
|
||||
case TIFFTAG_FILLORDER:
|
||||
*va_arg(ap, uint16 *) = td->td_fillorder;
|
||||
return (1);
|
||||
case TIFFTAG_ORIENTATION:
|
||||
*va_arg(ap, uint16 *) = td->td_orientation;
|
||||
return (1);
|
||||
case TIFFTAG_SAMPLESPERPIXEL:
|
||||
*va_arg(ap, uint16 *) = td->td_samplesperpixel;
|
||||
return (1);
|
||||
case TIFFTAG_ROWSPERSTRIP:
|
||||
*va_arg(ap, uint32 *) = td->td_rowsperstrip;
|
||||
return (1);
|
||||
case TIFFTAG_MINSAMPLEVALUE:
|
||||
*va_arg(ap, uint16 *) = td->td_minsamplevalue;
|
||||
return (1);
|
||||
case TIFFTAG_MAXSAMPLEVALUE:
|
||||
*va_arg(ap, uint16 *) = td->td_maxsamplevalue;
|
||||
return (1);
|
||||
case TIFFTAG_PLANARCONFIG:
|
||||
*va_arg(ap, uint16 *) = td->td_planarconfig;
|
||||
return (1);
|
||||
case TIFFTAG_RESOLUTIONUNIT:
|
||||
*va_arg(ap, uint16 *) = td->td_resolutionunit;
|
||||
return (1);
|
||||
case TIFFTAG_PREDICTOR:
|
||||
{
|
||||
TIFFPredictorState* sp = (TIFFPredictorState*) tif->tif_data;
|
||||
*va_arg(ap, uint16*) = (uint16) sp->predictor;
|
||||
return 1;
|
||||
}
|
||||
case TIFFTAG_DOTRANGE:
|
||||
*va_arg(ap, uint16 *) = 0;
|
||||
*va_arg(ap, uint16 *) = (1<<td->td_bitspersample)-1;
|
||||
return (1);
|
||||
case TIFFTAG_INKSET:
|
||||
*va_arg(ap, uint16 *) = INKSET_CMYK;
|
||||
if (TIFFVGetField(tif, tag, ap))
|
||||
return (1);
|
||||
switch (tag) {
|
||||
case TIFFTAG_SUBFILETYPE:
|
||||
*va_arg(ap, uint32 *) = td->td_subfiletype;
|
||||
return (1);
|
||||
case TIFFTAG_BITSPERSAMPLE:
|
||||
*va_arg(ap, uint16 *) = td->td_bitspersample;
|
||||
return (1);
|
||||
case TIFFTAG_THRESHHOLDING:
|
||||
*va_arg(ap, uint16 *) = td->td_threshholding;
|
||||
return (1);
|
||||
case TIFFTAG_FILLORDER:
|
||||
*va_arg(ap, uint16 *) = td->td_fillorder;
|
||||
return (1);
|
||||
case TIFFTAG_ORIENTATION:
|
||||
*va_arg(ap, uint16 *) = td->td_orientation;
|
||||
return (1);
|
||||
case TIFFTAG_SAMPLESPERPIXEL:
|
||||
*va_arg(ap, uint16 *) = td->td_samplesperpixel;
|
||||
return (1);
|
||||
case TIFFTAG_ROWSPERSTRIP:
|
||||
*va_arg(ap, uint32 *) = td->td_rowsperstrip;
|
||||
return (1);
|
||||
case TIFFTAG_MINSAMPLEVALUE:
|
||||
*va_arg(ap, uint16 *) = td->td_minsamplevalue;
|
||||
return (1);
|
||||
case TIFFTAG_MAXSAMPLEVALUE:
|
||||
*va_arg(ap, uint16 *) = td->td_maxsamplevalue;
|
||||
return (1);
|
||||
case TIFFTAG_PLANARCONFIG:
|
||||
*va_arg(ap, uint16 *) = td->td_planarconfig;
|
||||
return (1);
|
||||
case TIFFTAG_RESOLUTIONUNIT:
|
||||
*va_arg(ap, uint16 *) = td->td_resolutionunit;
|
||||
return (1);
|
||||
case TIFFTAG_PREDICTOR:
|
||||
{
|
||||
TIFFPredictorState* sp = (TIFFPredictorState*) tif->tif_data;
|
||||
if( sp == NULL )
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||
"Cannot get \"Predictor\" tag as plugin is not configured");
|
||||
*va_arg(ap, uint16*) = 0;
|
||||
return 0;
|
||||
}
|
||||
*va_arg(ap, uint16*) = (uint16) sp->predictor;
|
||||
return 1;
|
||||
case TIFFTAG_NUMBEROFINKS:
|
||||
*va_arg(ap, uint16 *) = 4;
|
||||
return (1);
|
||||
case TIFFTAG_EXTRASAMPLES:
|
||||
*va_arg(ap, uint16 *) = td->td_extrasamples;
|
||||
*va_arg(ap, uint16 **) = td->td_sampleinfo;
|
||||
return (1);
|
||||
case TIFFTAG_MATTEING:
|
||||
*va_arg(ap, uint16 *) =
|
||||
(td->td_extrasamples == 1 &&
|
||||
td->td_sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA);
|
||||
return (1);
|
||||
case TIFFTAG_TILEDEPTH:
|
||||
*va_arg(ap, uint32 *) = td->td_tiledepth;
|
||||
return (1);
|
||||
case TIFFTAG_DATATYPE:
|
||||
*va_arg(ap, uint16 *) = td->td_sampleformat-1;
|
||||
return (1);
|
||||
case TIFFTAG_SAMPLEFORMAT:
|
||||
*va_arg(ap, uint16 *) = td->td_sampleformat;
|
||||
return(1);
|
||||
case TIFFTAG_IMAGEDEPTH:
|
||||
*va_arg(ap, uint32 *) = td->td_imagedepth;
|
||||
return (1);
|
||||
case TIFFTAG_YCBCRCOEFFICIENTS:
|
||||
{
|
||||
/* defaults are from CCIR Recommendation 601-1 */
|
||||
static float ycbcrcoeffs[] = { 0.299f, 0.587f, 0.114f };
|
||||
*va_arg(ap, float **) = ycbcrcoeffs;
|
||||
return 1;
|
||||
}
|
||||
case TIFFTAG_YCBCRSUBSAMPLING:
|
||||
*va_arg(ap, uint16 *) = td->td_ycbcrsubsampling[0];
|
||||
*va_arg(ap, uint16 *) = td->td_ycbcrsubsampling[1];
|
||||
return (1);
|
||||
case TIFFTAG_YCBCRPOSITIONING:
|
||||
*va_arg(ap, uint16 *) = td->td_ycbcrpositioning;
|
||||
return (1);
|
||||
case TIFFTAG_WHITEPOINT:
|
||||
{
|
||||
static float whitepoint[2];
|
||||
|
||||
/* TIFF 6.0 specification tells that it is no default
|
||||
value for the WhitePoint, but AdobePhotoshop TIFF
|
||||
Technical Note tells that it should be CIE D50. */
|
||||
whitepoint[0] = D50_X0 / (D50_X0 + D50_Y0 + D50_Z0);
|
||||
whitepoint[1] = D50_Y0 / (D50_X0 + D50_Y0 + D50_Z0);
|
||||
*va_arg(ap, float **) = whitepoint;
|
||||
return 1;
|
||||
}
|
||||
case TIFFTAG_TRANSFERFUNCTION:
|
||||
if (!td->td_transferfunction[0] &&
|
||||
!TIFFDefaultTransferFunction(td)) {
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "No space for \"TransferFunction\" tag");
|
||||
return (0);
|
||||
}
|
||||
*va_arg(ap, uint16 **) = td->td_transferfunction[0];
|
||||
if (td->td_samplesperpixel - td->td_extrasamples > 1) {
|
||||
*va_arg(ap, uint16 **) = td->td_transferfunction[1];
|
||||
*va_arg(ap, uint16 **) = td->td_transferfunction[2];
|
||||
}
|
||||
return (1);
|
||||
case TIFFTAG_REFERENCEBLACKWHITE:
|
||||
if (!td->td_refblackwhite && !TIFFDefaultRefBlackWhite(td))
|
||||
return (0);
|
||||
*va_arg(ap, float **) = td->td_refblackwhite;
|
||||
return (1);
|
||||
}
|
||||
return 0;
|
||||
case TIFFTAG_DOTRANGE:
|
||||
*va_arg(ap, uint16 *) = 0;
|
||||
*va_arg(ap, uint16 *) = (1<<td->td_bitspersample)-1;
|
||||
return (1);
|
||||
case TIFFTAG_INKSET:
|
||||
*va_arg(ap, uint16 *) = INKSET_CMYK;
|
||||
return 1;
|
||||
case TIFFTAG_NUMBEROFINKS:
|
||||
*va_arg(ap, uint16 *) = 4;
|
||||
return (1);
|
||||
case TIFFTAG_EXTRASAMPLES:
|
||||
*va_arg(ap, uint16 *) = td->td_extrasamples;
|
||||
*va_arg(ap, uint16 **) = td->td_sampleinfo;
|
||||
return (1);
|
||||
case TIFFTAG_MATTEING:
|
||||
*va_arg(ap, uint16 *) =
|
||||
(td->td_extrasamples == 1 &&
|
||||
td->td_sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA);
|
||||
return (1);
|
||||
case TIFFTAG_TILEDEPTH:
|
||||
*va_arg(ap, uint32 *) = td->td_tiledepth;
|
||||
return (1);
|
||||
case TIFFTAG_DATATYPE:
|
||||
*va_arg(ap, uint16 *) = td->td_sampleformat-1;
|
||||
return (1);
|
||||
case TIFFTAG_SAMPLEFORMAT:
|
||||
*va_arg(ap, uint16 *) = td->td_sampleformat;
|
||||
return(1);
|
||||
case TIFFTAG_IMAGEDEPTH:
|
||||
*va_arg(ap, uint32 *) = td->td_imagedepth;
|
||||
return (1);
|
||||
case TIFFTAG_YCBCRCOEFFICIENTS:
|
||||
{
|
||||
/* defaults are from CCIR Recommendation 601-1 */
|
||||
static float ycbcrcoeffs[] = { 0.299f, 0.587f, 0.114f };
|
||||
*va_arg(ap, float **) = ycbcrcoeffs;
|
||||
return 1;
|
||||
}
|
||||
case TIFFTAG_YCBCRSUBSAMPLING:
|
||||
*va_arg(ap, uint16 *) = td->td_ycbcrsubsampling[0];
|
||||
*va_arg(ap, uint16 *) = td->td_ycbcrsubsampling[1];
|
||||
return (1);
|
||||
case TIFFTAG_YCBCRPOSITIONING:
|
||||
*va_arg(ap, uint16 *) = td->td_ycbcrpositioning;
|
||||
return (1);
|
||||
case TIFFTAG_WHITEPOINT:
|
||||
{
|
||||
static float whitepoint[2];
|
||||
|
||||
/* TIFF 6.0 specification tells that it is no default
|
||||
value for the WhitePoint, but AdobePhotoshop TIFF
|
||||
Technical Note tells that it should be CIE D50. */
|
||||
whitepoint[0] = D50_X0 / (D50_X0 + D50_Y0 + D50_Z0);
|
||||
whitepoint[1] = D50_Y0 / (D50_X0 + D50_Y0 + D50_Z0);
|
||||
*va_arg(ap, float **) = whitepoint;
|
||||
return 1;
|
||||
}
|
||||
case TIFFTAG_TRANSFERFUNCTION:
|
||||
if (!td->td_transferfunction[0] &&
|
||||
!TIFFDefaultTransferFunction(td)) {
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "No space for \"TransferFunction\" tag");
|
||||
return (0);
|
||||
}
|
||||
*va_arg(ap, uint16 **) = td->td_transferfunction[0];
|
||||
if (td->td_samplesperpixel - td->td_extrasamples > 1) {
|
||||
*va_arg(ap, uint16 **) = td->td_transferfunction[1];
|
||||
*va_arg(ap, uint16 **) = td->td_transferfunction[2];
|
||||
}
|
||||
return (1);
|
||||
case TIFFTAG_REFERENCEBLACKWHITE:
|
||||
if (!td->td_refblackwhite && !TIFFDefaultRefBlackWhite(td))
|
||||
return (0);
|
||||
*va_arg(ap, float **) = td->td_refblackwhite;
|
||||
return (1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -298,54 +309,61 @@ TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap)
|
||||
int
|
||||
TIFFGetFieldDefaulted(TIFF* tif, uint32 tag, ...)
|
||||
{
|
||||
int ok;
|
||||
va_list ap;
|
||||
int ok;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, tag);
|
||||
ok = TIFFVGetFieldDefaulted(tif, tag, ap);
|
||||
va_end(ap);
|
||||
return (ok);
|
||||
va_start(ap, tag);
|
||||
ok = TIFFVGetFieldDefaulted(tif, tag, ap);
|
||||
va_end(ap);
|
||||
return (ok);
|
||||
}
|
||||
|
||||
struct _Int64Parts {
|
||||
int32 low, high;
|
||||
int32 low, high;
|
||||
};
|
||||
|
||||
typedef union {
|
||||
struct _Int64Parts part;
|
||||
int64 value;
|
||||
struct _Int64Parts part;
|
||||
int64 value;
|
||||
} _Int64;
|
||||
|
||||
float
|
||||
_TIFFUInt64ToFloat(uint64 ui64)
|
||||
{
|
||||
_Int64 i;
|
||||
_Int64 i;
|
||||
|
||||
i.value = ui64;
|
||||
if (i.part.high >= 0) {
|
||||
return (float)i.value;
|
||||
} else {
|
||||
long double df;
|
||||
df = (long double)i.value;
|
||||
df += 18446744073709551616.0; /* adding 2**64 */
|
||||
return (float)df;
|
||||
}
|
||||
i.value = ui64;
|
||||
if (i.part.high >= 0) {
|
||||
return (float)i.value;
|
||||
} else {
|
||||
long double df;
|
||||
df = (long double)i.value;
|
||||
df += 18446744073709551616.0; /* adding 2**64 */
|
||||
return (float)df;
|
||||
}
|
||||
}
|
||||
|
||||
double
|
||||
_TIFFUInt64ToDouble(uint64 ui64)
|
||||
{
|
||||
_Int64 i;
|
||||
_Int64 i;
|
||||
|
||||
i.value = ui64;
|
||||
if (i.part.high >= 0) {
|
||||
return (double)i.value;
|
||||
} else {
|
||||
long double df;
|
||||
df = (long double)i.value;
|
||||
df += 18446744073709551616.0; /* adding 2**64 */
|
||||
return (double)df;
|
||||
}
|
||||
i.value = ui64;
|
||||
if (i.part.high >= 0) {
|
||||
return (double)i.value;
|
||||
} else {
|
||||
long double df;
|
||||
df = (long double)i.value;
|
||||
df += 18446744073709551616.0; /* adding 2**64 */
|
||||
return (double)df;
|
||||
}
|
||||
}
|
||||
|
||||
int _TIFFSeekOK(TIFF* tif, toff_t off)
|
||||
{
|
||||
/* Huge offsets, especially -1 / UINT64_MAX, can cause issues */
|
||||
/* See http://bugzilla.maptools.org/show_bug.cgi?id=2726 */
|
||||
return off <= (~(uint64)0)/2 && TIFFSeekFile(tif,off,SEEK_SET)==off;
|
||||
}
|
||||
|
||||
/* vim: set ts=8 sts=8 sw=8 noet: */
|
||||
|
||||
Vendored
+49
-49
@@ -1,26 +1,26 @@
|
||||
/* $Id: tif_close.c,v 1.19 2010-03-10 18:56:48 bfriesen Exp $ */
|
||||
/* $Id: tif_close.c,v 1.21 2016-01-23 21:20:34 erouault Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
@@ -36,61 +36,61 @@
|
||||
|
||||
/**
|
||||
* Auxiliary function to free the TIFF structure. Given structure will be
|
||||
* completetly freed, so you should save opened file handle and pointer
|
||||
* completely freed, so you should save opened file handle and pointer
|
||||
* to the close procedure in external variables before calling
|
||||
* _TIFFCleanup(), if you will need these ones to close the file.
|
||||
*
|
||||
*
|
||||
* @param tif A TIFF pointer.
|
||||
*/
|
||||
|
||||
void
|
||||
TIFFCleanup(TIFF* tif)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* Flush buffered data and directory (if dirty).
|
||||
*/
|
||||
if (tif->tif_mode != O_RDONLY)
|
||||
TIFFFlush(tif);
|
||||
(*tif->tif_cleanup)(tif);
|
||||
TIFFFreeDirectory(tif);
|
||||
if (tif->tif_mode != O_RDONLY)
|
||||
TIFFFlush(tif);
|
||||
(*tif->tif_cleanup)(tif);
|
||||
TIFFFreeDirectory(tif);
|
||||
|
||||
if (tif->tif_dirlist)
|
||||
_TIFFfree(tif->tif_dirlist);
|
||||
if (tif->tif_dirlist)
|
||||
_TIFFfree(tif->tif_dirlist);
|
||||
|
||||
/*
|
||||
/*
|
||||
* Clean up client info links.
|
||||
*/
|
||||
while( tif->tif_clientinfo )
|
||||
{
|
||||
TIFFClientInfoLink *link = tif->tif_clientinfo;
|
||||
while( tif->tif_clientinfo )
|
||||
{
|
||||
TIFFClientInfoLink *psLink = tif->tif_clientinfo;
|
||||
|
||||
tif->tif_clientinfo = link->next;
|
||||
_TIFFfree( link->name );
|
||||
_TIFFfree( link );
|
||||
}
|
||||
tif->tif_clientinfo = psLink->next;
|
||||
_TIFFfree( psLink->name );
|
||||
_TIFFfree( psLink );
|
||||
}
|
||||
|
||||
if (tif->tif_rawdata && (tif->tif_flags&TIFF_MYBUFFER))
|
||||
_TIFFfree(tif->tif_rawdata);
|
||||
if (isMapped(tif))
|
||||
TIFFUnmapFileContents(tif, tif->tif_base, (toff_t)tif->tif_size);
|
||||
if (tif->tif_rawdata && (tif->tif_flags&TIFF_MYBUFFER))
|
||||
_TIFFfree(tif->tif_rawdata);
|
||||
if (isMapped(tif))
|
||||
TIFFUnmapFileContents(tif, tif->tif_base, (toff_t)tif->tif_size);
|
||||
|
||||
/*
|
||||
/*
|
||||
* Clean up custom fields.
|
||||
*/
|
||||
if (tif->tif_fields && tif->tif_nfields > 0) {
|
||||
uint32 i;
|
||||
if (tif->tif_fields && tif->tif_nfields > 0) {
|
||||
uint32 i;
|
||||
|
||||
for (i = 0; i < tif->tif_nfields; i++) {
|
||||
TIFFField *fld = tif->tif_fields[i];
|
||||
if (fld->field_bit == FIELD_CUSTOM &&
|
||||
strncmp("Tag ", fld->field_name, 4) == 0) {
|
||||
_TIFFfree(fld->field_name);
|
||||
_TIFFfree(fld);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < tif->tif_nfields; i++) {
|
||||
TIFFField *fld = tif->tif_fields[i];
|
||||
if (fld->field_bit == FIELD_CUSTOM &&
|
||||
strncmp("Tag ", fld->field_name, 4) == 0) {
|
||||
_TIFFfree(fld->field_name);
|
||||
_TIFFfree(fld);
|
||||
}
|
||||
}
|
||||
|
||||
_TIFFfree(tif->tif_fields);
|
||||
}
|
||||
_TIFFfree(tif->tif_fields);
|
||||
}
|
||||
|
||||
if (tif->tif_nfieldscompat > 0) {
|
||||
uint32 i;
|
||||
@@ -102,7 +102,7 @@ TIFFCleanup(TIFF* tif)
|
||||
_TIFFfree(tif->tif_fieldscompat);
|
||||
}
|
||||
|
||||
_TIFFfree(tif);
|
||||
_TIFFfree(tif);
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
@@ -115,18 +115,18 @@ TIFFCleanup(TIFF* tif)
|
||||
* TIFFClose closes a file that was previously opened with TIFFOpen().
|
||||
* Any buffered data are flushed to the file, including the contents of
|
||||
* the current directory (if modified); and all resources are reclaimed.
|
||||
*
|
||||
*
|
||||
* @param tif A TIFF pointer.
|
||||
*/
|
||||
|
||||
void
|
||||
TIFFClose(TIFF* tif)
|
||||
{
|
||||
TIFFCloseProc closeproc = tif->tif_closeproc;
|
||||
thandle_t fd = tif->tif_clientdata;
|
||||
TIFFCloseProc closeproc = tif->tif_closeproc;
|
||||
thandle_t fd = tif->tif_clientdata;
|
||||
|
||||
TIFFCleanup(tif);
|
||||
(void) (*closeproc)(fd);
|
||||
TIFFCleanup(tif);
|
||||
(void) (*closeproc)(fd);
|
||||
}
|
||||
|
||||
/* vim: set ts=8 sts=8 sw=8 noet: */
|
||||
|
||||
Vendored
+34
-34
@@ -1,26 +1,26 @@
|
||||
/* $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
|
||||
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
@@ -94,7 +94,7 @@ TIFFCodec _TIFFBuiltinCODECS[] = {
|
||||
{ "CCITT Group 4", COMPRESSION_CCITTFAX4, TIFFInitCCITTFax4 },
|
||||
{ "ISO JBIG", COMPRESSION_JBIG, TIFFInitJBIG },
|
||||
{ "Deflate", COMPRESSION_DEFLATE, TIFFInitZIP },
|
||||
{ "AdobeDeflate", COMPRESSION_ADOBE_DEFLATE , TIFFInitZIP },
|
||||
{ "AdobeDeflate", COMPRESSION_ADOBE_DEFLATE , TIFFInitZIP },
|
||||
{ "PixarLog", COMPRESSION_PIXARLOG, TIFFInitPixarLog },
|
||||
{ "SGILog", COMPRESSION_SGILOG, TIFFInitSGILog },
|
||||
{ "SGILog24", COMPRESSION_SGILOG24, TIFFInitSGILog },
|
||||
@@ -105,27 +105,27 @@ TIFFCodec _TIFFBuiltinCODECS[] = {
|
||||
static int
|
||||
_notConfigured(TIFF* tif)
|
||||
{
|
||||
const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression);
|
||||
const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression);
|
||||
char compression_code[20];
|
||||
|
||||
sprintf( compression_code, "%d", tif->tif_dir.td_compression );
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||
"%s compression support is not configured",
|
||||
|
||||
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 );
|
||||
return (0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
NotConfigured(TIFF* tif, int scheme)
|
||||
{
|
||||
(void) scheme;
|
||||
(void) scheme;
|
||||
|
||||
tif->tif_fixuptags = _notConfigured;
|
||||
tif->tif_decodestatus = FALSE;
|
||||
tif->tif_setupdecode = _notConfigured;
|
||||
tif->tif_encodestatus = FALSE;
|
||||
tif->tif_setupencode = _notConfigured;
|
||||
return (1);
|
||||
tif->tif_fixuptags = _notConfigured;
|
||||
tif->tif_decodestatus = FALSE;
|
||||
tif->tif_setupdecode = _notConfigured;
|
||||
tif->tif_encodestatus = FALSE;
|
||||
tif->tif_setupencode = _notConfigured;
|
||||
return (1);
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
@@ -142,18 +142,18 @@ NotConfigured(TIFF* tif, int scheme)
|
||||
int
|
||||
TIFFIsCODECConfigured(uint16 scheme)
|
||||
{
|
||||
const TIFFCodec* codec = TIFFFindCODEC(scheme);
|
||||
const TIFFCodec* codec = TIFFFindCODEC(scheme);
|
||||
|
||||
if(codec == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if(codec->init == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if(codec->init != NotConfigured){
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
if(codec == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if(codec->init == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if(codec->init != NotConfigured){
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Vendored
+147
-125
@@ -1,26 +1,26 @@
|
||||
/* $Id: tif_color.c,v 1.19 2010-12-14 02:22:42 faxguy Exp $ */
|
||||
/* $Id: tif_color.c,v 1.24 2017-05-29 10:12:54 erouault Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
@@ -44,30 +44,30 @@
|
||||
*/
|
||||
void
|
||||
TIFFCIELabToXYZ(TIFFCIELabToRGB *cielab, uint32 l, int32 a, int32 b,
|
||||
float *X, float *Y, float *Z)
|
||||
float *X, float *Y, float *Z)
|
||||
{
|
||||
float L = (float)l * 100.0F / 255.0F;
|
||||
float cby, tmp;
|
||||
float L = (float)l * 100.0F / 255.0F;
|
||||
float cby, tmp;
|
||||
|
||||
if( L < 8.856F ) {
|
||||
*Y = (L * cielab->Y0) / 903.292F;
|
||||
cby = 7.787F * (*Y / cielab->Y0) + 16.0F / 116.0F;
|
||||
} else {
|
||||
cby = (L + 16.0F) / 116.0F;
|
||||
*Y = cielab->Y0 * cby * cby * cby;
|
||||
}
|
||||
if( L < 8.856F ) {
|
||||
*Y = (L * cielab->Y0) / 903.292F;
|
||||
cby = 7.787F * (*Y / cielab->Y0) + 16.0F / 116.0F;
|
||||
} else {
|
||||
cby = (L + 16.0F) / 116.0F;
|
||||
*Y = cielab->Y0 * cby * cby * cby;
|
||||
}
|
||||
|
||||
tmp = (float)a / 500.0F + cby;
|
||||
if( tmp < 0.2069F )
|
||||
*X = cielab->X0 * (tmp - 0.13793F) / 7.787F;
|
||||
else
|
||||
*X = cielab->X0 * tmp * tmp * tmp;
|
||||
tmp = (float)a / 500.0F + cby;
|
||||
if( tmp < 0.2069F )
|
||||
*X = cielab->X0 * (tmp - 0.13793F) / 7.787F;
|
||||
else
|
||||
*X = cielab->X0 * tmp * tmp * tmp;
|
||||
|
||||
tmp = cby - (float)b / 200.0F;
|
||||
if( tmp < 0.2069F )
|
||||
*Z = cielab->Z0 * (tmp - 0.13793F) / 7.787F;
|
||||
else
|
||||
*Z = cielab->Z0 * tmp * tmp * tmp;
|
||||
tmp = cby - (float)b / 200.0F;
|
||||
if( tmp < 0.2069F )
|
||||
*Z = cielab->Z0 * (tmp - 0.13793F) / 7.787F;
|
||||
else
|
||||
*Z = cielab->Z0 * tmp * tmp * tmp;
|
||||
}
|
||||
|
||||
#define RINT(R) ((uint32)((R)>0?((R)+0.5):((R)-0.5)))
|
||||
@@ -76,98 +76,98 @@ TIFFCIELabToXYZ(TIFFCIELabToRGB *cielab, uint32 l, int32 a, int32 b,
|
||||
*/
|
||||
void
|
||||
TIFFXYZToRGB(TIFFCIELabToRGB *cielab, float X, float Y, float Z,
|
||||
uint32 *r, uint32 *g, uint32 *b)
|
||||
uint32 *r, uint32 *g, uint32 *b)
|
||||
{
|
||||
int i;
|
||||
float Yr, Yg, Yb;
|
||||
float *matrix = &cielab->display.d_mat[0][0];
|
||||
int i;
|
||||
float Yr, Yg, Yb;
|
||||
float *matrix = &cielab->display.d_mat[0][0];
|
||||
|
||||
/* Multiply through the matrix to get luminosity values. */
|
||||
Yr = matrix[0] * X + matrix[1] * Y + matrix[2] * Z;
|
||||
Yg = matrix[3] * X + matrix[4] * Y + matrix[5] * Z;
|
||||
Yb = matrix[6] * X + matrix[7] * Y + matrix[8] * Z;
|
||||
/* Multiply through the matrix to get luminosity values. */
|
||||
Yr = matrix[0] * X + matrix[1] * Y + matrix[2] * Z;
|
||||
Yg = matrix[3] * X + matrix[4] * Y + matrix[5] * Z;
|
||||
Yb = matrix[6] * X + matrix[7] * Y + matrix[8] * Z;
|
||||
|
||||
/* Clip input */
|
||||
Yr = TIFFmax(Yr, cielab->display.d_Y0R);
|
||||
Yg = TIFFmax(Yg, cielab->display.d_Y0G);
|
||||
Yb = TIFFmax(Yb, cielab->display.d_Y0B);
|
||||
/* Clip input */
|
||||
Yr = TIFFmax(Yr, cielab->display.d_Y0R);
|
||||
Yg = TIFFmax(Yg, cielab->display.d_Y0G);
|
||||
Yb = TIFFmax(Yb, cielab->display.d_Y0B);
|
||||
|
||||
/* Avoid overflow in case of wrong input values */
|
||||
Yr = TIFFmin(Yr, cielab->display.d_YCR);
|
||||
Yg = TIFFmin(Yg, cielab->display.d_YCG);
|
||||
Yb = TIFFmin(Yb, cielab->display.d_YCB);
|
||||
/* Avoid overflow in case of wrong input values */
|
||||
Yr = TIFFmin(Yr, cielab->display.d_YCR);
|
||||
Yg = TIFFmin(Yg, cielab->display.d_YCG);
|
||||
Yb = TIFFmin(Yb, cielab->display.d_YCB);
|
||||
|
||||
/* Turn luminosity to colour value. */
|
||||
i = (int)((Yr - cielab->display.d_Y0R) / cielab->rstep);
|
||||
i = TIFFmin(cielab->range, i);
|
||||
*r = RINT(cielab->Yr2r[i]);
|
||||
/* Turn luminosity to colour value. */
|
||||
i = (int)((Yr - cielab->display.d_Y0R) / cielab->rstep);
|
||||
i = TIFFmin(cielab->range, i);
|
||||
*r = RINT(cielab->Yr2r[i]);
|
||||
|
||||
i = (int)((Yg - cielab->display.d_Y0G) / cielab->gstep);
|
||||
i = TIFFmin(cielab->range, i);
|
||||
*g = RINT(cielab->Yg2g[i]);
|
||||
i = (int)((Yg - cielab->display.d_Y0G) / cielab->gstep);
|
||||
i = TIFFmin(cielab->range, i);
|
||||
*g = RINT(cielab->Yg2g[i]);
|
||||
|
||||
i = (int)((Yb - cielab->display.d_Y0B) / cielab->bstep);
|
||||
i = TIFFmin(cielab->range, i);
|
||||
*b = RINT(cielab->Yb2b[i]);
|
||||
i = (int)((Yb - cielab->display.d_Y0B) / cielab->bstep);
|
||||
i = TIFFmin(cielab->range, i);
|
||||
*b = RINT(cielab->Yb2b[i]);
|
||||
|
||||
/* Clip output. */
|
||||
*r = TIFFmin(*r, cielab->display.d_Vrwr);
|
||||
*g = TIFFmin(*g, cielab->display.d_Vrwg);
|
||||
*b = TIFFmin(*b, cielab->display.d_Vrwb);
|
||||
/* Clip output. */
|
||||
*r = TIFFmin(*r, cielab->display.d_Vrwr);
|
||||
*g = TIFFmin(*g, cielab->display.d_Vrwg);
|
||||
*b = TIFFmin(*b, cielab->display.d_Vrwb);
|
||||
}
|
||||
#undef RINT
|
||||
|
||||
/*
|
||||
/*
|
||||
* Allocate conversion state structures and make look_up tables for
|
||||
* the Yr,Yb,Yg <=> r,g,b conversions.
|
||||
*/
|
||||
int
|
||||
TIFFCIELabToRGBInit(TIFFCIELabToRGB* cielab,
|
||||
const TIFFDisplay *display, float *refWhite)
|
||||
const TIFFDisplay *display, float *refWhite)
|
||||
{
|
||||
int i;
|
||||
double gamma;
|
||||
int i;
|
||||
double dfGamma;
|
||||
|
||||
cielab->range = CIELABTORGB_TABLE_RANGE;
|
||||
cielab->range = CIELABTORGB_TABLE_RANGE;
|
||||
|
||||
_TIFFmemcpy(&cielab->display, display, sizeof(TIFFDisplay));
|
||||
_TIFFmemcpy(&cielab->display, display, sizeof(TIFFDisplay));
|
||||
|
||||
/* Red */
|
||||
gamma = 1.0 / cielab->display.d_gammaR ;
|
||||
cielab->rstep =
|
||||
(cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
|
||||
for(i = 0; i <= cielab->range; i++) {
|
||||
cielab->Yr2r[i] = cielab->display.d_Vrwr
|
||||
* ((float)pow((double)i / cielab->range, gamma));
|
||||
}
|
||||
/* Red */
|
||||
dfGamma = 1.0 / cielab->display.d_gammaR ;
|
||||
cielab->rstep =
|
||||
(cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
|
||||
for(i = 0; i <= cielab->range; i++) {
|
||||
cielab->Yr2r[i] = cielab->display.d_Vrwr
|
||||
* ((float)pow((double)i / cielab->range, dfGamma));
|
||||
}
|
||||
|
||||
/* Green */
|
||||
gamma = 1.0 / cielab->display.d_gammaG ;
|
||||
cielab->gstep =
|
||||
(cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
|
||||
for(i = 0; i <= cielab->range; i++) {
|
||||
cielab->Yg2g[i] = cielab->display.d_Vrwg
|
||||
* ((float)pow((double)i / cielab->range, gamma));
|
||||
}
|
||||
/* Green */
|
||||
dfGamma = 1.0 / cielab->display.d_gammaG ;
|
||||
cielab->gstep =
|
||||
(cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
|
||||
for(i = 0; i <= cielab->range; i++) {
|
||||
cielab->Yg2g[i] = cielab->display.d_Vrwg
|
||||
* ((float)pow((double)i / cielab->range, dfGamma));
|
||||
}
|
||||
|
||||
/* Blue */
|
||||
gamma = 1.0 / cielab->display.d_gammaB ;
|
||||
cielab->bstep =
|
||||
(cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
|
||||
for(i = 0; i <= cielab->range; i++) {
|
||||
cielab->Yb2b[i] = cielab->display.d_Vrwb
|
||||
* ((float)pow((double)i / cielab->range, gamma));
|
||||
}
|
||||
/* Blue */
|
||||
dfGamma = 1.0 / cielab->display.d_gammaB ;
|
||||
cielab->bstep =
|
||||
(cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range;
|
||||
for(i = 0; i <= cielab->range; i++) {
|
||||
cielab->Yb2b[i] = cielab->display.d_Vrwb
|
||||
* ((float)pow((double)i / cielab->range, dfGamma));
|
||||
}
|
||||
|
||||
/* Init reference white point */
|
||||
cielab->X0 = refWhite[0];
|
||||
cielab->Y0 = refWhite[1];
|
||||
cielab->Z0 = refWhite[2];
|
||||
/* Init reference white point */
|
||||
cielab->X0 = refWhite[0];
|
||||
cielab->Y0 = refWhite[1];
|
||||
cielab->Z0 = refWhite[2];
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Convert color value from the YCbCr space to CIE XYZ.
|
||||
* The colorspace conversion algorithm comes from the IJG v5a code;
|
||||
* see below for more information on how it works.
|
||||
@@ -175,26 +175,45 @@ TIFFCIELabToRGBInit(TIFFCIELabToRGB* cielab,
|
||||
#define SHIFT 16
|
||||
#define FIX(x) ((int32)((x) * (1L<<SHIFT) + 0.5))
|
||||
#define ONE_HALF ((int32)(1<<(SHIFT-1)))
|
||||
#define Code2V(c, RB, RW, CR) ((((c)-(int32)(RB))*(float)(CR))/(float)(((RW)-(RB)) ? ((RW)-(RB)) : 1))
|
||||
#define Code2V(c, RB, RW, CR) ((((c)-(int32)(RB))*(float)(CR))/(float)(((RW)-(RB)!=0) ? ((RW)-(RB)) : 1))
|
||||
#define CLAMP(f,min,max) ((f)<(min)?(min):(f)>(max)?(max):(f))
|
||||
#define HICLAMP(f,max) ((f)>(max)?(max):(f))
|
||||
|
||||
void
|
||||
TIFFYCbCrtoRGB(TIFFYCbCrToRGB *ycbcr, uint32 Y, int32 Cb, int32 Cr,
|
||||
uint32 *r, uint32 *g, uint32 *b)
|
||||
uint32 *r, uint32 *g, uint32 *b)
|
||||
{
|
||||
int32 i;
|
||||
int32 i;
|
||||
|
||||
/* XXX: Only 8-bit YCbCr input supported for now */
|
||||
Y = HICLAMP(Y, 255), Cb = CLAMP(Cb, 0, 255), Cr = CLAMP(Cr, 0, 255);
|
||||
/* XXX: Only 8-bit YCbCr input supported for now */
|
||||
Y = HICLAMP(Y, 255);
|
||||
Cb = CLAMP(Cb, 0, 255);
|
||||
Cr = CLAMP(Cr, 0, 255);
|
||||
|
||||
i = ycbcr->Y_tab[Y] + ycbcr->Cr_r_tab[Cr];
|
||||
*r = CLAMP(i, 0, 255);
|
||||
i = ycbcr->Y_tab[Y]
|
||||
+ (int)((ycbcr->Cb_g_tab[Cb] + ycbcr->Cr_g_tab[Cr]) >> SHIFT);
|
||||
*g = CLAMP(i, 0, 255);
|
||||
i = ycbcr->Y_tab[Y] + ycbcr->Cb_b_tab[Cb];
|
||||
*b = CLAMP(i, 0, 255);
|
||||
i = ycbcr->Y_tab[Y] + ycbcr->Cr_r_tab[Cr];
|
||||
*r = CLAMP(i, 0, 255);
|
||||
i = ycbcr->Y_tab[Y]
|
||||
+ (int)((ycbcr->Cb_g_tab[Cb] + ycbcr->Cr_g_tab[Cr]) >> SHIFT);
|
||||
*g = CLAMP(i, 0, 255);
|
||||
i = ycbcr->Y_tab[Y] + ycbcr->Cb_b_tab[Cb];
|
||||
*b = CLAMP(i, 0, 255);
|
||||
}
|
||||
|
||||
/* Clamp function for sanitization purposes. Normally clamping should not */
|
||||
/* occur for well behaved chroma and refBlackWhite coefficients */
|
||||
static float CLAMPw(float v, float vmin, float vmax)
|
||||
{
|
||||
if( v < vmin )
|
||||
{
|
||||
/* printf("%f clamped to %f\n", v, vmin); */
|
||||
return vmin;
|
||||
}
|
||||
if( v > vmax )
|
||||
{
|
||||
/* printf("%f clamped to %f\n", v, vmax); */
|
||||
return vmax;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -218,17 +237,17 @@ TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, float *luma, float *refBlackWhite)
|
||||
{
|
||||
TIFFRGBValue* clamptab;
|
||||
int i;
|
||||
|
||||
|
||||
#define LumaRed luma[0]
|
||||
#define LumaGreen luma[1]
|
||||
#define LumaBlue luma[2]
|
||||
|
||||
clamptab = (TIFFRGBValue*)(
|
||||
(uint8*) ycbcr+TIFFroundup_32(sizeof (TIFFYCbCrToRGB), sizeof (long)));
|
||||
(uint8*) ycbcr+TIFFroundup_32(sizeof (TIFFYCbCrToRGB), sizeof (long)));
|
||||
_TIFFmemset(clamptab, 0, 256); /* v < 0 => 0 */
|
||||
ycbcr->clamptab = (clamptab += 256);
|
||||
for (i = 0; i < 256; i++)
|
||||
clamptab[i] = (TIFFRGBValue) i;
|
||||
clamptab[i] = (TIFFRGBValue) i;
|
||||
_TIFFmemset(clamptab+256, 255, 2*256); /* v > 255 => 255 */
|
||||
ycbcr->Cr_r_tab = (int*) (clamptab + 3*256);
|
||||
ycbcr->Cb_b_tab = ycbcr->Cr_r_tab + 256;
|
||||
@@ -236,16 +255,16 @@ TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, float *luma, float *refBlackWhite)
|
||||
ycbcr->Cb_g_tab = ycbcr->Cr_g_tab + 256;
|
||||
ycbcr->Y_tab = ycbcr->Cb_g_tab + 256;
|
||||
|
||||
{ float f1 = 2-2*LumaRed; int32 D1 = FIX(f1);
|
||||
float f2 = LumaRed*f1/LumaGreen; int32 D2 = -FIX(f2);
|
||||
float f3 = 2-2*LumaBlue; int32 D3 = FIX(f3);
|
||||
float f4 = LumaBlue*f3/LumaGreen; int32 D4 = -FIX(f4);
|
||||
{ float f1 = 2-2*LumaRed; int32 D1 = FIX(CLAMP(f1,0.0F,2.0F));
|
||||
float f2 = LumaRed*f1/LumaGreen; int32 D2 = -FIX(CLAMP(f2,0.0F,2.0F));
|
||||
float f3 = 2-2*LumaBlue; int32 D3 = FIX(CLAMP(f3,0.0F,2.0F));
|
||||
float f4 = LumaBlue*f3/LumaGreen; int32 D4 = -FIX(CLAMP(f4,0.0F,2.0F));
|
||||
int x;
|
||||
|
||||
#undef LumaBlue
|
||||
#undef LumaGreen
|
||||
#undef LumaRed
|
||||
|
||||
|
||||
/*
|
||||
* i is the actual input pixel value in the range 0..255
|
||||
* Cb and Cr values are in the range -128..127 (actually
|
||||
@@ -254,17 +273,20 @@ TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, float *luma, float *refBlackWhite)
|
||||
* constructing tables indexed by the raw pixel data.
|
||||
*/
|
||||
for (i = 0, x = -128; i < 256; i++, x++) {
|
||||
int32 Cr = (int32)Code2V(x, refBlackWhite[4] - 128.0F,
|
||||
refBlackWhite[5] - 128.0F, 127);
|
||||
int32 Cb = (int32)Code2V(x, refBlackWhite[2] - 128.0F,
|
||||
refBlackWhite[3] - 128.0F, 127);
|
||||
int32 Cr = (int32)CLAMPw(Code2V(x, refBlackWhite[4] - 128.0F,
|
||||
refBlackWhite[5] - 128.0F, 127),
|
||||
-128.0F * 32, 128.0F * 32);
|
||||
int32 Cb = (int32)CLAMPw(Code2V(x, refBlackWhite[2] - 128.0F,
|
||||
refBlackWhite[3] - 128.0F, 127),
|
||||
-128.0F * 32, 128.0F * 32);
|
||||
|
||||
ycbcr->Cr_r_tab[i] = (int32)((D1*Cr + ONE_HALF)>>SHIFT);
|
||||
ycbcr->Cb_b_tab[i] = (int32)((D3*Cb + ONE_HALF)>>SHIFT);
|
||||
ycbcr->Cr_g_tab[i] = D2*Cr;
|
||||
ycbcr->Cb_g_tab[i] = D4*Cb + ONE_HALF;
|
||||
ycbcr->Y_tab[i] =
|
||||
(int32)Code2V(x + 128, refBlackWhite[0], refBlackWhite[1], 255);
|
||||
ycbcr->Cr_r_tab[i] = (int32)((D1*Cr + ONE_HALF)>>SHIFT);
|
||||
ycbcr->Cb_b_tab[i] = (int32)((D3*Cb + ONE_HALF)>>SHIFT);
|
||||
ycbcr->Cr_g_tab[i] = D2*Cr;
|
||||
ycbcr->Cb_g_tab[i] = D4*Cb + ONE_HALF;
|
||||
ycbcr->Y_tab[i] =
|
||||
(int32)CLAMPw(Code2V(x + 128, refBlackWhite[0], refBlackWhite[1], 255),
|
||||
-128.0F * 32, 128.0F * 32);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+156
-156
@@ -1,26 +1,26 @@
|
||||
/* $Id: tif_compress.c,v 1.22 2010-03-10 18:56:48 bfriesen Exp $ */
|
||||
/* $Id: tif_compress.c,v 1.25 2016-10-25 20:04:22 erouault Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
@@ -34,99 +34,99 @@
|
||||
static int
|
||||
TIFFNoEncode(TIFF* tif, const char* method)
|
||||
{
|
||||
const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression);
|
||||
const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression);
|
||||
|
||||
if (c) {
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||
"%s %s encoding is not implemented",
|
||||
c->name, method);
|
||||
} else {
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||
"Compression scheme %u %s encoding is not implemented",
|
||||
tif->tif_dir.td_compression, method);
|
||||
}
|
||||
return (-1);
|
||||
if (c) {
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||
"%s %s encoding is not implemented",
|
||||
c->name, method);
|
||||
} else {
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||
"Compression scheme %u %s encoding is not implemented",
|
||||
tif->tif_dir.td_compression, method);
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
||||
int
|
||||
_TIFFNoRowEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s)
|
||||
{
|
||||
(void) pp; (void) cc; (void) s;
|
||||
return (TIFFNoEncode(tif, "scanline"));
|
||||
(void) pp; (void) cc; (void) s;
|
||||
return (TIFFNoEncode(tif, "scanline"));
|
||||
}
|
||||
|
||||
int
|
||||
_TIFFNoStripEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s)
|
||||
{
|
||||
(void) pp; (void) cc; (void) s;
|
||||
return (TIFFNoEncode(tif, "strip"));
|
||||
(void) pp; (void) cc; (void) s;
|
||||
return (TIFFNoEncode(tif, "strip"));
|
||||
}
|
||||
|
||||
int
|
||||
_TIFFNoTileEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s)
|
||||
{
|
||||
(void) pp; (void) cc; (void) s;
|
||||
return (TIFFNoEncode(tif, "tile"));
|
||||
(void) pp; (void) cc; (void) s;
|
||||
return (TIFFNoEncode(tif, "tile"));
|
||||
}
|
||||
|
||||
static int
|
||||
TIFFNoDecode(TIFF* tif, const char* method)
|
||||
{
|
||||
const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression);
|
||||
const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression);
|
||||
|
||||
if (c)
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||
"%s %s decoding is not implemented",
|
||||
c->name, method);
|
||||
else
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||
"Compression scheme %u %s decoding is not implemented",
|
||||
tif->tif_dir.td_compression, method);
|
||||
return (-1);
|
||||
if (c)
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||
"%s %s decoding is not implemented",
|
||||
c->name, method);
|
||||
else
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||
"Compression scheme %u %s decoding is not implemented",
|
||||
tif->tif_dir.td_compression, method);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
_TIFFNoFixupTags(TIFF* tif)
|
||||
{
|
||||
(void) tif;
|
||||
return (1);
|
||||
(void) tif;
|
||||
return (1);
|
||||
}
|
||||
|
||||
int
|
||||
_TIFFNoRowDecode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s)
|
||||
{
|
||||
(void) pp; (void) cc; (void) s;
|
||||
return (TIFFNoDecode(tif, "scanline"));
|
||||
(void) pp; (void) cc; (void) s;
|
||||
return (TIFFNoDecode(tif, "scanline"));
|
||||
}
|
||||
|
||||
int
|
||||
_TIFFNoStripDecode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s)
|
||||
{
|
||||
(void) pp; (void) cc; (void) s;
|
||||
return (TIFFNoDecode(tif, "strip"));
|
||||
(void) pp; (void) cc; (void) s;
|
||||
return (TIFFNoDecode(tif, "strip"));
|
||||
}
|
||||
|
||||
int
|
||||
_TIFFNoTileDecode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s)
|
||||
{
|
||||
(void) pp; (void) cc; (void) s;
|
||||
return (TIFFNoDecode(tif, "tile"));
|
||||
(void) pp; (void) cc; (void) s;
|
||||
return (TIFFNoDecode(tif, "tile"));
|
||||
}
|
||||
|
||||
int
|
||||
_TIFFNoSeek(TIFF* tif, uint32 off)
|
||||
{
|
||||
(void) off;
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||
"Compression algorithm does not support random access");
|
||||
return (0);
|
||||
(void) off;
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||
"Compression algorithm does not support random access");
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
_TIFFNoPreCode(TIFF* tif, uint16 s)
|
||||
{
|
||||
(void) tif; (void) s;
|
||||
return (1);
|
||||
(void) tif; (void) s;
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int _TIFFtrue(TIFF* tif) { (void) tif; return (1); }
|
||||
@@ -135,41 +135,41 @@ static void _TIFFvoid(TIFF* tif) { (void) tif; }
|
||||
void
|
||||
_TIFFSetDefaultCompressionState(TIFF* tif)
|
||||
{
|
||||
tif->tif_fixuptags = _TIFFNoFixupTags;
|
||||
tif->tif_decodestatus = TRUE;
|
||||
tif->tif_setupdecode = _TIFFtrue;
|
||||
tif->tif_predecode = _TIFFNoPreCode;
|
||||
tif->tif_decoderow = _TIFFNoRowDecode;
|
||||
tif->tif_decodestrip = _TIFFNoStripDecode;
|
||||
tif->tif_decodetile = _TIFFNoTileDecode;
|
||||
tif->tif_encodestatus = TRUE;
|
||||
tif->tif_setupencode = _TIFFtrue;
|
||||
tif->tif_preencode = _TIFFNoPreCode;
|
||||
tif->tif_postencode = _TIFFtrue;
|
||||
tif->tif_encoderow = _TIFFNoRowEncode;
|
||||
tif->tif_encodestrip = _TIFFNoStripEncode;
|
||||
tif->tif_encodetile = _TIFFNoTileEncode;
|
||||
tif->tif_close = _TIFFvoid;
|
||||
tif->tif_seek = _TIFFNoSeek;
|
||||
tif->tif_cleanup = _TIFFvoid;
|
||||
tif->tif_defstripsize = _TIFFDefaultStripSize;
|
||||
tif->tif_deftilesize = _TIFFDefaultTileSize;
|
||||
tif->tif_flags &= ~(TIFF_NOBITREV|TIFF_NOREADRAW);
|
||||
tif->tif_fixuptags = _TIFFNoFixupTags;
|
||||
tif->tif_decodestatus = TRUE;
|
||||
tif->tif_setupdecode = _TIFFtrue;
|
||||
tif->tif_predecode = _TIFFNoPreCode;
|
||||
tif->tif_decoderow = _TIFFNoRowDecode;
|
||||
tif->tif_decodestrip = _TIFFNoStripDecode;
|
||||
tif->tif_decodetile = _TIFFNoTileDecode;
|
||||
tif->tif_encodestatus = TRUE;
|
||||
tif->tif_setupencode = _TIFFtrue;
|
||||
tif->tif_preencode = _TIFFNoPreCode;
|
||||
tif->tif_postencode = _TIFFtrue;
|
||||
tif->tif_encoderow = _TIFFNoRowEncode;
|
||||
tif->tif_encodestrip = _TIFFNoStripEncode;
|
||||
tif->tif_encodetile = _TIFFNoTileEncode;
|
||||
tif->tif_close = _TIFFvoid;
|
||||
tif->tif_seek = _TIFFNoSeek;
|
||||
tif->tif_cleanup = _TIFFvoid;
|
||||
tif->tif_defstripsize = _TIFFDefaultStripSize;
|
||||
tif->tif_deftilesize = _TIFFDefaultTileSize;
|
||||
tif->tif_flags &= ~(TIFF_NOBITREV|TIFF_NOREADRAW);
|
||||
}
|
||||
|
||||
int
|
||||
TIFFSetCompressionScheme(TIFF* tif, int scheme)
|
||||
{
|
||||
const TIFFCodec *c = TIFFFindCODEC((uint16) scheme);
|
||||
const TIFFCodec *c = TIFFFindCODEC((uint16) scheme);
|
||||
|
||||
_TIFFSetDefaultCompressionState(tif);
|
||||
/*
|
||||
* Don't treat an unknown compression scheme as an error.
|
||||
* This permits applications to open files with data that
|
||||
* the library does not have builtin support for, but which
|
||||
* may still be meaningful.
|
||||
*/
|
||||
return (c ? (*c->init)(tif, scheme) : 1);
|
||||
_TIFFSetDefaultCompressionState(tif);
|
||||
/*
|
||||
* Don't treat an unknown compression scheme as an error.
|
||||
* This permits applications to open files with data that
|
||||
* the library does not have builtin support for, but which
|
||||
* may still be meaningful.
|
||||
*/
|
||||
return (c ? (*c->init)(tif, scheme) : 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -178,63 +178,63 @@ TIFFSetCompressionScheme(TIFF* tif, int scheme)
|
||||
* by this library.
|
||||
*/
|
||||
typedef struct _codec {
|
||||
struct _codec* next;
|
||||
TIFFCodec* info;
|
||||
struct _codec* next;
|
||||
TIFFCodec* info;
|
||||
} codec_t;
|
||||
static codec_t* registeredCODECS = NULL;
|
||||
|
||||
const TIFFCodec*
|
||||
TIFFFindCODEC(uint16 scheme)
|
||||
{
|
||||
const TIFFCodec* c;
|
||||
codec_t* cd;
|
||||
const TIFFCodec* c;
|
||||
codec_t* cd;
|
||||
|
||||
for (cd = registeredCODECS; cd; cd = cd->next)
|
||||
if (cd->info->scheme == scheme)
|
||||
return ((const TIFFCodec*) cd->info);
|
||||
for (c = _TIFFBuiltinCODECS; c->name; c++)
|
||||
if (c->scheme == scheme)
|
||||
return (c);
|
||||
return ((const TIFFCodec*) 0);
|
||||
for (cd = registeredCODECS; cd; cd = cd->next)
|
||||
if (cd->info->scheme == scheme)
|
||||
return ((const TIFFCodec*) cd->info);
|
||||
for (c = _TIFFBuiltinCODECS; c->name; c++)
|
||||
if (c->scheme == scheme)
|
||||
return (c);
|
||||
return ((const TIFFCodec*) 0);
|
||||
}
|
||||
|
||||
TIFFCodec*
|
||||
TIFFRegisterCODEC(uint16 scheme, const char* name, TIFFInitMethod init)
|
||||
{
|
||||
codec_t* cd = (codec_t*)
|
||||
_TIFFmalloc((tmsize_t)(sizeof (codec_t) + sizeof (TIFFCodec) + strlen(name)+1));
|
||||
codec_t* cd = (codec_t*)
|
||||
_TIFFmalloc((tmsize_t)(sizeof (codec_t) + sizeof (TIFFCodec) + strlen(name)+1));
|
||||
|
||||
if (cd != NULL) {
|
||||
cd->info = (TIFFCodec*) ((uint8*) cd + sizeof (codec_t));
|
||||
cd->info->name = (char*)
|
||||
((uint8*) cd->info + sizeof (TIFFCodec));
|
||||
strcpy(cd->info->name, name);
|
||||
cd->info->scheme = scheme;
|
||||
cd->info->init = init;
|
||||
cd->next = registeredCODECS;
|
||||
registeredCODECS = cd;
|
||||
} else {
|
||||
TIFFErrorExt(0, "TIFFRegisterCODEC",
|
||||
"No space to register compression scheme %s", name);
|
||||
return NULL;
|
||||
}
|
||||
return (cd->info);
|
||||
if (cd != NULL) {
|
||||
cd->info = (TIFFCodec*) ((uint8*) cd + sizeof (codec_t));
|
||||
cd->info->name = (char*)
|
||||
((uint8*) cd->info + sizeof (TIFFCodec));
|
||||
strcpy(cd->info->name, name);
|
||||
cd->info->scheme = scheme;
|
||||
cd->info->init = init;
|
||||
cd->next = registeredCODECS;
|
||||
registeredCODECS = cd;
|
||||
} else {
|
||||
TIFFErrorExt(0, "TIFFRegisterCODEC",
|
||||
"No space to register compression scheme %s", name);
|
||||
return NULL;
|
||||
}
|
||||
return (cd->info);
|
||||
}
|
||||
|
||||
void
|
||||
TIFFUnRegisterCODEC(TIFFCodec* c)
|
||||
{
|
||||
codec_t* cd;
|
||||
codec_t** pcd;
|
||||
codec_t* cd;
|
||||
codec_t** pcd;
|
||||
|
||||
for (pcd = ®isteredCODECS; (cd = *pcd); pcd = &cd->next)
|
||||
if (cd->info == c) {
|
||||
*pcd = cd->next;
|
||||
_TIFFfree(cd);
|
||||
return;
|
||||
}
|
||||
TIFFErrorExt(0, "TIFFUnRegisterCODEC",
|
||||
"Cannot remove compression scheme %s; not registered", c->name);
|
||||
for (pcd = ®isteredCODECS; (cd = *pcd) != NULL; pcd = &cd->next)
|
||||
if (cd->info == c) {
|
||||
*pcd = cd->next;
|
||||
_TIFFfree(cd);
|
||||
return;
|
||||
}
|
||||
TIFFErrorExt(0, "TIFFUnRegisterCODEC",
|
||||
"Cannot remove compression scheme %s; not registered", c->name);
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
@@ -244,7 +244,7 @@ TIFFUnRegisterCODEC(TIFFCodec* c)
|
||||
/**
|
||||
* Get list of configured codecs, both built-in and registered by user.
|
||||
* Caller is responsible to free this structure.
|
||||
*
|
||||
*
|
||||
* @return returns array of TIFFCodec records (the last record should be NULL)
|
||||
* or NULL if function failed.
|
||||
*/
|
||||
@@ -252,46 +252,46 @@ TIFFUnRegisterCODEC(TIFFCodec* c)
|
||||
TIFFCodec*
|
||||
TIFFGetConfiguredCODECs()
|
||||
{
|
||||
int i = 1;
|
||||
codec_t *cd;
|
||||
const TIFFCodec* c;
|
||||
TIFFCodec* codecs = NULL;
|
||||
TIFFCodec* new_codecs;
|
||||
int i = 1;
|
||||
codec_t *cd;
|
||||
const TIFFCodec* c;
|
||||
TIFFCodec* codecs = NULL;
|
||||
TIFFCodec* new_codecs;
|
||||
|
||||
for (cd = registeredCODECS; cd; cd = cd->next) {
|
||||
new_codecs = (TIFFCodec *)
|
||||
_TIFFrealloc(codecs, i * sizeof(TIFFCodec));
|
||||
if (!new_codecs) {
|
||||
_TIFFfree (codecs);
|
||||
return NULL;
|
||||
}
|
||||
codecs = new_codecs;
|
||||
_TIFFmemcpy(codecs + i - 1, cd, sizeof(TIFFCodec));
|
||||
i++;
|
||||
}
|
||||
for (c = _TIFFBuiltinCODECS; c->name; c++) {
|
||||
if (TIFFIsCODECConfigured(c->scheme)) {
|
||||
new_codecs = (TIFFCodec *)
|
||||
_TIFFrealloc(codecs, i * sizeof(TIFFCodec));
|
||||
if (!new_codecs) {
|
||||
_TIFFfree (codecs);
|
||||
return NULL;
|
||||
}
|
||||
codecs = new_codecs;
|
||||
_TIFFmemcpy(codecs + i - 1, (const void*)c, sizeof(TIFFCodec));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
for (cd = registeredCODECS; cd; cd = cd->next) {
|
||||
new_codecs = (TIFFCodec *)
|
||||
_TIFFrealloc(codecs, i * sizeof(TIFFCodec));
|
||||
if (!new_codecs) {
|
||||
_TIFFfree (codecs);
|
||||
return NULL;
|
||||
}
|
||||
codecs = new_codecs;
|
||||
_TIFFmemcpy(codecs + i - 1, cd, sizeof(TIFFCodec));
|
||||
i++;
|
||||
}
|
||||
for (c = _TIFFBuiltinCODECS; c->name; c++) {
|
||||
if (TIFFIsCODECConfigured(c->scheme)) {
|
||||
new_codecs = (TIFFCodec *)
|
||||
_TIFFrealloc(codecs, i * sizeof(TIFFCodec));
|
||||
if (!new_codecs) {
|
||||
_TIFFfree (codecs);
|
||||
return NULL;
|
||||
}
|
||||
codecs = new_codecs;
|
||||
_TIFFmemcpy(codecs + i - 1, (const void*)c, sizeof(TIFFCodec));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
new_codecs = (TIFFCodec *) _TIFFrealloc(codecs, i * sizeof(TIFFCodec));
|
||||
if (!new_codecs) {
|
||||
_TIFFfree (codecs);
|
||||
return NULL;
|
||||
}
|
||||
codecs = new_codecs;
|
||||
_TIFFmemset(codecs + i - 1, 0, sizeof(TIFFCodec));
|
||||
new_codecs = (TIFFCodec *) _TIFFrealloc(codecs, i * sizeof(TIFFCodec));
|
||||
if (!new_codecs) {
|
||||
_TIFFfree (codecs);
|
||||
return NULL;
|
||||
}
|
||||
codecs = new_codecs;
|
||||
_TIFFmemset(codecs + i - 1, 0, sizeof(TIFFCodec));
|
||||
|
||||
return codecs;
|
||||
return codecs;
|
||||
}
|
||||
|
||||
/* vim: set ts=8 sts=8 sw=8 noet: */
|
||||
|
||||
+261
@@ -0,0 +1,261 @@
|
||||
/* 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 1
|
||||
|
||||
/* Pick up YCbCr subsampling info from the JPEG data stream to support files
|
||||
lacking the tag (default enabled). */
|
||||
#cmakedefine CHECK_JPEG_YCBCR_SUBSAMPLING 1
|
||||
|
||||
/* enable partial strip reading for large strips (experimental) */
|
||||
#cmakedefine CHUNKY_STRIP_READ_SUPPORT 1
|
||||
|
||||
/* Support C++ stream API (requires C++ compiler) */
|
||||
#cmakedefine CXX_SUPPORT 1
|
||||
|
||||
/* enable deferred strip/tile offset/size loading (experimental) */
|
||||
#cmakedefine DEFER_STRILE_LOAD 1
|
||||
|
||||
/* Define to 1 if you have the <assert.h> header file. */
|
||||
#cmakedefine HAVE_ASSERT_H 1
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#cmakedefine HAVE_DLFCN_H 1
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#cmakedefine HAVE_FCNTL_H 1
|
||||
|
||||
/* Define to 1 if you have the `floor' function. */
|
||||
#cmakedefine HAVE_FLOOR 1
|
||||
|
||||
/* Define to 1 if you have the `getopt' function. */
|
||||
#cmakedefine HAVE_GETOPT 1
|
||||
|
||||
/* Define to 1 if you have the <GLUT/glut.h> header file. */
|
||||
#cmakedefine HAVE_GLUT_GLUT_H 1
|
||||
|
||||
/* Define to 1 if you have the <GL/glut.h> header file. */
|
||||
#cmakedefine HAVE_GL_GLUT_H 1
|
||||
|
||||
/* Define to 1 if you have the <GL/glu.h> header file. */
|
||||
#cmakedefine HAVE_GL_GLU_H 1
|
||||
|
||||
/* Define to 1 if you have the <GL/gl.h> header file. */
|
||||
#cmakedefine HAVE_GL_GL_H 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#cmakedefine HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <io.h> header file. */
|
||||
#cmakedefine HAVE_IO_H 1
|
||||
|
||||
/* Define to 1 if you have the `isascii' function. */
|
||||
#cmakedefine HAVE_ISASCII 1
|
||||
|
||||
/* Define to 1 if you have the `jbg_newlen' function. */
|
||||
#cmakedefine HAVE_JBG_NEWLEN 1
|
||||
|
||||
/* Define to 1 if you have the `lfind' function. */
|
||||
#cmakedefine HAVE_LFIND 1
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#cmakedefine HAVE_LIMITS_H 1
|
||||
|
||||
/* Define to 1 if you have the <malloc.h> header file. */
|
||||
#cmakedefine HAVE_MALLOC_H 1
|
||||
|
||||
/* Define to 1 if you have the `memmove' function. */
|
||||
#cmakedefine HAVE_MEMMOVE 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#cmakedefine HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the `memset' function. */
|
||||
#cmakedefine HAVE_MEMSET 1
|
||||
|
||||
/* Define to 1 if you have the `mmap' function. */
|
||||
#cmakedefine HAVE_MMAP 1
|
||||
|
||||
/* Define to 1 if you have the <OpenGL/glu.h> header file. */
|
||||
#cmakedefine HAVE_OPENGL_GLU_H 1
|
||||
|
||||
/* Define to 1 if you have the <OpenGL/gl.h> header file. */
|
||||
#cmakedefine HAVE_OPENGL_GL_H 1
|
||||
|
||||
/* Define to 1 if you have the `pow' function. */
|
||||
#cmakedefine HAVE_POW 1
|
||||
|
||||
/* Define to 1 if you have the <search.h> header file. */
|
||||
#cmakedefine HAVE_SEARCH_H 1
|
||||
|
||||
/* Define to 1 if you have the `setmode' function. */
|
||||
#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 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#cmakedefine HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the `strcasecmp' function. */
|
||||
#cmakedefine HAVE_STRCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the `strchr' function. */
|
||||
#cmakedefine HAVE_STRCHR 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#cmakedefine HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#cmakedefine HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the `strrchr' function. */
|
||||
#cmakedefine HAVE_STRRCHR 1
|
||||
|
||||
/* Define to 1 if you have the `strstr' function. */
|
||||
#cmakedefine HAVE_STRSTR 1
|
||||
|
||||
/* Define to 1 if you have the `strtol' function. */
|
||||
#cmakedefine HAVE_STRTOL 1
|
||||
|
||||
/* Define to 1 if you have the `strtoul' function. */
|
||||
#cmakedefine HAVE_STRTOUL 1
|
||||
|
||||
/* Define to 1 if you have the `strtoull' function. */
|
||||
#cmakedefine HAVE_STRTOULL 1
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#cmakedefine HAVE_SYS_TIME_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#cmakedefine HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#cmakedefine HAVE_UNISTD_H 1
|
||||
|
||||
/* 8/12 bit libjpeg dual mode enabled */
|
||||
#cmakedefine JPEG_DUAL_MODE_8_12 1
|
||||
|
||||
/* 12bit libjpeg primary include file with path */
|
||||
#define LIBJPEG_12_PATH @LIBJPEG_12_PATH@
|
||||
|
||||
/* Support LZMA2 compression */
|
||||
#cmakedefine LZMA_SUPPORT 1
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "@PACKAGE_NAME@"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "@PACKAGE_NAME@"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "@PACKAGE_STRING@"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "@PACKAGE_TARNAME@"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL "@PACKAGE_URL@"
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "@PACKAGE_VERSION@"
|
||||
|
||||
/* The size of `signed int', as computed by sizeof. */
|
||||
#define SIZEOF_SIGNED_INT @SIZEOF_SIGNED_INT@
|
||||
|
||||
/* The size of `signed long', as computed by sizeof. */
|
||||
#define SIZEOF_SIGNED_LONG @SIZEOF_SIGNED_LONG@
|
||||
|
||||
/* The size of `signed long long', as computed by sizeof. */
|
||||
#define SIZEOF_SIGNED_LONG_LONG @SIZEOF_SIGNED_LONG_LONG@
|
||||
|
||||
/* The size of `signed short', as computed by sizeof. */
|
||||
#define SIZEOF_SIGNED_SHORT @SIZEOF_SIGNED_SHORT@
|
||||
|
||||
/* The size of `unsigned char *', as computed by sizeof. */
|
||||
#define SIZEOF_UNSIGNED_CHAR_P @SIZEOF_UNSIGNED_CHAR_P@
|
||||
|
||||
/* The size of `unsigned int', as computed by sizeof. */
|
||||
#define SIZEOF_UNSIGNED_INT @SIZEOF_UNSIGNED_INT@
|
||||
|
||||
/* The size of `unsigned long', as computed by sizeof. */
|
||||
#define SIZEOF_UNSIGNED_LONG @SIZEOF_UNSIGNED_LONG@
|
||||
|
||||
/* The size of `unsigned long long', as computed by sizeof. */
|
||||
#define SIZEOF_UNSIGNED_LONG_LONG @SIZEOF_UNSIGNED_LONG_LONG@
|
||||
|
||||
/* The size of `unsigned short', as computed by sizeof. */
|
||||
#define SIZEOF_UNSIGNED_SHORT @SIZEOF_UNSIGNED_SHORT@
|
||||
|
||||
/* Default size of the strip in bytes (when strip chopping enabled) */
|
||||
#define STRIP_SIZE_DEFAULT @STRIP_SIZE_DEFAULT@
|
||||
|
||||
/* Signed 32-bit type formatter */
|
||||
#define TIFF_INT32_FORMAT "@TIFF_INT32_FORMAT@"
|
||||
|
||||
/* Signed 64-bit type formatter */
|
||||
#define TIFF_INT64_FORMAT "@TIFF_INT64_FORMAT@"
|
||||
|
||||
/* Pointer difference type formatter */
|
||||
#define TIFF_PTRDIFF_FORMAT "@TIFF_PTRDIFF_FORMAT@"
|
||||
|
||||
/* Unsigned size type formatter */
|
||||
#define TIFF_SIZE_FORMAT "@TIFF_SIZE_FORMAT@"
|
||||
|
||||
/* Signed size type formatter */
|
||||
#define TIFF_SSIZE_FORMAT "@TIFF_SSIZE_FORMAT@"
|
||||
|
||||
/* Unsigned 32-bit type formatter */
|
||||
#define TIFF_UINT32_FORMAT "@TIFF_UINT32_FORMAT@"
|
||||
|
||||
/* Unsigned 64-bit type formatter */
|
||||
#define TIFF_UINT64_FORMAT "@TIFF_UINT64_FORMAT@"
|
||||
|
||||
/* Unsigned 8-bit type */
|
||||
#define TIFF_UINT8_T @TIFF_UINT8_T@
|
||||
|
||||
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#undef TIME_WITH_SYS_TIME
|
||||
|
||||
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
|
||||
#cmakedefine TM_IN_SYS_TIME 1
|
||||
|
||||
/* define to use win32 IO system */
|
||||
#cmakedefine USE_WIN32_FILEIO 1
|
||||
|
||||
/* Version number of package */
|
||||
#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). */
|
||||
#if defined AC_APPLE_UNIVERSAL_BUILD
|
||||
# if defined __BIG_ENDIAN__
|
||||
# define WORDS_BIGENDIAN 1
|
||||
# endif
|
||||
#else
|
||||
# ifndef WORDS_BIGENDIAN
|
||||
# undef WORDS_BIGENDIAN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
#define _FILE_OFFSET_BITS @FILE_OFFSET_BITS@
|
||||
|
||||
/* 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_KEYWORD@
|
||||
#endif
|
||||
|
||||
/* Define to `long int' if <sys/types.h> does not define. */
|
||||
#undef off_t
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
#undef size_t
|
||||
-162
@@ -1,162 +0,0 @@
|
||||
/* libtiff/tif_config.h. Generated from tif_config.h.in by configure. */
|
||||
/* libtiff/tif_config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Support CCITT Group 3 & 4 algorithms */
|
||||
#define CCITT_SUPPORT 1
|
||||
|
||||
/* Pick up YCbCr subsampling info from the JPEG data stream to support files
|
||||
lacking the tag (default enabled). */
|
||||
#define CHECK_JPEG_YCBCR_SUBSAMPLING 1
|
||||
|
||||
/* enable partial strip reading for large strips (experimental) */
|
||||
#undef CHUNKY_STRIP_READ_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. */
|
||||
#define DEFAULT_EXTRASAMPLE_AS_ALPHA 1
|
||||
|
||||
/* enable deferred strip/tile offset/size loading (experimental) */
|
||||
#undef DEFER_STRILE_LOAD
|
||||
|
||||
/* Define to 1 if you have the <assert.h> header file. */
|
||||
#cmakedefine HAVE_ASSERT_H
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#cmakedefine HAVE_FCNTL_H
|
||||
|
||||
/* Define as 0 or 1 according to the floating point format suported by the
|
||||
machine */
|
||||
#define HAVE_IEEEFP 1
|
||||
|
||||
/* Define to 1 if you have the <io.h> header file. */
|
||||
#cmakedefine HAVE_IO_H
|
||||
|
||||
/* Define to 1 if you have the `jbg_newlen' function. */
|
||||
#cmakedefine HAVE_JBG_NEWLEN
|
||||
|
||||
/* Define to 1 if you have the `mmap' function. */
|
||||
#cmakedefine HAVE_MMAP
|
||||
|
||||
/* Define to 1 if you have the <search.h> header file. */
|
||||
#cmakedefine HAVE_SEARCH_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#cmakedefine HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#cmakedefine HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#ifndef HAVE_UNISTD_H
|
||||
#cmakedefine HAVE_UNISTD_H
|
||||
#endif
|
||||
|
||||
/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian
|
||||
(Intel) */
|
||||
#define HOST_BIGENDIAN @WORDS_BIGENDIAN@
|
||||
|
||||
/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */
|
||||
#define HOST_FILLORDER FILLORDER_LSB2MSB
|
||||
|
||||
/* Support ISO JBIG compression (requires JBIG-KIT library) */
|
||||
#undef JBIG_SUPPORT
|
||||
|
||||
/* 8/12 bit libjpeg dual mode enabled */
|
||||
/* #undef JPEG_DUAL_MODE_8_12 */
|
||||
|
||||
/* Support JPEG compression (requires IJG JPEG library) */
|
||||
#undef JPEG_SUPPORT
|
||||
|
||||
/* 12bit libjpeg primary include file with path */
|
||||
/* #undef LIBJPEG_12_PATH */
|
||||
|
||||
/* Support LogLuv high dynamic range encoding */
|
||||
#define LOGLUV_SUPPORT 1
|
||||
|
||||
/* Support LZMA2 compression */
|
||||
/* #undef LZMA_SUPPORT */
|
||||
|
||||
/* Support LZW algorithm */
|
||||
#define LZW_SUPPORT 1
|
||||
|
||||
/* Support Microsoft Document Imaging format */
|
||||
#define MDI_SUPPORT 1
|
||||
|
||||
/* Support NeXT 2-bit RLE algorithm */
|
||||
#define NEXT_SUPPORT 1
|
||||
|
||||
/* Support Old JPEG compresson (read-only) */
|
||||
#undef OJPEG_SUPPORT
|
||||
|
||||
/* Support Macintosh PackBits algorithm */
|
||||
#define PACKBITS_SUPPORT 1
|
||||
|
||||
/* Support Pixar log-format algorithm (requires Zlib) */
|
||||
#define PIXARLOG_SUPPORT 1
|
||||
|
||||
/* The size of `unsigned long', as computed by sizeof. */
|
||||
#define SIZEOF_UNSIGNED_LONG 8
|
||||
|
||||
/* Support strip chopping (whether or not to convert single-strip uncompressed
|
||||
images to mutiple strips of specified size to reduce memory usage) */
|
||||
#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP
|
||||
|
||||
/* Default size of the strip in bytes (when strip chopping enabled) */
|
||||
//#define STRIP_SIZE_DEFAULT 8192
|
||||
|
||||
/* Support ThunderScan 4-bit RLE algorithm */
|
||||
#define THUNDER_SUPPORT 1
|
||||
|
||||
/* Signed 8-bit type */
|
||||
#define TIFF_INT8_T signed char
|
||||
|
||||
/* Signed 16-bit type */
|
||||
#define TIFF_INT16_T signed short
|
||||
|
||||
/* Signed 32-bit type */
|
||||
#define TIFF_INT32_T signed int
|
||||
|
||||
/* Signed size type */
|
||||
#define TIFF_SSIZE_T size_t
|
||||
|
||||
/* Unsigned 8-bit type */
|
||||
#define TIFF_UINT8_T unsigned char
|
||||
|
||||
/* Unsigned 16-bit type */
|
||||
#define TIFF_UINT16_T unsigned short
|
||||
|
||||
/* Unsigned 32-bit type */
|
||||
#define TIFF_UINT32_T unsigned int
|
||||
|
||||
#ifdef _MSC_VER
|
||||
/* Signed 64-bit type */
|
||||
# define TIFF_INT64_T signed __int64
|
||||
/* Unsigned 64-bit type */
|
||||
# define TIFF_UINT64_T unsigned __int64
|
||||
#else
|
||||
/* Signed 64-bit type */
|
||||
# define TIFF_INT64_T long long
|
||||
/* Signed 64-bit type */
|
||||
# define TIFF_UINT64_T unsigned long long
|
||||
#endif
|
||||
|
||||
/* Signed 64-bit type formatter */
|
||||
/* Unsigned 64-bit type formatter */
|
||||
#if defined _MSC_VER || defined __MINGW__ || defined __MINGW32__
|
||||
# define TIFF_UINT64_FORMAT "%I64u"
|
||||
# define TIFF_SSIZE_FORMAT "%Iu"
|
||||
#else
|
||||
# define TIFF_UINT64_FORMAT "%llu"
|
||||
# define TIFF_SSIZE_FORMAT "%zd"
|
||||
#endif
|
||||
|
||||
/* define to use win32 IO system */
|
||||
#cmakedefine USE_WIN32_FILEIO
|
||||
|
||||
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||
significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||
#cmakedefine WORDS_BIGENDIAN 1
|
||||
|
||||
/* Support Deflate compression */
|
||||
#define ZIP_SUPPORT 1
|
||||
Vendored
+1417
-1309
File diff suppressed because it is too large
Load Diff
Vendored
+139
-138
@@ -1,26 +1,26 @@
|
||||
/* $Id: tif_dir.h,v 1.54 2011-02-18 20:53:05 fwarmerdam Exp $ */
|
||||
/* $Id: tif_dir.h,v 1.55 2017-06-01 12:44:04 erouault Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
@@ -31,9 +31,9 @@
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
const TIFFField *info;
|
||||
int count;
|
||||
void *value;
|
||||
const TIFFField *info;
|
||||
int count;
|
||||
void *value;
|
||||
} TIFFTagValue;
|
||||
|
||||
/*
|
||||
@@ -48,14 +48,14 @@ typedef struct {
|
||||
* it is left-justified in the offset field.
|
||||
*/
|
||||
typedef struct {
|
||||
uint16 tdir_tag; /* see below */
|
||||
uint16 tdir_type; /* data type; see below */
|
||||
uint64 tdir_count; /* number of items; length in spec */
|
||||
union {
|
||||
uint16 toff_short;
|
||||
uint32 toff_long;
|
||||
uint64 toff_long8;
|
||||
} tdir_offset; /* either offset or the data itself if fits */
|
||||
uint16 tdir_tag; /* see below */
|
||||
uint16 tdir_type; /* data type; see below */
|
||||
uint64 tdir_count; /* number of items; length in spec */
|
||||
union {
|
||||
uint16 toff_short;
|
||||
uint32 toff_long;
|
||||
uint64 toff_long8;
|
||||
} tdir_offset; /* either offset or the data itself if fits */
|
||||
} TIFFDirEntry;
|
||||
|
||||
/*
|
||||
@@ -63,58 +63,58 @@ typedef struct {
|
||||
*/
|
||||
typedef struct {
|
||||
#define FIELD_SETLONGS 4
|
||||
/* bit vector of fields that are set */
|
||||
unsigned long td_fieldsset[FIELD_SETLONGS];
|
||||
/* bit vector of fields that are set */
|
||||
unsigned long td_fieldsset[FIELD_SETLONGS];
|
||||
|
||||
uint32 td_imagewidth, td_imagelength, td_imagedepth;
|
||||
uint32 td_tilewidth, td_tilelength, td_tiledepth;
|
||||
uint32 td_subfiletype;
|
||||
uint16 td_bitspersample;
|
||||
uint16 td_sampleformat;
|
||||
uint16 td_compression;
|
||||
uint16 td_photometric;
|
||||
uint16 td_threshholding;
|
||||
uint16 td_fillorder;
|
||||
uint16 td_orientation;
|
||||
uint16 td_samplesperpixel;
|
||||
uint32 td_rowsperstrip;
|
||||
uint16 td_minsamplevalue, td_maxsamplevalue;
|
||||
double* td_sminsamplevalue;
|
||||
double* td_smaxsamplevalue;
|
||||
float td_xresolution, td_yresolution;
|
||||
uint16 td_resolutionunit;
|
||||
uint16 td_planarconfig;
|
||||
float td_xposition, td_yposition;
|
||||
uint16 td_pagenumber[2];
|
||||
uint16* td_colormap[3];
|
||||
uint16 td_halftonehints[2];
|
||||
uint16 td_extrasamples;
|
||||
uint16* td_sampleinfo;
|
||||
/* even though the name is misleading, td_stripsperimage is the number
|
||||
* of striles (=strips or tiles) per plane, and td_nstrips the total
|
||||
* number of striles */
|
||||
uint32 td_stripsperimage;
|
||||
uint32 td_nstrips; /* size of offset & bytecount arrays */
|
||||
uint64* td_stripoffset;
|
||||
uint64* td_stripbytecount;
|
||||
int td_stripbytecountsorted; /* is the bytecount array sorted ascending? */
|
||||
uint32 td_imagewidth, td_imagelength, td_imagedepth;
|
||||
uint32 td_tilewidth, td_tilelength, td_tiledepth;
|
||||
uint32 td_subfiletype;
|
||||
uint16 td_bitspersample;
|
||||
uint16 td_sampleformat;
|
||||
uint16 td_compression;
|
||||
uint16 td_photometric;
|
||||
uint16 td_threshholding;
|
||||
uint16 td_fillorder;
|
||||
uint16 td_orientation;
|
||||
uint16 td_samplesperpixel;
|
||||
uint32 td_rowsperstrip;
|
||||
uint16 td_minsamplevalue, td_maxsamplevalue;
|
||||
double* td_sminsamplevalue;
|
||||
double* td_smaxsamplevalue;
|
||||
float td_xresolution, td_yresolution;
|
||||
uint16 td_resolutionunit;
|
||||
uint16 td_planarconfig;
|
||||
float td_xposition, td_yposition;
|
||||
uint16 td_pagenumber[2];
|
||||
uint16* td_colormap[3];
|
||||
uint16 td_halftonehints[2];
|
||||
uint16 td_extrasamples;
|
||||
uint16* td_sampleinfo;
|
||||
/* even though the name is misleading, td_stripsperimage is the number
|
||||
* of striles (=strips or tiles) per plane, and td_nstrips the total
|
||||
* number of striles */
|
||||
uint32 td_stripsperimage;
|
||||
uint32 td_nstrips; /* size of offset & bytecount arrays */
|
||||
uint64* td_stripoffset;
|
||||
uint64* td_stripbytecount;
|
||||
int td_stripbytecountsorted; /* is the bytecount array sorted ascending? */
|
||||
#if defined(DEFER_STRILE_LOAD)
|
||||
TIFFDirEntry td_stripoffset_entry; /* for deferred loading */
|
||||
TIFFDirEntry td_stripbytecount_entry; /* for deferred loading */
|
||||
#endif
|
||||
uint16 td_nsubifd;
|
||||
uint64* td_subifd;
|
||||
/* YCbCr parameters */
|
||||
uint16 td_ycbcrsubsampling[2];
|
||||
uint16 td_ycbcrpositioning;
|
||||
/* Colorimetry parameters */
|
||||
uint16* td_transferfunction[3];
|
||||
float* td_refblackwhite;
|
||||
/* CMYK parameters */
|
||||
int td_inknameslen;
|
||||
char* td_inknames;
|
||||
uint16 td_nsubifd;
|
||||
uint64* td_subifd;
|
||||
/* YCbCr parameters */
|
||||
uint16 td_ycbcrsubsampling[2];
|
||||
uint16 td_ycbcrpositioning;
|
||||
/* Colorimetry parameters */
|
||||
uint16* td_transferfunction[3];
|
||||
float* td_refblackwhite;
|
||||
/* CMYK parameters */
|
||||
int td_inknameslen;
|
||||
char* td_inknames;
|
||||
|
||||
int td_customValueCount;
|
||||
int td_customValueCount;
|
||||
TIFFTagValue *td_customValues;
|
||||
} TIFFDirectory;
|
||||
|
||||
@@ -195,58 +195,58 @@ typedef struct {
|
||||
#define ResetFieldBit(fields, f) (fields[(f)/32] &= ~BITn(f))
|
||||
|
||||
typedef enum {
|
||||
TIFF_SETGET_UNDEFINED = 0,
|
||||
TIFF_SETGET_ASCII = 1,
|
||||
TIFF_SETGET_UINT8 = 2,
|
||||
TIFF_SETGET_SINT8 = 3,
|
||||
TIFF_SETGET_UINT16 = 4,
|
||||
TIFF_SETGET_SINT16 = 5,
|
||||
TIFF_SETGET_UINT32 = 6,
|
||||
TIFF_SETGET_SINT32 = 7,
|
||||
TIFF_SETGET_UINT64 = 8,
|
||||
TIFF_SETGET_SINT64 = 9,
|
||||
TIFF_SETGET_FLOAT = 10,
|
||||
TIFF_SETGET_DOUBLE = 11,
|
||||
TIFF_SETGET_IFD8 = 12,
|
||||
TIFF_SETGET_INT = 13,
|
||||
TIFF_SETGET_UINT16_PAIR = 14,
|
||||
TIFF_SETGET_C0_ASCII = 15,
|
||||
TIFF_SETGET_C0_UINT8 = 16,
|
||||
TIFF_SETGET_C0_SINT8 = 17,
|
||||
TIFF_SETGET_C0_UINT16 = 18,
|
||||
TIFF_SETGET_C0_SINT16 = 19,
|
||||
TIFF_SETGET_C0_UINT32 = 20,
|
||||
TIFF_SETGET_C0_SINT32 = 21,
|
||||
TIFF_SETGET_C0_UINT64 = 22,
|
||||
TIFF_SETGET_C0_SINT64 = 23,
|
||||
TIFF_SETGET_C0_FLOAT = 24,
|
||||
TIFF_SETGET_C0_DOUBLE = 25,
|
||||
TIFF_SETGET_C0_IFD8 = 26,
|
||||
TIFF_SETGET_C16_ASCII = 27,
|
||||
TIFF_SETGET_C16_UINT8 = 28,
|
||||
TIFF_SETGET_C16_SINT8 = 29,
|
||||
TIFF_SETGET_C16_UINT16 = 30,
|
||||
TIFF_SETGET_C16_SINT16 = 31,
|
||||
TIFF_SETGET_C16_UINT32 = 32,
|
||||
TIFF_SETGET_C16_SINT32 = 33,
|
||||
TIFF_SETGET_C16_UINT64 = 34,
|
||||
TIFF_SETGET_C16_SINT64 = 35,
|
||||
TIFF_SETGET_C16_FLOAT = 36,
|
||||
TIFF_SETGET_C16_DOUBLE = 37,
|
||||
TIFF_SETGET_C16_IFD8 = 38,
|
||||
TIFF_SETGET_C32_ASCII = 39,
|
||||
TIFF_SETGET_C32_UINT8 = 40,
|
||||
TIFF_SETGET_C32_SINT8 = 41,
|
||||
TIFF_SETGET_C32_UINT16 = 42,
|
||||
TIFF_SETGET_C32_SINT16 = 43,
|
||||
TIFF_SETGET_C32_UINT32 = 44,
|
||||
TIFF_SETGET_C32_SINT32 = 45,
|
||||
TIFF_SETGET_C32_UINT64 = 46,
|
||||
TIFF_SETGET_C32_SINT64 = 47,
|
||||
TIFF_SETGET_C32_FLOAT = 48,
|
||||
TIFF_SETGET_C32_DOUBLE = 49,
|
||||
TIFF_SETGET_C32_IFD8 = 50,
|
||||
TIFF_SETGET_OTHER = 51
|
||||
TIFF_SETGET_UNDEFINED = 0,
|
||||
TIFF_SETGET_ASCII = 1,
|
||||
TIFF_SETGET_UINT8 = 2,
|
||||
TIFF_SETGET_SINT8 = 3,
|
||||
TIFF_SETGET_UINT16 = 4,
|
||||
TIFF_SETGET_SINT16 = 5,
|
||||
TIFF_SETGET_UINT32 = 6,
|
||||
TIFF_SETGET_SINT32 = 7,
|
||||
TIFF_SETGET_UINT64 = 8,
|
||||
TIFF_SETGET_SINT64 = 9,
|
||||
TIFF_SETGET_FLOAT = 10,
|
||||
TIFF_SETGET_DOUBLE = 11,
|
||||
TIFF_SETGET_IFD8 = 12,
|
||||
TIFF_SETGET_INT = 13,
|
||||
TIFF_SETGET_UINT16_PAIR = 14,
|
||||
TIFF_SETGET_C0_ASCII = 15,
|
||||
TIFF_SETGET_C0_UINT8 = 16,
|
||||
TIFF_SETGET_C0_SINT8 = 17,
|
||||
TIFF_SETGET_C0_UINT16 = 18,
|
||||
TIFF_SETGET_C0_SINT16 = 19,
|
||||
TIFF_SETGET_C0_UINT32 = 20,
|
||||
TIFF_SETGET_C0_SINT32 = 21,
|
||||
TIFF_SETGET_C0_UINT64 = 22,
|
||||
TIFF_SETGET_C0_SINT64 = 23,
|
||||
TIFF_SETGET_C0_FLOAT = 24,
|
||||
TIFF_SETGET_C0_DOUBLE = 25,
|
||||
TIFF_SETGET_C0_IFD8 = 26,
|
||||
TIFF_SETGET_C16_ASCII = 27,
|
||||
TIFF_SETGET_C16_UINT8 = 28,
|
||||
TIFF_SETGET_C16_SINT8 = 29,
|
||||
TIFF_SETGET_C16_UINT16 = 30,
|
||||
TIFF_SETGET_C16_SINT16 = 31,
|
||||
TIFF_SETGET_C16_UINT32 = 32,
|
||||
TIFF_SETGET_C16_SINT32 = 33,
|
||||
TIFF_SETGET_C16_UINT64 = 34,
|
||||
TIFF_SETGET_C16_SINT64 = 35,
|
||||
TIFF_SETGET_C16_FLOAT = 36,
|
||||
TIFF_SETGET_C16_DOUBLE = 37,
|
||||
TIFF_SETGET_C16_IFD8 = 38,
|
||||
TIFF_SETGET_C32_ASCII = 39,
|
||||
TIFF_SETGET_C32_UINT8 = 40,
|
||||
TIFF_SETGET_C32_SINT8 = 41,
|
||||
TIFF_SETGET_C32_UINT16 = 42,
|
||||
TIFF_SETGET_C32_SINT16 = 43,
|
||||
TIFF_SETGET_C32_UINT32 = 44,
|
||||
TIFF_SETGET_C32_SINT32 = 45,
|
||||
TIFF_SETGET_C32_UINT64 = 46,
|
||||
TIFF_SETGET_C32_SINT64 = 47,
|
||||
TIFF_SETGET_C32_FLOAT = 48,
|
||||
TIFF_SETGET_C32_DOUBLE = 49,
|
||||
TIFF_SETGET_C32_IFD8 = 50,
|
||||
TIFF_SETGET_OTHER = 51
|
||||
} TIFFSetGetFieldType;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
@@ -258,39 +258,40 @@ extern const TIFFFieldArray* _TIFFGetExifFields(void);
|
||||
extern void _TIFFSetupFields(TIFF* tif, const TIFFFieldArray* infoarray);
|
||||
extern void _TIFFPrintFieldInfo(TIFF*, FILE*);
|
||||
|
||||
extern int _TIFFFillStriles(TIFF*);
|
||||
extern int _TIFFFillStriles(TIFF*);
|
||||
|
||||
typedef enum {
|
||||
tfiatImage,
|
||||
tfiatExif,
|
||||
tfiatOther
|
||||
tfiatImage,
|
||||
tfiatExif,
|
||||
tfiatOther
|
||||
} TIFFFieldArrayType;
|
||||
|
||||
struct _TIFFFieldArray {
|
||||
TIFFFieldArrayType type; /* array type, will be used to determine if IFD is image and such */
|
||||
uint32 allocated_size; /* 0 if array is constant, other if modified by future definition extension support */
|
||||
uint32 count; /* number of elements in fields array */
|
||||
TIFFField* fields; /* actual field info */
|
||||
TIFFFieldArrayType type; /* array type, will be used to determine if IFD is image and such */
|
||||
uint32 allocated_size; /* 0 if array is constant, other if modified by future definition extension support */
|
||||
uint32 count; /* number of elements in fields array */
|
||||
TIFFField* fields; /* actual field info */
|
||||
};
|
||||
|
||||
struct _TIFFField {
|
||||
uint32 field_tag; /* field's tag */
|
||||
short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */
|
||||
short field_writecount; /* write count/TIFF_VARIABLE */
|
||||
TIFFDataType field_type; /* type of associated data */
|
||||
uint32 reserved; /* reserved for future extension */
|
||||
TIFFSetGetFieldType set_field_type; /* type to be passed to TIFFSetField */
|
||||
TIFFSetGetFieldType get_field_type; /* type to be passed to TIFFGetField */
|
||||
unsigned short field_bit; /* bit in fieldsset bit vector */
|
||||
unsigned char field_oktochange; /* if true, can change while writing */
|
||||
unsigned char field_passcount; /* if true, pass dir count on set */
|
||||
char* field_name; /* ASCII name */
|
||||
TIFFFieldArray* field_subfields; /* if field points to child ifds, child ifd field definition array */
|
||||
uint32 field_tag; /* field's tag */
|
||||
short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */
|
||||
short field_writecount; /* write count/TIFF_VARIABLE */
|
||||
TIFFDataType field_type; /* type of associated data */
|
||||
uint32 reserved; /* reserved for future extension */
|
||||
TIFFSetGetFieldType set_field_type; /* type to be passed to TIFFSetField */
|
||||
TIFFSetGetFieldType get_field_type; /* type to be passed to TIFFGetField */
|
||||
unsigned short field_bit; /* bit in fieldsset bit vector */
|
||||
unsigned char field_oktochange; /* if true, can change while writing */
|
||||
unsigned char field_passcount; /* if true, pass dir count on set */
|
||||
char* field_name; /* ASCII name */
|
||||
TIFFFieldArray* field_subfields; /* if field points to child ifds, child ifd field definition array */
|
||||
};
|
||||
|
||||
extern int _TIFFMergeFields(TIFF*, const TIFFField[], uint32);
|
||||
extern const TIFFField* _TIFFFindOrRegisterField(TIFF *, uint32, TIFFDataType);
|
||||
extern TIFFField* _TIFFCreateAnonField(TIFF *, uint32, TIFFDataType);
|
||||
extern int _TIFFCheckFieldIsValidForCodec(TIFF *tif, ttag_t tag);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
||||
Vendored
+850
-687
File diff suppressed because it is too large
Load Diff
Vendored
+5053
-4850
File diff suppressed because it is too large
Load Diff
Vendored
+1924
-1810
File diff suppressed because it is too large
Load Diff
Vendored
+68
-68
@@ -1,26 +1,26 @@
|
||||
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dumpmode.c,v 1.14 2011-04-02 20:54:09 bfriesen Exp $ */
|
||||
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dumpmode.c,v 1.15 2015-12-12 18:04:26 erouault Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
@@ -34,8 +34,8 @@
|
||||
static int
|
||||
DumpFixupTags(TIFF* tif)
|
||||
{
|
||||
(void) tif;
|
||||
return (1);
|
||||
(void) tif;
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -44,31 +44,31 @@ DumpFixupTags(TIFF* tif)
|
||||
static int
|
||||
DumpModeEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s)
|
||||
{
|
||||
(void) s;
|
||||
while (cc > 0) {
|
||||
tmsize_t n;
|
||||
(void) s;
|
||||
while (cc > 0) {
|
||||
tmsize_t n;
|
||||
|
||||
n = cc;
|
||||
if (tif->tif_rawcc + n > tif->tif_rawdatasize)
|
||||
n = tif->tif_rawdatasize - tif->tif_rawcc;
|
||||
n = cc;
|
||||
if (tif->tif_rawcc + n > tif->tif_rawdatasize)
|
||||
n = tif->tif_rawdatasize - tif->tif_rawcc;
|
||||
|
||||
assert( n > 0 );
|
||||
assert( n > 0 );
|
||||
|
||||
/*
|
||||
* Avoid copy if client has setup raw
|
||||
* data buffer to avoid extra copy.
|
||||
*/
|
||||
if (tif->tif_rawcp != pp)
|
||||
_TIFFmemcpy(tif->tif_rawcp, pp, n);
|
||||
tif->tif_rawcp += n;
|
||||
tif->tif_rawcc += n;
|
||||
pp += n;
|
||||
cc -= n;
|
||||
if (tif->tif_rawcc >= tif->tif_rawdatasize &&
|
||||
!TIFFFlushData1(tif))
|
||||
return (-1);
|
||||
}
|
||||
return (1);
|
||||
/*
|
||||
* Avoid copy if client has setup raw
|
||||
* data buffer to avoid extra copy.
|
||||
*/
|
||||
if (tif->tif_rawcp != pp)
|
||||
_TIFFmemcpy(tif->tif_rawcp, pp, n);
|
||||
tif->tif_rawcp += n;
|
||||
tif->tif_rawcc += n;
|
||||
pp += n;
|
||||
cc -= n;
|
||||
if (tif->tif_rawcc >= tif->tif_rawdatasize &&
|
||||
!TIFFFlushData1(tif))
|
||||
return (0);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -77,33 +77,33 @@ DumpModeEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s)
|
||||
static int
|
||||
DumpModeDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
|
||||
{
|
||||
static const char module[] = "DumpModeDecode";
|
||||
(void) s;
|
||||
if (tif->tif_rawcc < cc) {
|
||||
static const char module[] = "DumpModeDecode";
|
||||
(void) s;
|
||||
if (tif->tif_rawcc < cc) {
|
||||
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Not enough data for scanline %lu, expected a request for at most %I64d bytes, got a request for %I64d bytes",
|
||||
(unsigned long) tif->tif_row,
|
||||
(signed __int64) tif->tif_rawcc,
|
||||
(signed __int64) cc);
|
||||
(unsigned long) tif->tif_row,
|
||||
(signed __int64) tif->tif_rawcc,
|
||||
(signed __int64) cc);
|
||||
#else
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Not enough data for scanline %lu, expected a request for at most %lld bytes, got a request for %lld bytes",
|
||||
(unsigned long) tif->tif_row,
|
||||
(signed long long) tif->tif_rawcc,
|
||||
(signed long long) cc);
|
||||
(unsigned long) tif->tif_row,
|
||||
(signed long long) tif->tif_rawcc,
|
||||
(signed long long) cc);
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
/*
|
||||
* Avoid copy if client has setup raw
|
||||
* data buffer to avoid extra copy.
|
||||
*/
|
||||
if (tif->tif_rawcp != buf)
|
||||
_TIFFmemcpy(buf, tif->tif_rawcp, cc);
|
||||
tif->tif_rawcp += cc;
|
||||
tif->tif_rawcc -= cc;
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
/*
|
||||
* Avoid copy if client has setup raw
|
||||
* data buffer to avoid extra copy.
|
||||
*/
|
||||
if (tif->tif_rawcp != buf)
|
||||
_TIFFmemcpy(buf, tif->tif_rawcp, cc);
|
||||
tif->tif_rawcp += cc;
|
||||
tif->tif_rawcc -= cc;
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -112,9 +112,9 @@ DumpModeDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
|
||||
static int
|
||||
DumpModeSeek(TIFF* tif, uint32 nrows)
|
||||
{
|
||||
tif->tif_rawcp += nrows * tif->tif_scanlinesize;
|
||||
tif->tif_rawcc -= nrows * tif->tif_scanlinesize;
|
||||
return (1);
|
||||
tif->tif_rawcp += nrows * tif->tif_scanlinesize;
|
||||
tif->tif_rawcc -= nrows * tif->tif_scanlinesize;
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -123,16 +123,16 @@ DumpModeSeek(TIFF* tif, uint32 nrows)
|
||||
int
|
||||
TIFFInitDumpMode(TIFF* tif, int scheme)
|
||||
{
|
||||
(void) scheme;
|
||||
tif->tif_fixuptags = DumpFixupTags;
|
||||
tif->tif_decoderow = DumpModeDecode;
|
||||
tif->tif_decodestrip = DumpModeDecode;
|
||||
tif->tif_decodetile = DumpModeDecode;
|
||||
tif->tif_encoderow = DumpModeEncode;
|
||||
tif->tif_encodestrip = DumpModeEncode;
|
||||
tif->tif_encodetile = DumpModeEncode;
|
||||
tif->tif_seek = DumpModeSeek;
|
||||
return (1);
|
||||
(void) scheme;
|
||||
tif->tif_fixuptags = DumpFixupTags;
|
||||
tif->tif_decoderow = DumpModeDecode;
|
||||
tif->tif_decodestrip = DumpModeDecode;
|
||||
tif->tif_decodetile = DumpModeDecode;
|
||||
tif->tif_encoderow = DumpModeEncode;
|
||||
tif->tif_encodestrip = DumpModeEncode;
|
||||
tif->tif_encodetile = DumpModeEncode;
|
||||
tif->tif_seek = DumpModeSeek;
|
||||
return (1);
|
||||
}
|
||||
/*
|
||||
* Local Variables:
|
||||
|
||||
Vendored
+37
-29
@@ -1,26 +1,26 @@
|
||||
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_error.c,v 1.5 2010-03-10 18:56:48 bfriesen Exp $ */
|
||||
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_error.c,v 1.6 2017-07-04 12:54:42 erouault Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
@@ -34,41 +34,49 @@ TIFFErrorHandlerExt _TIFFerrorHandlerExt = NULL;
|
||||
TIFFErrorHandler
|
||||
TIFFSetErrorHandler(TIFFErrorHandler handler)
|
||||
{
|
||||
TIFFErrorHandler prev = _TIFFerrorHandler;
|
||||
_TIFFerrorHandler = handler;
|
||||
return (prev);
|
||||
TIFFErrorHandler prev = _TIFFerrorHandler;
|
||||
_TIFFerrorHandler = handler;
|
||||
return (prev);
|
||||
}
|
||||
|
||||
TIFFErrorHandlerExt
|
||||
TIFFSetErrorHandlerExt(TIFFErrorHandlerExt handler)
|
||||
{
|
||||
TIFFErrorHandlerExt prev = _TIFFerrorHandlerExt;
|
||||
_TIFFerrorHandlerExt = handler;
|
||||
return (prev);
|
||||
TIFFErrorHandlerExt prev = _TIFFerrorHandlerExt;
|
||||
_TIFFerrorHandlerExt = handler;
|
||||
return (prev);
|
||||
}
|
||||
|
||||
void
|
||||
TIFFError(const char* module, const char* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
if (_TIFFerrorHandler)
|
||||
(*_TIFFerrorHandler)(module, fmt, ap);
|
||||
if (_TIFFerrorHandlerExt)
|
||||
(*_TIFFerrorHandlerExt)(0, module, fmt, ap);
|
||||
va_end(ap);
|
||||
va_list ap;
|
||||
if (_TIFFerrorHandler) {
|
||||
va_start(ap, fmt);
|
||||
(*_TIFFerrorHandler)(module, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
if (_TIFFerrorHandlerExt) {
|
||||
va_start(ap, fmt);
|
||||
(*_TIFFerrorHandlerExt)(0, module, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TIFFErrorExt(thandle_t fd, const char* module, const char* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
if (_TIFFerrorHandler)
|
||||
(*_TIFFerrorHandler)(module, fmt, ap);
|
||||
if (_TIFFerrorHandlerExt)
|
||||
(*_TIFFerrorHandlerExt)(fd, module, fmt, ap);
|
||||
va_end(ap);
|
||||
va_list ap;
|
||||
if (_TIFFerrorHandler) {
|
||||
va_start(ap, fmt);
|
||||
(*_TIFFerrorHandler)(module, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
if (_TIFFerrorHandlerExt) {
|
||||
va_start(ap, fmt);
|
||||
(*_TIFFerrorHandlerExt)(fd, module, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Vendored
+29
-29
@@ -1,26 +1,26 @@
|
||||
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_extension.c,v 1.7 2010-03-10 18:56:48 bfriesen Exp $ */
|
||||
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_extension.c,v 1.8 2015-12-06 11:13:43 erouault Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
* TIFF Library.
|
||||
*
|
||||
* Various routines support external extension of the tag set, and other
|
||||
* application extension capabilities.
|
||||
* application extension capabilities.
|
||||
*/
|
||||
|
||||
#include "tiffiop.h"
|
||||
@@ -37,7 +37,7 @@ int TIFFGetTagListCount( TIFF *tif )
|
||||
|
||||
{
|
||||
TIFFDirectory* td = &tif->tif_dir;
|
||||
|
||||
|
||||
return td->td_customValueCount;
|
||||
}
|
||||
|
||||
@@ -66,13 +66,13 @@ TIFFTagMethods *TIFFAccessTagMethods( TIFF *tif )
|
||||
void *TIFFGetClientInfo( TIFF *tif, const char *name )
|
||||
|
||||
{
|
||||
TIFFClientInfoLink *link = tif->tif_clientinfo;
|
||||
TIFFClientInfoLink *psLink = tif->tif_clientinfo;
|
||||
|
||||
while( link != NULL && strcmp(link->name,name) != 0 )
|
||||
link = link->next;
|
||||
while( psLink != NULL && strcmp(psLink->name,name) != 0 )
|
||||
psLink = psLink->next;
|
||||
|
||||
if( link != NULL )
|
||||
return link->data;
|
||||
if( psLink != NULL )
|
||||
return psLink->data;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
@@ -80,18 +80,18 @@ void *TIFFGetClientInfo( TIFF *tif, const char *name )
|
||||
void TIFFSetClientInfo( TIFF *tif, void *data, const char *name )
|
||||
|
||||
{
|
||||
TIFFClientInfoLink *link = tif->tif_clientinfo;
|
||||
TIFFClientInfoLink *psLink = tif->tif_clientinfo;
|
||||
|
||||
/*
|
||||
** Do we have an existing link with this name? If so, just
|
||||
** set it.
|
||||
*/
|
||||
while( link != NULL && strcmp(link->name,name) != 0 )
|
||||
link = link->next;
|
||||
while( psLink != NULL && strcmp(psLink->name,name) != 0 )
|
||||
psLink = psLink->next;
|
||||
|
||||
if( link != NULL )
|
||||
if( psLink != NULL )
|
||||
{
|
||||
link->data = data;
|
||||
psLink->data = data;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -99,15 +99,15 @@ void TIFFSetClientInfo( TIFF *tif, void *data, const char *name )
|
||||
** Create a new link.
|
||||
*/
|
||||
|
||||
link = (TIFFClientInfoLink *) _TIFFmalloc(sizeof(TIFFClientInfoLink));
|
||||
assert (link != NULL);
|
||||
link->next = tif->tif_clientinfo;
|
||||
link->name = (char *) _TIFFmalloc((tmsize_t)(strlen(name)+1));
|
||||
assert (link->name != NULL);
|
||||
strcpy(link->name, name);
|
||||
link->data = data;
|
||||
psLink = (TIFFClientInfoLink *) _TIFFmalloc(sizeof(TIFFClientInfoLink));
|
||||
assert (psLink != NULL);
|
||||
psLink->next = tif->tif_clientinfo;
|
||||
psLink->name = (char *) _TIFFmalloc((tmsize_t)(strlen(name)+1));
|
||||
assert (psLink->name != NULL);
|
||||
strcpy(psLink->name, name);
|
||||
psLink->data = data;
|
||||
|
||||
tif->tif_clientinfo = link;
|
||||
tif->tif_clientinfo = psLink;
|
||||
}
|
||||
/*
|
||||
* Local Variables:
|
||||
|
||||
Vendored
+1054
-1001
File diff suppressed because it is too large
Load Diff
Vendored
+246
-244
@@ -1,26 +1,26 @@
|
||||
/* $Id: tif_fax3.h,v 1.9 2011-03-10 20:23:07 fwarmerdam Exp $ */
|
||||
/* $Id: tif_fax3.h,v 1.13 2016-12-14 18:36:27 faxguy Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990-1997 Sam Leffler
|
||||
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
/*
|
||||
* To override the default routine used to image decoded
|
||||
* spans one can use the pseduo tag TIFFTAG_FAXFILLFUNC.
|
||||
* spans one can use the pseudo tag TIFFTAG_FAXFILLFUNC.
|
||||
* The routine must have the type signature given below;
|
||||
* for example:
|
||||
*
|
||||
@@ -81,10 +81,12 @@ extern void _TIFFFax3fillruns(unsigned char*, uint32*, uint32*, uint32);
|
||||
#define S_MakeUp 11
|
||||
#define S_EOL 12
|
||||
|
||||
/* WARNING: do not change the layout of this structure as the HylaFAX software */
|
||||
/* really depends on it. See http://bugzilla.maptools.org/show_bug.cgi?id=2636 */
|
||||
typedef struct { /* state table entry */
|
||||
unsigned char State; /* see above */
|
||||
unsigned char Width; /* width of code in bits */
|
||||
uint32 Param; /* unsigned 32-bit run length in bits */
|
||||
unsigned char State; /* see above */
|
||||
unsigned char Width; /* width of code in bits */
|
||||
uint32 Param; /* unsigned 32-bit run length in bits (holds on 16 bit actually, but cannot be changed. See above warning) */
|
||||
} TIFFFaxTabEnt;
|
||||
|
||||
extern const TIFFFaxTabEnt TIFFFaxMainTable[];
|
||||
@@ -136,36 +138,36 @@ extern const TIFFFaxTabEnt TIFFFaxBlackTable[];
|
||||
#ifndef NeedBits8
|
||||
#define NeedBits8(n,eoflab) do { \
|
||||
if (BitsAvail < (n)) { \
|
||||
if (EndOfData()) { \
|
||||
if (BitsAvail == 0) /* no valid bits */ \
|
||||
goto eoflab; \
|
||||
BitsAvail = (n); /* pad with zeros */ \
|
||||
} else { \
|
||||
BitAcc |= ((uint32) bitmap[*cp++])<<BitsAvail; \
|
||||
BitsAvail += 8; \
|
||||
} \
|
||||
if (EndOfData()) { \
|
||||
if (BitsAvail == 0) /* no valid bits */ \
|
||||
goto eoflab; \
|
||||
BitsAvail = (n); /* pad with zeros */ \
|
||||
} else { \
|
||||
BitAcc |= ((uint32) bitmap[*cp++])<<BitsAvail; \
|
||||
BitsAvail += 8; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
#ifndef NeedBits16
|
||||
#define NeedBits16(n,eoflab) do { \
|
||||
if (BitsAvail < (n)) { \
|
||||
if (EndOfData()) { \
|
||||
if (BitsAvail == 0) /* no valid bits */ \
|
||||
goto eoflab; \
|
||||
BitsAvail = (n); /* pad with zeros */ \
|
||||
} else { \
|
||||
BitAcc |= ((uint32) bitmap[*cp++])<<BitsAvail; \
|
||||
if ((BitsAvail += 8) < (n)) { \
|
||||
if (EndOfData()) { \
|
||||
/* NB: we know BitsAvail is non-zero here */ \
|
||||
BitsAvail = (n); /* pad with zeros */ \
|
||||
} else { \
|
||||
BitAcc |= ((uint32) bitmap[*cp++])<<BitsAvail; \
|
||||
BitsAvail += 8; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
if (EndOfData()) { \
|
||||
if (BitsAvail == 0) /* no valid bits */ \
|
||||
goto eoflab; \
|
||||
BitsAvail = (n); /* pad with zeros */ \
|
||||
} else { \
|
||||
BitAcc |= ((uint32) bitmap[*cp++])<<BitsAvail; \
|
||||
if ((BitsAvail += 8) < (n)) { \
|
||||
if (EndOfData()) { \
|
||||
/* NB: we know BitsAvail is non-zero here */ \
|
||||
BitsAvail = (n); /* pad with zeros */ \
|
||||
} else { \
|
||||
BitAcc |= ((uint32) bitmap[*cp++])<<BitsAvail; \
|
||||
BitsAvail += 8; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
@@ -197,9 +199,9 @@ static const char* StateNames[] = {
|
||||
NeedBits8(wid,eoflab); \
|
||||
TabEnt = tab + GetBits(wid); \
|
||||
printf("%08lX/%d: %s%5d\t", (long) BitAcc, BitsAvail, \
|
||||
StateNames[TabEnt->State], TabEnt->Param); \
|
||||
StateNames[TabEnt->State], TabEnt->Param); \
|
||||
for (t = 0; t < TabEnt->Width; t++) \
|
||||
DEBUG_SHOW; \
|
||||
DEBUG_SHOW; \
|
||||
putchar('\n'); \
|
||||
fflush(stdout); \
|
||||
ClrBits(TabEnt->Width); \
|
||||
@@ -209,9 +211,9 @@ static const char* StateNames[] = {
|
||||
NeedBits16(wid,eoflab); \
|
||||
TabEnt = tab + GetBits(wid); \
|
||||
printf("%08lX/%d: %s%5d\t", (long) BitAcc, BitsAvail, \
|
||||
StateNames[TabEnt->State], TabEnt->Param); \
|
||||
StateNames[TabEnt->State], TabEnt->Param); \
|
||||
for (t = 0; t < TabEnt->Width; t++) \
|
||||
DEBUG_SHOW; \
|
||||
DEBUG_SHOW; \
|
||||
putchar('\n'); \
|
||||
fflush(stdout); \
|
||||
ClrBits(TabEnt->Width); \
|
||||
@@ -258,21 +260,21 @@ static const char* StateNames[] = {
|
||||
*/
|
||||
#define SYNC_EOL(eoflab) do { \
|
||||
if (EOLcnt == 0) { \
|
||||
for (;;) { \
|
||||
NeedBits16(11,eoflab); \
|
||||
if (GetBits(11) == 0) \
|
||||
break; \
|
||||
ClrBits(1); \
|
||||
} \
|
||||
for (;;) { \
|
||||
NeedBits16(11,eoflab); \
|
||||
if (GetBits(11) == 0) \
|
||||
break; \
|
||||
ClrBits(1); \
|
||||
} \
|
||||
} \
|
||||
for (;;) { \
|
||||
NeedBits8(8,eoflab); \
|
||||
if (GetBits(8)) \
|
||||
break; \
|
||||
ClrBits(8); \
|
||||
NeedBits8(8,eoflab); \
|
||||
if (GetBits(8)) \
|
||||
break; \
|
||||
ClrBits(8); \
|
||||
} \
|
||||
while (GetBits(1) == 0) \
|
||||
ClrBits(1); \
|
||||
ClrBits(1); \
|
||||
ClrBits(1); /* EOL bit */ \
|
||||
EOLcnt = 0; /* reset EOL counter/flag */ \
|
||||
} while (0)
|
||||
@@ -284,21 +286,21 @@ static const char* StateNames[] = {
|
||||
*/
|
||||
#define CLEANUP_RUNS() do { \
|
||||
if (RunLength) \
|
||||
SETVALUE(0); \
|
||||
SETVALUE(0); \
|
||||
if (a0 != lastx) { \
|
||||
badlength(a0, lastx); \
|
||||
while (a0 > lastx && pa > thisrun) \
|
||||
a0 -= *--pa; \
|
||||
if (a0 < lastx) { \
|
||||
if (a0 < 0) \
|
||||
a0 = 0; \
|
||||
if ((pa-thisrun)&1) \
|
||||
SETVALUE(0); \
|
||||
SETVALUE(lastx - a0); \
|
||||
} else if (a0 > lastx) { \
|
||||
SETVALUE(lastx); \
|
||||
SETVALUE(0); \
|
||||
} \
|
||||
badlength(a0, lastx); \
|
||||
while (a0 > lastx && pa > thisrun) \
|
||||
a0 -= *--pa; \
|
||||
if (a0 < lastx) { \
|
||||
if (a0 < 0) \
|
||||
a0 = 0; \
|
||||
if ((pa-thisrun)&1) \
|
||||
SETVALUE(0); \
|
||||
SETVALUE(lastx - a0); \
|
||||
} else if (a0 > lastx) { \
|
||||
SETVALUE(lastx); \
|
||||
SETVALUE(0); \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
@@ -316,50 +318,50 @@ static const char* StateNames[] = {
|
||||
*/
|
||||
#define EXPAND1D(eoflab) do { \
|
||||
for (;;) { \
|
||||
for (;;) { \
|
||||
LOOKUP16(12, TIFFFaxWhiteTable, eof1d); \
|
||||
switch (TabEnt->State) { \
|
||||
case S_EOL: \
|
||||
EOLcnt = 1; \
|
||||
goto done1d; \
|
||||
case S_TermW: \
|
||||
SETVALUE(TabEnt->Param); \
|
||||
goto doneWhite1d; \
|
||||
case S_MakeUpW: \
|
||||
case S_MakeUp: \
|
||||
a0 += TabEnt->Param; \
|
||||
RunLength += TabEnt->Param; \
|
||||
break; \
|
||||
default: \
|
||||
unexpected("WhiteTable", a0); \
|
||||
goto done1d; \
|
||||
} \
|
||||
} \
|
||||
for (;;) { \
|
||||
LOOKUP16(12, TIFFFaxWhiteTable, eof1d); \
|
||||
switch (TabEnt->State) { \
|
||||
case S_EOL: \
|
||||
EOLcnt = 1; \
|
||||
goto done1d; \
|
||||
case S_TermW: \
|
||||
SETVALUE(TabEnt->Param); \
|
||||
goto doneWhite1d; \
|
||||
case S_MakeUpW: \
|
||||
case S_MakeUp: \
|
||||
a0 += TabEnt->Param; \
|
||||
RunLength += TabEnt->Param; \
|
||||
break; \
|
||||
default: \
|
||||
unexpected("WhiteTable", a0); \
|
||||
goto done1d; \
|
||||
} \
|
||||
} \
|
||||
doneWhite1d: \
|
||||
if (a0 >= lastx) \
|
||||
goto done1d; \
|
||||
for (;;) { \
|
||||
LOOKUP16(13, TIFFFaxBlackTable, eof1d); \
|
||||
switch (TabEnt->State) { \
|
||||
case S_EOL: \
|
||||
EOLcnt = 1; \
|
||||
goto done1d; \
|
||||
case S_TermB: \
|
||||
SETVALUE(TabEnt->Param); \
|
||||
goto doneBlack1d; \
|
||||
case S_MakeUpB: \
|
||||
case S_MakeUp: \
|
||||
a0 += TabEnt->Param; \
|
||||
RunLength += TabEnt->Param; \
|
||||
break; \
|
||||
default: \
|
||||
unexpected("BlackTable", a0); \
|
||||
goto done1d; \
|
||||
} \
|
||||
} \
|
||||
if (a0 >= lastx) \
|
||||
goto done1d; \
|
||||
for (;;) { \
|
||||
LOOKUP16(13, TIFFFaxBlackTable, eof1d); \
|
||||
switch (TabEnt->State) { \
|
||||
case S_EOL: \
|
||||
EOLcnt = 1; \
|
||||
goto done1d; \
|
||||
case S_TermB: \
|
||||
SETVALUE(TabEnt->Param); \
|
||||
goto doneBlack1d; \
|
||||
case S_MakeUpB: \
|
||||
case S_MakeUp: \
|
||||
a0 += TabEnt->Param; \
|
||||
RunLength += TabEnt->Param; \
|
||||
break; \
|
||||
default: \
|
||||
unexpected("BlackTable", a0); \
|
||||
goto done1d; \
|
||||
} \
|
||||
} \
|
||||
doneBlack1d: \
|
||||
if (a0 >= lastx) \
|
||||
goto done1d; \
|
||||
if (a0 >= lastx) \
|
||||
goto done1d; \
|
||||
if( *(pa-1) == 0 && *(pa-2) == 0 ) \
|
||||
pa -= 2; \
|
||||
} \
|
||||
@@ -377,8 +379,8 @@ done1d: \
|
||||
*/
|
||||
#define CHECK_b1 do { \
|
||||
if (pa != thisrun) while (b1 <= a0 && b1 < lastx) { \
|
||||
b1 += pb[0] + pb[1]; \
|
||||
pb += 2; \
|
||||
b1 += pb[0] + pb[1]; \
|
||||
pb += 2; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
@@ -387,143 +389,143 @@ done1d: \
|
||||
*/
|
||||
#define EXPAND2D(eoflab) do { \
|
||||
while (a0 < lastx) { \
|
||||
LOOKUP8(7, TIFFFaxMainTable, eof2d); \
|
||||
switch (TabEnt->State) { \
|
||||
case S_Pass: \
|
||||
CHECK_b1; \
|
||||
b1 += *pb++; \
|
||||
RunLength += b1 - a0; \
|
||||
a0 = b1; \
|
||||
b1 += *pb++; \
|
||||
break; \
|
||||
case S_Horiz: \
|
||||
if ((pa-thisrun)&1) { \
|
||||
for (;;) { /* black first */ \
|
||||
LOOKUP16(13, TIFFFaxBlackTable, eof2d); \
|
||||
switch (TabEnt->State) { \
|
||||
case S_TermB: \
|
||||
SETVALUE(TabEnt->Param); \
|
||||
goto doneWhite2da; \
|
||||
case S_MakeUpB: \
|
||||
case S_MakeUp: \
|
||||
a0 += TabEnt->Param; \
|
||||
RunLength += TabEnt->Param; \
|
||||
break; \
|
||||
default: \
|
||||
goto badBlack2d; \
|
||||
} \
|
||||
} \
|
||||
doneWhite2da:; \
|
||||
for (;;) { /* then white */ \
|
||||
LOOKUP16(12, TIFFFaxWhiteTable, eof2d); \
|
||||
switch (TabEnt->State) { \
|
||||
case S_TermW: \
|
||||
SETVALUE(TabEnt->Param); \
|
||||
goto doneBlack2da; \
|
||||
case S_MakeUpW: \
|
||||
case S_MakeUp: \
|
||||
a0 += TabEnt->Param; \
|
||||
RunLength += TabEnt->Param; \
|
||||
break; \
|
||||
default: \
|
||||
goto badWhite2d; \
|
||||
} \
|
||||
} \
|
||||
doneBlack2da:; \
|
||||
} else { \
|
||||
for (;;) { /* white first */ \
|
||||
LOOKUP16(12, TIFFFaxWhiteTable, eof2d); \
|
||||
switch (TabEnt->State) { \
|
||||
case S_TermW: \
|
||||
SETVALUE(TabEnt->Param); \
|
||||
goto doneWhite2db; \
|
||||
case S_MakeUpW: \
|
||||
case S_MakeUp: \
|
||||
a0 += TabEnt->Param; \
|
||||
RunLength += TabEnt->Param; \
|
||||
break; \
|
||||
default: \
|
||||
goto badWhite2d; \
|
||||
} \
|
||||
} \
|
||||
doneWhite2db:; \
|
||||
for (;;) { /* then black */ \
|
||||
LOOKUP16(13, TIFFFaxBlackTable, eof2d); \
|
||||
switch (TabEnt->State) { \
|
||||
case S_TermB: \
|
||||
SETVALUE(TabEnt->Param); \
|
||||
goto doneBlack2db; \
|
||||
case S_MakeUpB: \
|
||||
case S_MakeUp: \
|
||||
a0 += TabEnt->Param; \
|
||||
RunLength += TabEnt->Param; \
|
||||
break; \
|
||||
default: \
|
||||
goto badBlack2d; \
|
||||
} \
|
||||
} \
|
||||
doneBlack2db:; \
|
||||
} \
|
||||
CHECK_b1; \
|
||||
break; \
|
||||
case S_V0: \
|
||||
CHECK_b1; \
|
||||
SETVALUE(b1 - a0); \
|
||||
b1 += *pb++; \
|
||||
break; \
|
||||
case S_VR: \
|
||||
CHECK_b1; \
|
||||
SETVALUE(b1 - a0 + TabEnt->Param); \
|
||||
b1 += *pb++; \
|
||||
break; \
|
||||
case S_VL: \
|
||||
CHECK_b1; \
|
||||
if (b1 <= (int) (a0 + TabEnt->Param)) { \
|
||||
if (b1 < (int) (a0 + TabEnt->Param) || pa != thisrun) { \
|
||||
unexpected("VL", a0); \
|
||||
goto eol2d; \
|
||||
} \
|
||||
} \
|
||||
SETVALUE(b1 - a0 - TabEnt->Param); \
|
||||
b1 -= *--pb; \
|
||||
break; \
|
||||
case S_Ext: \
|
||||
*pa++ = lastx - a0; \
|
||||
extension(a0); \
|
||||
goto eol2d; \
|
||||
case S_EOL: \
|
||||
*pa++ = lastx - a0; \
|
||||
NeedBits8(4,eof2d); \
|
||||
if (GetBits(4)) \
|
||||
unexpected("EOL", a0); \
|
||||
LOOKUP8(7, TIFFFaxMainTable, eof2d); \
|
||||
switch (TabEnt->State) { \
|
||||
case S_Pass: \
|
||||
CHECK_b1; \
|
||||
b1 += *pb++; \
|
||||
RunLength += b1 - a0; \
|
||||
a0 = b1; \
|
||||
b1 += *pb++; \
|
||||
break; \
|
||||
case S_Horiz: \
|
||||
if ((pa-thisrun)&1) { \
|
||||
for (;;) { /* black first */ \
|
||||
LOOKUP16(13, TIFFFaxBlackTable, eof2d); \
|
||||
switch (TabEnt->State) { \
|
||||
case S_TermB: \
|
||||
SETVALUE(TabEnt->Param); \
|
||||
goto doneWhite2da; \
|
||||
case S_MakeUpB: \
|
||||
case S_MakeUp: \
|
||||
a0 += TabEnt->Param; \
|
||||
RunLength += TabEnt->Param; \
|
||||
break; \
|
||||
default: \
|
||||
goto badBlack2d; \
|
||||
} \
|
||||
} \
|
||||
doneWhite2da:; \
|
||||
for (;;) { /* then white */ \
|
||||
LOOKUP16(12, TIFFFaxWhiteTable, eof2d); \
|
||||
switch (TabEnt->State) { \
|
||||
case S_TermW: \
|
||||
SETVALUE(TabEnt->Param); \
|
||||
goto doneBlack2da; \
|
||||
case S_MakeUpW: \
|
||||
case S_MakeUp: \
|
||||
a0 += TabEnt->Param; \
|
||||
RunLength += TabEnt->Param; \
|
||||
break; \
|
||||
default: \
|
||||
goto badWhite2d; \
|
||||
} \
|
||||
} \
|
||||
doneBlack2da:; \
|
||||
} else { \
|
||||
for (;;) { /* white first */ \
|
||||
LOOKUP16(12, TIFFFaxWhiteTable, eof2d); \
|
||||
switch (TabEnt->State) { \
|
||||
case S_TermW: \
|
||||
SETVALUE(TabEnt->Param); \
|
||||
goto doneWhite2db; \
|
||||
case S_MakeUpW: \
|
||||
case S_MakeUp: \
|
||||
a0 += TabEnt->Param; \
|
||||
RunLength += TabEnt->Param; \
|
||||
break; \
|
||||
default: \
|
||||
goto badWhite2d; \
|
||||
} \
|
||||
} \
|
||||
doneWhite2db:; \
|
||||
for (;;) { /* then black */ \
|
||||
LOOKUP16(13, TIFFFaxBlackTable, eof2d); \
|
||||
switch (TabEnt->State) { \
|
||||
case S_TermB: \
|
||||
SETVALUE(TabEnt->Param); \
|
||||
goto doneBlack2db; \
|
||||
case S_MakeUpB: \
|
||||
case S_MakeUp: \
|
||||
a0 += TabEnt->Param; \
|
||||
RunLength += TabEnt->Param; \
|
||||
break; \
|
||||
default: \
|
||||
goto badBlack2d; \
|
||||
} \
|
||||
} \
|
||||
doneBlack2db:; \
|
||||
} \
|
||||
CHECK_b1; \
|
||||
break; \
|
||||
case S_V0: \
|
||||
CHECK_b1; \
|
||||
SETVALUE(b1 - a0); \
|
||||
b1 += *pb++; \
|
||||
break; \
|
||||
case S_VR: \
|
||||
CHECK_b1; \
|
||||
SETVALUE(b1 - a0 + TabEnt->Param); \
|
||||
b1 += *pb++; \
|
||||
break; \
|
||||
case S_VL: \
|
||||
CHECK_b1; \
|
||||
if (b1 <= (int) (a0 + TabEnt->Param)) { \
|
||||
if (b1 < (int) (a0 + TabEnt->Param) || pa != thisrun) { \
|
||||
unexpected("VL", a0); \
|
||||
goto eol2d; \
|
||||
} \
|
||||
} \
|
||||
SETVALUE(b1 - a0 - TabEnt->Param); \
|
||||
b1 -= *--pb; \
|
||||
break; \
|
||||
case S_Ext: \
|
||||
*pa++ = lastx - a0; \
|
||||
extension(a0); \
|
||||
goto eol2d; \
|
||||
case S_EOL: \
|
||||
*pa++ = lastx - a0; \
|
||||
NeedBits8(4,eof2d); \
|
||||
if (GetBits(4)) \
|
||||
unexpected("EOL", a0); \
|
||||
ClrBits(4); \
|
||||
EOLcnt = 1; \
|
||||
goto eol2d; \
|
||||
default: \
|
||||
badMain2d: \
|
||||
unexpected("MainTable", a0); \
|
||||
goto eol2d; \
|
||||
badBlack2d: \
|
||||
unexpected("BlackTable", a0); \
|
||||
goto eol2d; \
|
||||
badWhite2d: \
|
||||
unexpected("WhiteTable", a0); \
|
||||
goto eol2d; \
|
||||
eof2d: \
|
||||
prematureEOF(a0); \
|
||||
CLEANUP_RUNS(); \
|
||||
goto eoflab; \
|
||||
} \
|
||||
EOLcnt = 1; \
|
||||
goto eol2d; \
|
||||
default: \
|
||||
badMain2d: \
|
||||
unexpected("MainTable", a0); \
|
||||
goto eol2d; \
|
||||
badBlack2d: \
|
||||
unexpected("BlackTable", a0); \
|
||||
goto eol2d; \
|
||||
badWhite2d: \
|
||||
unexpected("WhiteTable", a0); \
|
||||
goto eol2d; \
|
||||
eof2d: \
|
||||
prematureEOF(a0); \
|
||||
CLEANUP_RUNS(); \
|
||||
goto eoflab; \
|
||||
} \
|
||||
} \
|
||||
if (RunLength) { \
|
||||
if (RunLength + a0 < lastx) { \
|
||||
/* expect a final V0 */ \
|
||||
NeedBits8(1,eof2d); \
|
||||
if (!GetBits(1)) \
|
||||
goto badMain2d; \
|
||||
ClrBits(1); \
|
||||
} \
|
||||
SETVALUE(0); \
|
||||
if (RunLength + a0 < lastx) { \
|
||||
/* expect a final V0 */ \
|
||||
NeedBits8(1,eof2d); \
|
||||
if (!GetBits(1)) \
|
||||
goto badMain2d; \
|
||||
ClrBits(1); \
|
||||
} \
|
||||
SETVALUE(0); \
|
||||
} \
|
||||
eol2d: \
|
||||
CLEANUP_RUNS(); \
|
||||
|
||||
Vendored
+32
-32
@@ -4,23 +4,23 @@
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
@@ -37,25 +37,25 @@ TIFFFlush(TIFF* tif)
|
||||
|
||||
if (!TIFFFlushData(tif))
|
||||
return (0);
|
||||
|
||||
/* In update (r+) mode we try to detect the case where
|
||||
only the strip/tile map has been altered, and we try to
|
||||
rewrite only that portion of the directory without
|
||||
|
||||
/* In update (r+) mode we try to detect the case where
|
||||
only the strip/tile map has been altered, and we try to
|
||||
rewrite only that portion of the directory without
|
||||
making any other changes */
|
||||
|
||||
|
||||
if( (tif->tif_flags & TIFF_DIRTYSTRIP)
|
||||
&& !(tif->tif_flags & TIFF_DIRTYDIRECT)
|
||||
&& !(tif->tif_flags & TIFF_DIRTYDIRECT)
|
||||
&& tif->tif_mode == O_RDWR )
|
||||
{
|
||||
uint64 *offsets=NULL, *sizes=NULL;
|
||||
|
||||
if( TIFFIsTiled(tif) )
|
||||
{
|
||||
if( TIFFGetField( tif, TIFFTAG_TILEOFFSETS, &offsets )
|
||||
&& TIFFGetField( tif, TIFFTAG_TILEBYTECOUNTS, &sizes )
|
||||
&& _TIFFRewriteField( tif, TIFFTAG_TILEOFFSETS, TIFF_LONG8,
|
||||
if( TIFFGetField( tif, TIFFTAG_TILEOFFSETS, &offsets )
|
||||
&& TIFFGetField( tif, TIFFTAG_TILEBYTECOUNTS, &sizes )
|
||||
&& _TIFFRewriteField( tif, TIFFTAG_TILEOFFSETS, TIFF_LONG8,
|
||||
tif->tif_dir.td_nstrips, offsets )
|
||||
&& _TIFFRewriteField( tif, TIFFTAG_TILEBYTECOUNTS, TIFF_LONG8,
|
||||
&& _TIFFRewriteField( tif, TIFFTAG_TILEBYTECOUNTS, TIFF_LONG8,
|
||||
tif->tif_dir.td_nstrips, sizes ) )
|
||||
{
|
||||
tif->tif_flags &= ~TIFF_DIRTYSTRIP;
|
||||
@@ -65,11 +65,11 @@ TIFFFlush(TIFF* tif)
|
||||
}
|
||||
else
|
||||
{
|
||||
if( TIFFGetField( tif, TIFFTAG_STRIPOFFSETS, &offsets )
|
||||
&& TIFFGetField( tif, TIFFTAG_STRIPBYTECOUNTS, &sizes )
|
||||
&& _TIFFRewriteField( tif, TIFFTAG_STRIPOFFSETS, TIFF_LONG8,
|
||||
if( TIFFGetField( tif, TIFFTAG_STRIPOFFSETS, &offsets )
|
||||
&& TIFFGetField( tif, TIFFTAG_STRIPBYTECOUNTS, &sizes )
|
||||
&& _TIFFRewriteField( tif, TIFFTAG_STRIPOFFSETS, TIFF_LONG8,
|
||||
tif->tif_dir.td_nstrips, offsets )
|
||||
&& _TIFFRewriteField( tif, TIFFTAG_STRIPBYTECOUNTS, TIFF_LONG8,
|
||||
&& _TIFFRewriteField( tif, TIFFTAG_STRIPBYTECOUNTS, TIFF_LONG8,
|
||||
tif->tif_dir.td_nstrips, sizes ) )
|
||||
{
|
||||
tif->tif_flags &= ~TIFF_DIRTYSTRIP;
|
||||
@@ -79,7 +79,7 @@ TIFFFlush(TIFF* tif)
|
||||
}
|
||||
}
|
||||
|
||||
if ((tif->tif_flags & (TIFF_DIRTYDIRECT|TIFF_DIRTYSTRIP))
|
||||
if ((tif->tif_flags & (TIFF_DIRTYDIRECT|TIFF_DIRTYSTRIP))
|
||||
&& !TIFFRewriteDirectory(tif))
|
||||
return (0);
|
||||
|
||||
@@ -93,19 +93,19 @@ TIFFFlush(TIFF* tif)
|
||||
* is not set, so that TIFFFlush() will proceed to write out the directory.
|
||||
* The documentation says returning 1 is an error indicator, but not having
|
||||
* been writing isn't exactly a an error. Hopefully this doesn't cause
|
||||
* problems for other people.
|
||||
* problems for other people.
|
||||
*/
|
||||
int
|
||||
TIFFFlushData(TIFF* tif)
|
||||
{
|
||||
if ((tif->tif_flags & TIFF_BEENWRITING) == 0)
|
||||
return (1);
|
||||
if (tif->tif_flags & TIFF_POSTENCODE) {
|
||||
tif->tif_flags &= ~TIFF_POSTENCODE;
|
||||
if (!(*tif->tif_postencode)(tif))
|
||||
return (0);
|
||||
}
|
||||
return (TIFFFlushData1(tif));
|
||||
if ((tif->tif_flags & TIFF_BEENWRITING) == 0)
|
||||
return (1);
|
||||
if (tif->tif_flags & TIFF_POSTENCODE) {
|
||||
tif->tif_flags &= ~TIFF_POSTENCODE;
|
||||
if (!(*tif->tif_postencode)(tif))
|
||||
return (0);
|
||||
}
|
||||
return (TIFFFlushData1(tif));
|
||||
}
|
||||
|
||||
/* vim: set ts=8 sts=8 sw=8 noet: */
|
||||
|
||||
Vendored
+1823
-1642
File diff suppressed because it is too large
Load Diff
Vendored
+113
-112
@@ -1,4 +1,4 @@
|
||||
/* $Id: tif_jbig.c,v 1.15 2010-03-10 18:56:48 bfriesen Exp $ */
|
||||
/* $Id: tif_jbig.c,v 1.16 2017-06-26 15:20:00 erouault Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@@ -39,165 +39,166 @@
|
||||
|
||||
static int JBIGSetupDecode(TIFF* tif)
|
||||
{
|
||||
if (TIFFNumberOfStrips(tif) != 1)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, "JBIG", "Multistrip images not supported in decoder");
|
||||
return 0;
|
||||
}
|
||||
if (TIFFNumberOfStrips(tif) != 1)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, "JBIG", "Multistrip images not supported in decoder");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int JBIGDecode(TIFF* tif, uint8* buffer, tmsize_t size, uint16 s)
|
||||
{
|
||||
struct jbg_dec_state decoder;
|
||||
int decodeStatus = 0;
|
||||
unsigned char* pImage = NULL;
|
||||
(void) size, (void) s;
|
||||
struct jbg_dec_state decoder;
|
||||
int decodeStatus = 0;
|
||||
unsigned char* pImage = NULL;
|
||||
(void) size, (void) s;
|
||||
|
||||
if (isFillOrder(tif, tif->tif_dir.td_fillorder))
|
||||
{
|
||||
TIFFReverseBits(tif->tif_rawdata, tif->tif_rawdatasize);
|
||||
}
|
||||
if (isFillOrder(tif, tif->tif_dir.td_fillorder))
|
||||
{
|
||||
TIFFReverseBits(tif->tif_rawdata, tif->tif_rawdatasize);
|
||||
}
|
||||
|
||||
jbg_dec_init(&decoder);
|
||||
jbg_dec_init(&decoder);
|
||||
|
||||
#if defined(HAVE_JBG_NEWLEN)
|
||||
jbg_newlen(tif->tif_rawdata, (size_t)tif->tif_rawdatasize);
|
||||
/*
|
||||
* I do not check the return status of jbg_newlen because even if this
|
||||
* function fails it does not necessarily mean that decoding the image
|
||||
* will fail. It is generally only needed for received fax images
|
||||
* that do not contain the actual length of the image in the BIE
|
||||
* header. I do not log when an error occurs because that will cause
|
||||
* problems when converting JBIG encoded TIFF's to
|
||||
* PostScript. As long as the actual image length is contained in the
|
||||
* BIE header jbg_dec_in should succeed.
|
||||
*/
|
||||
jbg_newlen(tif->tif_rawdata, (size_t)tif->tif_rawdatasize);
|
||||
/*
|
||||
* I do not check the return status of jbg_newlen because even if this
|
||||
* function fails it does not necessarily mean that decoding the image
|
||||
* will fail. It is generally only needed for received fax images
|
||||
* that do not contain the actual length of the image in the BIE
|
||||
* header. I do not log when an error occurs because that will cause
|
||||
* problems when converting JBIG encoded TIFF's to
|
||||
* PostScript. As long as the actual image length is contained in the
|
||||
* BIE header jbg_dec_in should succeed.
|
||||
*/
|
||||
#endif /* HAVE_JBG_NEWLEN */
|
||||
|
||||
decodeStatus = jbg_dec_in(&decoder, (unsigned char*)tif->tif_rawdata,
|
||||
(size_t)tif->tif_rawdatasize, NULL);
|
||||
if (JBG_EOK != decodeStatus)
|
||||
{
|
||||
/*
|
||||
* XXX: JBG_EN constant was defined in pre-2.0 releases of the
|
||||
* JBIG-KIT. Since the 2.0 the error reporting functions were
|
||||
* changed. We will handle both cases here.
|
||||
*/
|
||||
TIFFErrorExt(tif->tif_clientdata,
|
||||
"JBIG", "Error (%d) decoding: %s",
|
||||
decodeStatus,
|
||||
decodeStatus = jbg_dec_in(&decoder, (unsigned char*)tif->tif_rawdata,
|
||||
(size_t)tif->tif_rawdatasize, NULL);
|
||||
if (JBG_EOK != decodeStatus)
|
||||
{
|
||||
/*
|
||||
* XXX: JBG_EN constant was defined in pre-2.0 releases of the
|
||||
* JBIG-KIT. Since the 2.0 the error reporting functions were
|
||||
* changed. We will handle both cases here.
|
||||
*/
|
||||
TIFFErrorExt(tif->tif_clientdata,
|
||||
"JBIG", "Error (%d) decoding: %s",
|
||||
decodeStatus,
|
||||
#if defined(JBG_EN)
|
||||
jbg_strerror(decodeStatus, JBG_EN)
|
||||
jbg_strerror(decodeStatus, JBG_EN)
|
||||
#else
|
||||
jbg_strerror(decodeStatus)
|
||||
jbg_strerror(decodeStatus)
|
||||
#endif
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
);
|
||||
jbg_dec_free(&decoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
pImage = jbg_dec_getimage(&decoder, 0);
|
||||
_TIFFmemcpy(buffer, pImage, jbg_dec_getsize(&decoder));
|
||||
jbg_dec_free(&decoder);
|
||||
return 1;
|
||||
pImage = jbg_dec_getimage(&decoder, 0);
|
||||
_TIFFmemcpy(buffer, pImage, jbg_dec_getsize(&decoder));
|
||||
jbg_dec_free(&decoder);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int JBIGSetupEncode(TIFF* tif)
|
||||
{
|
||||
if (TIFFNumberOfStrips(tif) != 1)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, "JBIG", "Multistrip images not supported in encoder");
|
||||
return 0;
|
||||
}
|
||||
if (TIFFNumberOfStrips(tif) != 1)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, "JBIG", "Multistrip images not supported in encoder");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int JBIGCopyEncodedData(TIFF* tif, unsigned char* pp, size_t cc, uint16 s)
|
||||
{
|
||||
(void) s;
|
||||
while (cc > 0)
|
||||
{
|
||||
tmsize_t n = (tmsize_t)cc;
|
||||
(void) s;
|
||||
while (cc > 0)
|
||||
{
|
||||
tmsize_t n = (tmsize_t)cc;
|
||||
|
||||
if (tif->tif_rawcc + n > tif->tif_rawdatasize)
|
||||
{
|
||||
n = tif->tif_rawdatasize - tif->tif_rawcc;
|
||||
}
|
||||
if (tif->tif_rawcc + n > tif->tif_rawdatasize)
|
||||
{
|
||||
n = tif->tif_rawdatasize - tif->tif_rawcc;
|
||||
}
|
||||
|
||||
assert(n > 0);
|
||||
_TIFFmemcpy(tif->tif_rawcp, pp, n);
|
||||
tif->tif_rawcp += n;
|
||||
tif->tif_rawcc += n;
|
||||
pp += n;
|
||||
cc -= (size_t)n;
|
||||
if (tif->tif_rawcc >= tif->tif_rawdatasize &&
|
||||
!TIFFFlushData1(tif))
|
||||
{
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
assert(n > 0);
|
||||
_TIFFmemcpy(tif->tif_rawcp, pp, n);
|
||||
tif->tif_rawcp += n;
|
||||
tif->tif_rawcc += n;
|
||||
pp += n;
|
||||
cc -= (size_t)n;
|
||||
if (tif->tif_rawcc >= tif->tif_rawdatasize &&
|
||||
!TIFFFlushData1(tif))
|
||||
{
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
return (1);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static void JBIGOutputBie(unsigned char* buffer, size_t len, void* userData)
|
||||
{
|
||||
TIFF* tif = (TIFF*)userData;
|
||||
TIFF* tif = (TIFF*)userData;
|
||||
|
||||
if (isFillOrder(tif, tif->tif_dir.td_fillorder))
|
||||
{
|
||||
TIFFReverseBits(buffer, (tmsize_t)len);
|
||||
}
|
||||
if (isFillOrder(tif, tif->tif_dir.td_fillorder))
|
||||
{
|
||||
TIFFReverseBits(buffer, (tmsize_t)len);
|
||||
}
|
||||
|
||||
JBIGCopyEncodedData(tif, buffer, len, 0);
|
||||
JBIGCopyEncodedData(tif, buffer, len, 0);
|
||||
}
|
||||
|
||||
static int JBIGEncode(TIFF* tif, uint8* buffer, tmsize_t size, uint16 s)
|
||||
{
|
||||
TIFFDirectory* dir = &tif->tif_dir;
|
||||
struct jbg_enc_state encoder;
|
||||
TIFFDirectory* dir = &tif->tif_dir;
|
||||
struct jbg_enc_state encoder;
|
||||
|
||||
(void) size, (void) s;
|
||||
(void) size, (void) s;
|
||||
|
||||
jbg_enc_init(&encoder,
|
||||
dir->td_imagewidth,
|
||||
dir->td_imagelength,
|
||||
1,
|
||||
&buffer,
|
||||
JBIGOutputBie,
|
||||
tif);
|
||||
/*
|
||||
* jbg_enc_out does the "real" encoding. As data is encoded,
|
||||
* JBIGOutputBie is called, which writes the data to the directory.
|
||||
*/
|
||||
jbg_enc_out(&encoder);
|
||||
jbg_enc_free(&encoder);
|
||||
jbg_enc_init(&encoder,
|
||||
dir->td_imagewidth,
|
||||
dir->td_imagelength,
|
||||
1,
|
||||
&buffer,
|
||||
JBIGOutputBie,
|
||||
tif);
|
||||
/*
|
||||
* jbg_enc_out does the "real" encoding. As data is encoded,
|
||||
* JBIGOutputBie is called, which writes the data to the directory.
|
||||
*/
|
||||
jbg_enc_out(&encoder);
|
||||
jbg_enc_free(&encoder);
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int TIFFInitJBIG(TIFF* tif, int scheme)
|
||||
{
|
||||
assert(scheme == COMPRESSION_JBIG);
|
||||
assert(scheme == COMPRESSION_JBIG);
|
||||
|
||||
/*
|
||||
* These flags are set so the JBIG Codec can control when to reverse
|
||||
* bits and when not to and to allow the jbig decoder and bit reverser
|
||||
* to write to memory when necessary.
|
||||
*/
|
||||
tif->tif_flags |= TIFF_NOBITREV;
|
||||
tif->tif_flags &= ~TIFF_MAPPED;
|
||||
/*
|
||||
* These flags are set so the JBIG Codec can control when to reverse
|
||||
* bits and when not to and to allow the jbig decoder and bit reverser
|
||||
* to write to memory when necessary.
|
||||
*/
|
||||
tif->tif_flags |= TIFF_NOBITREV;
|
||||
tif->tif_flags &= ~TIFF_MAPPED;
|
||||
|
||||
/* Setup the function pointers for encode, decode, and cleanup. */
|
||||
tif->tif_setupdecode = JBIGSetupDecode;
|
||||
tif->tif_decodestrip = JBIGDecode;
|
||||
/* Setup the function pointers for encode, decode, and cleanup. */
|
||||
tif->tif_setupdecode = JBIGSetupDecode;
|
||||
tif->tif_decodestrip = JBIGDecode;
|
||||
|
||||
tif->tif_setupencode = JBIGSetupEncode;
|
||||
tif->tif_encodestrip = JBIGEncode;
|
||||
tif->tif_setupencode = JBIGSetupEncode;
|
||||
tif->tif_encodestrip = JBIGEncode;
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* JBIG_SUPPORT */
|
||||
|
||||
Vendored
+1684
-1384
File diff suppressed because it is too large
Load Diff
Vendored
+5
-1
@@ -4,6 +4,10 @@
|
||||
#if defined(JPEG_DUAL_MODE_8_12)
|
||||
|
||||
# define TIFFInitJPEG TIFFInitJPEG_12
|
||||
# define TIFFJPEGIsFullStripRequired TIFFJPEGIsFullStripRequired_12
|
||||
|
||||
int
|
||||
TIFFInitJPEG_12(TIFF* tif, int scheme);
|
||||
|
||||
# include LIBJPEG_12_PATH
|
||||
|
||||
@@ -40,7 +44,7 @@ int TIFFReInitJPEG_12( TIFF *tif, int scheme, int is_encode )
|
||||
tif->tif_postencode = JPEGPostEncode;
|
||||
tif->tif_encoderow = JPEGEncode;
|
||||
tif->tif_encodestrip = JPEGEncode;
|
||||
tif->tif_encodetile = JPEGEncode;
|
||||
tif->tif_encodetile = JPEGEncode;
|
||||
tif->tif_cleanup = JPEGCleanup;
|
||||
tif->tif_defstripsize = JPEGDefaultStripSize;
|
||||
tif->tif_deftilesize = JPEGDefaultTileSize;
|
||||
|
||||
Vendored
+1157
-1075
File diff suppressed because it is too large
Load Diff
Vendored
+312
-312
@@ -1,4 +1,4 @@
|
||||
/* $Id: tif_lzma.c,v 1.4 2011-12-22 00:29:29 bfriesen Exp $ */
|
||||
/* $Id: tif_lzma.c,v 1.6 2016-09-17 09:18:59 erouault Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2010, Andrey Kiselev <dron@ak4719.spb.edu>
|
||||
@@ -44,19 +44,19 @@
|
||||
* State block for each open TIFF file using LZMA2 compression/decompression.
|
||||
*/
|
||||
typedef struct {
|
||||
TIFFPredictorState predict;
|
||||
TIFFPredictorState predict;
|
||||
lzma_stream stream;
|
||||
lzma_filter filters[LZMA_FILTERS_MAX + 1];
|
||||
lzma_options_delta opt_delta; /* delta filter options */
|
||||
lzma_options_lzma opt_lzma; /* LZMA2 filter options */
|
||||
int preset; /* compression level */
|
||||
lzma_check check; /* type of the integrity check */
|
||||
int state; /* state flags */
|
||||
lzma_filter filters[LZMA_FILTERS_MAX + 1];
|
||||
lzma_options_delta opt_delta; /* delta filter options */
|
||||
lzma_options_lzma opt_lzma; /* LZMA2 filter options */
|
||||
int preset; /* compression level */
|
||||
lzma_check check; /* type of the integrity check */
|
||||
int state; /* state flags */
|
||||
#define LSTATE_INIT_DECODE 0x01
|
||||
#define LSTATE_INIT_ENCODE 0x02
|
||||
|
||||
TIFFVGetMethod vgetparent; /* super-class method */
|
||||
TIFFVSetMethod vsetparent; /* super-class method */
|
||||
TIFFVGetMethod vgetparent; /* super-class method */
|
||||
TIFFVSetMethod vsetparent; /* super-class method */
|
||||
} LZMAState;
|
||||
|
||||
#define LState(tif) ((LZMAState*) (tif)->tif_data)
|
||||
@@ -69,58 +69,58 @@ static int LZMADecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s);
|
||||
static const char *
|
||||
LZMAStrerror(lzma_ret ret)
|
||||
{
|
||||
switch (ret) {
|
||||
case LZMA_OK:
|
||||
return "operation completed successfully";
|
||||
case LZMA_STREAM_END:
|
||||
return "end of stream was reached";
|
||||
case LZMA_NO_CHECK:
|
||||
return "input stream has no integrity check";
|
||||
case LZMA_UNSUPPORTED_CHECK:
|
||||
return "cannot calculate the integrity check";
|
||||
case LZMA_GET_CHECK:
|
||||
return "integrity check type is now available";
|
||||
case LZMA_MEM_ERROR:
|
||||
return "cannot allocate memory";
|
||||
case LZMA_MEMLIMIT_ERROR:
|
||||
return "memory usage limit was reached";
|
||||
case LZMA_FORMAT_ERROR:
|
||||
return "file format not recognized";
|
||||
case LZMA_OPTIONS_ERROR:
|
||||
return "invalid or unsupported options";
|
||||
case LZMA_DATA_ERROR:
|
||||
return "data is corrupt";
|
||||
case LZMA_BUF_ERROR:
|
||||
return "no progress is possible (stream is truncated or corrupt)";
|
||||
case LZMA_PROG_ERROR:
|
||||
return "programming error";
|
||||
default:
|
||||
return "unindentified liblzma error";
|
||||
}
|
||||
switch (ret) {
|
||||
case LZMA_OK:
|
||||
return "operation completed successfully";
|
||||
case LZMA_STREAM_END:
|
||||
return "end of stream was reached";
|
||||
case LZMA_NO_CHECK:
|
||||
return "input stream has no integrity check";
|
||||
case LZMA_UNSUPPORTED_CHECK:
|
||||
return "cannot calculate the integrity check";
|
||||
case LZMA_GET_CHECK:
|
||||
return "integrity check type is now available";
|
||||
case LZMA_MEM_ERROR:
|
||||
return "cannot allocate memory";
|
||||
case LZMA_MEMLIMIT_ERROR:
|
||||
return "memory usage limit was reached";
|
||||
case LZMA_FORMAT_ERROR:
|
||||
return "file format not recognized";
|
||||
case LZMA_OPTIONS_ERROR:
|
||||
return "invalid or unsupported options";
|
||||
case LZMA_DATA_ERROR:
|
||||
return "data is corrupt";
|
||||
case LZMA_BUF_ERROR:
|
||||
return "no progress is possible (stream is truncated or corrupt)";
|
||||
case LZMA_PROG_ERROR:
|
||||
return "programming error";
|
||||
default:
|
||||
return "unidentified liblzma error";
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
LZMAFixupTags(TIFF* tif)
|
||||
{
|
||||
(void) tif;
|
||||
return 1;
|
||||
(void) tif;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
LZMASetupDecode(TIFF* tif)
|
||||
{
|
||||
LZMAState* sp = DecoderState(tif);
|
||||
|
||||
assert(sp != NULL);
|
||||
LZMAState* sp = DecoderState(tif);
|
||||
|
||||
assert(sp != NULL);
|
||||
|
||||
/* if we were last encoding, terminate this mode */
|
||||
if (sp->state & LSTATE_INIT_ENCODE) {
|
||||
lzma_end(&sp->stream);
|
||||
sp->state = 0;
|
||||
}
|
||||
if (sp->state & LSTATE_INIT_ENCODE) {
|
||||
lzma_end(&sp->stream);
|
||||
sp->state = 0;
|
||||
}
|
||||
|
||||
sp->state |= LSTATE_INIT_DECODE;
|
||||
return 1;
|
||||
sp->state |= LSTATE_INIT_DECODE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -129,116 +129,116 @@ LZMASetupDecode(TIFF* tif)
|
||||
static int
|
||||
LZMAPreDecode(TIFF* tif, uint16 s)
|
||||
{
|
||||
static const char module[] = "LZMAPreDecode";
|
||||
LZMAState* sp = DecoderState(tif);
|
||||
lzma_ret ret;
|
||||
static const char module[] = "LZMAPreDecode";
|
||||
LZMAState* sp = DecoderState(tif);
|
||||
lzma_ret ret;
|
||||
|
||||
(void) s;
|
||||
assert(sp != NULL);
|
||||
(void) s;
|
||||
assert(sp != NULL);
|
||||
|
||||
if( (sp->state & LSTATE_INIT_DECODE) == 0 )
|
||||
if( (sp->state & LSTATE_INIT_DECODE) == 0 )
|
||||
tif->tif_setupdecode(tif);
|
||||
|
||||
sp->stream.next_in = tif->tif_rawdata;
|
||||
sp->stream.avail_in = (size_t) tif->tif_rawcc;
|
||||
if ((tmsize_t)sp->stream.avail_in != tif->tif_rawcc) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Liblzma cannot deal with buffers this size");
|
||||
return 0;
|
||||
}
|
||||
sp->stream.next_in = tif->tif_rawdata;
|
||||
sp->stream.avail_in = (size_t) tif->tif_rawcc;
|
||||
if ((tmsize_t)sp->stream.avail_in != tif->tif_rawcc) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Liblzma cannot deal with buffers this size");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Disable memory limit when decoding. UINT64_MAX is a flag to disable
|
||||
* the limit, we are passing (uint64_t)-1 which should be the same.
|
||||
*/
|
||||
ret = lzma_stream_decoder(&sp->stream, (uint64_t)-1, 0);
|
||||
if (ret != LZMA_OK) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Error initializing the stream decoder, %s",
|
||||
LZMAStrerror(ret));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
/*
|
||||
* Disable memory limit when decoding. UINT64_MAX is a flag to disable
|
||||
* the limit, we are passing (uint64_t)-1 which should be the same.
|
||||
*/
|
||||
ret = lzma_stream_decoder(&sp->stream, (uint64_t)-1, 0);
|
||||
if (ret != LZMA_OK) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Error initializing the stream decoder, %s",
|
||||
LZMAStrerror(ret));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
LZMADecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s)
|
||||
{
|
||||
static const char module[] = "LZMADecode";
|
||||
LZMAState* sp = DecoderState(tif);
|
||||
static const char module[] = "LZMADecode";
|
||||
LZMAState* sp = DecoderState(tif);
|
||||
|
||||
(void) s;
|
||||
assert(sp != NULL);
|
||||
assert(sp->state == LSTATE_INIT_DECODE);
|
||||
(void) s;
|
||||
assert(sp != NULL);
|
||||
assert(sp->state == LSTATE_INIT_DECODE);
|
||||
|
||||
sp->stream.next_in = tif->tif_rawcp;
|
||||
sp->stream.avail_in = (size_t) tif->tif_rawcc;
|
||||
|
||||
sp->stream.next_out = op;
|
||||
sp->stream.avail_out = (size_t) occ;
|
||||
if ((tmsize_t)sp->stream.avail_out != occ) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Liblzma cannot deal with buffers this size");
|
||||
return 0;
|
||||
}
|
||||
sp->stream.next_out = op;
|
||||
sp->stream.avail_out = (size_t) occ;
|
||||
if ((tmsize_t)sp->stream.avail_out != occ) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Liblzma cannot deal with buffers this size");
|
||||
return 0;
|
||||
}
|
||||
|
||||
do {
|
||||
/*
|
||||
* Save the current stream state to properly recover from the
|
||||
* decoding errors later.
|
||||
*/
|
||||
const uint8_t *next_in = sp->stream.next_in;
|
||||
size_t avail_in = sp->stream.avail_in;
|
||||
do {
|
||||
/*
|
||||
* Save the current stream state to properly recover from the
|
||||
* decoding errors later.
|
||||
*/
|
||||
const uint8_t *next_in = sp->stream.next_in;
|
||||
size_t avail_in = sp->stream.avail_in;
|
||||
|
||||
lzma_ret ret = lzma_code(&sp->stream, LZMA_RUN);
|
||||
if (ret == LZMA_STREAM_END)
|
||||
break;
|
||||
if (ret == LZMA_MEMLIMIT_ERROR) {
|
||||
lzma_ret r = lzma_stream_decoder(&sp->stream,
|
||||
lzma_memusage(&sp->stream), 0);
|
||||
if (r != LZMA_OK) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Error initializing the stream decoder, %s",
|
||||
LZMAStrerror(r));
|
||||
break;
|
||||
}
|
||||
sp->stream.next_in = next_in;
|
||||
sp->stream.avail_in = avail_in;
|
||||
continue;
|
||||
}
|
||||
if (ret != LZMA_OK) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Decoding error at scanline %lu, %s",
|
||||
(unsigned long) tif->tif_row, LZMAStrerror(ret));
|
||||
break;
|
||||
}
|
||||
} while (sp->stream.avail_out > 0);
|
||||
if (sp->stream.avail_out != 0) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Not enough data at scanline %lu (short %lu bytes)",
|
||||
(unsigned long) tif->tif_row, (unsigned long) sp->stream.avail_out);
|
||||
return 0;
|
||||
}
|
||||
lzma_ret ret = lzma_code(&sp->stream, LZMA_RUN);
|
||||
if (ret == LZMA_STREAM_END)
|
||||
break;
|
||||
if (ret == LZMA_MEMLIMIT_ERROR) {
|
||||
lzma_ret r = lzma_stream_decoder(&sp->stream,
|
||||
lzma_memusage(&sp->stream), 0);
|
||||
if (r != LZMA_OK) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Error initializing the stream decoder, %s",
|
||||
LZMAStrerror(r));
|
||||
break;
|
||||
}
|
||||
sp->stream.next_in = next_in;
|
||||
sp->stream.avail_in = avail_in;
|
||||
continue;
|
||||
}
|
||||
if (ret != LZMA_OK) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Decoding error at scanline %lu, %s",
|
||||
(unsigned long) tif->tif_row, LZMAStrerror(ret));
|
||||
break;
|
||||
}
|
||||
} while (sp->stream.avail_out > 0);
|
||||
if (sp->stream.avail_out != 0) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Not enough data at scanline %lu (short %lu bytes)",
|
||||
(unsigned long) tif->tif_row, (unsigned long) sp->stream.avail_out);
|
||||
return 0;
|
||||
}
|
||||
|
||||
tif->tif_rawcp = (uint8 *)sp->stream.next_in; /* cast away const */
|
||||
tif->tif_rawcc = sp->stream.avail_in;
|
||||
|
||||
return 1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
LZMASetupEncode(TIFF* tif)
|
||||
{
|
||||
LZMAState* sp = EncoderState(tif);
|
||||
LZMAState* sp = EncoderState(tif);
|
||||
|
||||
assert(sp != NULL);
|
||||
if (sp->state & LSTATE_INIT_DECODE) {
|
||||
lzma_end(&sp->stream);
|
||||
sp->state = 0;
|
||||
}
|
||||
assert(sp != NULL);
|
||||
if (sp->state & LSTATE_INIT_DECODE) {
|
||||
lzma_end(&sp->stream);
|
||||
sp->state = 0;
|
||||
}
|
||||
|
||||
sp->state |= LSTATE_INIT_ENCODE;
|
||||
return 1;
|
||||
sp->state |= LSTATE_INIT_ENCODE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -247,22 +247,22 @@ LZMASetupEncode(TIFF* tif)
|
||||
static int
|
||||
LZMAPreEncode(TIFF* tif, uint16 s)
|
||||
{
|
||||
static const char module[] = "LZMAPreEncode";
|
||||
LZMAState *sp = EncoderState(tif);
|
||||
static const char module[] = "LZMAPreEncode";
|
||||
LZMAState *sp = EncoderState(tif);
|
||||
|
||||
(void) s;
|
||||
assert(sp != NULL);
|
||||
if( sp->state != LSTATE_INIT_ENCODE )
|
||||
(void) s;
|
||||
assert(sp != NULL);
|
||||
if( sp->state != LSTATE_INIT_ENCODE )
|
||||
tif->tif_setupencode(tif);
|
||||
|
||||
sp->stream.next_out = tif->tif_rawdata;
|
||||
sp->stream.avail_out = (size_t)tif->tif_rawdatasize;
|
||||
if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Liblzma cannot deal with buffers this size");
|
||||
return 0;
|
||||
}
|
||||
return (lzma_stream_encoder(&sp->stream, sp->filters, sp->check) == LZMA_OK);
|
||||
sp->stream.next_out = tif->tif_rawdata;
|
||||
sp->stream.avail_out = (size_t)tif->tif_rawdatasize;
|
||||
if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Liblzma cannot deal with buffers this size");
|
||||
return 0;
|
||||
}
|
||||
return (lzma_stream_encoder(&sp->stream, sp->filters, sp->check) == LZMA_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -271,36 +271,36 @@ LZMAPreEncode(TIFF* tif, uint16 s)
|
||||
static int
|
||||
LZMAEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
|
||||
{
|
||||
static const char module[] = "LZMAEncode";
|
||||
LZMAState *sp = EncoderState(tif);
|
||||
static const char module[] = "LZMAEncode";
|
||||
LZMAState *sp = EncoderState(tif);
|
||||
|
||||
assert(sp != NULL);
|
||||
assert(sp->state == LSTATE_INIT_ENCODE);
|
||||
assert(sp != NULL);
|
||||
assert(sp->state == LSTATE_INIT_ENCODE);
|
||||
|
||||
(void) s;
|
||||
sp->stream.next_in = bp;
|
||||
sp->stream.avail_in = (size_t) cc;
|
||||
if ((tmsize_t)sp->stream.avail_in != cc) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Liblzma cannot deal with buffers this size");
|
||||
return 0;
|
||||
}
|
||||
do {
|
||||
lzma_ret ret = lzma_code(&sp->stream, LZMA_RUN);
|
||||
if (ret != LZMA_OK) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Encoding error at scanline %lu, %s",
|
||||
(unsigned long) tif->tif_row, LZMAStrerror(ret));
|
||||
return 0;
|
||||
}
|
||||
if (sp->stream.avail_out == 0) {
|
||||
tif->tif_rawcc = tif->tif_rawdatasize;
|
||||
TIFFFlushData1(tif);
|
||||
sp->stream.next_out = tif->tif_rawdata;
|
||||
sp->stream.avail_out = (size_t)tif->tif_rawdatasize; /* this is a safe typecast, as check is made already in LZMAPreEncode */
|
||||
}
|
||||
} while (sp->stream.avail_in > 0);
|
||||
return 1;
|
||||
(void) s;
|
||||
sp->stream.next_in = bp;
|
||||
sp->stream.avail_in = (size_t) cc;
|
||||
if ((tmsize_t)sp->stream.avail_in != cc) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Liblzma cannot deal with buffers this size");
|
||||
return 0;
|
||||
}
|
||||
do {
|
||||
lzma_ret ret = lzma_code(&sp->stream, LZMA_RUN);
|
||||
if (ret != LZMA_OK) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Encoding error at scanline %lu, %s",
|
||||
(unsigned long) tif->tif_row, LZMAStrerror(ret));
|
||||
return 0;
|
||||
}
|
||||
if (sp->stream.avail_out == 0) {
|
||||
tif->tif_rawcc = tif->tif_rawdatasize;
|
||||
TIFFFlushData1(tif);
|
||||
sp->stream.next_out = tif->tif_rawdata;
|
||||
sp->stream.avail_out = (size_t)tif->tif_rawdatasize; /* this is a safe typecast, as check is made already in LZMAPreEncode */
|
||||
}
|
||||
} while (sp->stream.avail_in > 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -310,186 +310,186 @@ LZMAEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
|
||||
static int
|
||||
LZMAPostEncode(TIFF* tif)
|
||||
{
|
||||
static const char module[] = "LZMAPostEncode";
|
||||
LZMAState *sp = EncoderState(tif);
|
||||
lzma_ret ret;
|
||||
static const char module[] = "LZMAPostEncode";
|
||||
LZMAState *sp = EncoderState(tif);
|
||||
lzma_ret ret;
|
||||
|
||||
sp->stream.avail_in = 0;
|
||||
do {
|
||||
ret = lzma_code(&sp->stream, LZMA_FINISH);
|
||||
switch (ret) {
|
||||
case LZMA_STREAM_END:
|
||||
case LZMA_OK:
|
||||
if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize) {
|
||||
tif->tif_rawcc =
|
||||
tif->tif_rawdatasize - sp->stream.avail_out;
|
||||
TIFFFlushData1(tif);
|
||||
sp->stream.next_out = tif->tif_rawdata;
|
||||
sp->stream.avail_out = (size_t)tif->tif_rawdatasize; /* this is a safe typecast, as check is made already in ZIPPreEncode */
|
||||
}
|
||||
break;
|
||||
default:
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "Liblzma error: %s",
|
||||
LZMAStrerror(ret));
|
||||
return 0;
|
||||
}
|
||||
} while (ret != LZMA_STREAM_END);
|
||||
return 1;
|
||||
sp->stream.avail_in = 0;
|
||||
do {
|
||||
ret = lzma_code(&sp->stream, LZMA_FINISH);
|
||||
switch (ret) {
|
||||
case LZMA_STREAM_END:
|
||||
case LZMA_OK:
|
||||
if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize) {
|
||||
tif->tif_rawcc =
|
||||
tif->tif_rawdatasize - sp->stream.avail_out;
|
||||
TIFFFlushData1(tif);
|
||||
sp->stream.next_out = tif->tif_rawdata;
|
||||
sp->stream.avail_out = (size_t)tif->tif_rawdatasize; /* this is a safe typecast, as check is made already in ZIPPreEncode */
|
||||
}
|
||||
break;
|
||||
default:
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "Liblzma error: %s",
|
||||
LZMAStrerror(ret));
|
||||
return 0;
|
||||
}
|
||||
} while (ret != LZMA_STREAM_END);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
LZMACleanup(TIFF* tif)
|
||||
{
|
||||
LZMAState* sp = LState(tif);
|
||||
LZMAState* sp = LState(tif);
|
||||
|
||||
assert(sp != 0);
|
||||
assert(sp != 0);
|
||||
|
||||
(void)TIFFPredictorCleanup(tif);
|
||||
(void)TIFFPredictorCleanup(tif);
|
||||
|
||||
tif->tif_tagmethods.vgetfield = sp->vgetparent;
|
||||
tif->tif_tagmethods.vsetfield = sp->vsetparent;
|
||||
tif->tif_tagmethods.vgetfield = sp->vgetparent;
|
||||
tif->tif_tagmethods.vsetfield = sp->vsetparent;
|
||||
|
||||
if (sp->state) {
|
||||
lzma_end(&sp->stream);
|
||||
sp->state = 0;
|
||||
}
|
||||
_TIFFfree(sp);
|
||||
tif->tif_data = NULL;
|
||||
if (sp->state) {
|
||||
lzma_end(&sp->stream);
|
||||
sp->state = 0;
|
||||
}
|
||||
_TIFFfree(sp);
|
||||
tif->tif_data = NULL;
|
||||
|
||||
_TIFFSetDefaultCompressionState(tif);
|
||||
_TIFFSetDefaultCompressionState(tif);
|
||||
}
|
||||
|
||||
static int
|
||||
LZMAVSetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
{
|
||||
static const char module[] = "LZMAVSetField";
|
||||
LZMAState* sp = LState(tif);
|
||||
static const char module[] = "LZMAVSetField";
|
||||
LZMAState* sp = LState(tif);
|
||||
|
||||
switch (tag) {
|
||||
case TIFFTAG_LZMAPRESET:
|
||||
sp->preset = (int) va_arg(ap, int);
|
||||
lzma_lzma_preset(&sp->opt_lzma, sp->preset);
|
||||
if (sp->state & LSTATE_INIT_ENCODE) {
|
||||
lzma_ret ret = lzma_stream_encoder(&sp->stream,
|
||||
sp->filters,
|
||||
sp->check);
|
||||
if (ret != LZMA_OK) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Liblzma error: %s",
|
||||
LZMAStrerror(ret));
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
default:
|
||||
return (*sp->vsetparent)(tif, tag, ap);
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
switch (tag) {
|
||||
case TIFFTAG_LZMAPRESET:
|
||||
sp->preset = (int) va_arg(ap, int);
|
||||
lzma_lzma_preset(&sp->opt_lzma, sp->preset);
|
||||
if (sp->state & LSTATE_INIT_ENCODE) {
|
||||
lzma_ret ret = lzma_stream_encoder(&sp->stream,
|
||||
sp->filters,
|
||||
sp->check);
|
||||
if (ret != LZMA_OK) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Liblzma error: %s",
|
||||
LZMAStrerror(ret));
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
default:
|
||||
return (*sp->vsetparent)(tif, tag, ap);
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
static int
|
||||
LZMAVGetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
{
|
||||
LZMAState* sp = LState(tif);
|
||||
LZMAState* sp = LState(tif);
|
||||
|
||||
switch (tag) {
|
||||
case TIFFTAG_LZMAPRESET:
|
||||
*va_arg(ap, int*) = sp->preset;
|
||||
break;
|
||||
default:
|
||||
return (*sp->vgetparent)(tif, tag, ap);
|
||||
}
|
||||
return 1;
|
||||
switch (tag) {
|
||||
case TIFFTAG_LZMAPRESET:
|
||||
*va_arg(ap, int*) = sp->preset;
|
||||
break;
|
||||
default:
|
||||
return (*sp->vgetparent)(tif, tag, ap);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const TIFFField lzmaFields[] = {
|
||||
{ TIFFTAG_LZMAPRESET, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, TIFF_SETGET_UNDEFINED,
|
||||
FIELD_PSEUDO, TRUE, FALSE, "LZMA2 Compression Preset", NULL },
|
||||
{ TIFFTAG_LZMAPRESET, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, TIFF_SETGET_UNDEFINED,
|
||||
FIELD_PSEUDO, TRUE, FALSE, "LZMA2 Compression Preset", NULL },
|
||||
};
|
||||
|
||||
int
|
||||
TIFFInitLZMA(TIFF* tif, int scheme)
|
||||
{
|
||||
static const char module[] = "TIFFInitLZMA";
|
||||
LZMAState* sp;
|
||||
lzma_stream tmp_stream = LZMA_STREAM_INIT;
|
||||
static const char module[] = "TIFFInitLZMA";
|
||||
LZMAState* sp;
|
||||
lzma_stream tmp_stream = LZMA_STREAM_INIT;
|
||||
|
||||
assert( scheme == COMPRESSION_LZMA );
|
||||
assert( scheme == COMPRESSION_LZMA );
|
||||
|
||||
/*
|
||||
* Merge codec-specific tag information.
|
||||
*/
|
||||
if (!_TIFFMergeFields(tif, lzmaFields, TIFFArrayCount(lzmaFields))) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Merging LZMA2 codec-specific tags failed");
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Merge codec-specific tag information.
|
||||
*/
|
||||
if (!_TIFFMergeFields(tif, lzmaFields, TIFFArrayCount(lzmaFields))) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Merging LZMA2 codec-specific tags failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate state block so tag methods have storage to record values.
|
||||
*/
|
||||
tif->tif_data = (uint8*) _TIFFmalloc(sizeof(LZMAState));
|
||||
if (tif->tif_data == NULL)
|
||||
goto bad;
|
||||
sp = LState(tif);
|
||||
memcpy(&sp->stream, &tmp_stream, sizeof(lzma_stream));
|
||||
/*
|
||||
* Allocate state block so tag methods have storage to record values.
|
||||
*/
|
||||
tif->tif_data = (uint8*) _TIFFmalloc(sizeof(LZMAState));
|
||||
if (tif->tif_data == NULL)
|
||||
goto bad;
|
||||
sp = LState(tif);
|
||||
memcpy(&sp->stream, &tmp_stream, sizeof(lzma_stream));
|
||||
|
||||
/*
|
||||
* Override parent get/set field methods.
|
||||
*/
|
||||
sp->vgetparent = tif->tif_tagmethods.vgetfield;
|
||||
tif->tif_tagmethods.vgetfield = LZMAVGetField; /* hook for codec tags */
|
||||
sp->vsetparent = tif->tif_tagmethods.vsetfield;
|
||||
tif->tif_tagmethods.vsetfield = LZMAVSetField; /* hook for codec tags */
|
||||
/*
|
||||
* Override parent get/set field methods.
|
||||
*/
|
||||
sp->vgetparent = tif->tif_tagmethods.vgetfield;
|
||||
tif->tif_tagmethods.vgetfield = LZMAVGetField; /* hook for codec tags */
|
||||
sp->vsetparent = tif->tif_tagmethods.vsetfield;
|
||||
tif->tif_tagmethods.vsetfield = LZMAVSetField; /* hook for codec tags */
|
||||
|
||||
/* Default values for codec-specific fields */
|
||||
sp->preset = LZMA_PRESET_DEFAULT; /* default comp. level */
|
||||
sp->check = LZMA_CHECK_NONE;
|
||||
sp->state = 0;
|
||||
/* Default values for codec-specific fields */
|
||||
sp->preset = LZMA_PRESET_DEFAULT; /* default comp. level */
|
||||
sp->check = LZMA_CHECK_NONE;
|
||||
sp->state = 0;
|
||||
|
||||
/* Data filters. So far we are using delta and LZMA2 filters only. */
|
||||
sp->opt_delta.type = LZMA_DELTA_TYPE_BYTE;
|
||||
/*
|
||||
* The sample size in bytes seems to be reasonable distance for delta
|
||||
* filter.
|
||||
*/
|
||||
sp->opt_delta.dist = (tif->tif_dir.td_bitspersample % 8) ?
|
||||
1 : tif->tif_dir.td_bitspersample / 8;
|
||||
sp->filters[0].id = LZMA_FILTER_DELTA;
|
||||
sp->filters[0].options = &sp->opt_delta;
|
||||
/* Data filters. So far we are using delta and LZMA2 filters only. */
|
||||
sp->opt_delta.type = LZMA_DELTA_TYPE_BYTE;
|
||||
/*
|
||||
* The sample size in bytes seems to be reasonable distance for delta
|
||||
* filter.
|
||||
*/
|
||||
sp->opt_delta.dist = (tif->tif_dir.td_bitspersample % 8) ?
|
||||
1 : tif->tif_dir.td_bitspersample / 8;
|
||||
sp->filters[0].id = LZMA_FILTER_DELTA;
|
||||
sp->filters[0].options = &sp->opt_delta;
|
||||
|
||||
lzma_lzma_preset(&sp->opt_lzma, sp->preset);
|
||||
sp->filters[1].id = LZMA_FILTER_LZMA2;
|
||||
sp->filters[1].options = &sp->opt_lzma;
|
||||
lzma_lzma_preset(&sp->opt_lzma, sp->preset);
|
||||
sp->filters[1].id = LZMA_FILTER_LZMA2;
|
||||
sp->filters[1].options = &sp->opt_lzma;
|
||||
|
||||
sp->filters[2].id = LZMA_VLI_UNKNOWN;
|
||||
sp->filters[2].options = NULL;
|
||||
sp->filters[2].id = LZMA_VLI_UNKNOWN;
|
||||
sp->filters[2].options = NULL;
|
||||
|
||||
/*
|
||||
* Install codec methods.
|
||||
*/
|
||||
tif->tif_fixuptags = LZMAFixupTags;
|
||||
tif->tif_setupdecode = LZMASetupDecode;
|
||||
tif->tif_predecode = LZMAPreDecode;
|
||||
tif->tif_decoderow = LZMADecode;
|
||||
tif->tif_decodestrip = LZMADecode;
|
||||
tif->tif_decodetile = LZMADecode;
|
||||
tif->tif_setupencode = LZMASetupEncode;
|
||||
tif->tif_preencode = LZMAPreEncode;
|
||||
tif->tif_postencode = LZMAPostEncode;
|
||||
tif->tif_encoderow = LZMAEncode;
|
||||
tif->tif_encodestrip = LZMAEncode;
|
||||
tif->tif_encodetile = LZMAEncode;
|
||||
tif->tif_cleanup = LZMACleanup;
|
||||
/*
|
||||
* Setup predictor setup.
|
||||
*/
|
||||
(void) TIFFPredictorInit(tif);
|
||||
return 1;
|
||||
/*
|
||||
* Install codec methods.
|
||||
*/
|
||||
tif->tif_fixuptags = LZMAFixupTags;
|
||||
tif->tif_setupdecode = LZMASetupDecode;
|
||||
tif->tif_predecode = LZMAPreDecode;
|
||||
tif->tif_decoderow = LZMADecode;
|
||||
tif->tif_decodestrip = LZMADecode;
|
||||
tif->tif_decodetile = LZMADecode;
|
||||
tif->tif_setupencode = LZMASetupEncode;
|
||||
tif->tif_preencode = LZMAPreEncode;
|
||||
tif->tif_postencode = LZMAPostEncode;
|
||||
tif->tif_encoderow = LZMAEncode;
|
||||
tif->tif_encodestrip = LZMAEncode;
|
||||
tif->tif_encodetile = LZMAEncode;
|
||||
tif->tif_cleanup = LZMACleanup;
|
||||
/*
|
||||
* Setup predictor setup.
|
||||
*/
|
||||
(void) TIFFPredictorInit(tif);
|
||||
return 1;
|
||||
bad:
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"No space for LZMA2 state block");
|
||||
return 0;
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"No space for LZMA2 state block");
|
||||
return 0;
|
||||
}
|
||||
#endif /* LZMA_SUPORT */
|
||||
#endif /* LZMA_SUPPORT */
|
||||
|
||||
/* vim: set ts=8 sts=8 sw=8 noet: */
|
||||
|
||||
Vendored
+881
-830
File diff suppressed because it is too large
Load Diff
Vendored
+134
-105
@@ -1,26 +1,26 @@
|
||||
/* $Id: tif_next.c,v 1.13 2010-03-10 18:56:48 bfriesen Exp $ */
|
||||
/* $Id: tif_next.c,v 1.19 2016-09-04 21:32:56 erouault Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
@@ -33,12 +33,12 @@
|
||||
*/
|
||||
|
||||
#define SETPIXEL(op, v) { \
|
||||
switch (npixels++ & 3) { \
|
||||
case 0: op[0] = (unsigned char) ((v) << 6); break; \
|
||||
case 1: op[0] |= (v) << 4; break; \
|
||||
case 2: op[0] |= (v) << 2; break; \
|
||||
case 3: *op++ |= (v); break; \
|
||||
} \
|
||||
switch (npixels++ & 3) { \
|
||||
case 0: op[0] = (unsigned char) ((v) << 6); break; \
|
||||
case 1: op[0] |= (v) << 4; break; \
|
||||
case 2: op[0] |= (v) << 2; break; \
|
||||
case 3: *op++ |= (v); op_offset++; break; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define LITERALROW 0x00
|
||||
@@ -48,105 +48,134 @@
|
||||
static int
|
||||
NeXTDecode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s)
|
||||
{
|
||||
static const char module[] = "NeXTDecode";
|
||||
unsigned char *bp, *op;
|
||||
tmsize_t cc;
|
||||
uint8* row;
|
||||
tmsize_t scanline, n;
|
||||
static const char module[] = "NeXTDecode";
|
||||
unsigned char *bp, *op;
|
||||
tmsize_t cc;
|
||||
uint8* row;
|
||||
tmsize_t scanline, n;
|
||||
|
||||
(void) s;
|
||||
/*
|
||||
* Each scanline is assumed to start off as all
|
||||
* white (we assume a PhotometricInterpretation
|
||||
* of ``min-is-black'').
|
||||
*/
|
||||
for (op = (unsigned char*) buf, cc = occ; cc-- > 0;)
|
||||
*op++ = 0xff;
|
||||
(void) s;
|
||||
/*
|
||||
* Each scanline is assumed to start off as all
|
||||
* white (we assume a PhotometricInterpretation
|
||||
* of ``min-is-black'').
|
||||
*/
|
||||
for (op = (unsigned char*) buf, cc = occ; cc-- > 0;)
|
||||
*op++ = 0xff;
|
||||
|
||||
bp = (unsigned char *)tif->tif_rawcp;
|
||||
cc = tif->tif_rawcc;
|
||||
scanline = tif->tif_scanlinesize;
|
||||
if (occ % scanline)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be read");
|
||||
return (0);
|
||||
}
|
||||
for (row = buf; occ > 0; occ -= scanline, row += scanline) {
|
||||
n = *bp++, cc--;
|
||||
switch (n) {
|
||||
case LITERALROW:
|
||||
/*
|
||||
* The entire scanline is given as literal values.
|
||||
*/
|
||||
if (cc < scanline)
|
||||
goto bad;
|
||||
_TIFFmemcpy(row, bp, scanline);
|
||||
bp += scanline;
|
||||
cc -= scanline;
|
||||
break;
|
||||
case LITERALSPAN: {
|
||||
tmsize_t off;
|
||||
/*
|
||||
* The scanline has a literal span that begins at some
|
||||
* offset.
|
||||
*/
|
||||
off = (bp[0] * 256) + bp[1];
|
||||
n = (bp[2] * 256) + bp[3];
|
||||
if (cc < 4+n || off+n > scanline)
|
||||
goto bad;
|
||||
_TIFFmemcpy(row+off, bp+4, n);
|
||||
bp += 4+n;
|
||||
cc -= 4+n;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
uint32 npixels = 0, grey;
|
||||
uint32 imagewidth = tif->tif_dir.td_imagewidth;
|
||||
bp = (unsigned char *)tif->tif_rawcp;
|
||||
cc = tif->tif_rawcc;
|
||||
scanline = tif->tif_scanlinesize;
|
||||
if (occ % scanline)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be read");
|
||||
return (0);
|
||||
}
|
||||
for (row = buf; cc > 0 && occ > 0; occ -= scanline, row += scanline) {
|
||||
n = *bp++;
|
||||
cc--;
|
||||
switch (n) {
|
||||
case LITERALROW:
|
||||
/*
|
||||
* The entire scanline is given as literal values.
|
||||
*/
|
||||
if (cc < scanline)
|
||||
goto bad;
|
||||
_TIFFmemcpy(row, bp, scanline);
|
||||
bp += scanline;
|
||||
cc -= scanline;
|
||||
break;
|
||||
case LITERALSPAN: {
|
||||
tmsize_t off;
|
||||
/*
|
||||
* 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)
|
||||
goto bad;
|
||||
_TIFFmemcpy(row+off, bp+4, n);
|
||||
bp += 4+n;
|
||||
cc -= 4+n;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
uint32 npixels = 0, grey;
|
||||
tmsize_t op_offset = 0;
|
||||
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
|
||||
* color ``runs''. We shift into ``run mode'' and
|
||||
* interpret bytes as codes of the form
|
||||
* <color><npixels> until we've filled the scanline.
|
||||
*/
|
||||
op = row;
|
||||
for (;;) {
|
||||
grey = (uint32)((n>>6) & 0x3);
|
||||
n &= 0x3f;
|
||||
/*
|
||||
* Ensure the run does not exceed the scanline
|
||||
* bounds, potentially resulting in a security
|
||||
* issue.
|
||||
*/
|
||||
while (n-- > 0 && npixels < imagewidth)
|
||||
SETPIXEL(op, grey);
|
||||
if (npixels >= imagewidth)
|
||||
break;
|
||||
if (cc == 0)
|
||||
goto bad;
|
||||
n = *bp++, cc--;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
tif->tif_rawcp = (uint8*) bp;
|
||||
tif->tif_rawcc = cc;
|
||||
return (1);
|
||||
/*
|
||||
* The scanline is composed of a sequence of constant
|
||||
* color ``runs''. We shift into ``run mode'' and
|
||||
* interpret bytes as codes of the form
|
||||
* <color><npixels> until we've filled the scanline.
|
||||
*/
|
||||
op = row;
|
||||
for (;;) {
|
||||
grey = (uint32)((n>>6) & 0x3);
|
||||
n &= 0x3f;
|
||||
/*
|
||||
* Ensure the run does not exceed the scanline
|
||||
* bounds, potentially resulting in a security
|
||||
* issue.
|
||||
*/
|
||||
while (n-- > 0 && npixels < imagewidth && op_offset < scanline)
|
||||
SETPIXEL(op, grey);
|
||||
if (npixels >= imagewidth)
|
||||
break;
|
||||
if (op_offset >= scanline ) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "Invalid data for scanline %ld",
|
||||
(long) tif->tif_row);
|
||||
return (0);
|
||||
}
|
||||
if (cc == 0)
|
||||
goto bad;
|
||||
n = *bp++;
|
||||
cc--;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
tif->tif_rawcp = (uint8*) bp;
|
||||
tif->tif_rawcc = cc;
|
||||
return (1);
|
||||
bad:
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "Not enough data for scanline %ld",
|
||||
(long) tif->tif_row);
|
||||
return (0);
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "Not enough data for scanline %ld",
|
||||
(long) tif->tif_row);
|
||||
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_decoderow = NeXTDecode;
|
||||
tif->tif_decodestrip = NeXTDecode;
|
||||
tif->tif_decodetile = NeXTDecode;
|
||||
return (1);
|
||||
(void) scheme;
|
||||
tif->tif_predecode = NeXTPreDecode;
|
||||
tif->tif_decoderow = NeXTDecode;
|
||||
tif->tif_decodestrip = NeXTDecode;
|
||||
tif->tif_decodetile = NeXTDecode;
|
||||
return (1);
|
||||
}
|
||||
#endif /* NEXT_SUPPORT */
|
||||
|
||||
|
||||
Vendored
+1921
-1854
File diff suppressed because it is too large
Load Diff
Vendored
+461
-461
File diff suppressed because it is too large
Load Diff
Vendored
+229
-212
@@ -1,26 +1,26 @@
|
||||
/* $Id: tif_packbits.c,v 1.20 2010-03-10 18:56:49 bfriesen Exp $ */
|
||||
/* $Id: tif_packbits.c,v 1.26 2017-05-14 02:26:07 erouault Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
@@ -36,18 +36,19 @@
|
||||
static int
|
||||
PackBitsPreEncode(TIFF* tif, uint16 s)
|
||||
{
|
||||
(void) s;
|
||||
(void) s;
|
||||
|
||||
if (!(tif->tif_data = (uint8*)_TIFFmalloc(sizeof(tmsize_t))))
|
||||
return (0);
|
||||
/*
|
||||
* Calculate the scanline/tile-width size in bytes.
|
||||
*/
|
||||
if (isTiled(tif))
|
||||
*(tmsize_t*)tif->tif_data = TIFFTileRowSize(tif);
|
||||
else
|
||||
*(tmsize_t*)tif->tif_data = TIFFScanlineSize(tif);
|
||||
return (1);
|
||||
tif->tif_data = (uint8*)_TIFFmalloc(sizeof(tmsize_t));
|
||||
if (tif->tif_data == NULL)
|
||||
return (0);
|
||||
/*
|
||||
* Calculate the scanline/tile-width size in bytes.
|
||||
*/
|
||||
if (isTiled(tif))
|
||||
*(tmsize_t*)tif->tif_data = TIFFTileRowSize(tif);
|
||||
else
|
||||
*(tmsize_t*)tif->tif_data = TIFFScanlineSize(tif);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -55,7 +56,7 @@ PackBitsPostEncode(TIFF* tif)
|
||||
{
|
||||
if (tif->tif_data)
|
||||
_TIFFfree(tif->tif_data);
|
||||
return (1);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -64,123 +65,125 @@ PackBitsPostEncode(TIFF* tif)
|
||||
static int
|
||||
PackBitsEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
|
||||
{
|
||||
unsigned char* bp = (unsigned char*) buf;
|
||||
uint8* op;
|
||||
uint8* ep;
|
||||
uint8* lastliteral;
|
||||
long n, slop;
|
||||
int b;
|
||||
enum { BASE, LITERAL, RUN, LITERAL_RUN } state;
|
||||
unsigned char* bp = (unsigned char*) buf;
|
||||
uint8* op;
|
||||
uint8* ep;
|
||||
uint8* lastliteral;
|
||||
long n, slop;
|
||||
int b;
|
||||
enum { BASE, LITERAL, RUN, LITERAL_RUN } state;
|
||||
|
||||
(void) s;
|
||||
op = tif->tif_rawcp;
|
||||
ep = tif->tif_rawdata + tif->tif_rawdatasize;
|
||||
state = BASE;
|
||||
lastliteral = 0;
|
||||
while (cc > 0) {
|
||||
/*
|
||||
* Find the longest string of identical bytes.
|
||||
*/
|
||||
b = *bp++, cc--, n = 1;
|
||||
for (; cc > 0 && b == *bp; cc--, bp++)
|
||||
n++;
|
||||
again:
|
||||
if (op + 2 >= ep) { /* insure space for new data */
|
||||
/*
|
||||
* Be careful about writing the last
|
||||
* literal. Must write up to that point
|
||||
* and then copy the remainder to the
|
||||
* front of the buffer.
|
||||
*/
|
||||
if (state == LITERAL || state == LITERAL_RUN) {
|
||||
slop = (long)(op - lastliteral);
|
||||
tif->tif_rawcc += (tmsize_t)(lastliteral - tif->tif_rawcp);
|
||||
if (!TIFFFlushData1(tif))
|
||||
return (-1);
|
||||
op = tif->tif_rawcp;
|
||||
while (slop-- > 0)
|
||||
*op++ = *lastliteral++;
|
||||
lastliteral = tif->tif_rawcp;
|
||||
} else {
|
||||
tif->tif_rawcc += (tmsize_t)(op - tif->tif_rawcp);
|
||||
if (!TIFFFlushData1(tif))
|
||||
return (-1);
|
||||
op = tif->tif_rawcp;
|
||||
}
|
||||
}
|
||||
switch (state) {
|
||||
case BASE: /* initial state, set run/literal */
|
||||
if (n > 1) {
|
||||
state = RUN;
|
||||
if (n > 128) {
|
||||
*op++ = (uint8) -127;
|
||||
*op++ = (uint8) b;
|
||||
n -= 128;
|
||||
goto again;
|
||||
}
|
||||
*op++ = (uint8)(-(n-1));
|
||||
*op++ = (uint8) b;
|
||||
} else {
|
||||
lastliteral = op;
|
||||
*op++ = 0;
|
||||
*op++ = (uint8) b;
|
||||
state = LITERAL;
|
||||
}
|
||||
break;
|
||||
case LITERAL: /* last object was literal string */
|
||||
if (n > 1) {
|
||||
state = LITERAL_RUN;
|
||||
if (n > 128) {
|
||||
*op++ = (uint8) -127;
|
||||
*op++ = (uint8) b;
|
||||
n -= 128;
|
||||
goto again;
|
||||
}
|
||||
*op++ = (uint8)(-(n-1)); /* encode run */
|
||||
*op++ = (uint8) b;
|
||||
} else { /* extend literal */
|
||||
if (++(*lastliteral) == 127)
|
||||
state = BASE;
|
||||
*op++ = (uint8) b;
|
||||
}
|
||||
break;
|
||||
case RUN: /* last object was run */
|
||||
if (n > 1) {
|
||||
if (n > 128) {
|
||||
*op++ = (uint8) -127;
|
||||
*op++ = (uint8) b;
|
||||
n -= 128;
|
||||
goto again;
|
||||
}
|
||||
*op++ = (uint8)(-(n-1));
|
||||
*op++ = (uint8) b;
|
||||
} else {
|
||||
lastliteral = op;
|
||||
*op++ = 0;
|
||||
*op++ = (uint8) b;
|
||||
state = LITERAL;
|
||||
}
|
||||
break;
|
||||
case LITERAL_RUN: /* literal followed by a run */
|
||||
/*
|
||||
* Check to see if previous run should
|
||||
* be converted to a literal, in which
|
||||
* case we convert literal-run-literal
|
||||
* to a single literal.
|
||||
*/
|
||||
if (n == 1 && op[-2] == (uint8) -1 &&
|
||||
*lastliteral < 126) {
|
||||
state = (((*lastliteral) += 2) == 127 ?
|
||||
BASE : LITERAL);
|
||||
op[-2] = op[-1]; /* replicate */
|
||||
} else
|
||||
state = RUN;
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
tif->tif_rawcc += (tmsize_t)(op - tif->tif_rawcp);
|
||||
tif->tif_rawcp = op;
|
||||
return (1);
|
||||
(void) s;
|
||||
op = tif->tif_rawcp;
|
||||
ep = tif->tif_rawdata + tif->tif_rawdatasize;
|
||||
state = BASE;
|
||||
lastliteral = 0;
|
||||
while (cc > 0) {
|
||||
/*
|
||||
* Find the longest string of identical bytes.
|
||||
*/
|
||||
b = *bp++;
|
||||
cc--;
|
||||
n = 1;
|
||||
for (; cc > 0 && b == *bp; cc--, bp++)
|
||||
n++;
|
||||
again:
|
||||
if (op + 2 >= ep) { /* insure space for new data */
|
||||
/*
|
||||
* Be careful about writing the last
|
||||
* literal. Must write up to that point
|
||||
* and then copy the remainder to the
|
||||
* front of the buffer.
|
||||
*/
|
||||
if (state == LITERAL || state == LITERAL_RUN) {
|
||||
slop = (long)(op - lastliteral);
|
||||
tif->tif_rawcc += (tmsize_t)(lastliteral - tif->tif_rawcp);
|
||||
if (!TIFFFlushData1(tif))
|
||||
return (0);
|
||||
op = tif->tif_rawcp;
|
||||
while (slop-- > 0)
|
||||
*op++ = *lastliteral++;
|
||||
lastliteral = tif->tif_rawcp;
|
||||
} else {
|
||||
tif->tif_rawcc += (tmsize_t)(op - tif->tif_rawcp);
|
||||
if (!TIFFFlushData1(tif))
|
||||
return (0);
|
||||
op = tif->tif_rawcp;
|
||||
}
|
||||
}
|
||||
switch (state) {
|
||||
case BASE: /* initial state, set run/literal */
|
||||
if (n > 1) {
|
||||
state = RUN;
|
||||
if (n > 128) {
|
||||
*op++ = (uint8) -127;
|
||||
*op++ = (uint8) b;
|
||||
n -= 128;
|
||||
goto again;
|
||||
}
|
||||
*op++ = (uint8)(-(n-1));
|
||||
*op++ = (uint8) b;
|
||||
} else {
|
||||
lastliteral = op;
|
||||
*op++ = 0;
|
||||
*op++ = (uint8) b;
|
||||
state = LITERAL;
|
||||
}
|
||||
break;
|
||||
case LITERAL: /* last object was literal string */
|
||||
if (n > 1) {
|
||||
state = LITERAL_RUN;
|
||||
if (n > 128) {
|
||||
*op++ = (uint8) -127;
|
||||
*op++ = (uint8) b;
|
||||
n -= 128;
|
||||
goto again;
|
||||
}
|
||||
*op++ = (uint8)(-(n-1)); /* encode run */
|
||||
*op++ = (uint8) b;
|
||||
} else { /* extend literal */
|
||||
if (++(*lastliteral) == 127)
|
||||
state = BASE;
|
||||
*op++ = (uint8) b;
|
||||
}
|
||||
break;
|
||||
case RUN: /* last object was run */
|
||||
if (n > 1) {
|
||||
if (n > 128) {
|
||||
*op++ = (uint8) -127;
|
||||
*op++ = (uint8) b;
|
||||
n -= 128;
|
||||
goto again;
|
||||
}
|
||||
*op++ = (uint8)(-(n-1));
|
||||
*op++ = (uint8) b;
|
||||
} else {
|
||||
lastliteral = op;
|
||||
*op++ = 0;
|
||||
*op++ = (uint8) b;
|
||||
state = LITERAL;
|
||||
}
|
||||
break;
|
||||
case LITERAL_RUN: /* literal followed by a run */
|
||||
/*
|
||||
* Check to see if previous run should
|
||||
* be converted to a literal, in which
|
||||
* case we convert literal-run-literal
|
||||
* to a single literal.
|
||||
*/
|
||||
if (n == 1 && op[-2] == (uint8) -1 &&
|
||||
*lastliteral < 126) {
|
||||
state = (((*lastliteral) += 2) == 127 ?
|
||||
BASE : LITERAL);
|
||||
op[-2] = op[-1]; /* replicate */
|
||||
} else
|
||||
state = RUN;
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
tif->tif_rawcc += (tmsize_t)(op - tif->tif_rawcp);
|
||||
tif->tif_rawcp = op;
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -193,94 +196,108 @@ PackBitsEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
|
||||
static int
|
||||
PackBitsEncodeChunk(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
|
||||
{
|
||||
tmsize_t rowsize = *(tmsize_t*)tif->tif_data;
|
||||
tmsize_t rowsize = *(tmsize_t*)tif->tif_data;
|
||||
|
||||
while (cc > 0) {
|
||||
tmsize_t chunk = rowsize;
|
||||
while (cc > 0) {
|
||||
tmsize_t chunk = rowsize;
|
||||
|
||||
if( cc < chunk )
|
||||
chunk = cc;
|
||||
|
||||
if( cc < chunk )
|
||||
chunk = cc;
|
||||
|
||||
if (PackBitsEncode(tif, bp, chunk, s) < 0)
|
||||
return (-1);
|
||||
bp += chunk;
|
||||
cc -= chunk;
|
||||
}
|
||||
return (1);
|
||||
if (PackBitsEncode(tif, bp, chunk, s) < 0)
|
||||
return (-1);
|
||||
bp += chunk;
|
||||
cc -= chunk;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
PackBitsDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s)
|
||||
{
|
||||
static const char module[] = "PackBitsDecode";
|
||||
char *bp;
|
||||
tmsize_t cc;
|
||||
long n;
|
||||
int b;
|
||||
static const char module[] = "PackBitsDecode";
|
||||
char *bp;
|
||||
tmsize_t cc;
|
||||
long n;
|
||||
int b;
|
||||
|
||||
(void) s;
|
||||
bp = (char*) tif->tif_rawcp;
|
||||
cc = tif->tif_rawcc;
|
||||
while (cc > 0 && occ > 0) {
|
||||
n = (long) *bp++, cc--;
|
||||
/*
|
||||
* Watch out for compilers that
|
||||
* don't sign extend chars...
|
||||
*/
|
||||
if (n >= 128)
|
||||
n -= 256;
|
||||
if (n < 0) { /* replicate next byte -n+1 times */
|
||||
if (n == -128) /* nop */
|
||||
continue;
|
||||
n = -n + 1;
|
||||
if( occ < (tmsize_t)n )
|
||||
{
|
||||
TIFFWarningExt(tif->tif_clientdata, module,
|
||||
"Discarding %lu bytes to avoid buffer overrun",
|
||||
(unsigned long) ((tmsize_t)n - occ));
|
||||
n = (long)occ;
|
||||
}
|
||||
occ -= n;
|
||||
b = *bp++, cc--; /* TODO: may be reading past input buffer here when input data is corrupt or ends prematurely */
|
||||
while (n-- > 0)
|
||||
*op++ = (uint8) b;
|
||||
} else { /* copy next n+1 bytes literally */
|
||||
if (occ < (tmsize_t)(n + 1))
|
||||
{
|
||||
TIFFWarningExt(tif->tif_clientdata, module,
|
||||
"Discarding %lu bytes to avoid buffer overrun",
|
||||
(unsigned long) ((tmsize_t)n - occ + 1));
|
||||
n = (long)occ - 1;
|
||||
}
|
||||
_TIFFmemcpy(op, bp, ++n); /* TODO: may be reading past input buffer here when input data is corrupt or ends prematurely */
|
||||
op += n; occ -= n;
|
||||
bp += n; cc -= n;
|
||||
}
|
||||
}
|
||||
tif->tif_rawcp = (uint8*) bp;
|
||||
tif->tif_rawcc = cc;
|
||||
if (occ > 0) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Not enough data for scanline %lu",
|
||||
(unsigned long) tif->tif_row);
|
||||
return (0);
|
||||
}
|
||||
return (1);
|
||||
(void) s;
|
||||
bp = (char*) tif->tif_rawcp;
|
||||
cc = tif->tif_rawcc;
|
||||
while (cc > 0 && occ > 0) {
|
||||
n = (long) *bp++;
|
||||
cc--;
|
||||
/*
|
||||
* Watch out for compilers that
|
||||
* don't sign extend chars...
|
||||
*/
|
||||
if (n >= 128)
|
||||
n -= 256;
|
||||
if (n < 0) { /* replicate next byte -n+1 times */
|
||||
if (n == -128) /* nop */
|
||||
continue;
|
||||
n = -n + 1;
|
||||
if( occ < (tmsize_t)n )
|
||||
{
|
||||
TIFFWarningExt(tif->tif_clientdata, module,
|
||||
"Discarding %lu bytes to avoid buffer overrun",
|
||||
(unsigned long) ((tmsize_t)n - occ));
|
||||
n = (long)occ;
|
||||
}
|
||||
if( cc == 0 )
|
||||
{
|
||||
TIFFWarningExt(tif->tif_clientdata, module,
|
||||
"Terminating PackBitsDecode due to lack of data.");
|
||||
break;
|
||||
}
|
||||
occ -= n;
|
||||
b = *bp++;
|
||||
cc--;
|
||||
while (n-- > 0)
|
||||
*op++ = (uint8) b;
|
||||
} else { /* copy next n+1 bytes literally */
|
||||
if (occ < (tmsize_t)(n + 1))
|
||||
{
|
||||
TIFFWarningExt(tif->tif_clientdata, module,
|
||||
"Discarding %lu bytes to avoid buffer overrun",
|
||||
(unsigned long) ((tmsize_t)n - occ + 1));
|
||||
n = (long)occ - 1;
|
||||
}
|
||||
if (cc < (tmsize_t) (n+1))
|
||||
{
|
||||
TIFFWarningExt(tif->tif_clientdata, module,
|
||||
"Terminating PackBitsDecode due to lack of data.");
|
||||
break;
|
||||
}
|
||||
_TIFFmemcpy(op, bp, ++n);
|
||||
op += n; occ -= n;
|
||||
bp += n; cc -= n;
|
||||
}
|
||||
}
|
||||
tif->tif_rawcp = (uint8*) bp;
|
||||
tif->tif_rawcc = cc;
|
||||
if (occ > 0) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Not enough data for scanline %lu",
|
||||
(unsigned long) tif->tif_row);
|
||||
return (0);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
int
|
||||
TIFFInitPackBits(TIFF* tif, int scheme)
|
||||
{
|
||||
(void) scheme;
|
||||
tif->tif_decoderow = PackBitsDecode;
|
||||
tif->tif_decodestrip = PackBitsDecode;
|
||||
tif->tif_decodetile = PackBitsDecode;
|
||||
tif->tif_preencode = PackBitsPreEncode;
|
||||
tif->tif_postencode = PackBitsPostEncode;
|
||||
tif->tif_encoderow = PackBitsEncode;
|
||||
tif->tif_encodestrip = PackBitsEncodeChunk;
|
||||
tif->tif_encodetile = PackBitsEncodeChunk;
|
||||
return (1);
|
||||
(void) scheme;
|
||||
tif->tif_decoderow = PackBitsDecode;
|
||||
tif->tif_decodestrip = PackBitsDecode;
|
||||
tif->tif_decodetile = PackBitsDecode;
|
||||
tif->tif_preencode = PackBitsPreEncode;
|
||||
tif->tif_postencode = PackBitsPostEncode;
|
||||
tif->tif_encoderow = PackBitsEncode;
|
||||
tif->tif_encodestrip = PackBitsEncodeChunk;
|
||||
tif->tif_encodetile = PackBitsEncodeChunk;
|
||||
return (1);
|
||||
}
|
||||
#endif /* PACKBITS_SUPPORT */
|
||||
|
||||
|
||||
Vendored
+1008
-949
File diff suppressed because it is too large
Load Diff
Vendored
+607
-490
File diff suppressed because it is too large
Load Diff
Vendored
+19
-17
@@ -1,4 +1,4 @@
|
||||
/* $Id: tif_predict.h,v 1.8 2010-03-10 18:56:49 bfriesen Exp $ */
|
||||
/* $Id: tif_predict.h,v 1.9 2016-10-31 17:24:26 erouault Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995-1997 Sam Leffler
|
||||
@@ -30,31 +30,33 @@
|
||||
* ``Library-private'' Support for the Predictor Tag
|
||||
*/
|
||||
|
||||
typedef int (*TIFFEncodeDecodeMethod)(TIFF* tif, uint8* buf, tmsize_t size);
|
||||
|
||||
/*
|
||||
* Codecs that want to support the Predictor tag must place
|
||||
* this structure first in their private state block so that
|
||||
* the predictor code can cast tif_data to find its state.
|
||||
*/
|
||||
typedef struct {
|
||||
int predictor; /* predictor tag value */
|
||||
tmsize_t stride; /* sample stride over data */
|
||||
tmsize_t rowsize; /* tile/strip row size */
|
||||
int predictor; /* predictor tag value */
|
||||
tmsize_t stride; /* sample stride over data */
|
||||
tmsize_t rowsize; /* tile/strip row size */
|
||||
|
||||
TIFFCodeMethod encoderow; /* parent codec encode/decode row */
|
||||
TIFFCodeMethod encodestrip; /* parent codec encode/decode strip */
|
||||
TIFFCodeMethod encodetile; /* parent codec encode/decode tile */
|
||||
TIFFPostMethod encodepfunc; /* horizontal differencer */
|
||||
TIFFCodeMethod encoderow; /* parent codec encode/decode row */
|
||||
TIFFCodeMethod encodestrip; /* parent codec encode/decode strip */
|
||||
TIFFCodeMethod encodetile; /* parent codec encode/decode tile */
|
||||
TIFFEncodeDecodeMethod encodepfunc; /* horizontal differencer */
|
||||
|
||||
TIFFCodeMethod decoderow; /* parent codec encode/decode row */
|
||||
TIFFCodeMethod decodestrip; /* parent codec encode/decode strip */
|
||||
TIFFCodeMethod decodetile; /* parent codec encode/decode tile */
|
||||
TIFFPostMethod decodepfunc; /* horizontal accumulator */
|
||||
TIFFCodeMethod decoderow; /* parent codec encode/decode row */
|
||||
TIFFCodeMethod decodestrip; /* parent codec encode/decode strip */
|
||||
TIFFCodeMethod decodetile; /* parent codec encode/decode tile */
|
||||
TIFFEncodeDecodeMethod decodepfunc; /* horizontal accumulator */
|
||||
|
||||
TIFFVGetMethod vgetparent; /* super-class method */
|
||||
TIFFVSetMethod vsetparent; /* super-class method */
|
||||
TIFFPrintMethod printdir; /* super-class method */
|
||||
TIFFBoolMethod setupdecode; /* super-class method */
|
||||
TIFFBoolMethod setupencode; /* super-class method */
|
||||
TIFFVGetMethod vgetparent; /* super-class method */
|
||||
TIFFVSetMethod vsetparent; /* super-class method */
|
||||
TIFFPrintMethod printdir; /* super-class method */
|
||||
TIFFBoolMethod setupdecode; /* super-class method */
|
||||
TIFFBoolMethod setupencode; /* super-class method */
|
||||
} TIFFPredictorState;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
Vendored
+584
-576
File diff suppressed because it is too large
Load Diff
Vendored
+1138
-649
File diff suppressed because it is too large
Load Diff
Vendored
+232
-226
@@ -1,26 +1,26 @@
|
||||
/* $Id: tif_strip.c,v 1.35 2012-06-06 05:33:55 fwarmerdam Exp $ */
|
||||
/* $Id: tif_strip.c,v 1.38 2016-12-03 11:02:15 erouault Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1991-1997 Sam Leffler
|
||||
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
@@ -37,21 +37,21 @@
|
||||
uint32
|
||||
TIFFComputeStrip(TIFF* tif, uint32 row, uint16 sample)
|
||||
{
|
||||
static const char module[] = "TIFFComputeStrip";
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
uint32 strip;
|
||||
static const char module[] = "TIFFComputeStrip";
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
uint32 strip;
|
||||
|
||||
strip = row / td->td_rowsperstrip;
|
||||
if (td->td_planarconfig == PLANARCONFIG_SEPARATE) {
|
||||
if (sample >= td->td_samplesperpixel) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"%lu: Sample out of range, max %lu",
|
||||
(unsigned long) sample, (unsigned long) td->td_samplesperpixel);
|
||||
return (0);
|
||||
}
|
||||
strip += (uint32)sample*td->td_stripsperimage;
|
||||
}
|
||||
return (strip);
|
||||
strip = row / td->td_rowsperstrip;
|
||||
if (td->td_planarconfig == PLANARCONFIG_SEPARATE) {
|
||||
if (sample >= td->td_samplesperpixel) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"%lu: Sample out of range, max %lu",
|
||||
(unsigned long) sample, (unsigned long) td->td_samplesperpixel);
|
||||
return (0);
|
||||
}
|
||||
strip += (uint32)sample*td->td_stripsperimage;
|
||||
}
|
||||
return (strip);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -60,15 +60,15 @@ TIFFComputeStrip(TIFF* tif, uint32 row, uint16 sample)
|
||||
uint32
|
||||
TIFFNumberOfStrips(TIFF* tif)
|
||||
{
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
uint32 nstrips;
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
uint32 nstrips;
|
||||
|
||||
nstrips = (td->td_rowsperstrip == (uint32) -1 ? 1 :
|
||||
TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip));
|
||||
if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
|
||||
nstrips = _TIFFMultiply32(tif, nstrips, (uint32)td->td_samplesperpixel,
|
||||
"TIFFNumberOfStrips");
|
||||
return (nstrips);
|
||||
nstrips = (td->td_rowsperstrip == (uint32) -1 ? 1 :
|
||||
TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip));
|
||||
if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
|
||||
nstrips = _TIFFMultiply32(tif, nstrips, (uint32)td->td_samplesperpixel,
|
||||
"TIFFNumberOfStrips");
|
||||
return (nstrips);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -77,69 +77,69 @@ TIFFNumberOfStrips(TIFF* tif)
|
||||
uint64
|
||||
TIFFVStripSize64(TIFF* tif, uint32 nrows)
|
||||
{
|
||||
static const char module[] = "TIFFVStripSize64";
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
if (nrows==(uint32)(-1))
|
||||
nrows=td->td_imagelength;
|
||||
if ((td->td_planarconfig==PLANARCONFIG_CONTIG)&&
|
||||
(td->td_photometric == PHOTOMETRIC_YCBCR)&&
|
||||
(!isUpSampled(tif)))
|
||||
{
|
||||
/*
|
||||
* Packed YCbCr data contain one Cb+Cr for every
|
||||
* HorizontalSampling*VerticalSampling Y values.
|
||||
* Must also roundup width and height when calculating
|
||||
* since images that are not a multiple of the
|
||||
* horizontal/vertical subsampling area include
|
||||
* YCbCr data for the extended image.
|
||||
*/
|
||||
uint16 ycbcrsubsampling[2];
|
||||
uint16 samplingblock_samples;
|
||||
uint32 samplingblocks_hor;
|
||||
uint32 samplingblocks_ver;
|
||||
uint64 samplingrow_samples;
|
||||
uint64 samplingrow_size;
|
||||
if(td->td_samplesperpixel!=3)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,
|
||||
"Invalid td_samplesperpixel value");
|
||||
return 0;
|
||||
}
|
||||
TIFFGetFieldDefaulted(tif,TIFFTAG_YCBCRSUBSAMPLING,ycbcrsubsampling+0,
|
||||
ycbcrsubsampling+1);
|
||||
if ((ycbcrsubsampling[0] != 1 && ycbcrsubsampling[0] != 2 && ycbcrsubsampling[0] != 4)
|
||||
||(ycbcrsubsampling[1] != 1 && ycbcrsubsampling[1] != 2 && ycbcrsubsampling[1] != 4))
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,
|
||||
"Invalid YCbCr subsampling (%dx%d)",
|
||||
ycbcrsubsampling[0],
|
||||
ycbcrsubsampling[1] );
|
||||
return 0;
|
||||
}
|
||||
samplingblock_samples=ycbcrsubsampling[0]*ycbcrsubsampling[1]+2;
|
||||
samplingblocks_hor=TIFFhowmany_32(td->td_imagewidth,ycbcrsubsampling[0]);
|
||||
samplingblocks_ver=TIFFhowmany_32(nrows,ycbcrsubsampling[1]);
|
||||
samplingrow_samples=_TIFFMultiply64(tif,samplingblocks_hor,samplingblock_samples,module);
|
||||
samplingrow_size=TIFFhowmany8_64(_TIFFMultiply64(tif,samplingrow_samples,td->td_bitspersample,module));
|
||||
return(_TIFFMultiply64(tif,samplingrow_size,samplingblocks_ver,module));
|
||||
}
|
||||
else
|
||||
return(_TIFFMultiply64(tif,nrows,TIFFScanlineSize64(tif),module));
|
||||
static const char module[] = "TIFFVStripSize64";
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
if (nrows==(uint32)(-1))
|
||||
nrows=td->td_imagelength;
|
||||
if ((td->td_planarconfig==PLANARCONFIG_CONTIG)&&
|
||||
(td->td_photometric == PHOTOMETRIC_YCBCR)&&
|
||||
(!isUpSampled(tif)))
|
||||
{
|
||||
/*
|
||||
* Packed YCbCr data contain one Cb+Cr for every
|
||||
* HorizontalSampling*VerticalSampling Y values.
|
||||
* Must also roundup width and height when calculating
|
||||
* since images that are not a multiple of the
|
||||
* horizontal/vertical subsampling area include
|
||||
* YCbCr data for the extended image.
|
||||
*/
|
||||
uint16 ycbcrsubsampling[2];
|
||||
uint16 samplingblock_samples;
|
||||
uint32 samplingblocks_hor;
|
||||
uint32 samplingblocks_ver;
|
||||
uint64 samplingrow_samples;
|
||||
uint64 samplingrow_size;
|
||||
if(td->td_samplesperpixel!=3)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,
|
||||
"Invalid td_samplesperpixel value");
|
||||
return 0;
|
||||
}
|
||||
TIFFGetFieldDefaulted(tif,TIFFTAG_YCBCRSUBSAMPLING,ycbcrsubsampling+0,
|
||||
ycbcrsubsampling+1);
|
||||
if ((ycbcrsubsampling[0] != 1 && ycbcrsubsampling[0] != 2 && ycbcrsubsampling[0] != 4)
|
||||
||(ycbcrsubsampling[1] != 1 && ycbcrsubsampling[1] != 2 && ycbcrsubsampling[1] != 4))
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,
|
||||
"Invalid YCbCr subsampling (%dx%d)",
|
||||
ycbcrsubsampling[0],
|
||||
ycbcrsubsampling[1] );
|
||||
return 0;
|
||||
}
|
||||
samplingblock_samples=ycbcrsubsampling[0]*ycbcrsubsampling[1]+2;
|
||||
samplingblocks_hor=TIFFhowmany_32(td->td_imagewidth,ycbcrsubsampling[0]);
|
||||
samplingblocks_ver=TIFFhowmany_32(nrows,ycbcrsubsampling[1]);
|
||||
samplingrow_samples=_TIFFMultiply64(tif,samplingblocks_hor,samplingblock_samples,module);
|
||||
samplingrow_size=TIFFhowmany8_64(_TIFFMultiply64(tif,samplingrow_samples,td->td_bitspersample,module));
|
||||
return(_TIFFMultiply64(tif,samplingrow_size,samplingblocks_ver,module));
|
||||
}
|
||||
else
|
||||
return(_TIFFMultiply64(tif,nrows,TIFFScanlineSize64(tif),module));
|
||||
}
|
||||
tmsize_t
|
||||
TIFFVStripSize(TIFF* tif, uint32 nrows)
|
||||
{
|
||||
static const char module[] = "TIFFVStripSize";
|
||||
uint64 m;
|
||||
tmsize_t n;
|
||||
m=TIFFVStripSize64(tif,nrows);
|
||||
n=(tmsize_t)m;
|
||||
if ((uint64)n!=m)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
|
||||
n=0;
|
||||
}
|
||||
return(n);
|
||||
static const char module[] = "TIFFVStripSize";
|
||||
uint64 m;
|
||||
tmsize_t n;
|
||||
m=TIFFVStripSize64(tif,nrows);
|
||||
n=(tmsize_t)m;
|
||||
if ((uint64)n!=m)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
|
||||
n=0;
|
||||
}
|
||||
return(n);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -148,47 +148,47 @@ TIFFVStripSize(TIFF* tif, uint32 nrows)
|
||||
uint64
|
||||
TIFFRawStripSize64(TIFF* tif, uint32 strip)
|
||||
{
|
||||
static const char module[] = "TIFFRawStripSize64";
|
||||
TIFFDirectory* td = &tif->tif_dir;
|
||||
uint64 bytecount = td->td_stripbytecount[strip];
|
||||
static const char module[] = "TIFFRawStripSize64";
|
||||
TIFFDirectory* td = &tif->tif_dir;
|
||||
uint64 bytecount = td->td_stripbytecount[strip];
|
||||
|
||||
if (bytecount == 0)
|
||||
{
|
||||
if (bytecount == 0)
|
||||
{
|
||||
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"%I64u: Invalid strip byte count, strip %lu",
|
||||
(unsigned __int64) bytecount,
|
||||
(unsigned long) strip);
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"%I64u: Invalid strip byte count, strip %lu",
|
||||
(unsigned __int64) bytecount,
|
||||
(unsigned long) strip);
|
||||
#else
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"%llu: Invalid strip byte count, strip %lu",
|
||||
(unsigned long long) bytecount,
|
||||
(unsigned long) strip);
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"%llu: Invalid strip byte count, strip %lu",
|
||||
(unsigned long long) bytecount,
|
||||
(unsigned long) strip);
|
||||
#endif
|
||||
bytecount = (uint64) -1;
|
||||
}
|
||||
bytecount = (uint64) -1;
|
||||
}
|
||||
|
||||
return bytecount;
|
||||
return bytecount;
|
||||
}
|
||||
tmsize_t
|
||||
TIFFRawStripSize(TIFF* tif, uint32 strip)
|
||||
{
|
||||
static const char module[] = "TIFFRawStripSize";
|
||||
uint64 m;
|
||||
tmsize_t n;
|
||||
m=TIFFRawStripSize64(tif,strip);
|
||||
if (m==(uint64)(-1))
|
||||
n=(tmsize_t)(-1);
|
||||
else
|
||||
{
|
||||
n=(tmsize_t)m;
|
||||
if ((uint64)n!=m)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
|
||||
n=0;
|
||||
}
|
||||
}
|
||||
return(n);
|
||||
static const char module[] = "TIFFRawStripSize";
|
||||
uint64 m;
|
||||
tmsize_t n;
|
||||
m=TIFFRawStripSize64(tif,strip);
|
||||
if (m==(uint64)(-1))
|
||||
n=(tmsize_t)(-1);
|
||||
else
|
||||
{
|
||||
n=(tmsize_t)m;
|
||||
if ((uint64)n!=m)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
|
||||
n=0;
|
||||
}
|
||||
}
|
||||
return(n);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -202,26 +202,26 @@ TIFFRawStripSize(TIFF* tif, uint32 strip)
|
||||
uint64
|
||||
TIFFStripSize64(TIFF* tif)
|
||||
{
|
||||
TIFFDirectory* td = &tif->tif_dir;
|
||||
uint32 rps = td->td_rowsperstrip;
|
||||
if (rps > td->td_imagelength)
|
||||
rps = td->td_imagelength;
|
||||
return (TIFFVStripSize64(tif, rps));
|
||||
TIFFDirectory* td = &tif->tif_dir;
|
||||
uint32 rps = td->td_rowsperstrip;
|
||||
if (rps > td->td_imagelength)
|
||||
rps = td->td_imagelength;
|
||||
return (TIFFVStripSize64(tif, rps));
|
||||
}
|
||||
tmsize_t
|
||||
TIFFStripSize(TIFF* tif)
|
||||
{
|
||||
static const char module[] = "TIFFStripSize";
|
||||
uint64 m;
|
||||
tmsize_t n;
|
||||
m=TIFFStripSize64(tif);
|
||||
n=(tmsize_t)m;
|
||||
if ((uint64)n!=m)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
|
||||
n=0;
|
||||
}
|
||||
return(n);
|
||||
static const char module[] = "TIFFStripSize";
|
||||
uint64 m;
|
||||
tmsize_t n;
|
||||
m=TIFFStripSize64(tif);
|
||||
n=(tmsize_t)m;
|
||||
if ((uint64)n!=m)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
|
||||
n=0;
|
||||
}
|
||||
return(n);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -233,31 +233,31 @@ TIFFStripSize(TIFF* tif)
|
||||
uint32
|
||||
TIFFDefaultStripSize(TIFF* tif, uint32 request)
|
||||
{
|
||||
return (*tif->tif_defstripsize)(tif, request);
|
||||
return (*tif->tif_defstripsize)(tif, request);
|
||||
}
|
||||
|
||||
uint32
|
||||
_TIFFDefaultStripSize(TIFF* tif, uint32 s)
|
||||
{
|
||||
if ((int32) s < 1) {
|
||||
/*
|
||||
* If RowsPerStrip is unspecified, try to break the
|
||||
* image up into strips that are approximately
|
||||
* STRIP_SIZE_DEFAULT bytes long.
|
||||
*/
|
||||
uint64 scanlinesize;
|
||||
uint64 rows;
|
||||
scanlinesize=TIFFScanlineSize64(tif);
|
||||
if (scanlinesize==0)
|
||||
scanlinesize=1;
|
||||
rows=(uint64)STRIP_SIZE_DEFAULT/scanlinesize;
|
||||
if (rows==0)
|
||||
rows=1;
|
||||
else if (rows>0xFFFFFFFF)
|
||||
rows=0xFFFFFFFF;
|
||||
s=(uint32)rows;
|
||||
}
|
||||
return (s);
|
||||
if ((int32) s < 1) {
|
||||
/*
|
||||
* If RowsPerStrip is unspecified, try to break the
|
||||
* image up into strips that are approximately
|
||||
* STRIP_SIZE_DEFAULT bytes long.
|
||||
*/
|
||||
uint64 scanlinesize;
|
||||
uint64 rows;
|
||||
scanlinesize=TIFFScanlineSize64(tif);
|
||||
if (scanlinesize==0)
|
||||
scanlinesize=1;
|
||||
rows=(uint64)STRIP_SIZE_DEFAULT/scanlinesize;
|
||||
if (rows==0)
|
||||
rows=1;
|
||||
else if (rows>0xFFFFFFFF)
|
||||
rows=0xFFFFFFFF;
|
||||
s=(uint32)rows;
|
||||
}
|
||||
return (s);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -273,67 +273,73 @@ _TIFFDefaultStripSize(TIFF* tif, uint32 s)
|
||||
uint64
|
||||
TIFFScanlineSize64(TIFF* tif)
|
||||
{
|
||||
static const char module[] = "TIFFScanlineSize64";
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
uint64 scanline_size;
|
||||
if (td->td_planarconfig==PLANARCONFIG_CONTIG)
|
||||
{
|
||||
if ((td->td_photometric==PHOTOMETRIC_YCBCR)&&
|
||||
(td->td_samplesperpixel==3)&&
|
||||
(!isUpSampled(tif)))
|
||||
{
|
||||
uint16 ycbcrsubsampling[2];
|
||||
uint16 samplingblock_samples;
|
||||
uint32 samplingblocks_hor;
|
||||
uint64 samplingrow_samples;
|
||||
uint64 samplingrow_size;
|
||||
if(td->td_samplesperpixel!=3)
|
||||
{
|
||||
static const char module[] = "TIFFScanlineSize64";
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
uint64 scanline_size;
|
||||
if (td->td_planarconfig==PLANARCONFIG_CONTIG)
|
||||
{
|
||||
if ((td->td_photometric==PHOTOMETRIC_YCBCR)&&
|
||||
(td->td_samplesperpixel==3)&&
|
||||
(!isUpSampled(tif)))
|
||||
{
|
||||
uint16 ycbcrsubsampling[2];
|
||||
uint16 samplingblock_samples;
|
||||
uint32 samplingblocks_hor;
|
||||
uint64 samplingrow_samples;
|
||||
uint64 samplingrow_size;
|
||||
if(td->td_samplesperpixel!=3)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,
|
||||
"Invalid td_samplesperpixel value");
|
||||
return 0;
|
||||
}
|
||||
TIFFGetFieldDefaulted(tif,TIFFTAG_YCBCRSUBSAMPLING,
|
||||
}
|
||||
TIFFGetFieldDefaulted(tif,TIFFTAG_YCBCRSUBSAMPLING,
|
||||
ycbcrsubsampling+0,
|
||||
ycbcrsubsampling+1);
|
||||
if (((ycbcrsubsampling[0]!=1)&&(ycbcrsubsampling[0]!=2)&&(ycbcrsubsampling[0]!=4)) ||
|
||||
((ycbcrsubsampling[1]!=1)&&(ycbcrsubsampling[1]!=2)&&(ycbcrsubsampling[1]!=4)))
|
||||
{
|
||||
if (((ycbcrsubsampling[0]!=1)&&(ycbcrsubsampling[0]!=2)&&(ycbcrsubsampling[0]!=4)) ||
|
||||
((ycbcrsubsampling[1]!=1)&&(ycbcrsubsampling[1]!=2)&&(ycbcrsubsampling[1]!=4)))
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,
|
||||
"Invalid YCbCr subsampling");
|
||||
return 0;
|
||||
}
|
||||
samplingblock_samples = ycbcrsubsampling[0]*ycbcrsubsampling[1]+2;
|
||||
samplingblocks_hor = TIFFhowmany_32(td->td_imagewidth,ycbcrsubsampling[0]);
|
||||
samplingrow_samples = _TIFFMultiply64(tif,samplingblocks_hor,samplingblock_samples,module);
|
||||
samplingrow_size = TIFFhowmany_64(_TIFFMultiply64(tif,samplingrow_samples,td->td_bitspersample,module),8);
|
||||
scanline_size = (samplingrow_size/ycbcrsubsampling[1]);
|
||||
}
|
||||
else
|
||||
}
|
||||
samplingblock_samples = ycbcrsubsampling[0]*ycbcrsubsampling[1]+2;
|
||||
samplingblocks_hor = TIFFhowmany_32(td->td_imagewidth,ycbcrsubsampling[0]);
|
||||
samplingrow_samples = _TIFFMultiply64(tif,samplingblocks_hor,samplingblock_samples,module);
|
||||
samplingrow_size = TIFFhowmany_64(_TIFFMultiply64(tif,samplingrow_samples,td->td_bitspersample,module),8);
|
||||
scanline_size = (samplingrow_size/ycbcrsubsampling[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint64 scanline_samples;
|
||||
scanline_samples=_TIFFMultiply64(tif,td->td_imagewidth,td->td_samplesperpixel,module);
|
||||
scanline_size=TIFFhowmany_64(_TIFFMultiply64(tif,scanline_samples,td->td_bitspersample,module),8);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
uint64 scanline_samples;
|
||||
scanline_samples=_TIFFMultiply64(tif,td->td_imagewidth,td->td_samplesperpixel,module);
|
||||
scanline_size=TIFFhowmany_64(_TIFFMultiply64(tif,scanline_samples,td->td_bitspersample,module),8);
|
||||
scanline_size=TIFFhowmany_64(_TIFFMultiply64(tif,td->td_imagewidth,td->td_bitspersample,module),8);
|
||||
}
|
||||
}
|
||||
else
|
||||
scanline_size=TIFFhowmany_64(_TIFFMultiply64(tif,td->td_imagewidth,td->td_bitspersample,module),8);
|
||||
return(scanline_size);
|
||||
if (scanline_size == 0)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Computed scanline size is zero");
|
||||
return 0;
|
||||
}
|
||||
return(scanline_size);
|
||||
}
|
||||
tmsize_t
|
||||
TIFFScanlineSize(TIFF* tif)
|
||||
{
|
||||
static const char module[] = "TIFFScanlineSize";
|
||||
uint64 m;
|
||||
tmsize_t n;
|
||||
m=TIFFScanlineSize64(tif);
|
||||
n=(tmsize_t)m;
|
||||
if ((uint64)n!=m)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Integer arithmetic overflow");
|
||||
n=0;
|
||||
}
|
||||
return(n);
|
||||
static const char module[] = "TIFFScanlineSize";
|
||||
uint64 m;
|
||||
tmsize_t n;
|
||||
m=TIFFScanlineSize64(tif);
|
||||
n=(tmsize_t)m;
|
||||
if ((uint64)n!=m) {
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Integer arithmetic overflow");
|
||||
n=0;
|
||||
}
|
||||
return(n);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -345,32 +351,32 @@ TIFFScanlineSize(TIFF* tif)
|
||||
uint64
|
||||
TIFFRasterScanlineSize64(TIFF* tif)
|
||||
{
|
||||
static const char module[] = "TIFFRasterScanlineSize64";
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
uint64 scanline;
|
||||
static const char module[] = "TIFFRasterScanlineSize64";
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
uint64 scanline;
|
||||
|
||||
scanline = _TIFFMultiply64(tif, td->td_bitspersample, td->td_imagewidth, module);
|
||||
if (td->td_planarconfig == PLANARCONFIG_CONTIG) {
|
||||
scanline = _TIFFMultiply64(tif, scanline, td->td_samplesperpixel, module);
|
||||
return (TIFFhowmany8_64(scanline));
|
||||
} else
|
||||
return (_TIFFMultiply64(tif, TIFFhowmany8_64(scanline),
|
||||
td->td_samplesperpixel, module));
|
||||
scanline = _TIFFMultiply64(tif, td->td_bitspersample, td->td_imagewidth, module);
|
||||
if (td->td_planarconfig == PLANARCONFIG_CONTIG) {
|
||||
scanline = _TIFFMultiply64(tif, scanline, td->td_samplesperpixel, module);
|
||||
return (TIFFhowmany8_64(scanline));
|
||||
} else
|
||||
return (_TIFFMultiply64(tif, TIFFhowmany8_64(scanline),
|
||||
td->td_samplesperpixel, module));
|
||||
}
|
||||
tmsize_t
|
||||
TIFFRasterScanlineSize(TIFF* tif)
|
||||
{
|
||||
static const char module[] = "TIFFRasterScanlineSize";
|
||||
uint64 m;
|
||||
tmsize_t n;
|
||||
m=TIFFRasterScanlineSize64(tif);
|
||||
n=(tmsize_t)m;
|
||||
if ((uint64)n!=m)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Integer arithmetic overflow");
|
||||
n=0;
|
||||
}
|
||||
return(n);
|
||||
static const char module[] = "TIFFRasterScanlineSize";
|
||||
uint64 m;
|
||||
tmsize_t n;
|
||||
m=TIFFRasterScanlineSize64(tif);
|
||||
n=(tmsize_t)m;
|
||||
if ((uint64)n!=m)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Integer arithmetic overflow");
|
||||
n=0;
|
||||
}
|
||||
return(n);
|
||||
}
|
||||
|
||||
/* vim: set ts=8 sts=8 sw=8 noet: */
|
||||
|
||||
Vendored
+158
-156
@@ -1,26 +1,26 @@
|
||||
/* $Id: tif_swab.c,v 1.13 2010-03-10 18:56:49 bfriesen Exp $ */
|
||||
/* $Id: tif_swab.c,v 1.15 2017-06-08 16:39:50 erouault Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
@@ -31,170 +31,170 @@
|
||||
*/
|
||||
#include "tiffiop.h"
|
||||
|
||||
#ifndef TIFFSwabShort
|
||||
#if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabShort)
|
||||
void
|
||||
TIFFSwabShort(uint16* wp)
|
||||
{
|
||||
register unsigned char* cp = (unsigned char*) wp;
|
||||
unsigned char t;
|
||||
assert(sizeof(uint16)==2);
|
||||
t = cp[1]; cp[1] = cp[0]; cp[0] = t;
|
||||
register unsigned char* cp = (unsigned char*) wp;
|
||||
unsigned char t;
|
||||
assert(sizeof(uint16)==2);
|
||||
t = cp[1]; cp[1] = cp[0]; cp[0] = t;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef TIFFSwabLong
|
||||
#if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabLong)
|
||||
void
|
||||
TIFFSwabLong(uint32* lp)
|
||||
{
|
||||
register unsigned char* cp = (unsigned char*) lp;
|
||||
unsigned char t;
|
||||
assert(sizeof(uint32)==4);
|
||||
t = cp[3]; cp[3] = cp[0]; cp[0] = t;
|
||||
t = cp[2]; cp[2] = cp[1]; cp[1] = t;
|
||||
register unsigned char* cp = (unsigned char*) lp;
|
||||
unsigned char t;
|
||||
assert(sizeof(uint32)==4);
|
||||
t = cp[3]; cp[3] = cp[0]; cp[0] = t;
|
||||
t = cp[2]; cp[2] = cp[1]; cp[1] = t;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef TIFFSwabLong8
|
||||
#if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabLong8)
|
||||
void
|
||||
TIFFSwabLong8(uint64* lp)
|
||||
{
|
||||
register unsigned char* cp = (unsigned char*) lp;
|
||||
unsigned char t;
|
||||
assert(sizeof(uint64)==8);
|
||||
t = cp[7]; cp[7] = cp[0]; cp[0] = t;
|
||||
t = cp[6]; cp[6] = cp[1]; cp[1] = t;
|
||||
t = cp[5]; cp[5] = cp[2]; cp[2] = t;
|
||||
t = cp[4]; cp[4] = cp[3]; cp[3] = t;
|
||||
register unsigned char* cp = (unsigned char*) lp;
|
||||
unsigned char t;
|
||||
assert(sizeof(uint64)==8);
|
||||
t = cp[7]; cp[7] = cp[0]; cp[0] = t;
|
||||
t = cp[6]; cp[6] = cp[1]; cp[1] = t;
|
||||
t = cp[5]; cp[5] = cp[2]; cp[2] = t;
|
||||
t = cp[4]; cp[4] = cp[3]; cp[3] = t;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef TIFFSwabArrayOfShort
|
||||
#if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabArrayOfShort)
|
||||
void
|
||||
TIFFSwabArrayOfShort(register uint16* wp, tmsize_t n)
|
||||
{
|
||||
register unsigned char* cp;
|
||||
register unsigned char t;
|
||||
assert(sizeof(uint16)==2);
|
||||
/* XXX unroll loop some */
|
||||
while (n-- > 0) {
|
||||
cp = (unsigned char*) wp;
|
||||
t = cp[1]; cp[1] = cp[0]; cp[0] = t;
|
||||
wp++;
|
||||
}
|
||||
register unsigned char* cp;
|
||||
register unsigned char t;
|
||||
assert(sizeof(uint16)==2);
|
||||
/* XXX unroll loop some */
|
||||
while (n-- > 0) {
|
||||
cp = (unsigned char*) wp;
|
||||
t = cp[1]; cp[1] = cp[0]; cp[0] = t;
|
||||
wp++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef TIFFSwabArrayOfTriples
|
||||
#if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabArrayOfTriples)
|
||||
void
|
||||
TIFFSwabArrayOfTriples(register uint8* tp, tmsize_t n)
|
||||
{
|
||||
unsigned char* cp;
|
||||
unsigned char t;
|
||||
unsigned char* cp;
|
||||
unsigned char t;
|
||||
|
||||
/* XXX unroll loop some */
|
||||
while (n-- > 0) {
|
||||
cp = (unsigned char*) tp;
|
||||
t = cp[2]; cp[2] = cp[0]; cp[0] = t;
|
||||
tp += 3;
|
||||
}
|
||||
/* XXX unroll loop some */
|
||||
while (n-- > 0) {
|
||||
cp = (unsigned char*) tp;
|
||||
t = cp[2]; cp[2] = cp[0]; cp[0] = t;
|
||||
tp += 3;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef TIFFSwabArrayOfLong
|
||||
#if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabArrayOfLong)
|
||||
void
|
||||
TIFFSwabArrayOfLong(register uint32* lp, tmsize_t n)
|
||||
{
|
||||
register unsigned char *cp;
|
||||
register unsigned char t;
|
||||
assert(sizeof(uint32)==4);
|
||||
/* XXX unroll loop some */
|
||||
while (n-- > 0) {
|
||||
cp = (unsigned char *)lp;
|
||||
t = cp[3]; cp[3] = cp[0]; cp[0] = t;
|
||||
t = cp[2]; cp[2] = cp[1]; cp[1] = t;
|
||||
lp++;
|
||||
}
|
||||
register unsigned char *cp;
|
||||
register unsigned char t;
|
||||
assert(sizeof(uint32)==4);
|
||||
/* XXX unroll loop some */
|
||||
while (n-- > 0) {
|
||||
cp = (unsigned char *)lp;
|
||||
t = cp[3]; cp[3] = cp[0]; cp[0] = t;
|
||||
t = cp[2]; cp[2] = cp[1]; cp[1] = t;
|
||||
lp++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef TIFFSwabArrayOfLong8
|
||||
#if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabArrayOfLong8)
|
||||
void
|
||||
TIFFSwabArrayOfLong8(register uint64* lp, tmsize_t n)
|
||||
{
|
||||
register unsigned char *cp;
|
||||
register unsigned char t;
|
||||
assert(sizeof(uint64)==8);
|
||||
/* XXX unroll loop some */
|
||||
while (n-- > 0) {
|
||||
cp = (unsigned char *)lp;
|
||||
t = cp[7]; cp[7] = cp[0]; cp[0] = t;
|
||||
t = cp[6]; cp[6] = cp[1]; cp[1] = t;
|
||||
t = cp[5]; cp[5] = cp[2]; cp[2] = t;
|
||||
t = cp[4]; cp[4] = cp[3]; cp[3] = t;
|
||||
lp++;
|
||||
}
|
||||
register unsigned char *cp;
|
||||
register unsigned char t;
|
||||
assert(sizeof(uint64)==8);
|
||||
/* XXX unroll loop some */
|
||||
while (n-- > 0) {
|
||||
cp = (unsigned char *)lp;
|
||||
t = cp[7]; cp[7] = cp[0]; cp[0] = t;
|
||||
t = cp[6]; cp[6] = cp[1]; cp[1] = t;
|
||||
t = cp[5]; cp[5] = cp[2]; cp[2] = t;
|
||||
t = cp[4]; cp[4] = cp[3]; cp[3] = t;
|
||||
lp++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef TIFFSwabFloat
|
||||
#if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabFloat)
|
||||
void
|
||||
TIFFSwabFloat(float* fp)
|
||||
{
|
||||
register unsigned char* cp = (unsigned char*) fp;
|
||||
unsigned char t;
|
||||
assert(sizeof(float)==4);
|
||||
t = cp[3]; cp[3] = cp[0]; cp[0] = t;
|
||||
t = cp[2]; cp[2] = cp[1]; cp[1] = t;
|
||||
register unsigned char* cp = (unsigned char*) fp;
|
||||
unsigned char t;
|
||||
assert(sizeof(float)==4);
|
||||
t = cp[3]; cp[3] = cp[0]; cp[0] = t;
|
||||
t = cp[2]; cp[2] = cp[1]; cp[1] = t;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef TIFFSwabArrayOfFloat
|
||||
#if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabArrayOfFloat)
|
||||
void
|
||||
TIFFSwabArrayOfFloat(register float* fp, tmsize_t n)
|
||||
{
|
||||
register unsigned char *cp;
|
||||
register unsigned char t;
|
||||
assert(sizeof(float)==4);
|
||||
/* XXX unroll loop some */
|
||||
while (n-- > 0) {
|
||||
cp = (unsigned char *)fp;
|
||||
t = cp[3]; cp[3] = cp[0]; cp[0] = t;
|
||||
t = cp[2]; cp[2] = cp[1]; cp[1] = t;
|
||||
fp++;
|
||||
}
|
||||
register unsigned char *cp;
|
||||
register unsigned char t;
|
||||
assert(sizeof(float)==4);
|
||||
/* XXX unroll loop some */
|
||||
while (n-- > 0) {
|
||||
cp = (unsigned char *)fp;
|
||||
t = cp[3]; cp[3] = cp[0]; cp[0] = t;
|
||||
t = cp[2]; cp[2] = cp[1]; cp[1] = t;
|
||||
fp++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef TIFFSwabDouble
|
||||
#if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabDouble)
|
||||
void
|
||||
TIFFSwabDouble(double *dp)
|
||||
{
|
||||
register unsigned char* cp = (unsigned char*) dp;
|
||||
unsigned char t;
|
||||
assert(sizeof(double)==8);
|
||||
t = cp[7]; cp[7] = cp[0]; cp[0] = t;
|
||||
t = cp[6]; cp[6] = cp[1]; cp[1] = t;
|
||||
t = cp[5]; cp[5] = cp[2]; cp[2] = t;
|
||||
t = cp[4]; cp[4] = cp[3]; cp[3] = t;
|
||||
register unsigned char* cp = (unsigned char*) dp;
|
||||
unsigned char t;
|
||||
assert(sizeof(double)==8);
|
||||
t = cp[7]; cp[7] = cp[0]; cp[0] = t;
|
||||
t = cp[6]; cp[6] = cp[1]; cp[1] = t;
|
||||
t = cp[5]; cp[5] = cp[2]; cp[2] = t;
|
||||
t = cp[4]; cp[4] = cp[3]; cp[3] = t;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef TIFFSwabArrayOfDouble
|
||||
#if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabArrayOfDouble)
|
||||
void
|
||||
TIFFSwabArrayOfDouble(double* dp, tmsize_t n)
|
||||
{
|
||||
register unsigned char *cp;
|
||||
register unsigned char t;
|
||||
assert(sizeof(double)==8);
|
||||
/* XXX unroll loop some */
|
||||
while (n-- > 0) {
|
||||
cp = (unsigned char *)dp;
|
||||
t = cp[7]; cp[7] = cp[0]; cp[0] = t;
|
||||
t = cp[6]; cp[6] = cp[1]; cp[1] = t;
|
||||
t = cp[5]; cp[5] = cp[2]; cp[2] = t;
|
||||
t = cp[4]; cp[4] = cp[3]; cp[3] = t;
|
||||
dp++;
|
||||
}
|
||||
register unsigned char *cp;
|
||||
register unsigned char t;
|
||||
assert(sizeof(double)==8);
|
||||
/* XXX unroll loop some */
|
||||
while (n-- > 0) {
|
||||
cp = (unsigned char *)dp;
|
||||
t = cp[7]; cp[7] = cp[0]; cp[0] = t;
|
||||
t = cp[6]; cp[6] = cp[1]; cp[1] = t;
|
||||
t = cp[5]; cp[5] = cp[2]; cp[2] = t;
|
||||
t = cp[4]; cp[4] = cp[3]; cp[3] = t;
|
||||
dp++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -242,62 +242,64 @@ static const unsigned char TIFFBitRevTable[256] = {
|
||||
0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
|
||||
};
|
||||
static const unsigned char TIFFNoBitRevTable[256] = {
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
||||
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
|
||||
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
|
||||
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
||||
0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
|
||||
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
|
||||
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
|
||||
0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
|
||||
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
|
||||
0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
|
||||
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
|
||||
0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
|
||||
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
|
||||
0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
|
||||
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
|
||||
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
|
||||
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
|
||||
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
|
||||
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
|
||||
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
|
||||
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
|
||||
0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
|
||||
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
|
||||
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
||||
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
|
||||
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
|
||||
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
||||
0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
|
||||
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
|
||||
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
|
||||
0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
|
||||
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
|
||||
0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
|
||||
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
|
||||
0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
|
||||
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
|
||||
0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
|
||||
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
|
||||
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
|
||||
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
|
||||
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
|
||||
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
|
||||
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
|
||||
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
|
||||
0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
|
||||
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
|
||||
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
|
||||
};
|
||||
|
||||
const unsigned char*
|
||||
TIFFGetBitRevTable(int reversed)
|
||||
{
|
||||
return (reversed ? TIFFBitRevTable : TIFFNoBitRevTable);
|
||||
return (reversed ? TIFFBitRevTable : TIFFNoBitRevTable);
|
||||
}
|
||||
|
||||
void
|
||||
TIFFReverseBits(uint8* cp, tmsize_t n)
|
||||
TIFFReverseBits(uint8* cp, tmsize_t n)
|
||||
{
|
||||
for (; n > 8; n -= 8) {
|
||||
cp[0] = TIFFBitRevTable[cp[0]];
|
||||
cp[1] = TIFFBitRevTable[cp[1]];
|
||||
cp[2] = TIFFBitRevTable[cp[2]];
|
||||
cp[3] = TIFFBitRevTable[cp[3]];
|
||||
cp[4] = TIFFBitRevTable[cp[4]];
|
||||
cp[5] = TIFFBitRevTable[cp[5]];
|
||||
cp[6] = TIFFBitRevTable[cp[6]];
|
||||
cp[7] = TIFFBitRevTable[cp[7]];
|
||||
cp += 8;
|
||||
}
|
||||
while (n-- > 0)
|
||||
*cp = TIFFBitRevTable[*cp], cp++;
|
||||
for (; n > 8; n -= 8) {
|
||||
cp[0] = TIFFBitRevTable[cp[0]];
|
||||
cp[1] = TIFFBitRevTable[cp[1]];
|
||||
cp[2] = TIFFBitRevTable[cp[2]];
|
||||
cp[3] = TIFFBitRevTable[cp[3]];
|
||||
cp[4] = TIFFBitRevTable[cp[4]];
|
||||
cp[5] = TIFFBitRevTable[cp[5]];
|
||||
cp[6] = TIFFBitRevTable[cp[6]];
|
||||
cp[7] = TIFFBitRevTable[cp[7]];
|
||||
cp += 8;
|
||||
}
|
||||
while (n-- > 0) {
|
||||
*cp = TIFFBitRevTable[*cp];
|
||||
cp++;
|
||||
}
|
||||
}
|
||||
|
||||
/* vim: set ts=8 sts=8 sw=8 noet: */
|
||||
|
||||
Vendored
+106
-105
@@ -1,26 +1,26 @@
|
||||
/* $Id: tif_thunder.c,v 1.12 2011-04-02 20:54:09 bfriesen Exp $ */
|
||||
/* $Id: tif_thunder.c,v 1.13 2016-09-04 21:32:56 erouault Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
@@ -57,20 +57,20 @@ static const int twobitdeltas[4] = { 0, 1, 0, -1 };
|
||||
static const int threebitdeltas[8] = { 0, 1, 2, 3, 0, -3, -2, -1 };
|
||||
|
||||
#define SETPIXEL(op, v) { \
|
||||
lastpixel = (v) & 0xf; \
|
||||
lastpixel = (v) & 0xf; \
|
||||
if ( npixels < maxpixels ) \
|
||||
{ \
|
||||
if (npixels++ & 1) \
|
||||
*op++ |= lastpixel; \
|
||||
else \
|
||||
op[0] = (uint8) (lastpixel << 4); \
|
||||
if (npixels++ & 1) \
|
||||
*op++ |= lastpixel; \
|
||||
else \
|
||||
op[0] = (uint8) (lastpixel << 4); \
|
||||
} \
|
||||
}
|
||||
|
||||
static int
|
||||
ThunderSetupDecode(TIFF* tif)
|
||||
{
|
||||
static const char module[] = "ThunderSetupDecode";
|
||||
static const char module[] = "ThunderSetupDecode";
|
||||
|
||||
if( tif->tif_dir.td_bitspersample != 4 )
|
||||
{
|
||||
@@ -79,87 +79,88 @@ ThunderSetupDecode(TIFF* tif)
|
||||
(int) tif->tif_dir.td_bitspersample );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return (1);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
ThunderDecode(TIFF* tif, uint8* op, tmsize_t maxpixels)
|
||||
{
|
||||
static const char module[] = "ThunderDecode";
|
||||
register unsigned char *bp;
|
||||
register tmsize_t cc;
|
||||
unsigned int lastpixel;
|
||||
tmsize_t npixels;
|
||||
static const char module[] = "ThunderDecode";
|
||||
register unsigned char *bp;
|
||||
register tmsize_t cc;
|
||||
unsigned int lastpixel;
|
||||
tmsize_t npixels;
|
||||
|
||||
bp = (unsigned char *)tif->tif_rawcp;
|
||||
cc = tif->tif_rawcc;
|
||||
lastpixel = 0;
|
||||
npixels = 0;
|
||||
while (cc > 0 && npixels < maxpixels) {
|
||||
int n, delta;
|
||||
bp = (unsigned char *)tif->tif_rawcp;
|
||||
cc = tif->tif_rawcc;
|
||||
lastpixel = 0;
|
||||
npixels = 0;
|
||||
while (cc > 0 && npixels < maxpixels) {
|
||||
int n, delta;
|
||||
|
||||
n = *bp++, cc--;
|
||||
switch (n & THUNDER_CODE) {
|
||||
case THUNDER_RUN: /* pixel run */
|
||||
/*
|
||||
* Replicate the last pixel n times,
|
||||
* where n is the lower-order 6 bits.
|
||||
*/
|
||||
if (npixels & 1) {
|
||||
op[0] |= lastpixel;
|
||||
lastpixel = *op++; npixels++; n--;
|
||||
} else
|
||||
lastpixel |= lastpixel << 4;
|
||||
npixels += n;
|
||||
if (npixels < maxpixels) {
|
||||
for (; n > 0; n -= 2)
|
||||
*op++ = (uint8) lastpixel;
|
||||
}
|
||||
if (n == -1)
|
||||
*--op &= 0xf0;
|
||||
lastpixel &= 0xf;
|
||||
break;
|
||||
case THUNDER_2BITDELTAS: /* 2-bit deltas */
|
||||
if ((delta = ((n >> 4) & 3)) != DELTA2_SKIP)
|
||||
SETPIXEL(op, lastpixel + twobitdeltas[delta]);
|
||||
if ((delta = ((n >> 2) & 3)) != DELTA2_SKIP)
|
||||
SETPIXEL(op, lastpixel + twobitdeltas[delta]);
|
||||
if ((delta = (n & 3)) != DELTA2_SKIP)
|
||||
SETPIXEL(op, lastpixel + twobitdeltas[delta]);
|
||||
break;
|
||||
case THUNDER_3BITDELTAS: /* 3-bit deltas */
|
||||
if ((delta = ((n >> 3) & 7)) != DELTA3_SKIP)
|
||||
SETPIXEL(op, lastpixel + threebitdeltas[delta]);
|
||||
if ((delta = (n & 7)) != DELTA3_SKIP)
|
||||
SETPIXEL(op, lastpixel + threebitdeltas[delta]);
|
||||
break;
|
||||
case THUNDER_RAW: /* raw data */
|
||||
SETPIXEL(op, n);
|
||||
break;
|
||||
}
|
||||
}
|
||||
tif->tif_rawcp = (uint8*) bp;
|
||||
tif->tif_rawcc = cc;
|
||||
if (npixels != maxpixels) {
|
||||
n = *bp++;
|
||||
cc--;
|
||||
switch (n & THUNDER_CODE) {
|
||||
case THUNDER_RUN: /* pixel run */
|
||||
/*
|
||||
* Replicate the last pixel n times,
|
||||
* where n is the lower-order 6 bits.
|
||||
*/
|
||||
if (npixels & 1) {
|
||||
op[0] |= lastpixel;
|
||||
lastpixel = *op++; npixels++; n--;
|
||||
} else
|
||||
lastpixel |= lastpixel << 4;
|
||||
npixels += n;
|
||||
if (npixels < maxpixels) {
|
||||
for (; n > 0; n -= 2)
|
||||
*op++ = (uint8) lastpixel;
|
||||
}
|
||||
if (n == -1)
|
||||
*--op &= 0xf0;
|
||||
lastpixel &= 0xf;
|
||||
break;
|
||||
case THUNDER_2BITDELTAS: /* 2-bit deltas */
|
||||
if ((delta = ((n >> 4) & 3)) != DELTA2_SKIP)
|
||||
SETPIXEL(op, lastpixel + twobitdeltas[delta]);
|
||||
if ((delta = ((n >> 2) & 3)) != DELTA2_SKIP)
|
||||
SETPIXEL(op, lastpixel + twobitdeltas[delta]);
|
||||
if ((delta = (n & 3)) != DELTA2_SKIP)
|
||||
SETPIXEL(op, lastpixel + twobitdeltas[delta]);
|
||||
break;
|
||||
case THUNDER_3BITDELTAS: /* 3-bit deltas */
|
||||
if ((delta = ((n >> 3) & 7)) != DELTA3_SKIP)
|
||||
SETPIXEL(op, lastpixel + threebitdeltas[delta]);
|
||||
if ((delta = (n & 7)) != DELTA3_SKIP)
|
||||
SETPIXEL(op, lastpixel + threebitdeltas[delta]);
|
||||
break;
|
||||
case THUNDER_RAW: /* raw data */
|
||||
SETPIXEL(op, n);
|
||||
break;
|
||||
}
|
||||
}
|
||||
tif->tif_rawcp = (uint8*) bp;
|
||||
tif->tif_rawcc = cc;
|
||||
if (npixels != maxpixels) {
|
||||
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"%s data at scanline %lu (%I64u != %I64u)",
|
||||
npixels < maxpixels ? "Not enough" : "Too much",
|
||||
(unsigned long) tif->tif_row,
|
||||
(unsigned __int64) npixels,
|
||||
(unsigned __int64) maxpixels);
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"%s data at scanline %lu (%I64u != %I64u)",
|
||||
npixels < maxpixels ? "Not enough" : "Too much",
|
||||
(unsigned long) tif->tif_row,
|
||||
(unsigned __int64) npixels,
|
||||
(unsigned __int64) maxpixels);
|
||||
#else
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"%s data at scanline %lu (%llu != %llu)",
|
||||
npixels < maxpixels ? "Not enough" : "Too much",
|
||||
(unsigned long) tif->tif_row,
|
||||
(unsigned long long) npixels,
|
||||
(unsigned long long) maxpixels);
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"%s data at scanline %lu (%llu != %llu)",
|
||||
npixels < maxpixels ? "Not enough" : "Too much",
|
||||
(unsigned long) tif->tif_row,
|
||||
(unsigned long long) npixels,
|
||||
(unsigned long long) maxpixels);
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
return (1);
|
||||
}
|
||||
@@ -167,33 +168,33 @@ ThunderDecode(TIFF* tif, uint8* op, tmsize_t maxpixels)
|
||||
static int
|
||||
ThunderDecodeRow(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s)
|
||||
{
|
||||
static const char module[] = "ThunderDecodeRow";
|
||||
uint8* row = buf;
|
||||
|
||||
(void) s;
|
||||
if (occ % tif->tif_scanlinesize)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be read");
|
||||
return (0);
|
||||
}
|
||||
while (occ > 0) {
|
||||
if (!ThunderDecode(tif, row, tif->tif_dir.td_imagewidth))
|
||||
return (0);
|
||||
occ -= tif->tif_scanlinesize;
|
||||
row += tif->tif_scanlinesize;
|
||||
}
|
||||
return (1);
|
||||
static const char module[] = "ThunderDecodeRow";
|
||||
uint8* row = buf;
|
||||
|
||||
(void) s;
|
||||
if (occ % tif->tif_scanlinesize)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be read");
|
||||
return (0);
|
||||
}
|
||||
while (occ > 0) {
|
||||
if (!ThunderDecode(tif, row, tif->tif_dir.td_imagewidth))
|
||||
return (0);
|
||||
occ -= tif->tif_scanlinesize;
|
||||
row += tif->tif_scanlinesize;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
int
|
||||
TIFFInitThunderScan(TIFF* tif, int scheme)
|
||||
{
|
||||
(void) scheme;
|
||||
(void) scheme;
|
||||
|
||||
tif->tif_setupdecode = ThunderSetupDecode;
|
||||
tif->tif_decoderow = ThunderDecodeRow;
|
||||
tif->tif_decodestrip = ThunderDecodeRow;
|
||||
return (1);
|
||||
tif->tif_decoderow = ThunderDecodeRow;
|
||||
tif->tif_decodestrip = ThunderDecodeRow;
|
||||
return (1);
|
||||
}
|
||||
#endif /* THUNDER_SUPPORT */
|
||||
|
||||
|
||||
Vendored
+208
-185
@@ -1,26 +1,26 @@
|
||||
/* $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
|
||||
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
@@ -37,34 +37,34 @@
|
||||
uint32
|
||||
TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s)
|
||||
{
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
uint32 dx = td->td_tilewidth;
|
||||
uint32 dy = td->td_tilelength;
|
||||
uint32 dz = td->td_tiledepth;
|
||||
uint32 tile = 1;
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
uint32 dx = td->td_tilewidth;
|
||||
uint32 dy = td->td_tilelength;
|
||||
uint32 dz = td->td_tiledepth;
|
||||
uint32 tile = 1;
|
||||
|
||||
if (td->td_imagedepth == 1)
|
||||
z = 0;
|
||||
if (dx == (uint32) -1)
|
||||
dx = td->td_imagewidth;
|
||||
if (dy == (uint32) -1)
|
||||
dy = td->td_imagelength;
|
||||
if (dz == (uint32) -1)
|
||||
dz = td->td_imagedepth;
|
||||
if (dx != 0 && dy != 0 && dz != 0) {
|
||||
uint32 xpt = TIFFhowmany_32(td->td_imagewidth, dx);
|
||||
uint32 ypt = TIFFhowmany_32(td->td_imagelength, dy);
|
||||
uint32 zpt = TIFFhowmany_32(td->td_imagedepth, dz);
|
||||
if (td->td_imagedepth == 1)
|
||||
z = 0;
|
||||
if (dx == (uint32) -1)
|
||||
dx = td->td_imagewidth;
|
||||
if (dy == (uint32) -1)
|
||||
dy = td->td_imagelength;
|
||||
if (dz == (uint32) -1)
|
||||
dz = td->td_imagedepth;
|
||||
if (dx != 0 && dy != 0 && dz != 0) {
|
||||
uint32 xpt = TIFFhowmany_32(td->td_imagewidth, dx);
|
||||
uint32 ypt = TIFFhowmany_32(td->td_imagelength, dy);
|
||||
uint32 zpt = TIFFhowmany_32(td->td_imagedepth, dz);
|
||||
|
||||
if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
|
||||
tile = (xpt*ypt*zpt)*s +
|
||||
(xpt*ypt)*(z/dz) +
|
||||
xpt*(y/dy) +
|
||||
x/dx;
|
||||
else
|
||||
tile = (xpt*ypt)*(z/dz) + xpt*(y/dy) + x/dx;
|
||||
}
|
||||
return (tile);
|
||||
if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
|
||||
tile = (xpt*ypt*zpt)*s +
|
||||
(xpt*ypt)*(z/dz) +
|
||||
xpt*(y/dy) +
|
||||
x/dx;
|
||||
else
|
||||
tile = (xpt*ypt)*(z/dz) + xpt*(y/dy) + x/dx;
|
||||
}
|
||||
return (tile);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -74,38 +74,38 @@ TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s)
|
||||
int
|
||||
TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s)
|
||||
{
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
|
||||
if (x >= td->td_imagewidth) {
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||
"%lu: Col out of range, max %lu",
|
||||
(unsigned long) x,
|
||||
(unsigned long) (td->td_imagewidth - 1));
|
||||
return (0);
|
||||
}
|
||||
if (y >= td->td_imagelength) {
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||
"%lu: Row out of range, max %lu",
|
||||
(unsigned long) y,
|
||||
(unsigned long) (td->td_imagelength - 1));
|
||||
return (0);
|
||||
}
|
||||
if (z >= td->td_imagedepth) {
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||
"%lu: Depth out of range, max %lu",
|
||||
(unsigned long) z,
|
||||
(unsigned long) (td->td_imagedepth - 1));
|
||||
return (0);
|
||||
}
|
||||
if (td->td_planarconfig == PLANARCONFIG_SEPARATE &&
|
||||
s >= td->td_samplesperpixel) {
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||
"%lu: Sample out of range, max %lu",
|
||||
(unsigned long) s,
|
||||
(unsigned long) (td->td_samplesperpixel - 1));
|
||||
return (0);
|
||||
}
|
||||
return (1);
|
||||
if (x >= td->td_imagewidth) {
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||
"%lu: Col out of range, max %lu",
|
||||
(unsigned long) x,
|
||||
(unsigned long) (td->td_imagewidth - 1));
|
||||
return (0);
|
||||
}
|
||||
if (y >= td->td_imagelength) {
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||
"%lu: Row out of range, max %lu",
|
||||
(unsigned long) y,
|
||||
(unsigned long) (td->td_imagelength - 1));
|
||||
return (0);
|
||||
}
|
||||
if (z >= td->td_imagedepth) {
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||
"%lu: Depth out of range, max %lu",
|
||||
(unsigned long) z,
|
||||
(unsigned long) (td->td_imagedepth - 1));
|
||||
return (0);
|
||||
}
|
||||
if (td->td_planarconfig == PLANARCONFIG_SEPARATE &&
|
||||
s >= td->td_samplesperpixel) {
|
||||
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
|
||||
"%lu: Sample out of range, max %lu",
|
||||
(unsigned long) s,
|
||||
(unsigned long) (td->td_samplesperpixel - 1));
|
||||
return (0);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -114,27 +114,27 @@ TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s)
|
||||
uint32
|
||||
TIFFNumberOfTiles(TIFF* tif)
|
||||
{
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
uint32 dx = td->td_tilewidth;
|
||||
uint32 dy = td->td_tilelength;
|
||||
uint32 dz = td->td_tiledepth;
|
||||
uint32 ntiles;
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
uint32 dx = td->td_tilewidth;
|
||||
uint32 dy = td->td_tilelength;
|
||||
uint32 dz = td->td_tiledepth;
|
||||
uint32 ntiles;
|
||||
|
||||
if (dx == (uint32) -1)
|
||||
dx = td->td_imagewidth;
|
||||
if (dy == (uint32) -1)
|
||||
dy = td->td_imagelength;
|
||||
if (dz == (uint32) -1)
|
||||
dz = td->td_imagedepth;
|
||||
ntiles = (dx == 0 || dy == 0 || dz == 0) ? 0 :
|
||||
_TIFFMultiply32(tif, _TIFFMultiply32(tif, TIFFhowmany_32(td->td_imagewidth, dx),
|
||||
TIFFhowmany_32(td->td_imagelength, dy),
|
||||
"TIFFNumberOfTiles"),
|
||||
TIFFhowmany_32(td->td_imagedepth, dz), "TIFFNumberOfTiles");
|
||||
if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
|
||||
ntiles = _TIFFMultiply32(tif, ntiles, td->td_samplesperpixel,
|
||||
"TIFFNumberOfTiles");
|
||||
return (ntiles);
|
||||
if (dx == (uint32) -1)
|
||||
dx = td->td_imagewidth;
|
||||
if (dy == (uint32) -1)
|
||||
dy = td->td_imagelength;
|
||||
if (dz == (uint32) -1)
|
||||
dz = td->td_imagedepth;
|
||||
ntiles = (dx == 0 || dy == 0 || dz == 0) ? 0 :
|
||||
_TIFFMultiply32(tif, _TIFFMultiply32(tif, TIFFhowmany_32(td->td_imagewidth, dx),
|
||||
TIFFhowmany_32(td->td_imagelength, dy),
|
||||
"TIFFNumberOfTiles"),
|
||||
TIFFhowmany_32(td->td_imagedepth, dz), "TIFFNumberOfTiles");
|
||||
if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
|
||||
ntiles = _TIFFMultiply32(tif, ntiles, td->td_samplesperpixel,
|
||||
"TIFFNumberOfTiles");
|
||||
return (ntiles);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -143,32 +143,55 @@ TIFFNumberOfTiles(TIFF* tif)
|
||||
uint64
|
||||
TIFFTileRowSize64(TIFF* tif)
|
||||
{
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
uint64 rowsize;
|
||||
static const char module[] = "TIFFTileRowSize64";
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
uint64 rowsize;
|
||||
uint64 tilerowsize;
|
||||
|
||||
if (td->td_tilelength == 0 || td->td_tilewidth == 0)
|
||||
return (0);
|
||||
rowsize = _TIFFMultiply64(tif, td->td_bitspersample, td->td_tilewidth,
|
||||
"TIFFTileRowSize");
|
||||
if (td->td_planarconfig == PLANARCONFIG_CONTIG)
|
||||
rowsize = _TIFFMultiply64(tif, rowsize, td->td_samplesperpixel,
|
||||
"TIFFTileRowSize");
|
||||
return (TIFFhowmany8_64(rowsize));
|
||||
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");
|
||||
}
|
||||
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)
|
||||
{
|
||||
static const char module[] = "TIFFTileRowSize";
|
||||
uint64 m;
|
||||
tmsize_t n;
|
||||
m=TIFFTileRowSize64(tif);
|
||||
n=(tmsize_t)m;
|
||||
if ((uint64)n!=m)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
|
||||
n=0;
|
||||
}
|
||||
return(n);
|
||||
static const char module[] = "TIFFTileRowSize";
|
||||
uint64 m;
|
||||
tmsize_t n;
|
||||
m=TIFFTileRowSize64(tif);
|
||||
n=(tmsize_t)m;
|
||||
if ((uint64)n!=m)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
|
||||
n=0;
|
||||
}
|
||||
return(n);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -177,65 +200,65 @@ TIFFTileRowSize(TIFF* tif)
|
||||
uint64
|
||||
TIFFVTileSize64(TIFF* tif, uint32 nrows)
|
||||
{
|
||||
static const char module[] = "TIFFVTileSize64";
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
if (td->td_tilelength == 0 || td->td_tilewidth == 0 ||
|
||||
td->td_tiledepth == 0)
|
||||
return (0);
|
||||
if ((td->td_planarconfig==PLANARCONFIG_CONTIG)&&
|
||||
(td->td_photometric==PHOTOMETRIC_YCBCR)&&
|
||||
(td->td_samplesperpixel==3)&&
|
||||
(!isUpSampled(tif)))
|
||||
{
|
||||
/*
|
||||
* Packed YCbCr data contain one Cb+Cr for every
|
||||
* HorizontalSampling*VerticalSampling Y values.
|
||||
* Must also roundup width and height when calculating
|
||||
* since images that are not a multiple of the
|
||||
* horizontal/vertical subsampling area include
|
||||
* YCbCr data for the extended image.
|
||||
*/
|
||||
uint16 ycbcrsubsampling[2];
|
||||
uint16 samplingblock_samples;
|
||||
uint32 samplingblocks_hor;
|
||||
uint32 samplingblocks_ver;
|
||||
uint64 samplingrow_samples;
|
||||
uint64 samplingrow_size;
|
||||
TIFFGetFieldDefaulted(tif,TIFFTAG_YCBCRSUBSAMPLING,ycbcrsubsampling+0,
|
||||
ycbcrsubsampling+1);
|
||||
if ((ycbcrsubsampling[0] != 1 && ycbcrsubsampling[0] != 2 && ycbcrsubsampling[0] != 4)
|
||||
||(ycbcrsubsampling[1] != 1 && ycbcrsubsampling[1] != 2 && ycbcrsubsampling[1] != 4))
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,
|
||||
"Invalid YCbCr subsampling (%dx%d)",
|
||||
ycbcrsubsampling[0],
|
||||
ycbcrsubsampling[1] );
|
||||
return 0;
|
||||
}
|
||||
samplingblock_samples=ycbcrsubsampling[0]*ycbcrsubsampling[1]+2;
|
||||
samplingblocks_hor=TIFFhowmany_32(td->td_tilewidth,ycbcrsubsampling[0]);
|
||||
samplingblocks_ver=TIFFhowmany_32(nrows,ycbcrsubsampling[1]);
|
||||
samplingrow_samples=_TIFFMultiply64(tif,samplingblocks_hor,samplingblock_samples,module);
|
||||
samplingrow_size=TIFFhowmany8_64(_TIFFMultiply64(tif,samplingrow_samples,td->td_bitspersample,module));
|
||||
return(_TIFFMultiply64(tif,samplingrow_size,samplingblocks_ver,module));
|
||||
}
|
||||
else
|
||||
return(_TIFFMultiply64(tif,nrows,TIFFTileRowSize64(tif),module));
|
||||
static const char module[] = "TIFFVTileSize64";
|
||||
TIFFDirectory *td = &tif->tif_dir;
|
||||
if (td->td_tilelength == 0 || td->td_tilewidth == 0 ||
|
||||
td->td_tiledepth == 0)
|
||||
return (0);
|
||||
if ((td->td_planarconfig==PLANARCONFIG_CONTIG)&&
|
||||
(td->td_photometric==PHOTOMETRIC_YCBCR)&&
|
||||
(td->td_samplesperpixel==3)&&
|
||||
(!isUpSampled(tif)))
|
||||
{
|
||||
/*
|
||||
* Packed YCbCr data contain one Cb+Cr for every
|
||||
* HorizontalSampling*VerticalSampling Y values.
|
||||
* Must also roundup width and height when calculating
|
||||
* since images that are not a multiple of the
|
||||
* horizontal/vertical subsampling area include
|
||||
* YCbCr data for the extended image.
|
||||
*/
|
||||
uint16 ycbcrsubsampling[2];
|
||||
uint16 samplingblock_samples;
|
||||
uint32 samplingblocks_hor;
|
||||
uint32 samplingblocks_ver;
|
||||
uint64 samplingrow_samples;
|
||||
uint64 samplingrow_size;
|
||||
TIFFGetFieldDefaulted(tif,TIFFTAG_YCBCRSUBSAMPLING,ycbcrsubsampling+0,
|
||||
ycbcrsubsampling+1);
|
||||
if ((ycbcrsubsampling[0] != 1 && ycbcrsubsampling[0] != 2 && ycbcrsubsampling[0] != 4)
|
||||
||(ycbcrsubsampling[1] != 1 && ycbcrsubsampling[1] != 2 && ycbcrsubsampling[1] != 4))
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,
|
||||
"Invalid YCbCr subsampling (%dx%d)",
|
||||
ycbcrsubsampling[0],
|
||||
ycbcrsubsampling[1] );
|
||||
return 0;
|
||||
}
|
||||
samplingblock_samples=ycbcrsubsampling[0]*ycbcrsubsampling[1]+2;
|
||||
samplingblocks_hor=TIFFhowmany_32(td->td_tilewidth,ycbcrsubsampling[0]);
|
||||
samplingblocks_ver=TIFFhowmany_32(nrows,ycbcrsubsampling[1]);
|
||||
samplingrow_samples=_TIFFMultiply64(tif,samplingblocks_hor,samplingblock_samples,module);
|
||||
samplingrow_size=TIFFhowmany8_64(_TIFFMultiply64(tif,samplingrow_samples,td->td_bitspersample,module));
|
||||
return(_TIFFMultiply64(tif,samplingrow_size,samplingblocks_ver,module));
|
||||
}
|
||||
else
|
||||
return(_TIFFMultiply64(tif,nrows,TIFFTileRowSize64(tif),module));
|
||||
}
|
||||
tmsize_t
|
||||
TIFFVTileSize(TIFF* tif, uint32 nrows)
|
||||
{
|
||||
static const char module[] = "TIFFVTileSize";
|
||||
uint64 m;
|
||||
tmsize_t n;
|
||||
m=TIFFVTileSize64(tif,nrows);
|
||||
n=(tmsize_t)m;
|
||||
if ((uint64)n!=m)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
|
||||
n=0;
|
||||
}
|
||||
return(n);
|
||||
static const char module[] = "TIFFVTileSize";
|
||||
uint64 m;
|
||||
tmsize_t n;
|
||||
m=TIFFVTileSize64(tif,nrows);
|
||||
n=(tmsize_t)m;
|
||||
if ((uint64)n!=m)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
|
||||
n=0;
|
||||
}
|
||||
return(n);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -244,22 +267,22 @@ TIFFVTileSize(TIFF* tif, uint32 nrows)
|
||||
uint64
|
||||
TIFFTileSize64(TIFF* tif)
|
||||
{
|
||||
return (TIFFVTileSize64(tif, tif->tif_dir.td_tilelength));
|
||||
return (TIFFVTileSize64(tif, tif->tif_dir.td_tilelength));
|
||||
}
|
||||
tmsize_t
|
||||
TIFFTileSize(TIFF* tif)
|
||||
{
|
||||
static const char module[] = "TIFFTileSize";
|
||||
uint64 m;
|
||||
tmsize_t n;
|
||||
m=TIFFTileSize64(tif);
|
||||
n=(tmsize_t)m;
|
||||
if ((uint64)n!=m)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
|
||||
n=0;
|
||||
}
|
||||
return(n);
|
||||
static const char module[] = "TIFFTileSize";
|
||||
uint64 m;
|
||||
tmsize_t n;
|
||||
m=TIFFTileSize64(tif);
|
||||
n=(tmsize_t)m;
|
||||
if ((uint64)n!=m)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
|
||||
n=0;
|
||||
}
|
||||
return(n);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -271,22 +294,22 @@ TIFFTileSize(TIFF* tif)
|
||||
void
|
||||
TIFFDefaultTileSize(TIFF* tif, uint32* tw, uint32* th)
|
||||
{
|
||||
(*tif->tif_deftilesize)(tif, tw, th);
|
||||
(*tif->tif_deftilesize)(tif, tw, th);
|
||||
}
|
||||
|
||||
void
|
||||
_TIFFDefaultTileSize(TIFF* tif, uint32* tw, uint32* th)
|
||||
{
|
||||
(void) tif;
|
||||
if (*(int32*) tw < 1)
|
||||
*tw = 256;
|
||||
if (*(int32*) th < 1)
|
||||
*th = 256;
|
||||
/* roundup to a multiple of 16 per the spec */
|
||||
if (*tw & 0xf)
|
||||
*tw = TIFFroundup_32(*tw, 16);
|
||||
if (*th & 0xf)
|
||||
*th = TIFFroundup_32(*th, 16);
|
||||
(void) tif;
|
||||
if (*(int32*) tw < 1)
|
||||
*tw = 256;
|
||||
if (*(int32*) th < 1)
|
||||
*th = 256;
|
||||
/* roundup to a multiple of 16 per the spec */
|
||||
if (*tw & 0xf)
|
||||
*tw = TIFFroundup_32(*tw, 16);
|
||||
if (*th & 0xf)
|
||||
*th = TIFFroundup_32(*th, 16);
|
||||
}
|
||||
|
||||
/* vim: set ts=8 sts=8 sw=8 noet: */
|
||||
|
||||
Vendored
+186
-122
@@ -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.28 2017-01-11 19:02:49 erouault Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@@ -55,56 +55,105 @@
|
||||
|
||||
#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)
|
||||
{
|
||||
errno=EINVAL;
|
||||
return (tmsize_t) -1;
|
||||
}
|
||||
return ((tmsize_t) read((int) fd, buf, size_io));
|
||||
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;
|
||||
}
|
||||
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)
|
||||
{
|
||||
errno=EINVAL;
|
||||
return (tmsize_t) -1;
|
||||
}
|
||||
return ((tmsize_t) write((int) fd, buf, size_io));
|
||||
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;
|
||||
}
|
||||
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;
|
||||
if ((uint64) off_io != off)
|
||||
{
|
||||
errno=EINVAL;
|
||||
return (uint64) -1; /* this is really gross */
|
||||
}
|
||||
return((uint64)lseek((int)fd,off_io,whence));
|
||||
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 */
|
||||
}
|
||||
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)
|
||||
return(0);
|
||||
else
|
||||
return((uint64)sb.st_size);
|
||||
_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);
|
||||
}
|
||||
|
||||
#ifdef HAVE_MMAP
|
||||
@@ -113,37 +162,39 @@ _tiffSizeProc(thandle_t fd)
|
||||
static int
|
||||
_tiffMapProc(thandle_t fd, void** pbase, toff_t* psize)
|
||||
{
|
||||
uint64 size64 = _tiffSizeProc(fd);
|
||||
tmsize_t sizem = (tmsize_t)size64;
|
||||
if ((uint64)sizem==size64) {
|
||||
*pbase = (void*)
|
||||
mmap(0, (size_t)sizem, PROT_READ, MAP_SHARED, (int) fd, 0);
|
||||
if (*pbase != (void*) -1) {
|
||||
*psize = (tmsize_t)sizem;
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
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, fdh.fd, 0);
|
||||
if (*pbase != (void*) -1) {
|
||||
*psize = (tmsize_t)sizem;
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
_tiffUnmapProc(thandle_t fd, void* base, toff_t size)
|
||||
{
|
||||
(void) fd;
|
||||
(void) munmap(base, (off_t) size);
|
||||
(void) fd;
|
||||
(void) munmap(base, (off_t) size);
|
||||
}
|
||||
#else /* !HAVE_MMAP */
|
||||
static int
|
||||
_tiffMapProc(thandle_t fd, void** pbase, toff_t* psize)
|
||||
{
|
||||
(void) fd; (void) pbase; (void) psize;
|
||||
return (0);
|
||||
(void) fd; (void) pbase; (void) psize;
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
_tiffUnmapProc(thandle_t fd, void* base, toff_t size)
|
||||
{
|
||||
(void) fd; (void) base; (void) size;
|
||||
(void) fd; (void) base; (void) size;
|
||||
}
|
||||
#endif /* !HAVE_MMAP */
|
||||
|
||||
@@ -153,16 +204,18 @@ _tiffUnmapProc(thandle_t fd, void* base, toff_t size)
|
||||
TIFF*
|
||||
TIFFFdOpen(int fd, const char* name, const char* mode)
|
||||
{
|
||||
TIFF* tif;
|
||||
TIFF* tif;
|
||||
|
||||
tif = TIFFClientOpen(name, mode,
|
||||
(thandle_t) fd,
|
||||
_tiffReadProc, _tiffWriteProc,
|
||||
_tiffSeekProc, _tiffCloseProc, _tiffSizeProc,
|
||||
_tiffMapProc, _tiffUnmapProc);
|
||||
if (tif)
|
||||
tif->tif_fd = fd;
|
||||
return (tif);
|
||||
fd_as_handle_union_t fdh;
|
||||
fdh.fd = fd;
|
||||
tif = TIFFClientOpen(name, mode,
|
||||
fdh.h,
|
||||
_tiffReadProc, _tiffWriteProc,
|
||||
_tiffSeekProc, _tiffCloseProc, _tiffSizeProc,
|
||||
_tiffMapProc, _tiffUnmapProc);
|
||||
if (tif)
|
||||
tif->tif_fd = fd;
|
||||
return (tif);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -171,33 +224,33 @@ TIFFFdOpen(int fd, const char* name, const char* mode)
|
||||
TIFF*
|
||||
TIFFOpen(const char* name, const char* mode)
|
||||
{
|
||||
static const char module[] = "TIFFOpen";
|
||||
int m, fd;
|
||||
TIFF* tif;
|
||||
static const char module[] = "TIFFOpen";
|
||||
int m, fd;
|
||||
TIFF* tif;
|
||||
|
||||
m = _TIFFgetMode(mode, module);
|
||||
if (m == -1)
|
||||
return ((TIFF*)0);
|
||||
m = _TIFFgetMode(mode, module);
|
||||
if (m == -1)
|
||||
return ((TIFF*)0);
|
||||
|
||||
/* for cygwin and mingw */
|
||||
#ifdef O_BINARY
|
||||
m |= O_BINARY;
|
||||
m |= O_BINARY;
|
||||
#endif
|
||||
|
||||
fd = open(name, m, 0666);
|
||||
if (fd < 0) {
|
||||
if (errno > 0 && strerror(errno) != NULL ) {
|
||||
TIFFErrorExt(0, module, "%s: %s", name, strerror(errno) );
|
||||
} else {
|
||||
TIFFErrorExt(0, module, "%s: Cannot open", name);
|
||||
}
|
||||
return ((TIFF *)0);
|
||||
}
|
||||
fd = open(name, m, 0666);
|
||||
if (fd < 0) {
|
||||
if (errno > 0 && strerror(errno) != NULL ) {
|
||||
TIFFErrorExt(0, module, "%s: %s", name, strerror(errno) );
|
||||
} else {
|
||||
TIFFErrorExt(0, module, "%s: Cannot open", name);
|
||||
}
|
||||
return ((TIFF *)0);
|
||||
}
|
||||
|
||||
tif = TIFFFdOpen((int)fd, name, mode);
|
||||
if(!tif)
|
||||
close(fd);
|
||||
return tif;
|
||||
tif = TIFFFdOpen((int)fd, name, mode);
|
||||
if(!tif)
|
||||
close(fd);
|
||||
return tif;
|
||||
}
|
||||
|
||||
#ifdef __WIN32__
|
||||
@@ -208,106 +261,117 @@ TIFFOpen(const char* name, const char* mode)
|
||||
TIFF*
|
||||
TIFFOpenW(const wchar_t* name, const char* mode)
|
||||
{
|
||||
static const char module[] = "TIFFOpenW";
|
||||
int m, fd;
|
||||
int mbsize;
|
||||
char *mbname;
|
||||
TIFF* tif;
|
||||
static const char module[] = "TIFFOpenW";
|
||||
int m, fd;
|
||||
int mbsize;
|
||||
char *mbname;
|
||||
TIFF* tif;
|
||||
|
||||
m = _TIFFgetMode(mode, module);
|
||||
if (m == -1)
|
||||
return ((TIFF*)0);
|
||||
m = _TIFFgetMode(mode, module);
|
||||
if (m == -1)
|
||||
return ((TIFF*)0);
|
||||
|
||||
/* for cygwin and mingw */
|
||||
#ifdef O_BINARY
|
||||
m |= O_BINARY;
|
||||
m |= O_BINARY;
|
||||
#endif
|
||||
|
||||
fd = _wopen(name, m, 0666);
|
||||
if (fd < 0) {
|
||||
TIFFErrorExt(0, module, "%s: Cannot open", name);
|
||||
return ((TIFF *)0);
|
||||
}
|
||||
fd = _wopen(name, m, 0666);
|
||||
if (fd < 0) {
|
||||
TIFFErrorExt(0, module, "%ls: Cannot open", name);
|
||||
return ((TIFF *)0);
|
||||
}
|
||||
|
||||
mbname = NULL;
|
||||
mbsize = WideCharToMultiByte(CP_ACP, 0, name, -1, NULL, 0, NULL, NULL);
|
||||
if (mbsize > 0) {
|
||||
mbname = _TIFFmalloc(mbsize);
|
||||
if (!mbname) {
|
||||
TIFFErrorExt(0, module,
|
||||
"Can't allocate space for filename conversion buffer");
|
||||
return ((TIFF*)0);
|
||||
}
|
||||
mbname = NULL;
|
||||
mbsize = WideCharToMultiByte(CP_ACP, 0, name, -1, NULL, 0, NULL, NULL);
|
||||
if (mbsize > 0) {
|
||||
mbname = _TIFFmalloc(mbsize);
|
||||
if (!mbname) {
|
||||
TIFFErrorExt(0, module,
|
||||
"Can't allocate space for filename conversion buffer");
|
||||
return ((TIFF*)0);
|
||||
}
|
||||
|
||||
WideCharToMultiByte(CP_ACP, 0, name, -1, mbname, mbsize,
|
||||
NULL, NULL);
|
||||
}
|
||||
WideCharToMultiByte(CP_ACP, 0, name, -1, mbname, mbsize,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
tif = TIFFFdOpen((int)fd, (mbname != NULL) ? mbname : "<unknown>",
|
||||
mode);
|
||||
|
||||
_TIFFfree(mbname);
|
||||
|
||||
if(!tif)
|
||||
close(fd);
|
||||
return tif;
|
||||
tif = TIFFFdOpen((int)fd, (mbname != NULL) ? mbname : "<unknown>",
|
||||
mode);
|
||||
|
||||
_TIFFfree(mbname);
|
||||
|
||||
if(!tif)
|
||||
close(fd);
|
||||
return tif;
|
||||
}
|
||||
#endif
|
||||
|
||||
void*
|
||||
_TIFFmalloc(tmsize_t s)
|
||||
{
|
||||
return (malloc((size_t) s));
|
||||
if (s == 0)
|
||||
return ((void *) NULL);
|
||||
|
||||
return (malloc((size_t) s));
|
||||
}
|
||||
|
||||
void* _TIFFcalloc(tmsize_t nmemb, tmsize_t siz)
|
||||
{
|
||||
if( nmemb == 0 || siz == 0 )
|
||||
return ((void *) NULL);
|
||||
|
||||
return calloc((size_t) nmemb, (size_t)siz);
|
||||
}
|
||||
|
||||
void
|
||||
_TIFFfree(void* p)
|
||||
{
|
||||
free(p);
|
||||
free(p);
|
||||
}
|
||||
|
||||
void*
|
||||
_TIFFrealloc(void* p, tmsize_t s)
|
||||
{
|
||||
return (realloc(p, (size_t) s));
|
||||
return (realloc(p, (size_t) s));
|
||||
}
|
||||
|
||||
void
|
||||
_TIFFmemset(void* p, int v, tmsize_t c)
|
||||
{
|
||||
memset(p, v, (size_t) c);
|
||||
memset(p, v, (size_t) c);
|
||||
}
|
||||
|
||||
void
|
||||
_TIFFmemcpy(void* d, const void* s, tmsize_t c)
|
||||
{
|
||||
memcpy(d, s, (size_t) c);
|
||||
memcpy(d, s, (size_t) c);
|
||||
}
|
||||
|
||||
int
|
||||
_TIFFmemcmp(const void* p1, const void* p2, tmsize_t c)
|
||||
{
|
||||
return (memcmp(p1, p2, (size_t) c));
|
||||
return (memcmp(p1, p2, (size_t) c));
|
||||
}
|
||||
|
||||
static void
|
||||
unixWarningHandler(const char* module, const char* fmt, va_list ap)
|
||||
{
|
||||
if (module != NULL)
|
||||
fprintf(stderr, "%s: ", module);
|
||||
fprintf(stderr, "Warning, ");
|
||||
vfprintf(stderr, fmt, ap);
|
||||
fprintf(stderr, ".\n");
|
||||
if (module != NULL)
|
||||
fprintf(stderr, "%s: ", module);
|
||||
fprintf(stderr, "Warning, ");
|
||||
vfprintf(stderr, fmt, ap);
|
||||
fprintf(stderr, ".\n");
|
||||
}
|
||||
TIFFErrorHandler _TIFFwarningHandler = unixWarningHandler;
|
||||
|
||||
static void
|
||||
unixErrorHandler(const char* module, const char* fmt, va_list ap)
|
||||
{
|
||||
if (module != NULL)
|
||||
fprintf(stderr, "%s: ", module);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
fprintf(stderr, ".\n");
|
||||
if (module != NULL)
|
||||
fprintf(stderr, "%s: ", module);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
fprintf(stderr, ".\n");
|
||||
}
|
||||
TIFFErrorHandler _TIFFerrorHandler = unixErrorHandler;
|
||||
|
||||
|
||||
Vendored
+9
-9
@@ -3,23 +3,23 @@
|
||||
* Copyright (c) 1992-1997 Sam Leffler
|
||||
* Copyright (c) 1992-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
#include "tiffiop.h"
|
||||
@@ -29,7 +29,7 @@ static const char TIFFVersion[] = TIFFLIB_VERSION_STR;
|
||||
const char*
|
||||
TIFFGetVersion(void)
|
||||
{
|
||||
return (TIFFVersion);
|
||||
return (TIFFVersion);
|
||||
}
|
||||
/*
|
||||
* Local Variables:
|
||||
|
||||
Vendored
+37
-29
@@ -1,26 +1,26 @@
|
||||
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_warning.c,v 1.3 2010-03-10 18:56:49 bfriesen Exp $ */
|
||||
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_warning.c,v 1.4 2017-07-04 12:54:42 erouault Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
@@ -34,41 +34,49 @@ TIFFErrorHandlerExt _TIFFwarningHandlerExt = NULL;
|
||||
TIFFErrorHandler
|
||||
TIFFSetWarningHandler(TIFFErrorHandler handler)
|
||||
{
|
||||
TIFFErrorHandler prev = _TIFFwarningHandler;
|
||||
_TIFFwarningHandler = handler;
|
||||
return (prev);
|
||||
TIFFErrorHandler prev = _TIFFwarningHandler;
|
||||
_TIFFwarningHandler = handler;
|
||||
return (prev);
|
||||
}
|
||||
|
||||
TIFFErrorHandlerExt
|
||||
TIFFSetWarningHandlerExt(TIFFErrorHandlerExt handler)
|
||||
{
|
||||
TIFFErrorHandlerExt prev = _TIFFwarningHandlerExt;
|
||||
_TIFFwarningHandlerExt = handler;
|
||||
return (prev);
|
||||
TIFFErrorHandlerExt prev = _TIFFwarningHandlerExt;
|
||||
_TIFFwarningHandlerExt = handler;
|
||||
return (prev);
|
||||
}
|
||||
|
||||
void
|
||||
TIFFWarning(const char* module, const char* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
if (_TIFFwarningHandler)
|
||||
(*_TIFFwarningHandler)(module, fmt, ap);
|
||||
if (_TIFFwarningHandlerExt)
|
||||
(*_TIFFwarningHandlerExt)(0, module, fmt, ap);
|
||||
va_end(ap);
|
||||
va_list ap;
|
||||
if (_TIFFwarningHandler) {
|
||||
va_start(ap, fmt);
|
||||
(*_TIFFwarningHandler)(module, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
if (_TIFFwarningHandlerExt) {
|
||||
va_start(ap, fmt);
|
||||
(*_TIFFwarningHandlerExt)(0, module, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TIFFWarningExt(thandle_t fd, const char* module, const char* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
if (_TIFFwarningHandler)
|
||||
(*_TIFFwarningHandler)(module, fmt, ap);
|
||||
if (_TIFFwarningHandlerExt)
|
||||
(*_TIFFwarningHandlerExt)(fd, module, fmt, ap);
|
||||
va_end(ap);
|
||||
va_list ap;
|
||||
if (_TIFFwarningHandler) {
|
||||
va_start(ap, fmt);
|
||||
(*_TIFFwarningHandler)(module, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
if (_TIFFwarningHandlerExt) {
|
||||
va_start(ap, fmt);
|
||||
(*_TIFFwarningHandlerExt)(fd, module, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Vendored
+283
-247
@@ -1,26 +1,26 @@
|
||||
/* $Id: tif_win32.c,v 1.39 2011-12-22 17:07:57 bfriesen Exp $ */
|
||||
/* $Id: tif_win32.c,v 1.42 2017-01-11 19:02:49 erouault Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
@@ -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>
|
||||
@@ -35,111 +60,111 @@
|
||||
static tmsize_t
|
||||
_tiffReadProc(thandle_t fd, void* buf, tmsize_t size)
|
||||
{
|
||||
/* tmsize_t is 64bit on 64bit systems, but the WinAPI ReadFile takes
|
||||
* 32bit sizes, so we loop through the data in suitable 32bit sized
|
||||
* chunks */
|
||||
uint8* ma;
|
||||
uint64 mb;
|
||||
DWORD n;
|
||||
DWORD o;
|
||||
tmsize_t p;
|
||||
ma=(uint8*)buf;
|
||||
mb=size;
|
||||
p=0;
|
||||
while (mb>0)
|
||||
{
|
||||
n=0x80000000UL;
|
||||
if ((uint64)n>mb)
|
||||
n=(DWORD)mb;
|
||||
if (!ReadFile(fd,(LPVOID)ma,n,&o,NULL))
|
||||
return(0);
|
||||
ma+=o;
|
||||
mb-=o;
|
||||
p+=o;
|
||||
if (o!=n)
|
||||
break;
|
||||
}
|
||||
return(p);
|
||||
/* tmsize_t is 64bit on 64bit systems, but the WinAPI ReadFile takes
|
||||
* 32bit sizes, so we loop through the data in suitable 32bit sized
|
||||
* chunks */
|
||||
uint8* ma;
|
||||
uint64 mb;
|
||||
DWORD n;
|
||||
DWORD o;
|
||||
tmsize_t p;
|
||||
ma=(uint8*)buf;
|
||||
mb=size;
|
||||
p=0;
|
||||
while (mb>0)
|
||||
{
|
||||
n=0x80000000UL;
|
||||
if ((uint64)n>mb)
|
||||
n=(DWORD)mb;
|
||||
if (!ReadFile(fd,(LPVOID)ma,n,&o,NULL))
|
||||
return(0);
|
||||
ma+=o;
|
||||
mb-=o;
|
||||
p+=o;
|
||||
if (o!=n)
|
||||
break;
|
||||
}
|
||||
return(p);
|
||||
}
|
||||
|
||||
static tmsize_t
|
||||
_tiffWriteProc(thandle_t fd, void* buf, tmsize_t size)
|
||||
{
|
||||
/* tmsize_t is 64bit on 64bit systems, but the WinAPI WriteFile takes
|
||||
* 32bit sizes, so we loop through the data in suitable 32bit sized
|
||||
* chunks */
|
||||
uint8* ma;
|
||||
uint64 mb;
|
||||
DWORD n;
|
||||
DWORD o;
|
||||
tmsize_t p;
|
||||
ma=(uint8*)buf;
|
||||
mb=size;
|
||||
p=0;
|
||||
while (mb>0)
|
||||
{
|
||||
n=0x80000000UL;
|
||||
if ((uint64)n>mb)
|
||||
n=(DWORD)mb;
|
||||
if (!WriteFile(fd,(LPVOID)ma,n,&o,NULL))
|
||||
return(0);
|
||||
ma+=o;
|
||||
mb-=o;
|
||||
p+=o;
|
||||
if (o!=n)
|
||||
break;
|
||||
}
|
||||
return(p);
|
||||
/* tmsize_t is 64bit on 64bit systems, but the WinAPI WriteFile takes
|
||||
* 32bit sizes, so we loop through the data in suitable 32bit sized
|
||||
* chunks */
|
||||
uint8* ma;
|
||||
uint64 mb;
|
||||
DWORD n;
|
||||
DWORD o;
|
||||
tmsize_t p;
|
||||
ma=(uint8*)buf;
|
||||
mb=size;
|
||||
p=0;
|
||||
while (mb>0)
|
||||
{
|
||||
n=0x80000000UL;
|
||||
if ((uint64)n>mb)
|
||||
n=(DWORD)mb;
|
||||
if (!WriteFile(fd,(LPVOID)ma,n,&o,NULL))
|
||||
return(0);
|
||||
ma+=o;
|
||||
mb-=o;
|
||||
p+=o;
|
||||
if (o!=n)
|
||||
break;
|
||||
}
|
||||
return(p);
|
||||
}
|
||||
|
||||
static uint64
|
||||
_tiffSeekProc(thandle_t fd, uint64 off, int whence)
|
||||
{
|
||||
LARGE_INTEGER offli;
|
||||
DWORD dwMoveMethod;
|
||||
offli.QuadPart = off;
|
||||
switch(whence)
|
||||
{
|
||||
case SEEK_SET:
|
||||
dwMoveMethod = FILE_BEGIN;
|
||||
break;
|
||||
case SEEK_CUR:
|
||||
dwMoveMethod = FILE_CURRENT;
|
||||
break;
|
||||
case SEEK_END:
|
||||
dwMoveMethod = FILE_END;
|
||||
break;
|
||||
default:
|
||||
dwMoveMethod = FILE_BEGIN;
|
||||
break;
|
||||
}
|
||||
offli.LowPart=SetFilePointer(fd,offli.LowPart,&offli.HighPart,dwMoveMethod);
|
||||
if ((offli.LowPart==INVALID_SET_FILE_POINTER)&&(GetLastError()!=NO_ERROR))
|
||||
offli.QuadPart=0;
|
||||
return(offli.QuadPart);
|
||||
LARGE_INTEGER offli;
|
||||
DWORD dwMoveMethod;
|
||||
offli.QuadPart = off;
|
||||
switch(whence)
|
||||
{
|
||||
case SEEK_SET:
|
||||
dwMoveMethod = FILE_BEGIN;
|
||||
break;
|
||||
case SEEK_CUR:
|
||||
dwMoveMethod = FILE_CURRENT;
|
||||
break;
|
||||
case SEEK_END:
|
||||
dwMoveMethod = FILE_END;
|
||||
break;
|
||||
default:
|
||||
dwMoveMethod = FILE_BEGIN;
|
||||
break;
|
||||
}
|
||||
offli.LowPart=SetFilePointer(fd,offli.LowPart,&offli.HighPart,dwMoveMethod);
|
||||
if ((offli.LowPart==INVALID_SET_FILE_POINTER)&&(GetLastError()!=NO_ERROR))
|
||||
offli.QuadPart=0;
|
||||
return(offli.QuadPart);
|
||||
}
|
||||
|
||||
static int
|
||||
_tiffCloseProc(thandle_t fd)
|
||||
{
|
||||
return (CloseHandle(fd) ? 0 : -1);
|
||||
return (CloseHandle(fd) ? 0 : -1);
|
||||
}
|
||||
|
||||
static uint64
|
||||
_tiffSizeProc(thandle_t fd)
|
||||
{
|
||||
ULARGE_INTEGER m;
|
||||
m.LowPart=GetFileSize(fd,&m.HighPart);
|
||||
return(m.QuadPart);
|
||||
ULARGE_INTEGER m;
|
||||
m.LowPart=GetFileSize(fd,&m.HighPart);
|
||||
return(m.QuadPart);
|
||||
}
|
||||
|
||||
static int
|
||||
_tiffDummyMapProc(thandle_t fd, void** pbase, toff_t* psize)
|
||||
{
|
||||
(void) fd;
|
||||
(void) pbase;
|
||||
(void) psize;
|
||||
return (0);
|
||||
(void) fd;
|
||||
(void) pbase;
|
||||
(void) psize;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -156,42 +181,42 @@ _tiffDummyMapProc(thandle_t fd, void** pbase, toff_t* psize)
|
||||
static int
|
||||
_tiffMapProc(thandle_t fd, void** pbase, toff_t* psize)
|
||||
{
|
||||
uint64 size;
|
||||
tmsize_t sizem;
|
||||
HANDLE hMapFile;
|
||||
uint64 size;
|
||||
tmsize_t sizem;
|
||||
HANDLE hMapFile;
|
||||
|
||||
size = _tiffSizeProc(fd);
|
||||
sizem = (tmsize_t)size;
|
||||
if ((uint64)sizem!=size)
|
||||
return (0);
|
||||
size = _tiffSizeProc(fd);
|
||||
sizem = (tmsize_t)size;
|
||||
if ((uint64)sizem!=size)
|
||||
return (0);
|
||||
|
||||
/* By passing in 0 for the maximum file size, it specifies that we
|
||||
create a file mapping object for the full file size. */
|
||||
hMapFile = CreateFileMapping(fd, NULL, PAGE_READONLY, 0, 0, NULL);
|
||||
if (hMapFile == NULL)
|
||||
return (0);
|
||||
*pbase = MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 0);
|
||||
CloseHandle(hMapFile);
|
||||
if (*pbase == NULL)
|
||||
return (0);
|
||||
*psize = size;
|
||||
return(1);
|
||||
/* By passing in 0 for the maximum file size, it specifies that we
|
||||
create a file mapping object for the full file size. */
|
||||
hMapFile = CreateFileMapping(fd, NULL, PAGE_READONLY, 0, 0, NULL);
|
||||
if (hMapFile == NULL)
|
||||
return (0);
|
||||
*pbase = MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 0);
|
||||
CloseHandle(hMapFile);
|
||||
if (*pbase == NULL)
|
||||
return (0);
|
||||
*psize = size;
|
||||
return(1);
|
||||
}
|
||||
|
||||
static void
|
||||
_tiffDummyUnmapProc(thandle_t fd, void* base, toff_t size)
|
||||
{
|
||||
(void) fd;
|
||||
(void) base;
|
||||
(void) size;
|
||||
(void) fd;
|
||||
(void) base;
|
||||
(void) size;
|
||||
}
|
||||
|
||||
static void
|
||||
_tiffUnmapProc(thandle_t fd, void* base, toff_t size)
|
||||
{
|
||||
(void) fd;
|
||||
(void) size;
|
||||
UnmapViewOfFile(base);
|
||||
(void) fd;
|
||||
(void) size;
|
||||
UnmapViewOfFile(base);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -202,26 +227,26 @@ _tiffUnmapProc(thandle_t fd, void* base, toff_t size)
|
||||
TIFF*
|
||||
TIFFFdOpen(int ifd, const char* name, const char* mode)
|
||||
{
|
||||
TIFF* tif;
|
||||
int fSuppressMap;
|
||||
int m;
|
||||
fSuppressMap=0;
|
||||
for (m=0; mode[m]!=0; m++)
|
||||
{
|
||||
if (mode[m]=='u')
|
||||
{
|
||||
fSuppressMap=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
tif = TIFFClientOpen(name, mode, (thandle_t)ifd,
|
||||
_tiffReadProc, _tiffWriteProc,
|
||||
_tiffSeekProc, _tiffCloseProc, _tiffSizeProc,
|
||||
fSuppressMap ? _tiffDummyMapProc : _tiffMapProc,
|
||||
fSuppressMap ? _tiffDummyUnmapProc : _tiffUnmapProc);
|
||||
if (tif)
|
||||
tif->tif_fd = ifd;
|
||||
return (tif);
|
||||
TIFF* tif;
|
||||
int fSuppressMap;
|
||||
int m;
|
||||
fSuppressMap=0;
|
||||
for (m=0; mode[m]!=0; m++)
|
||||
{
|
||||
if (mode[m]=='u')
|
||||
{
|
||||
fSuppressMap=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
tif = TIFFClientOpen(name, mode, (thandle_t)ifd, /* FIXME: WIN64 cast to pointer warning */
|
||||
_tiffReadProc, _tiffWriteProc,
|
||||
_tiffSeekProc, _tiffCloseProc, _tiffSizeProc,
|
||||
fSuppressMap ? _tiffDummyMapProc : _tiffMapProc,
|
||||
fSuppressMap ? _tiffDummyUnmapProc : _tiffUnmapProc);
|
||||
if (tif)
|
||||
tif->tif_fd = ifd;
|
||||
return (tif);
|
||||
}
|
||||
|
||||
#ifndef _WIN32_WCE
|
||||
@@ -232,37 +257,37 @@ TIFFFdOpen(int ifd, const char* name, const char* mode)
|
||||
TIFF*
|
||||
TIFFOpen(const char* name, const char* mode)
|
||||
{
|
||||
static const char module[] = "TIFFOpen";
|
||||
thandle_t fd;
|
||||
int m;
|
||||
DWORD dwMode;
|
||||
TIFF* tif;
|
||||
static const char module[] = "TIFFOpen";
|
||||
thandle_t fd;
|
||||
int m;
|
||||
DWORD dwMode;
|
||||
TIFF* tif;
|
||||
|
||||
m = _TIFFgetMode(mode, module);
|
||||
m = _TIFFgetMode(mode, module);
|
||||
|
||||
switch(m) {
|
||||
case O_RDONLY: dwMode = OPEN_EXISTING; break;
|
||||
case O_RDWR: dwMode = OPEN_ALWAYS; break;
|
||||
case O_RDWR|O_CREAT: dwMode = OPEN_ALWAYS; break;
|
||||
case O_RDWR|O_TRUNC: dwMode = CREATE_ALWAYS; break;
|
||||
case O_RDWR|O_CREAT|O_TRUNC: dwMode = CREATE_ALWAYS; break;
|
||||
default: return ((TIFF*)0);
|
||||
}
|
||||
switch(m) {
|
||||
case O_RDONLY: dwMode = OPEN_EXISTING; break;
|
||||
case O_RDWR: dwMode = OPEN_ALWAYS; break;
|
||||
case O_RDWR|O_CREAT: dwMode = OPEN_ALWAYS; break;
|
||||
case O_RDWR|O_TRUNC: dwMode = CREATE_ALWAYS; break;
|
||||
case O_RDWR|O_CREAT|O_TRUNC: dwMode = CREATE_ALWAYS; break;
|
||||
default: return ((TIFF*)0);
|
||||
}
|
||||
|
||||
fd = (thandle_t)CreateFileA(name,
|
||||
(m == O_RDONLY)?GENERIC_READ:(GENERIC_READ | GENERIC_WRITE),
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, dwMode,
|
||||
(m == O_RDONLY)?FILE_ATTRIBUTE_READONLY:FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
if (fd == INVALID_HANDLE_VALUE) {
|
||||
TIFFErrorExt(0, module, "%s: Cannot open", name);
|
||||
return ((TIFF *)0);
|
||||
}
|
||||
|
||||
fd = (thandle_t)CreateFileA(name,
|
||||
(m == O_RDONLY)?GENERIC_READ:(GENERIC_READ | GENERIC_WRITE),
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, dwMode,
|
||||
(m == O_RDONLY)?FILE_ATTRIBUTE_READONLY:FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
if (fd == INVALID_HANDLE_VALUE) {
|
||||
TIFFErrorExt(0, module, "%s: Cannot open", name);
|
||||
return ((TIFF *)0);
|
||||
}
|
||||
|
||||
tif = TIFFFdOpen((int)fd, name, mode);
|
||||
if(!tif)
|
||||
CloseHandle(fd);
|
||||
return tif;
|
||||
tif = TIFFFdOpen((int)fd, name, mode); /* FIXME: WIN64 cast from pointer to int warning */
|
||||
if(!tif)
|
||||
CloseHandle(fd);
|
||||
return tif;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -271,57 +296,57 @@ TIFFOpen(const char* name, const char* mode)
|
||||
TIFF*
|
||||
TIFFOpenW(const wchar_t* name, const char* mode)
|
||||
{
|
||||
static const char module[] = "TIFFOpenW";
|
||||
thandle_t fd;
|
||||
int m;
|
||||
DWORD dwMode;
|
||||
int mbsize;
|
||||
char *mbname;
|
||||
TIFF *tif;
|
||||
static const char module[] = "TIFFOpenW";
|
||||
thandle_t fd;
|
||||
int m;
|
||||
DWORD dwMode;
|
||||
int mbsize;
|
||||
char *mbname;
|
||||
TIFF *tif;
|
||||
|
||||
m = _TIFFgetMode(mode, module);
|
||||
m = _TIFFgetMode(mode, module);
|
||||
|
||||
switch(m) {
|
||||
case O_RDONLY: dwMode = OPEN_EXISTING; break;
|
||||
case O_RDWR: dwMode = OPEN_ALWAYS; break;
|
||||
case O_RDWR|O_CREAT: dwMode = OPEN_ALWAYS; break;
|
||||
case O_RDWR|O_TRUNC: dwMode = CREATE_ALWAYS; break;
|
||||
case O_RDWR|O_CREAT|O_TRUNC: dwMode = CREATE_ALWAYS; break;
|
||||
default: return ((TIFF*)0);
|
||||
}
|
||||
switch(m) {
|
||||
case O_RDONLY: dwMode = OPEN_EXISTING; break;
|
||||
case O_RDWR: dwMode = OPEN_ALWAYS; break;
|
||||
case O_RDWR|O_CREAT: dwMode = OPEN_ALWAYS; break;
|
||||
case O_RDWR|O_TRUNC: dwMode = CREATE_ALWAYS; break;
|
||||
case O_RDWR|O_CREAT|O_TRUNC: dwMode = CREATE_ALWAYS; break;
|
||||
default: return ((TIFF*)0);
|
||||
}
|
||||
|
||||
fd = (thandle_t)CreateFileW(name,
|
||||
(m == O_RDONLY)?GENERIC_READ:(GENERIC_READ|GENERIC_WRITE),
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, dwMode,
|
||||
(m == O_RDONLY)?FILE_ATTRIBUTE_READONLY:FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
if (fd == INVALID_HANDLE_VALUE) {
|
||||
TIFFErrorExt(0, module, "%S: Cannot open", name);
|
||||
return ((TIFF *)0);
|
||||
}
|
||||
fd = (thandle_t)CreateFileW(name,
|
||||
(m == O_RDONLY)?GENERIC_READ:(GENERIC_READ|GENERIC_WRITE),
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, dwMode,
|
||||
(m == O_RDONLY)?FILE_ATTRIBUTE_READONLY:FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
if (fd == INVALID_HANDLE_VALUE) {
|
||||
TIFFErrorExt(0, module, "%S: Cannot open", name);
|
||||
return ((TIFF *)0);
|
||||
}
|
||||
|
||||
mbname = NULL;
|
||||
mbsize = WideCharToMultiByte(CP_ACP, 0, name, -1, NULL, 0, NULL, NULL);
|
||||
if (mbsize > 0) {
|
||||
mbname = (char *)_TIFFmalloc(mbsize);
|
||||
if (!mbname) {
|
||||
TIFFErrorExt(0, module,
|
||||
"Can't allocate space for filename conversion buffer");
|
||||
return ((TIFF*)0);
|
||||
}
|
||||
mbname = NULL;
|
||||
mbsize = WideCharToMultiByte(CP_ACP, 0, name, -1, NULL, 0, NULL, NULL);
|
||||
if (mbsize > 0) {
|
||||
mbname = (char *)_TIFFmalloc(mbsize);
|
||||
if (!mbname) {
|
||||
TIFFErrorExt(0, module,
|
||||
"Can't allocate space for filename conversion buffer");
|
||||
return ((TIFF*)0);
|
||||
}
|
||||
|
||||
WideCharToMultiByte(CP_ACP, 0, name, -1, mbname, mbsize,
|
||||
NULL, NULL);
|
||||
}
|
||||
WideCharToMultiByte(CP_ACP, 0, name, -1, mbname, mbsize,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
tif = TIFFFdOpen((int)fd,
|
||||
(mbname != NULL) ? mbname : "<unknown>", mode);
|
||||
if(!tif)
|
||||
CloseHandle(fd);
|
||||
tif = TIFFFdOpen((int)fd, /* FIXME: WIN64 cast from pointer to int warning */
|
||||
(mbname != NULL) ? mbname : "<unknown>", mode);
|
||||
if(!tif)
|
||||
CloseHandle(fd);
|
||||
|
||||
_TIFFfree(mbname);
|
||||
_TIFFfree(mbname);
|
||||
|
||||
return tif;
|
||||
return tif;
|
||||
}
|
||||
|
||||
#endif /* ndef _WIN32_WCE */
|
||||
@@ -329,37 +354,48 @@ TIFFOpenW(const wchar_t* name, const char* mode)
|
||||
void*
|
||||
_TIFFmalloc(tmsize_t s)
|
||||
{
|
||||
return (malloc((size_t) s));
|
||||
if (s == 0)
|
||||
return ((void *) NULL);
|
||||
|
||||
return (malloc((size_t) s));
|
||||
}
|
||||
|
||||
void* _TIFFcalloc(tmsize_t nmemb, tmsize_t siz)
|
||||
{
|
||||
if( nmemb == 0 || siz == 0 )
|
||||
return ((void *) NULL);
|
||||
|
||||
return calloc((size_t) nmemb, (size_t)siz);
|
||||
}
|
||||
|
||||
void
|
||||
_TIFFfree(void* p)
|
||||
{
|
||||
free(p);
|
||||
free(p);
|
||||
}
|
||||
|
||||
void*
|
||||
_TIFFrealloc(void* p, tmsize_t s)
|
||||
{
|
||||
return (realloc(p, (size_t) s));
|
||||
return (realloc(p, (size_t) s));
|
||||
}
|
||||
|
||||
void
|
||||
_TIFFmemset(void* p, int v, tmsize_t c)
|
||||
{
|
||||
memset(p, v, (size_t) c);
|
||||
memset(p, v, (size_t) c);
|
||||
}
|
||||
|
||||
void
|
||||
_TIFFmemcpy(void* d, const void* s, tmsize_t c)
|
||||
{
|
||||
memcpy(d, s, (size_t) c);
|
||||
memcpy(d, s, (size_t) c);
|
||||
}
|
||||
|
||||
int
|
||||
_TIFFmemcmp(const void* p1, const void* p2, tmsize_t c)
|
||||
{
|
||||
return (memcmp(p1, p2, (size_t) c));
|
||||
return (memcmp(p1, p2, (size_t) c));
|
||||
}
|
||||
|
||||
#ifndef _WIN32_WCE
|
||||
@@ -372,30 +408,30 @@ static void
|
||||
Win32WarningHandler(const char* module, const char* fmt, va_list ap)
|
||||
{
|
||||
#ifndef TIF_PLATFORM_CONSOLE
|
||||
LPTSTR szTitle;
|
||||
LPTSTR szTmp;
|
||||
LPCTSTR szTitleText = "%s Warning";
|
||||
LPCTSTR szDefaultModule = "LIBTIFF";
|
||||
LPCTSTR szTmpModule = (module == NULL) ? szDefaultModule : module;
|
||||
LPTSTR szTitle;
|
||||
LPTSTR szTmp;
|
||||
LPCTSTR szTitleText = "%s Warning";
|
||||
LPCTSTR szDefaultModule = "LIBTIFF";
|
||||
LPCTSTR szTmpModule = (module == NULL) ? szDefaultModule : module;
|
||||
SIZE_T nBufSize = (strlen(szTmpModule) +
|
||||
strlen(szTitleText) + strlen(fmt) + 256)*sizeof(char);
|
||||
|
||||
if ((szTitle = (LPTSTR)LocalAlloc(LMEM_FIXED, nBufSize)) == NULL)
|
||||
return;
|
||||
sprintf(szTitle, szTitleText, szTmpModule);
|
||||
szTmp = szTitle + (strlen(szTitle)+2)*sizeof(char);
|
||||
vsnprintf(szTmp, nBufSize-(strlen(szTitle)+2)*sizeof(char), fmt, ap);
|
||||
MessageBoxA(GetFocus(), szTmp, szTitle, MB_OK | MB_ICONINFORMATION);
|
||||
LocalFree(szTitle);
|
||||
if ((szTitle = (LPTSTR)LocalAlloc(LMEM_FIXED, nBufSize)) == NULL)
|
||||
return;
|
||||
sprintf(szTitle, szTitleText, szTmpModule);
|
||||
szTmp = szTitle + (strlen(szTitle)+2)*sizeof(char);
|
||||
vsnprintf(szTmp, nBufSize-(strlen(szTitle)+2)*sizeof(char), fmt, ap);
|
||||
MessageBoxA(GetFocus(), szTmp, szTitle, MB_OK | MB_ICONINFORMATION);
|
||||
LocalFree(szTitle);
|
||||
|
||||
return;
|
||||
return;
|
||||
#else
|
||||
if (module != NULL)
|
||||
fprintf(stderr, "%s: ", module);
|
||||
fprintf(stderr, "Warning, ");
|
||||
vfprintf(stderr, fmt, ap);
|
||||
fprintf(stderr, ".\n");
|
||||
#endif
|
||||
if (module != NULL)
|
||||
fprintf(stderr, "%s: ", module);
|
||||
fprintf(stderr, "Warning, ");
|
||||
vfprintf(stderr, fmt, ap);
|
||||
fprintf(stderr, ".\n");
|
||||
#endif
|
||||
}
|
||||
TIFFErrorHandler _TIFFwarningHandler = Win32WarningHandler;
|
||||
|
||||
@@ -403,28 +439,28 @@ static void
|
||||
Win32ErrorHandler(const char* module, const char* fmt, va_list ap)
|
||||
{
|
||||
#ifndef TIF_PLATFORM_CONSOLE
|
||||
LPTSTR szTitle;
|
||||
LPTSTR szTmp;
|
||||
LPCTSTR szTitleText = "%s Error";
|
||||
LPCTSTR szDefaultModule = "LIBTIFF";
|
||||
LPCTSTR szTmpModule = (module == NULL) ? szDefaultModule : module;
|
||||
LPTSTR szTitle;
|
||||
LPTSTR szTmp;
|
||||
LPCTSTR szTitleText = "%s Error";
|
||||
LPCTSTR szDefaultModule = "LIBTIFF";
|
||||
LPCTSTR szTmpModule = (module == NULL) ? szDefaultModule : module;
|
||||
SIZE_T nBufSize = (strlen(szTmpModule) +
|
||||
strlen(szTitleText) + strlen(fmt) + 256)*sizeof(char);
|
||||
|
||||
if ((szTitle = (LPTSTR)LocalAlloc(LMEM_FIXED, nBufSize)) == NULL)
|
||||
return;
|
||||
sprintf(szTitle, szTitleText, szTmpModule);
|
||||
szTmp = szTitle + (strlen(szTitle)+2)*sizeof(char);
|
||||
vsnprintf(szTmp, nBufSize-(strlen(szTitle)+2)*sizeof(char), fmt, ap);
|
||||
MessageBoxA(GetFocus(), szTmp, szTitle, MB_OK | MB_ICONEXCLAMATION);
|
||||
LocalFree(szTitle);
|
||||
return;
|
||||
if ((szTitle = (LPTSTR)LocalAlloc(LMEM_FIXED, nBufSize)) == NULL)
|
||||
return;
|
||||
sprintf(szTitle, szTitleText, szTmpModule);
|
||||
szTmp = szTitle + (strlen(szTitle)+2)*sizeof(char);
|
||||
vsnprintf(szTmp, nBufSize-(strlen(szTitle)+2)*sizeof(char), fmt, ap);
|
||||
MessageBoxA(GetFocus(), szTmp, szTitle, MB_OK | MB_ICONEXCLAMATION);
|
||||
LocalFree(szTitle);
|
||||
return;
|
||||
#else
|
||||
if (module != NULL)
|
||||
fprintf(stderr, "%s: ", module);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
fprintf(stderr, ".\n");
|
||||
#endif
|
||||
if (module != NULL)
|
||||
fprintf(stderr, "%s: ", module);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
fprintf(stderr, ".\n");
|
||||
#endif
|
||||
}
|
||||
TIFFErrorHandler _TIFFerrorHandler = Win32ErrorHandler;
|
||||
|
||||
|
||||
Vendored
+557
-472
File diff suppressed because it is too large
Load Diff
Vendored
+284
-277
@@ -1,26 +1,26 @@
|
||||
/* $Id: tif_zip.c,v 1.31 2011-01-06 16:00:23 fwarmerdam Exp $ */
|
||||
/* $Id: tif_zip.c,v 1.37 2017-05-10 15:21:16 erouault Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995-1997 Sam Leffler
|
||||
* Copyright (c) 1995-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
@@ -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,20 +61,22 @@
|
||||
#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.
|
||||
*/
|
||||
typedef struct {
|
||||
TIFFPredictorState predict;
|
||||
TIFFPredictorState predict;
|
||||
z_stream stream;
|
||||
int zipquality; /* compression level */
|
||||
int state; /* state flags */
|
||||
int zipquality; /* compression level */
|
||||
int state; /* state flags */
|
||||
#define ZSTATE_INIT_DECODE 0x01
|
||||
#define ZSTATE_INIT_ENCODE 0x02
|
||||
|
||||
TIFFVGetMethod vgetparent; /* super-class method */
|
||||
TIFFVSetMethod vsetparent; /* super-class method */
|
||||
TIFFVGetMethod vgetparent; /* super-class method */
|
||||
TIFFVSetMethod vsetparent; /* super-class method */
|
||||
} ZIPState;
|
||||
|
||||
#define ZState(tif) ((ZIPState*) (tif)->tif_data)
|
||||
@@ -87,31 +89,35 @@ static int ZIPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s);
|
||||
static int
|
||||
ZIPFixupTags(TIFF* tif)
|
||||
{
|
||||
(void) tif;
|
||||
return (1);
|
||||
(void) tif;
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
ZIPSetupDecode(TIFF* tif)
|
||||
{
|
||||
static const char module[] = "ZIPSetupDecode";
|
||||
ZIPState* sp = DecoderState(tif);
|
||||
|
||||
assert(sp != NULL);
|
||||
static const char module[] = "ZIPSetupDecode";
|
||||
ZIPState* sp = DecoderState(tif);
|
||||
|
||||
assert(sp != NULL);
|
||||
|
||||
/* if we were last encoding, terminate this mode */
|
||||
if (sp->state & ZSTATE_INIT_ENCODE) {
|
||||
deflateEnd(&sp->stream);
|
||||
sp->state = 0;
|
||||
}
|
||||
if (sp->state & ZSTATE_INIT_ENCODE) {
|
||||
deflateEnd(&sp->stream);
|
||||
sp->state = 0;
|
||||
}
|
||||
|
||||
if (inflateInit(&sp->stream) != Z_OK) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "%s", sp->stream.msg);
|
||||
return (0);
|
||||
} else {
|
||||
sp->state |= ZSTATE_INIT_DECODE;
|
||||
return (1);
|
||||
}
|
||||
/* This function can possibly be called several times by */
|
||||
/* PredictorSetupDecode() if this function succeeds but */
|
||||
/* PredictorSetup() fails */
|
||||
if ((sp->state & ZSTATE_INIT_DECODE) == 0 &&
|
||||
inflateInit(&sp->stream) != Z_OK) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "%s", SAFE_MSG(sp));
|
||||
return (0);
|
||||
} else {
|
||||
sp->state |= ZSTATE_INIT_DECODE;
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -120,103 +126,103 @@ ZIPSetupDecode(TIFF* tif)
|
||||
static int
|
||||
ZIPPreDecode(TIFF* tif, uint16 s)
|
||||
{
|
||||
static const char module[] = "ZIPPreDecode";
|
||||
ZIPState* sp = DecoderState(tif);
|
||||
static const char module[] = "ZIPPreDecode";
|
||||
ZIPState* sp = DecoderState(tif);
|
||||
|
||||
(void) s;
|
||||
assert(sp != NULL);
|
||||
(void) s;
|
||||
assert(sp != NULL);
|
||||
|
||||
if( (sp->state & ZSTATE_INIT_DECODE) == 0 )
|
||||
if( (sp->state & ZSTATE_INIT_DECODE) == 0 )
|
||||
tif->tif_setupdecode( tif );
|
||||
|
||||
sp->stream.next_in = tif->tif_rawdata;
|
||||
assert(sizeof(sp->stream.avail_in)==4); /* if this assert gets raised,
|
||||
we need to simplify this code to reflect a ZLib that is likely updated
|
||||
to deal with 8byte memory sizes, though this code will respond
|
||||
apropriately even before we simplify it */
|
||||
sp->stream.avail_in = (uInt) tif->tif_rawcc;
|
||||
if ((tmsize_t)sp->stream.avail_in != tif->tif_rawcc)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size");
|
||||
return (0);
|
||||
}
|
||||
return (inflateReset(&sp->stream) == Z_OK);
|
||||
sp->stream.next_in = tif->tif_rawdata;
|
||||
assert(sizeof(sp->stream.avail_in)==4); /* if this assert gets raised,
|
||||
we need to simplify this code to reflect a ZLib that is likely updated
|
||||
to deal with 8byte memory sizes, though this code will respond
|
||||
appropriately even before we simplify it */
|
||||
sp->stream.avail_in = (uInt) tif->tif_rawcc;
|
||||
if ((tmsize_t)sp->stream.avail_in != tif->tif_rawcc)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size");
|
||||
return (0);
|
||||
}
|
||||
return (inflateReset(&sp->stream) == Z_OK);
|
||||
}
|
||||
|
||||
static int
|
||||
ZIPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s)
|
||||
{
|
||||
static const char module[] = "ZIPDecode";
|
||||
ZIPState* sp = DecoderState(tif);
|
||||
static const char module[] = "ZIPDecode";
|
||||
ZIPState* sp = DecoderState(tif);
|
||||
|
||||
(void) s;
|
||||
assert(sp != NULL);
|
||||
assert(sp->state == ZSTATE_INIT_DECODE);
|
||||
(void) s;
|
||||
assert(sp != NULL);
|
||||
assert(sp->state == ZSTATE_INIT_DECODE);
|
||||
|
||||
sp->stream.next_in = tif->tif_rawcp;
|
||||
sp->stream.avail_in = (uInt) tif->tif_rawcc;
|
||||
|
||||
sp->stream.next_out = op;
|
||||
assert(sizeof(sp->stream.avail_out)==4); /* if this assert gets raised,
|
||||
we need to simplify this code to reflect a ZLib that is likely updated
|
||||
to deal with 8byte memory sizes, though this code will respond
|
||||
apropriately even before we simplify it */
|
||||
sp->stream.avail_out = (uInt) occ;
|
||||
if ((tmsize_t)sp->stream.avail_out != occ)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size");
|
||||
return (0);
|
||||
}
|
||||
do {
|
||||
int state = inflate(&sp->stream, Z_PARTIAL_FLUSH);
|
||||
if (state == Z_STREAM_END)
|
||||
break;
|
||||
if (state == Z_DATA_ERROR) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Decoding error at scanline %lu, %s",
|
||||
(unsigned long) tif->tif_row, sp->stream.msg);
|
||||
if (inflateSync(&sp->stream) != Z_OK)
|
||||
return (0);
|
||||
continue;
|
||||
}
|
||||
if (state != Z_OK) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "ZLib error: %s",
|
||||
sp->stream.msg);
|
||||
return (0);
|
||||
}
|
||||
} while (sp->stream.avail_out > 0);
|
||||
if (sp->stream.avail_out != 0) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Not enough data at scanline %lu (short " TIFF_UINT64_FORMAT " bytes)",
|
||||
(unsigned long) tif->tif_row, (TIFF_UINT64_T) sp->stream.avail_out);
|
||||
return (0);
|
||||
}
|
||||
sp->stream.avail_in = (uInt) tif->tif_rawcc;
|
||||
|
||||
sp->stream.next_out = op;
|
||||
assert(sizeof(sp->stream.avail_out)==4); /* if this assert gets raised,
|
||||
we need to simplify this code to reflect a ZLib that is likely updated
|
||||
to deal with 8byte memory sizes, though this code will respond
|
||||
appropriately even before we simplify it */
|
||||
sp->stream.avail_out = (uInt) occ;
|
||||
if ((tmsize_t)sp->stream.avail_out != occ)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size");
|
||||
return (0);
|
||||
}
|
||||
do {
|
||||
int state = inflate(&sp->stream, Z_PARTIAL_FLUSH);
|
||||
if (state == Z_STREAM_END)
|
||||
break;
|
||||
if (state == Z_DATA_ERROR) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Decoding error at scanline %lu, %s",
|
||||
(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", SAFE_MSG(sp));
|
||||
return (0);
|
||||
}
|
||||
} while (sp->stream.avail_out > 0);
|
||||
if (sp->stream.avail_out != 0) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Not enough data at scanline %lu (short " TIFF_UINT64_FORMAT " bytes)",
|
||||
(unsigned long) tif->tif_row, (TIFF_UINT64_T) sp->stream.avail_out);
|
||||
return (0);
|
||||
}
|
||||
|
||||
tif->tif_rawcp = sp->stream.next_in;
|
||||
tif->tif_rawcc = sp->stream.avail_in;
|
||||
|
||||
return (1);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static int
|
||||
ZIPSetupEncode(TIFF* tif)
|
||||
{
|
||||
static const char module[] = "ZIPSetupEncode";
|
||||
ZIPState* sp = EncoderState(tif);
|
||||
static const char module[] = "ZIPSetupEncode";
|
||||
ZIPState* sp = EncoderState(tif);
|
||||
|
||||
assert(sp != NULL);
|
||||
if (sp->state & ZSTATE_INIT_DECODE) {
|
||||
inflateEnd(&sp->stream);
|
||||
sp->state = 0;
|
||||
}
|
||||
assert(sp != NULL);
|
||||
if (sp->state & ZSTATE_INIT_DECODE) {
|
||||
inflateEnd(&sp->stream);
|
||||
sp->state = 0;
|
||||
}
|
||||
|
||||
if (deflateInit(&sp->stream, sp->zipquality) != Z_OK) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "%s", sp->stream.msg);
|
||||
return (0);
|
||||
} else {
|
||||
sp->state |= ZSTATE_INIT_ENCODE;
|
||||
return (1);
|
||||
}
|
||||
if (deflateInit(&sp->stream, sp->zipquality) != Z_OK) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "%s", SAFE_MSG(sp));
|
||||
return (0);
|
||||
} else {
|
||||
sp->state |= ZSTATE_INIT_ENCODE;
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -225,26 +231,26 @@ ZIPSetupEncode(TIFF* tif)
|
||||
static int
|
||||
ZIPPreEncode(TIFF* tif, uint16 s)
|
||||
{
|
||||
static const char module[] = "ZIPPreEncode";
|
||||
ZIPState *sp = EncoderState(tif);
|
||||
static const char module[] = "ZIPPreEncode";
|
||||
ZIPState *sp = EncoderState(tif);
|
||||
|
||||
(void) s;
|
||||
assert(sp != NULL);
|
||||
if( sp->state != ZSTATE_INIT_ENCODE )
|
||||
(void) s;
|
||||
assert(sp != NULL);
|
||||
if( sp->state != ZSTATE_INIT_ENCODE )
|
||||
tif->tif_setupencode( tif );
|
||||
|
||||
sp->stream.next_out = tif->tif_rawdata;
|
||||
assert(sizeof(sp->stream.avail_out)==4); /* if this assert gets raised,
|
||||
we need to simplify this code to reflect a ZLib that is likely updated
|
||||
to deal with 8byte memory sizes, though this code will respond
|
||||
apropriately even before we simplify it */
|
||||
sp->stream.avail_out = tif->tif_rawdatasize;
|
||||
if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size");
|
||||
return (0);
|
||||
}
|
||||
return (deflateReset(&sp->stream) == Z_OK);
|
||||
sp->stream.next_out = tif->tif_rawdata;
|
||||
assert(sizeof(sp->stream.avail_out)==4); /* if this assert gets raised,
|
||||
we need to simplify this code to reflect a ZLib that is likely updated
|
||||
to deal with 8byte memory sizes, though this code will respond
|
||||
appropriately even before we simplify it */
|
||||
sp->stream.avail_out = (uInt)tif->tif_rawdatasize;
|
||||
if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size");
|
||||
return (0);
|
||||
}
|
||||
return (deflateReset(&sp->stream) == Z_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -253,38 +259,39 @@ ZIPPreEncode(TIFF* tif, uint16 s)
|
||||
static int
|
||||
ZIPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
|
||||
{
|
||||
static const char module[] = "ZIPEncode";
|
||||
ZIPState *sp = EncoderState(tif);
|
||||
static const char module[] = "ZIPEncode";
|
||||
ZIPState *sp = EncoderState(tif);
|
||||
|
||||
assert(sp != NULL);
|
||||
assert(sp->state == ZSTATE_INIT_ENCODE);
|
||||
assert(sp != NULL);
|
||||
assert(sp->state == ZSTATE_INIT_ENCODE);
|
||||
|
||||
(void) s;
|
||||
sp->stream.next_in = bp;
|
||||
assert(sizeof(sp->stream.avail_in)==4); /* if this assert gets raised,
|
||||
we need to simplify this code to reflect a ZLib that is likely updated
|
||||
to deal with 8byte memory sizes, though this code will respond
|
||||
apropriately even before we simplify it */
|
||||
sp->stream.avail_in = (uInt) cc;
|
||||
if ((tmsize_t)sp->stream.avail_in != cc)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size");
|
||||
return (0);
|
||||
}
|
||||
do {
|
||||
if (deflate(&sp->stream, Z_NO_FLUSH) != Z_OK) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "Encoder error: %s",
|
||||
sp->stream.msg);
|
||||
return (0);
|
||||
}
|
||||
if (sp->stream.avail_out == 0) {
|
||||
tif->tif_rawcc = tif->tif_rawdatasize;
|
||||
TIFFFlushData1(tif);
|
||||
sp->stream.next_out = tif->tif_rawdata;
|
||||
sp->stream.avail_out = (uInt) tif->tif_rawdatasize; /* this is a safe typecast, as check is made already in ZIPPreEncode */
|
||||
}
|
||||
} while (sp->stream.avail_in > 0);
|
||||
return (1);
|
||||
(void) s;
|
||||
sp->stream.next_in = bp;
|
||||
assert(sizeof(sp->stream.avail_in)==4); /* if this assert gets raised,
|
||||
we need to simplify this code to reflect a ZLib that is likely updated
|
||||
to deal with 8byte memory sizes, though this code will respond
|
||||
appropriately even before we simplify it */
|
||||
sp->stream.avail_in = (uInt) cc;
|
||||
if ((tmsize_t)sp->stream.avail_in != cc)
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size");
|
||||
return (0);
|
||||
}
|
||||
do {
|
||||
if (deflate(&sp->stream, Z_NO_FLUSH) != Z_OK) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Encoder error: %s",
|
||||
SAFE_MSG(sp));
|
||||
return (0);
|
||||
}
|
||||
if (sp->stream.avail_out == 0) {
|
||||
tif->tif_rawcc = tif->tif_rawdatasize;
|
||||
TIFFFlushData1(tif);
|
||||
sp->stream.next_out = tif->tif_rawdata;
|
||||
sp->stream.avail_out = (uInt) tif->tif_rawdatasize; /* this is a safe typecast, as check is made already in ZIPPreEncode */
|
||||
}
|
||||
} while (sp->stream.avail_in > 0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -294,95 +301,95 @@ ZIPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
|
||||
static int
|
||||
ZIPPostEncode(TIFF* tif)
|
||||
{
|
||||
static const char module[] = "ZIPPostEncode";
|
||||
ZIPState *sp = EncoderState(tif);
|
||||
int state;
|
||||
static const char module[] = "ZIPPostEncode";
|
||||
ZIPState *sp = EncoderState(tif);
|
||||
int state;
|
||||
|
||||
sp->stream.avail_in = 0;
|
||||
do {
|
||||
state = deflate(&sp->stream, Z_FINISH);
|
||||
switch (state) {
|
||||
case Z_STREAM_END:
|
||||
case Z_OK:
|
||||
if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize)
|
||||
{
|
||||
tif->tif_rawcc = tif->tif_rawdatasize - sp->stream.avail_out;
|
||||
TIFFFlushData1(tif);
|
||||
sp->stream.next_out = tif->tif_rawdata;
|
||||
sp->stream.avail_out = (uInt) tif->tif_rawdatasize; /* this is a safe typecast, as check is made already in ZIPPreEncode */
|
||||
}
|
||||
break;
|
||||
default:
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "ZLib error: %s",
|
||||
sp->stream.msg);
|
||||
return (0);
|
||||
}
|
||||
} while (state != Z_STREAM_END);
|
||||
return (1);
|
||||
sp->stream.avail_in = 0;
|
||||
do {
|
||||
state = deflate(&sp->stream, Z_FINISH);
|
||||
switch (state) {
|
||||
case Z_STREAM_END:
|
||||
case Z_OK:
|
||||
if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize)
|
||||
{
|
||||
tif->tif_rawcc = tif->tif_rawdatasize - sp->stream.avail_out;
|
||||
TIFFFlushData1(tif);
|
||||
sp->stream.next_out = tif->tif_rawdata;
|
||||
sp->stream.avail_out = (uInt) tif->tif_rawdatasize; /* this is a safe typecast, as check is made already in ZIPPreEncode */
|
||||
}
|
||||
break;
|
||||
default:
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"ZLib error: %s", SAFE_MSG(sp));
|
||||
return (0);
|
||||
}
|
||||
} while (state != Z_STREAM_END);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static void
|
||||
ZIPCleanup(TIFF* tif)
|
||||
{
|
||||
ZIPState* sp = ZState(tif);
|
||||
ZIPState* sp = ZState(tif);
|
||||
|
||||
assert(sp != 0);
|
||||
assert(sp != 0);
|
||||
|
||||
(void)TIFFPredictorCleanup(tif);
|
||||
(void)TIFFPredictorCleanup(tif);
|
||||
|
||||
tif->tif_tagmethods.vgetfield = sp->vgetparent;
|
||||
tif->tif_tagmethods.vsetfield = sp->vsetparent;
|
||||
tif->tif_tagmethods.vgetfield = sp->vgetparent;
|
||||
tif->tif_tagmethods.vsetfield = sp->vsetparent;
|
||||
|
||||
if (sp->state & ZSTATE_INIT_ENCODE) {
|
||||
deflateEnd(&sp->stream);
|
||||
sp->state = 0;
|
||||
} else if( sp->state & ZSTATE_INIT_DECODE) {
|
||||
inflateEnd(&sp->stream);
|
||||
sp->state = 0;
|
||||
}
|
||||
_TIFFfree(sp);
|
||||
tif->tif_data = NULL;
|
||||
if (sp->state & ZSTATE_INIT_ENCODE) {
|
||||
deflateEnd(&sp->stream);
|
||||
sp->state = 0;
|
||||
} else if( sp->state & ZSTATE_INIT_DECODE) {
|
||||
inflateEnd(&sp->stream);
|
||||
sp->state = 0;
|
||||
}
|
||||
_TIFFfree(sp);
|
||||
tif->tif_data = NULL;
|
||||
|
||||
_TIFFSetDefaultCompressionState(tif);
|
||||
_TIFFSetDefaultCompressionState(tif);
|
||||
}
|
||||
|
||||
static int
|
||||
ZIPVSetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
{
|
||||
static const char module[] = "ZIPVSetField";
|
||||
ZIPState* sp = ZState(tif);
|
||||
static const char module[] = "ZIPVSetField";
|
||||
ZIPState* sp = ZState(tif);
|
||||
|
||||
switch (tag) {
|
||||
case TIFFTAG_ZIPQUALITY:
|
||||
sp->zipquality = (int) va_arg(ap, int);
|
||||
if ( sp->state&ZSTATE_INIT_ENCODE ) {
|
||||
if (deflateParams(&sp->stream,
|
||||
sp->zipquality, Z_DEFAULT_STRATEGY) != Z_OK) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "ZLib error: %s",
|
||||
sp->stream.msg);
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
return (1);
|
||||
default:
|
||||
return (*sp->vsetparent)(tif, tag, ap);
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
switch (tag) {
|
||||
case TIFFTAG_ZIPQUALITY:
|
||||
sp->zipquality = (int) va_arg(ap, int);
|
||||
if ( sp->state&ZSTATE_INIT_ENCODE ) {
|
||||
if (deflateParams(&sp->stream,
|
||||
sp->zipquality, Z_DEFAULT_STRATEGY) != Z_OK) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module, "ZLib error: %s",
|
||||
SAFE_MSG(sp));
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
return (1);
|
||||
default:
|
||||
return (*sp->vsetparent)(tif, tag, ap);
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
static int
|
||||
ZIPVGetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
{
|
||||
ZIPState* sp = ZState(tif);
|
||||
ZIPState* sp = ZState(tif);
|
||||
|
||||
switch (tag) {
|
||||
case TIFFTAG_ZIPQUALITY:
|
||||
*va_arg(ap, int*) = sp->zipquality;
|
||||
break;
|
||||
default:
|
||||
return (*sp->vgetparent)(tif, tag, ap);
|
||||
}
|
||||
return (1);
|
||||
switch (tag) {
|
||||
case TIFFTAG_ZIPQUALITY:
|
||||
*va_arg(ap, int*) = sp->zipquality;
|
||||
break;
|
||||
default:
|
||||
return (*sp->vgetparent)(tif, tag, ap);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
static const TIFFField zipFields[] = {
|
||||
@@ -392,72 +399,72 @@ static const TIFFField zipFields[] = {
|
||||
int
|
||||
TIFFInitZIP(TIFF* tif, int scheme)
|
||||
{
|
||||
static const char module[] = "TIFFInitZIP";
|
||||
ZIPState* sp;
|
||||
static const char module[] = "TIFFInitZIP";
|
||||
ZIPState* sp;
|
||||
|
||||
assert( (scheme == COMPRESSION_DEFLATE)
|
||||
|| (scheme == COMPRESSION_ADOBE_DEFLATE));
|
||||
assert( (scheme == COMPRESSION_DEFLATE)
|
||||
|| (scheme == COMPRESSION_ADOBE_DEFLATE));
|
||||
|
||||
/*
|
||||
* Merge codec-specific tag information.
|
||||
*/
|
||||
if (!_TIFFMergeFields(tif, zipFields, TIFFArrayCount(zipFields))) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Merging Deflate codec-specific tags failed");
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Merge codec-specific tag information.
|
||||
*/
|
||||
if (!_TIFFMergeFields(tif, zipFields, TIFFArrayCount(zipFields))) {
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Merging Deflate codec-specific tags failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate state block so tag methods have storage to record values.
|
||||
*/
|
||||
tif->tif_data = (uint8*) _TIFFmalloc(sizeof (ZIPState));
|
||||
if (tif->tif_data == NULL)
|
||||
goto bad;
|
||||
sp = ZState(tif);
|
||||
sp->stream.zalloc = NULL;
|
||||
sp->stream.zfree = NULL;
|
||||
sp->stream.opaque = NULL;
|
||||
sp->stream.data_type = Z_BINARY;
|
||||
/*
|
||||
* Allocate state block so tag methods have storage to record values.
|
||||
*/
|
||||
tif->tif_data = (uint8*) _TIFFmalloc(sizeof (ZIPState));
|
||||
if (tif->tif_data == NULL)
|
||||
goto bad;
|
||||
sp = ZState(tif);
|
||||
sp->stream.zalloc = NULL;
|
||||
sp->stream.zfree = NULL;
|
||||
sp->stream.opaque = NULL;
|
||||
sp->stream.data_type = Z_BINARY;
|
||||
|
||||
/*
|
||||
* Override parent get/set field methods.
|
||||
*/
|
||||
sp->vgetparent = tif->tif_tagmethods.vgetfield;
|
||||
tif->tif_tagmethods.vgetfield = ZIPVGetField; /* hook for codec tags */
|
||||
sp->vsetparent = tif->tif_tagmethods.vsetfield;
|
||||
tif->tif_tagmethods.vsetfield = ZIPVSetField; /* hook for codec tags */
|
||||
/*
|
||||
* Override parent get/set field methods.
|
||||
*/
|
||||
sp->vgetparent = tif->tif_tagmethods.vgetfield;
|
||||
tif->tif_tagmethods.vgetfield = ZIPVGetField; /* hook for codec tags */
|
||||
sp->vsetparent = tif->tif_tagmethods.vsetfield;
|
||||
tif->tif_tagmethods.vsetfield = ZIPVSetField; /* hook for codec tags */
|
||||
|
||||
/* Default values for codec-specific fields */
|
||||
sp->zipquality = Z_DEFAULT_COMPRESSION; /* default comp. level */
|
||||
sp->state = 0;
|
||||
/* Default values for codec-specific fields */
|
||||
sp->zipquality = Z_DEFAULT_COMPRESSION; /* default comp. level */
|
||||
sp->state = 0;
|
||||
|
||||
/*
|
||||
* Install codec methods.
|
||||
*/
|
||||
tif->tif_fixuptags = ZIPFixupTags;
|
||||
tif->tif_setupdecode = ZIPSetupDecode;
|
||||
tif->tif_predecode = ZIPPreDecode;
|
||||
tif->tif_decoderow = ZIPDecode;
|
||||
tif->tif_decodestrip = ZIPDecode;
|
||||
tif->tif_decodetile = ZIPDecode;
|
||||
tif->tif_setupencode = ZIPSetupEncode;
|
||||
tif->tif_preencode = ZIPPreEncode;
|
||||
tif->tif_postencode = ZIPPostEncode;
|
||||
tif->tif_encoderow = ZIPEncode;
|
||||
tif->tif_encodestrip = ZIPEncode;
|
||||
tif->tif_encodetile = ZIPEncode;
|
||||
tif->tif_cleanup = ZIPCleanup;
|
||||
/*
|
||||
* Setup predictor setup.
|
||||
*/
|
||||
(void) TIFFPredictorInit(tif);
|
||||
return (1);
|
||||
/*
|
||||
* Install codec methods.
|
||||
*/
|
||||
tif->tif_fixuptags = ZIPFixupTags;
|
||||
tif->tif_setupdecode = ZIPSetupDecode;
|
||||
tif->tif_predecode = ZIPPreDecode;
|
||||
tif->tif_decoderow = ZIPDecode;
|
||||
tif->tif_decodestrip = ZIPDecode;
|
||||
tif->tif_decodetile = ZIPDecode;
|
||||
tif->tif_setupencode = ZIPSetupEncode;
|
||||
tif->tif_preencode = ZIPPreEncode;
|
||||
tif->tif_postencode = ZIPPostEncode;
|
||||
tif->tif_encoderow = ZIPEncode;
|
||||
tif->tif_encodestrip = ZIPEncode;
|
||||
tif->tif_encodetile = ZIPEncode;
|
||||
tif->tif_cleanup = ZIPCleanup;
|
||||
/*
|
||||
* Setup predictor setup.
|
||||
*/
|
||||
(void) TIFFPredictorInit(tif);
|
||||
return (1);
|
||||
bad:
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"No space for ZIP state block");
|
||||
return (0);
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"No space for ZIP state block");
|
||||
return (0);
|
||||
}
|
||||
#endif /* ZIP_SUPORT */
|
||||
#endif /* ZIP_SUPPORT */
|
||||
|
||||
/* vim: set ts=8 sts=8 sw=8 noet: */
|
||||
/*
|
||||
|
||||
Vendored
+117
-86
@@ -1,33 +1,33 @@
|
||||
/* $Id: tiff.h,v 1.67 2011-01-24 21:06:32 olivier Exp $ */
|
||||
/* $Id: tiff.h,v 1.70 2016-01-23 21:20:34 erouault Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _TIFF_
|
||||
#define _TIFF_
|
||||
|
||||
#include "tif_config.h"
|
||||
#include "tiffconf.h"
|
||||
|
||||
/*
|
||||
* Tag Image File Format (TIFF)
|
||||
@@ -91,20 +91,20 @@ typedef int uint16_vap;
|
||||
* TIFF header.
|
||||
*/
|
||||
typedef struct {
|
||||
uint16 tiff_magic; /* magic number (defines byte order) */
|
||||
uint16 tiff_version; /* TIFF version number */
|
||||
uint16 tiff_magic; /* magic number (defines byte order) */
|
||||
uint16 tiff_version; /* TIFF version number */
|
||||
} TIFFHeaderCommon;
|
||||
typedef struct {
|
||||
uint16 tiff_magic; /* magic number (defines byte order) */
|
||||
uint16 tiff_version; /* TIFF version number */
|
||||
uint32 tiff_diroff; /* byte offset to first directory */
|
||||
uint16 tiff_magic; /* magic number (defines byte order) */
|
||||
uint16 tiff_version; /* TIFF version number */
|
||||
uint32 tiff_diroff; /* byte offset to first directory */
|
||||
} TIFFHeaderClassic;
|
||||
typedef struct {
|
||||
uint16 tiff_magic; /* magic number (defines byte order) */
|
||||
uint16 tiff_version; /* TIFF version number */
|
||||
uint16 tiff_offsetsize; /* size of offsets, should be 8 */
|
||||
uint16 tiff_unused; /* unused word, should be 0 */
|
||||
uint64 tiff_diroff; /* byte offset to first directory */
|
||||
uint16 tiff_magic; /* magic number (defines byte order) */
|
||||
uint16 tiff_version; /* TIFF version number */
|
||||
uint16 tiff_offsetsize; /* size of offsets, should be 8 */
|
||||
uint16 tiff_unused; /* unused word, should be 0 */
|
||||
uint64 tiff_diroff; /* byte offset to first directory */
|
||||
} TIFFHeaderBig;
|
||||
|
||||
|
||||
@@ -123,23 +123,23 @@ typedef struct {
|
||||
* Note: RATIONALs are the ratio of two 32-bit integer values.
|
||||
*/
|
||||
typedef enum {
|
||||
TIFF_NOTYPE = 0, /* placeholder */
|
||||
TIFF_BYTE = 1, /* 8-bit unsigned integer */
|
||||
TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */
|
||||
TIFF_SHORT = 3, /* 16-bit unsigned integer */
|
||||
TIFF_LONG = 4, /* 32-bit unsigned integer */
|
||||
TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */
|
||||
TIFF_SBYTE = 6, /* !8-bit signed integer */
|
||||
TIFF_UNDEFINED = 7, /* !8-bit untyped data */
|
||||
TIFF_SSHORT = 8, /* !16-bit signed integer */
|
||||
TIFF_SLONG = 9, /* !32-bit signed integer */
|
||||
TIFF_SRATIONAL = 10, /* !64-bit signed fraction */
|
||||
TIFF_FLOAT = 11, /* !32-bit IEEE floating point */
|
||||
TIFF_DOUBLE = 12, /* !64-bit IEEE floating point */
|
||||
TIFF_IFD = 13, /* %32-bit unsigned integer (offset) */
|
||||
TIFF_LONG8 = 16, /* BigTIFF 64-bit unsigned integer */
|
||||
TIFF_SLONG8 = 17, /* BigTIFF 64-bit signed integer */
|
||||
TIFF_IFD8 = 18 /* BigTIFF 64-bit unsigned integer (offset) */
|
||||
TIFF_NOTYPE = 0, /* placeholder */
|
||||
TIFF_BYTE = 1, /* 8-bit unsigned integer */
|
||||
TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */
|
||||
TIFF_SHORT = 3, /* 16-bit unsigned integer */
|
||||
TIFF_LONG = 4, /* 32-bit unsigned integer */
|
||||
TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */
|
||||
TIFF_SBYTE = 6, /* !8-bit signed integer */
|
||||
TIFF_UNDEFINED = 7, /* !8-bit untyped data */
|
||||
TIFF_SSHORT = 8, /* !16-bit signed integer */
|
||||
TIFF_SLONG = 9, /* !32-bit signed integer */
|
||||
TIFF_SRATIONAL = 10, /* !64-bit signed fraction */
|
||||
TIFF_FLOAT = 11, /* !32-bit IEEE floating point */
|
||||
TIFF_DOUBLE = 12, /* !64-bit IEEE floating point */
|
||||
TIFF_IFD = 13, /* %32-bit unsigned integer (offset) */
|
||||
TIFF_LONG8 = 16, /* BigTIFF 64-bit unsigned integer */
|
||||
TIFF_SLONG8 = 17, /* BigTIFF 64-bit signed integer */
|
||||
TIFF_IFD8 = 18 /* BigTIFF 64-bit unsigned integer (offset) */
|
||||
} TIFFDataType;
|
||||
|
||||
/*
|
||||
@@ -166,6 +166,8 @@ typedef enum {
|
||||
#define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */
|
||||
#define COMPRESSION_OJPEG 6 /* !6.0 JPEG */
|
||||
#define COMPRESSION_JPEG 7 /* %JPEG DCT compression */
|
||||
#define COMPRESSION_T85 9 /* !TIFF/FX T.85 JBIG compression */
|
||||
#define COMPRESSION_T43 10 /* !TIFF/FX T.43 colour by layered JBIG compression */
|
||||
#define COMPRESSION_NEXT 32766 /* NeXT 2-bit RLE */
|
||||
#define COMPRESSION_CCITTRLEW 32771 /* #1 w/ word alignment */
|
||||
#define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */
|
||||
@@ -180,7 +182,7 @@ typedef enum {
|
||||
#define COMPRESSION_PIXARLOG 32909 /* Pixar companded 11bit ZIP */
|
||||
#define COMPRESSION_DEFLATE 32946 /* Deflate compression */
|
||||
#define COMPRESSION_ADOBE_DEFLATE 8 /* Deflate compression,
|
||||
as recognized by Adobe */
|
||||
as recognized by Adobe */
|
||||
/* compression code 32947 is reserved for Oceana Matrix <dev@oceana.com> */
|
||||
#define COMPRESSION_DCS 32947 /* Kodak DCS encoding */
|
||||
#define COMPRESSION_JBIG 34661 /* ISO JBIG */
|
||||
@@ -199,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 */
|
||||
@@ -276,7 +279,7 @@ typedef enum {
|
||||
#define PREDICTOR_FLOATINGPOINT 3 /* floating point predictor */
|
||||
#define TIFFTAG_WHITEPOINT 318 /* image white point */
|
||||
#define TIFFTAG_PRIMARYCHROMATICITIES 319 /* !primary chromaticities */
|
||||
#define TIFFTAG_COLORMAP 320 /* RGB map for pallette image */
|
||||
#define TIFFTAG_COLORMAP 320 /* RGB map for palette image */
|
||||
#define TIFFTAG_HALFTONEHINTS 321 /* !highlight+shadow info */
|
||||
#define TIFFTAG_TILEWIDTH 322 /* !tile width in pixels */
|
||||
#define TIFFTAG_TILELENGTH 323 /* !tile height in pixels */
|
||||
@@ -310,15 +313,39 @@ typedef enum {
|
||||
#define TIFFTAG_SMINSAMPLEVALUE 340 /* !variable MinSampleValue */
|
||||
#define TIFFTAG_SMAXSAMPLEVALUE 341 /* !variable MaxSampleValue */
|
||||
#define TIFFTAG_CLIPPATH 343 /* %ClipPath
|
||||
[Adobe TIFF technote 2] */
|
||||
[Adobe TIFF technote 2] */
|
||||
#define TIFFTAG_XCLIPPATHUNITS 344 /* %XClipPathUnits
|
||||
[Adobe TIFF technote 2] */
|
||||
[Adobe TIFF technote 2] */
|
||||
#define TIFFTAG_YCLIPPATHUNITS 345 /* %YClipPathUnits
|
||||
[Adobe TIFF technote 2] */
|
||||
[Adobe TIFF technote 2] */
|
||||
#define TIFFTAG_INDEXED 346 /* %Indexed
|
||||
[Adobe TIFF Technote 3] */
|
||||
[Adobe TIFF Technote 3] */
|
||||
#define TIFFTAG_JPEGTABLES 347 /* %JPEG table stream */
|
||||
#define TIFFTAG_OPIPROXY 351 /* %OPI Proxy [Adobe TIFF technote] */
|
||||
/* Tags 400-435 are from the TIFF/FX spec */
|
||||
#define TIFFTAG_GLOBALPARAMETERSIFD 400 /* ! */
|
||||
#define TIFFTAG_PROFILETYPE 401 /* ! */
|
||||
#define PROFILETYPE_UNSPECIFIED 0 /* ! */
|
||||
#define PROFILETYPE_G3_FAX 1 /* ! */
|
||||
#define TIFFTAG_FAXPROFILE 402 /* ! */
|
||||
#define FAXPROFILE_S 1 /* !TIFF/FX FAX profile S */
|
||||
#define FAXPROFILE_F 2 /* !TIFF/FX FAX profile F */
|
||||
#define FAXPROFILE_J 3 /* !TIFF/FX FAX profile J */
|
||||
#define FAXPROFILE_C 4 /* !TIFF/FX FAX profile C */
|
||||
#define FAXPROFILE_L 5 /* !TIFF/FX FAX profile L */
|
||||
#define FAXPROFILE_M 6 /* !TIFF/FX FAX profile LM */
|
||||
#define TIFFTAG_CODINGMETHODS 403 /* !TIFF/FX coding methods */
|
||||
#define CODINGMETHODS_T4_1D (1 << 1) /* !T.4 1D */
|
||||
#define CODINGMETHODS_T4_2D (1 << 2) /* !T.4 2D */
|
||||
#define CODINGMETHODS_T6 (1 << 3) /* !T.6 */
|
||||
#define CODINGMETHODS_T85 (1 << 4) /* !T.85 JBIG */
|
||||
#define CODINGMETHODS_T42 (1 << 5) /* !T.42 JPEG */
|
||||
#define CODINGMETHODS_T43 (1 << 6) /* !T.43 colour by layered JBIG */
|
||||
#define TIFFTAG_VERSIONYEAR 404 /* !TIFF/FX version year */
|
||||
#define TIFFTAG_MODENUMBER 405 /* !TIFF/FX mode number */
|
||||
#define TIFFTAG_DECODE 433 /* !TIFF/FX decode */
|
||||
#define TIFFTAG_IMAGEBASECOLOR 434 /* !TIFF/FX image base colour */
|
||||
#define TIFFTAG_T82OPTIONS 435 /* !TIFF/FX T.82 options */
|
||||
/*
|
||||
* Tags 512-521 are obsoleted by Technical Note #2 which specifies a
|
||||
* revised JPEG-in-TIFF scheme.
|
||||
@@ -331,7 +358,7 @@ typedef enum {
|
||||
#define TIFFTAG_JPEGRESTARTINTERVAL 515 /* !restart interval length */
|
||||
#define TIFFTAG_JPEGLOSSLESSPREDICTORS 517 /* !lossless proc predictor */
|
||||
#define TIFFTAG_JPEGPOINTTRANSFORM 518 /* !lossless point transform */
|
||||
#define TIFFTAG_JPEGQTABLES 519 /* !Q matrice offsets */
|
||||
#define TIFFTAG_JPEGQTABLES 519 /* !Q matrix offsets */
|
||||
#define TIFFTAG_JPEGDCTABLES 520 /* !DCT table offsets */
|
||||
#define TIFFTAG_JPEGACTABLES 521 /* !AC coefficient offsets */
|
||||
#define TIFFTAG_YCBCRCOEFFICIENTS 529 /* !RGB -> YCbCr transform */
|
||||
@@ -340,11 +367,12 @@ typedef enum {
|
||||
#define YCBCRPOSITION_CENTERED 1 /* !as in PostScript Level 2 */
|
||||
#define YCBCRPOSITION_COSITED 2 /* !as in CCIR 601-1 */
|
||||
#define TIFFTAG_REFERENCEBLACKWHITE 532 /* !colorimetry info */
|
||||
#define TIFFTAG_STRIPROWCOUNTS 559 /* !TIFF/FX strip row counts */
|
||||
#define TIFFTAG_XMLPACKET 700 /* %XML packet
|
||||
[Adobe XMP Specification,
|
||||
January 2004 */
|
||||
[Adobe XMP Specification,
|
||||
January 2004 */
|
||||
#define TIFFTAG_OPIIMAGEID 32781 /* %OPI ImageID
|
||||
[Adobe TIFF technote] */
|
||||
[Adobe TIFF technote] */
|
||||
/* tags 32952-32956 are private tags registered to Island Graphics */
|
||||
#define TIFFTAG_REFPTS 32953 /* image reference points */
|
||||
#define TIFFTAG_REGIONTACKPOINT 32954 /* region-xform tack point */
|
||||
@@ -358,7 +386,7 @@ typedef enum {
|
||||
/* tags 33300-33309 are private tags registered to Pixar */
|
||||
/*
|
||||
* TIFFTAG_PIXAR_IMAGEFULLWIDTH and TIFFTAG_PIXAR_IMAGEFULLLENGTH
|
||||
* are set when an image has been cropped out of a larger image.
|
||||
* are set when an image has been cropped out of a larger image.
|
||||
* They reflect the size of the original uncropped image.
|
||||
* The TIFFTAG_XPOSITION and TIFFTAG_YPOSITION can be used
|
||||
* to determine the position of the smaller image in the larger one.
|
||||
@@ -375,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 */
|
||||
@@ -396,16 +426,17 @@ typedef enum {
|
||||
#define TIFFTAG_IT8COLORCHARACTERIZATION 34029 /* color character. table */
|
||||
#define TIFFTAG_IT8HCUSAGE 34030 /* HC usage indicator */
|
||||
#define TIFFTAG_IT8TRAPINDICATOR 34031 /* Trapping indicator
|
||||
(untrapped=0, trapped=1) */
|
||||
(untrapped=0, trapped=1) */
|
||||
#define TIFFTAG_IT8CMYKEQUIVALENT 34032 /* CMYK color equivalents */
|
||||
/* tags 34232-34236 are private tags registered to Texas Instruments */
|
||||
#define TIFFTAG_FRAMECOUNT 34232 /* Sequence Frame Count */
|
||||
/* tag 34377 is private tag registered to Adobe for PhotoShop */
|
||||
#define TIFFTAG_PHOTOSHOP 34377
|
||||
#define TIFFTAG_PHOTOSHOP 34377
|
||||
/* tags 34665, 34853 and 40965 are documented in EXIF specification */
|
||||
#define TIFFTAG_EXIFIFD 34665 /* Pointer to EXIF private directory */
|
||||
/* tag 34750 is a private tag registered to Adobe? */
|
||||
#define TIFFTAG_ICCPROFILE 34675 /* ICC profile data */
|
||||
#define TIFFTAG_IMAGELAYER 34732 /* !TIFF/FX image layer information */
|
||||
/* tag 34750 is a private tag registered to Pixel Magic */
|
||||
#define TIFFTAG_JBIGOPTIONS 34750 /* JBIG options */
|
||||
#define TIFFTAG_GPSIFD 34853 /* Pointer to GPS private directory */
|
||||
@@ -424,80 +455,80 @@ typedef enum {
|
||||
#define TIFFTAG_DNGBACKWARDVERSION 50707 /* &DNG compatibility version */
|
||||
#define TIFFTAG_UNIQUECAMERAMODEL 50708 /* &name for the camera model */
|
||||
#define TIFFTAG_LOCALIZEDCAMERAMODEL 50709 /* &localized camera model
|
||||
name */
|
||||
name */
|
||||
#define TIFFTAG_CFAPLANECOLOR 50710 /* &CFAPattern->LinearRaw space
|
||||
mapping */
|
||||
mapping */
|
||||
#define TIFFTAG_CFALAYOUT 50711 /* &spatial layout of the CFA */
|
||||
#define TIFFTAG_LINEARIZATIONTABLE 50712 /* &lookup table description */
|
||||
#define TIFFTAG_BLACKLEVELREPEATDIM 50713 /* &repeat pattern size for
|
||||
the BlackLevel tag */
|
||||
the BlackLevel tag */
|
||||
#define TIFFTAG_BLACKLEVEL 50714 /* &zero light encoding level */
|
||||
#define TIFFTAG_BLACKLEVELDELTAH 50715 /* &zero light encoding level
|
||||
differences (columns) */
|
||||
differences (columns) */
|
||||
#define TIFFTAG_BLACKLEVELDELTAV 50716 /* &zero light encoding level
|
||||
differences (rows) */
|
||||
differences (rows) */
|
||||
#define TIFFTAG_WHITELEVEL 50717 /* &fully saturated encoding
|
||||
level */
|
||||
level */
|
||||
#define TIFFTAG_DEFAULTSCALE 50718 /* &default scale factors */
|
||||
#define TIFFTAG_DEFAULTCROPORIGIN 50719 /* &origin of the final image
|
||||
area */
|
||||
#define TIFFTAG_DEFAULTCROPSIZE 50720 /* &size of the final image
|
||||
area */
|
||||
area */
|
||||
#define TIFFTAG_DEFAULTCROPSIZE 50720 /* &size of the final image
|
||||
area */
|
||||
#define TIFFTAG_COLORMATRIX1 50721 /* &XYZ->reference color space
|
||||
transformation matrix 1 */
|
||||
transformation matrix 1 */
|
||||
#define TIFFTAG_COLORMATRIX2 50722 /* &XYZ->reference color space
|
||||
transformation matrix 2 */
|
||||
transformation matrix 2 */
|
||||
#define TIFFTAG_CAMERACALIBRATION1 50723 /* &calibration matrix 1 */
|
||||
#define TIFFTAG_CAMERACALIBRATION2 50724 /* &calibration matrix 2 */
|
||||
#define TIFFTAG_REDUCTIONMATRIX1 50725 /* &dimensionality reduction
|
||||
matrix 1 */
|
||||
matrix 1 */
|
||||
#define TIFFTAG_REDUCTIONMATRIX2 50726 /* &dimensionality reduction
|
||||
matrix 2 */
|
||||
matrix 2 */
|
||||
#define TIFFTAG_ANALOGBALANCE 50727 /* &gain applied the stored raw
|
||||
values*/
|
||||
values*/
|
||||
#define TIFFTAG_ASSHOTNEUTRAL 50728 /* &selected white balance in
|
||||
linear reference space */
|
||||
linear reference space */
|
||||
#define TIFFTAG_ASSHOTWHITEXY 50729 /* &selected white balance in
|
||||
x-y chromaticity
|
||||
coordinates */
|
||||
x-y chromaticity
|
||||
coordinates */
|
||||
#define TIFFTAG_BASELINEEXPOSURE 50730 /* &how much to move the zero
|
||||
point */
|
||||
point */
|
||||
#define TIFFTAG_BASELINENOISE 50731 /* &relative noise level */
|
||||
#define TIFFTAG_BASELINESHARPNESS 50732 /* &relative amount of
|
||||
sharpening */
|
||||
sharpening */
|
||||
#define TIFFTAG_BAYERGREENSPLIT 50733 /* &how closely the values of
|
||||
the green pixels in the
|
||||
blue/green rows track the
|
||||
values of the green pixels
|
||||
in the red/green rows */
|
||||
the green pixels in the
|
||||
blue/green rows track the
|
||||
values of the green pixels
|
||||
in the red/green rows */
|
||||
#define TIFFTAG_LINEARRESPONSELIMIT 50734 /* &non-linear encoding range */
|
||||
#define TIFFTAG_CAMERASERIALNUMBER 50735 /* &camera's serial number */
|
||||
#define TIFFTAG_LENSINFO 50736 /* info about the lens */
|
||||
#define TIFFTAG_CHROMABLURRADIUS 50737 /* &chroma blur radius */
|
||||
#define TIFFTAG_ANTIALIASSTRENGTH 50738 /* &relative strength of the
|
||||
camera's anti-alias filter */
|
||||
camera's anti-alias filter */
|
||||
#define TIFFTAG_SHADOWSCALE 50739 /* &used by Adobe Camera Raw */
|
||||
#define TIFFTAG_DNGPRIVATEDATA 50740 /* &manufacturer's private data */
|
||||
#define TIFFTAG_MAKERNOTESAFETY 50741 /* &whether the EXIF MakerNote
|
||||
tag is safe to preserve
|
||||
along with the rest of the
|
||||
EXIF data */
|
||||
tag is safe to preserve
|
||||
along with the rest of the
|
||||
EXIF data */
|
||||
#define TIFFTAG_CALIBRATIONILLUMINANT1 50778 /* &illuminant 1 */
|
||||
#define TIFFTAG_CALIBRATIONILLUMINANT2 50779 /* &illuminant 2 */
|
||||
#define TIFFTAG_BESTQUALITYSCALE 50780 /* &best quality multiplier */
|
||||
#define TIFFTAG_RAWDATAUNIQUEID 50781 /* &unique identifier for
|
||||
the raw image data */
|
||||
the raw image data */
|
||||
#define TIFFTAG_ORIGINALRAWFILENAME 50827 /* &file name of the original
|
||||
raw file */
|
||||
raw file */
|
||||
#define TIFFTAG_ORIGINALRAWFILEDATA 50828 /* &contents of the original
|
||||
raw file */
|
||||
raw file */
|
||||
#define TIFFTAG_ACTIVEAREA 50829 /* &active (non-masked) pixels
|
||||
of the sensor */
|
||||
of the sensor */
|
||||
#define TIFFTAG_MASKEDAREAS 50830 /* &list of coordinates
|
||||
of fully masked pixels */
|
||||
of fully masked pixels */
|
||||
#define TIFFTAG_ASSHOTICCPROFILE 50831 /* &these two tags used to */
|
||||
#define TIFFTAG_ASSHOTPREPROFILEMATRIX 50832 /* map cameras's color space
|
||||
into ICC profile space */
|
||||
into ICC profile space */
|
||||
#define TIFFTAG_CURRENTICCPROFILE 50833 /* & */
|
||||
#define TIFFTAG_CURRENTPREPROFILEMATRIX 50834 /* & */
|
||||
/* tag 65535 is an undefined tag used by Eastman Kodak */
|
||||
@@ -582,12 +613,12 @@ typedef enum {
|
||||
#define EXIFTAG_SPECTRALSENSITIVITY 34852 /* Spectral sensitivity */
|
||||
#define EXIFTAG_ISOSPEEDRATINGS 34855 /* ISO speed rating */
|
||||
#define EXIFTAG_OECF 34856 /* Optoelectric conversion
|
||||
factor */
|
||||
factor */
|
||||
#define EXIFTAG_EXIFVERSION 36864 /* Exif version */
|
||||
#define EXIFTAG_DATETIMEORIGINAL 36867 /* Date and time of original
|
||||
data generation */
|
||||
data generation */
|
||||
#define EXIFTAG_DATETIMEDIGITIZED 36868 /* Date and time of digital
|
||||
data generation */
|
||||
data generation */
|
||||
#define EXIFTAG_COMPONENTSCONFIGURATION 37121 /* Meaning of each component */
|
||||
#define EXIFTAG_COMPRESSEDBITSPERPIXEL 37122 /* Image compression mode */
|
||||
#define EXIFTAG_SHUTTERSPEEDVALUE 37377 /* Shutter speed */
|
||||
|
||||
Vendored
+130
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
Configuration defines for installed libtiff.
|
||||
This file maintained for backward compatibility. Do not use definitions
|
||||
from this file in your programs.
|
||||
*/
|
||||
|
||||
#ifndef _TIFFCONF_
|
||||
#define _TIFFCONF_
|
||||
|
||||
/* 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 to 1 if the system has the type `int16'. */
|
||||
#cmakedefine HAVE_INT16 1
|
||||
|
||||
/* Define to 1 if the system has the type `int32'. */
|
||||
#cmakedefine HAVE_INT32 1
|
||||
|
||||
/* Define to 1 if the system has the type `int8'. */
|
||||
#cmakedefine HAVE_INT8 1
|
||||
|
||||
/* Compatibility stuff. */
|
||||
|
||||
/* Define as 0 or 1 according to the floating point format suported by the
|
||||
machine */
|
||||
#cmakedefine HAVE_IEEEFP 1
|
||||
|
||||
/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */
|
||||
#define HOST_FILLORDER @HOST_FILLORDER@
|
||||
|
||||
/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian
|
||||
(Intel) */
|
||||
#define HOST_BIGENDIAN @HOST_BIG_ENDIAN@
|
||||
|
||||
/* Support CCITT Group 3 & 4 algorithms */
|
||||
#cmakedefine CCITT_SUPPORT 1
|
||||
|
||||
/* Support JPEG compression (requires IJG JPEG library) */
|
||||
#cmakedefine JPEG_SUPPORT 1
|
||||
|
||||
/* Support JBIG compression (requires JBIG-KIT library) */
|
||||
#cmakedefine JBIG_SUPPORT
|
||||
|
||||
/* Support LogLuv high dynamic range encoding */
|
||||
#cmakedefine LOGLUV_SUPPORT 1
|
||||
|
||||
/* Support LZW algorithm */
|
||||
#cmakedefine LZW_SUPPORT 1
|
||||
|
||||
/* Support NeXT 2-bit RLE algorithm */
|
||||
#cmakedefine NEXT_SUPPORT 1
|
||||
|
||||
/* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation
|
||||
fails with unpatched IJG JPEG library) */
|
||||
#cmakedefine OJPEG_SUPPORT 1
|
||||
|
||||
/* Support Macintosh PackBits algorithm */
|
||||
#cmakedefine PACKBITS_SUPPORT 1
|
||||
|
||||
/* Support Pixar log-format algorithm (requires Zlib) */
|
||||
#cmakedefine PIXARLOG_SUPPORT 1
|
||||
|
||||
/* Support ThunderScan 4-bit RLE algorithm */
|
||||
#cmakedefine THUNDER_SUPPORT 1
|
||||
|
||||
/* Support Deflate compression */
|
||||
#cmakedefine ZIP_SUPPORT 1
|
||||
|
||||
/* Support strip chopping (whether or not to convert single-strip uncompressed
|
||||
images to mutiple strips of ~8Kb to reduce memory usage) */
|
||||
#cmakedefine STRIPCHOP_DEFAULT 1
|
||||
|
||||
/* Enable SubIFD tag (330) support */
|
||||
#cmakedefine SUBIFD_SUPPORT 1
|
||||
|
||||
/* 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 1
|
||||
|
||||
/* Pick up YCbCr subsampling info from the JPEG data stream to support files
|
||||
lacking the tag (default enabled). */
|
||||
#cmakedefine CHECK_JPEG_YCBCR_SUBSAMPLING 1
|
||||
|
||||
/* Support MS MDI magic number files as TIFF */
|
||||
#cmakedefine MDI_SUPPORT 1
|
||||
|
||||
/*
|
||||
* Feature support definitions.
|
||||
* XXX: These macros are obsoleted. Don't use them in your apps!
|
||||
* Macros stays here for backward compatibility and should be always defined.
|
||||
*/
|
||||
#define COLORIMETRY_SUPPORT
|
||||
#define YCBCR_SUPPORT
|
||||
#define CMYK_SUPPORT
|
||||
#define ICC_SUPPORT
|
||||
#define PHOTOSHOP_SUPPORT
|
||||
#define IPTC_SUPPORT
|
||||
|
||||
#endif /* _TIFFCONF_ */
|
||||
Vendored
+98
-88
@@ -1,4 +1,4 @@
|
||||
/* $Id: tiffio.h,v 1.90 2012-06-06 04:58:00 fwarmerdam Exp $ */
|
||||
/* $Id: tiffio.h,v 1.94 2017-01-11 19:02:49 erouault Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@@ -120,7 +120,7 @@ typedef void* thandle_t; /* client data handle */
|
||||
#define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */
|
||||
#define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */
|
||||
|
||||
/*
|
||||
/*
|
||||
* Colour conversion stuff
|
||||
*/
|
||||
|
||||
@@ -138,39 +138,39 @@ typedef void* thandle_t; /* client data handle */
|
||||
typedef unsigned char TIFFRGBValue; /* 8-bit samples */
|
||||
|
||||
typedef struct {
|
||||
float d_mat[3][3]; /* XYZ -> luminance matrix */
|
||||
float d_YCR; /* Light o/p for reference white */
|
||||
float d_YCG;
|
||||
float d_YCB;
|
||||
uint32 d_Vrwr; /* Pixel values for ref. white */
|
||||
uint32 d_Vrwg;
|
||||
uint32 d_Vrwb;
|
||||
float d_Y0R; /* Residual light for black pixel */
|
||||
float d_Y0G;
|
||||
float d_Y0B;
|
||||
float d_gammaR; /* Gamma values for the three guns */
|
||||
float d_gammaG;
|
||||
float d_gammaB;
|
||||
float d_mat[3][3]; /* XYZ -> luminance matrix */
|
||||
float d_YCR; /* Light o/p for reference white */
|
||||
float d_YCG;
|
||||
float d_YCB;
|
||||
uint32 d_Vrwr; /* Pixel values for ref. white */
|
||||
uint32 d_Vrwg;
|
||||
uint32 d_Vrwb;
|
||||
float d_Y0R; /* Residual light for black pixel */
|
||||
float d_Y0G;
|
||||
float d_Y0B;
|
||||
float d_gammaR; /* Gamma values for the three guns */
|
||||
float d_gammaG;
|
||||
float d_gammaB;
|
||||
} TIFFDisplay;
|
||||
|
||||
typedef struct { /* YCbCr->RGB support */
|
||||
TIFFRGBValue* clamptab; /* range clamping table */
|
||||
int* Cr_r_tab;
|
||||
int* Cb_b_tab;
|
||||
int32* Cr_g_tab;
|
||||
int32* Cb_g_tab;
|
||||
int32* Y_tab;
|
||||
TIFFRGBValue* clamptab; /* range clamping table */
|
||||
int* Cr_r_tab;
|
||||
int* Cb_b_tab;
|
||||
int32* Cr_g_tab;
|
||||
int32* Cb_g_tab;
|
||||
int32* Y_tab;
|
||||
} TIFFYCbCrToRGB;
|
||||
|
||||
typedef struct { /* CIE Lab 1976->RGB support */
|
||||
int range; /* Size of conversion table */
|
||||
int range; /* Size of conversion table */
|
||||
#define CIELABTORGB_TABLE_RANGE 1500
|
||||
float rstep, gstep, bstep;
|
||||
float X0, Y0, Z0; /* Reference white point */
|
||||
TIFFDisplay display;
|
||||
float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */
|
||||
float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */
|
||||
float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */
|
||||
float rstep, gstep, bstep;
|
||||
float X0, Y0, Z0; /* Reference white point */
|
||||
TIFFDisplay display;
|
||||
float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */
|
||||
float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */
|
||||
float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */
|
||||
} TIFFCIELabToRGB;
|
||||
|
||||
/*
|
||||
@@ -180,7 +180,7 @@ typedef struct _TIFFRGBAImage TIFFRGBAImage;
|
||||
/*
|
||||
* The image reading and conversion routines invoke
|
||||
* ``put routines'' to copy/image/whatever tiles of
|
||||
* raw image data. A default set of routines are
|
||||
* raw image data. A default set of routines are
|
||||
* provided to convert/copy raw image data to 8-bit
|
||||
* packed ABGR format rasters. Applications can supply
|
||||
* alternate routines that unpack the data into a
|
||||
@@ -189,47 +189,47 @@ typedef struct _TIFFRGBAImage TIFFRGBAImage;
|
||||
*/
|
||||
typedef void (*tileContigRoutine)
|
||||
(TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32,
|
||||
unsigned char*);
|
||||
unsigned char*);
|
||||
typedef void (*tileSeparateRoutine)
|
||||
(TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32,
|
||||
unsigned char*, unsigned char*, unsigned char*, unsigned char*);
|
||||
unsigned char*, unsigned char*, unsigned char*, unsigned char*);
|
||||
/*
|
||||
* RGBA-reader state.
|
||||
*/
|
||||
struct _TIFFRGBAImage {
|
||||
TIFF* tif; /* image handle */
|
||||
int stoponerr; /* stop on read error */
|
||||
int isContig; /* data is packed/separate */
|
||||
int alpha; /* type of alpha data present */
|
||||
uint32 width; /* image width */
|
||||
uint32 height; /* image height */
|
||||
uint16 bitspersample; /* image bits/sample */
|
||||
uint16 samplesperpixel; /* image samples/pixel */
|
||||
uint16 orientation; /* image orientation */
|
||||
uint16 req_orientation; /* requested orientation */
|
||||
uint16 photometric; /* image photometric interp */
|
||||
uint16* redcmap; /* colormap pallete */
|
||||
uint16* greencmap;
|
||||
uint16* bluecmap;
|
||||
/* get image data routine */
|
||||
int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32);
|
||||
/* put decoded strip/tile */
|
||||
union {
|
||||
void (*any)(TIFFRGBAImage*);
|
||||
tileContigRoutine contig;
|
||||
tileSeparateRoutine separate;
|
||||
} put;
|
||||
TIFFRGBValue* Map; /* sample mapping array */
|
||||
uint32** BWmap; /* black&white map */
|
||||
uint32** PALmap; /* palette image map */
|
||||
TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */
|
||||
TIFFCIELabToRGB* cielab; /* CIE L*a*b conversion state */
|
||||
TIFF* tif; /* image handle */
|
||||
int stoponerr; /* stop on read error */
|
||||
int isContig; /* data is packed/separate */
|
||||
int alpha; /* type of alpha data present */
|
||||
uint32 width; /* image width */
|
||||
uint32 height; /* image height */
|
||||
uint16 bitspersample; /* image bits/sample */
|
||||
uint16 samplesperpixel; /* image samples/pixel */
|
||||
uint16 orientation; /* image orientation */
|
||||
uint16 req_orientation; /* requested orientation */
|
||||
uint16 photometric; /* image photometric interp */
|
||||
uint16* redcmap; /* colormap palette */
|
||||
uint16* greencmap;
|
||||
uint16* bluecmap;
|
||||
/* get image data routine */
|
||||
int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32);
|
||||
/* put decoded strip/tile */
|
||||
union {
|
||||
void (*any)(TIFFRGBAImage*);
|
||||
tileContigRoutine contig;
|
||||
tileSeparateRoutine separate;
|
||||
} put;
|
||||
TIFFRGBValue* Map; /* sample mapping array */
|
||||
uint32** BWmap; /* black&white map */
|
||||
uint32** PALmap; /* palette image map */
|
||||
TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */
|
||||
TIFFCIELabToRGB* cielab; /* CIE L*a*b conversion state */
|
||||
|
||||
uint8* UaToAa; /* Unassociated alpha to associated alpha convertion LUT */
|
||||
uint8* Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */
|
||||
uint8* UaToAa; /* Unassociated alpha to associated alpha conversion LUT */
|
||||
uint8* Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */
|
||||
|
||||
int row_offset;
|
||||
int col_offset;
|
||||
int row_offset;
|
||||
int col_offset;
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -250,9 +250,9 @@ struct _TIFFRGBAImage {
|
||||
*/
|
||||
typedef int (*TIFFInitMethod)(TIFF*, int);
|
||||
typedef struct {
|
||||
char* name;
|
||||
uint16 scheme;
|
||||
TIFFInitMethod init;
|
||||
char* name;
|
||||
uint16 scheme;
|
||||
TIFFInitMethod init;
|
||||
} TIFFCodec;
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -293,6 +293,7 @@ extern TIFFCodec* TIFFGetConfiguredCODECs(void);
|
||||
*/
|
||||
|
||||
extern void* _TIFFmalloc(tmsize_t s);
|
||||
extern void* _TIFFcalloc(tmsize_t nmemb, tmsize_t siz);
|
||||
extern void* _TIFFrealloc(void* p, tmsize_t s);
|
||||
extern void _TIFFmemset(void* p, int v, tmsize_t c);
|
||||
extern void _TIFFmemcpy(void* d, const void* s, tmsize_t c);
|
||||
@@ -304,7 +305,7 @@ extern void _TIFFfree(void* p);
|
||||
*/
|
||||
extern int TIFFGetTagListCount( TIFF * );
|
||||
extern uint32 TIFFGetTagListEntry( TIFF *, int tag_index );
|
||||
|
||||
|
||||
#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */
|
||||
#define TIFF_VARIABLE -1 /* marker for variable length tags */
|
||||
#define TIFF_SPP -2 /* marker for SamplesPerPixel tags */
|
||||
@@ -319,6 +320,13 @@ extern const TIFFField* TIFFFindField(TIFF *, uint32, TIFFDataType);
|
||||
extern const TIFFField* TIFFFieldWithTag(TIFF*, uint32);
|
||||
extern const TIFFField* TIFFFieldWithName(TIFF*, const char *);
|
||||
|
||||
extern uint32 TIFFFieldTag(const TIFFField*);
|
||||
extern const char* TIFFFieldName(const TIFFField*);
|
||||
extern TIFFDataType TIFFFieldDataType(const TIFFField*);
|
||||
extern int TIFFFieldPassCount(const TIFFField*);
|
||||
extern int TIFFFieldReadCount(const TIFFField*);
|
||||
extern int TIFFFieldWriteCount(const TIFFField*);
|
||||
|
||||
typedef int (*TIFFVSetMethod)(TIFF*, uint32, va_list);
|
||||
typedef int (*TIFFVGetMethod)(TIFF*, uint32, va_list);
|
||||
typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long);
|
||||
@@ -375,7 +383,7 @@ extern int TIFFIsMSB2LSB(TIFF*);
|
||||
extern int TIFFIsBigEndian(TIFF*);
|
||||
extern TIFFReadWriteProc TIFFGetReadProc(TIFF*);
|
||||
extern TIFFReadWriteProc TIFFGetWriteProc(TIFF*);
|
||||
extern TIFFSeekProc TIFFGetSeekProc(TIFF*);
|
||||
extern TIFFSeekProc TIFFGetSeekProc(TIFF*);
|
||||
extern TIFFCloseProc TIFFGetCloseProc(TIFF*);
|
||||
extern TIFFSizeProc TIFFGetSizeProc(TIFF*);
|
||||
extern TIFFMapFileProc TIFFGetMapFileProc(TIFF*);
|
||||
@@ -387,7 +395,7 @@ extern uint64 TIFFCurrentDirOffset(TIFF*);
|
||||
extern uint32 TIFFCurrentStrip(TIFF*);
|
||||
extern uint32 TIFFCurrentTile(TIFF* tif);
|
||||
extern int TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size);
|
||||
extern int TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size);
|
||||
extern int TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size);
|
||||
extern int TIFFSetupStrips(TIFF *);
|
||||
extern int TIFFWriteCheck(TIFF*, int, const char *);
|
||||
extern void TIFFFreeDirectory(TIFF*);
|
||||
@@ -423,6 +431,8 @@ extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int, int);
|
||||
|
||||
extern int TIFFReadRGBAStrip(TIFF*, uint32, uint32 * );
|
||||
extern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * );
|
||||
extern int TIFFReadRGBAStripExt(TIFF*, uint32, uint32 *, int stop_on_error );
|
||||
extern int TIFFReadRGBATileExt(TIFF*, uint32, uint32, uint32 *, int stop_on_error );
|
||||
extern int TIFFRGBAImageOK(TIFF*, char [1024]);
|
||||
extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]);
|
||||
extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32);
|
||||
@@ -433,11 +443,11 @@ extern TIFF* TIFFOpenW(const wchar_t*, const char*);
|
||||
# endif /* __WIN32__ */
|
||||
extern TIFF* TIFFFdOpen(int, const char*, const char*);
|
||||
extern TIFF* TIFFClientOpen(const char*, const char*,
|
||||
thandle_t,
|
||||
TIFFReadWriteProc, TIFFReadWriteProc,
|
||||
TIFFSeekProc, TIFFCloseProc,
|
||||
TIFFSizeProc,
|
||||
TIFFMapFileProc, TIFFUnmapFileProc);
|
||||
thandle_t,
|
||||
TIFFReadWriteProc, TIFFReadWriteProc,
|
||||
TIFFSeekProc, TIFFCloseProc,
|
||||
TIFFSizeProc,
|
||||
TIFFMapFileProc, TIFFUnmapFileProc);
|
||||
extern const char* TIFFFileName(TIFF*);
|
||||
extern const char* TIFFSetFileName(TIFF*, const char *);
|
||||
extern void TIFFError(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3)));
|
||||
@@ -452,18 +462,18 @@ extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc);
|
||||
extern uint32 TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s);
|
||||
extern int TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s);
|
||||
extern uint32 TIFFNumberOfTiles(TIFF*);
|
||||
extern tmsize_t TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s);
|
||||
extern tmsize_t TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s);
|
||||
extern tmsize_t TIFFWriteTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s);
|
||||
extern uint32 TIFFComputeStrip(TIFF*, uint32, uint16);
|
||||
extern uint32 TIFFNumberOfStrips(TIFF*);
|
||||
extern tmsize_t TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size);
|
||||
extern tmsize_t TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size);
|
||||
extern tmsize_t TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size);
|
||||
extern tmsize_t TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size);
|
||||
extern tmsize_t TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size);
|
||||
extern tmsize_t TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size);
|
||||
extern tmsize_t TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size);
|
||||
extern tmsize_t TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc);
|
||||
extern tmsize_t TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc);
|
||||
extern tmsize_t TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc);
|
||||
extern tmsize_t TIFFWriteRawTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc);
|
||||
extern tmsize_t TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc);
|
||||
extern tmsize_t TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc);
|
||||
extern tmsize_t TIFFWriteRawTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc);
|
||||
extern int TIFFDataWidth(TIFFDataType); /* table of tag datatype widths */
|
||||
extern void TIFFSetWriteOffset(TIFF* tif, toff_t off);
|
||||
extern void TIFFSwabShort(uint16*);
|
||||
@@ -522,18 +532,18 @@ extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32,
|
||||
* libtiff versions.
|
||||
****************************************************************************/
|
||||
typedef struct {
|
||||
ttag_t field_tag; /* field's tag */
|
||||
short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */
|
||||
short field_writecount; /* write count/TIFF_VARIABLE */
|
||||
TIFFDataType field_type; /* type of associated data */
|
||||
ttag_t field_tag; /* field's tag */
|
||||
short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */
|
||||
short field_writecount; /* write count/TIFF_VARIABLE */
|
||||
TIFFDataType field_type; /* type of associated data */
|
||||
unsigned short field_bit; /* bit in fieldsset bit vector */
|
||||
unsigned char field_oktochange; /* if true, can change while writing */
|
||||
unsigned char field_passcount; /* if true, pass dir count on set */
|
||||
char *field_name; /* ASCII name */
|
||||
unsigned char field_oktochange; /* if true, can change while writing */
|
||||
unsigned char field_passcount; /* if true, pass dir count on set */
|
||||
char *field_name; /* ASCII name */
|
||||
} TIFFFieldInfo;
|
||||
|
||||
extern int TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], uint32);
|
||||
|
||||
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
Vendored
+8
-8
@@ -4,23 +4,23 @@
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
Vendored
+207
-129
@@ -1,26 +1,26 @@
|
||||
/* $Id: tiffiop.h,v 1.84 2012-05-30 01:50:17 fwarmerdam Exp $ */
|
||||
/* $Id: tiffiop.h,v 1.95 2017-09-07 14:02:52 erouault Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the names of
|
||||
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Sam Leffler and Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
@@ -47,14 +47,20 @@
|
||||
#ifdef HAVE_ASSERT_H
|
||||
# include <assert.h>
|
||||
#else
|
||||
# define assert(x)
|
||||
# define assert(x)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SEARCH_H
|
||||
# include <search.h>
|
||||
#else
|
||||
extern void *lfind(const void *, const void *, size_t *, size_t,
|
||||
int (*)(const void *, const void *));
|
||||
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"
|
||||
@@ -80,7 +86,7 @@ typedef struct client_info {
|
||||
|
||||
/*
|
||||
* Typedefs for ``method pointers'' used internally.
|
||||
* these are depriciated and provided only for backwards compatibility
|
||||
* these are deprecated and provided only for backwards compatibility.
|
||||
*/
|
||||
typedef unsigned char tidataval_t; /* internal image data value type */
|
||||
typedef tidataval_t* tidata_t; /* reference to internal image data */
|
||||
@@ -95,112 +101,112 @@ typedef uint32 (*TIFFStripMethod)(TIFF*, uint32);
|
||||
typedef void (*TIFFTileMethod)(TIFF*, uint32*, uint32*);
|
||||
|
||||
struct tiff {
|
||||
char* tif_name; /* name of open file */
|
||||
int tif_fd; /* open file descriptor */
|
||||
int tif_mode; /* open mode (O_*) */
|
||||
uint32 tif_flags;
|
||||
#define TIFF_FILLORDER 0x00003 /* natural bit fill order for machine */
|
||||
#define TIFF_DIRTYHEADER 0x00004 /* header must be written on close */
|
||||
#define TIFF_DIRTYDIRECT 0x00008 /* current directory must be written */
|
||||
#define TIFF_BUFFERSETUP 0x00010 /* data buffers setup */
|
||||
#define TIFF_CODERSETUP 0x00020 /* encoder/decoder setup done */
|
||||
#define TIFF_BEENWRITING 0x00040 /* written 1+ scanlines to file */
|
||||
#define TIFF_SWAB 0x00080 /* byte swap file information */
|
||||
#define TIFF_NOBITREV 0x00100 /* inhibit bit reversal logic */
|
||||
#define TIFF_MYBUFFER 0x00200 /* my raw data buffer; free on close */
|
||||
#define TIFF_ISTILED 0x00400 /* file is tile, not strip- based */
|
||||
#define TIFF_MAPPED 0x00800 /* file is mapped into memory */
|
||||
#define TIFF_POSTENCODE 0x01000 /* need call to postencode routine */
|
||||
#define TIFF_INSUBIFD 0x02000 /* currently writing a subifd */
|
||||
#define TIFF_UPSAMPLED 0x04000 /* library is doing data up-sampling */
|
||||
#define TIFF_STRIPCHOP 0x08000 /* enable strip chopping support */
|
||||
#define TIFF_HEADERONLY 0x10000 /* read header only, do not process the first directory */
|
||||
#define TIFF_NOREADRAW 0x20000 /* skip reading of raw uncompressed image data */
|
||||
#define TIFF_INCUSTOMIFD 0x40000 /* currently writing a custom IFD */
|
||||
#define TIFF_BIGTIFF 0x80000 /* read/write bigtiff */
|
||||
#define TIFF_BUF4WRITE 0x100000 /* rawcc bytes are for writing */
|
||||
#define TIFF_DIRTYSTRIP 0x200000 /* stripoffsets/stripbytecount dirty*/
|
||||
#define TIFF_PERSAMPLE 0x400000 /* get/set per sample tags as arrays */
|
||||
#define TIFF_BUFFERMMAP 0x800000 /* read buffer (tif_rawdata) points into mmap() memory */
|
||||
uint64 tif_diroff; /* file offset of current directory */
|
||||
uint64 tif_nextdiroff; /* file offset of following directory */
|
||||
uint64* tif_dirlist; /* list of offsets to already seen directories to prevent IFD looping */
|
||||
uint16 tif_dirlistsize; /* number of entires in offset list */
|
||||
uint16 tif_dirnumber; /* number of already seen directories */
|
||||
TIFFDirectory tif_dir; /* internal rep of current directory */
|
||||
TIFFDirectory tif_customdir; /* custom IFDs are separated from the main ones */
|
||||
union {
|
||||
TIFFHeaderCommon common;
|
||||
TIFFHeaderClassic classic;
|
||||
TIFFHeaderBig big;
|
||||
} tif_header;
|
||||
uint16 tif_header_size; /* file's header block and its length */
|
||||
uint32 tif_row; /* current scanline */
|
||||
uint16 tif_curdir; /* current directory (index) */
|
||||
uint32 tif_curstrip; /* current strip for read/write */
|
||||
uint64 tif_curoff; /* current offset for read/write */
|
||||
uint64 tif_dataoff; /* current offset for writing dir */
|
||||
/* SubIFD support */
|
||||
uint16 tif_nsubifd; /* remaining subifds to write */
|
||||
uint64 tif_subifdoff; /* offset for patching SubIFD link */
|
||||
/* tiling support */
|
||||
uint32 tif_col; /* current column (offset by row too) */
|
||||
uint32 tif_curtile; /* current tile for read/write */
|
||||
tmsize_t tif_tilesize; /* # of bytes in a tile */
|
||||
/* compression scheme hooks */
|
||||
int tif_decodestatus;
|
||||
TIFFBoolMethod tif_fixuptags; /* called in TIFFReadDirectory */
|
||||
TIFFBoolMethod tif_setupdecode; /* called once before predecode */
|
||||
TIFFPreMethod tif_predecode; /* pre- row/strip/tile decoding */
|
||||
TIFFBoolMethod tif_setupencode; /* called once before preencode */
|
||||
int tif_encodestatus;
|
||||
TIFFPreMethod tif_preencode; /* pre- row/strip/tile encoding */
|
||||
TIFFBoolMethod tif_postencode; /* post- row/strip/tile encoding */
|
||||
TIFFCodeMethod tif_decoderow; /* scanline decoding routine */
|
||||
TIFFCodeMethod tif_encoderow; /* scanline encoding routine */
|
||||
TIFFCodeMethod tif_decodestrip; /* strip decoding routine */
|
||||
TIFFCodeMethod tif_encodestrip; /* strip encoding routine */
|
||||
TIFFCodeMethod tif_decodetile; /* tile decoding routine */
|
||||
TIFFCodeMethod tif_encodetile; /* tile encoding routine */
|
||||
TIFFVoidMethod tif_close; /* cleanup-on-close routine */
|
||||
TIFFSeekMethod tif_seek; /* position within a strip routine */
|
||||
TIFFVoidMethod tif_cleanup; /* cleanup state routine */
|
||||
TIFFStripMethod tif_defstripsize; /* calculate/constrain strip size */
|
||||
TIFFTileMethod tif_deftilesize; /* calculate/constrain tile size */
|
||||
uint8* tif_data; /* compression scheme private data */
|
||||
/* input/output buffering */
|
||||
tmsize_t tif_scanlinesize; /* # of bytes in a scanline */
|
||||
tmsize_t tif_scanlineskew; /* scanline skew for reading strips */
|
||||
uint8* tif_rawdata; /* raw data buffer */
|
||||
tmsize_t tif_rawdatasize; /* # of bytes in raw data buffer */
|
||||
char* tif_name; /* name of open file */
|
||||
int tif_fd; /* open file descriptor */
|
||||
int tif_mode; /* open mode (O_*) */
|
||||
uint32 tif_flags;
|
||||
#define TIFF_FILLORDER 0x00003U /* natural bit fill order for machine */
|
||||
#define TIFF_DIRTYHEADER 0x00004U /* header must be written on close */
|
||||
#define TIFF_DIRTYDIRECT 0x00008U /* current directory must be written */
|
||||
#define TIFF_BUFFERSETUP 0x00010U /* data buffers setup */
|
||||
#define TIFF_CODERSETUP 0x00020U /* encoder/decoder setup done */
|
||||
#define TIFF_BEENWRITING 0x00040U /* written 1+ scanlines to file */
|
||||
#define TIFF_SWAB 0x00080U /* byte swap file information */
|
||||
#define TIFF_NOBITREV 0x00100U /* inhibit bit reversal logic */
|
||||
#define TIFF_MYBUFFER 0x00200U /* my raw data buffer; free on close */
|
||||
#define TIFF_ISTILED 0x00400U /* file is tile, not strip- based */
|
||||
#define TIFF_MAPPED 0x00800U /* file is mapped into memory */
|
||||
#define TIFF_POSTENCODE 0x01000U /* need call to postencode routine */
|
||||
#define TIFF_INSUBIFD 0x02000U /* currently writing a subifd */
|
||||
#define TIFF_UPSAMPLED 0x04000U /* library is doing data up-sampling */
|
||||
#define TIFF_STRIPCHOP 0x08000U /* enable strip chopping support */
|
||||
#define TIFF_HEADERONLY 0x10000U /* read header only, do not process the first directory */
|
||||
#define TIFF_NOREADRAW 0x20000U /* skip reading of raw uncompressed image data */
|
||||
#define TIFF_INCUSTOMIFD 0x40000U /* currently writing a custom IFD */
|
||||
#define TIFF_BIGTIFF 0x80000U /* read/write bigtiff */
|
||||
#define TIFF_BUF4WRITE 0x100000U /* rawcc bytes are for writing */
|
||||
#define TIFF_DIRTYSTRIP 0x200000U /* stripoffsets/stripbytecount dirty*/
|
||||
#define TIFF_PERSAMPLE 0x400000U /* get/set per sample tags as arrays */
|
||||
#define TIFF_BUFFERMMAP 0x800000U /* read buffer (tif_rawdata) points into mmap() memory */
|
||||
uint64 tif_diroff; /* file offset of current directory */
|
||||
uint64 tif_nextdiroff; /* file offset of following directory */
|
||||
uint64* tif_dirlist; /* list of offsets to already seen directories to prevent IFD looping */
|
||||
uint16 tif_dirlistsize; /* number of entries in offset list */
|
||||
uint16 tif_dirnumber; /* number of already seen directories */
|
||||
TIFFDirectory tif_dir; /* internal rep of current directory */
|
||||
TIFFDirectory tif_customdir; /* custom IFDs are separated from the main ones */
|
||||
union {
|
||||
TIFFHeaderCommon common;
|
||||
TIFFHeaderClassic classic;
|
||||
TIFFHeaderBig big;
|
||||
} tif_header;
|
||||
uint16 tif_header_size; /* file's header block and its length */
|
||||
uint32 tif_row; /* current scanline */
|
||||
uint16 tif_curdir; /* current directory (index) */
|
||||
uint32 tif_curstrip; /* current strip for read/write */
|
||||
uint64 tif_curoff; /* current offset for read/write */
|
||||
uint64 tif_dataoff; /* current offset for writing dir */
|
||||
/* SubIFD support */
|
||||
uint16 tif_nsubifd; /* remaining subifds to write */
|
||||
uint64 tif_subifdoff; /* offset for patching SubIFD link */
|
||||
/* tiling support */
|
||||
uint32 tif_col; /* current column (offset by row too) */
|
||||
uint32 tif_curtile; /* current tile for read/write */
|
||||
tmsize_t tif_tilesize; /* # of bytes in a tile */
|
||||
/* compression scheme hooks */
|
||||
int tif_decodestatus;
|
||||
TIFFBoolMethod tif_fixuptags; /* called in TIFFReadDirectory */
|
||||
TIFFBoolMethod tif_setupdecode; /* called once before predecode */
|
||||
TIFFPreMethod tif_predecode; /* pre- row/strip/tile decoding */
|
||||
TIFFBoolMethod tif_setupencode; /* called once before preencode */
|
||||
int tif_encodestatus;
|
||||
TIFFPreMethod tif_preencode; /* pre- row/strip/tile encoding */
|
||||
TIFFBoolMethod tif_postencode; /* post- row/strip/tile encoding */
|
||||
TIFFCodeMethod tif_decoderow; /* scanline decoding routine */
|
||||
TIFFCodeMethod tif_encoderow; /* scanline encoding routine */
|
||||
TIFFCodeMethod tif_decodestrip; /* strip decoding routine */
|
||||
TIFFCodeMethod tif_encodestrip; /* strip encoding routine */
|
||||
TIFFCodeMethod tif_decodetile; /* tile decoding routine */
|
||||
TIFFCodeMethod tif_encodetile; /* tile encoding routine */
|
||||
TIFFVoidMethod tif_close; /* cleanup-on-close routine */
|
||||
TIFFSeekMethod tif_seek; /* position within a strip routine */
|
||||
TIFFVoidMethod tif_cleanup; /* cleanup state routine */
|
||||
TIFFStripMethod tif_defstripsize; /* calculate/constrain strip size */
|
||||
TIFFTileMethod tif_deftilesize; /* calculate/constrain tile size */
|
||||
uint8* tif_data; /* compression scheme private data */
|
||||
/* input/output buffering */
|
||||
tmsize_t tif_scanlinesize; /* # of bytes in a scanline */
|
||||
tmsize_t tif_scanlineskew; /* scanline skew for reading strips */
|
||||
uint8* tif_rawdata; /* raw data buffer */
|
||||
tmsize_t tif_rawdatasize; /* # of bytes in raw data buffer */
|
||||
tmsize_t tif_rawdataoff; /* rawdata offset within strip */
|
||||
tmsize_t tif_rawdataloaded;/* amount of data in rawdata */
|
||||
uint8* tif_rawcp; /* current spot in raw buffer */
|
||||
tmsize_t tif_rawcc; /* bytes unread from raw buffer */
|
||||
/* memory-mapped file support */
|
||||
uint8* tif_base; /* base of mapped file */
|
||||
tmsize_t tif_size; /* size of mapped file region (bytes, thus tmsize_t) */
|
||||
TIFFMapFileProc tif_mapproc; /* map file method */
|
||||
TIFFUnmapFileProc tif_unmapproc; /* unmap file method */
|
||||
/* input/output callback methods */
|
||||
thandle_t tif_clientdata; /* callback parameter */
|
||||
TIFFReadWriteProc tif_readproc; /* read method */
|
||||
TIFFReadWriteProc tif_writeproc; /* write method */
|
||||
TIFFSeekProc tif_seekproc; /* lseek method */
|
||||
TIFFCloseProc tif_closeproc; /* close method */
|
||||
TIFFSizeProc tif_sizeproc; /* filesize method */
|
||||
/* post-decoding support */
|
||||
TIFFPostMethod tif_postdecode; /* post decoding routine */
|
||||
/* tag support */
|
||||
TIFFField** tif_fields; /* sorted table of registered tags */
|
||||
size_t tif_nfields; /* # entries in registered tag table */
|
||||
const TIFFField* tif_foundfield; /* cached pointer to already found tag */
|
||||
TIFFTagMethods tif_tagmethods; /* tag get/set/print routines */
|
||||
TIFFClientInfoLink* tif_clientinfo; /* extra client information. */
|
||||
/* Backward compatibility stuff. We need these two fields for
|
||||
* setting up an old tag extension scheme. */
|
||||
TIFFFieldArray* tif_fieldscompat;
|
||||
size_t tif_nfieldscompat;
|
||||
uint8* tif_rawcp; /* current spot in raw buffer */
|
||||
tmsize_t tif_rawcc; /* bytes unread from raw buffer */
|
||||
/* memory-mapped file support */
|
||||
uint8* tif_base; /* base of mapped file */
|
||||
tmsize_t tif_size; /* size of mapped file region (bytes, thus tmsize_t) */
|
||||
TIFFMapFileProc tif_mapproc; /* map file method */
|
||||
TIFFUnmapFileProc tif_unmapproc; /* unmap file method */
|
||||
/* input/output callback methods */
|
||||
thandle_t tif_clientdata; /* callback parameter */
|
||||
TIFFReadWriteProc tif_readproc; /* read method */
|
||||
TIFFReadWriteProc tif_writeproc; /* write method */
|
||||
TIFFSeekProc tif_seekproc; /* lseek method */
|
||||
TIFFCloseProc tif_closeproc; /* close method */
|
||||
TIFFSizeProc tif_sizeproc; /* filesize method */
|
||||
/* post-decoding support */
|
||||
TIFFPostMethod tif_postdecode; /* post decoding routine */
|
||||
/* tag support */
|
||||
TIFFField** tif_fields; /* sorted table of registered tags */
|
||||
size_t tif_nfields; /* # entries in registered tag table */
|
||||
const TIFFField* tif_foundfield; /* cached pointer to already found tag */
|
||||
TIFFTagMethods tif_tagmethods; /* tag get/set/print routines */
|
||||
TIFFClientInfoLink* tif_clientinfo; /* extra client information. */
|
||||
/* Backward compatibility stuff. We need these two fields for
|
||||
* setting up an old tag extension scheme. */
|
||||
TIFFFieldArray* tif_fieldscompat;
|
||||
size_t tif_nfieldscompat;
|
||||
};
|
||||
|
||||
#define isPseudoTag(t) (t > 0xffff) /* is tag value normal or pseudo */
|
||||
@@ -210,40 +216,43 @@ struct tiff {
|
||||
#define isFillOrder(tif, o) (((tif)->tif_flags & (o)) != 0)
|
||||
#define isUpSampled(tif) (((tif)->tif_flags & TIFF_UPSAMPLED) != 0)
|
||||
#define TIFFReadFile(tif, buf, size) \
|
||||
((*(tif)->tif_readproc)((tif)->tif_clientdata,(buf),(size)))
|
||||
((*(tif)->tif_readproc)((tif)->tif_clientdata,(buf),(size)))
|
||||
#define TIFFWriteFile(tif, buf, size) \
|
||||
((*(tif)->tif_writeproc)((tif)->tif_clientdata,(buf),(size)))
|
||||
((*(tif)->tif_writeproc)((tif)->tif_clientdata,(buf),(size)))
|
||||
#define TIFFSeekFile(tif, off, whence) \
|
||||
((*(tif)->tif_seekproc)((tif)->tif_clientdata,(off),(whence)))
|
||||
((*(tif)->tif_seekproc)((tif)->tif_clientdata,(off),(whence)))
|
||||
#define TIFFCloseFile(tif) \
|
||||
((*(tif)->tif_closeproc)((tif)->tif_clientdata))
|
||||
((*(tif)->tif_closeproc)((tif)->tif_clientdata))
|
||||
#define TIFFGetFileSize(tif) \
|
||||
((*(tif)->tif_sizeproc)((tif)->tif_clientdata))
|
||||
((*(tif)->tif_sizeproc)((tif)->tif_clientdata))
|
||||
#define TIFFMapFileContents(tif, paddr, psize) \
|
||||
((*(tif)->tif_mapproc)((tif)->tif_clientdata,(paddr),(psize)))
|
||||
((*(tif)->tif_mapproc)((tif)->tif_clientdata,(paddr),(psize)))
|
||||
#define TIFFUnmapFileContents(tif, addr, size) \
|
||||
((*(tif)->tif_unmapproc)((tif)->tif_clientdata,(addr),(size)))
|
||||
((*(tif)->tif_unmapproc)((tif)->tif_clientdata,(addr),(size)))
|
||||
|
||||
/*
|
||||
* Default Read/Seek/Write definitions.
|
||||
*/
|
||||
#ifndef ReadOK
|
||||
#define ReadOK(tif, buf, size) \
|
||||
(TIFFReadFile((tif),(buf),(size))==(size))
|
||||
(TIFFReadFile((tif),(buf),(size))==(size))
|
||||
#endif
|
||||
#ifndef SeekOK
|
||||
#define SeekOK(tif, off) \
|
||||
(TIFFSeekFile((tif),(off),SEEK_SET)==(off))
|
||||
#define SeekOK(tif, off) _TIFFSeekOK(tif, off)
|
||||
#endif
|
||||
#ifndef WriteOK
|
||||
#define WriteOK(tif, buf, size) \
|
||||
(TIFFWriteFile((tif),(buf),(size))==(size))
|
||||
(TIFFWriteFile((tif),(buf),(size))==(size))
|
||||
#endif
|
||||
|
||||
/* NB: the uint32 casts are to silence certain ANSI-C compilers */
|
||||
#define TIFFhowmany_32(x, y) (((uint32)x < (0xffffffff - (uint32)(y-1))) ? \
|
||||
((((uint32)(x))+(((uint32)(y))-1))/((uint32)(y))) : \
|
||||
0U)
|
||||
((((uint32)(x))+(((uint32)(y))-1))/((uint32)(y))) : \
|
||||
0U)
|
||||
/* Variant of TIFFhowmany_32() that doesn't return 0 if x close to MAXUINT. */
|
||||
/* Caution: TIFFhowmany_32_maxuint_compat(x,y)*y might overflow */
|
||||
#define TIFFhowmany_32_maxuint_compat(x, y) \
|
||||
(((uint32)(x) / (uint32)(y)) + ((((uint32)(x) % (uint32)(y)) != 0) ? 1 : 0))
|
||||
#define TIFFhowmany8_32(x) (((x)&0x07)?((uint32)(x)>>3)+1:(uint32)(x)>>3)
|
||||
#define TIFFroundup_32(x, y) (TIFFhowmany_32(x,y)*(y))
|
||||
#define TIFFhowmany_64(x, y) ((((uint64)(x))+(((uint64)(y))-1))/((uint64)(y)))
|
||||
@@ -258,6 +267,60 @@ 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 __clang_major__ >= 4 || (__clang_major__ == 3 && __clang_minor__ >= 8)
|
||||
#define TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW __attribute__((no_sanitize("unsigned-integer-overflow")))
|
||||
#else
|
||||
#define TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -308,6 +371,20 @@ extern void* _TIFFCheckRealloc(TIFF*, void*, tmsize_t, tmsize_t, const char*);
|
||||
extern double _TIFFUInt64ToDouble(uint64);
|
||||
extern float _TIFFUInt64ToFloat(uint64);
|
||||
|
||||
extern tmsize_t
|
||||
_TIFFReadEncodedStripAndAllocBuffer(TIFF* tif, uint32 strip,
|
||||
void **buf, tmsize_t bufsizetoalloc,
|
||||
tmsize_t size_to_read);
|
||||
extern tmsize_t
|
||||
_TIFFReadEncodedTileAndAllocBuffer(TIFF* tif, uint32 tile,
|
||||
void **buf, tmsize_t bufsizetoalloc,
|
||||
tmsize_t size_to_read);
|
||||
extern tmsize_t
|
||||
_TIFFReadTileAndAllocBuffer(TIFF* tif,
|
||||
void **buf, tmsize_t bufsizetoalloc,
|
||||
uint32 x, uint32 y, uint32 z, uint16 s);
|
||||
extern int _TIFFSeekOK(TIFF* tif, toff_t off);
|
||||
|
||||
extern int TIFFInitDumpMode(TIFF*, int);
|
||||
#ifdef PACKBITS_SUPPORT
|
||||
extern int TIFFInitPackBits(TIFF*, int);
|
||||
@@ -330,6 +407,7 @@ extern int TIFFInitOJPEG(TIFF*, int);
|
||||
#endif
|
||||
#ifdef JPEG_SUPPORT
|
||||
extern int TIFFInitJPEG(TIFF*, int);
|
||||
extern int TIFFJPEGIsFullStripRequired(TIFF*);
|
||||
#endif
|
||||
#ifdef JBIG_SUPPORT
|
||||
extern int TIFFInitJBIG(TIFF*, int);
|
||||
|
||||
Vendored
+2
-2
@@ -1,4 +1,4 @@
|
||||
#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.0.2\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
|
||||
#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.0.9\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 20120615
|
||||
#define TIFFLIB_VERSION 20171118
|
||||
|
||||
Vendored
+166
-166
@@ -3,173 +3,173 @@
|
||||
#define UV_NDIVS 16289
|
||||
#define UV_VSTART (float)0.016940
|
||||
#define UV_NVS 163
|
||||
static struct {
|
||||
float ustart;
|
||||
short nus, ncum;
|
||||
static const struct {
|
||||
float ustart;
|
||||
short nus, ncum;
|
||||
} uv_row[UV_NVS] = {
|
||||
{ (float)0.247663, 4, 0 },
|
||||
{ (float)0.243779, 6, 4 },
|
||||
{ (float)0.241684, 7, 10 },
|
||||
{ (float)0.237874, 9, 17 },
|
||||
{ (float)0.235906, 10, 26 },
|
||||
{ (float)0.232153, 12, 36 },
|
||||
{ (float)0.228352, 14, 48 },
|
||||
{ (float)0.226259, 15, 62 },
|
||||
{ (float)0.222371, 17, 77 },
|
||||
{ (float)0.220410, 18, 94 },
|
||||
{ (float)0.214710, 21, 112 },
|
||||
{ (float)0.212714, 22, 133 },
|
||||
{ (float)0.210721, 23, 155 },
|
||||
{ (float)0.204976, 26, 178 },
|
||||
{ (float)0.202986, 27, 204 },
|
||||
{ (float)0.199245, 29, 231 },
|
||||
{ (float)0.195525, 31, 260 },
|
||||
{ (float)0.193560, 32, 291 },
|
||||
{ (float)0.189878, 34, 323 },
|
||||
{ (float)0.186216, 36, 357 },
|
||||
{ (float)0.186216, 36, 393 },
|
||||
{ (float)0.182592, 38, 429 },
|
||||
{ (float)0.179003, 40, 467 },
|
||||
{ (float)0.175466, 42, 507 },
|
||||
{ (float)0.172001, 44, 549 },
|
||||
{ (float)0.172001, 44, 593 },
|
||||
{ (float)0.168612, 46, 637 },
|
||||
{ (float)0.168612, 46, 683 },
|
||||
{ (float)0.163575, 49, 729 },
|
||||
{ (float)0.158642, 52, 778 },
|
||||
{ (float)0.158642, 52, 830 },
|
||||
{ (float)0.158642, 52, 882 },
|
||||
{ (float)0.153815, 55, 934 },
|
||||
{ (float)0.153815, 55, 989 },
|
||||
{ (float)0.149097, 58, 1044 },
|
||||
{ (float)0.149097, 58, 1102 },
|
||||
{ (float)0.142746, 62, 1160 },
|
||||
{ (float)0.142746, 62, 1222 },
|
||||
{ (float)0.142746, 62, 1284 },
|
||||
{ (float)0.138270, 65, 1346 },
|
||||
{ (float)0.138270, 65, 1411 },
|
||||
{ (float)0.138270, 65, 1476 },
|
||||
{ (float)0.132166, 69, 1541 },
|
||||
{ (float)0.132166, 69, 1610 },
|
||||
{ (float)0.126204, 73, 1679 },
|
||||
{ (float)0.126204, 73, 1752 },
|
||||
{ (float)0.126204, 73, 1825 },
|
||||
{ (float)0.120381, 77, 1898 },
|
||||
{ (float)0.120381, 77, 1975 },
|
||||
{ (float)0.120381, 77, 2052 },
|
||||
{ (float)0.120381, 77, 2129 },
|
||||
{ (float)0.112962, 82, 2206 },
|
||||
{ (float)0.112962, 82, 2288 },
|
||||
{ (float)0.112962, 82, 2370 },
|
||||
{ (float)0.107450, 86, 2452 },
|
||||
{ (float)0.107450, 86, 2538 },
|
||||
{ (float)0.107450, 86, 2624 },
|
||||
{ (float)0.107450, 86, 2710 },
|
||||
{ (float)0.100343, 91, 2796 },
|
||||
{ (float)0.100343, 91, 2887 },
|
||||
{ (float)0.100343, 91, 2978 },
|
||||
{ (float)0.095126, 95, 3069 },
|
||||
{ (float)0.095126, 95, 3164 },
|
||||
{ (float)0.095126, 95, 3259 },
|
||||
{ (float)0.095126, 95, 3354 },
|
||||
{ (float)0.088276, 100, 3449 },
|
||||
{ (float)0.088276, 100, 3549 },
|
||||
{ (float)0.088276, 100, 3649 },
|
||||
{ (float)0.088276, 100, 3749 },
|
||||
{ (float)0.081523, 105, 3849 },
|
||||
{ (float)0.081523, 105, 3954 },
|
||||
{ (float)0.081523, 105, 4059 },
|
||||
{ (float)0.081523, 105, 4164 },
|
||||
{ (float)0.074861, 110, 4269 },
|
||||
{ (float)0.074861, 110, 4379 },
|
||||
{ (float)0.074861, 110, 4489 },
|
||||
{ (float)0.074861, 110, 4599 },
|
||||
{ (float)0.068290, 115, 4709 },
|
||||
{ (float)0.068290, 115, 4824 },
|
||||
{ (float)0.068290, 115, 4939 },
|
||||
{ (float)0.068290, 115, 5054 },
|
||||
{ (float)0.063573, 119, 5169 },
|
||||
{ (float)0.063573, 119, 5288 },
|
||||
{ (float)0.063573, 119, 5407 },
|
||||
{ (float)0.063573, 119, 5526 },
|
||||
{ (float)0.057219, 124, 5645 },
|
||||
{ (float)0.057219, 124, 5769 },
|
||||
{ (float)0.057219, 124, 5893 },
|
||||
{ (float)0.057219, 124, 6017 },
|
||||
{ (float)0.050985, 129, 6141 },
|
||||
{ (float)0.050985, 129, 6270 },
|
||||
{ (float)0.050985, 129, 6399 },
|
||||
{ (float)0.050985, 129, 6528 },
|
||||
{ (float)0.050985, 129, 6657 },
|
||||
{ (float)0.044859, 134, 6786 },
|
||||
{ (float)0.044859, 134, 6920 },
|
||||
{ (float)0.044859, 134, 7054 },
|
||||
{ (float)0.044859, 134, 7188 },
|
||||
{ (float)0.040571, 138, 7322 },
|
||||
{ (float)0.040571, 138, 7460 },
|
||||
{ (float)0.040571, 138, 7598 },
|
||||
{ (float)0.040571, 138, 7736 },
|
||||
{ (float)0.036339, 142, 7874 },
|
||||
{ (float)0.036339, 142, 8016 },
|
||||
{ (float)0.036339, 142, 8158 },
|
||||
{ (float)0.036339, 142, 8300 },
|
||||
{ (float)0.032139, 146, 8442 },
|
||||
{ (float)0.032139, 146, 8588 },
|
||||
{ (float)0.032139, 146, 8734 },
|
||||
{ (float)0.032139, 146, 8880 },
|
||||
{ (float)0.027947, 150, 9026 },
|
||||
{ (float)0.027947, 150, 9176 },
|
||||
{ (float)0.027947, 150, 9326 },
|
||||
{ (float)0.023739, 154, 9476 },
|
||||
{ (float)0.023739, 154, 9630 },
|
||||
{ (float)0.023739, 154, 9784 },
|
||||
{ (float)0.023739, 154, 9938 },
|
||||
{ (float)0.019504, 158, 10092 },
|
||||
{ (float)0.019504, 158, 10250 },
|
||||
{ (float)0.019504, 158, 10408 },
|
||||
{ (float)0.016976, 161, 10566 },
|
||||
{ (float)0.016976, 161, 10727 },
|
||||
{ (float)0.016976, 161, 10888 },
|
||||
{ (float)0.016976, 161, 11049 },
|
||||
{ (float)0.012639, 165, 11210 },
|
||||
{ (float)0.012639, 165, 11375 },
|
||||
{ (float)0.012639, 165, 11540 },
|
||||
{ (float)0.009991, 168, 11705 },
|
||||
{ (float)0.009991, 168, 11873 },
|
||||
{ (float)0.009991, 168, 12041 },
|
||||
{ (float)0.009016, 170, 12209 },
|
||||
{ (float)0.009016, 170, 12379 },
|
||||
{ (float)0.009016, 170, 12549 },
|
||||
{ (float)0.006217, 173, 12719 },
|
||||
{ (float)0.006217, 173, 12892 },
|
||||
{ (float)0.005097, 175, 13065 },
|
||||
{ (float)0.005097, 175, 13240 },
|
||||
{ (float)0.005097, 175, 13415 },
|
||||
{ (float)0.003909, 177, 13590 },
|
||||
{ (float)0.003909, 177, 13767 },
|
||||
{ (float)0.002340, 177, 13944 },
|
||||
{ (float)0.002389, 170, 14121 },
|
||||
{ (float)0.001068, 164, 14291 },
|
||||
{ (float)0.001653, 157, 14455 },
|
||||
{ (float)0.000717, 150, 14612 },
|
||||
{ (float)0.001614, 143, 14762 },
|
||||
{ (float)0.000270, 136, 14905 },
|
||||
{ (float)0.000484, 129, 15041 },
|
||||
{ (float)0.001103, 123, 15170 },
|
||||
{ (float)0.001242, 115, 15293 },
|
||||
{ (float)0.001188, 109, 15408 },
|
||||
{ (float)0.001011, 103, 15517 },
|
||||
{ (float)0.000709, 97, 15620 },
|
||||
{ (float)0.000301, 89, 15717 },
|
||||
{ (float)0.002416, 82, 15806 },
|
||||
{ (float)0.003251, 76, 15888 },
|
||||
{ (float)0.003246, 69, 15964 },
|
||||
{ (float)0.004141, 62, 16033 },
|
||||
{ (float)0.005963, 55, 16095 },
|
||||
{ (float)0.008839, 47, 16150 },
|
||||
{ (float)0.010490, 40, 16197 },
|
||||
{ (float)0.016994, 31, 16237 },
|
||||
{ (float)0.023659, 21, 16268 },
|
||||
{ (float)0.247663, 4, 0 },
|
||||
{ (float)0.243779, 6, 4 },
|
||||
{ (float)0.241684, 7, 10 },
|
||||
{ (float)0.237874, 9, 17 },
|
||||
{ (float)0.235906, 10, 26 },
|
||||
{ (float)0.232153, 12, 36 },
|
||||
{ (float)0.228352, 14, 48 },
|
||||
{ (float)0.226259, 15, 62 },
|
||||
{ (float)0.222371, 17, 77 },
|
||||
{ (float)0.220410, 18, 94 },
|
||||
{ (float)0.214710, 21, 112 },
|
||||
{ (float)0.212714, 22, 133 },
|
||||
{ (float)0.210721, 23, 155 },
|
||||
{ (float)0.204976, 26, 178 },
|
||||
{ (float)0.202986, 27, 204 },
|
||||
{ (float)0.199245, 29, 231 },
|
||||
{ (float)0.195525, 31, 260 },
|
||||
{ (float)0.193560, 32, 291 },
|
||||
{ (float)0.189878, 34, 323 },
|
||||
{ (float)0.186216, 36, 357 },
|
||||
{ (float)0.186216, 36, 393 },
|
||||
{ (float)0.182592, 38, 429 },
|
||||
{ (float)0.179003, 40, 467 },
|
||||
{ (float)0.175466, 42, 507 },
|
||||
{ (float)0.172001, 44, 549 },
|
||||
{ (float)0.172001, 44, 593 },
|
||||
{ (float)0.168612, 46, 637 },
|
||||
{ (float)0.168612, 46, 683 },
|
||||
{ (float)0.163575, 49, 729 },
|
||||
{ (float)0.158642, 52, 778 },
|
||||
{ (float)0.158642, 52, 830 },
|
||||
{ (float)0.158642, 52, 882 },
|
||||
{ (float)0.153815, 55, 934 },
|
||||
{ (float)0.153815, 55, 989 },
|
||||
{ (float)0.149097, 58, 1044 },
|
||||
{ (float)0.149097, 58, 1102 },
|
||||
{ (float)0.142746, 62, 1160 },
|
||||
{ (float)0.142746, 62, 1222 },
|
||||
{ (float)0.142746, 62, 1284 },
|
||||
{ (float)0.138270, 65, 1346 },
|
||||
{ (float)0.138270, 65, 1411 },
|
||||
{ (float)0.138270, 65, 1476 },
|
||||
{ (float)0.132166, 69, 1541 },
|
||||
{ (float)0.132166, 69, 1610 },
|
||||
{ (float)0.126204, 73, 1679 },
|
||||
{ (float)0.126204, 73, 1752 },
|
||||
{ (float)0.126204, 73, 1825 },
|
||||
{ (float)0.120381, 77, 1898 },
|
||||
{ (float)0.120381, 77, 1975 },
|
||||
{ (float)0.120381, 77, 2052 },
|
||||
{ (float)0.120381, 77, 2129 },
|
||||
{ (float)0.112962, 82, 2206 },
|
||||
{ (float)0.112962, 82, 2288 },
|
||||
{ (float)0.112962, 82, 2370 },
|
||||
{ (float)0.107450, 86, 2452 },
|
||||
{ (float)0.107450, 86, 2538 },
|
||||
{ (float)0.107450, 86, 2624 },
|
||||
{ (float)0.107450, 86, 2710 },
|
||||
{ (float)0.100343, 91, 2796 },
|
||||
{ (float)0.100343, 91, 2887 },
|
||||
{ (float)0.100343, 91, 2978 },
|
||||
{ (float)0.095126, 95, 3069 },
|
||||
{ (float)0.095126, 95, 3164 },
|
||||
{ (float)0.095126, 95, 3259 },
|
||||
{ (float)0.095126, 95, 3354 },
|
||||
{ (float)0.088276, 100, 3449 },
|
||||
{ (float)0.088276, 100, 3549 },
|
||||
{ (float)0.088276, 100, 3649 },
|
||||
{ (float)0.088276, 100, 3749 },
|
||||
{ (float)0.081523, 105, 3849 },
|
||||
{ (float)0.081523, 105, 3954 },
|
||||
{ (float)0.081523, 105, 4059 },
|
||||
{ (float)0.081523, 105, 4164 },
|
||||
{ (float)0.074861, 110, 4269 },
|
||||
{ (float)0.074861, 110, 4379 },
|
||||
{ (float)0.074861, 110, 4489 },
|
||||
{ (float)0.074861, 110, 4599 },
|
||||
{ (float)0.068290, 115, 4709 },
|
||||
{ (float)0.068290, 115, 4824 },
|
||||
{ (float)0.068290, 115, 4939 },
|
||||
{ (float)0.068290, 115, 5054 },
|
||||
{ (float)0.063573, 119, 5169 },
|
||||
{ (float)0.063573, 119, 5288 },
|
||||
{ (float)0.063573, 119, 5407 },
|
||||
{ (float)0.063573, 119, 5526 },
|
||||
{ (float)0.057219, 124, 5645 },
|
||||
{ (float)0.057219, 124, 5769 },
|
||||
{ (float)0.057219, 124, 5893 },
|
||||
{ (float)0.057219, 124, 6017 },
|
||||
{ (float)0.050985, 129, 6141 },
|
||||
{ (float)0.050985, 129, 6270 },
|
||||
{ (float)0.050985, 129, 6399 },
|
||||
{ (float)0.050985, 129, 6528 },
|
||||
{ (float)0.050985, 129, 6657 },
|
||||
{ (float)0.044859, 134, 6786 },
|
||||
{ (float)0.044859, 134, 6920 },
|
||||
{ (float)0.044859, 134, 7054 },
|
||||
{ (float)0.044859, 134, 7188 },
|
||||
{ (float)0.040571, 138, 7322 },
|
||||
{ (float)0.040571, 138, 7460 },
|
||||
{ (float)0.040571, 138, 7598 },
|
||||
{ (float)0.040571, 138, 7736 },
|
||||
{ (float)0.036339, 142, 7874 },
|
||||
{ (float)0.036339, 142, 8016 },
|
||||
{ (float)0.036339, 142, 8158 },
|
||||
{ (float)0.036339, 142, 8300 },
|
||||
{ (float)0.032139, 146, 8442 },
|
||||
{ (float)0.032139, 146, 8588 },
|
||||
{ (float)0.032139, 146, 8734 },
|
||||
{ (float)0.032139, 146, 8880 },
|
||||
{ (float)0.027947, 150, 9026 },
|
||||
{ (float)0.027947, 150, 9176 },
|
||||
{ (float)0.027947, 150, 9326 },
|
||||
{ (float)0.023739, 154, 9476 },
|
||||
{ (float)0.023739, 154, 9630 },
|
||||
{ (float)0.023739, 154, 9784 },
|
||||
{ (float)0.023739, 154, 9938 },
|
||||
{ (float)0.019504, 158, 10092 },
|
||||
{ (float)0.019504, 158, 10250 },
|
||||
{ (float)0.019504, 158, 10408 },
|
||||
{ (float)0.016976, 161, 10566 },
|
||||
{ (float)0.016976, 161, 10727 },
|
||||
{ (float)0.016976, 161, 10888 },
|
||||
{ (float)0.016976, 161, 11049 },
|
||||
{ (float)0.012639, 165, 11210 },
|
||||
{ (float)0.012639, 165, 11375 },
|
||||
{ (float)0.012639, 165, 11540 },
|
||||
{ (float)0.009991, 168, 11705 },
|
||||
{ (float)0.009991, 168, 11873 },
|
||||
{ (float)0.009991, 168, 12041 },
|
||||
{ (float)0.009016, 170, 12209 },
|
||||
{ (float)0.009016, 170, 12379 },
|
||||
{ (float)0.009016, 170, 12549 },
|
||||
{ (float)0.006217, 173, 12719 },
|
||||
{ (float)0.006217, 173, 12892 },
|
||||
{ (float)0.005097, 175, 13065 },
|
||||
{ (float)0.005097, 175, 13240 },
|
||||
{ (float)0.005097, 175, 13415 },
|
||||
{ (float)0.003909, 177, 13590 },
|
||||
{ (float)0.003909, 177, 13767 },
|
||||
{ (float)0.002340, 177, 13944 },
|
||||
{ (float)0.002389, 170, 14121 },
|
||||
{ (float)0.001068, 164, 14291 },
|
||||
{ (float)0.001653, 157, 14455 },
|
||||
{ (float)0.000717, 150, 14612 },
|
||||
{ (float)0.001614, 143, 14762 },
|
||||
{ (float)0.000270, 136, 14905 },
|
||||
{ (float)0.000484, 129, 15041 },
|
||||
{ (float)0.001103, 123, 15170 },
|
||||
{ (float)0.001242, 115, 15293 },
|
||||
{ (float)0.001188, 109, 15408 },
|
||||
{ (float)0.001011, 103, 15517 },
|
||||
{ (float)0.000709, 97, 15620 },
|
||||
{ (float)0.000301, 89, 15717 },
|
||||
{ (float)0.002416, 82, 15806 },
|
||||
{ (float)0.003251, 76, 15888 },
|
||||
{ (float)0.003246, 69, 15964 },
|
||||
{ (float)0.004141, 62, 16033 },
|
||||
{ (float)0.005963, 55, 16095 },
|
||||
{ (float)0.008839, 47, 16150 },
|
||||
{ (float)0.010490, 40, 16197 },
|
||||
{ (float)0.016994, 31, 16237 },
|
||||
{ (float)0.023659, 21, 16268 },
|
||||
};
|
||||
/*
|
||||
* Local Variables:
|
||||
|
||||
@@ -26,7 +26,28 @@ if(NOT ZLIB_FOUND)
|
||||
ocv_parse_header2(ZLIB "${${ZLIB_LIBRARY}_SOURCE_DIR}/zlib.h" ZLIB_VERSION)
|
||||
endif()
|
||||
|
||||
# --- libtiff (optional, should be searched after zlib) ---
|
||||
# --- libjpeg (optional) ---
|
||||
if(WITH_JPEG)
|
||||
if(BUILD_JPEG)
|
||||
ocv_clear_vars(JPEG_FOUND)
|
||||
else()
|
||||
include(FindJPEG)
|
||||
endif()
|
||||
|
||||
if(NOT JPEG_FOUND)
|
||||
ocv_clear_vars(JPEG_LIBRARY JPEG_LIBRARIES JPEG_INCLUDE_DIR)
|
||||
|
||||
set(JPEG_LIBRARY libjpeg)
|
||||
set(JPEG_LIBRARIES ${JPEG_LIBRARY})
|
||||
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libjpeg")
|
||||
set(JPEG_INCLUDE_DIR "${${JPEG_LIBRARY}_SOURCE_DIR}")
|
||||
endif()
|
||||
|
||||
ocv_parse_header("${JPEG_INCLUDE_DIR}/jpeglib.h" JPEG_VERSION_LINES JPEG_LIB_VERSION)
|
||||
set(HAVE_JPEG YES)
|
||||
endif()
|
||||
|
||||
# --- libtiff (optional, should be searched after zlib and libjpeg) ---
|
||||
if(WITH_TIFF)
|
||||
if(BUILD_TIFF)
|
||||
ocv_clear_vars(TIFF_FOUND)
|
||||
@@ -68,27 +89,6 @@ if(WITH_TIFF)
|
||||
set(HAVE_TIFF YES)
|
||||
endif()
|
||||
|
||||
# --- libjpeg (optional) ---
|
||||
if(WITH_JPEG)
|
||||
if(BUILD_JPEG)
|
||||
ocv_clear_vars(JPEG_FOUND)
|
||||
else()
|
||||
include(FindJPEG)
|
||||
endif()
|
||||
|
||||
if(NOT JPEG_FOUND)
|
||||
ocv_clear_vars(JPEG_LIBRARY JPEG_LIBRARIES JPEG_INCLUDE_DIR)
|
||||
|
||||
set(JPEG_LIBRARY libjpeg)
|
||||
set(JPEG_LIBRARIES ${JPEG_LIBRARY})
|
||||
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/libjpeg")
|
||||
set(JPEG_INCLUDE_DIR "${${JPEG_LIBRARY}_SOURCE_DIR}")
|
||||
endif()
|
||||
|
||||
ocv_parse_header("${JPEG_INCLUDE_DIR}/jpeglib.h" JPEG_VERSION_LINES JPEG_LIB_VERSION)
|
||||
set(HAVE_JPEG YES)
|
||||
endif()
|
||||
|
||||
# --- libwebp (optional) ---
|
||||
|
||||
if(WITH_WEBP)
|
||||
|
||||
Reference in New Issue
Block a user