plugin/tif updated to version 1.43 (thanks tojocky)

git-svn-id: svn://ultimatepp.org/upp/trunk@3916 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2011-09-26 20:30:40 +00:00
parent 75b9f3bcda
commit 58593f591c
73 changed files with 7744 additions and 5168 deletions

View file

@ -1,4 +1,4 @@
description "Image designer";
description "Image designer\377";
uses
CtrlLib,

View file

@ -1,7 +1,7 @@
#ifndef _plugin_tif_icpp_init_stub
#define _plugin_tif_icpp_init_stub
#include "plugin\jpg/init"
#define BLITZ_INDEX__ F5D71619E03D4F53F261D43793AA7FBC0
#define BLITZ_INDEX__ F0C7CE7C605666463896D90595BBCCCB8
#include "tifreg.icpp"
#undef BLITZ_INDEX__
#endif

View file

@ -25,28 +25,38 @@
LIBPORT = $(top_builddir)/port/libport.la
LIBTIFF = $(top_builddir)/libtiff/libtiff.la
libtiffincludedir = $(includedir)
EXTRA_DIST = Makefile.vc SConstruct tif_config.h.vc tiffconf.h.vc libtiff.def \
EXTRA_DIST = Makefile.vc \
SConstruct \
tif_config.h-vms \
tif_config.vc.h \
tif_config.wince.h \
tiffconf.vc.h \
tiffconf.wince.h \
libtiff.def \
$(EXTRA_SRCS)
HDRS = \
libtiffinclude_HEADERS = \
tiff.h \
tiffconf.h \
tiffio.h \
tiffvers.h
if HAVE_CXX
HDRS += tiffio.hxx
libtiffinclude_HEADERS += tiffio.hxx
endif
EXTRA_HDRS = \
noinst_HEADERS = \
t4.h \
tif_dir.h \
tif_predict.h \
tiffiop.h \
uvcode.h
SRCS = \
nodist_libtiffinclude_HEADERS = \
tiffconf.h
libtiff_la_SOURCES = \
tif_aux.c \
tif_close.c \
tif_codec.c \
@ -63,6 +73,7 @@ SRCS = \
tif_fax3sm.c \
tif_flush.c \
tif_getimage.c \
tif_jbig.c \
tif_jpeg.c \
tif_luv.c \
tif_lzw.c \
@ -84,7 +95,7 @@ SRCS = \
tif_write.c \
tif_zip.c
SRCSXX = \
libtiffxx_la_SOURCES = \
tif_stream.cxx
EXTRA_SRCS = \
@ -96,16 +107,11 @@ EXTRA_SRCS = \
tif_win3.c \
tif_win32.c
libtiffincludedir = $(includedir)
libtiffinclude_HEADERS = $(HDRS)
noinst_HEADERS = $(EXTRA_HDRS)
lib_LTLIBRARIES = libtiff.la
if HAVE_CXX
lib_LTLIBRARIES += libtiffxx.la
endif
libtiff_la_SOURCES = $(SRCS)
libtiff_la_LDFLAGS = \
-no-undefined \
-version-number $(LIBTIFF_VERSION_INFO)
@ -114,7 +120,6 @@ libtiff_la_LDFLAGS += $(LIBDIR)
endif
libtiff_la_LIBADD = $(LIBPORT)
libtiffxx_la_SOURCES = $(SRCSXX)
libtiffxx_la_LDFLAGS = \
-no-undefined \
-version-number $(LIBTIFF_VERSION_INFO)

View file

@ -1,8 +1,9 @@
# Makefile.in generated by automake 1.9.6 from Makefile.am.
# Makefile.in generated by automake 1.11.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 Free Software Foundation, Inc.
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
# Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@ -41,15 +42,12 @@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
@ -63,7 +61,6 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
@HAVE_CXX_TRUE@am__append_1 = tiffio.hxx
@HAVE_CXX_TRUE@am__append_2 = libtiffxx.la
@HAVE_RPATH_TRUE@am__append_3 = $(LIBDIR)
@ -77,78 +74,122 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/acinclude.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/configure.ac
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
CONFIG_HEADER = tif_config.h tiffconf.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__installdirs = "$(DESTDIR)$(libdir)" \
"$(DESTDIR)$(libtiffincludedir)" \
"$(DESTDIR)$(libtiffincludedir)"
libLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(lib_LTLIBRARIES)
am__DEPENDENCIES_1 = $(top_builddir)/port/libport.la
libtiff_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
am__objects_1 = tif_aux.lo tif_close.lo tif_codec.lo tif_color.lo \
tif_compress.lo tif_dir.lo tif_dirinfo.lo tif_dirread.lo \
tif_dirwrite.lo tif_dumpmode.lo tif_error.lo tif_extension.lo \
tif_fax3.lo tif_fax3sm.lo tif_flush.lo tif_getimage.lo \
tif_jpeg.lo tif_luv.lo tif_lzw.lo tif_next.lo tif_ojpeg.lo \
tif_open.lo tif_packbits.lo tif_pixarlog.lo tif_predict.lo \
tif_print.lo tif_read.lo tif_strip.lo tif_swab.lo \
tif_thunder.lo tif_tile.lo tif_unix.lo tif_version.lo \
tif_warning.lo tif_write.lo tif_zip.lo
am_libtiff_la_OBJECTS = $(am__objects_1)
libtiff_la_DEPENDENCIES = $(LIBPORT)
am_libtiff_la_OBJECTS = tif_aux.lo tif_close.lo tif_codec.lo \
tif_color.lo tif_compress.lo tif_dir.lo tif_dirinfo.lo \
tif_dirread.lo tif_dirwrite.lo tif_dumpmode.lo tif_error.lo \
tif_extension.lo tif_fax3.lo tif_fax3sm.lo tif_flush.lo \
tif_getimage.lo tif_jbig.lo tif_jpeg.lo tif_luv.lo tif_lzw.lo \
tif_next.lo tif_ojpeg.lo tif_open.lo tif_packbits.lo \
tif_pixarlog.lo tif_predict.lo tif_print.lo tif_read.lo \
tif_strip.lo tif_swab.lo tif_thunder.lo tif_tile.lo \
tif_unix.lo tif_version.lo tif_warning.lo tif_write.lo \
tif_zip.lo
libtiff_la_OBJECTS = $(am_libtiff_la_OBJECTS)
am__DEPENDENCIES_2 = $(top_builddir)/libtiff/libtiff.la
am__objects_2 = tif_stream.lo
am_libtiffxx_la_OBJECTS = $(am__objects_2)
AM_V_lt = $(am__v_lt_$(V))
am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
am__v_lt_0 = --silent
libtiff_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(libtiff_la_LDFLAGS) $(LDFLAGS) -o $@
am_libtiffxx_la_OBJECTS = tif_stream.lo
libtiffxx_la_OBJECTS = $(am_libtiffxx_la_OBJECTS)
libtiffxx_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
$(CXXFLAGS) $(libtiffxx_la_LDFLAGS) $(LDFLAGS) -o $@
@HAVE_CXX_TRUE@am_libtiffxx_la_rpath = -rpath $(libdir)
PROGRAMS = $(noinst_PROGRAMS)
am_mkg3states_OBJECTS = mkg3states.$(OBJEXT)
mkg3states_OBJECTS = $(am_mkg3states_OBJECTS)
mkg3states_DEPENDENCIES = $(am__DEPENDENCIES_1)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I. -I.
mkg3states_DEPENDENCIES = $(LIBPORT)
DEFAULT_INCLUDES = -I.@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/config/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_$(V))
am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
am__v_CC_0 = @echo " CC " $@;
AM_V_at = $(am__v_at_$(V))
am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
am__v_at_0 = @
CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_$(V))
am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
am__v_CCLD_0 = @echo " CCLD " $@;
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) \
LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CXXFLAGS) $(CXXFLAGS)
AM_V_CXX = $(am__v_CXX_$(V))
am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
am__v_CXX_0 = @echo " CXX " $@;
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) \
CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CXXLD = $(am__v_CXXLD_$(V))
am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
am__v_CXXLD_0 = @echo " CXXLD " $@;
AM_V_GEN = $(am__v_GEN_$(V))
am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
am__v_GEN_0 = @echo " GEN " $@;
SOURCES = $(libtiff_la_SOURCES) $(libtiffxx_la_SOURCES) \
$(mkg3states_SOURCES)
DIST_SOURCES = $(libtiff_la_SOURCES) $(libtiffxx_la_SOURCES) \
$(mkg3states_SOURCES)
am__libtiffinclude_HEADERS_DIST = tiff.h tiffconf.h tiffio.h \
tiffvers.h tiffio.hxx
libtiffincludeHEADERS_INSTALL = $(INSTALL_HEADER)
HEADERS = $(libtiffinclude_HEADERS) $(noinst_HEADERS)
am__libtiffinclude_HEADERS_DIST = tiff.h tiffio.h tiffvers.h \
tiffio.hxx
HEADERS = $(libtiffinclude_HEADERS) $(nodist_libtiffinclude_HEADERS) \
$(noinst_HEADERS)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
@ -168,6 +209,7 @@ CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
@ -182,12 +224,7 @@ GLU_LIBS = @GLU_LIBS@
GL_CFLAGS = @GL_CFLAGS@
GL_LIBS = @GL_LIBS@
GREP = @GREP@
HAVE_CXX_FALSE = @HAVE_CXX_FALSE@
HAVE_CXX_TRUE = @HAVE_CXX_TRUE@
HAVE_OPENGL_FALSE = @HAVE_OPENGL_FALSE@
HAVE_OPENGL_TRUE = @HAVE_OPENGL_TRUE@
HAVE_RPATH_FALSE = @HAVE_RPATH_FALSE@
HAVE_RPATH_TRUE = @HAVE_RPATH_TRUE@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
@ -206,20 +243,25 @@ LIBTIFF_RELEASE_DATE = @LIBTIFF_RELEASE_DATE@
LIBTIFF_VERSION = @LIBTIFF_VERSION@
LIBTIFF_VERSION_INFO = @LIBTIFF_VERSION_INFO@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PTHREAD_CC = @PTHREAD_CC@
@ -231,24 +273,20 @@ SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
XMKMF = @XMKMF@
X_CFLAGS = @X_CFLAGS@
X_EXTRA_LIBS = @X_EXTRA_LIBS@
X_LIBS = @X_LIBS@
X_PRE_LIBS = @X_PRE_LIBS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_AS = @ac_ct_AS@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DLLTOOL = @ac_ct_DLLTOOL@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
ac_ct_OBJDUMP = @ac_ct_OBJDUMP@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
acx_pthread_config = @acx_pthread_config@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
@ -260,47 +298,65 @@ build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
LIBPORT = $(top_builddir)/port/libport.la
LIBTIFF = $(top_builddir)/libtiff/libtiff.la
EXTRA_DIST = Makefile.vc SConstruct tif_config.h.vc tiffconf.h.vc libtiff.def \
libtiffincludedir = $(includedir)
EXTRA_DIST = Makefile.vc \
SConstruct \
tif_config.h-vms \
tif_config.vc.h \
tif_config.wince.h \
tiffconf.vc.h \
tiffconf.wince.h \
libtiff.def \
$(EXTRA_SRCS)
HDRS = tiff.h tiffconf.h tiffio.h tiffvers.h $(am__append_1)
EXTRA_HDRS = \
libtiffinclude_HEADERS = tiff.h tiffio.h tiffvers.h $(am__append_1)
noinst_HEADERS = \
t4.h \
tif_dir.h \
tif_predict.h \
tiffiop.h \
uvcode.h
SRCS = \
nodist_libtiffinclude_HEADERS = \
tiffconf.h
libtiff_la_SOURCES = \
tif_aux.c \
tif_close.c \
tif_codec.c \
@ -317,6 +373,7 @@ SRCS = \
tif_fax3sm.c \
tif_flush.c \
tif_getimage.c \
tif_jbig.c \
tif_jpeg.c \
tif_luv.c \
tif_lzw.c \
@ -338,7 +395,7 @@ SRCS = \
tif_write.c \
tif_zip.c
SRCSXX = \
libtiffxx_la_SOURCES = \
tif_stream.cxx
EXTRA_SRCS = \
@ -350,15 +407,10 @@ EXTRA_SRCS = \
tif_win3.c \
tif_win32.c
libtiffincludedir = $(includedir)
libtiffinclude_HEADERS = $(HDRS)
noinst_HEADERS = $(EXTRA_HDRS)
lib_LTLIBRARIES = libtiff.la $(am__append_2)
libtiff_la_SOURCES = $(SRCS)
libtiff_la_LDFLAGS = -no-undefined -version-number \
$(LIBTIFF_VERSION_INFO) $(am__append_3)
libtiff_la_LIBADD = $(LIBPORT)
libtiffxx_la_SOURCES = $(SRCSXX)
libtiffxx_la_LDFLAGS = -no-undefined -version-number \
$(LIBTIFF_VERSION_INFO) $(am__append_4)
libtiffxx_la_LIBADD = $(LIBTIFF) $(LIBPORT)
@ -374,14 +426,14 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libtiff/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --foreign libtiff/Makefile
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libtiff/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign libtiff/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
@ -399,25 +451,26 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
tif_config.h: stamp-h1
@if test ! -f $@; then \
rm -f stamp-h1; \
$(MAKE) stamp-h1; \
$(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
else :; fi
stamp-h1: $(srcdir)/tif_config.h.in $(top_builddir)/config.status
@rm -f stamp-h1
cd $(top_builddir) && $(SHELL) ./config.status libtiff/tif_config.h
$(srcdir)/tif_config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_srcdir) && $(AUTOHEADER)
($(am__cd) $(top_srcdir) && $(AUTOHEADER))
rm -f stamp-h1
touch $@
tiffconf.h: stamp-h2
@if test ! -f $@; then \
rm -f stamp-h2; \
$(MAKE) stamp-h2; \
$(MAKE) $(AM_MAKEFLAGS) stamp-h2; \
else :; fi
stamp-h2: $(srcdir)/tiffconf.h.in $(top_builddir)/config.status
@ -428,21 +481,25 @@ distclean-hdr:
-rm -f tif_config.h stamp-h1 tiffconf.h stamp-h2
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)"
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
list2=; for p in $$list; do \
if test -f $$p; then \
f=$(am__strip_dir) \
echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
$(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
list2="$$list2 $$p"; \
else :; fi; \
done
done; \
test -z "$$list2" || { \
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
}
uninstall-libLTLIBRARIES:
@$(NORMAL_UNINSTALL)
@set -x; list='$(lib_LTLIBRARIES)'; for p in $$list; do \
p=$(am__strip_dir) \
echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \
$(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \
@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
for p in $$list; do \
$(am__strip_dir) \
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
done
clean-libLTLIBRARIES:
@ -454,19 +511,21 @@ clean-libLTLIBRARIES:
rm -f "$${dir}/so_locations"; \
done
libtiff.la: $(libtiff_la_OBJECTS) $(libtiff_la_DEPENDENCIES)
$(LINK) -rpath $(libdir) $(libtiff_la_LDFLAGS) $(libtiff_la_OBJECTS) $(libtiff_la_LIBADD) $(LIBS)
$(AM_V_CCLD)$(libtiff_la_LINK) -rpath $(libdir) $(libtiff_la_OBJECTS) $(libtiff_la_LIBADD) $(LIBS)
libtiffxx.la: $(libtiffxx_la_OBJECTS) $(libtiffxx_la_DEPENDENCIES)
$(CXXLINK) $(am_libtiffxx_la_rpath) $(libtiffxx_la_LDFLAGS) $(libtiffxx_la_OBJECTS) $(libtiffxx_la_LIBADD) $(LIBS)
$(AM_V_CXXLD)$(libtiffxx_la_LINK) $(am_libtiffxx_la_rpath) $(libtiffxx_la_OBJECTS) $(libtiffxx_la_LIBADD) $(LIBS)
clean-noinstPROGRAMS:
@list='$(noinst_PROGRAMS)'; for p in $$list; do \
f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
echo " rm -f $$p $$f"; \
rm -f $$p $$f ; \
done
@list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
echo " rm -f" $$list; \
rm -f $$list || exit $$?; \
test -n "$(EXEEXT)" || exit 0; \
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
echo " rm -f" $$list; \
rm -f $$list
mkg3states$(EXEEXT): $(mkg3states_OBJECTS) $(mkg3states_DEPENDENCIES)
@rm -f mkg3states$(EXEEXT)
$(LINK) $(mkg3states_LDFLAGS) $(mkg3states_OBJECTS) $(mkg3states_LDADD) $(LIBS)
$(AM_V_CCLD)$(LINK) $(mkg3states_OBJECTS) $(mkg3states_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@ -491,6 +550,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tif_fax3sm.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tif_flush.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tif_getimage.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tif_jbig.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tif_jpeg.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tif_luv.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tif_lzw.Plo@am__quote@
@ -514,43 +574,49 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tif_zip.Plo@am__quote@
.c.o:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
.cxx.o:
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
.cxx.obj:
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.cxx.lo:
@am__fastdepCXX_TRUE@ if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
@ -560,100 +626,126 @@ mostlyclean-libtool:
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
install-libtiffincludeHEADERS: $(libtiffinclude_HEADERS)
@$(NORMAL_INSTALL)
test -z "$(libtiffincludedir)" || $(mkdir_p) "$(DESTDIR)$(libtiffincludedir)"
@list='$(libtiffinclude_HEADERS)'; for p in $$list; do \
test -z "$(libtiffincludedir)" || $(MKDIR_P) "$(DESTDIR)$(libtiffincludedir)"
@list='$(libtiffinclude_HEADERS)'; test -n "$(libtiffincludedir)" || list=; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f=$(am__strip_dir) \
echo " $(libtiffincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(libtiffincludedir)/$$f'"; \
$(libtiffincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(libtiffincludedir)/$$f"; \
echo "$$d$$p"; \
done | $(am__base_list) | \
while read files; do \
echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(libtiffincludedir)'"; \
$(INSTALL_HEADER) $$files "$(DESTDIR)$(libtiffincludedir)" || exit $$?; \
done
uninstall-libtiffincludeHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(libtiffinclude_HEADERS)'; for p in $$list; do \
f=$(am__strip_dir) \
echo " rm -f '$(DESTDIR)$(libtiffincludedir)/$$f'"; \
rm -f "$(DESTDIR)$(libtiffincludedir)/$$f"; \
@list='$(libtiffinclude_HEADERS)'; test -n "$(libtiffincludedir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
test -n "$$files" || exit 0; \
echo " ( cd '$(DESTDIR)$(libtiffincludedir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(libtiffincludedir)" && rm -f $$files
install-nodist_libtiffincludeHEADERS: $(nodist_libtiffinclude_HEADERS)
@$(NORMAL_INSTALL)
test -z "$(libtiffincludedir)" || $(MKDIR_P) "$(DESTDIR)$(libtiffincludedir)"
@list='$(nodist_libtiffinclude_HEADERS)'; test -n "$(libtiffincludedir)" || list=; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; \
done | $(am__base_list) | \
while read files; do \
echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(libtiffincludedir)'"; \
$(INSTALL_HEADER) $$files "$(DESTDIR)$(libtiffincludedir)" || exit $$?; \
done
uninstall-nodist_libtiffincludeHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(nodist_libtiffinclude_HEADERS)'; test -n "$(libtiffincludedir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
test -n "$$files" || exit 0; \
echo " ( cd '$(DESTDIR)$(libtiffincludedir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(libtiffincludedir)" && rm -f $$files
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) tif_config.h.in tiffconf.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
set x; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) tif_config.h.in tiffconf.h.in $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) tif_config.h.in tiffconf.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) tif_config.h.in tiffconf.h.in $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
@ -662,8 +754,8 @@ check: check-am
all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS) tif_config.h \
tiffconf.h
installdirs:
for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(libtiffincludedir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(libtiffincludedir)" "$(DESTDIR)$(libtiffincludedir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
@ -685,6 +777,7 @@ clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@ -698,7 +791,7 @@ distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-hdr distclean-libtool distclean-tags
distclean-hdr distclean-tags
dvi: dvi-am
@ -706,18 +799,39 @@ dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am: install-libtiffincludeHEADERS
install-data-am: install-libtiffincludeHEADERS \
install-nodist_libtiffincludeHEADERS
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am: install-libLTLIBRARIES
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
@ -738,26 +852,33 @@ ps: ps-am
ps-am:
uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES \
uninstall-libtiffincludeHEADERS
uninstall-am: uninstall-libLTLIBRARIES uninstall-libtiffincludeHEADERS \
uninstall-nodist_libtiffincludeHEADERS
.MAKE: all install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libLTLIBRARIES clean-libtool clean-noinstPROGRAMS ctags \
distclean distclean-compile distclean-generic distclean-hdr \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-exec install-exec-am install-info \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-libLTLIBRARIES \
install-libtiffincludeHEADERS install-man install-strip \
install-libtiffincludeHEADERS install-man \
install-nodist_libtiffincludeHEADERS install-pdf \
install-pdf-am install-ps install-ps-am install-strip \
installcheck installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags uninstall uninstall-am uninstall-info-am \
uninstall-libLTLIBRARIES uninstall-libtiffincludeHEADERS
tags uninstall uninstall-am uninstall-libLTLIBRARIES \
uninstall-libtiffincludeHEADERS \
uninstall-nodist_libtiffincludeHEADERS
faxtable: mkg3states
(rm -f tif_fax3sm.c && ./mkg3states -b -c const tif_fax3sm.c)
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View file

@ -1,4 +1,4 @@
# $Id: Makefile.vc,v 1.15 2006/03/23 14:54:02 dron Exp $
# $Id: Makefile.vc,v 1.17.2.2 2007/07/18 14:30:05 dron Exp $
#
# Copyright (C) 2004, Andrey Kiselev <dron@ak4719.spb.edu>
#
@ -29,7 +29,7 @@
!INCLUDE ..\nmake.opt
INCL = -I. $(JPEG_INCLUDE) $(ZLIB_INCLUDE)
INCL = -I. $(JPEG_INCLUDE) $(ZLIB_INCLUDE) $(JBIG_INCLUDE)
!IFDEF USE_WIN_CRT_LIB
OBJ_SYSDEP_MODULE = tif_unix.obj
@ -53,6 +53,7 @@ OBJ = \
tif_fax3.obj \
tif_fax3sm.obj \
tif_getimage.obj \
tif_jbig.obj \
tif_jpeg.obj \
tif_ojpeg.obj \
tif_flush.obj \
@ -74,15 +75,16 @@ OBJ = \
tif_warning.obj \
tif_write.obj \
tif_zip.obj \
tif_jbig.obj \
$(OBJ_SYSDEP_MODULE)
all: libtiff.lib $(DLLNAME)
tif_config.h: tif_config.h.vc
copy tif_config.h.vc tif_config.h
tif_config.h: tif_config.vc.h
copy tif_config.vc.h tif_config.h
tiffconf.h: tiffconf.h.vc
copy tiffconf.h.vc tiffconf.h
tiffconf.h: tiffconf.vc.h
copy tiffconf.vc.h tiffconf.h
libtiff.lib: tif_config.h tiffconf.h $(OBJ)
$(AR) /out:libtiff.lib $(OBJ) $(LIBS)
@ -92,7 +94,9 @@ $(DLLNAME): tif_config.h tiffconf.h libtiff.def $(OBJ)
/implib:libtiff_i.lib $(OBJ) $(LIBS)
clean:
-del tif_config.h tiffconf.h
-del *.obj
-del *.lib
-del *.dll
-del *.exe
-del *.pdb

View file

@ -1,4 +1,4 @@
# $Id: SConstruct,v 1.2 2006/03/23 14:54:02 dron Exp $
# $Id: SConstruct,v 1.4 2007/02/24 15:03:50 dron Exp $
# Tag Image File Format (TIFF) Software
#
@ -46,6 +46,7 @@ SRCS = [ \
'tif_fax3sm.c', \
'tif_flush.c', \
'tif_getimage.c', \
'tif_jbig.c', \
'tif_jpeg.c', \
'tif_luv.c', \
'tif_lzw.c', \
@ -69,3 +70,4 @@ SRCS = [ \
StaticLibrary('tiff', SRCS)
SharedLibrary('tiff', SRCS)

View file

@ -1,4 +1,4 @@
/* "$Id: mkg3states.c,v 1.9 2004/10/10 11:46:16 dron Exp $ */
/* "$Id: mkg3states.c,v 1.10.2.1 2010-06-08 18:50:41 bfriesen Exp $ */
/*
* Copyright (c) 1991-1997 Sam Leffler
@ -41,6 +41,10 @@
#include "tif_fax3.h"
#ifndef HAVE_GETOPT
extern int getopt(int, char**, char*);
#endif
#define streq(a,b) (strcmp(a,b) == 0)
/* NB: can't use names in tif_fax3.h 'cuz they are declared const */
@ -438,3 +442,10 @@ main(int argc, char* argv[])
}
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: t4.h,v 1.1.1.1 1999/07/27 21:50:27 mike Exp $ */
/* $Id: t4.h,v 1.1.1.1.2.1 2010-06-08 18:50:41 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -283,3 +283,10 @@ extern const tableentry TIFFFaxWhiteCodes[];
extern const tableentry TIFFFaxBlackCodes[];
#endif
#endif /* _T4_ */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_acorn.c,v 1.2 2005/12/21 12:23:13 joris Exp $ */
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/Attic/tif_acorn.c,v 1.2.2.1 2010-06-08 18:50:41 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -517,3 +517,10 @@ acornErrorHandler(const char* module, const char* fmt, va_list ap)
fprintf(stderr, ".\n");
}
TIFFErrorHandler _TIFFerrorHandler = acornErrorHandler;
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_apple.c,v 1.3 2005/12/21 12:23:13 joris Exp $ */
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/Attic/tif_apple.c,v 1.3.2.1 2010-06-08 18:50:41 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -272,3 +272,10 @@ appleErrorHandler(const char* module, const char* fmt, va_list ap)
fprintf(stderr, ".\n");
}
TIFFErrorHandler _TIFFerrorHandler = appleErrorHandler;
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* "$Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_atari.c,v 1.2 2005/12/21 12:23:13 joris Exp $" */
/* "$Header: /cvs/maptools/cvsroot/libtiff/libtiff/Attic/tif_atari.c,v 1.2.2.1 2010-06-08 18:50:41 bfriesen Exp $" */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -241,3 +241,10 @@ atariErrorHandler(const char* module, const char* fmt, va_list ap)
fprintf(stderr, ".\n");
}
TIFFErrorHandler _TIFFerrorHandler = atariErrorHandler;
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tif_aux.c,v 1.19 2006/02/07 10:41:30 dron Exp $ */
/* $Id: tif_aux.c,v 1.20.2.3 2010-06-09 21:15:27 bfriesen Exp $ */
/*
* Copyright (c) 1991-1997 Sam Leffler
@ -34,7 +34,8 @@
#include <math.h>
tdata_t
_TIFFCheckMalloc(TIFF* tif, size_t nmemb, size_t elem_size, const char* what)
_TIFFCheckRealloc(TIFF* tif, tdata_t buffer,
size_t nmemb, size_t elem_size, const char* what)
{
tdata_t cp = NULL;
tsize_t bytes = nmemb * elem_size;
@ -43,12 +44,21 @@ _TIFFCheckMalloc(TIFF* tif, size_t nmemb, size_t elem_size, const char* what)
* XXX: Check for integer overflow.
*/
if (nmemb && elem_size && bytes / elem_size == nmemb)
cp = _TIFFmalloc(bytes);
cp = _TIFFrealloc(buffer, bytes);
if (cp == NULL)
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "No space %s", what);
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;
}
tdata_t
_TIFFCheckMalloc(TIFF* tif, size_t nmemb, size_t elem_size, const char* what)
{
return _TIFFCheckRealloc(tif, NULL, nmemb, elem_size, what);
}
static int
@ -92,6 +102,35 @@ bad:
return 0;
}
static int
TIFFDefaultRefBlackWhite(TIFFDirectory* td)
{
int i;
if (!(td->td_refblackwhite = (float *)_TIFFmalloc(6*sizeof (float))))
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;
}
/*
* Like TIFFGetField, but return any default
* value if the tag is not present in the directory.
@ -217,33 +256,10 @@ TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap)
}
return (1);
case TIFFTAG_REFERENCEBLACKWHITE:
{
int i;
static float ycbcr_refblackwhite[] =
{ 0.0F, 255.0F, 128.0F, 255.0F, 128.0F, 255.0F };
static float rgb_refblackwhite[6];
for (i = 0; i < 3; i++) {
rgb_refblackwhite[2 * i + 0] = 0.0F;
rgb_refblackwhite[2 * i + 1] =
(float)((1L<<td->td_bitspersample)-1L);
}
if (td->td_photometric == PHOTOMETRIC_YCBCR) {
/*
* YCbCr (Class Y) images must have the
* ReferenceBlackWhite tag set. Fix the
* broken images, which lacks that tag.
*/
*va_arg(ap, float **) = ycbcr_refblackwhite;
} else {
/*
* Assume RGB (Class R)
*/
*va_arg(ap, float **) = rgb_refblackwhite;
}
return 1;
}
if (!td->td_refblackwhite && !TIFFDefaultRefBlackWhite(td))
return (0);
*va_arg(ap, float **) = td->td_refblackwhite;
return (1);
}
return 0;
}
@ -265,3 +281,10 @@ TIFFGetFieldDefaulted(TIFF* tif, ttag_t tag, ...)
}
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tif_close.c,v 1.9 2005/11/23 22:20:56 dron Exp $ */
/* $Id: tif_close.c,v 1.10.2.1 2010-06-08 18:50:41 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -54,27 +54,27 @@ TIFFCleanup(TIFF* tif)
TIFFFreeDirectory(tif);
if (tif->tif_dirlist)
_TIFFfree(tif->tif_dirlist);
_TIFFfree(tif->tif_dirlist);
/* Clean up client info links */
while( tif->tif_clientinfo )
{
TIFFClientInfoLink *link = tif->tif_clientinfo;
TIFFClientInfoLink *link = tif->tif_clientinfo;
tif->tif_clientinfo = link->next;
_TIFFfree( link->name );
_TIFFfree( link );
tif->tif_clientinfo = link->next;
_TIFFfree( link->name );
_TIFFfree( link );
}
if (tif->tif_rawdata && (tif->tif_flags&TIFF_MYBUFFER))
_TIFFfree(tif->tif_rawdata);
_TIFFfree(tif->tif_rawdata);
if (isMapped(tif))
TIFFUnmapFileContents(tif, tif->tif_base, tif->tif_size);
TIFFUnmapFileContents(tif, tif->tif_base, tif->tif_size);
/* Clean up custom fields */
if (tif->tif_nfields > 0)
if (tif->tif_nfields > 0)
{
size_t i;
size_t i;
for (i = 0; i < tif->tif_nfields; i++)
{
@ -117,3 +117,10 @@ TIFFClose(TIFF* tif)
(void) (*closeproc)(fd);
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tif_codec.c,v 1.10 2005/12/21 12:23:13 joris Exp $ */
/* $Id: tif_codec.c,v 1.10.2.2 2010-06-08 18:50:41 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -102,9 +102,12 @@ static int
_notConfigured(TIFF* tif)
{
const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression);
char compression_code[20];
sprintf( compression_code, "%d", tif->tif_dir.td_compression );
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"%s compression support is not configured", c->name);
"%s compression support is not configured",
c ? c->name : compression_code );
return (0);
}
@ -148,3 +151,10 @@ TIFFIsCODECConfigured(uint16 scheme)
return 0;
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tif_color.c,v 1.12 2006/02/09 15:42:20 dron Exp $ */
/* $Id: tif_color.c,v 1.12.2.2 2010-12-14 02:23:09 faxguy Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -183,13 +183,18 @@ void
TIFFYCbCrtoRGB(TIFFYCbCrToRGB *ycbcr, uint32 Y, int32 Cb, int32 Cr,
uint32 *r, uint32 *g, uint32 *b)
{
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);
*r = ycbcr->clamptab[ycbcr->Y_tab[Y] + ycbcr->Cr_r_tab[Cr]];
*g = ycbcr->clamptab[ycbcr->Y_tab[Y]
+ (int)((ycbcr->Cb_g_tab[Cb] + ycbcr->Cr_g_tab[Cr]) >> SHIFT)];
*b = ycbcr->clamptab[ycbcr->Y_tab[Y] + ycbcr->Cb_b_tab[Cb]];
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);
}
/*
@ -273,3 +278,10 @@ TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, float *luma, float *refBlackWhite)
#undef FIX
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tif_compress.c,v 1.11 2005/12/21 12:23:13 joris Exp $ */
/* $Id: tif_compress.c,v 1.13.2.1 2010-06-08 18:50:41 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -37,12 +37,13 @@ TIFFNoEncode(TIFF* tif, const char* method)
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);
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);
"Compression scheme %u %s encoding is not implemented",
tif->tif_dir.td_compression, method);
}
return (-1);
}
@ -74,12 +75,13 @@ TIFFNoDecode(TIFF* tif, const char* method)
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);
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);
"Compression scheme %u %s decoding is not implemented",
tif->tif_dir.td_compression, method);
return (-1);
}
@ -109,7 +111,7 @@ _TIFFNoSeek(TIFF* tif, uint32 off)
{
(void) off;
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"Compression algorithm does not support random access");
"Compression algorithm does not support random access");
return (0);
}
@ -144,7 +146,7 @@ _TIFFSetDefaultCompressionState(TIFF* tif)
tif->tif_cleanup = _TIFFvoid;
tif->tif_defstripsize = _TIFFDefaultStripSize;
tif->tif_deftilesize = _TIFFDefaultTileSize;
tif->tif_flags &= ~TIFF_NOBITREV;
tif->tif_flags &= ~(TIFF_NOBITREV|TIFF_NOREADRAW);
}
int
@ -284,3 +286,10 @@ TIFFGetConfiguredCODECs()
}
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -31,6 +31,25 @@
first (like Motorola and SPARC, unlike Intel and VAX). */
/* #undef WORDS_BIGENDIAN */
#ifdef COMPILER_MSC
#define TIFF_INT64_T __int64
#define TIFF_UINT64_T __int64 unsigned
#else
#define TIFF_INT64_T long long int
#define TIFF_UINT64_T long long int unsigned;
#endif
#define HAVE_INT64
#define HAVE_UINT64
#ifdef COMPILER_MSC
#define int64 __int64
#define uint64 __int64 unsigned
#else
#define int64 long long int
#define uint64 long long int unsigned
#endif
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus

View file

@ -0,0 +1,46 @@
/* Define to 1 if you have the <assert.h> header file. */
#define HAVE_ASSERT_H 1
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define as 0 or 1 according to the floating point format suported by the
machine */
#define HAVE_IEEEFP 1
#define HAVE_UNISTD_H 1
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <io.h> header file. */
//#define HAVE_IO_H 1
/* Define to 1 if you have the <search.h> header file. */
//#define HAVE_SEARCH_H 1
/* The size of a `int', as computed by sizeof. */
#define SIZEOF_INT 4
/* The size of a `long', as computed by sizeof. */
#define SIZEOF_LONG 4
/* Set the native cpu bit order */
#define HOST_FILLORDER FILLORDER_LSB2MSB
/* Define to 1 if your processor stores words with the most significant byte
first (like Motorola and SPARC, unlike Intel and VAX). */
/* #undef WORDS_BIGENDIAN */
/* 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
# ifndef inline
# define inline __inline
# endif
#endif
*/
// #define lfind _lfind

View file

@ -1,5 +1,8 @@
/* libtiff/tif_config.h.in. Generated from configure.ac by autoheader. */
/* Define if building universal (internal helper macro) */
#undef AC_APPLE_UNIVERSAL_BUILD
/* Support CCITT Group 3 & 4 algorithms */
#undef CCITT_SUPPORT
@ -49,9 +52,15 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <io.h> header file. */
#undef HAVE_IO_H
/* Define to 1 if you have the `isascii' function. */
#undef HAVE_ISASCII
/* Define to 1 if you have the `jbg_newlen' function. */
#undef HAVE_JBG_NEWLEN
/* Define to 1 if you have the `lfind' function. */
#undef HAVE_LFIND
@ -88,6 +97,9 @@
/* Define to 1 if you have the <search.h> header file. */
#undef HAVE_SEARCH_H
/* Define to 1 if you have the `setmode' function. */
#undef HAVE_SETMODE
/* Define to 1 if you have the `sqrt' function. */
#undef HAVE_SQRT
@ -143,6 +155,9 @@
/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */
#undef HOST_FILLORDER
/* Support ISO JBIG compression (requires JBIG-KIT library) */
#undef JBIG_SUPPORT
/* Support JPEG compression (requires IJG JPEG library) */
#undef JPEG_SUPPORT
@ -165,8 +180,7 @@
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
#undef NO_MINUS_C_MINUS_O
/* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation
fails with unpatched IJG JPEG library) */
/* Support Old JPEG compresson (read-only) */
#undef OJPEG_SUPPORT
/* Name of package */
@ -184,6 +198,9 @@
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
@ -197,12 +214,24 @@
your system. */
#undef PTHREAD_CREATE_JOINABLE
/* The size of a `int', as computed by sizeof. */
/* The size of `int', as computed by sizeof. */
#undef SIZEOF_INT
/* The size of a `long', as computed by sizeof. */
/* The size of `long', as computed by sizeof. */
#undef SIZEOF_LONG
/* The size of `signed long', as computed by sizeof. */
#undef SIZEOF_SIGNED_LONG
/* The size of `signed long long', as computed by sizeof. */
#undef SIZEOF_SIGNED_LONG_LONG
/* The size of `unsigned long', as computed by sizeof. */
#undef SIZEOF_UNSIGNED_LONG
/* The size of `unsigned long long', as computed by sizeof. */
#undef SIZEOF_UNSIGNED_LONG_LONG
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
@ -219,6 +248,18 @@
/* Support ThunderScan 4-bit RLE algorithm */
#undef THUNDER_SUPPORT
/* Signed 64-bit type formatter */
#undef TIFF_INT64_FORMAT
/* Signed 64-bit type */
#undef TIFF_INT64_T
/* Unsigned 64-bit type formatter */
#undef TIFF_UINT64_FORMAT
/* Unsigned 64-bit type */
#undef TIFF_UINT64_T
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
@ -228,9 +269,17 @@
/* Version number of package */
#undef VERSION
/* Define to 1 if your processor stores words with the most significant byte
first (like Motorola and SPARC, unlike Intel and VAX). */
#undef WORDS_BIGENDIAN
/* 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
/* Define to 1 if the X Window System is missing or not being used. */
#undef X_DISPLAY_MISSING
@ -253,8 +302,8 @@
#undef inline
#endif
/* Define to `long' if <sys/types.h> does not define. */
/* Define to `long int' if <sys/types.h> does not define. */
#undef off_t
/* Define to `unsigned' if <sys/types.h> does not define. */
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t

View file

@ -0,0 +1,63 @@
/* Define to 1 if you have the <assert.h> header file. */
#define HAVE_ASSERT_H 1
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* 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 `jbg_newlen' function. */
#define HAVE_JBG_NEWLEN 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <io.h> header file. */
#define HAVE_IO_H 1
/* Define to 1 if you have the <search.h> header file. */
#define HAVE_SEARCH_H 1
/* Define to 1 if you have the `setmode' function. */
#define HAVE_SETMODE 1
/* The size of a `int', as computed by sizeof. */
#define SIZEOF_INT 4
/* The size of a `long', as computed by sizeof. */
#define SIZEOF_LONG 4
/* Signed 64-bit type */
#define TIFF_INT64_T signed __int64
/* Unsigned 64-bit type */
#define TIFF_UINT64_T unsigned __int64
/* Set the native cpu bit order */
#define HOST_FILLORDER FILLORDER_LSB2MSB
/* Define to 1 if your processor stores words with the most significant byte
first (like Motorola and SPARC, unlike Intel and VAX). */
/* #undef WORDS_BIGENDIAN */
/* 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
# ifndef inline
# define inline __inline
# endif
#endif
#define lfind _lfind
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -0,0 +1,74 @@
/* $Id: tif_config.wince.h,v 1.1.2.1 2010-06-08 18:50:41 bfriesen Exp $ */
/*
* TIFF library configuration header for Windows CE platform.
*/
#ifndef _WIN32_WCE
# error This version of tif_config.h header is dedicated for Windows CE platform!
#endif
/* Define to 1 if you have the <assert.h> header file. */
#define HAVE_ASSERT_H 1
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* 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 `jbg_newlen' function. */
#define HAVE_JBG_NEWLEN 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <io.h> header file. */
#define HAVE_IO_H 1
/* Define to 1 if you have the <search.h> header file. */
#define HAVE_SEARCH_H 1
/* Define to 1 if you have the `setmode' function. */
#define HAVE_SETMODE 1
/* Define to 1 if you have the `bsearch' function. */
#define HAVE_BSEARCH 1
#define bsearch wceex_bsearch
/* Define to 1 if you have the `lfind' function. */
#define HAVE_LFIND 1
#define lfind wceex_lfind
/* The size of a `int', as computed by sizeof. */
#define SIZEOF_INT 4
/* The size of a `long', as computed by sizeof. */
#define SIZEOF_LONG 4
/* Set the native cpu bit order */
#define HOST_FILLORDER FILLORDER_LSB2MSB
/* Define to 1 if your processor stores words with the most significant byte
first (like Motorola and SPARC, unlike Intel and VAX). */
/* #undef WORDS_BIGENDIAN */
/* 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
# ifndef inline
# define inline __inline
# endif
#endif
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tif_dir.c,v 1.72 2006/03/15 12:49:35 dron Exp $ */
/* $Id: tif_dir.c,v 1.75.2.6 2010-07-02 09:49:23 dron Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -74,21 +74,37 @@ void _TIFFsetDoubleArray(double** dpp, double* dp, uint32 n)
static int
setExtraSamples(TIFFDirectory* td, va_list ap, uint32* v)
{
/* XXX: Unassociated alpha data == 999 is a known Corel Draw bug, see below */
#define EXTRASAMPLE_COREL_UNASSALPHA 999
uint16* va;
uint32 i;
*v = va_arg(ap, uint32);
if ((uint16) *v > td->td_samplesperpixel)
return (0);
return 0;
va = va_arg(ap, uint16*);
if (*v > 0 && va == NULL) /* typically missing param */
return (0);
for (i = 0; i < *v; i++)
if (va[i] > EXTRASAMPLE_UNASSALPHA)
return (0);
return 0;
for (i = 0; i < *v; i++) {
if (va[i] > EXTRASAMPLE_UNASSALPHA) {
/*
* XXX: Corel Draw is known to produce incorrect
* ExtraSamples tags which must be patched here if we
* want to be able to open some of the damaged TIFF
* files:
*/
if (va[i] == EXTRASAMPLE_COREL_UNASSALPHA)
va[i] = EXTRASAMPLE_UNASSALPHA;
else
return 0;
}
}
td->td_extrasamples = (uint16) *v;
_TIFFsetShortArray(&td->td_sampleinfo, va, td->td_extrasamples);
return (1);
return 1;
#undef EXTRASAMPLE_COREL_UNASSALPHA
}
static uint32
@ -121,7 +137,7 @@ static int
_TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
{
static const char module[] = "_TIFFVSetField";
TIFFDirectory* td = &tif->tif_dir;
int status = 1;
uint32 v32, i, v;
@ -147,7 +163,9 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
* work in with its normal work.
*/
if (tif->tif_flags & TIFF_SWAB) {
if (td->td_bitspersample == 16)
if (td->td_bitspersample == 8)
tif->tif_postdecode = _TIFFNoPostDecode;
else if (td->td_bitspersample == 16)
tif->tif_postdecode = _TIFFSwab16BitData;
else if (td->td_bitspersample == 24)
tif->tif_postdecode = _TIFFSwab24BitData;
@ -192,14 +210,11 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
goto badvalue;
td->td_fillorder = (uint16) v;
break;
break;
case TIFFTAG_ORIENTATION:
v = va_arg(ap, uint32);
if (v < ORIENTATION_TOPLEFT || ORIENTATION_LEFTBOT < v) {
TIFFWarningExt(tif->tif_clientdata, tif->tif_name,
"Bad value %lu for \"%s\" tag ignored",
v, _TIFFFieldWithTag(tif, tag)->field_name);
} else
if (v < ORIENTATION_TOPLEFT || ORIENTATION_LEFTBOT < v)
goto badvalue;
else
td->td_orientation = (uint16) v;
break;
case TIFFTAG_SAMPLESPERPIXEL:
@ -345,8 +360,9 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
_TIFFsetLongArray(&td->td_subifd, va_arg(ap, uint32*),
(long) td->td_nsubifd);
} else {
TIFFErrorExt(tif->tif_clientdata, module, "%s: Sorry, cannot nest SubIFDs",
tif->tif_name);
TIFFErrorExt(tif->tif_clientdata, module,
"%s: Sorry, cannot nest SubIFDs",
tif->tif_name);
status = 0;
}
break;
@ -363,6 +379,10 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
_TIFFsetShortArray(&td->td_transferfunction[i],
va_arg(ap, uint16*), 1L<<td->td_bitspersample);
break;
case TIFFTAG_REFERENCEBLACKWHITE:
/* XXX should check for null range */
_TIFFsetFloatArray(&td->td_refblackwhite, va_arg(ap, float*), 6);
break;
case TIFFTAG_INKNAMES:
v = va_arg(ap, uint32);
s = va_arg(ap, char*);
@ -374,9 +394,9 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
}
break;
default: {
const TIFFFieldInfo* fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY);
TIFFTagValue *tv;
int tv_size, iCustom;
const TIFFFieldInfo* fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY);
/*
* This can happen if multiple images are open with different
@ -389,9 +409,9 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
*/
if(fip == NULL || fip->field_bit != FIELD_CUSTOM) {
TIFFErrorExt(tif->tif_clientdata, module,
"%s: Invalid %stag \"%s\" (not supported by codec)",
tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "",
_TIFFFieldWithTag(tif, tag)->field_name);
"%s: Invalid %stag \"%s\" (not supported by codec)",
tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "",
fip ? fip->field_name : "Unknown");
status = 0;
break;
}
@ -400,16 +420,15 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
* Find the existing entry for this custom value.
*/
tv = NULL;
for(iCustom = 0; iCustom < td->td_customValueCount; iCustom++) {
if(td->td_customValues[iCustom].info == fip) {
tv = td->td_customValues + iCustom;
if(tv->value != NULL)
{
_TIFFfree(tv->value);
tv->value = NULL;
}
break;
}
for (iCustom = 0; iCustom < td->td_customValueCount; iCustom++) {
if (td->td_customValues[iCustom].info->field_tag == tag) {
tv = td->td_customValues + iCustom;
if (tv->value != NULL) {
_TIFFfree(tv->value);
tv->value = NULL;
}
break;
}
}
/*
@ -432,7 +451,7 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
td->td_customValues = new_customValues;
tv = td->td_customValues + (td->td_customValueCount-1);
tv = td->td_customValues + (td->td_customValueCount - 1);
tv->info = fip;
tv->value = NULL;
tv->count = 0;
@ -468,7 +487,8 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
if (fip->field_type == TIFF_ASCII)
_TIFFsetString((char **)&tv->value, va_arg(ap, char *));
else {
tv->value = _TIFFmalloc(tv_size * tv->count);
tv->value = _TIFFCheckMalloc(tif, tv_size, tv->count,
"Tag Value");
if (!tv->value) {
status = 0;
goto end;
@ -571,13 +591,17 @@ end:
va_end(ap);
return (status);
badvalue:
TIFFErrorExt(tif->tif_clientdata, module, "%s: Bad value %d for \"%s\"",
tif->tif_name, v, _TIFFFieldWithTag(tif, tag)->field_name);
TIFFErrorExt(tif->tif_clientdata, module,
"%s: Bad value %d for \"%s\" tag",
tif->tif_name, v,
_TIFFFieldWithTag(tif, tag)->field_name);
va_end(ap);
return (0);
badvalue32:
TIFFErrorExt(tif->tif_clientdata, module, "%s: Bad value %ld for \"%s\"",
tif->tif_name, v32, _TIFFFieldWithTag(tif, tag)->field_name);
TIFFErrorExt(tif->tif_clientdata, module,
"%s: Bad value %u for \"%s\" tag",
tif->tif_name, v32,
_TIFFFieldWithTag(tif, tag)->field_name);
va_end(ap);
return (0);
}
@ -797,6 +821,9 @@ _TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap)
*va_arg(ap, uint16**) = td->td_transferfunction[2];
}
break;
case TIFFTAG_REFERENCEBLACKWHITE:
*va_arg(ap, float**) = td->td_refblackwhite;
break;
case TIFFTAG_INKNAMES:
*va_arg(ap, char**) = td->td_inknames;
break;
@ -806,21 +833,22 @@ _TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap)
int i;
/*
* This can happen if multiple images are open with
* different codecs which have private tags. The
* global tag information table may then have tags
* that are valid for one file but not the other.
* If the client tries to get a tag that is not valid
* for the image's codec then we'll arrive here.
* This can happen if multiple images are open with different
* codecs which have private tags. The global tag information
* table may then have tags that are valid for one file but not
* the other. If the client tries to get a tag that is not valid
* for the image's codec then we'll arrive here.
*/
if( fip == NULL || fip->field_bit != FIELD_CUSTOM )
{
TIFFErrorExt(tif->tif_clientdata, "_TIFFVGetField",
"%s: Invalid %stag \"%s\" (not supported by codec)",
tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "",
_TIFFFieldWithTag(tif, tag)->field_name);
ret_val = 0;
break;
TIFFErrorExt(tif->tif_clientdata, "_TIFFVGetField",
"%s: Invalid %stag \"%s\" "
"(not supported by codec)",
tif->tif_name,
isPseudoTag(tag) ? "pseudo-" : "",
fip ? fip->field_name : "Unknown");
ret_val = 0;
break;
}
/*
@ -970,6 +998,7 @@ TIFFFreeDirectory(TIFF* tif)
CleanupField(td_sampleinfo);
CleanupField(td_subifd);
CleanupField(td_inknames);
CleanupField(td_refblackwhite);
CleanupField(td_transferfunction[0]);
CleanupField(td_transferfunction[1]);
CleanupField(td_transferfunction[2]);
@ -1032,7 +1061,7 @@ TIFFDefaultDirectory(TIFF* tif)
size_t tiffFieldInfoCount;
const TIFFFieldInfo *tiffFieldInfo =
_TIFFGetFieldInfo(&tiffFieldInfoCount);
_TIFFGetFieldInfo(&tiffFieldInfoCount);
_TIFFSetupFieldInfo(tif, tiffFieldInfo, tiffFieldInfoCount);
_TIFFmemset(td, 0, sizeof (*td));
@ -1053,7 +1082,7 @@ TIFFDefaultDirectory(TIFF* tif)
td->td_ycbcrsubsampling[1] = 2;
td->td_ycbcrpositioning = YCBCRPOSITION_CENTERED;
tif->tif_postdecode = _TIFFNoPostDecode;
tif->tif_foundfield = NULL;
tif->tif_foundfield = NULL;
tif->tif_tagmethods.vsetfield = _TIFFVSetField;
tif->tif_tagmethods.vgetfield = _TIFFVGetField;
tif->tif_tagmethods.printdir = NULL;
@ -1074,12 +1103,17 @@ TIFFDefaultDirectory(TIFF* tif)
*/
tif->tif_flags &= ~TIFF_DIRTYDIRECT;
/*
* As per http://bugzilla.remotesensing.org/show_bug.cgi?id=19
* we clear the ISTILED flag when setting up a new directory.
* Should we also be clearing stuff like INSUBIFD?
*/
tif->tif_flags &= ~TIFF_ISTILED;
/*
* As per http://bugzilla.remotesensing.org/show_bug.cgi?id=19
* we clear the ISTILED flag when setting up a new directory.
* Should we also be clearing stuff like INSUBIFD?
* Clear other directory-specific fields.
*/
tif->tif_flags &= ~TIFF_ISTILED;
tif->tif_tilesize = -1;
tif->tif_scanlinesize = -1;
return (1);
}
@ -1087,59 +1121,59 @@ TIFFDefaultDirectory(TIFF* tif)
static int
TIFFAdvanceDirectory(TIFF* tif, uint32* nextdir, toff_t* off)
{
static const char module[] = "TIFFAdvanceDirectory";
uint16 dircount;
if (isMapped(tif))
{
toff_t poff=*nextdir;
if (poff+sizeof(uint16) > tif->tif_size)
{
static const char module[] = "TIFFAdvanceDirectory";
uint16 dircount;
if (isMapped(tif))
{
toff_t poff=*nextdir;
if (poff+sizeof(uint16) > tif->tif_size)
{
TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory count",
tif->tif_name);
return (0);
}
_TIFFmemcpy(&dircount, tif->tif_base+poff, sizeof (uint16));
if (tif->tif_flags & TIFF_SWAB)
TIFFSwabShort(&dircount);
poff+=sizeof (uint16)+dircount*sizeof (TIFFDirEntry);
if (off != NULL)
*off = poff;
if (((toff_t) (poff+sizeof (uint32))) > tif->tif_size)
{
tif->tif_name);
return (0);
}
_TIFFmemcpy(&dircount, tif->tif_base+poff, sizeof (uint16));
if (tif->tif_flags & TIFF_SWAB)
TIFFSwabShort(&dircount);
poff+=sizeof (uint16)+dircount*sizeof (TIFFDirEntry);
if (off != NULL)
*off = poff;
if (((toff_t) (poff+sizeof (uint32))) > tif->tif_size)
{
TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory link",
tif->tif_name);
return (0);
}
_TIFFmemcpy(nextdir, tif->tif_base+poff, sizeof (uint32));
if (tif->tif_flags & TIFF_SWAB)
TIFFSwabLong(nextdir);
return (1);
}
else
{
if (!SeekOK(tif, *nextdir) ||
!ReadOK(tif, &dircount, sizeof (uint16))) {
tif->tif_name);
return (0);
}
_TIFFmemcpy(nextdir, tif->tif_base+poff, sizeof (uint32));
if (tif->tif_flags & TIFF_SWAB)
TIFFSwabLong(nextdir);
return (1);
}
else
{
if (!SeekOK(tif, *nextdir) ||
!ReadOK(tif, &dircount, sizeof (uint16))) {
TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory count",
tif->tif_name);
return (0);
}
if (tif->tif_flags & TIFF_SWAB)
TIFFSwabShort(&dircount);
if (off != NULL)
*off = TIFFSeekFile(tif,
dircount*sizeof (TIFFDirEntry), SEEK_CUR);
else
(void) TIFFSeekFile(tif,
dircount*sizeof (TIFFDirEntry), SEEK_CUR);
if (!ReadOK(tif, nextdir, sizeof (uint32))) {
tif->tif_name);
return (0);
}
if (tif->tif_flags & TIFF_SWAB)
TIFFSwabShort(&dircount);
if (off != NULL)
*off = TIFFSeekFile(tif,
dircount*sizeof (TIFFDirEntry), SEEK_CUR);
else
(void) TIFFSeekFile(tif,
dircount*sizeof (TIFFDirEntry), SEEK_CUR);
if (!ReadOK(tif, nextdir, sizeof (uint32))) {
TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory link",
tif->tif_name);
return (0);
}
if (tif->tif_flags & TIFF_SWAB)
TIFFSwabLong(nextdir);
return (1);
}
tif->tif_name);
return (0);
}
if (tif->tif_flags & TIFF_SWAB)
TIFFSwabLong(nextdir);
return (1);
}
}
/*
@ -1348,3 +1382,10 @@ TIFFReassignTagToIgnore (enum TIFFIgnoreSense task, int TIFFtagID)
}
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tif_dir.h,v 1.28 2005/12/26 14:31:25 dron Exp $ */
/* $Id: tif_dir.h,v 1.30.2.3 2010-06-09 21:15:27 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -38,44 +38,48 @@ typedef struct {
/* 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, 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;
tstrip_t td_stripsperimage;
tstrip_t td_nstrips; /* size of offset & bytecount arrays */
uint32* td_stripoffset;
uint32* td_stripbytecount;
int td_stripbytecountsorted; /* is the bytecount array sorted ascending? */
uint16 td_nsubifd;
uint32* td_subifd;
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, 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 */
tstrile_t td_stripsperimage;
tstrile_t td_nstrips; /* size of offset & bytecount arrays */
toff_t* td_stripoffset;
toff_t* td_stripbytecount; /* FIXME: it should be tsize_t array */
int td_stripbytecountsorted; /* is the bytecount array sorted ascending? */
uint16 td_nsubifd;
uint32* td_subifd;
/* YCbCr parameters */
uint16 td_ycbcrsubsampling[2];
uint16 td_ycbcrpositioning;
uint16 td_ycbcrsubsampling[2];
uint16 td_ycbcrpositioning;
/* Colorimetry parameters */
uint16* td_transferfunction[3];
float* td_refblackwhite;
uint16* td_transferfunction[3];
/* CMYK parameters */
int td_inknameslen;
char* td_inknames;
int td_inknameslen;
char* td_inknames;
int td_customValueCount;
TIFFTagValue *td_customValues;
@ -130,6 +134,7 @@ typedef struct {
#define FIELD_HALFTONEHINTS 37
#define FIELD_YCBCRSUBSAMPLING 39
#define FIELD_YCBCRPOSITIONING 40
#define FIELD_REFBLACKWHITE 41
#define FIELD_TRANSFERFUNCTION 44
#define FIELD_INKNAMES 46
#define FIELD_SUBIFD 49
@ -177,6 +182,7 @@ extern "C" {
extern const TIFFFieldInfo *_TIFFGetFieldInfo(size_t *);
extern const TIFFFieldInfo *_TIFFGetExifFieldInfo(size_t *);
extern void _TIFFSetupFieldInfo(TIFF*, const TIFFFieldInfo[], size_t);
extern int _TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], int);
extern void _TIFFPrintFieldInfo(TIFF*, FILE*);
extern TIFFDataType _TIFFSampleToTagType(TIFF*);
extern const TIFFFieldInfo* _TIFFFindOrRegisterFieldInfo( TIFF *tif,
@ -185,7 +191,6 @@ extern const TIFFFieldInfo* _TIFFFindOrRegisterFieldInfo( TIFF *tif,
extern TIFFFieldInfo* _TIFFCreateAnonFieldInfo( TIFF *tif, ttag_t tag,
TIFFDataType dt );
#define _TIFFMergeFieldInfo TIFFMergeFieldInfo
#define _TIFFFindFieldInfo TIFFFindFieldInfo
#define _TIFFFindFieldInfoByName TIFFFindFieldInfoByName
#define _TIFFFieldWithTag TIFFFieldWithTag
@ -197,3 +202,10 @@ extern TIFFFieldInfo* _TIFFCreateAnonFieldInfo( TIFF *tif, ttag_t tag,
#endif /* _TIFFDIR_ */
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tif_dirinfo.c,v 1.62 2006/02/07 10:45:38 dron Exp $ */
/* $Id: tif_dirinfo.c,v 1.65.2.10 2010-07-06 14:14:41 dron Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -31,6 +31,7 @@
*/
#include "tiffiop.h"
#include <stdlib.h>
#include <string.h>
/*
* NB: NB: THIS ARRAY IS ASSUMED TO BE SORTED BY TAG.
@ -216,10 +217,10 @@ tiffFieldInfo[] = {
0, 0, "YCbCrSubsampling" },
{ TIFFTAG_YCBCRPOSITIONING, 1, 1, TIFF_SHORT, FIELD_YCBCRPOSITIONING,
0, 0, "YCbCrPositioning" },
{ TIFFTAG_REFERENCEBLACKWHITE, 6, 6, TIFF_RATIONAL, FIELD_CUSTOM,
{ TIFFTAG_REFERENCEBLACKWHITE, 6, 6, TIFF_RATIONAL, FIELD_REFBLACKWHITE,
1, 0, "ReferenceBlackWhite" },
/* XXX temporarily accept LONG for backwards compatibility */
{ TIFFTAG_REFERENCEBLACKWHITE, 6, 6, TIFF_LONG, FIELD_CUSTOM,
{ TIFFTAG_REFERENCEBLACKWHITE, 6, 6, TIFF_LONG, FIELD_REFBLACKWHITE,
1, 0, "ReferenceBlackWhite" },
{ TIFFTAG_XMLPACKET, -3,-3, TIFF_BYTE, FIELD_CUSTOM,
0, 1, "XMLPacket" },
@ -449,6 +450,8 @@ exifFieldInfo[] = {
1, 0, "SubSecTimeDigitized" },
{ EXIFTAG_FLASHPIXVERSION, 4, 4, TIFF_UNDEFINED, FIELD_CUSTOM,
1, 0, "FlashpixVersion" },
{ EXIFTAG_COLORSPACE, 1, 1, TIFF_SHORT, FIELD_CUSTOM,
1, 0, "ColorSpace" },
{ EXIFTAG_PIXELXDIMENSION, 1, 1, TIFF_LONG, FIELD_CUSTOM,
1, 0, "PixelXDimension" },
{ EXIFTAG_PIXELXDIMENSION, 1, 1, TIFF_SHORT, FIELD_CUSTOM,
@ -542,7 +545,11 @@ _TIFFSetupFieldInfo(TIFF* tif, const TIFFFieldInfo info[], size_t n)
_TIFFfree(tif->tif_fieldinfo);
tif->tif_nfields = 0;
}
_TIFFMergeFieldInfo(tif, info, n);
if (!_TIFFMergeFieldInfo(tif, info, n))
{
TIFFErrorExt(tif->tif_clientdata, "_TIFFSetupFieldInfo",
"Setting up field info failed");
}
}
static int
@ -552,9 +559,10 @@ tagCompare(const void* a, const void* b)
const TIFFFieldInfo* tb = *(const TIFFFieldInfo**) b;
/* NB: be careful of return values for 16-bit platforms */
if (ta->field_tag != tb->field_tag)
return (ta->field_tag < tb->field_tag ? -1 : 1);
return (int)ta->field_tag - (int)tb->field_tag;
else
return ((int)tb->field_type - (int)ta->field_type);
return (ta->field_type == TIFF_ANY) ?
0 : ((int)tb->field_type - (int)ta->field_type);
}
static int
@ -562,13 +570,30 @@ tagNameCompare(const void* a, const void* b)
{
const TIFFFieldInfo* ta = *(const TIFFFieldInfo**) a;
const TIFFFieldInfo* tb = *(const TIFFFieldInfo**) b;
int ret = strcmp(ta->field_name, tb->field_name);
return strcmp(ta->field_name, tb->field_name);
if (ret)
return ret;
else
return (ta->field_type == TIFF_ANY) ?
0 : ((int)tb->field_type - (int)ta->field_type);
}
void
TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], int n)
{
if (_TIFFMergeFieldInfo(tif, info, n) < 0)
{
TIFFErrorExt(tif->tif_clientdata, "TIFFMergeFieldInfo",
"Merging block of %d fields failed", n);
}
}
int
_TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], int n)
{
static const char module[] = "_TIFFMergeFieldInfo";
static const char reason[] = "for field info array";
TIFFFieldInfo** tp;
int i;
@ -576,20 +601,37 @@ _TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], int n)
if (tif->tif_nfields > 0) {
tif->tif_fieldinfo = (TIFFFieldInfo**)
_TIFFrealloc(tif->tif_fieldinfo,
(tif->tif_nfields+n) * sizeof (TIFFFieldInfo*));
_TIFFCheckRealloc(tif, tif->tif_fieldinfo,
(tif->tif_nfields + n),
sizeof (TIFFFieldInfo*), reason);
} else {
tif->tif_fieldinfo = (TIFFFieldInfo**)
_TIFFmalloc(n * sizeof (TIFFFieldInfo*));
_TIFFCheckMalloc(tif, n, sizeof (TIFFFieldInfo*),
reason);
}
if (!tif->tif_fieldinfo) {
TIFFErrorExt(tif->tif_clientdata, module,
"Failed to allocate field info array");
return 0;
}
assert(tif->tif_fieldinfo != NULL);
tp = tif->tif_fieldinfo + tif->tif_nfields;
for (i = 0; i < n; i++)
*tp++ = (TIFFFieldInfo*) (info + i); /* XXX */
{
const TIFFFieldInfo *fip =
_TIFFFindFieldInfo(tif, info[i].field_tag, info[i].field_type);
/* only add definitions that aren't already present */
if (!fip) {
*tp++ = (TIFFFieldInfo*) (info + i);
tif->tif_nfields++;
}
}
/* Sort the field info by tag number */
qsort(tif->tif_fieldinfo, tif->tif_nfields += n,
qsort(tif->tif_fieldinfo, tif->tif_nfields,
sizeof (TIFFFieldInfo*), tagCompare);
return n;
}
void
@ -704,67 +746,58 @@ _TIFFSampleToTagType(TIFF* tif)
const TIFFFieldInfo*
_TIFFFindFieldInfo(TIFF* tif, ttag_t tag, TIFFDataType dt)
{
int i, n;
TIFFFieldInfo key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0};
TIFFFieldInfo* pkey = &key;
const TIFFFieldInfo **ret;
if (tif->tif_foundfield && tif->tif_foundfield->field_tag == tag &&
(dt == TIFF_ANY || dt == tif->tif_foundfield->field_type))
return (tif->tif_foundfield);
/* NB: use sorted search (e.g. binary search) */
if(dt != TIFF_ANY) {
TIFFFieldInfo key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0};
TIFFFieldInfo* pkey = &key;
const TIFFFieldInfo **ret;
return tif->tif_foundfield;
key.field_tag = tag;
key.field_type = dt;
ret = (const TIFFFieldInfo **) bsearch(&pkey,
tif->tif_fieldinfo,
tif->tif_nfields,
sizeof(TIFFFieldInfo *),
tagCompare);
return (ret) ? (*ret) : NULL;
} else for (i = 0, n = tif->tif_nfields; i < n; i++) {
const TIFFFieldInfo* fip = tif->tif_fieldinfo[i];
if (fip->field_tag == tag &&
(dt == TIFF_ANY || fip->field_type == dt))
return (tif->tif_foundfield = fip);
/* If we are invoked with no field information, then just return. */
if ( !tif->tif_fieldinfo ) {
return NULL;
}
return ((const TIFFFieldInfo *)0);
/* NB: use sorted search (e.g. binary search) */
key.field_tag = tag;
key.field_type = dt;
ret = (const TIFFFieldInfo **) bsearch(&pkey,
tif->tif_fieldinfo,
tif->tif_nfields,
sizeof(TIFFFieldInfo *),
tagCompare);
return tif->tif_foundfield = (ret ? *ret : NULL);
}
const TIFFFieldInfo*
_TIFFFindFieldInfoByName(TIFF* tif, const char *field_name, TIFFDataType dt)
{
int i, n;
TIFFFieldInfo key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0};
TIFFFieldInfo* pkey = &key;
const TIFFFieldInfo **ret;
if (tif->tif_foundfield
&& streq(tif->tif_foundfield->field_name, field_name)
&& (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type))
return (tif->tif_foundfield);
/* If we are invoked with no field information, then just return. */
if ( !tif->tif_fieldinfo ) {
return NULL;
}
/* NB: use sorted search (e.g. binary search) */
if(dt != TIFF_ANY) {
TIFFFieldInfo key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0};
TIFFFieldInfo* pkey = &key;
const TIFFFieldInfo **ret;
key.field_name = (char *)field_name;
key.field_type = dt;
key.field_name = (char *)field_name;
key.field_type = dt;
ret = (const TIFFFieldInfo **) lfind(&pkey,
tif->tif_fieldinfo,
&tif->tif_nfields,
sizeof(TIFFFieldInfo *),
tagNameCompare);
return (ret) ? (*ret) : NULL;
} else
for (i = 0, n = tif->tif_nfields; i < n; i++) {
const TIFFFieldInfo* fip = tif->tif_fieldinfo[i];
if (streq(fip->field_name, field_name) &&
(dt == TIFF_ANY || fip->field_type == dt))
return (tif->tif_foundfield = fip);
}
return ((const TIFFFieldInfo *)0);
ret = (const TIFFFieldInfo **) lfind(&pkey,
tif->tif_fieldinfo,
&tif->tif_nfields,
sizeof(TIFFFieldInfo *),
tagNameCompare);
return tif->tif_foundfield = (ret ? *ret : NULL);
}
const TIFFFieldInfo*
@ -773,10 +806,8 @@ _TIFFFieldWithTag(TIFF* tif, ttag_t tag)
const TIFFFieldInfo* fip = _TIFFFindFieldInfo(tif, tag, TIFF_ANY);
if (!fip) {
TIFFErrorExt(tif->tif_clientdata, "TIFFFieldWithTag",
"Internal error, unknown tag 0x%x",
(unsigned int) tag);
assert(fip != NULL);
/*NOTREACHED*/
"Internal error, unknown tag 0x%x",
(unsigned int) tag);
}
return (fip);
}
@ -788,9 +819,7 @@ _TIFFFieldWithName(TIFF* tif, const char *field_name)
_TIFFFindFieldInfoByName(tif, field_name, TIFF_ANY);
if (!fip) {
TIFFErrorExt(tif->tif_clientdata, "TIFFFieldWithName",
"Internal error, unknown tag %s", field_name);
assert(fip != NULL);
/*NOTREACHED*/
"Internal error, unknown tag %s", field_name);
}
return (fip);
}
@ -805,7 +834,8 @@ _TIFFFindOrRegisterFieldInfo( TIFF *tif, ttag_t tag, TIFFDataType dt )
if( fld == NULL )
{
fld = _TIFFCreateAnonFieldInfo( tif, tag, dt );
_TIFFMergeFieldInfo( tif, fld, 1 );
if (!_TIFFMergeFieldInfo(tif, fld, 1))
return NULL;
}
return fld;
@ -823,8 +853,8 @@ _TIFFCreateAnonFieldInfo(TIFF *tif, ttag_t tag, TIFFDataType field_type)
_TIFFmemset( fld, 0, sizeof(TIFFFieldInfo) );
fld->field_tag = tag;
fld->field_readcount = TIFF_VARIABLE;
fld->field_writecount = TIFF_VARIABLE;
fld->field_readcount = TIFF_VARIABLE2;
fld->field_writecount = TIFF_VARIABLE2;
fld->field_type = field_type;
fld->field_bit = FIELD_CUSTOM;
fld->field_oktochange = TRUE;
@ -835,7 +865,8 @@ _TIFFCreateAnonFieldInfo(TIFF *tif, ttag_t tag, TIFFDataType field_type)
return NULL;
}
/* note that this name is a special sign to TIFFClose() and
/*
* note that this name is a special sign to TIFFClose() and
* _TIFFSetupFieldInfo() to free the field
*/
sprintf(fld->field_name, "Tag %d", (int) tag);
@ -844,3 +875,10 @@ _TIFFCreateAnonFieldInfo(TIFF *tif, ttag_t tag, TIFFDataType field_type)
}
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
/* $Id: tif_dirwrite.c,v 1.34 2006/02/23 16:07:45 dron Exp $ */
/* $Id: tif_dirwrite.c,v 1.37.2.9 2011-02-25 15:28:30 dron Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -42,6 +42,7 @@ extern void TIFFCvtNativeToIEEEDouble(TIFF*, uint32, double*);
static int TIFFWriteNormalTag(TIFF*, TIFFDirEntry*, const TIFFFieldInfo*);
static void TIFFSetupShortLong(TIFF*, ttag_t, TIFFDirEntry*, uint32);
static void TIFFSetupShort(TIFF*, ttag_t, TIFFDirEntry*, uint16);
static int TIFFSetupBytePair(TIFF*, ttag_t, TIFFDirEntry*);
static int TIFFSetupShortPair(TIFF*, ttag_t, TIFFDirEntry*);
static int TIFFWritePerSampleShorts(TIFF*, ttag_t, TIFFDirEntry*);
static int TIFFWritePerSampleAnys(TIFF*, TIFFDataType, ttag_t, TIFFDirEntry*);
@ -100,31 +101,34 @@ _TIFFWriteDirectory(TIFF* tif, int done)
*/
if (done)
{
if (tif->tif_flags & TIFF_POSTENCODE) {
tif->tif_flags &= ~TIFF_POSTENCODE;
if (!(*tif->tif_postencode)(tif)) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
if (tif->tif_flags & TIFF_POSTENCODE) {
tif->tif_flags &= ~TIFF_POSTENCODE;
if (!(*tif->tif_postencode)(tif)) {
TIFFErrorExt(tif->tif_clientdata,
tif->tif_name,
"Error post-encoding before directory write");
return (0);
}
}
(*tif->tif_close)(tif); /* shutdown encoder */
/*
* Flush any data that might have been written
* by the compression close+cleanup routines.
*/
if (tif->tif_rawcc > 0 && !TIFFFlushData1(tif)) {
return (0);
}
}
(*tif->tif_close)(tif); /* shutdown encoder */
/*
* Flush any data that might have been written
* by the compression close+cleanup routines.
*/
if (tif->tif_rawcc > 0
&& (tif->tif_flags & TIFF_BEENWRITING) != 0
&& !TIFFFlushData1(tif)) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"Error flushing data before directory write");
return (0);
}
if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) {
_TIFFfree(tif->tif_rawdata);
tif->tif_rawdata = NULL;
tif->tif_rawcc = 0;
tif->tif_rawdatasize = 0;
}
tif->tif_flags &= ~(TIFF_BEENWRITING|TIFF_BUFFERSETUP);
"Error flushing data before directory write");
return (0);
}
if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) {
_TIFFfree(tif->tif_rawdata);
tif->tif_rawdata = NULL;
tif->tif_rawcc = 0;
tif->tif_rawdatasize = 0;
}
tif->tif_flags &= ~(TIFF_BEENWRITING|TIFF_BUFFERSETUP);
}
td = &tif->tif_dir;
@ -137,12 +141,12 @@ _TIFFWriteDirectory(TIFF* tif, int done)
for (b = 0; b <= FIELD_LAST; b++)
if (TIFFFieldSet(tif, b) && b != FIELD_CUSTOM)
nfields += (b < FIELD_SUBFILETYPE ? 2 : 1);
nfields += td->td_customValueCount;
nfields += td->td_customValueCount;
dirsize = nfields * sizeof (TIFFDirEntry);
data = (char*) _TIFFmalloc(dirsize);
if (data == NULL) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"Cannot write directory, out of space");
"Cannot write directory, out of space");
return (0);
}
/*
@ -176,30 +180,29 @@ _TIFFWriteDirectory(TIFF* tif, int done)
for (fi = 0, nfi = tif->tif_nfields; nfi > 0; nfi--, fi++) {
const TIFFFieldInfo* fip = tif->tif_fieldinfo[fi];
/*
** For custom fields, we test to see if the custom field
** is set or not. For normal fields, we just use the
** FieldSet test.
*/
if( fip->field_bit == FIELD_CUSTOM )
{
int ci, is_set = FALSE;
/*
* For custom fields, we test to see if the custom field
* is set or not. For normal fields, we just use the
* FieldSet test.
*/
if( fip->field_bit == FIELD_CUSTOM )
{
int ci, is_set = FALSE;
for( ci = 0; ci < td->td_customValueCount; ci++ )
is_set |= (td->td_customValues[ci].info == fip);
for( ci = 0; ci < td->td_customValueCount; ci++ )
is_set |= (td->td_customValues[ci].info == fip);
if( !is_set )
continue;
}
if( !is_set )
continue;
}
else if (!FieldSet(fields, fip->field_bit))
continue;
continue;
/*
** Handle other fields.
*/
/*
* Handle other fields.
*/
switch (fip->field_bit)
{
{
case FIELD_STRIPOFFSETS:
/*
* We use one field bit for both strip and tile
@ -234,8 +237,7 @@ _TIFFWriteDirectory(TIFF* tif, int done)
dir->tdir_tag = (uint16) tag;
dir->tdir_type = (uint16) TIFF_LONG;
dir->tdir_count = (uint32) td->td_nstrips;
if (!TIFFWriteLongArray(tif, dir,
td->td_stripbytecount))
if (!TIFFWriteLongArray(tif, dir, td->td_stripbytecount))
goto bad;
break;
case FIELD_ROWSPERSTRIP:
@ -290,12 +292,6 @@ _TIFFWriteDirectory(TIFF* tif, int done)
_TIFFSampleToTagType(tif), fip->field_tag, dir))
goto bad;
break;
case FIELD_PAGENUMBER:
case FIELD_HALFTONEHINTS:
case FIELD_YCBCRSUBSAMPLING:
if (!TIFFSetupShortPair(tif, fip->field_tag, dir))
goto bad;
break;
case FIELD_INKNAMES:
if (!TIFFWriteInkNames(tif, dir))
goto bad;
@ -335,19 +331,29 @@ _TIFFWriteDirectory(TIFF* tif, int done)
}
break;
default:
/* XXX: Should be fixed and removed. */
if (fip->field_tag == TIFFTAG_DOTRANGE) {
if (!TIFFSetupShortPair(tif, fip->field_tag, dir))
goto bad;
}
else if (!TIFFWriteNormalTag(tif, dir, fip))
/*
* XXX: Should be fixed and removed. See comments
* related to these tags in tif_dir.c.
*/
if (fip->field_tag == TIFFTAG_PAGENUMBER
|| fip->field_tag == TIFFTAG_HALFTONEHINTS
|| fip->field_tag == TIFFTAG_YCBCRSUBSAMPLING
|| fip->field_tag == TIFFTAG_DOTRANGE) {
if (fip->field_type == TIFF_BYTE) {
if (!TIFFSetupBytePair(tif, fip->field_tag, dir))
goto bad;
} else if (fip->field_type == TIFF_SHORT) {
if (!TIFFSetupShortPair(tif, fip->field_tag, dir))
goto bad;
}
} else if (!TIFFWriteNormalTag(tif, dir, fip))
goto bad;
break;
}
dir++;
if( fip->field_bit != FIELD_CUSTOM )
ResetFieldBit(fields, fip->field_bit);
if( fip->field_bit != FIELD_CUSTOM )
ResetFieldBit(fields, fip->field_bit);
}
/*
@ -376,15 +382,18 @@ _TIFFWriteDirectory(TIFF* tif, int done)
}
(void) TIFFSeekFile(tif, tif->tif_diroff, SEEK_SET);
if (!WriteOK(tif, &dircount, sizeof (dircount))) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Error writing directory count");
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"Error writing directory count");
goto bad;
}
if (!WriteOK(tif, data, dirsize)) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Error writing directory contents");
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"Error writing directory contents");
goto bad;
}
if (!WriteOK(tif, &diroff, sizeof (diroff))) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Error writing directory link");
if (!WriteOK(tif, &diroff, sizeof (uint32))) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"Error writing directory link");
goto bad;
}
if (done) {
@ -430,6 +439,133 @@ TIFFCheckpointDirectory(TIFF* tif)
return rc;
}
static int
_TIFFWriteCustomDirectory(TIFF* tif, toff_t *pdiroff)
{
uint16 dircount;
uint32 nfields;
tsize_t dirsize;
char* data;
TIFFDirEntry* dir;
TIFFDirectory* td;
unsigned long b, fields[FIELD_SETLONGS];
int fi, nfi;
if (tif->tif_mode == O_RDONLY)
return (1);
td = &tif->tif_dir;
/*
* Size the directory so that we can calculate
* offsets for the data items that aren't kept
* in-place in each field.
*/
nfields = 0;
for (b = 0; b <= FIELD_LAST; b++)
if (TIFFFieldSet(tif, b) && b != FIELD_CUSTOM)
nfields += (b < FIELD_SUBFILETYPE ? 2 : 1);
nfields += td->td_customValueCount;
dirsize = nfields * sizeof (TIFFDirEntry);
data = (char*) _TIFFmalloc(dirsize);
if (data == NULL) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"Cannot write directory, out of space");
return (0);
}
/*
* Put the directory at the end of the file.
*/
tif->tif_diroff = (TIFFSeekFile(tif, (toff_t) 0, SEEK_END)+1) &~ 1;
tif->tif_dataoff = (toff_t)(
tif->tif_diroff + sizeof (uint16) + dirsize + sizeof (toff_t));
if (tif->tif_dataoff & 1)
tif->tif_dataoff++;
(void) TIFFSeekFile(tif, tif->tif_dataoff, SEEK_SET);
dir = (TIFFDirEntry*) data;
/*
* Setup external form of directory
* entries and write data items.
*/
_TIFFmemcpy(fields, td->td_fieldsset, sizeof (fields));
for (fi = 0, nfi = tif->tif_nfields; nfi > 0; nfi--, fi++) {
const TIFFFieldInfo* fip = tif->tif_fieldinfo[fi];
/*
* For custom fields, we test to see if the custom field
* is set or not. For normal fields, we just use the
* FieldSet test.
*/
if( fip->field_bit == FIELD_CUSTOM )
{
int ci, is_set = FALSE;
for( ci = 0; ci < td->td_customValueCount; ci++ )
is_set |= (td->td_customValues[ci].info == fip);
if( !is_set )
continue;
}
else if (!FieldSet(fields, fip->field_bit))
continue;
if( fip->field_bit != FIELD_CUSTOM )
ResetFieldBit(fields, fip->field_bit);
}
/*
* Write directory.
*/
dircount = (uint16) nfields;
*pdiroff = (uint32) tif->tif_nextdiroff;
if (tif->tif_flags & TIFF_SWAB) {
/*
* The file's byte order is opposite to the
* native machine architecture. We overwrite
* the directory information with impunity
* because it'll be released below after we
* write it to the file. Note that all the
* other tag construction routines assume that
* we do this byte-swapping; i.e. they only
* byte-swap indirect data.
*/
for (dir = (TIFFDirEntry*) data; dircount; dir++, dircount--) {
TIFFSwabArrayOfShort(&dir->tdir_tag, 2);
TIFFSwabArrayOfLong(&dir->tdir_count, 2);
}
dircount = (uint16) nfields;
TIFFSwabShort(&dircount);
TIFFSwabLong(pdiroff);
}
(void) TIFFSeekFile(tif, tif->tif_diroff, SEEK_SET);
if (!WriteOK(tif, &dircount, sizeof (dircount))) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"Error writing directory count");
goto bad;
}
if (!WriteOK(tif, data, dirsize)) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"Error writing directory contents");
goto bad;
}
if (!WriteOK(tif, pdiroff, sizeof (uint32))) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"Error writing directory link");
goto bad;
}
_TIFFfree(data);
return (1);
bad:
_TIFFfree(data);
return (0);
}
int
TIFFWriteCustomDirectory(TIFF* tif, toff_t *pdiroff)
{
return _TIFFWriteCustomDirectory(tif, pdiroff);
}
/*
* Process tags that are not special cased.
*/
@ -581,7 +717,12 @@ TIFFWriteNormalTag(TIFF* tif, TIFFDirEntry* dir, const TIFFFieldInfo* fip)
{
char* cp;
if (fip->field_passcount)
TIFFGetField(tif, fip->field_tag, &wc, &cp);
{
if( wc == (uint16) TIFF_VARIABLE2 )
TIFFGetField(tif, fip->field_tag, &wc2, &cp);
else
TIFFGetField(tif, fip->field_tag, &wc, &cp);
}
else
TIFFGetField(tif, fip->field_tag, &cp);
@ -739,6 +880,23 @@ TIFFWritePerSampleAnys(TIFF* tif,
}
#undef NITEMS
/*
* Setup a pair of bytes that are returned by
* value, rather than as a reference to an array.
*/
static int
TIFFSetupBytePair(TIFF* tif, ttag_t tag, TIFFDirEntry* dir)
{
char v[2];
TIFFGetField(tif, tag, &v[0], &v[1]);
dir->tdir_tag = (uint16) tag;
dir->tdir_type = (uint16) TIFF_BYTE;
dir->tdir_count = 2;
return (TIFFWriteByteArray(tif, dir, v));
}
/*
* Setup a pair of shorts that are returned by
* value, rather than as a reference to an array.
@ -786,12 +944,27 @@ TIFFWriteShortTable(TIFF* tif,
static int
TIFFWriteByteArray(TIFF* tif, TIFFDirEntry* dir, char* cp)
{
if (dir->tdir_count > 4) {
if (!TIFFWriteData(tif, dir, cp))
return (0);
if (dir->tdir_count <= 4) {
if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) {
dir->tdir_offset = (uint32)cp[0] << 24;
if (dir->tdir_count >= 2)
dir->tdir_offset |= (uint32)cp[1] << 16;
if (dir->tdir_count >= 3)
dir->tdir_offset |= (uint32)cp[2] << 8;
if (dir->tdir_count == 4)
dir->tdir_offset |= cp[3];
} else {
dir->tdir_offset = cp[0];
if (dir->tdir_count >= 2)
dir->tdir_offset |= (uint32) cp[1] << 8;
if (dir->tdir_count >= 3)
dir->tdir_offset |= (uint32) cp[2] << 16;
if (dir->tdir_count == 4)
dir->tdir_offset |= (uint32) cp[3] << 24;
}
return 1;
} else
_TIFFmemcpy(&dir->tdir_offset, cp, dir->tdir_count);
return (1);
return TIFFWriteData(tif, dir, cp);
}
/*
@ -803,13 +976,13 @@ TIFFWriteShortArray(TIFF* tif, TIFFDirEntry* dir, uint16* v)
{
if (dir->tdir_count <= 2) {
if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) {
dir->tdir_offset = (uint32) ((long) v[0] << 16);
dir->tdir_offset = (uint32) v[0] << 16;
if (dir->tdir_count == 2)
dir->tdir_offset |= v[1] & 0xffff;
} else {
dir->tdir_offset = v[0] & 0xffff;
if (dir->tdir_count == 2)
dir->tdir_offset |= (long) v[1] << 16;
dir->tdir_offset |= (uint32) v[1] << 16;
}
return (1);
} else
@ -854,10 +1027,11 @@ TIFFWriteRationalArray(TIFF* tif, TIFFDirEntry* dir, float* v)
if (fv < 0) {
if (dir->tdir_type == TIFF_RATIONAL) {
TIFFWarningExt(tif->tif_clientdata, tif->tif_name,
TIFFWarningExt(tif->tif_clientdata,
tif->tif_name,
"\"%s\": Information lost writing value (%g) as (unsigned) RATIONAL",
_TIFFFieldWithTag(tif,dir->tdir_tag)->field_name,
fv);
fv);
fv = 0;
} else
fv = -fv, sign = -1;
@ -867,7 +1041,7 @@ TIFFWriteRationalArray(TIFF* tif, TIFFDirEntry* dir, float* v)
while (fv < 1L<<(31-3) && den < 1L<<(31-3))
fv *= 1<<3, den *= 1L<<3;
}
t[2*i+0] = (uint32) (sign * (fv + 0.5));
t[2*i+0] = (uint32) (sign * (int32)(fv + 0.5));
t[2*i+1] = den;
}
status = TIFFWriteData(tif, dir, (char *)t);
@ -914,7 +1088,7 @@ TIFFWriteAnyArray(TIFF* tif,
w = (char*) _TIFFmalloc(n * TIFFDataWidth(type));
if (w == NULL) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"No space to write array");
"No space to write array");
return (0);
}
}
@ -988,7 +1162,11 @@ TIFFWriteAnyArray(TIFF* tif,
}
break;
case TIFF_DOUBLE:
return (TIFFWriteDoubleArray(tif, dir, v));
{
if( !TIFFWriteDoubleArray(tif, dir, v))
goto out;
}
break;
default:
/* TIFF_NOTYPE */
/* TIFF_ASCII */
@ -1073,8 +1251,9 @@ TIFFWriteData(TIFF* tif, TIFFDirEntry* dir, char* cp)
tif->tif_dataoff += (cc + 1) & ~1;
return (1);
}
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Error writing data for field \"%s\"",
_TIFFFieldWithTag(tif, dir->tdir_tag)->field_name);
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"Error writing data for field \"%s\"",
_TIFFFieldWithTag(tif, dir->tdir_tag)->field_name);
return (0);
}
@ -1110,7 +1289,8 @@ TIFFRewriteDirectory( TIFF *tif )
if (!WriteOK(tif, &(tif->tif_header.tiff_diroff),
sizeof (tif->tif_diroff)))
{
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Error updating TIFF header");
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"Error updating TIFF header");
return (0);
}
}
@ -1124,7 +1304,8 @@ TIFFRewriteDirectory( TIFF *tif )
if (!SeekOK(tif, nextdir) ||
!ReadOK(tif, &dircount, sizeof (dircount))) {
TIFFErrorExt(tif->tif_clientdata, module, "Error fetching directory count");
TIFFErrorExt(tif->tif_clientdata, module,
"Error fetching directory count");
return (0);
}
if (tif->tif_flags & TIFF_SWAB)
@ -1132,7 +1313,8 @@ TIFFRewriteDirectory( TIFF *tif )
(void) TIFFSeekFile(tif,
dircount * sizeof (TIFFDirEntry), SEEK_CUR);
if (!ReadOK(tif, &nextdir, sizeof (nextdir))) {
TIFFErrorExt(tif->tif_clientdata, module, "Error fetching directory link");
TIFFErrorExt(tif->tif_clientdata, module,
"Error fetching directory link");
return (0);
}
if (tif->tif_flags & TIFF_SWAB)
@ -1142,7 +1324,8 @@ TIFFRewriteDirectory( TIFF *tif )
(void) TIFFSeekFile(tif, off - (toff_t)sizeof(nextdir), SEEK_SET);
tif->tif_diroff = 0;
if (!WriteOK(tif, &(tif->tif_diroff), sizeof (nextdir))) {
TIFFErrorExt(tif->tif_clientdata, module, "Error writing directory link");
TIFFErrorExt(tif->tif_clientdata, module,
"Error writing directory link");
return (0);
}
}
@ -1156,8 +1339,7 @@ TIFFRewriteDirectory( TIFF *tif )
/*
* Link the current directory into the
* directory chain for the file.
* Link the current directory into the directory chain for the file.
*/
static int
TIFFLinkDirectory(TIFF* tif)
@ -1178,8 +1360,8 @@ TIFFLinkDirectory(TIFF* tif)
(void) TIFFSeekFile(tif, tif->tif_subifdoff, SEEK_SET);
if (!WriteOK(tif, &diroff, sizeof (diroff))) {
TIFFErrorExt(tif->tif_clientdata, module,
"%s: Error writing SubIFD directory link",
tif->tif_name);
"%s: Error writing SubIFD directory link",
tif->tif_name);
return (0);
}
/*
@ -1203,7 +1385,8 @@ TIFFLinkDirectory(TIFF* tif)
(toff_t)(TIFF_MAGIC_SIZE+TIFF_VERSION_SIZE),
SEEK_SET);
if (!WriteOK(tif, &diroff, sizeof (diroff))) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Error writing TIFF header");
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"Error writing TIFF header");
return (0);
}
return (1);
@ -1217,7 +1400,8 @@ TIFFLinkDirectory(TIFF* tif)
if (!SeekOK(tif, nextdir) ||
!ReadOK(tif, &dircount, sizeof (dircount))) {
TIFFErrorExt(tif->tif_clientdata, module, "Error fetching directory count");
TIFFErrorExt(tif->tif_clientdata, module,
"Error fetching directory count");
return (0);
}
if (tif->tif_flags & TIFF_SWAB)
@ -1225,7 +1409,8 @@ TIFFLinkDirectory(TIFF* tif)
(void) TIFFSeekFile(tif,
dircount * sizeof (TIFFDirEntry), SEEK_CUR);
if (!ReadOK(tif, &nextdir, sizeof (nextdir))) {
TIFFErrorExt(tif->tif_clientdata, module, "Error fetching directory link");
TIFFErrorExt(tif->tif_clientdata, module,
"Error fetching directory link");
return (0);
}
if (tif->tif_flags & TIFF_SWAB)
@ -1234,10 +1419,18 @@ TIFFLinkDirectory(TIFF* tif)
off = TIFFSeekFile(tif, 0, SEEK_CUR); /* get current offset */
(void) TIFFSeekFile(tif, off - (toff_t)sizeof(nextdir), SEEK_SET);
if (!WriteOK(tif, &diroff, sizeof (diroff))) {
TIFFErrorExt(tif->tif_clientdata, module, "Error writing directory link");
TIFFErrorExt(tif->tif_clientdata, module,
"Error writing directory link");
return (0);
}
return (1);
}
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dumpmode.c,v 1.4 2005/12/21 12:23:13 joris Exp $ */
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dumpmode.c,v 1.5.2.2 2010-06-08 18:50:42 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -45,7 +45,7 @@ DumpModeEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s)
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
@ -71,6 +71,8 @@ static int
DumpModeDecode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s)
{
(void) s;
/* fprintf(stderr,"DumpModeDecode: scanline %ld, expected %ld bytes, got %ld bytes\n", */
/* (long) tif->tif_row, (long) tif->tif_rawcc, (long) cc); */
if (tif->tif_rawcc < cc) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"DumpModeDecode: Not enough data for scanline %d",
@ -115,3 +117,10 @@ TIFFInitDumpMode(TIFF* tif, int scheme)
tif->tif_seek = DumpModeSeek;
return (1);
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_error.c,v 1.4 2005/12/23 01:18:59 joris Exp $ */
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_error.c,v 1.4.2.1 2010-06-08 18:50:42 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -71,3 +71,10 @@ TIFFErrorExt(thandle_t fd, const char* module, const char* fmt, ...)
va_end(ap);
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_extension.c,v 1.4 2004/10/02 13:29:41 dron Exp $ */
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_extension.c,v 1.4.2.1 2010-06-08 18:50:42 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -109,3 +109,10 @@ void TIFFSetClientInfo( TIFF *tif, void *data, const char *name )
tif->tif_clientinfo = link;
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tif_fax3.c,v 1.40 2006/03/16 12:38:24 dron Exp $ */
/* $Id: tif_fax3.c,v 1.43.2.10 2010-06-09 17:16:58 bfriesen Exp $ */
/*
* Copyright (c) 1990-1997 Sam Leffler
@ -63,6 +63,7 @@ typedef struct {
char* faxdcs; /* Table 2/T.30 encoded session params */
TIFFVGetMethod vgetparent; /* super-class method */
TIFFVSetMethod vsetparent; /* super-class method */
TIFFPrintMethod printdir; /* super-class method */
} Fax3BaseState;
#define Fax3State(tif) ((Fax3BaseState*) (tif)->tif_data)
@ -85,6 +86,8 @@ typedef struct {
unsigned char* refline; /* reference line for 2d decoding */
int k; /* #rows left that can be 2d encoded */
int maxk; /* max #rows that can be 2d encoded */
int line;
} Fax3CodecState;
#define DecoderState(tif) ((Fax3CodecState*) Fax3State(tif))
#define EncoderState(tif) ((Fax3CodecState*) Fax3State(tif))
@ -167,6 +170,7 @@ Fax3PreDecode(TIFF* tif, tsample_t s)
sp->refruns[0] = (uint32) sp->b.rowpixels;
sp->refruns[1] = 0;
}
sp->line = 0;
return (1);
}
@ -179,46 +183,46 @@ Fax3PreDecode(TIFF* tif, tsample_t s)
static void
Fax3Unexpected(const char* module, TIFF* tif, uint32 line, uint32 a0)
{
TIFFErrorExt(tif->tif_clientdata, module, "%s: Bad code word at line %lu of %s %lu (x %lu)",
tif->tif_name, (unsigned long) line, isTiled(tif) ? "tile" : "strip",
(unsigned long) (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip),
(unsigned long) a0);
TIFFErrorExt(tif->tif_clientdata, module, "%s: Bad code word at line %u of %s %u (x %u)",
tif->tif_name, line, isTiled(tif) ? "tile" : "strip",
(isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip),
a0);
}
#define unexpected(table, a0) Fax3Unexpected(module, tif, line, a0)
#define unexpected(table, a0) Fax3Unexpected(module, tif, sp->line, a0)
static void
Fax3Extension(const char* module, TIFF* tif, uint32 line, uint32 a0)
{
TIFFErrorExt(tif->tif_clientdata, module,
"%s: Uncompressed data (not supported) at line %lu of %s %lu (x %lu)",
tif->tif_name, (unsigned long) line, isTiled(tif) ? "tile" : "strip",
(unsigned long) (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip),
(unsigned long) a0);
"%s: Uncompressed data (not supported) at line %u of %s %u (x %u)",
tif->tif_name, line, isTiled(tif) ? "tile" : "strip",
(isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip),
a0);
}
#define extension(a0) Fax3Extension(module, tif, line, a0)
#define extension(a0) Fax3Extension(module, tif, sp->line, a0)
static void
Fax3BadLength(const char* module, TIFF* tif, uint32 line, uint32 a0, uint32 lastx)
{
TIFFWarningExt(tif->tif_clientdata, module, "%s: %s at line %lu of %s %lu (got %lu, expected %lu)",
tif->tif_name,
a0 < lastx ? "Premature EOL" : "Line length mismatch",
(unsigned long) line, isTiled(tif) ? "tile" : "strip",
(unsigned long) (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip),
(unsigned long) a0, lastx);
TIFFWarningExt(tif->tif_clientdata, module, "%s: %s at line %u of %s %u (got %u, expected %u)",
tif->tif_name,
a0 < lastx ? "Premature EOL" : "Line length mismatch",
line, isTiled(tif) ? "tile" : "strip",
(isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip),
a0, lastx);
}
#define badlength(a0,lastx) Fax3BadLength(module, tif, line, a0, lastx)
#define badlength(a0,lastx) Fax3BadLength(module, tif, sp->line, a0, lastx)
static void
Fax3PrematureEOF(const char* module, TIFF* tif, uint32 line, uint32 a0)
{
TIFFWarningExt(tif->tif_clientdata, module, "%s: Premature EOF at line %lu of %s %lu (x %lu)",
TIFFWarningExt(tif->tif_clientdata, module, "%s: Premature EOF at line %u of %s %u (x %u)",
tif->tif_name,
(unsigned long) line, isTiled(tif) ? "tile" : "strip",
(unsigned long) (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip),
(unsigned long) a0);
line, isTiled(tif) ? "tile" : "strip",
(isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip),
a0);
}
#define prematureEOF(a0) Fax3PrematureEOF(module, tif, line, a0)
#define prematureEOF(a0) Fax3PrematureEOF(module, tif, sp->line, a0)
#define Nop
@ -229,7 +233,6 @@ static int
Fax3Decode1D(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s)
{
DECLARE_STATE(tif, sp, "Fax3Decode1D");
int line = 0;
(void) s;
CACHE_STATE(tif, sp);
@ -248,7 +251,7 @@ Fax3Decode1D(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s)
(*sp->fill)(buf, thisrun, pa, lastx);
buf += sp->b.rowbytes;
occ -= sp->b.rowbytes;
line++;
sp->line++;
continue;
EOF1D: /* premature EOF */
CLEANUP_RUNS();
@ -269,7 +272,6 @@ static int
Fax3Decode2D(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s)
{
DECLARE_STATE_2D(tif, sp, "Fax3Decode2D");
int line = 0;
int is1D; /* current line is 1d/2d-encoded */
(void) s;
@ -302,7 +304,7 @@ Fax3Decode2D(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s)
SWAP(uint32*, sp->curruns, sp->refruns);
buf += sp->b.rowbytes;
occ -= sp->b.rowbytes;
line++;
sp->line++;
continue;
EOF2D: /* premature EOF */
CLEANUP_RUNS();
@ -491,15 +493,31 @@ Fax3SetupState(TIFF* tif)
td->td_compression == COMPRESSION_CCITTFAX4
);
nruns = needsRefLine ? 2*TIFFroundup(rowpixels,32) : rowpixels;
dsp->runs = (uint32*) _TIFFCheckMalloc(tif, 2*nruns+3, sizeof (uint32),
"for Group 3/4 run arrays");
/*
Assure that allocation computations do not overflow.
TIFFroundup and TIFFSafeMultiply return zero on integer overflow
*/
dsp->runs=(uint32*) NULL;
nruns = TIFFroundup(rowpixels,32);
if (needsRefLine) {
nruns = TIFFSafeMultiply(uint32,nruns,2);
}
if ((nruns == 0) || (TIFFSafeMultiply(uint32,nruns,2) == 0)) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"Row pixels integer overflow (rowpixels %u)",
rowpixels);
return (0);
}
dsp->runs = (uint32*) _TIFFCheckMalloc(tif,
TIFFSafeMultiply(uint32,nruns,2),
sizeof (uint32),
"for Group 3/4 run arrays");
if (dsp->runs == NULL)
return (0);
dsp->curruns = dsp->runs;
if (needsRefLine)
dsp->refruns = dsp->runs + (nruns>>1);
dsp->refruns = dsp->runs + nruns;
else
dsp->refruns = NULL;
if (td->td_compression == COMPRESSION_CCITTFAX3
@ -718,6 +736,7 @@ Fax3PreEncode(TIFF* tif, tsample_t s)
sp->k = sp->maxk-1;
} else
sp->k = sp->maxk = 0;
sp->line = 0;
return (1);
}
@ -773,7 +792,7 @@ static int32 find1span(unsigned char*, int32, int32);
* table. The ``base'' of the bit string is supplied
* along with the start+end bit indices.
*/
inline static int32
static int32
find0span(unsigned char* bp, int32 bs, int32 be)
{
int32 bits = be - bs;
@ -832,7 +851,7 @@ find0span(unsigned char* bp, int32 bs, int32 be)
return (span);
}
inline static int32
static int32
find1span(unsigned char* bp, int32 bs, int32 be)
{
int32 bits = be - bs;
@ -1074,6 +1093,7 @@ Fax3Cleanup(TIFF* tif)
tif->tif_tagmethods.vgetfield = sp->b.vgetparent;
tif->tif_tagmethods.vsetfield = sp->b.vsetparent;
tif->tif_tagmethods.printdir = sp->b.printdir;
if (sp->runs)
_TIFFfree(sp->runs);
@ -1082,6 +1102,9 @@ Fax3Cleanup(TIFF* tif)
if (Fax3State(tif)->subaddress)
_TIFFfree(Fax3State(tif)->subaddress);
if (Fax3State(tif)->faxdcs)
_TIFFfree(Fax3State(tif)->faxdcs);
_TIFFfree(tif->tif_data);
tif->tif_data = NULL;
@ -1136,6 +1159,7 @@ static int
Fax3VSetField(TIFF* tif, ttag_t tag, va_list ap)
{
Fax3BaseState* sp = Fax3State(tif);
const TIFFFieldInfo* fip;
assert(sp != 0);
assert(sp->vsetparent != 0);
@ -1143,10 +1167,10 @@ Fax3VSetField(TIFF* tif, ttag_t tag, va_list ap)
switch (tag) {
case TIFFTAG_FAXMODE:
sp->mode = va_arg(ap, int);
return (1); /* NB: pseudo tag */
return 1; /* NB: pseudo tag */
case TIFFTAG_FAXFILLFUNC:
DecoderState(tif)->fill = va_arg(ap, TIFFFaxFillFunc);
return (1); /* NB: pseudo tag */
return 1; /* NB: pseudo tag */
case TIFFTAG_GROUP3OPTIONS:
/* XXX: avoid reading options if compression mismatches. */
if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX3)
@ -1181,9 +1205,14 @@ Fax3VSetField(TIFF* tif, ttag_t tag, va_list ap)
default:
return (*sp->vsetparent)(tif, tag, ap);
}
TIFFSetFieldBit(tif, _TIFFFieldWithTag(tif, tag)->field_bit);
if ((fip = _TIFFFieldWithTag(tif, tag)))
TIFFSetFieldBit(tif, fip->field_bit);
else
return 0;
tif->tif_flags |= TIFF_DIRTYDIRECT;
return (1);
return 1;
}
static int
@ -1191,6 +1220,8 @@ Fax3VGetField(TIFF* tif, ttag_t tag, va_list ap)
{
Fax3BaseState* sp = Fax3State(tif);
assert(sp != 0);
switch (tag) {
case TIFFTAG_FAXMODE:
*va_arg(ap, int*) = sp->mode;
@ -1234,6 +1265,8 @@ Fax3PrintDir(TIFF* tif, FILE* fd, long flags)
{
Fax3BaseState* sp = Fax3State(tif);
assert(sp != 0);
(void) flags;
if (TIFFFieldSet(tif,FIELD_OPTIONS)) {
const char* sep = " ";
@ -1294,6 +1327,15 @@ InitCCITTFax3(TIFF* tif)
{
Fax3BaseState* sp;
/*
* Merge codec-specific tag information.
*/
if (!_TIFFMergeFieldInfo(tif, faxFieldInfo, N(faxFieldInfo))) {
TIFFErrorExt(tif->tif_clientdata, "InitCCITTFax3",
"Merging common CCITT Fax codec-specific tags failed");
return 0;
}
/*
* Allocate state block so tag methods have storage to record values.
*/
@ -1310,14 +1352,13 @@ InitCCITTFax3(TIFF* tif)
sp->rw_mode = tif->tif_mode;
/*
* Merge codec-specific tag information and
* override parent get/set field methods.
* Override parent get/set field methods.
*/
_TIFFMergeFieldInfo(tif, faxFieldInfo, N(faxFieldInfo));
sp->vgetparent = tif->tif_tagmethods.vgetfield;
tif->tif_tagmethods.vgetfield = Fax3VGetField; /* hook for codec tags */
sp->vsetparent = tif->tif_tagmethods.vsetfield;
tif->tif_tagmethods.vsetfield = Fax3VSetField; /* hook for codec tags */
sp->printdir = tif->tif_tagmethods.printdir;
tif->tif_tagmethods.printdir = Fax3PrintDir; /* hook for codec tags */
sp->groupoptions = 0;
sp->recvparams = 0;
@ -1355,14 +1396,21 @@ TIFFInitCCITTFax3(TIFF* tif, int scheme)
{
(void) scheme;
if (InitCCITTFax3(tif)) {
_TIFFMergeFieldInfo(tif, fax3FieldInfo, N(fax3FieldInfo));
/*
* Merge codec-specific tag information.
*/
if (!_TIFFMergeFieldInfo(tif, fax3FieldInfo, N(fax3FieldInfo))) {
TIFFErrorExt(tif->tif_clientdata, "TIFFInitCCITTFax3",
"Merging CCITT Fax 3 codec-specific tags failed");
return 0;
}
/*
* The default format is Class/F-style w/o RTC.
*/
return TIFFSetField(tif, TIFFTAG_FAXMODE, FAXMODE_CLASSF);
} else
return (0);
return 01;
}
/*
@ -1378,7 +1426,6 @@ static int
Fax4Decode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s)
{
DECLARE_STATE_2D(tif, sp, "Fax4Decode");
int line = 0;
(void) s;
CACHE_STATE(tif, sp);
@ -1401,19 +1448,19 @@ Fax4Decode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s)
SWAP(uint32*, sp->curruns, sp->refruns);
buf += sp->b.rowbytes;
occ -= sp->b.rowbytes;
line++;
sp->line++;
continue;
EOFG4:
NeedBits16( 13, BADG4 );
BADG4:
#ifdef FAX3_DEBUG
if( GetBits(13) != 0x1001 )
fputs( "Bad RTC\n", stderr );
fputs( "Bad EOFB\n", stderr );
#endif
ClrBits( 13 );
(*sp->fill)(buf, thisrun, pa, lastx);
UNCACHE_STATE(tif, sp);
return (-1);
return ( sp->line ? 1 : -1); /* don't error on badly-terminated strips */
}
UNCACHE_STATE(tif, sp);
return (1);
@ -1457,7 +1504,14 @@ TIFFInitCCITTFax4(TIFF* tif, int scheme)
{
(void) scheme;
if (InitCCITTFax3(tif)) { /* reuse G3 support */
_TIFFMergeFieldInfo(tif, fax4FieldInfo, N(fax4FieldInfo));
/*
* Merge codec-specific tag information.
*/
if (!_TIFFMergeFieldInfo(tif, fax4FieldInfo, N(fax4FieldInfo))) {
TIFFErrorExt(tif->tif_clientdata, "TIFFInitCCITTFax4",
"Merging CCITT Fax 4 codec-specific tags failed");
return 0;
}
tif->tif_decoderow = Fax4Decode;
tif->tif_decodestrip = Fax4Decode;
@ -1487,7 +1541,6 @@ Fax3DecodeRLE(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s)
{
DECLARE_STATE(tif, sp, "Fax3DecodeRLE");
int mode = sp->b.mode;
int line = 0;
(void) s;
CACHE_STATE(tif, sp);
@ -1517,7 +1570,7 @@ Fax3DecodeRLE(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s)
}
buf += sp->b.rowbytes;
occ -= sp->b.rowbytes;
line++;
sp->line++;
continue;
EOFRLE: /* premature EOF */
(*sp->fill)(buf, thisrun, pa, lastx);
@ -1564,3 +1617,10 @@ TIFFInitCCITTRLEW(TIFF* tif, int scheme)
#endif /* CCITT_SUPPORT */
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tif_fax3.h,v 1.5 2005/12/12 09:23:11 dron Exp $ */
/* $Id: tif_fax3.h,v 1.5.2.3 2011-03-10 20:22:33 fwarmerdam Exp $ */
/*
* Copyright (c) 1990-1997 Sam Leffler
@ -478,6 +478,12 @@ done1d: \
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; \
@ -523,3 +529,10 @@ eol2d: \
CLEANUP_RUNS(); \
} while (0)
#endif /* _FAX3_ */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1251,3 +1251,10 @@
{8,4,6},{8,2,3},{8,3,4},{8,2,2},{8,5,7},{8,2,3},{8,3,1},{8,2,2},{8,4,5},{8,2,3},
{8,3,4},{8,2,2}
};
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_flush.c,v 1.3 2000/09/15 20:52:42 warmerda Exp $ */
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_flush.c,v 1.3.2.1 2010-06-08 18:50:42 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -65,3 +65,10 @@ TIFFFlushData(TIFF* tif)
return (TIFFFlushData1(tif));
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,385 @@
/* $Id: tif_jbig.c,v 1.2.2.3 2010-06-08 18:50:42 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
* its documentation for any purpose is hereby granted without fee, provided
* that (i) the above copyright notices and this permission notice appear in
* all copies of the software and related documentation, and (ii) the names of
* Sam Leffler and Silicon Graphics may not be used in any advertising or
* publicity relating to the software without the specific, prior written
* permission of Sam Leffler and Silicon Graphics.
*
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
*
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
/*
* TIFF Library.
*
* JBIG Compression Algorithm Support.
* Contributed by Lee Howard <faxguy@deanox.com>
*
*/
#include "tiffiop.h"
#ifdef JBIG_SUPPORT
#include "jbig.h"
typedef struct
{
uint32 recvparams; /* encoded Class 2 session params */
char* subaddress; /* subaddress string */
uint32 recvtime; /* time spend receiving in seconds */
char* faxdcs; /* encoded fax parameters (DCS, Table 2/T.30) */
TIFFVGetMethod vgetparent;
TIFFVSetMethod vsetparent;
} JBIGState;
#define GetJBIGState(tif) ((JBIGState*)(tif)->tif_data)
#define FIELD_RECVPARAMS (FIELD_CODEC+0)
#define FIELD_SUBADDRESS (FIELD_CODEC+1)
#define FIELD_RECVTIME (FIELD_CODEC+2)
#define FIELD_FAXDCS (FIELD_CODEC+3)
static const TIFFFieldInfo jbigFieldInfo[] =
{
{TIFFTAG_FAXRECVPARAMS, 1, 1, TIFF_LONG, FIELD_RECVPARAMS, TRUE, FALSE, "FaxRecvParams"},
{TIFFTAG_FAXSUBADDRESS, -1, -1, TIFF_ASCII, FIELD_SUBADDRESS, TRUE, FALSE, "FaxSubAddress"},
{TIFFTAG_FAXRECVTIME, 1, 1, TIFF_LONG, FIELD_RECVTIME, TRUE, FALSE, "FaxRecvTime"},
{TIFFTAG_FAXDCS, -1, -1, TIFF_ASCII, FIELD_FAXDCS, TRUE, FALSE, "FaxDcs"},
};
static int JBIGSetupDecode(TIFF* tif)
{
if (TIFFNumberOfStrips(tif) != 1)
{
TIFFError("JBIG", "Multistrip images not supported in decoder");
return 0;
}
return 1;
}
static int JBIGDecode(TIFF* tif, tidata_t buffer, tsize_t size, tsample_t 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);
}
jbg_dec_init(&decoder);
#if defined(HAVE_JBG_NEWLEN)
jbg_newlen(tif->tif_rawdata, 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, tif->tif_rawdata,
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.
*/
TIFFError("JBIG", "Error (%d) decoding: %s", decodeStatus,
#if defined(JBG_EN)
jbg_strerror(decodeStatus, JBG_EN)
#else
jbg_strerror(decodeStatus)
#endif
);
return 0;
}
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)
{
TIFFError("JBIG", "Multistrip images not supported in encoder");
return 0;
}
return 1;
}
static int JBIGCopyEncodedData(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s)
{
(void) s;
while (cc > 0)
{
tsize_t n = cc;
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 -= n;
if (tif->tif_rawcc >= tif->tif_rawdatasize &&
!TIFFFlushData1(tif))
{
return (-1);
}
}
return (1);
}
static void JBIGOutputBie(unsigned char* buffer, size_t len, void *userData)
{
TIFF* tif = (TIFF*)userData;
if (isFillOrder(tif, tif->tif_dir.td_fillorder))
{
TIFFReverseBits(buffer, len);
}
JBIGCopyEncodedData(tif, buffer, len, 0);
}
static int JBIGEncode(TIFF* tif, tidata_t buffer, tsize_t size, tsample_t s)
{
TIFFDirectory* dir = &tif->tif_dir;
struct jbg_enc_state encoder;
(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);
return 1;
}
static void JBIGCleanup(TIFF* tif)
{
JBIGState *sp = GetJBIGState(tif);
assert(sp != 0);
tif->tif_tagmethods.vgetfield = sp->vgetparent;
tif->tif_tagmethods.vsetfield = sp->vsetparent;
_TIFFfree(tif->tif_data);
tif->tif_data = NULL;
_TIFFSetDefaultCompressionState(tif);
}
static void JBIGPrintDir(TIFF* tif, FILE* fd, long flags)
{
JBIGState* codec = GetJBIGState(tif);
(void)flags;
if (TIFFFieldSet(tif, FIELD_RECVPARAMS))
{
fprintf(fd,
" Fax Receive Parameters: %08lx\n",
(unsigned long)codec->recvparams);
}
if (TIFFFieldSet(tif, FIELD_SUBADDRESS))
{
fprintf(fd,
" Fax SubAddress: %s\n",
codec->subaddress);
}
if (TIFFFieldSet(tif, FIELD_RECVTIME))
{
fprintf(fd,
" Fax Receive Time: %lu secs\n",
(unsigned long)codec->recvtime);
}
if (TIFFFieldSet(tif, FIELD_FAXDCS))
{
fprintf(fd,
" Fax DCS: %s\n",
codec->faxdcs);
}
}
static int JBIGVGetField(TIFF* tif, ttag_t tag, va_list ap)
{
JBIGState* codec = GetJBIGState(tif);
switch (tag)
{
case TIFFTAG_FAXRECVPARAMS:
*va_arg(ap, uint32*) = codec->recvparams;
break;
case TIFFTAG_FAXSUBADDRESS:
*va_arg(ap, char**) = codec->subaddress;
break;
case TIFFTAG_FAXRECVTIME:
*va_arg(ap, uint32*) = codec->recvtime;
break;
case TIFFTAG_FAXDCS:
*va_arg(ap, char**) = codec->faxdcs;
break;
default:
return (*codec->vgetparent)(tif, tag, ap);
}
return 1;
}
static int JBIGVSetField(TIFF* tif, ttag_t tag, va_list ap)
{
JBIGState* codec = GetJBIGState(tif);
switch (tag)
{
case TIFFTAG_FAXRECVPARAMS:
codec->recvparams = va_arg(ap, uint32);
break;
case TIFFTAG_FAXSUBADDRESS:
_TIFFsetString(&codec->subaddress, va_arg(ap, char*));
break;
case TIFFTAG_FAXRECVTIME:
codec->recvtime = va_arg(ap, uint32);
break;
case TIFFTAG_FAXDCS:
_TIFFsetString(&codec->faxdcs, va_arg(ap, char*));
break;
default:
return (*codec->vsetparent)(tif, tag, ap);
}
TIFFSetFieldBit(tif, _TIFFFieldWithTag(tif, tag)->field_bit);
tif->tif_flags |= TIFF_DIRTYDIRECT;
return 1;
}
int TIFFInitJBIG(TIFF* tif, int scheme)
{
JBIGState* codec = NULL;
assert(scheme == COMPRESSION_JBIG);
/*
* Merge codec-specific tag information.
*/
if (!_TIFFMergeFieldInfo(tif, jbigFieldInfo,
TIFFArrayCount(jbigFieldInfo))) {
TIFFErrorExt(tif->tif_clientdata, "TIFFInitJBIG",
"Merging JBIG codec-specific tags failed");
return 0;
}
/* Allocate memory for the JBIGState structure.*/
tif->tif_data = (tdata_t)_TIFFmalloc(sizeof(JBIGState));
if (tif->tif_data == NULL)
{
TIFFError("TIFFInitJBIG", "Not enough memory for JBIGState");
return 0;
}
_TIFFmemset(tif->tif_data, 0, sizeof(JBIGState));
codec = GetJBIGState(tif);
/* Initialize codec private fields */
codec->recvparams = 0;
codec->subaddress = NULL;
codec->faxdcs = NULL;
codec->recvtime = 0;
/*
* Override parent get/set field methods.
*/
codec->vgetparent = tif->tif_tagmethods.vgetfield;
codec->vsetparent = tif->tif_tagmethods.vsetfield;
tif->tif_tagmethods.vgetfield = JBIGVGetField;
tif->tif_tagmethods.vsetfield = JBIGVSetField;
tif->tif_tagmethods.printdir = JBIGPrintDir;
/*
* 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;
tif->tif_setupencode = JBIGSetupEncode;
tif->tif_encodestrip = JBIGEncode;
tif->tif_cleanup = JBIGCleanup;
return 1;
}
#endif /* JBIG_SUPPORT */
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tif_jpeg.c,v 1.45 2006/03/16 12:38:24 dron Exp $ */
/* $Id: tif_jpeg.c,v 1.50.2.17 2011-01-04 02:51:17 faxguy Exp $ */
/*
* Copyright (c) 1994-1997 Sam Leffler
@ -152,6 +152,7 @@ typedef struct {
TIFFVGetMethod vgetparent; /* super-class method */
TIFFVSetMethod vsetparent; /* super-class method */
TIFFPrintMethod printdir; /* super-class method */
TIFFStripMethod defsparent; /* super-class method */
TIFFTileMethod deftparent; /* super-class method */
/* pseudo-tag fields */
@ -225,7 +226,7 @@ TIFFjpeg_error_exit(j_common_ptr cinfo)
char buffer[JMSG_LENGTH_MAX];
(*cinfo->err->format_message) (cinfo, buffer);
TIFFErrorExt(sp->tif->tif_clientdata, "JPEGLib", buffer); /* display the error message */
TIFFErrorExt(sp->tif->tif_clientdata, "JPEGLib", "%s", buffer); /* display the error message */
jpeg_abort(cinfo); /* clean up libjpeg state */
LONGJMP(sp->exit_jmpbuf, 1); /* return to libtiff caller */
}
@ -241,7 +242,7 @@ TIFFjpeg_output_message(j_common_ptr cinfo)
char buffer[JMSG_LENGTH_MAX];
(*cinfo->err->format_message) (cinfo, buffer);
TIFFWarningExt(((JPEGState *) cinfo)->tif->tif_clientdata, "JPEGLib", buffer);
TIFFWarningExt(((JPEGState *) cinfo)->tif->tif_clientdata, "JPEGLib", "%s", buffer);
}
/*
@ -712,7 +713,7 @@ JPEGPreDecode(TIFF* tif, tsample_t s)
} else {
if (segment_height > td->td_rowsperstrip)
segment_height = td->td_rowsperstrip;
sp->bytesperline = TIFFScanlineSize(tif);
sp->bytesperline = TIFFOldScanlineSize(tif);
}
if (td->td_planarconfig == PLANARCONFIG_SEPARATE && s > 0) {
/*
@ -722,14 +723,29 @@ JPEGPreDecode(TIFF* tif, tsample_t s)
segment_width = TIFFhowmany(segment_width, sp->h_sampling);
segment_height = TIFFhowmany(segment_height, sp->v_sampling);
}
if (sp->cinfo.d.image_width != segment_width ||
sp->cinfo.d.image_height != segment_height) {
if (sp->cinfo.d.image_width < segment_width ||
sp->cinfo.d.image_height < segment_height) {
TIFFWarningExt(tif->tif_clientdata, module,
"Improper JPEG strip/tile size, expected %dx%d, got %dx%d",
segment_width,
segment_height,
sp->cinfo.d.image_width,
sp->cinfo.d.image_height);
"Improper JPEG strip/tile size, "
"expected %dx%d, got %dx%d",
segment_width, segment_height,
sp->cinfo.d.image_width,
sp->cinfo.d.image_height);
}
if (sp->cinfo.d.image_width > segment_width ||
sp->cinfo.d.image_height > segment_height) {
/*
* This case could be dangerous, if the strip or tile size has
* been reported as less than the amount of data jpeg will
* return, some potential security issues arise. Catch this
* case and error out.
*/
TIFFErrorExt(tif->tif_clientdata, module,
"JPEG strip/tile size exceeds expected dimensions,"
" expected %dx%d, got %dx%d",
segment_width, segment_height,
sp->cinfo.d.image_width, sp->cinfo.d.image_height);
return (0);
}
if (sp->cinfo.d.num_components !=
(td->td_planarconfig == PLANARCONFIG_CONTIG ?
@ -761,6 +777,24 @@ JPEGPreDecode(TIFF* tif, tsample_t s)
sp->cinfo.d.comp_info[0].v_samp_factor,
sp->h_sampling, sp->v_sampling);
/*
* There are potential security issues here
* for decoders that have already allocated
* buffers based on the expected sampling
* factors. Lets check the sampling factors
* dont exceed what we were expecting.
*/
if (sp->cinfo.d.comp_info[0].h_samp_factor
> sp->h_sampling
|| sp->cinfo.d.comp_info[0].v_samp_factor
> sp->v_sampling) {
TIFFErrorExt(tif->tif_clientdata,
module,
"Cannot honour JPEG sampling factors"
" that exceed those specified.");
return (0);
}
/*
* XXX: Files written by the Intergraph software
* has different sampling factors stored in the
@ -950,119 +984,127 @@ JPEGDecode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s)
/*ARGSUSED*/ static int
JPEGDecodeRaw(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s)
{
JPEGState *sp = JState(tif);
tsize_t nrows;
(void) s;
JPEGState *sp = JState(tif);
tsize_t nrows;
(void) s;
nrows = cc / sp->bytesperline;
if (cc % sp->bytesperline)
TIFFWarningExt(tif->tif_clientdata, tif->tif_name, "fractional scanline not read");
if( nrows > (int) sp->cinfo.d.image_height )
nrows = sp->cinfo.d.image_height;
/* data is expected to be read in multiples of a scanline */
if ( (nrows = sp->cinfo.d.image_height) ) {
/* Cb,Cr both have sampling factors 1, so this is correct */
JDIMENSION clumps_per_line = sp->cinfo.d.comp_info[1].downsampled_width;
int samples_per_clump = sp->samplesperclump;
if (nrows) {
/* Cb,Cr both have sampling factors 1, so this is correct */
JDIMENSION clumps_per_line = sp->cinfo.d.comp_info[1].downsampled_width;
int samples_per_clump = sp->samplesperclump;
#ifdef JPEG_LIB_MK1
unsigned short* tmpbuf = _TIFFmalloc(sizeof(unsigned short) *
sp->cinfo.d.output_width *
sp->cinfo.d.num_components);
unsigned short* tmpbuf = _TIFFmalloc(sizeof(unsigned short) *
sp->cinfo.d.output_width *
sp->cinfo.d.num_components);
#endif
do {
jpeg_component_info *compptr;
int ci, clumpoffset;
/* Reload downsampled-data buffer if needed */
if (sp->scancount >= DCTSIZE) {
int n = sp->cinfo.d.max_v_samp_factor * DCTSIZE;
if (TIFFjpeg_read_raw_data(sp, sp->ds_buffer, n)
!= n)
return (0);
sp->scancount = 0;
}
/*
* Fastest way to unseparate data is to make one pass
* over the scanline for each row of each component.
*/
clumpoffset = 0; /* first sample in clump */
for (ci = 0, compptr = sp->cinfo.d.comp_info;
ci < sp->cinfo.d.num_components;
ci++, compptr++) {
int hsamp = compptr->h_samp_factor;
int vsamp = compptr->v_samp_factor;
int ypos;
do {
jpeg_component_info *compptr;
int ci, clumpoffset;
for (ypos = 0; ypos < vsamp; ypos++) {
JSAMPLE *inptr = sp->ds_buffer[ci][sp->scancount*vsamp + ypos];
/* Reload downsampled-data buffer if needed */
if (sp->scancount >= DCTSIZE) {
int n = sp->cinfo.d.max_v_samp_factor * DCTSIZE;
if (TIFFjpeg_read_raw_data(sp, sp->ds_buffer, n) != n)
return (0);
sp->scancount = 0;
}
/*
* Fastest way to unseparate data is to make one pass
* over the scanline for each row of each component.
*/
clumpoffset = 0; /* first sample in clump */
for (ci = 0, compptr = sp->cinfo.d.comp_info;
ci < sp->cinfo.d.num_components;
ci++, compptr++) {
int hsamp = compptr->h_samp_factor;
int vsamp = compptr->v_samp_factor;
int ypos;
for (ypos = 0; ypos < vsamp; ypos++) {
JSAMPLE *inptr = sp->ds_buffer[ci][sp->scancount*vsamp + ypos];
#ifdef JPEG_LIB_MK1
JSAMPLE *outptr = (JSAMPLE*)tmpbuf + clumpoffset;
JSAMPLE *outptr = (JSAMPLE*)tmpbuf + clumpoffset;
#else
JSAMPLE *outptr = (JSAMPLE*)buf + clumpoffset;
JSAMPLE *outptr = (JSAMPLE*)buf + clumpoffset;
#endif
JDIMENSION nclump;
JDIMENSION nclump;
if (hsamp == 1) {
/* fast path for at least Cb and Cr */
for (nclump = clumps_per_line; nclump-- > 0; ) {
outptr[0] = *inptr++;
outptr += samples_per_clump;
}
} else {
int xpos;
if (hsamp == 1) {
/* fast path for at least Cb and Cr */
for (nclump = clumps_per_line; nclump-- > 0; ) {
outptr[0] = *inptr++;
outptr += samples_per_clump;
}
} else {
int xpos;
/* general case */
for (nclump = clumps_per_line; nclump-- > 0; ) {
for (xpos = 0; xpos < hsamp; xpos++)
outptr[xpos] = *inptr++;
outptr += samples_per_clump;
}
}
clumpoffset += hsamp;
}
}
/* general case */
for (nclump = clumps_per_line; nclump-- > 0; ) {
for (xpos = 0; xpos < hsamp; xpos++)
outptr[xpos] = *inptr++;
outptr += samples_per_clump;
}
}
clumpoffset += hsamp;
}
}
#ifdef JPEG_LIB_MK1
{
if (sp->cinfo.d.data_precision == 8)
{
int i=0;
int len = sp->cinfo.d.output_width * sp->cinfo.d.num_components;
for (i=0; i<len; i++)
{
((unsigned char*)buf)[i] = tmpbuf[i] & 0xff;
}
}
else
{ // 12-bit
int value_pairs = (sp->cinfo.d.output_width
* sp->cinfo.d.num_components) / 2;
int iPair;
for( iPair = 0; iPair < value_pairs; iPair++ )
{
unsigned char *out_ptr = ((unsigned char *) buf) + iPair * 3;
JSAMPLE *in_ptr = tmpbuf + iPair * 2;
out_ptr[0] = (in_ptr[0] & 0xff0) >> 4;
out_ptr[1] = ((in_ptr[0] & 0xf) << 4)
| ((in_ptr[1] & 0xf00) >> 8);
out_ptr[2] = ((in_ptr[1] & 0xff) >> 0);
}
}
}
{
if (sp->cinfo.d.data_precision == 8)
{
int i=0;
int len = sp->cinfo.d.output_width * sp->cinfo.d.num_components;
for (i=0; i<len; i++)
{
((unsigned char*)buf)[i] = tmpbuf[i] & 0xff;
}
}
else
{ /* 12-bit */
int value_pairs = (sp->cinfo.d.output_width
* sp->cinfo.d.num_components) / 2;
int iPair;
for( iPair = 0; iPair < value_pairs; iPair++ )
{
unsigned char *out_ptr = ((unsigned char *) buf) + iPair * 3;
JSAMPLE *in_ptr = tmpbuf + iPair * 2;
out_ptr[0] = (in_ptr[0] & 0xff0) >> 4;
out_ptr[1] = ((in_ptr[0] & 0xf) << 4)
| ((in_ptr[1] & 0xf00) >> 8);
out_ptr[2] = ((in_ptr[1] & 0xff) >> 0);
}
}
}
#endif
++sp->scancount;
++tif->tif_row;
buf += sp->bytesperline;
cc -= sp->bytesperline;
} while (--nrows > 0);
sp->scancount ++;
tif->tif_row += sp->v_sampling;
/* increment/decrement of buf and cc is still incorrect, but should not matter
* TODO: resolve this */
buf += sp->bytesperline;
cc -= sp->bytesperline;
} while (--nrows > 0);
#ifdef JPEG_LIB_MK1
_TIFFfree(tmpbuf);
_TIFFfree(tmpbuf);
#endif
}
}
/* Close down the decompressor if done. */
return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height
|| TIFFjpeg_finish_decompress(sp);
/* Close down the decompressor if done. */
return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height
|| TIFFjpeg_finish_decompress(sp);
}
@ -1197,9 +1239,9 @@ JPEGSetupEncode(TIFF* tif)
/* BITS_IN_JSAMPLE now permits 8 and 12 --- dgilbert */
if (td->td_bitspersample != 8 && td->td_bitspersample != 12)
#else
if (td->td_bitspersample != BITS_IN_JSAMPLE )
if (td->td_bitspersample != BITS_IN_JSAMPLE )
#endif
{
{
TIFFErrorExt(tif->tif_clientdata, module, "BitsPerSample %d not allowed for JPEG",
(int) td->td_bitspersample);
return (0);
@ -1233,12 +1275,16 @@ JPEGSetupEncode(TIFF* tif)
/* Create a JPEGTables field if appropriate */
if (sp->jpegtablesmode & (JPEGTABLESMODE_QUANT|JPEGTABLESMODE_HUFF)) {
if (!prepare_JPEGTables(tif))
return (0);
/* Mark the field present */
/* Can't use TIFFSetField since BEENWRITING is already set! */
TIFFSetFieldBit(tif, FIELD_JPEGTABLES);
tif->tif_flags |= TIFF_DIRTYDIRECT;
if( sp->jpegtables == NULL
|| memcmp(sp->jpegtables,"\0\0\0\0\0\0\0\0\0",8) == 0 )
{
if (!prepare_JPEGTables(tif))
return (0);
/* Mark the field present */
/* Can't use TIFFSetField since BEENWRITING is already set! */
tif->tif_flags |= TIFF_DIRTYDIRECT;
TIFFSetFieldBit(tif, FIELD_JPEGTABLES);
}
} else {
/* We do not support application-supplied JPEGTables, */
/* so mark the field not present */
@ -1277,7 +1323,7 @@ JPEGPreEncode(TIFF* tif, tsample_t s)
segment_height = td->td_imagelength - tif->tif_row;
if (segment_height > td->td_rowsperstrip)
segment_height = td->td_rowsperstrip;
sp->bytesperline = TIFFScanlineSize(tif);
sp->bytesperline = TIFFOldScanlineSize(tif);
}
if (td->td_planarconfig == PLANARCONFIG_SEPARATE && s > 0) {
/* for PC 2, scale down the strip/tile size
@ -1312,8 +1358,15 @@ JPEGPreEncode(TIFF* tif, tsample_t s)
sp->cinfo.c.comp_info[0].h_samp_factor = sp->h_sampling;
sp->cinfo.c.comp_info[0].v_samp_factor = sp->v_sampling;
} else {
sp->cinfo.c.in_color_space = JCS_UNKNOWN;
if (!TIFFjpeg_set_colorspace(sp, JCS_UNKNOWN))
if ((td->td_photometric == PHOTOMETRIC_MINISWHITE || td->td_photometric == PHOTOMETRIC_MINISBLACK) && td->td_samplesperpixel == 1)
sp->cinfo.c.in_color_space = JCS_GRAYSCALE;
else if (td->td_photometric == PHOTOMETRIC_RGB)
sp->cinfo.c.in_color_space = JCS_RGB;
else if (td->td_photometric == PHOTOMETRIC_SEPARATED && td->td_samplesperpixel == 4)
sp->cinfo.c.in_color_space = JCS_CMYK;
else
sp->cinfo.c.in_color_space = JCS_UNKNOWN;
if (!TIFFjpeg_set_colorspace(sp, sp->cinfo.c.in_color_space))
return (0);
/* jpeg_set_colorspace set all sampling factors to 1 */
}
@ -1334,9 +1387,9 @@ JPEGPreEncode(TIFF* tif, tsample_t s)
sp->cinfo.c.write_JFIF_header = FALSE;
sp->cinfo.c.write_Adobe_marker = FALSE;
/* set up table handling correctly */
if (!TIFFjpeg_set_quality(sp, sp->jpegquality, FALSE))
return (0);
if (! (sp->jpegtablesmode & JPEGTABLESMODE_QUANT)) {
if (!TIFFjpeg_set_quality(sp, sp->jpegquality, FALSE))
return (0);
unsuppress_quant_table(sp, 0);
unsuppress_quant_table(sp, 1);
}
@ -1389,6 +1442,10 @@ JPEGEncode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s)
if (cc % sp->bytesperline)
TIFFWarningExt(tif->tif_clientdata, tif->tif_name, "fractional scanline discarded");
/* The last strip will be limited to image size */
if( !isTiled(tif) && tif->tif_row+nrows > tif->tif_dir.td_imagelength )
nrows = tif->tif_dir.td_imagelength - tif->tif_row;
while (nrows-- > 0) {
bufptr[0] = (JSAMPROW) buf;
if (TIFFjpeg_write_scanlines(sp, bufptr, 1) != 1)
@ -1415,18 +1472,25 @@ JPEGEncodeRaw(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s)
int clumpoffset, ci, xpos, ypos;
jpeg_component_info* compptr;
int samples_per_clump = sp->samplesperclump;
tsize_t bytesperclumpline;
(void) s;
assert(sp != NULL);
/* data is expected to be supplied in multiples of a scanline */
nrows = cc / sp->bytesperline;
if (cc % sp->bytesperline)
/* data is expected to be supplied in multiples of a clumpline */
/* a clumpline is equivalent to v_sampling desubsampled scanlines */
/* TODO: the following calculation of bytesperclumpline, should substitute calculation of sp->bytesperline, except that it is per v_sampling lines */
bytesperclumpline = (((sp->cinfo.c.image_width+sp->h_sampling-1)/sp->h_sampling)
*(sp->h_sampling*sp->v_sampling+2)*sp->cinfo.c.data_precision+7)
/8;
nrows = ( cc / bytesperclumpline ) * sp->v_sampling;
if (cc % bytesperclumpline)
TIFFWarningExt(tif->tif_clientdata, tif->tif_name, "fractional scanline discarded");
/* Cb,Cr both have sampling factors 1, so this is correct */
clumps_per_line = sp->cinfo.c.comp_info[1].downsampled_width;
while (nrows-- > 0) {
while (nrows > 0) {
/*
* Fastest way to separate the data is to make one pass
* over the scanline for each row of each component.
@ -1471,9 +1535,9 @@ JPEGEncodeRaw(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s)
return (0);
sp->scancount = 0;
}
if (nrows > 0)
tif->tif_row++;
buf += sp->bytesperline;
tif->tif_row += sp->v_sampling;
buf += bytesperclumpline;
nrows -= sp->v_sampling;
}
return (1);
}
@ -1525,6 +1589,7 @@ JPEGCleanup(TIFF* tif)
tif->tif_tagmethods.vgetfield = sp->vgetparent;
tif->tif_tagmethods.vsetfield = sp->vsetparent;
tif->tif_tagmethods.printdir = sp->printdir;
if( sp->cinfo_initialized )
TIFFjpeg_destroy(sp); /* release libjpeg resources */
@ -1536,11 +1601,47 @@ JPEGCleanup(TIFF* tif)
_TIFFSetDefaultCompressionState(tif);
}
static void
JPEGResetUpsampled( TIFF* tif )
{
JPEGState* sp = JState(tif);
TIFFDirectory* td = &tif->tif_dir;
/*
* Mark whether returned data is up-sampled or not so TIFFStripSize
* and TIFFTileSize return values that reflect the true amount of
* data.
*/
tif->tif_flags &= ~TIFF_UPSAMPLED;
if (td->td_planarconfig == PLANARCONFIG_CONTIG) {
if (td->td_photometric == PHOTOMETRIC_YCBCR &&
sp->jpegcolormode == JPEGCOLORMODE_RGB) {
tif->tif_flags |= TIFF_UPSAMPLED;
} else {
#ifdef notdef
if (td->td_ycbcrsubsampling[0] != 1 ||
td->td_ycbcrsubsampling[1] != 1)
; /* XXX what about up-sampling? */
#endif
}
}
/*
* Must recalculate cached tile size in case sampling state changed.
* Should we really be doing this now if image size isn't set?
*/
if( tif->tif_tilesize > 0 )
tif->tif_tilesize = isTiled(tif) ? TIFFTileSize(tif) : (tsize_t) -1;
if(tif->tif_scanlinesize > 0 )
tif->tif_scanlinesize = TIFFScanlineSize(tif);
}
static int
JPEGVSetField(TIFF* tif, ttag_t tag, va_list ap)
{
JPEGState* sp = JState(tif);
TIFFDirectory* td = &tif->tif_dir;
const TIFFFieldInfo* fip;
uint32 v32;
assert(sp != NULL);
@ -1562,34 +1663,21 @@ JPEGVSetField(TIFF* tif, ttag_t tag, va_list ap)
return (1); /* pseudo tag */
case TIFFTAG_JPEGCOLORMODE:
sp->jpegcolormode = va_arg(ap, int);
/*
* Mark whether returned data is up-sampled or not
* so TIFFStripSize and TIFFTileSize return values
* that reflect the true amount of data.
*/
tif->tif_flags &= ~TIFF_UPSAMPLED;
if (td->td_planarconfig == PLANARCONFIG_CONTIG) {
if (td->td_photometric == PHOTOMETRIC_YCBCR &&
sp->jpegcolormode == JPEGCOLORMODE_RGB) {
tif->tif_flags |= TIFF_UPSAMPLED;
} else {
if (td->td_ycbcrsubsampling[0] != 1 ||
td->td_ycbcrsubsampling[1] != 1)
; /* XXX what about up-sampling? */
}
}
/*
* Must recalculate cached tile size
* in case sampling state changed.
*/
tif->tif_tilesize = isTiled(tif) ? TIFFTileSize(tif) : (tsize_t) -1;
JPEGResetUpsampled( tif );
return (1); /* pseudo tag */
case TIFFTAG_PHOTOMETRIC:
{
int ret_value = (*sp->vsetparent)(tif, tag, ap);
JPEGResetUpsampled( tif );
return ret_value;
}
case TIFFTAG_JPEGTABLESMODE:
sp->jpegtablesmode = va_arg(ap, int);
return (1); /* pseudo tag */
case TIFFTAG_YCBCRSUBSAMPLING:
/* mark the fact that we have a real ycbcrsubsampling! */
sp->ycbcrsampling_fetched = 1;
/* should we be recomputing upsampling info here? */
return (*sp->vsetparent)(tif, tag, ap);
case TIFFTAG_FAXRECVPARAMS:
sp->recvparams = va_arg(ap, uint32);
@ -1606,7 +1694,13 @@ JPEGVSetField(TIFF* tif, ttag_t tag, va_list ap)
default:
return (*sp->vsetparent)(tif, tag, ap);
}
TIFFSetFieldBit(tif, _TIFFFieldWithTag(tif, tag)->field_bit);
if ((fip = _TIFFFieldWithTag(tif, tag))) {
TIFFSetFieldBit(tif, fip->field_bit);
} else {
return (0);
}
tif->tif_flags |= TIFF_DIRTYDIRECT;
return (1);
}
@ -1668,13 +1762,21 @@ JPEGFixupTestSubsampling( TIFF * tif )
return;
}
else
{
{
if( !TIFFFillStrip( tif, 0 ) )
return;
}
TIFFSetField( tif, TIFFTAG_YCBCRSUBSAMPLING,
(uint16) sp->h_sampling, (uint16) sp->v_sampling );
/*
** We want to clear the loaded strip so the application has time
** to set JPEGCOLORMODE or other behavior modifiers. This essentially
** undoes the JPEGPreDecode triggers by TIFFFileStrip(). (#1936)
*/
tif->tif_curstrip = -1;
#endif /* CHECK_JPEG_YCBCR_SUBSAMPLING */
}
@ -1702,7 +1804,6 @@ JPEGVGetField(TIFF* tif, ttag_t tag, va_list ap)
case TIFFTAG_YCBCRSUBSAMPLING:
JPEGFixupTestSubsampling( tif );
return (*sp->vgetparent)(tif, tag, ap);
break;
case TIFFTAG_FAXRECVPARAMS:
*va_arg(ap, uint32*) = sp->recvparams;
break;
@ -1796,8 +1897,18 @@ static int JPEGInitializeLibJPEG( TIFF * tif, int force_encode, int force_decode
int data_is_empty = TRUE;
int decompress;
if( sp->cinfo_initialized )
return 1;
if(sp->cinfo_initialized)
{
if( force_encode && sp->cinfo.comm.is_decompressor )
TIFFjpeg_destroy( sp );
else if( force_decode && !sp->cinfo.comm.is_decompressor )
TIFFjpeg_destroy( sp );
else
return 1;
sp->cinfo_initialized = 0;
}
/*
* Do we have tile data already? Make sure we initialize the
@ -1852,29 +1963,39 @@ TIFFInitJPEG(TIFF* tif, int scheme)
assert(scheme == COMPRESSION_JPEG);
/*
* Merge codec-specific tag information.
*/
if (!_TIFFMergeFieldInfo(tif, jpegFieldInfo, N(jpegFieldInfo))) {
TIFFErrorExt(tif->tif_clientdata,
"TIFFInitJPEG",
"Merging JPEG codec-specific tags failed");
return 0;
}
/*
* Allocate state block so tag methods have storage to record values.
*/
tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (JPEGState));
if (tif->tif_data == NULL) {
TIFFErrorExt(tif->tif_clientdata, "TIFFInitJPEG", "No space for JPEG state block");
return (0);
TIFFErrorExt(tif->tif_clientdata,
"TIFFInitJPEG", "No space for JPEG state block");
return 0;
}
_TIFFmemset( tif->tif_data, 0, sizeof(JPEGState));
_TIFFmemset(tif->tif_data, 0, sizeof(JPEGState));
sp = JState(tif);
sp->tif = tif; /* back link */
/*
* Merge codec-specific tag information and override parent get/set
* field methods.
* Override parent get/set field methods.
*/
_TIFFMergeFieldInfo(tif, jpegFieldInfo, N(jpegFieldInfo));
sp->vgetparent = tif->tif_tagmethods.vgetfield;
tif->tif_tagmethods.vgetfield = JPEGVGetField; /* hook for codec tags */
sp->vsetparent = tif->tif_tagmethods.vsetfield;
tif->tif_tagmethods.vsetfield = JPEGVSetField; /* hook for codec tags */
sp->printdir = tif->tif_tagmethods.printdir;
tif->tif_tagmethods.printdir = JPEGPrintDir; /* hook for codec tags */
/* Default values for codec-specific fields */
@ -1922,7 +2043,14 @@ TIFFInitJPEG(TIFF* tif, int scheme)
if( tif->tif_diroff == 0 )
{
#define SIZE_OF_JPEGTABLES 2000
/*
The following line assumes incorrectly that all JPEG-in-TIFF files will have
a JPEGTABLES tag generated and causes null-filled JPEGTABLES tags to be written
when the JPEG data is placed with TIFFWriteRawStrip. The field bit should be
set, anyway, later when actual JPEGTABLES header is generated, so removing it
here hopefully is harmless.
TIFFSetFieldBit(tif, FIELD_JPEGTABLES);
*/
sp->jpegtables_length = SIZE_OF_JPEGTABLES;
sp->jpegtables = (void *) _TIFFmalloc(sp->jpegtables_length);
_TIFFmemset(sp->jpegtables, 0, SIZE_OF_JPEGTABLES);
@ -1940,3 +2068,11 @@ TIFFInitJPEG(TIFF* tif, int scheme)
#endif /* JPEG_SUPPORT */
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tif_luv.c,v 1.17 2006/03/16 12:38:24 dron Exp $ */
/* $Id: tif_luv.c,v 1.17.2.4 2010-06-08 18:50:42 bfriesen Exp $ */
/*
* Copyright (c) 1997 Greg Ward Larson
@ -451,7 +451,7 @@ LogL16Encode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
tif->tif_rawcp = op;
tif->tif_rawcc = tif->tif_rawdatasize - occ;
return (0);
return (1);
}
/*
@ -496,7 +496,7 @@ LogLuvEncode24(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
tif->tif_rawcp = op;
tif->tif_rawcc = tif->tif_rawdatasize - occ;
return (0);
return (1);
}
/*
@ -585,7 +585,7 @@ LogLuvEncode32(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
tif->tif_rawcp = op;
tif->tif_rawcc = tif->tif_rawdatasize - occ;
return (0);
return (1);
}
/*
@ -598,7 +598,7 @@ LogLuvEncodeStrip(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
tsize_t rowlen = TIFFScanlineSize(tif);
assert(cc%rowlen == 0);
while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 0)
while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 1)
bp += rowlen, cc -= rowlen;
return (cc == 0);
}
@ -613,7 +613,7 @@ LogLuvEncodeTile(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
tsize_t rowlen = TIFFTileRowSize(tif);
assert(cc%rowlen == 0);
while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 0)
while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 1)
bp += rowlen, cc -= rowlen;
return (cc == 0);
}
@ -1200,7 +1200,10 @@ LogL16InitState(TIFF* tif)
"No support for converting user data format to LogL");
return (0);
}
sp->tbuflen = multiply(td->td_imagewidth, td->td_rowsperstrip);
if( isTiled(tif) )
sp->tbuflen = multiply(td->td_tilewidth, td->td_tilelength);
else
sp->tbuflen = multiply(td->td_imagewidth, td->td_rowsperstrip);
if (multiply(sp->tbuflen, sizeof (int16)) == 0 ||
(sp->tbuf = (tidata_t*) _TIFFmalloc(sp->tbuflen * sizeof (int16))) == NULL) {
TIFFErrorExt(tif->tif_clientdata, module, "%s: No space for SGILog translation buffer",
@ -1298,7 +1301,10 @@ LogLuvInitState(TIFF* tif)
"No support for converting user data format to LogLuv");
return (0);
}
sp->tbuflen = multiply(td->td_imagewidth, td->td_rowsperstrip);
if( isTiled(tif) )
sp->tbuflen = multiply(td->td_tilewidth, td->td_tilelength);
else
sp->tbuflen = multiply(td->td_imagewidth, td->td_rowsperstrip);
if (multiply(sp->tbuflen, sizeof (uint32)) == 0 ||
(sp->tbuf = (tidata_t*) _TIFFmalloc(sp->tbuflen * sizeof (uint32))) == NULL) {
TIFFErrorExt(tif->tif_clientdata, module, "%s: No space for SGILog translation buffer",
@ -1560,6 +1566,16 @@ TIFFInitSGILog(TIFF* tif, int scheme)
assert(scheme == COMPRESSION_SGILOG24 || scheme == COMPRESSION_SGILOG);
/*
* Merge codec-specific tag information.
*/
if (!_TIFFMergeFieldInfo(tif, LogLuvFieldInfo,
TIFFArrayCount(LogLuvFieldInfo))) {
TIFFErrorExt(tif->tif_clientdata, module,
"Merging SGILog codec-specific tags failed");
return 0;
}
/*
* Allocate state block so tag methods have storage to record values.
*/
@ -1587,9 +1603,9 @@ TIFFInitSGILog(TIFF* tif, int scheme)
tif->tif_close = LogLuvClose;
tif->tif_cleanup = LogLuvCleanup;
/* override SetField so we can handle our private pseudo-tag */
_TIFFMergeFieldInfo(tif, LogLuvFieldInfo,
TIFFArrayCount(LogLuvFieldInfo));
/*
* Override parent get/set field methods.
*/
sp->vgetparent = tif->tif_tagmethods.vgetfield;
tif->tif_tagmethods.vgetfield = LogLuvVGetField; /* hook for codec tags */
sp->vsetparent = tif->tif_tagmethods.vsetfield;
@ -1604,3 +1620,10 @@ bad:
#endif /* LOGLUV_SUPPORT */
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tif_lzw.c,v 1.28 2006/03/16 12:38:24 dron Exp $ */
/* $Id: tif_lzw.c,v 1.29.2.6 2010-06-08 18:50:42 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -224,7 +224,8 @@ LZWSetupDecode(TIFF* tif)
if (sp->dec_codetab == NULL) {
sp->dec_codetab = (code_t*)_TIFFmalloc(CSIZE*sizeof (code_t));
if (sp->dec_codetab == NULL) {
TIFFErrorExt(tif->tif_clientdata, module, "No space for LZW code table");
TIFFErrorExt(tif->tif_clientdata, module,
"No space for LZW code table");
return (0);
}
/*
@ -237,6 +238,11 @@ LZWSetupDecode(TIFF* tif)
sp->dec_codetab[code].length = 1;
sp->dec_codetab[code].next = NULL;
} while (code--);
/*
* Zero-out the unused entries
*/
_TIFFmemset(&sp->dec_codetab[CODE_CLEAR], 0,
(CODE_FIRST - CODE_CLEAR) * sizeof (code_t));
}
return (1);
}
@ -251,6 +257,11 @@ LZWPreDecode(TIFF* tif, tsample_t s)
(void) s;
assert(sp != NULL);
if( sp->dec_codetab == NULL )
{
tif->tif_setupdecode( tif );
}
/*
* Check for old bit-reversed codes.
*/
@ -350,6 +361,7 @@ LZWDecode(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s)
(void) s;
assert(sp != NULL);
assert(sp->dec_codetab != NULL);
/*
* Restart interrupted output operation.
*/
@ -408,12 +420,20 @@ LZWDecode(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s)
break;
if (code == CODE_CLEAR) {
free_entp = sp->dec_codetab + CODE_FIRST;
_TIFFmemset(free_entp, 0,
(CSIZE - CODE_FIRST) * sizeof (code_t));
nbits = BITS_MIN;
nbitsmask = MAXCODE(BITS_MIN);
maxcodep = sp->dec_codetab + nbitsmask-1;
NextCode(tif, sp, bp, code, GetNextCode);
if (code == CODE_EOI)
break;
if (code == CODE_CLEAR) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"LZWDecode: Corrupted LZW table at scanline %d",
tif->tif_row);
return (0);
}
*op++ = (char)code, occ--;
oldcodep = sp->dec_codetab + code;
continue;
@ -514,7 +534,7 @@ LZWDecode(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s)
if (occ > 0) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"LZWDecode: Not enough data at scanline %d (short %d bytes)",
"LZWDecode: Not enough data at scanline %d (short %ld bytes)",
tif->tif_row, occ);
return (0);
}
@ -604,12 +624,20 @@ LZWDecodeCompat(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s)
break;
if (code == CODE_CLEAR) {
free_entp = sp->dec_codetab + CODE_FIRST;
_TIFFmemset(free_entp, 0,
(CSIZE - CODE_FIRST) * sizeof (code_t));
nbits = BITS_MIN;
nbitsmask = MAXCODE(BITS_MIN);
maxcodep = sp->dec_codetab + nbitsmask;
NextCode(tif, sp, bp, code, GetNextCodeCompat);
if (code == CODE_EOI)
break;
if (code == CODE_CLEAR) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"LZWDecode: Corrupted LZW table at scanline %d",
tif->tif_row);
return (0);
}
*op++ = code, occ--;
oldcodep = sp->dec_codetab + code;
continue;
@ -647,6 +675,7 @@ LZWDecodeCompat(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s)
}
oldcodep = codep;
if (code >= 256) {
char *op_orig = op;
/*
* Code maps to a string, copy string
* value to output (written in reverse).
@ -681,7 +710,7 @@ LZWDecodeCompat(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s)
tp = op;
do {
*--tp = codep->value;
} while( (codep = codep->next) != NULL);
} while( (codep = codep->next) != NULL && tp > op_orig);
} else
*op++ = code, occ--;
}
@ -697,7 +726,7 @@ LZWDecodeCompat(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s)
if (occ > 0) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"LZWDecodeCompat: Not enough data at scanline %d (short %d bytes)",
"LZWDecodeCompat: Not enough data at scanline %d (short %ld bytes)",
tif->tif_row, occ);
return (0);
}
@ -734,6 +763,12 @@ LZWPreEncode(TIFF* tif, tsample_t s)
(void) s;
assert(sp != NULL);
if( sp->enc_hashtab == NULL )
{
tif->tif_setupencode( tif );
}
sp->lzw_nbits = BITS_MIN;
sp->lzw_maxcode = MAXCODE(BITS_MIN);
sp->lzw_free_ent = CODE_FIRST;
@ -803,6 +838,9 @@ LZWEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
(void) s;
if (sp == NULL)
return (0);
assert(sp->enc_hashtab != NULL);
/*
* Load local state.
*/
@ -1082,3 +1120,10 @@ bad:
#endif /* LZW_SUPPORT */
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_msdos.c,v 1.2 2005/12/21 12:23:13 joris Exp $ */
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/Attic/tif_msdos.c,v 1.3.2.1 2010-06-08 18:50:42 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -102,6 +102,7 @@ TIFFOpen(const char* name, const char* mode)
{
static const char module[] = "TIFFOpen";
int m, fd;
TIFF *ret;
m = _TIFFgetMode(mode, module);
if (m == -1)
@ -112,6 +113,12 @@ TIFFOpen(const char* name, const char* mode)
return ((TIFF*)0);
}
return (TIFFFdOpen(fd, name, mode));
ret = TIFFFdOpen(fd, name, mode);
if (ret == NULL) close(fd);
return ret;
}
#ifdef __GNUC__
@ -177,3 +184,10 @@ msdosErrorHandler(const char* module, const char* fmt, va_list ap)
fprintf(stderr, ".\n");
}
TIFFErrorHandler _TIFFerrorHandler = msdosErrorHandler;
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tif_next.c,v 1.6 2005/12/21 12:23:13 joris Exp $ */
/* $Id: tif_next.c,v 1.8.2.1 2010-06-08 18:50:42 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -48,11 +48,10 @@
static int
NeXTDecode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s)
{
register unsigned char *bp, *op;
register tsize_t cc;
register int n;
unsigned char *bp, *op;
tsize_t cc;
tidata_t row;
tsize_t scanline;
tsize_t scanline, n;
(void) s;
/*
@ -66,7 +65,7 @@ NeXTDecode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s)
bp = (unsigned char *)tif->tif_rawcp;
cc = tif->tif_rawcc;
scanline = tif->tif_scanlinesize;
for (row = buf; (long)occ > 0; occ -= scanline, row += scanline) {
for (row = buf; occ > 0; occ -= scanline, row += scanline) {
n = *bp++, cc--;
switch (n) {
case LITERALROW:
@ -80,10 +79,10 @@ NeXTDecode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s)
cc -= scanline;
break;
case LITERALSPAN: {
int off;
tsize_t off;
/*
* The scanline has a literal span
* that begins at some offset.
* The scanline has a literal span that begins at some
* offset.
*/
off = (bp[0] * 256) + bp[1];
n = (bp[2] * 256) + bp[3];
@ -95,23 +94,27 @@ NeXTDecode(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s)
break;
}
default: {
register int npixels = 0, grey;
unsigned long imagewidth = tif->tif_dir.td_imagewidth;
uint32 npixels = 0, grey;
uint32 imagewidth = tif->tif_dir.td_imagewidth;
/*
* 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.
* 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 = (n>>6) & 0x3;
n &= 0x3f;
while (n-- > 0)
/*
* 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 >= (int) imagewidth)
if (npixels >= imagewidth)
break;
if (cc == 0)
goto bad;
@ -142,3 +145,10 @@ TIFFInitNeXT(TIFF* tif, int scheme)
#endif /* NEXT_SUPPORT */
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
/* $Id: tif_open.c,v 1.31 2006/03/16 12:23:02 dron Exp $ */
/* $Id: tif_open.c,v 1.33.2.2 2010-12-06 16:54:22 faxguy Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -198,7 +198,7 @@ TIFFClientOpen(
*/
tif->tif_flags = FILLORDER_MSB2LSB;
if (m == O_RDONLY )
tif->tif_flags |= TIFF_MAPPED;
tif->tif_flags |= TIFF_MAPPED;
#ifdef STRIPCHOP_DEFAULT
if (m == O_RDONLY || m == O_RDWR)
@ -304,10 +304,11 @@ TIFFClientOpen(
/*
* Read in TIFF header.
*/
if (tif->tif_mode & O_TRUNC ||
if ((m & O_TRUNC) ||
!ReadOK(tif, &tif->tif_header, sizeof (TIFFHeader))) {
if (tif->tif_mode == O_RDONLY) {
TIFFErrorExt(tif->tif_clientdata, name, "Cannot read TIFF header");
TIFFErrorExt(tif->tif_clientdata, name,
"Cannot read TIFF header");
goto bad;
}
/*
@ -336,7 +337,8 @@ TIFFClientOpen(
TIFFSeekFile( tif, 0, SEEK_SET );
if (!WriteOK(tif, &tif->tif_header, sizeof (TIFFHeader))) {
TIFFErrorExt(tif->tif_clientdata, name, "Error writing TIFF header");
TIFFErrorExt(tif->tif_clientdata, name,
"Error writing TIFF header");
goto bad;
}
/*
@ -350,6 +352,7 @@ TIFFClientOpen(
goto bad;
tif->tif_diroff = 0;
tif->tif_dirlist = NULL;
tif->tif_dirlistsize = 0;
tif->tif_dirnumber = 0;
return (tif);
}
@ -366,10 +369,12 @@ TIFFClientOpen(
tif->tif_header.tiff_magic != MDI_LITTLEENDIAN
#endif
) {
TIFFErrorExt(tif->tif_clientdata, name, "Not a TIFF or MDI file, bad magic number %d (0x%x)",
TIFFErrorExt(tif->tif_clientdata, name,
"Not a TIFF or MDI file, bad magic number %d (0x%x)",
#else
) {
TIFFErrorExt(tif->tif_clientdata, name, "Not a TIFF file, bad magic number %d (0x%x)",
TIFFErrorExt(tif->tif_clientdata, name,
"Not a TIFF file, bad magic number %d (0x%x)",
#endif
tif->tif_header.tiff_magic,
tif->tif_header.tiff_magic);
@ -398,7 +403,7 @@ TIFFClientOpen(
TIFFErrorExt(tif->tif_clientdata, name,
"Not a TIFF file, bad version number %d (0x%x)",
tif->tif_header.tiff_version,
tif->tif_header.tiff_version);
tif->tif_header.tiff_version);
goto bad;
}
tif->tif_flags |= TIFF_MYBUFFER;
@ -681,3 +686,10 @@ TIFFGetUnmapFileProc(TIFF* tif)
}
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tif_packbits.c,v 1.13 2006/02/07 11:03:29 dron Exp $ */
/* $Id: tif_packbits.c,v 1.13.2.2 2010-06-08 18:50:42 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -240,7 +240,7 @@ PackBitsDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s)
if( occ < n )
{
TIFFWarningExt(tif->tif_clientdata, tif->tif_name,
"PackBitsDecode: discarding %d bytes "
"PackBitsDecode: discarding %ld bytes "
"to avoid buffer overrun",
n - occ);
n = occ;
@ -253,7 +253,7 @@ PackBitsDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s)
if (occ < n + 1)
{
TIFFWarningExt(tif->tif_clientdata, tif->tif_name,
"PackBitsDecode: discarding %d bytes "
"PackBitsDecode: discarding %ld bytes "
"to avoid buffer overrun",
n - occ + 1);
n = occ - 1;
@ -291,3 +291,10 @@ TIFFInitPackBits(TIFF* tif, int scheme)
#endif /* PACKBITS_SUPPORT */
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tif_pixarlog.c,v 1.14 2006/03/16 12:38:24 dron Exp $ */
/* $Id: tif_pixarlog.c,v 1.15.2.4 2010-06-08 18:50:42 bfriesen Exp $ */
/*
* Copyright (c) 1996-1997 Sam Leffler
@ -327,7 +327,7 @@ horizontalAccumulate11(uint16 *wp, int n, int stride, uint16 *op)
while (n > 0) {
REPEAT(stride,
wp[stride] += *wp; *op = *wp&mask; wp++; op++)
n -= stride;
n -= stride;
}
}
}
@ -593,7 +593,6 @@ PixarLogMakeTables(PixarLogState *sp)
static int PixarLogEncode(TIFF*, tidata_t, tsize_t, tsample_t);
static int PixarLogDecode(TIFF*, tidata_t, tsize_t, tsample_t);
#define N(a) (sizeof(a)/sizeof(a[0]))
#define PIXARLOGDATAFMT_UNKNOWN -1
static int
@ -768,6 +767,18 @@ PixarLogDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s)
if (tif->tif_flags & TIFF_SWAB)
TIFFSwabArrayOfShort(up, nsamples);
/*
* if llen is not an exact multiple of nsamples, the decode operation
* may overflow the output buffer, so truncate it enough to prevent
* that but still salvage as much data as possible.
*/
if (nsamples % llen) {
TIFFWarningExt(tif->tif_clientdata, module,
"%s: stride %d is not a multiple of sample count, "
"%d, data truncated.", tif->tif_name, llen, nsamples);
nsamples -= nsamples % llen;
}
for (i = 0; i < nsamples; i += llen, up += llen) {
switch (sp->user_datafmt) {
case PIXARLOGDATAFMT_FLOAT:
@ -1036,7 +1047,7 @@ PixarLogEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
TIFFDirectory *td = &tif->tif_dir;
PixarLogState *sp = EncoderState(tif);
static const char module[] = "PixarLogEncode";
int i, n, llen;
int i, n, llen;
unsigned short * up;
(void) s;
@ -1278,10 +1289,22 @@ static const TIFFFieldInfo pixarlogFieldInfo[] = {
int
TIFFInitPixarLog(TIFF* tif, int scheme)
{
static const char module[] = "TIFFInitPixarLog";
PixarLogState* sp;
assert(scheme == COMPRESSION_PIXARLOG);
/*
* Merge codec-specific tag information.
*/
if (!_TIFFMergeFieldInfo(tif, pixarlogFieldInfo,
TIFFArrayCount(pixarlogFieldInfo))) {
TIFFErrorExt(tif->tif_clientdata, module,
"Merging PixarLog codec-specific tags failed");
return 0;
}
/*
* Allocate state block so tag methods have storage to record values.
*/
@ -1311,7 +1334,6 @@ TIFFInitPixarLog(TIFF* tif, int scheme)
tif->tif_cleanup = PixarLogCleanup;
/* Override SetField so we can handle our private pseudo-tag */
_TIFFMergeFieldInfo(tif, pixarlogFieldInfo, N(pixarlogFieldInfo));
sp->vgetparent = tif->tif_tagmethods.vgetfield;
tif->tif_tagmethods.vgetfield = PixarLogVGetField; /* hook for codec tags */
sp->vsetparent = tif->tif_tagmethods.vsetfield;
@ -1333,10 +1355,17 @@ TIFFInitPixarLog(TIFF* tif, int scheme)
return (1);
bad:
TIFFErrorExt(tif->tif_clientdata, "TIFFInitPixarLog",
TIFFErrorExt(tif->tif_clientdata, module,
"No space for PixarLog state block");
return (0);
}
#endif /* PIXARLOG_SUPPORT */
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tif_predict.c,v 1.11 2006/03/03 14:10:09 dron Exp $ */
/* $Id: tif_predict.c,v 1.11.2.4 2010-06-08 18:50:42 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -36,9 +36,12 @@
static void horAcc8(TIFF*, tidata_t, tsize_t);
static void horAcc16(TIFF*, tidata_t, tsize_t);
static void horAcc32(TIFF*, tidata_t, tsize_t);
static void swabHorAcc16(TIFF*, tidata_t, tsize_t);
static void swabHorAcc32(TIFF*, tidata_t, tsize_t);
static void horDiff8(TIFF*, tidata_t, tsize_t);
static void horDiff16(TIFF*, tidata_t, tsize_t);
static void horDiff32(TIFF*, tidata_t, tsize_t);
static void fpAcc(TIFF*, tidata_t, tsize_t);
static void fpDiff(TIFF*, tidata_t, tsize_t);
static int PredictorDecodeRow(TIFF*, tidata_t, tsize_t, tsample_t);
@ -60,7 +63,8 @@ PredictorSetup(TIFF* tif)
return 1;
case PREDICTOR_HORIZONTAL:
if (td->td_bitspersample != 8
&& td->td_bitspersample != 16) {
&& td->td_bitspersample != 16
&& td->td_bitspersample != 32) {
TIFFErrorExt(tif->tif_clientdata, module,
"Horizontal differencing \"Predictor\" not supported with %d-bit samples",
td->td_bitspersample);
@ -105,19 +109,23 @@ PredictorSetupDecode(TIFF* tif)
if (sp->predictor == 2) {
switch (td->td_bitspersample) {
case 8: sp->pfunc = horAcc8; break;
case 16: sp->pfunc = horAcc16; break;
case 8: sp->decodepfunc = horAcc8; break;
case 16: sp->decodepfunc = horAcc16; break;
case 32: sp->decodepfunc = horAcc32; break;
}
/*
* Override default decoding method with one that does the
* predictor stuff.
*/
sp->coderow = tif->tif_decoderow;
tif->tif_decoderow = PredictorDecodeRow;
sp->codestrip = tif->tif_decodestrip;
tif->tif_decodestrip = PredictorDecodeTile;
sp->codetile = tif->tif_decodetile;
tif->tif_decodetile = PredictorDecodeTile;
if( tif->tif_decoderow != PredictorDecodeRow )
{
sp->decoderow = tif->tif_decoderow;
tif->tif_decoderow = PredictorDecodeRow;
sp->decodestrip = tif->tif_decodestrip;
tif->tif_decodestrip = PredictorDecodeTile;
sp->decodetile = tif->tif_decodetile;
tif->tif_decodetile = PredictorDecodeTile;
}
/*
* If the data is horizontally differenced 16-bit data that
* requires byte-swapping, then it must be byte swapped before
@ -126,25 +134,31 @@ PredictorSetupDecode(TIFF* tif)
* the library setup when the directory was read.
*/
if (tif->tif_flags & TIFF_SWAB) {
if (sp->pfunc == horAcc16) {
sp->pfunc = swabHorAcc16;
if (sp->decodepfunc == horAcc16) {
sp->decodepfunc = swabHorAcc16;
tif->tif_postdecode = _TIFFNoPostDecode;
} /* else handle 32-bit case... */
} else if (sp->decodepfunc == horAcc32) {
sp->decodepfunc = swabHorAcc32;
tif->tif_postdecode = _TIFFNoPostDecode;
}
}
}
else if (sp->predictor == 3) {
sp->pfunc = fpAcc;
sp->decodepfunc = fpAcc;
/*
* Override default decoding method with one that does the
* predictor stuff.
*/
sp->coderow = tif->tif_decoderow;
tif->tif_decoderow = PredictorDecodeRow;
sp->codestrip = tif->tif_decodestrip;
tif->tif_decodestrip = PredictorDecodeTile;
sp->codetile = tif->tif_decodetile;
tif->tif_decodetile = PredictorDecodeTile;
if( tif->tif_decoderow != PredictorDecodeRow )
{
sp->decoderow = tif->tif_decoderow;
tif->tif_decoderow = PredictorDecodeRow;
sp->decodestrip = tif->tif_decodestrip;
tif->tif_decodestrip = PredictorDecodeTile;
sp->decodetile = tif->tif_decodetile;
tif->tif_decodetile = PredictorDecodeTile;
}
/*
* The data should not be swapped outside of the floating
* point predictor, the accumulation routine should return
@ -173,33 +187,40 @@ PredictorSetupEncode(TIFF* tif)
if (sp->predictor == 2) {
switch (td->td_bitspersample) {
case 8: sp->pfunc = horDiff8; break;
case 16: sp->pfunc = horDiff16; break;
case 8: sp->encodepfunc = horDiff8; break;
case 16: sp->encodepfunc = horDiff16; break;
case 32: sp->encodepfunc = horDiff32; break;
}
/*
* Override default encoding method with one that does the
* predictor stuff.
*/
sp->coderow = tif->tif_encoderow;
tif->tif_encoderow = PredictorEncodeRow;
sp->codestrip = tif->tif_encodestrip;
tif->tif_encodestrip = PredictorEncodeTile;
sp->codetile = tif->tif_encodetile;
tif->tif_encodetile = PredictorEncodeTile;
if( tif->tif_encoderow != PredictorEncodeRow )
{
sp->encoderow = tif->tif_encoderow;
tif->tif_encoderow = PredictorEncodeRow;
sp->encodestrip = tif->tif_encodestrip;
tif->tif_encodestrip = PredictorEncodeTile;
sp->encodetile = tif->tif_encodetile;
tif->tif_encodetile = PredictorEncodeTile;
}
}
else if (sp->predictor == 3) {
sp->pfunc = fpDiff;
sp->encodepfunc = fpDiff;
/*
* Override default encoding method with one that does the
* predictor stuff.
*/
sp->coderow = tif->tif_encoderow;
tif->tif_encoderow = PredictorEncodeRow;
sp->codestrip = tif->tif_encodestrip;
tif->tif_encodestrip = PredictorEncodeTile;
sp->codetile = tif->tif_encodetile;
tif->tif_encodetile = PredictorEncodeTile;
if( tif->tif_encoderow != PredictorEncodeRow )
{
sp->encoderow = tif->tif_encoderow;
tif->tif_encoderow = PredictorEncodeRow;
sp->encodestrip = tif->tif_encodestrip;
tif->tif_encodestrip = PredictorEncodeTile;
sp->encodetile = tif->tif_encodetile;
tif->tif_encodetile = PredictorEncodeTile;
}
}
return 1;
@ -291,6 +312,39 @@ horAcc16(TIFF* tif, tidata_t cp0, tsize_t cc)
}
}
static void
swabHorAcc32(TIFF* tif, tidata_t cp0, tsize_t cc)
{
tsize_t stride = PredictorState(tif)->stride;
uint32* wp = (uint32*) cp0;
tsize_t wc = cc / 4;
if (wc > stride) {
TIFFSwabArrayOfLong(wp, wc);
wc -= stride;
do {
REPEAT4(stride, wp[stride] += wp[0]; wp++)
wc -= stride;
} while ((int32) wc > 0);
}
}
static void
horAcc32(TIFF* tif, tidata_t cp0, tsize_t cc)
{
tsize_t stride = PredictorState(tif)->stride;
uint32* wp = (uint32*) cp0;
tsize_t wc = cc / 4;
if (wc > stride) {
wc -= stride;
do {
REPEAT4(stride, wp[stride] += wp[0]; wp++)
wc -= stride;
} while ((int32) wc > 0);
}
}
/*
* Floating point predictor accumulation routine.
*/
@ -337,11 +391,11 @@ PredictorDecodeRow(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s)
TIFFPredictorState *sp = PredictorState(tif);
assert(sp != NULL);
assert(sp->coderow != NULL);
assert(sp->pfunc != NULL);
assert(sp->decoderow != NULL);
assert(sp->decodepfunc != NULL);
if ((*sp->coderow)(tif, op0, occ0, s)) {
(*sp->pfunc)(tif, op0, occ0);
if ((*sp->decoderow)(tif, op0, occ0, s)) {
(*sp->decodepfunc)(tif, op0, occ0);
return 1;
} else
return 0;
@ -360,14 +414,14 @@ PredictorDecodeTile(TIFF* tif, tidata_t op0, tsize_t occ0, tsample_t s)
TIFFPredictorState *sp = PredictorState(tif);
assert(sp != NULL);
assert(sp->codetile != NULL);
assert(sp->decodetile != NULL);
if ((*sp->codetile)(tif, op0, occ0, s)) {
if ((*sp->decodetile)(tif, op0, occ0, s)) {
tsize_t rowsize = sp->rowsize;
assert(rowsize > 0);
assert(sp->pfunc != NULL);
assert(sp->decodepfunc != NULL);
while ((long)occ0 > 0) {
(*sp->pfunc)(tif, op0, (tsize_t) rowsize);
(*sp->decodepfunc)(tif, op0, (tsize_t) rowsize);
occ0 -= rowsize;
op0 += rowsize;
}
@ -439,6 +493,24 @@ horDiff16(TIFF* tif, tidata_t cp0, tsize_t cc)
}
}
static void
horDiff32(TIFF* tif, tidata_t cp0, tsize_t cc)
{
TIFFPredictorState* sp = PredictorState(tif);
tsize_t stride = sp->stride;
int32 *wp = (int32*) cp0;
tsize_t wc = cc/4;
if (wc > stride) {
wc -= stride;
wp += wc - 1;
do {
REPEAT4(stride, wp[stride] -= wp[0]; wp--)
wc -= stride;
} while ((int32) wc > 0);
}
}
/*
* Floating point predictor differencing routine.
*/
@ -481,33 +553,56 @@ PredictorEncodeRow(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
TIFFPredictorState *sp = PredictorState(tif);
assert(sp != NULL);
assert(sp->pfunc != NULL);
assert(sp->coderow != NULL);
assert(sp->encodepfunc != NULL);
assert(sp->encoderow != NULL);
/* XXX horizontal differencing alters user's data XXX */
(*sp->pfunc)(tif, bp, cc);
return (*sp->coderow)(tif, bp, cc, s);
(*sp->encodepfunc)(tif, bp, cc);
return (*sp->encoderow)(tif, bp, cc, s);
}
static int
PredictorEncodeTile(TIFF* tif, tidata_t bp0, tsize_t cc0, tsample_t s)
{
static const char module[] = "PredictorEncodeTile";
TIFFPredictorState *sp = PredictorState(tif);
uint8 *working_copy;
tsize_t cc = cc0, rowsize;
unsigned char* bp = bp0;
unsigned char* bp;
int result_code;
assert(sp != NULL);
assert(sp->pfunc != NULL);
assert(sp->codetile != NULL);
assert(sp->encodepfunc != NULL);
assert(sp->encodetile != NULL);
/*
* Do predictor manipulation in a working buffer to avoid altering
* the callers buffer. http://trac.osgeo.org/gdal/ticket/1965
*/
working_copy = (uint8*) _TIFFmalloc(cc0);
if( working_copy == NULL )
{
TIFFErrorExt(tif->tif_clientdata, module,
"Out of memory allocating %d byte temp buffer.",
cc0 );
return 0;
}
memcpy( working_copy, bp0, cc0 );
bp = working_copy;
rowsize = sp->rowsize;
assert(rowsize > 0);
while ((long)cc > 0) {
(*sp->pfunc)(tif, bp, (tsize_t) rowsize);
assert((cc0%rowsize)==0);
while (cc > 0) {
(*sp->encodepfunc)(tif, bp, rowsize);
cc -= rowsize;
bp += rowsize;
}
return (*sp->codetile)(tif, bp0, cc0, s);
result_code = (*sp->encodetile)(tif, working_copy, cc0, s);
_TIFFfree( working_copy );
return result_code;
}
#define FIELD_PREDICTOR (FIELD_CODEC+0) /* XXX */
@ -516,7 +611,6 @@ static const TIFFFieldInfo predictFieldInfo[] = {
{ TIFFTAG_PREDICTOR, 1, 1, TIFF_SHORT, FIELD_PREDICTOR,
FALSE, FALSE, "Predictor" },
};
#define N(a) (sizeof (a) / sizeof (a[0]))
static int
PredictorVSetField(TIFF* tif, ttag_t tag, va_list ap)
@ -583,10 +677,18 @@ TIFFPredictorInit(TIFF* tif)
assert(sp != 0);
/*
* Merge codec-specific tag information and
* override parent get/set field methods.
* Merge codec-specific tag information.
*/
if (!_TIFFMergeFieldInfo(tif, predictFieldInfo,
TIFFArrayCount(predictFieldInfo))) {
TIFFErrorExt(tif->tif_clientdata, "TIFFPredictorInit",
"Merging Predictor codec-specific tags failed");
return 0;
}
/*
* Override parent get/set field methods.
*/
_TIFFMergeFieldInfo(tif, predictFieldInfo, N(predictFieldInfo));
sp->vgetparent = tif->tif_tagmethods.vgetfield;
tif->tif_tagmethods.vgetfield =
PredictorVGetField;/* hook for predictor tag */
@ -603,7 +705,8 @@ TIFFPredictorInit(TIFF* tif)
tif->tif_setupencode = PredictorSetupEncode;
sp->predictor = 1; /* default value */
sp->pfunc = NULL; /* no predictor routine */
sp->encodepfunc = NULL; /* no predictor routine */
sp->decodepfunc = NULL; /* no predictor routine */
return 1;
}
@ -624,3 +727,10 @@ TIFFPredictorCleanup(TIFF* tif)
}
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tif_predict.h,v 1.3 2006/03/03 14:10:09 dron Exp $ */
/* $Id: tif_predict.h,v 1.3.2.2 2010-06-08 18:50:42 bfriesen Exp $ */
/*
* Copyright (c) 1995-1997 Sam Leffler
@ -40,10 +40,16 @@ typedef struct {
int stride; /* sample stride over data */
tsize_t rowsize; /* tile/strip row size */
TIFFPostMethod pfunc; /* horizontal differencer/accumulator */
TIFFCodeMethod coderow; /* parent codec encode/decode row */
TIFFCodeMethod codestrip; /* parent codec encode/decode strip */
TIFFCodeMethod codetile; /* parent codec encode/decode tile */
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 decoderow; /* parent codec encode/decode row */
TIFFCodeMethod decodestrip; /* parent codec encode/decode strip */
TIFFCodeMethod decodetile; /* parent codec encode/decode tile */
TIFFPostMethod decodepfunc; /* horizontal accumulator */
TIFFVGetMethod vgetparent; /* super-class method */
TIFFVSetMethod vsetparent; /* super-class method */
TIFFPrintMethod printdir; /* super-class method */
@ -62,3 +68,10 @@ extern int TIFFPredictorCleanup(TIFF*);
#endif /* _TIFFPREDICT_ */
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tif_print.c,v 1.35 2006/03/13 07:53:28 dron Exp $ */
/* $Id: tif_print.c,v 1.36.2.5 2010-07-06 14:05:30 dron Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -31,7 +31,7 @@
*/
#include "tiffiop.h"
#include <stdio.h>
#include <string.h>
#include <ctype.h>
static const char *photoNames[] = {
@ -132,10 +132,6 @@ _TIFFPrettyPrintField(TIFF* tif, FILE* fd, ttag_t tag,
break;
}
return 1;
case TIFFTAG_DOTRANGE:
fprintf(fd, " Dot Range: %u-%u\n",
((uint16*)raw_data)[0], ((uint16*)raw_data)[1]);
return 1;
case TIFFTAG_WHITEPOINT:
fprintf(fd, " White Point: %g-%g\n",
((float *)raw_data)[0], ((float *)raw_data)[1]); return 1;
@ -144,7 +140,7 @@ _TIFFPrettyPrintField(TIFF* tif, FILE* fd, ttag_t tag,
uint16 i;
fprintf(fd, " Reference Black/White:\n");
for (i = 0; i < td->td_samplesperpixel; i++)
for (i = 0; i < 3; i++)
fprintf(fd, " %2d: %5g %5g\n", i,
((float *)raw_data)[2*i+0],
((float *)raw_data)[2*i+1]);
@ -491,7 +487,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
} else
fprintf(fd, "(present)\n");
}
if (TIFFFieldSet(tif, FIELD_SUBIFD)) {
if (TIFFFieldSet(tif, FIELD_SUBIFD) && (td->td_subifd)) {
fprintf(fd, " SubIFD Offsets:");
for (i = 0; i < td->td_nsubifd; i++)
fprintf(fd, " %5lu", (long) td->td_subifd[i]);
@ -509,7 +505,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
for(i = 0; i < count; i++) {
ttag_t tag = TIFFGetTagListEntry(tif, i);
const TIFFFieldInfo *fip;
uint16 value_count;
uint32 value_count;
int mem_alloc = 0;
void *raw_data;
@ -637,3 +633,10 @@ _TIFFprintAsciiTag(FILE* fd, const char* name, const char* value)
}
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tif_read.c,v 1.13 2005/12/21 12:23:13 joris Exp $ */
/* $Id: tif_read.c,v 1.16.2.3 2010-06-09 14:32:47 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -50,8 +50,10 @@ TIFFSeek(TIFF* tif, uint32 row, tsample_t sample)
tstrip_t strip;
if (row >= td->td_imagelength) { /* out of range */
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "%lu: Row out of range, max %lu",
(unsigned long) row, (unsigned long) td->td_imagelength);
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"%lu: Row out of range, max %lu",
(unsigned long) row,
(unsigned long) td->td_imagelength);
return (0);
}
if (td->td_planarconfig == PLANARCONFIG_SEPARATE) {
@ -64,7 +66,7 @@ TIFFSeek(TIFF* tif, uint32 row, tsample_t sample)
strip = sample*td->td_stripsperimage + row/td->td_rowsperstrip;
} else
strip = row / td->td_rowsperstrip;
if (strip != tif->tif_curstrip) { /* different strip, refill */
if (strip != tif->tif_curstrip) { /* different strip, refill */
if (!TIFFFillStrip(tif, strip))
return (0);
} else if (row < tif->tif_row) {
@ -104,8 +106,8 @@ TIFFReadScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample)
e = (*tif->tif_decoderow)
(tif, (tidata_t) buf, tif->tif_scanlinesize, sample);
/* we are now poised at the beginning of the next row */
tif->tif_row = row + 1;
/* we are now poised at the beginning of the next row */
tif->tif_row = row + 1;
if (e)
(*tif->tif_postdecode)(tif, (tidata_t) buf,
@ -129,22 +131,23 @@ TIFFReadEncodedStrip(TIFF* tif, tstrip_t strip, tdata_t buf, tsize_t size)
if (!TIFFCheckRead(tif, 0))
return (-1);
if (strip >= td->td_nstrips) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "%ld: Strip out of range, max %ld",
(long) strip, (long) td->td_nstrips);
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"%ld: Strip out of range, max %ld",
(long) strip, (long) td->td_nstrips);
return (-1);
}
/*
* Calculate the strip size according to the number of
* rows in the strip (check for truncated last strip on any
* of the separations).
* of the separations).
*/
if( td->td_rowsperstrip >= td->td_imagelength )
strips_per_sep = 1;
else
strips_per_sep = (td->td_imagelength+td->td_rowsperstrip-1)
/ td->td_rowsperstrip;
if( td->td_rowsperstrip >= td->td_imagelength )
strips_per_sep = 1;
else
strips_per_sep = (td->td_imagelength+td->td_rowsperstrip-1)
/ td->td_rowsperstrip;
sep_strip = strip % strips_per_sep;
sep_strip = strip % strips_per_sep;
if (sep_strip != strips_per_sep-1 ||
(nrows = td->td_imagelength % td->td_rowsperstrip) == 0)
@ -155,9 +158,9 @@ TIFFReadEncodedStrip(TIFF* tif, tstrip_t strip, tdata_t buf, tsize_t size)
size = stripsize;
else if (size > stripsize)
size = stripsize;
if (TIFFFillStrip(tif, strip)
&& (*tif->tif_decodestrip)(tif, (tidata_t) buf, size,
(tsample_t)(strip / td->td_stripsperimage)) > 0 ) {
if (TIFFFillStrip(tif, strip)
&& (*tif->tif_decodestrip)(tif, (tidata_t) buf, size,
(tsample_t)(strip / td->td_stripsperimage)) > 0 ) {
(*tif->tif_postdecode)(tif, (tidata_t) buf, size);
return (size);
} else
@ -170,6 +173,7 @@ TIFFReadRawStrip1(TIFF* tif,
{
TIFFDirectory *td = &tif->tif_dir;
assert((tif->tif_flags&TIFF_NOREADRAW)==0);
if (!isMapped(tif)) {
tsize_t cc;
@ -215,13 +219,27 @@ TIFFReadRawStrip(TIFF* tif, tstrip_t strip, tdata_t buf, tsize_t size)
{
static const char module[] = "TIFFReadRawStrip";
TIFFDirectory *td = &tif->tif_dir;
tsize_t bytecount;
/*
* FIXME: butecount should have tsize_t type, but for now libtiff
* defines tsize_t as a signed 32-bit integer and we are losing
* ability to read arrays larger than 2^31 bytes. So we are using
* uint32 instead of tsize_t here.
*/
uint32 bytecount;
if (!TIFFCheckRead(tif, 0))
return ((tsize_t) -1);
if (strip >= td->td_nstrips) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "%lu: Strip out of range, max %lu",
(unsigned long) strip, (unsigned long) td->td_nstrips);
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"%lu: Strip out of range, max %lu",
(unsigned long) strip,
(unsigned long) td->td_nstrips);
return ((tsize_t) -1);
}
if (tif->tif_flags&TIFF_NOREADRAW)
{
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"Compression scheme does not support access to raw uncompressed data");
return ((tsize_t) -1);
}
bytecount = td->td_stripbytecount[strip];
@ -231,88 +249,110 @@ TIFFReadRawStrip(TIFF* tif, tstrip_t strip, tdata_t buf, tsize_t size)
(unsigned long) bytecount, (unsigned long) strip);
return ((tsize_t) -1);
}
if (size != (tsize_t)-1 && size < bytecount)
if (size != (tsize_t)-1 && (uint32)size < bytecount)
bytecount = size;
return (TIFFReadRawStrip1(tif, strip, buf, bytecount, module));
}
/*
* Read the specified strip and setup for decoding.
* The data buffer is expanded, as necessary, to
* hold the strip's data.
* Read the specified strip and setup for decoding. The data buffer is
* expanded, as necessary, to hold the strip's data.
*/
int
TIFFFillStrip(TIFF* tif, tstrip_t strip)
{
static const char module[] = "TIFFFillStrip";
TIFFDirectory *td = &tif->tif_dir;
tsize_t bytecount;
bytecount = td->td_stripbytecount[strip];
if (bytecount <= 0) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"%lu: Invalid strip byte count, strip %lu",
(unsigned long) bytecount, (unsigned long) strip);
return (0);
}
if (isMapped(tif) &&
(isFillOrder(tif, td->td_fillorder)
|| (tif->tif_flags & TIFF_NOBITREV))) {
if ((tif->tif_flags&TIFF_NOREADRAW)==0)
{
/*
* The image is mapped into memory and we either don't
* need to flip bits or the compression routine is going
* to handle this operation itself. In this case, avoid
* copying the raw data and instead just reference the
* data from the memory mapped file image. This assumes
* that the decompression routines do not modify the
* contents of the raw data buffer (if they try to,
* the application will get a fault since the file is
* mapped read-only).
* FIXME: butecount should have tsize_t type, but for now
* libtiff defines tsize_t as a signed 32-bit integer and we
* are losing ability to read arrays larger than 2^31 bytes.
* So we are using uint32 instead of tsize_t here.
*/
if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata)
_TIFFfree(tif->tif_rawdata);
tif->tif_flags &= ~TIFF_MYBUFFER;
if ( td->td_stripoffset[strip] + bytecount > tif->tif_size) {
/*
* This error message might seem strange, but it's
* what would happen if a read were done instead.
*/
uint32 bytecount = td->td_stripbytecount[strip];
if (bytecount <= 0) {
TIFFErrorExt(tif->tif_clientdata, module,
"%s: Read error on strip %lu; got %lu bytes, expected %lu",
tif->tif_name,
(unsigned long) strip,
(unsigned long) tif->tif_size - td->td_stripoffset[strip],
(unsigned long) bytecount);
tif->tif_curstrip = NOSTRIP;
"%s: Invalid strip byte count %lu, strip %lu",
tif->tif_name, (unsigned long) bytecount,
(unsigned long) strip);
return (0);
}
tif->tif_rawdatasize = bytecount;
tif->tif_rawdata = tif->tif_base + td->td_stripoffset[strip];
} else {
/*
* Expand raw data buffer, if needed, to
* hold data strip coming from file
* (perhaps should set upper bound on
* the size of a buffer we'll use?).
*/
if (bytecount > tif->tif_rawdatasize) {
tif->tif_curstrip = NOSTRIP;
if ((tif->tif_flags & TIFF_MYBUFFER) == 0) {
if (isMapped(tif) &&
(isFillOrder(tif, td->td_fillorder)
|| (tif->tif_flags & TIFF_NOBITREV))) {
/*
* The image is mapped into memory and we either don't
* need to flip bits or the compression routine is
* going to handle this operation itself. In this
* case, avoid copying the raw data and instead just
* reference the data from the memory mapped file
* image. This assumes that the decompression
* routines do not modify the contents of the raw data
* buffer (if they try to, the application will get a
* fault since the file is mapped read-only).
*/
if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata)
_TIFFfree(tif->tif_rawdata);
tif->tif_flags &= ~TIFF_MYBUFFER;
/*
* We must check for overflow, potentially causing
* an OOB read. Instead of simple
*
* td->td_stripoffset[strip]+bytecount > tif->tif_size
*
* comparison (which can overflow) we do the following
* two comparisons:
*/
if (bytecount > tif->tif_size ||
td->td_stripoffset[strip] > tif->tif_size - bytecount) {
/*
* This error message might seem strange, but
* it's what would happen if a read were done
* instead.
*/
TIFFErrorExt(tif->tif_clientdata, module,
"%s: Data buffer too small to hold strip %lu",
tif->tif_name, (unsigned long) strip);
"%s: Read error on strip %lu; "
"got %lu bytes, expected %lu",
tif->tif_name, (unsigned long) strip,
(unsigned long) tif->tif_size - td->td_stripoffset[strip],
(unsigned long) bytecount);
tif->tif_curstrip = NOSTRIP;
return (0);
}
if (!TIFFReadBufferSetup(tif, 0,
TIFFroundup(bytecount, 1024)))
tif->tif_rawdatasize = bytecount;
tif->tif_rawdata = tif->tif_base + td->td_stripoffset[strip];
} else {
/*
* Expand raw data buffer, if needed, to hold data
* strip coming from file (perhaps should set upper
* bound on the size of a buffer we'll use?).
*/
if (bytecount > (uint32)tif->tif_rawdatasize) {
tif->tif_curstrip = NOSTRIP;
if ((tif->tif_flags & TIFF_MYBUFFER) == 0) {
TIFFErrorExt(tif->tif_clientdata,
module,
"%s: Data buffer too small to hold strip %lu",
tif->tif_name,
(unsigned long) strip);
return (0);
}
if (!TIFFReadBufferSetup(tif, 0,
TIFFroundup(bytecount, 1024)))
return (0);
}
if ((uint32)TIFFReadRawStrip1(tif, strip,
(unsigned char *)tif->tif_rawdata,
bytecount, module) != bytecount)
return (0);
if (!isFillOrder(tif, td->td_fillorder) &&
(tif->tif_flags & TIFF_NOBITREV) == 0)
TIFFReverseBits(tif->tif_rawdata, bytecount);
}
if (TIFFReadRawStrip1(tif, strip, (unsigned char *)tif->tif_rawdata,
bytecount, module) != bytecount)
return (0);
if (!isFillOrder(tif, td->td_fillorder) &&
(tif->tif_flags & TIFF_NOBITREV) == 0)
TIFFReverseBits(tif->tif_rawdata, bytecount);
}
return (TIFFStartStrip(tif, strip));
}
@ -349,8 +389,9 @@ TIFFReadEncodedTile(TIFF* tif, ttile_t tile, tdata_t buf, tsize_t size)
if (!TIFFCheckRead(tif, 1))
return (-1);
if (tile >= td->td_nstrips) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "%ld: Tile out of range, max %ld",
(long) tile, (unsigned long) td->td_nstrips);
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"%ld: Tile out of range, max %ld",
(long) tile, (unsigned long) td->td_nstrips);
return (-1);
}
if (size == (tsize_t) -1)
@ -371,6 +412,7 @@ TIFFReadRawTile1(TIFF* tif,
{
TIFFDirectory *td = &tif->tif_dir;
assert((tif->tif_flags&TIFF_NOREADRAW)==0);
if (!isMapped(tif)) {
tsize_t cc;
@ -419,89 +461,121 @@ TIFFReadRawTile(TIFF* tif, ttile_t tile, tdata_t buf, tsize_t size)
{
static const char module[] = "TIFFReadRawTile";
TIFFDirectory *td = &tif->tif_dir;
tsize_t bytecount;
/*
* FIXME: butecount should have tsize_t type, but for now libtiff
* defines tsize_t as a signed 32-bit integer and we are losing
* ability to read arrays larger than 2^31 bytes. So we are using
* uint32 instead of tsize_t here.
*/
uint32 bytecount;
if (!TIFFCheckRead(tif, 1))
return ((tsize_t) -1);
if (tile >= td->td_nstrips) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "%lu: Tile out of range, max %lu",
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"%lu: Tile out of range, max %lu",
(unsigned long) tile, (unsigned long) td->td_nstrips);
return ((tsize_t) -1);
}
if (tif->tif_flags&TIFF_NOREADRAW)
{
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"Compression scheme does not support access to raw uncompressed data");
return ((tsize_t) -1);
}
bytecount = td->td_stripbytecount[tile];
if (size != (tsize_t) -1 && size < bytecount)
if (size != (tsize_t) -1 && (uint32)size < bytecount)
bytecount = size;
return (TIFFReadRawTile1(tif, tile, buf, bytecount, module));
}
/*
* Read the specified tile and setup for decoding.
* The data buffer is expanded, as necessary, to
* hold the tile's data.
* Read the specified tile and setup for decoding. The data buffer is
* expanded, as necessary, to hold the tile's data.
*/
int
TIFFFillTile(TIFF* tif, ttile_t tile)
{
static const char module[] = "TIFFFillTile";
TIFFDirectory *td = &tif->tif_dir;
tsize_t bytecount;
bytecount = td->td_stripbytecount[tile];
if (bytecount <= 0) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"%lu: Invalid tile byte count, tile %lu",
(unsigned long) bytecount, (unsigned long) tile);
return (0);
}
if (isMapped(tif) &&
(isFillOrder(tif, td->td_fillorder)
|| (tif->tif_flags & TIFF_NOBITREV))) {
if ((tif->tif_flags&TIFF_NOREADRAW)==0)
{
/*
* The image is mapped into memory and we either don't
* need to flip bits or the compression routine is going
* to handle this operation itself. In this case, avoid
* copying the raw data and instead just reference the
* data from the memory mapped file image. This assumes
* that the decompression routines do not modify the
* contents of the raw data buffer (if they try to,
* the application will get a fault since the file is
* mapped read-only).
* FIXME: butecount should have tsize_t type, but for now
* libtiff defines tsize_t as a signed 32-bit integer and we
* are losing ability to read arrays larger than 2^31 bytes.
* So we are using uint32 instead of tsize_t here.
*/
if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata)
_TIFFfree(tif->tif_rawdata);
tif->tif_flags &= ~TIFF_MYBUFFER;
if ( td->td_stripoffset[tile] + bytecount > tif->tif_size) {
tif->tif_curtile = NOTILE;
uint32 bytecount = td->td_stripbytecount[tile];
if (bytecount <= 0) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"%lu: Invalid tile byte count, tile %lu",
(unsigned long) bytecount, (unsigned long) tile);
return (0);
}
tif->tif_rawdatasize = bytecount;
tif->tif_rawdata = tif->tif_base + td->td_stripoffset[tile];
} else {
/*
* Expand raw data buffer, if needed, to
* hold data tile coming from file
* (perhaps should set upper bound on
* the size of a buffer we'll use?).
*/
if (bytecount > tif->tif_rawdatasize) {
tif->tif_curtile = NOTILE;
if ((tif->tif_flags & TIFF_MYBUFFER) == 0) {
TIFFErrorExt(tif->tif_clientdata, module,
"%s: Data buffer too small to hold tile %ld",
tif->tif_name, (long) tile);
if (isMapped(tif) &&
(isFillOrder(tif, td->td_fillorder)
|| (tif->tif_flags & TIFF_NOBITREV))) {
/*
* The image is mapped into memory and we either don't
* need to flip bits or the compression routine is
* going to handle this operation itself. In this
* case, avoid copying the raw data and instead just
* reference the data from the memory mapped file
* image. This assumes that the decompression
* routines do not modify the contents of the raw data
* buffer (if they try to, the application will get a
* fault since the file is mapped read-only).
*/
if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata)
_TIFFfree(tif->tif_rawdata);
tif->tif_flags &= ~TIFF_MYBUFFER;
/*
* We must check for overflow, potentially causing
* an OOB read. Instead of simple
*
* td->td_stripoffset[tile]+bytecount > tif->tif_size
*
* comparison (which can overflow) we do the following
* two comparisons:
*/
if (bytecount > tif->tif_size ||
td->td_stripoffset[tile] > tif->tif_size - bytecount) {
tif->tif_curtile = NOTILE;
return (0);
}
if (!TIFFReadBufferSetup(tif, 0,
TIFFroundup(bytecount, 1024)))
tif->tif_rawdatasize = bytecount;
tif->tif_rawdata =
tif->tif_base + td->td_stripoffset[tile];
} else {
/*
* Expand raw data buffer, if needed, to hold data
* tile coming from file (perhaps should set upper
* bound on the size of a buffer we'll use?).
*/
if (bytecount > (uint32)tif->tif_rawdatasize) {
tif->tif_curtile = NOTILE;
if ((tif->tif_flags & TIFF_MYBUFFER) == 0) {
TIFFErrorExt(tif->tif_clientdata,
module,
"%s: Data buffer too small to hold tile %ld",
tif->tif_name,
(long) tile);
return (0);
}
if (!TIFFReadBufferSetup(tif, 0,
TIFFroundup(bytecount, 1024)))
return (0);
}
if ((uint32)TIFFReadRawTile1(tif, tile,
(unsigned char *)tif->tif_rawdata,
bytecount, module) != bytecount)
return (0);
if (!isFillOrder(tif, td->td_fillorder) &&
(tif->tif_flags & TIFF_NOBITREV) == 0)
TIFFReverseBits(tif->tif_rawdata, bytecount);
}
if (TIFFReadRawTile1(tif, tile,
(unsigned char *)tif->tif_rawdata,
bytecount, module) != bytecount)
return (0);
if (!isFillOrder(tif, td->td_fillorder) &&
(tif->tif_flags & TIFF_NOBITREV) == 0)
TIFFReverseBits(tif->tif_rawdata, bytecount);
}
return (TIFFStartTile(tif, tile));
}
@ -520,21 +594,24 @@ TIFFReadBufferSetup(TIFF* tif, tdata_t bp, tsize_t size)
{
static const char module[] = "TIFFReadBufferSetup";
assert((tif->tif_flags&TIFF_NOREADRAW)==0);
if (tif->tif_rawdata) {
if (tif->tif_flags & TIFF_MYBUFFER)
_TIFFfree(tif->tif_rawdata);
tif->tif_rawdata = NULL;
}
if (bp) {
tif->tif_rawdatasize = size;
tif->tif_rawdata = (tidata_t) bp;
tif->tif_flags &= ~TIFF_MYBUFFER;
} else {
tif->tif_rawdatasize = TIFFroundup(size, 1024);
tif->tif_rawdata = (tidata_t) _TIFFmalloc(tif->tif_rawdatasize);
if (tif->tif_rawdatasize > 0)
tif->tif_rawdata = (tidata_t) _TIFFmalloc(tif->tif_rawdatasize);
tif->tif_flags |= TIFF_MYBUFFER;
}
if (tif->tif_rawdata == NULL) {
if ((tif->tif_rawdata == NULL) || (tif->tif_rawdatasize == 0)) {
TIFFErrorExt(tif->tif_clientdata, module,
"%s: No space for data buffer at scanline %ld",
tif->tif_name, (long) tif->tif_row);
@ -560,8 +637,16 @@ TIFFStartStrip(TIFF* tif, tstrip_t strip)
}
tif->tif_curstrip = strip;
tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip;
tif->tif_rawcp = tif->tif_rawdata;
tif->tif_rawcc = td->td_stripbytecount[strip];
if (tif->tif_flags&TIFF_NOREADRAW)
{
tif->tif_rawcp = NULL;
tif->tif_rawcc = 0;
}
else
{
tif->tif_rawcp = tif->tif_rawdata;
tif->tif_rawcc = td->td_stripbytecount[strip];
}
return ((*tif->tif_predecode)(tif,
(tsample_t)(strip / td->td_stripsperimage)));
}
@ -587,8 +672,16 @@ TIFFStartTile(TIFF* tif, ttile_t tile)
tif->tif_col =
(tile % TIFFhowmany(td->td_imagelength, td->td_tilelength)) *
td->td_tilewidth;
tif->tif_rawcp = tif->tif_rawdata;
tif->tif_rawcc = td->td_stripbytecount[tile];
if (tif->tif_flags&TIFF_NOREADRAW)
{
tif->tif_rawcp = NULL;
tif->tif_rawcc = 0;
}
else
{
tif->tif_rawcp = tif->tif_rawdata;
tif->tif_rawcc = td->td_stripbytecount[tile];
}
return ((*tif->tif_predecode)(tif,
(tsample_t)(tile/td->td_stripsperimage)));
}
@ -648,3 +741,10 @@ _TIFFSwab64BitData(TIFF* tif, tidata_t buf, tsize_t cc)
}
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tif_stream.cxx,v 1.5 2005/07/26 08:11:13 dron Exp $ */
/* $Id: tif_stream.cxx,v 1.6.2.1 2009-01-01 00:10:43 bfriesen Exp $ */
/*
* Copyright (c) 1988-1996 Sam Leffler
@ -30,7 +30,9 @@
#include "tiffiop.h"
#include <iostream>
#ifndef __VMS
using namespace std;
#endif
class tiffis_data
{
@ -109,8 +111,12 @@ _tiffosSeekProc(thandle_t fd, toff_t off, int whence)
// ostrstream/ostringstream does. In that situation, add intermediate
// '\0' characters.
if( os->fail() ) {
#ifdef __VMS
int old_state;
#else
ios::iostate old_state;
toff_t origin;
#endif
toff_t origin=0;
old_state = os->rdstate();
// reset the fail bit or else tellp() won't work below

View file

@ -1,4 +1,4 @@
/* $Id: tif_strip.c,v 1.17 2006/03/21 16:29:33 dron Exp $ */
/* $Id: tif_strip.c,v 1.19.2.3 2010-12-15 00:50:30 faxguy Exp $ */
/*
* Copyright (c) 1991-1997 Sam Leffler
@ -121,12 +121,12 @@ TIFFVStripSize(TIFF* tif, uint32 nrows)
* horizontal/vertical subsampling area include
* YCbCr data for the extended image.
*/
uint16 ycbcrsubsampling[2];
tsize_t w, scanline, samplingarea;
uint16 ycbcrsubsampling[2];
tsize_t w, scanline, samplingarea;
TIFFGetField( tif, TIFFTAG_YCBCRSUBSAMPLING,
ycbcrsubsampling + 0,
ycbcrsubsampling + 1 );
TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING,
ycbcrsubsampling + 0,
ycbcrsubsampling + 1);
samplingarea = ycbcrsubsampling[0]*ycbcrsubsampling[1];
if (samplingarea == 0) {
@ -228,33 +228,98 @@ TIFFScanlineSize(TIFF* tif)
{
TIFFDirectory *td = &tif->tif_dir;
tsize_t scanline;
if (td->td_planarconfig == PLANARCONFIG_CONTIG) {
if (td->td_photometric == PHOTOMETRIC_YCBCR
&& !isUpSampled(tif)) {
uint16 ycbcrsubsampling[2];
TIFFGetField(tif, TIFFTAG_YCBCRSUBSAMPLING,
ycbcrsubsampling + 0,
ycbcrsubsampling + 1);
TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING,
ycbcrsubsampling + 0,
ycbcrsubsampling + 1);
if (ycbcrsubsampling[0] == 0) {
if (ycbcrsubsampling[0]*ycbcrsubsampling[1] == 0) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"Invalid YCbCr subsampling");
return 0;
}
scanline = TIFFroundup(td->td_imagewidth,
/* number of sample clumps per line */
scanline = TIFFhowmany(td->td_imagewidth,
ycbcrsubsampling[0]);
scanline = TIFFhowmany8(multiply(tif, scanline,
td->td_bitspersample,
"TIFFScanlineSize"));
return ((tsize_t)
summarize(tif, scanline,
multiply(tif, 2,
scanline / ycbcrsubsampling[0],
"TIFFVStripSize"),
"TIFFVStripSize"));
/* number of samples per line */
scanline = multiply(tif, scanline,
ycbcrsubsampling[0]*ycbcrsubsampling[1] + 2,
"TIFFScanlineSize");
} else {
scanline = multiply(tif, td->td_imagewidth,
td->td_samplesperpixel,
"TIFFScanlineSize");
}
} else
scanline = td->td_imagewidth;
return ((tsize_t) TIFFhowmany8(multiply(tif, scanline,
td->td_bitspersample,
"TIFFScanlineSize")));
}
/*
* Some stuff depends on this older version of TIFFScanlineSize
* TODO: resolve this
*/
tsize_t
TIFFOldScanlineSize(TIFF* tif)
{
TIFFDirectory *td = &tif->tif_dir;
tsize_t scanline;
scanline = multiply (tif, td->td_bitspersample, td->td_imagewidth,
"TIFFScanlineSize");
if (td->td_planarconfig == PLANARCONFIG_CONTIG)
scanline = multiply (tif, scanline, td->td_samplesperpixel,
"TIFFScanlineSize");
return ((tsize_t) TIFFhowmany8(scanline));
}
/*
* Return the number of bytes to read/write in a call to
* one of the scanline-oriented i/o routines. Note that
* this number may be 1/samples-per-pixel if data is
* stored as separate planes.
* The ScanlineSize in case of YCbCrSubsampling is defined as the
* strip size divided by the strip height, i.e. the size of a pack of vertical
* subsampling lines divided by vertical subsampling. It should thus make
* sense when multiplied by a multiple of vertical subsampling.
* Some stuff depends on this newer version of TIFFScanlineSize
* TODO: resolve this
*/
tsize_t
TIFFNewScanlineSize(TIFF* tif)
{
TIFFDirectory *td = &tif->tif_dir;
tsize_t scanline;
if (td->td_planarconfig == PLANARCONFIG_CONTIG) {
if (td->td_photometric == PHOTOMETRIC_YCBCR
&& !isUpSampled(tif)) {
uint16 ycbcrsubsampling[2];
TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING,
ycbcrsubsampling + 0,
ycbcrsubsampling + 1);
if (ycbcrsubsampling[0]*ycbcrsubsampling[1] == 0) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"Invalid YCbCr subsampling");
return 0;
}
return((tsize_t) ((((td->td_imagewidth+ycbcrsubsampling[0]-1)
/ycbcrsubsampling[0])
*(ycbcrsubsampling[0]*ycbcrsubsampling[1]+2)
*td->td_bitspersample+7)
/8)/ycbcrsubsampling[1]);
} else {
scanline = multiply(tif, td->td_imagewidth,
td->td_samplesperpixel,
@ -292,3 +357,10 @@ TIFFRasterScanlineSize(TIFF* tif)
}
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tif_swab.c,v 1.4 2005/04/13 14:06:21 dron Exp $ */
/* $Id: tif_swab.c,v 1.4.2.1 2010-06-08 18:50:43 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -233,3 +233,10 @@ TIFFReverseBits(register unsigned char* cp, register unsigned long n)
}
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tif_thunder.c,v 1.5 2005/12/21 12:23:13 joris Exp $ */
/* $Id: tif_thunder.c,v 1.5.2.2 2011-03-21 16:01:28 fwarmerdam Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -25,6 +25,7 @@
*/
#include "tiffiop.h"
#include <assert.h>
#ifdef THUNDER_SUPPORT
/*
* TIFF Library.
@ -55,12 +56,32 @@
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; \
if (npixels++ & 1) \
*op++ |= lastpixel; \
else \
#define SETPIXEL(op, v) { \
lastpixel = (v) & 0xf; \
if ( npixels < maxpixels ) \
{ \
if (npixels++ & 1) \
*op++ |= lastpixel; \
else \
op[0] = (tidataval_t) (lastpixel << 4); \
} \
}
static int
ThunderSetupDecode(TIFF* tif)
{
static const char module[] = "ThunderSetupDecode";
if( tif->tif_dir.td_bitspersample != 4 )
{
TIFFErrorExt(tif->tif_clientdata, module,
"Wrong bitspersample value (%d), Thunder decoder only supports 4bits per sample.",
(int) tif->tif_dir.td_bitspersample );
return 0;
}
return (1);
}
static int
@ -142,7 +163,8 @@ ThunderDecodeRow(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s)
occ -= tif->tif_scanlinesize;
row += tif->tif_scanlinesize;
}
return (1);
return (1);
}
int
@ -151,8 +173,17 @@ TIFFInitThunderScan(TIFF* tif, int scheme)
(void) scheme;
tif->tif_decoderow = ThunderDecodeRow;
tif->tif_decodestrip = ThunderDecodeRow;
tif->tif_setupdecode = ThunderSetupDecode;
return (1);
}
#endif /* THUNDER_SUPPORT */
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tif_tile.c,v 1.12 2006/02/09 16:15:43 dron Exp $ */
/* $Id: tif_tile.c,v 1.12.2.1 2010-06-08 18:50:43 bfriesen Exp $ */
/*
* Copyright (c) 1991-1997 Sam Leffler
@ -271,3 +271,10 @@ _TIFFDefaultTileSize(TIFF* tif, uint32* tw, uint32* th)
}
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tif_unix.c,v 1.12 2006/03/21 16:37:51 dron Exp $ */
/* $Id: tif_unix.c,v 1.12.2.1 2010-06-08 18:50:43 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -291,3 +291,10 @@ unixErrorHandler(const char* module, const char* fmt, va_list ap)
fprintf(stderr, ".\n");
}
TIFFErrorHandler _TIFFerrorHandler = unixErrorHandler;
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_version.c,v 1.2 2000/11/13 14:42:38 warmerda Exp $ */
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_version.c,v 1.2.2.1 2010-06-08 18:50:43 bfriesen Exp $ */
/*
* Copyright (c) 1992-1997 Sam Leffler
* Copyright (c) 1992-1997 Silicon Graphics, Inc.
@ -31,3 +31,10 @@ TIFFGetVersion(void)
{
return (TIFFVersion);
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_warning.c,v 1.2 2005/12/23 01:18:59 joris Exp $ */
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_warning.c,v 1.2.2.1 2010-06-08 18:50:43 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -72,3 +72,10 @@ TIFFWarningExt(thandle_t fd, const char* module, const char* fmt, ...)
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_win3.c,v 1.2 2005/12/21 12:23:13 joris Exp $ */
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/Attic/tif_win3.c,v 1.2.2.1 2010-06-08 18:50:43 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -223,3 +223,10 @@ win3ErrorHandler(const char* module, const char* fmt, va_list ap)
MessageBox(GetActiveWindow(), e, "LibTIFF Error", MB_OK|MB_ICONSTOP);
}
TIFFErrorHandler _TIFFerrorHandler = win3ErrorHandler;
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tif_win32.c,v 1.18 2006/02/07 11:03:29 dron Exp $ */
/* $Id: tif_win32.c,v 1.21.2.1 2010-06-08 18:50:43 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -30,6 +30,8 @@
*/
#include "tiffiop.h"
#include <windows.h>
static tsize_t
_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size)
{
@ -51,11 +53,10 @@ _tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size)
static toff_t
_tiffSeekProc(thandle_t fd, toff_t off, int whence)
{
DWORD dwMoveMethod, dwMoveHigh;
ULARGE_INTEGER li;
DWORD dwMoveMethod;
/* we use this as a special code, so avoid accepting it */
if( off == 0xFFFFFFFF )
return 0xFFFFFFFF;
li.QuadPart = off;
switch(whence)
{
@ -72,9 +73,8 @@ _tiffSeekProc(thandle_t fd, toff_t off, int whence)
dwMoveMethod = FILE_BEGIN;
break;
}
dwMoveHigh = 0;
return ((toff_t)SetFilePointer(fd, (LONG) off, (PLONG)&dwMoveHigh,
dwMoveMethod));
return ((toff_t)SetFilePointer(fd, (LONG) li.LowPart,
(PLONG)&li.HighPart, dwMoveMethod));
}
static int
@ -89,12 +89,12 @@ _tiffSizeProc(thandle_t fd)
return ((toff_t)GetFileSize(fd, NULL));
}
#ifdef __BORLANDC__
#pragma argsused
#endif
static int
_tiffDummyMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize)
{
(void) fd;
(void) pbase;
(void) psize;
return (0);
}
@ -128,12 +128,12 @@ _tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize)
return(1);
}
#ifdef __BORLANDC__
#pragma argsused
#endif
static void
_tiffDummyUnmapProc(thandle_t fd, tdata_t base, toff_t size)
{
(void) fd;
(void) base;
(void) size;
}
static void
@ -163,6 +163,8 @@ TIFFFdOpen(int ifd, const char* name, const char* mode)
return (tif);
}
#ifndef _WIN32_WCE
/*
* Open a TIFF file for read/writing.
*/
@ -272,6 +274,9 @@ TIFFOpenW(const wchar_t* name, const char* mode)
return tif;
}
#endif /* ndef _WIN32_WCE */
tdata_t
_TIFFmalloc(tsize_t s)
{
@ -288,26 +293,26 @@ _TIFFfree(tdata_t p)
tdata_t
_TIFFrealloc(tdata_t p, tsize_t s)
{
void* pvTmp;
tsize_t old;
void* pvTmp;
tsize_t old;
if(p == NULL)
return ((tdata_t)GlobalAlloc(GMEM_FIXED, s));
if(p == NULL)
return ((tdata_t)GlobalAlloc(GMEM_FIXED, s));
old = GlobalSize(p);
old = GlobalSize(p);
if (old>=s) {
if ((pvTmp = GlobalAlloc(GMEM_FIXED, s)) != NULL) {
CopyMemory(pvTmp, p, s);
GlobalFree(p);
}
} else {
if ((pvTmp = GlobalAlloc(GMEM_FIXED, s)) != NULL) {
CopyMemory(pvTmp, p, old);
GlobalFree(p);
}
}
return ((tdata_t)pvTmp);
if (old>=s) {
if ((pvTmp = GlobalAlloc(GMEM_FIXED, s)) != NULL) {
CopyMemory(pvTmp, p, s);
GlobalFree(p);
}
} else {
if ((pvTmp = GlobalAlloc(GMEM_FIXED, s)) != NULL) {
CopyMemory(pvTmp, p, old);
GlobalFree(p);
}
}
return ((tdata_t)pvTmp);
}
void
@ -334,6 +339,8 @@ _TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c)
return (iTmp);
}
#ifndef _WIN32_WCE
static void
Win32WarningHandler(const char* module, const char* fmt, va_list ap)
{
@ -389,4 +396,13 @@ Win32ErrorHandler(const char* module, const char* fmt, va_list ap)
}
TIFFErrorHandler _TIFFerrorHandler = Win32ErrorHandler;
#endif /* ndef _WIN32_WCE */
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tif_write.c,v 1.21 2006/02/27 14:29:20 dron Exp $ */
/* $Id: tif_write.c,v 1.22.2.5 2010-06-08 18:50:43 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -227,10 +227,8 @@ TIFFWriteEncodedStrip(TIFF* tif, tstrip_t strip, tdata_t data, tsize_t cc)
if( td->td_stripbytecount[strip] > 0 )
{
/* if we are writing over existing tiles, zero length. */
td->td_stripbytecount[strip] = 0;
/* this forces TIFFAppendToStrip() to do a seek */
/* Force TIFFAppendToStrip() to consider placing data at end
of file. */
tif->tif_curoff = 0;
}
@ -363,10 +361,8 @@ TIFFWriteEncodedTile(TIFF* tif, ttile_t tile, tdata_t data, tsize_t cc)
if( td->td_stripbytecount[tile] > 0 )
{
/* if we are writing over existing tiles, zero length. */
td->td_stripbytecount[tile] = 0;
/* this forces TIFFAppendToStrip() to do a seek */
/* Force TIFFAppendToStrip() to consider placing data at end
of file. */
tif->tif_curoff = 0;
}
@ -521,7 +517,8 @@ TIFFWriteCheck(TIFF* tif, int tiles, const char* module)
* because this field is used in other parts of library even
* in the single band case.
*/
tif->tif_dir.td_planarconfig = PLANARCONFIG_CONTIG;
if (!TIFFFieldSet(tif, FIELD_PLANARCONFIG))
tif->tif_dir.td_planarconfig = PLANARCONFIG_CONTIG;
} else {
if (!TIFFFieldSet(tif, FIELD_PLANARCONFIG)) {
TIFFErrorExt(tif->tif_clientdata, module,
@ -625,64 +622,53 @@ TIFFGrowStrips(TIFF* tif, int delta, const char* module)
static int
TIFFAppendToStrip(TIFF* tif, tstrip_t strip, tidata_t data, tsize_t cc)
{
TIFFDirectory *td = &tif->tif_dir;
static const char module[] = "TIFFAppendToStrip";
TIFFDirectory *td = &tif->tif_dir;
if (td->td_stripoffset[strip] == 0 || tif->tif_curoff == 0) {
/*
* No current offset, set the current strip.
*/
assert(td->td_nstrips > 0);
if (td->td_stripoffset[strip] != 0) {
/*
* Prevent overlapping of the data chunks. We need
* this to enable in place updating of the compressed
* images. Larger blocks will be moved at the end of
* the file without any optimization of the spare
* space, so such scheme is not too much effective.
*/
if (td->td_stripbytecountsorted) {
if (strip == td->td_nstrips - 1
|| td->td_stripoffset[strip + 1] <
td->td_stripoffset[strip] + cc) {
td->td_stripoffset[strip] =
TIFFSeekFile(tif, (toff_t)0,
SEEK_END);
}
} else {
tstrip_t i;
for (i = 0; i < td->td_nstrips; i++) {
if (td->td_stripoffset[i] >
td->td_stripoffset[strip]
&& td->td_stripoffset[i] <
td->td_stripoffset[strip] + cc) {
td->td_stripoffset[strip] =
TIFFSeekFile(tif,
(toff_t)0,
SEEK_END);
}
}
}
assert(td->td_nstrips > 0);
if (!SeekOK(tif, td->td_stripoffset[strip])) {
TIFFErrorExt(tif->tif_clientdata, module,
"%s: Seek error at scanline %lu",
tif->tif_name,
(unsigned long)tif->tif_row);
return (0);
}
} else
td->td_stripoffset[strip] =
TIFFSeekFile(tif, (toff_t) 0, SEEK_END);
tif->tif_curoff = td->td_stripoffset[strip];
if( td->td_stripbytecount[strip] != 0
&& td->td_stripoffset[strip] != 0
&& td->td_stripbytecount[strip] >= cc )
{
/*
* There is already tile data on disk, and the new tile
* data we have to will fit in the same space. The only
* aspect of this that is risky is that there could be
* more data to append to this strip before we are done
* depending on how we are getting called.
*/
if (!SeekOK(tif, td->td_stripoffset[strip])) {
TIFFErrorExt(tif->tif_clientdata, module,
"Seek error at scanline %lu",
(unsigned long)tif->tif_row);
return (0);
}
}
else
{
/*
* Seek to end of file, and set that as our location to
* write this strip.
*/
td->td_stripoffset[strip] = TIFFSeekFile(tif, 0, SEEK_END);
}
tif->tif_curoff = td->td_stripoffset[strip];
/*
* We are starting a fresh strip/tile, so set the size to zero.
*/
td->td_stripbytecount[strip] = 0;
}
if (!WriteOK(tif, data, cc)) {
TIFFErrorExt(tif->tif_clientdata, module, "%s: Write error at scanline %lu",
tif->tif_name, (unsigned long) tif->tif_row);
return (0);
TIFFErrorExt(tif->tif_clientdata, module, "Write error at scanline %lu",
(unsigned long) tif->tif_row);
return (0);
}
tif->tif_curoff += cc;
tif->tif_curoff = tif->tif_curoff+cc;
td->td_stripbytecount[strip] += cc;
return (1);
}
@ -723,3 +709,10 @@ TIFFSetWriteOffset(TIFF* tif, toff_t off)
}
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tif_zip.c,v 1.10 2006/03/16 12:38:24 dron Exp $ */
/* $Id: tif_zip.c,v 1.11.2.4 2010-06-08 18:50:43 bfriesen Exp $ */
/*
* Copyright (c) 1995-1997 Sam Leffler
@ -70,7 +70,8 @@ typedef struct {
z_stream stream;
int zipquality; /* compression level */
int state; /* state flags */
#define ZSTATE_INIT 0x1 /* zlib setup successfully */
#define ZSTATE_INIT_DECODE 0x01
#define ZSTATE_INIT_ENCODE 0x02
TIFFVGetMethod vgetparent; /* super-class method */
TIFFVSetMethod vsetparent; /* super-class method */
@ -90,11 +91,18 @@ ZIPSetupDecode(TIFF* tif)
static const char module[] = "ZIPSetupDecode";
assert(sp != NULL);
/* if we were last encoding, terminate this mode */
if (sp->state & ZSTATE_INIT_ENCODE) {
deflateEnd(&sp->stream);
sp->state = 0;
}
if (inflateInit(&sp->stream) != Z_OK) {
TIFFErrorExt(tif->tif_clientdata, module, "%s: %s", tif->tif_name, sp->stream.msg);
return (0);
} else {
sp->state |= ZSTATE_INIT;
sp->state |= ZSTATE_INIT_DECODE;
return (1);
}
}
@ -109,6 +117,10 @@ ZIPPreDecode(TIFF* tif, tsample_t s)
(void) s;
assert(sp != NULL);
if( (sp->state & ZSTATE_INIT_DECODE) == 0 )
tif->tif_setupdecode( tif );
sp->stream.next_in = tif->tif_rawdata;
sp->stream.avail_in = tif->tif_rawcc;
return (inflateReset(&sp->stream) == Z_OK);
@ -122,6 +134,8 @@ ZIPDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s)
(void) s;
assert(sp != NULL);
assert(sp->state == ZSTATE_INIT_DECODE);
sp->stream.next_out = op;
sp->stream.avail_out = occ;
do {
@ -158,11 +172,16 @@ ZIPSetupEncode(TIFF* tif)
static const char module[] = "ZIPSetupEncode";
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: %s", tif->tif_name, sp->stream.msg);
return (0);
} else {
sp->state |= ZSTATE_INIT;
sp->state |= ZSTATE_INIT_ENCODE;
return (1);
}
}
@ -177,6 +196,9 @@ ZIPPreEncode(TIFF* tif, tsample_t s)
(void) s;
assert(sp != NULL);
if( sp->state != ZSTATE_INIT_ENCODE )
tif->tif_setupencode( tif );
sp->stream.next_out = tif->tif_rawdata;
sp->stream.avail_out = tif->tif_rawdatasize;
return (deflateReset(&sp->stream) == Z_OK);
@ -191,6 +213,9 @@ ZIPEncode(TIFF* tif, tidata_t bp, tsize_t cc, tsample_t s)
ZIPState *sp = EncoderState(tif);
static const char module[] = "ZIPEncode";
assert(sp != NULL);
assert(sp->state == ZSTATE_INIT_ENCODE);
(void) s;
sp->stream.next_in = bp;
sp->stream.avail_in = cc;
@ -257,12 +282,12 @@ ZIPCleanup(TIFF* tif)
tif->tif_tagmethods.vgetfield = sp->vgetparent;
tif->tif_tagmethods.vsetfield = sp->vsetparent;
if (sp->state&ZSTATE_INIT) {
/* NB: avoid problems in the library */
if (tif->tif_mode == O_RDONLY)
inflateEnd(&sp->stream);
else
deflateEnd(&sp->stream);
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;
@ -279,7 +304,7 @@ ZIPVSetField(TIFF* tif, ttag_t tag, va_list ap)
switch (tag) {
case TIFFTAG_ZIPQUALITY:
sp->zipquality = va_arg(ap, int);
if (tif->tif_mode != O_RDONLY && (sp->state&ZSTATE_INIT)) {
if ( sp->state&ZSTATE_INIT_ENCODE ) {
if (deflateParams(&sp->stream,
sp->zipquality, Z_DEFAULT_STRATEGY) != Z_OK) {
TIFFErrorExt(tif->tif_clientdata, module, "%s: zlib error: %s",
@ -317,11 +342,22 @@ static const TIFFFieldInfo zipFieldInfo[] = {
int
TIFFInitZIP(TIFF* tif, int scheme)
{
static const char module[] = "TIFFInitZIP";
ZIPState* sp;
assert( (scheme == COMPRESSION_DEFLATE)
|| (scheme == COMPRESSION_ADOBE_DEFLATE));
/*
* Merge codec-specific tag information.
*/
if (!_TIFFMergeFieldInfo(tif, zipFieldInfo,
TIFFArrayCount(zipFieldInfo))) {
TIFFErrorExt(tif->tif_clientdata, module,
"Merging Deflate codec-specific tags failed");
return 0;
}
/*
* Allocate state block so tag methods have storage to record values.
*/
@ -335,10 +371,8 @@ TIFFInitZIP(TIFF* tif, int scheme)
sp->stream.data_type = Z_BINARY;
/*
* Merge codec-specific tag information and
* override parent get/set field methods.
* Override parent get/set field methods.
*/
_TIFFMergeFieldInfo(tif, zipFieldInfo, TIFFArrayCount(zipFieldInfo));
sp->vgetparent = tif->tif_tagmethods.vgetfield;
tif->tif_tagmethods.vgetfield = ZIPVGetField; /* hook for codec tags */
sp->vsetparent = tif->tif_tagmethods.vsetfield;
@ -369,10 +403,17 @@ TIFFInitZIP(TIFF* tif, int scheme)
(void) TIFFPredictorInit(tif);
return (1);
bad:
TIFFErrorExt(tif->tif_clientdata, "TIFFInitZIP",
TIFFErrorExt(tif->tif_clientdata, module,
"No space for ZIP state block");
return (0);
}
#endif /* ZIP_SUPORT */
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tiff.h,v 1.42 2005/12/23 15:10:45 dron Exp $ */
/* $Id: tiff.h,v 1.43.2.1 2010-06-08 18:50:43 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -43,7 +43,7 @@
* (http://partners.adobe.com/asn/developer/PDFS/TN/TIFF6.pdf)
*
* For Big TIFF design notes see the following link
* http://gdal.maptools.org/twiki/bin/view/libtiff/BigTIFFDesign
* http://www.remotesensing.org/libtiff/bigtiffdesign.html
*/
#define TIFF_VERSION 42
#define TIFF_BIGTIFF_VERSION 43
@ -61,25 +61,34 @@
* strings unsigned char*
*/
#ifndef HAVE_INT8
typedef signed char int8; /* NB: non-ANSI compilers may not grok */
#endif
#ifndef HAVE_UINT8
typedef unsigned char uint8;
#endif
#ifndef HAVE_INT16
typedef short int16;
#endif
#ifndef HAVE_UINT16
typedef unsigned short uint16; /* sizeof (uint16) must == 2 */
#endif
#if SIZEOF_INT == 4
#ifndef HAVE_INT32
typedef int int32;
#endif
#ifndef HAVE_UINT32
typedef unsigned int uint32; /* sizeof (uint32) must == 4 */
#endif
#elif SIZEOF_LONG == 4
#ifndef HAVE_INT32
typedef long int32;
#endif
#ifndef HAVE_UINT32
typedef unsigned long uint32; /* sizeof (uint32) must == 4 */
#endif
#endif
/* For TIFFReassignTagToIgnore */
enum TIFFIgnoreSense /* IGNORE tag table */
@ -645,3 +654,10 @@ typedef enum {
#endif /* _TIFF_ */
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -9,13 +9,28 @@
#define _TIFFCONF_
/* Define to 1 if the system has the type `int16'. */
/* #undef HAVE_INT16 */
#define HAVE_INT16
/* Define to 1 if the system has the type `int32'. */
/* #undef HAVE_INT32 */
#define HAVE_INT32
/* Define to 1 if the system has the type `int8'. */
/* #undef HAVE_INT8 */
#define HAVE_INT8
/* Define to 1 if the system has the type `int64'. */
#define HAVE_INT64
/* Define to 1 if the system has the type `uint16'. */
#define HAVE_UINT16
/* Define to 1 if the system has the type `uint32'. */
#define HAVE_UINT32
/* Define to 1 if the system has the type `uint8'. */
#define HAVE_UINT8
/* Define to 1 if the system has the type `uint64'. */
#define HAVE_UINT64
/* The size of a `int', as computed by sizeof. */
#define SIZEOF_INT 4
@ -98,4 +113,17 @@
#define PHOTOSHOP_SUPPORT
#define IPTC_SUPPORT
#define int8 signed char
#define uint8 unsigned char
#define int16 short
#define uint16 unsigned short
#ifdef PLATFORM_WIN32
#define int32 long
#define uint32 unsigned long
#else
#define int32 int
#define uint32 int unsigned
#endif
#endif /* _TIFFCONF_ */

View file

@ -41,6 +41,9 @@
/* Support JPEG compression (requires IJG JPEG library) */
#undef JPEG_SUPPORT
/* Support JBIG compression (requires JBIG-KIT library) */
#undef JBIG_SUPPORT
/* Support LogLuv high dynamic range encoding */
#undef LOGLUV_SUPPORT

View file

@ -0,0 +1,116 @@
/*
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_
/* Define to 1 if the system has the type `int16'. */
/* #undef HAVE_INT16 */
/* Define to 1 if the system has the type `int32'. */
/* #undef HAVE_INT32 */
/* Define to 1 if the system has the type `int8'. */
/* #undef HAVE_INT8 */
/* The size of a `int', as computed by sizeof. */
#define SIZEOF_INT 4
/* The size of a `long', as computed by sizeof. */
#define SIZEOF_LONG 4
/* Signed 64-bit type formatter */
#define TIFF_INT64_FORMAT "%I64d"
/* Signed 64-bit type */
#define TIFF_INT64_T signed __int64
/* Unsigned 64-bit type formatter */
#define TIFF_UINT64_FORMAT "%I64u"
/* Unsigned 64-bit type */
#define TIFF_UINT64_T unsigned __int64
/* Compatibility stuff. */
/* Define as 0 or 1 according to the floating point format suported by the
machine */
#define HAVE_IEEEFP 1
/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */
#define HOST_FILLORDER FILLORDER_LSB2MSB
/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian
(Intel) */
#define HOST_BIGENDIAN 0
/* Support CCITT Group 3 & 4 algorithms */
#define CCITT_SUPPORT 1
/* Support JPEG compression (requires IJG JPEG library) */
/* #undef JPEG_SUPPORT */
/* Support LogLuv high dynamic range encoding */
#define LOGLUV_SUPPORT 1
/* Support LZW algorithm */
#define LZW_SUPPORT 1
/* Support NeXT 2-bit RLE algorithm */
#define NEXT_SUPPORT 1
/* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation
fails with unpatched IJG JPEG library) */
/* #undef OJPEG_SUPPORT */
/* Support Macintosh PackBits algorithm */
#define PACKBITS_SUPPORT 1
/* Support Pixar log-format algorithm (requires Zlib) */
/* #undef PIXARLOG_SUPPORT */
/* Support ThunderScan 4-bit RLE algorithm */
#define THUNDER_SUPPORT 1
/* Support Deflate compression */
/* #undef ZIP_SUPPORT */
/* Support strip chopping (whether or not to convert single-strip uncompressed
images to mutiple strips of ~8Kb to reduce memory usage) */
#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP
/* Enable SubIFD tag (330) support */
#define 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. */
#define DEFAULT_EXTRASAMPLE_AS_ALPHA 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
/*
* 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_ */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -0,0 +1,136 @@
/* $Id: tiffconf.wince.h,v 1.1.2.2 2010-06-08 18:50:43 bfriesen Exp $ */
/*
* Windows CE platform tiffconf.wince.h
* Created by Mateusz Loskot (mateusz@loskot.net)
*
* NOTE: Requires WCELIBCEX library with wceex_* functions,
* It's an extension to C library on Windows CE platform.
* For example, HAVE_STDIO_H definition indicates there are
* following files available:
* stdio.h - from Windows CE / Windows Mobile SDK
* wce_stdio.h - from WCELIBCEX library
*/
/*
Configuration defines for installed libtiff.
This file maintained for backward compatibility. Do not use definitions
from this file in your programs.
*/
#ifndef _WIN32_WCE
# error This version of tif_config.h header is dedicated for Windows CE platform!
#endif
#ifndef _TIFFCONF_
#define _TIFFCONF_
/* Define to 1 if the system has the type `int16'. */
/* #undef HAVE_INT16 */
/* Define to 1 if the system has the type `int32'. */
/* #undef HAVE_INT32 */
/* Define to 1 if the system has the type `int8'. */
/* #undef HAVE_INT8 */
/* The size of a `int', as computed by sizeof. */
#define SIZEOF_INT 4
/* The size of a `long', as computed by sizeof. */
#define SIZEOF_LONG 4
/* Signed 64-bit type formatter */
#define TIFF_INT64_FORMAT "%I64d"
/* Signed 64-bit type */
#define TIFF_INT64_T signed __int64
/* Unsigned 64-bit type formatter */
#define TIFF_UINT64_FORMAT "%I64u"
/* Unsigned 64-bit type */
#define TIFF_UINT64_T unsigned __int64
/* Compatibility stuff. */
/* Define as 0 or 1 according to the floating point format suported by the
machine */
#define HAVE_IEEEFP 1
/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */
#define HOST_FILLORDER FILLORDER_LSB2MSB
/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian
(Intel) */
#define HOST_BIGENDIAN 0
/* Support CCITT Group 3 & 4 algorithms */
#define CCITT_SUPPORT 1
/* Support JPEG compression (requires IJG JPEG library) */
/* #undef JPEG_SUPPORT */
/* Support LogLuv high dynamic range encoding */
#define LOGLUV_SUPPORT 1
/* Support LZW algorithm */
#define LZW_SUPPORT 1
/* Support NeXT 2-bit RLE algorithm */
#define NEXT_SUPPORT 1
/* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation
fails with unpatched IJG JPEG library) */
/* #undef OJPEG_SUPPORT */
/* Support Macintosh PackBits algorithm */
#define PACKBITS_SUPPORT 1
/* Support Pixar log-format algorithm (requires Zlib) */
/* #undef PIXARLOG_SUPPORT */
/* Support ThunderScan 4-bit RLE algorithm */
#define THUNDER_SUPPORT 1
/* Support Deflate compression */
/* #undef ZIP_SUPPORT */
/* Support strip chopping (whether or not to convert single-strip uncompressed
images to mutiple strips of ~8Kb to reduce memory usage) */
#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP
/* Enable SubIFD tag (330) support */
#define 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. */
#define DEFAULT_EXTRASAMPLE_AS_ALPHA 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
/*
* 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_ */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tiffio.h,v 1.50 2006/03/21 16:37:51 dron Exp $ */
/* $Id: tiffio.h,v 1.56.2.4 2010-06-08 18:50:43 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -58,14 +58,15 @@ typedef struct tiff TIFF;
* 32-bit file offsets being the most important, and to ensure
* that it is unsigned, rather than signed.
*/
typedef uint32 ttag_t; /* directory tag */
typedef uint16 tdir_t; /* directory index */
typedef uint16 tsample_t; /* sample number */
typedef uint32 tstrip_t; /* strip number */
typedef uint32 ttile_t; /* tile number */
typedef int32 tsize_t; /* i/o size in bytes */
typedef void* tdata_t; /* image data ref */
typedef uint32 toff_t; /* file offset */
typedef uint32 ttag_t; /* directory tag */
typedef uint16 tdir_t; /* directory index */
typedef uint16 tsample_t; /* sample number */
typedef uint32 tstrile_t; /* strip or tile number */
typedef tstrile_t tstrip_t; /* strip number */
typedef tstrile_t ttile_t; /* tile number */
typedef int32 tsize_t; /* i/o size in bytes */
typedef void* tdata_t; /* image data ref */
typedef uint32 toff_t; /* file offset */
#if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32))
#define __WIN32__
@ -96,10 +97,6 @@ typedef HFILE thandle_t; /* client data handle */
typedef void* thandle_t; /* client data handle */
#endif /* USE_WIN32_FILEIO */
#ifndef NULL
# define NULL (void *)0
#endif
/*
* Flags to pass to TIFFPrintDirectory to control
* printing of data structures that are potentially
@ -191,35 +188,36 @@ typedef void (*tileSeparateRoutine)
* 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);
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; /* put decoded strip/tile */
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 */
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 */
int row_offset;
int col_offset;
int row_offset;
int col_offset;
};
/*
@ -253,6 +251,10 @@ typedef struct {
#define LOGLUV_PUBLIC 1
#endif
#if !defined(__GNUC__) && !defined(__attribute__)
# define __attribute__(x) /*nothing*/
#endif
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
@ -349,6 +351,8 @@ extern int TIFFReadCustomDirectory(TIFF*, toff_t, const TIFFFieldInfo[],
size_t);
extern int TIFFReadEXIFDirectory(TIFF*, toff_t);
extern tsize_t TIFFScanlineSize(TIFF*);
extern tsize_t TIFFOldScanlineSize(TIFF*);
extern tsize_t TIFFNewScanlineSize(TIFF*);
extern tsize_t TIFFRasterScanlineSize(TIFF*);
extern tsize_t TIFFStripSize(TIFF*);
extern tsize_t TIFFRawStripSize(TIFF*, tstrip_t);
@ -433,10 +437,10 @@ extern TIFF* TIFFClientOpen(const char*, const char*,
TIFFMapFileProc, TIFFUnmapFileProc);
extern const char* TIFFFileName(TIFF*);
extern const char* TIFFSetFileName(TIFF*, const char *);
extern void TIFFError(const char*, const char*, ...);
extern void TIFFErrorExt(thandle_t, const char*, const char*, ...);
extern void TIFFWarning(const char*, const char*, ...);
extern void TIFFWarningExt(thandle_t, const char*, const char*, ...);
extern void TIFFError(const char*, const char*, ...) __attribute__((format (printf,2,3)));
extern void TIFFErrorExt(thandle_t, const char*, const char*, ...) __attribute__((format (printf,3,4)));
extern void TIFFWarning(const char*, const char*, ...) __attribute__((format (printf,2,3)));
extern void TIFFWarningExt(thandle_t, const char*, const char*, ...) __attribute__((format (printf,3,4)));
extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler);
extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt);
extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler);
@ -513,3 +517,10 @@ extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32,
#endif /* _TIFFIO_ */
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tiffio.hxx,v 1.1 2004/11/21 16:12:08 dron Exp $ */
/* $Id: tiffio.hxx,v 1.1.2.1 2010-06-08 18:50:43 bfriesen Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -40,3 +40,10 @@ extern TIFF* TIFFStreamOpen(const char*, std::istream *);
#endif /* _TIFFIO_HXX_ */
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c++
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
/* $Id: tiffiop.h,v 1.46 2006/03/16 12:22:27 dron Exp $ */
/* $Id: tiffiop.h,v 1.51.2.7 2011-03-21 21:09:19 fwarmerdam Exp $ */
/*
* Copyright (c) 1988-1997 Sam Leffler
@ -57,6 +57,17 @@ extern void *lfind(const void *, const void *, size_t *, size_t,
int (*)(const void *, const void *));
#endif
/*
Libtiff itself does not require a 64-bit type, but bundled TIFF
utilities may use it.
*/
#ifndef HAVE_INT64
#if !defined(__xlC__) && !defined(__xlc__) // Already defined there (#2301)
typedef TIFF_INT64_T int64;
typedef TIFF_UINT64_T uint64;
#endif
#endif
#include "tiffio.h"
#include "tif_dir.h"
@ -97,29 +108,35 @@ struct tiff {
int tif_fd; /* open file descriptor */
int tif_mode; /* open mode (O_*) */
uint32 tif_flags;
#define TIFF_FILLORDER 0x0003 /* natural bit fill order for machine */
#define TIFF_DIRTYHEADER 0x0004 /* header must be written on close */
#define TIFF_DIRTYDIRECT 0x0008 /* current directory must be written */
#define TIFF_BUFFERSETUP 0x0010 /* data buffers setup */
#define TIFF_CODERSETUP 0x0020 /* encoder/decoder setup done */
#define TIFF_BEENWRITING 0x0040 /* written 1+ scanlines to file */
#define TIFF_SWAB 0x0080 /* byte swap file information */
#define TIFF_NOBITREV 0x0100 /* inhibit bit reversal logic */
#define TIFF_MYBUFFER 0x0200 /* my raw data buffer; free on close */
#define TIFF_ISTILED 0x0400 /* file is tile, not strip- based */
#define TIFF_MAPPED 0x0800 /* file is mapped into memory */
#define TIFF_POSTENCODE 0x1000 /* need call to postencode routine */
#define TIFF_INSUBIFD 0x2000 /* currently writing a subifd */
#define TIFF_UPSAMPLED 0x4000 /* library is doing data up-sampling */
#define TIFF_STRIPCHOP 0x8000 /* enable strip chopping support */
#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 */
toff_t tif_diroff; /* file offset of current directory */
toff_t tif_nextdiroff; /* file offset of following directory */
toff_t* tif_dirlist; /* list of offsets to already seen */
/* directories to prevent IFD looping */
tsize_t 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 */
TIFFHeader tif_header; /* file's header block */
const int* tif_typeshift; /* data type shift counts */
const long* tif_typemask; /* data type masks */
@ -164,7 +181,8 @@ struct tiff {
tsize_t tif_rawcc; /* bytes unread from raw buffer */
/* memory-mapped file support */
tidata_t tif_base; /* base of mapped file */
toff_t tif_size; /* size of mapped file region (bytes) */
toff_t tif_size; /* size of mapped file region (bytes)
FIXME: it should be tsize_t */
TIFFMapFileProc tif_mapproc; /* map file method */
TIFFUnmapFileProc tif_unmapproc;/* unmap file method */
/* input/output callback methods */
@ -222,10 +240,15 @@ struct tiff {
#endif
/* NB: the uint32 casts are to silence certain ANSI-C compilers */
#define TIFFhowmany(x, y) ((((uint32)(x))+(((uint32)(y))-1))/((uint32)(y)))
#define TIFFhowmany(x, y) (((uint32)x < (0xffffffff - (uint32)(y-1))) ? \
((((uint32)(x))+(((uint32)(y))-1))/((uint32)(y))) : \
0U)
#define TIFFhowmany8(x) (((x)&0x07)?((uint32)(x)>>3)+1:(uint32)(x)>>3)
#define TIFFroundup(x, y) (TIFFhowmany(x,y)*(y))
/* Safe multiply which returns zero if there is an integer overflow */
#define TIFFSafeMultiply(t,v,m) ((((t)m != (t)0) && (((t)((v*m)/m)) == (t)v)) ? (t)(v*m) : (t)0)
#define TIFFmax(A,B) ((A)>(B)?(A):(B))
#define TIFFmin(A,B) ((A)<(B)?(A):(B))
@ -273,6 +296,7 @@ extern TIFFErrorHandlerExt _TIFFwarningHandlerExt;
extern TIFFErrorHandlerExt _TIFFerrorHandlerExt;
extern tdata_t _TIFFCheckMalloc(TIFF*, size_t, size_t, const char*);
extern tdata_t _TIFFCheckRealloc(TIFF*, tdata_t, size_t, size_t, const char*);
extern int TIFFInitDumpMode(TIFF*, int);
#ifdef PACKBITS_SUPPORT
@ -321,3 +345,10 @@ extern TIFFCodec _TIFFBuiltinCODECS[];
#endif /* _TIFFIOP_ */
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -1,4 +1,4 @@
#define TIFFLIB_VERSION_STR "LIBTIFF, Version 3.8.2\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
#define TIFFLIB_VERSION_STR "LIBTIFF, Version 3.9.5\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 20060323
#define TIFFLIB_VERSION 20110409

View file

@ -171,3 +171,10 @@ static struct {
{ (float)0.016994, 31, 16237 },
{ (float)0.023659, 21, 16268 },
};
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/

View file

@ -5,11 +5,32 @@
struct tiff;
#include <plugin/tif/lib/tiff.h>
#include <plugin/tif/lib/tiffio.h>
#include <plugin/tif/lib/tiffiop.h>
#undef int8
#undef uint8
#undef int16
#undef uint16
#undef int32
#undef uint32
#undef HAVE_INT8
#undef HAVE_INT16
#undef HAVE_INT32
#undef HAVE_UINT8
#undef HAVE_UINT16
#undef HAVE_UINT32
NAMESPACE_UPP
struct tiff *TIFFStreamOpen(const char *filename, const char *mode, Stream *stream, bool destruct = false);
struct tiff *TIFFFileStreamOpen(const char *filename, const char *mode);
//struct tiff* TIFFWrapOpen(const char*, const char*);
//int TIFFWrapGetField(::tiff* tif_data, uint32 tag, ...);
class TIFRaster : public StreamRaster {
public:
struct Data;

View file

@ -35,8 +35,6 @@ file
lib\Makefile.lcc,
lib\Makefile.vc,
lib\ojpeg.patch,
lib\Readme,
lib\Release-date,
lib\t4.h,
lib\tif_aux.c,
lib\tif_close.c,
@ -89,6 +87,5 @@ file
lib\tiffiop.h,
lib\tiffvers.h,
lib\uvcode.h,
lib\Version,
end readonly separator;

View file

@ -1,13 +1,13 @@
#include <Draw/Draw.h>
#include "tif.h"
#define int8 tif_int8
#define int32 tif_int32
#define uint32 tif_uint32
#include <plugin/tif/lib/tiffio.h>
#include <plugin/tif/lib/tiffiop.h>
#undef int32
#undef uint32
#ifdef PLATFORM_WIN32
#define tif_int32 long
#define tif_uint32 unsigned long
#else
#define tif_int32 int
#define tif_uint32 unsigned int
#endif
#define LLOG(x) // LOG(x)
@ -522,6 +522,17 @@ struct ::tiff *TIFFFileStreamOpen(const char *filename, const char *mode)
return NULL;
return TIFFStreamOpen(filename, mode, -fs, true);
}
/*
struct ::tiff* TIFFWrapOpen(const char *filename, const char *mode){
return ::TIFFOpen(filename, mode);
}
int TIFFWrapGetField(::tiff* tif_data, uint32 tag, ...){
va_list ap;
return ::TIFFGetField(tif_data, tag, ap);
}
*/
struct ::tiff *TIFFStreamOpen(const char *filename, const char *mode, Stream *stream, bool destruct)
{